• Resolved Elvis Morales

    (@elvismdev)


    I’m trying to customize the “Start shopping” button text in the WooCommerce Mini Cart block to display “Explore my art” instead. This text appears to be defined in:

    plugins/woocommerce/assets/client/blocks/mini-cart-contents-block/shopping-button-frontend.js
    

    Looking at the file, I can see the text is defined with:

    const l=(0,n(7723).__)("Start shopping","woocommerce");
    

    My Use Case

    I’m building an art store and need to customize this text to better match the brand voice. Since this is a core WooCommerce file that would be overwritten during updates, I need a proper way to override just this text. What I’ve Tried

    1. Using the gettext filter (didn’t work):
    function custom_woocommerce_button_text( $translated_text, $text, $domain ) {
    if ( $text === 'Start shopping' && $domain === 'woocommerce' ) {
    return 'Explore my art';
    }
    return $translated_text;
    }
    add_filter( 'gettext', 'custom_woocommerce_button_text', 20, 3 );
    1. Direct DOM manipulation as a workaround (this works but feels hacky):
    function custom_mini_cart_button_text_script() {
        ?>
        <script>
        document.addEventListener('DOMContentLoaded', function() {
            const observer = new MutationObserver(function(mutations) {
                const buttons = document.querySelectorAll('.wc-block-mini-cart__shopping-button');
                buttons.forEach(function(button) {
                    if (button.textContent.includes('Start shopping')) {
                        button.textContent = 'Explore my art';
                    }
                });
            });
            
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
        </script>
        <?php
    }
    add_action( 'wp_footer', 'custom_mini_cart_button_text_script' );
    

    Question

    What is the proper/recommended way to override this button text? Is there a specific hook or filter I should be using instead of manipulating the DOM directly?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    I checked the site link you shared, and it looks like you’re using the Kiosko theme, which is a block-based theme. Block themes that support the Full Site Editor allow you to change button text directly from the editor without needing any custom code.

    Here’s how you can update the button text:

    1. From your WordPress dashboard, go to Appearance → Editor.
    2. Click on Patterns, then select Template Parts.
    3. Look for the Mini Cart template part and open it in the editor.
    4. Select the button you want to edit and change its text to your preferred wording.

    To help guide you through the process, I’ve recorded a short video: 👉 Watch the video

    If you are not using a block theme and do not have access to the Site Editor. I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the  WooCommerce Community Slack as custom code falls outside our usual scope of support.

    Thread Starter Elvis Morales

    (@elvismdev)

    Resolved now. Thank you!

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi Elvis,

    Thank you for your update, I’m really glad to hear that you’ve successfully resolved the issue with customizing the “Start shopping” button text in the Mini Cart block!

    If WooCommerce has been helpful in building your store and enhancing your customer experience, we’d be truly grateful if you could take a moment to leave us a review. Your feedback not only helps us continue improving but also assists others in choosing the right tools for their store.

    You can leave a review here: https://wordpress.org/support/plugin/woocommerce/reviews/

    Thanks again, and wishing you continued success with your art store!

    Have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.