Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除“;“添加到购物车中”;及;购物车更新";关于WooCommerce结帐的信息_Woocommerce - Fatal编程技术网

删除“;“添加到购物车中”;及;购物车更新";关于WooCommerce结帐的信息

删除“;“添加到购物车中”;及;购物车更新";关于WooCommerce结帐的信息,woocommerce,Woocommerce,我在网上找到了下面的代码,效果很好。它创建一个“一页”签出。唯一的问题是,在更改产品数量时,签出时会显示“购物车已更新”消息。我需要把它取下来 下面是我用来获取“一页”签出的代码: // creates a combined cart and checkout page add_action( 'woocommerce_before_checkout_form', 'one_page_checkout', 5 ); function one_page_checkout() { if ( is_w

我在网上找到了下面的代码,效果很好。它创建一个“一页”签出。唯一的问题是,在更改产品数量时,签出时会显示“购物车已更新”消息。我需要把它取下来

下面是我用来获取“一页”签出的代码:

// creates a combined cart and checkout page
add_action( 'woocommerce_before_checkout_form', 'one_page_checkout', 5 );
function one_page_checkout() {
if ( is_wc_endpoint_url( 'order-received' ) ) return; ?>
<div class="one-page-checkout-cart"><?php echo do_shortcode('[woocommerce_cart]'); ?></div>
<?php
}

// on empty cart when on checkout, redirect to home page
add_action( 'template_redirect', 'redirect_on_empty_checkout' );
function redirect_on_empty_checkout() {
if ( is_cart() && is_checkout() && 0 == WC()->cart->get_cart_contents_count() && ! is_wc_endpoint_url( 'order-pay' ) && ! is_wc_endpoint_url( 'order-received' ) ) {
wp_safe_redirect( 'shop' );
exit; } }


// removes coupon field form checkout, do not use CSS for this
add_action( 'woocommerce_before_checkout_form', 'remove_checkout_coupon_form_for_one_page_checkout', 9 );
function remove_checkout_coupon_form_for_one_page_checkout(){
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
}
请帮助将“购物车更新”消息从签出中删除,同时将“添加到购物车”消息保留在产品页面上。

要删除自定义签出页面上的“购物车更新”或“{$product_name}已添加到购物车”消息,请使用以下命令:

add_filter( 'woocommerce_add_message', 'unset_atc_html_from_one_page_checkout' );
function unset_atc_html_from_one_page_checkout() {
global $woocommerce;
if (is_checkout() ) {
add_filter('woocommerce_add_message', '__return_false');
}}
add_filter( 'woocommerce_add_message', 'remove_cart_updated_message_from_checkout' );
function remove_cart_updated_message_from_checkout( $message ) {
    if ( is_checkout() && ( strpos($message, 'Cart updated') !== false
    || strpos($message, 'has been added to your cart') !== false ) ) {
        return false;
    }
    return $message;
}

代码进入活动子主题(或活动主题)的function.php文件。已测试且有效。

但不起作用。尝试了三个不同的主题,只是为了确保。@KevinAronsson对我来说,它适用于5个不同的主题…我总是测试我发布的代码。好吧,在storefront、genesis或astra上没有干净的安装。