Back to cart button on checkout page

2019-07-26 06:01发布

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条回答
劳资没心,怎么记你
2楼-- · 2019-07-26 06:23

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.

查看更多
登录 后发表回答