【发布时间】:2016-08-25 02:25:13
【问题描述】:
所以我使用example 中的代码片段的条件,this thread code 成功:
但是更新我的 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 文件中仍然有正确的代码。
请问我该如何解决这个问题?
谢谢
【问题讨论】:
标签: php wordpress woocommerce categories product