skip to Main Content

In WooCommerce, in my Storefront child theme, I edited the code in proceed-to-checkout-button.php to change the wording from "Proceed to checkout" to "Checkout":

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
?>

<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button wc-forward">
    <?php esc_html_e( 'Checkout', 'woocommerce' ); ?>
</a> 

But when the user changes product quantity in the cart page, then the button text goes back to default "Proceed to checkout".

Is there a filter or where to edit this updated text?


EDIT – Problem Solved

The issue was related to a specific cart option in WooCommerce Better Usability pro plugin where the option "Display text while updating cart automatically" requires to be disabled (unselected).

2

Answers


  1. This file proceed-to-checkout-button.php is calling from the function woocommerce_button_proceed_to_checkout() hooked to action ‘woocommerce_proceed_to_checkout’ – you can find it in woocommerce/includes/wc-template-hooks.php

    So, You can override the function woocommerce_button_proceed_to_checkout() – just add this to your functions.php

    /**
    *   Change Proceed To Checkout Text in WooCommerce
    *   Add this code in your active theme functions.php file
    **/
    function woocommerce_button_proceed_to_checkout() {
        
           $new_checkout_url = WC()->cart->get_checkout_url();
           ?>
           <a href="<?php echo $new_checkout_url; ?>" class="checkout-button button alt wc-forward">
           
           <?php _e( 'Go to Secure Checkout', 'woocommerce' ); ?></a>
           
    <?php
    }
    

    I’m guessing that maybe the ajax button’s update comes from the parent theme.

    Login or Signup to reply.
  2. Instead of overriding proceed-to-checkout-button.php file, should use the following instead:

    remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
    add_action( 'woocommerce_proceed_to_checkout', 'custom_button_proceed_to_checkout', 20 );
    function custom_button_proceed_to_checkout() {
        echo '<a href="'.esc_url(wc_get_checkout_url()).'" class="checkout-button button alt wc-forward">' .
        __("Checkout", "woocommerce") . '</a>';
    }
    

    Code goes in functions.php file of your active child theme (or active theme). Tested and works on last WooCommerce version under Storefront theme.

    Now as you have done a lot of customizations in your templates or may be you are using some plugin in cart page for customization, the problem can remains due to those customizations.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search