所以我使用条件寿代码片断从这个例子 ,与此线程代码成功:
但它的更新我的WordPress核心和WooCommerce插件后不再工作。
if ( is_product() && has_term( 'sample-category', 'product_cat' ) ){
add_action( 'woocommerce_after_add_to_cart_button', 'add_custom_button', 10, 0 );
function add_custom_button() {
global $products;
$product_link = get_permalink( $products->id );
$sample_link = substr($product_link, 0, -1) . '-swatch-card/';
echo '<a class="button alt btn-sample" href="' . esc_url( $sample_link ) .'">' . __( "Order a Sample", "my_theme_slug" ) . '</a>';
}
}
儿童插件仍然在function.php文件正确的代码。
我如何能解决这个问题吗?
谢谢