Change the text of ‘View cart’ button

Iam using a woocommerce plugin but I got an problem on how to change the text of the view cart button hope there is a one who can help with my problem this is my site
this is the image of the text that i want to change the image how can i edit it? all suggestion are appreciated.

Related posts

Leave a Reply

5 comments

  1. Add the following to your functions.php file.

    /**
     * Change text strings
     *
     * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
     */
    function my_text_strings( $translated_text, $text, $domain ) {
        switch ( strtolower( $translated_text ) ) {
            case 'View Cart' :
                $translated_text = __( 'View Shopping Cart', 'woocommerce' );
                break;
        }
        return $translated_text;
    }
    add_filter( 'gettext', 'my_text_strings', 20, 3 );
    

    This will change View Cart to View Shopping Cart

  2. The example code put forward by Selom works, but is highly inefficient, as it forces all WordPress text to be converted to lower case and then run through this filter to see if it matches a case. It has an immediate impact on load time as well as functions such as adding to cart. This is especially noticable if you are using ajax to add products to the cart without refreshing the page.

    It is far better to only run the text that is from the WooCommerce domain through a filter. This speeds things up a lot.

    I recommend using this example code instead, sourced from Rodolfo Melogli:

    /**
     * @snippet       Translate a String in WooCommerce
     * @sourcecode    https://businessbloomer.com/?p=162
     * @author        Rodolfo Melogli
     * @compatible    WooCommerce 3.5.4
     * @donate $9     https://businessbloomer.com/bloomer-armada/
     */
    
    add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
    
    function bbloomer_translate_woocommerce_strings( $translated, $text, $domain ) {
    
    
         if ( ! is_admin() && 'woocommerce' === $domain ) {
    
          switch ( strtolower( $translated ) ) {
    
             case 'view cart' :
                $translated = 'View/Edit Order';
                break;
    
             case 'proceed to checkout' :
                $translated = 'Place Order ';
                break;
    
              case 'checkout' :
                $translated = 'Place Order ';
                break;
    
        case 'add to cart' :
                $translated = 'Add to Order';
                break;
    
    
             // enter a new case for each line where you want Woocommerce text to be changed.
    
          }
    
       }   
    
    
        return $translated;
    }
    
    
  3. Add the following snippet to your functions.php file

    function woo_custom_change_cart_string($translated_text, $text, $domain) {
        $translated_text = str_replace("view cart", "NEW TEXT HERE ", $translated_text);
        $translated_text = str_replace("View cart", "NEW TEXT HERE ", $translated_text);
    return $translated_text;
    }
    add_filter('gettext', 'woo_custom_change_cart_string', 100, 3);
    add_filter('ngettext', 'woo_custom_change_cart_string', 100, 3);
    
  4. Add the following code to your functions.php file.

    function change_view_cart_link( $params, $handle )
    {
        switch ($handle) {
            case 'wc-add-to-cart':
                $params['i18n_view_cart'] = "Proceed to Cart"; //chnage Name of view cart button
                $params['cart_url'] = "http://myshop.com/custom-page"; //change URL of view cart button
            break;
        }
        return $params;
    }
    add_filter( 'woocommerce_get_script_data', 'change_view_cart_link', 10, 2 );
    
  5. Go to wp-contentpluginswoocommerceincludeswc-template-functions.php
    then edit raw 1429

    function woocommerce_widget_shopping_cart_button_view_cart() {
            echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>';
        }
    }
    function woocommerce_widget_shopping_cart_button_view_cart() {
            echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'your text', 'woocommerce' ) . '</a>';
        }
    }
    

    version woocommerce 3.0.3.