[英]How to replace Woocommerce “Add to Cart” Button with a Cart Icon and Cart Icon along with custom text?
Using the below code I was able to change the Text of "Add to Cart" button 使用以下代码,我可以更改“添加到购物车”按钮的文本
add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 +
function woo_custom_single_add_to_cart_text() {
return __( 'My Button Text', 'woocommerce' );
}
Similarly, is it possible to replace Add to Cart Button with a Cart Icon or a Cart Icon with Custom Text? 同样,是否可以将“添加到购物车”按钮替换为购物车图标或将“自定义文本”替换为购物车图标?
不确定我的答案是否是最佳实践,但可以肯定的是,到目前为止我最容易找到它,只需转到Woocommerce文件夹并找到“ add-to-cart.php”,然后在其中; s循环只需替换esc_html( $product->add_to_cart_text() )
sprintf('<i class="fa fa-shopping-basket"></i>')
esc_html( $product->add_to_cart_text() )
-如果您只想添加购物篮图标,只需将html放进去。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.