因此,我正在建立一个外部链接产品(附属公司),我一直在试图删除添加到购物车从网站上没有运气。我尝试了许多解决方案,但都没有奏效。要么弹出html 500,要么破坏页面,要么根本不起作用。还有一些插件不起作用。我有什么办法可以完成吗?
我使用的主题是Exzo:
https://themeforest.net/item/modern-electronics-ecommerce-wordpress-woocommerce-theme-exzo/19356950
我尝试的解决方案:
// Replace add to cart button by a linked button to the product in Shop and archives pages
add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_loop_add_to_cart_button', 10, 2 );
function replace_loop_add_to_cart_button( $button, $product ) {
// Not needed for variable products
if( $product->is_type( 'variable' ) ) return $button;
// Button text here
$button_text = __( "View product", "woocommerce" );
return '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';
}
然后
add_filter( âwoocommerce_is_purchasableâ, false );
而且
function WpBlog() {
remove_action( âwoocommerce_after_shop_loop_itemâ, âwoocommerce_template_loop_add_to_cartâ);
remove_action( âwoocommerce_single_product_summaryâ, âwoocommerce_template_single_add_to_cartâ);
return WooCommerce::instance();
}
和woocommerce。php不需要900多行代码
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );