我期待删除,上面写着“产品成功添加到购物车”后,我将项目添加到购物车的措辞和地区。 我只是希望这是什么,没有消息和消息没有空间。
下面是该网站: http://www.tinytreasurehunts.com的代码是woocommerece-的functions.php
有什么想法吗?
我期待删除,上面写着“产品成功添加到购物车”后,我将项目添加到购物车的措辞和地区。 我只是希望这是什么,没有消息和消息没有空间。
下面是该网站: http://www.tinytreasurehunts.com的代码是woocommerece-的functions.php
有什么想法吗?
在PHP层面解决这个问题,下面的模板文件(结构)添加到您的主题:
/wp-content/themes/YOUR-THEME/woocommerce/shop/messages.php
:
<?php
/**
* Show messages
*
* @author brasofilo
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! $messages ) return;
foreach ( $messages as $message ) :
// The message does not contain the "add to cart" string, so print the message
// http://stackoverflow.com/q/4366730/1287812
if ( strpos( $message, 'added to your cart' ) === false ) :
?>
<div class="woocommerce-message"><?php echo wp_kses_post( $message ); ?></div>
<?php
endif;
endforeach;
参见: 模板结构+压倒一切的模板,通过一个主题
使用以下之一:
旧版本的
$woocommerce->clear_messages();
2.3版
wc_clear_notices();
使用CSS和显示设置为none的ID或关联类。
.page-id-522 .woocommerce_message {
display: none;
}
这是特定于页面ID 522确保这不会也像躲信用卡被拒等其他有用信息
只需使用简单的CSS:
.single-product .woocommerce-message {
display: none !important;
}
此代码添加到您的主题functions.php文件。 它只会移除该消息。 它应该触发刚刚页面,其中很可能发生。
function remove_added_to_cart_notice()
{
$notices = WC()->session->get('wc_notices', array());
foreach( $notices['success'] as $key => &$notice){
if( strpos( $notice, 'has been added' ) !== false){
$added_to_cart_key = $key;
break;
}
}
unset( $notices['success'][$added_to_cart_key] );
WC()->session->set('wc_notices', $notices);
}
add_action('woocommerce_before_single_product','remove_added_to_cart_notice',1);
add_action('woocommerce_shortcode_before_product_cat_loop','remove_added_to_cart_notice',1);
add_action('woocommerce_before_shop_loop','remove_added_to_cart_notice',1);
我在贴这个答案从我自己的答案删除/隐藏Woocommerce添加到购物车消息,但保留/显示优惠券信息应用
更新WooCommerce版本2.1.6
该模板位于一个新的目录和文件。 相同的代码和上述溶液中。
/wp-content/plugins/woocommerce/templates/notices/success.php
使用.POST .woocommerce_message {显示:无;}在你的主题文件的末尾或者在你的子主题。