删除添加到购物车通知并更改 Woocommerce 中的 "add to cart" 按钮
Remove add to cart notice and change "add to cart" button in Woocommerce
如何从购物车页面删除 "has been added to your cart" 文本 以及如何替换数量并使用自定义按钮(我的图片)添加到购物车按钮使其看起来像这样
这是现在的样子:。
我在 child style.css 中使用了 来删除购物车页面中的文本,但它不起作用...
这是我的 child style.css 文件中的完整代码(我是否遗漏了什么):
.woocommerce-checkout .woocommerce .woocommerce-message {
display:none !important;}
您可以将 PHP 片段放在子主题 functions.php 文件的底部(如果有的话,放在“?>”之前)。
删除消息:
add_filter( 'wc_add_to_cart_message_html', '__return_null' );
编辑消息:
add_filter( 'wc_add_to_cart_message_html','msg_custom_add_to_cart_message' );
function msg_custom_add_to_cart_message() {
global $woocommerce;
$return_to = get_permalink(woocommerce_get_page_id('shop'));
$message = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
return $message;
}
有多种方式:
1) 使用PHP (最佳方式):
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
代码进入您的活动子主题(或活动主题)的 function.php 文件。
2) 使用CSS (不推荐:因为它在购物车页面上,它将隐藏所有其他通知):
.woocommerce-cart .woocommerce .woocommerce-message {
display:none !important;
}
进入您的活动子主题(或活动主题)的 styles.css 文件。
要更改“添加到购物车”按钮的样式,请尝试以下 CSS 规则:
.button.alt.single_add_to_cart_button {
background-color: #36ae33 !important;
color: #ffffff !important;
}
进入您的活动子主题(或活动主题)的 styles.css 文件。
您将不得不添加一些其他规则来更改,字体属性和填充…
如何从购物车页面删除 "has been added to your cart" 文本
这是现在的样子:
我在 child style.css 中使用了
这是我的 child style.css 文件中的完整代码(我是否遗漏了什么):
.woocommerce-checkout .woocommerce .woocommerce-message {
display:none !important;}
您可以将 PHP 片段放在子主题 functions.php 文件的底部(如果有的话,放在“?>”之前)。
删除消息:
add_filter( 'wc_add_to_cart_message_html', '__return_null' );
编辑消息:
add_filter( 'wc_add_to_cart_message_html','msg_custom_add_to_cart_message' );
function msg_custom_add_to_cart_message() {
global $woocommerce;
$return_to = get_permalink(woocommerce_get_page_id('shop'));
$message = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
return $message;
}
有多种方式:
1) 使用PHP (最佳方式):
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
代码进入您的活动子主题(或活动主题)的 function.php 文件。
2) 使用CSS (不推荐:因为它在购物车页面上,它将隐藏所有其他通知):
.woocommerce-cart .woocommerce .woocommerce-message {
display:none !important;
}
进入您的活动子主题(或活动主题)的 styles.css 文件。
要更改“添加到购物车”按钮的样式,请尝试以下 CSS 规则:
.button.alt.single_add_to_cart_button {
background-color: #36ae33 !important;
color: #ffffff !important;
}
进入您的活动子主题(或活动主题)的 styles.css 文件。
您将不得不添加一些其他规则来更改,字体属性和填充…