【发布时间】:2018-11-05 01:50:52
【问题描述】:
我在我的网站中设置了一些 php 代码以限制最小订单量,因此,我还添加了一个“返回购物车”按钮以显示在“结帐”页面中以改善用户体验(基于在这个例子中:Back to cart button on checkout page)。问题是,当客户被重定向到“谢谢”页面时,当订单有效(匹配最小订单数量)时,“返回购物车”按钮不断出现,在这个页面中没有任何意义,因为图片显示: thank you message with get back to cart button
有什么方法可以阻止它出现在感谢页面中,并在结帐页面中保持其行为?
到目前为止,在我的子主题中添加到函数文件中的 PHP 代码是:
// back to cart button
add_action ( 'woocommerce_checkout_process', 'return_to_cart_notice_button', 20 );
function return_to_cart_notice_button(){
//Set the messages for notice and button
$message = __( 'Do you want to go back to shopping cart?', 'woocommerce' );
$button_text = __( 'Go to shopping cart', 'woocommerce' );
$cart_link = WC()->cart->get_cart_url();
wc_add_notice( '<a href="' . $cart_link . '" class="button wc-forward">' . $button_text . '</a>' . $message, 'notice' );
}
【问题讨论】:
标签: php wordpress woocommerce checkout hook-woocommerce