php - 我如何更改 WooCommerce 中的默认添加到购物车按钮?
问题描述
这就是一切的样子
我想为外部产品卡添加一个新的“add_to_cart”按钮模板,而不影响内部产品卡。但是当我添加时,旧的仍然存在。我的代码有什么问题?
这是我在functions.php中的代码
function loop_custom_variable_products() {
global $product;
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 30 ); // Remove price
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 30); // remove add to cart
remove_action( 'woocommerce_after_shop_loop_item', 'loop_variations_custom_buttons_and_prices', 30 ); // Add prices with custom buttons
}
add_action( 'init', 'loop_custom_variable_products' );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_variable_add_to_cart1', 30 );
//add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_variable_add_to_cart1', 30);
function woocommerce_variable_add_to_cart1(){
//... some code for new add to card style
}
解决方案
推荐阅读
- python - 根据具有子字符串的特定值删除字典项
- sql - 如何修复:SQLSTATE [42S22]:找不到列:1054 Unknown column 'create_at
- python - ModelForm save() 得到了一个意外的关键字参数“提交”
- java - 大小为 2N 的数组中的 N 个重复元素
- php - 检查文件是否存在在在线主机上的 laravel 中不起作用
- python - 在这种情况下我应该使用哪个图像质量指标(二进制分割图像)?
- java - 从 url 获取文件名时如何修复空名称
- java - Java多线程在数据库中插入数百万条记录
- android - FIrebase 测试实验室应用程序仅显示没有互联网页面
- java - Spring Boot Unit Test MockMVC 会抛出 BadRequest,尽管它存在 API