1
所以我使用條件壽代碼片斷從這個example後的成功合作,與this thread code:WooCommerce - 條件has_term已經不更新
但它更新我的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文件中有正確的代碼。
我該如何解決這個問題?
感謝