结帐页面上的返回购物车按钮 [英] Back to cart button on checkout page

查看:106
本文介绍了结帐页面上的返回购物车按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有解决方案在WooCommerce结帐页面上显示返回购物车 按钮?

Is there any solution to display a "back to shopping cart" button on the WooCommerce checkout page?

实际上只有一个完整的订单按钮,但是如果用户要更正其订单,我们需要一个后退按钮。

Actually there is only a complete order button, but we need a back button, if a user want to correct his order.

谢谢。

推荐答案

是的,可以在结帐时显示带有返回购物车按钮的自定义通知页。这是 woocommerce_before_checkout_form 操作挂钩中的自定义挂钩函数:

Yes it's possible to display a custom notice with a "Back to Cart" button on checkout page. Here is that custom hooked function in woocommerce_before_checkout_form action hook:

add_action( 'woocommerce_before_checkout_form', 'return_to_cart_notice_button' );
function return_to_cart_notice_button(){

    // HERE Type your displayed message and text button
    $message = __('Go back to the Cart page', 'woocommerce');
    $button_text = __('Back to 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' );
}

代码进入活动子主题(或主题)的function.php文件

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

代码已经过测试并且可以正常工作。

The code is tested and works.

这篇关于结帐页面上的返回购物车按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆