Back to cart button on checkout page

巧了我就是萌 提交于 2019-12-11 06:07:04

问题


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.

Thanks.


回答1:


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' );
}

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.



来源:https://stackoverflow.com/questions/42491380/back-to-cart-button-on-checkout-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!