• Resolved Selah

    (@tubescreamer)


    Hello,

    I made some changes to the mini-cart.php file, after copying it to my child theme (woocommerce > cart > mini-cart.php) The changes I made worked fine, except, it doesn’t show up until I add an item to the cart and remove the item. (I made changes to the empty cart message).

    I thought that this would be the case only on the browser I was using, or the computer I was using to visit the website, but I used different browsers and an entirely different computer that I never used to visit the site before, and this was still the case. So that means that any one who visits my site will encounter the same problem, which is kind of weird.

    As you can see in the below screenshot, this is what the mini cart looks like when you hover over the cart icon:

    https://pasteboard.co/JGudt1x.png

    The empty cart message doesn’t show and it looks all broken. However, after adding an item and then removing it, the empty cart message shows like it’s supposed to:

    https://pasteboard.co/JGue35F.png

    What do I have to do to make it so that an item doesn’t have to be added and then removed from the cart for the empty cart message to show properly?

    Yes, I have the latest version of my theme, and WooCommerce. I updated WooCommerce and copied over the mini-cart.php file to my child theme again with the change I made.

    • This topic was modified 3 years, 11 months ago by Selah.
    • This topic was modified 3 years, 11 months ago by Selah.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @tubescreamer,

    Most likely it’s something in the changes that is causing the problem. It would be helpful to see the code for the mini-cart.php file from the template override. Could you post that here so that anyone who wants to help out can see the changes?

    Thanks!

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy.

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

    Thread Starter Selah

    (@tubescreamer)

    @3sonsdevelopment

    Sorry for the late response,

    This is the code from the original mini-cart.php file (last few lines)

    <?php else : ?>
    
    	<p class="woocommerce-mini-cart__empty-message"><?php esc_html_e( 'No products in the cart.', 'woocommerce' ); ?></p>
    
    <?php endif; ?>
    
    <?php do_action( 'woocommerce_after_mini_cart' ); ?>

    and this is what I updated it to in my child theme

    <?php else : ?>
    
        <p class="woocommerce-mini-cart__empty-message"><?php esc_html_e( 'Your bag is empty!', 'woocommerce' ); ?><i class="opal-icon-shopping-bag mini-cart-icon"><?php esc_html_e( '', 'woocommerce' ); ?></i>
        
    <?php endif; ?>
    
    <?php do_action( 'woocommerce_after_mini_cart' ); ?>

    As you can see, I changed the text from “No products in the cart” to “Your bag is empty!” and I also added a custom shopping bag icon with an “X” to show up in the mini cart area for when the cart is empty.

    • This reply was modified 3 years, 10 months ago by Selah.

    Hi @tubescreamer,

    Thanks for sending that over. If I recall correctly, the JavaScript that is used to update the mini-cart would need to be updated as well to account for the new strings.

    Take a look at this post. It has some guidance on a possible way to do this:

    https://pluginrepublic.com/updating-the-woocommerce-mini-cart-via-ajax/

    I hope that gets you pointed in the right direction.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Mini Cart not showing changes until adding and removing item’ is closed to new replies.