9

I am trying to override mini-cart.php which is template file located at woocommerce/cart/mini-cart.php. It should override behaviour of woocommerce widget cart but it isnt working. I can make any changes to the file but it looks like it is still loading from some other place and it is not overriden. I have also tried modifying core template files of woocommerce and deleting mini-cart.php from it but widget is still working. However mini-cart.php structure looks exactly the same as html structure generated in final. But it looks like woocommerce isnt using this file so it has probably changed by some update and mini-cart.php is just remain from later versions. Any ideas what file should I override to change look of widget cart?

I dont want to completely override whole core widget cart class because I just want to change one <span> to <p>.

Thanks in forward

2
  • 3
    Add and remove an item, this will force the cart to purge it's html May 27, 2015 at 9:12
  • @Andrew I can verify either adding or removing something from cart seems to clear whatever cache is preventing it from updating with FTP'ng the mini-cart.php override to the theme folder. Thanks!
    – OG Sean
    Mar 27, 2020 at 2:15

3 Answers 3

1

Have you made sure to copy the mini-cart.php into yourtheme/woocommerce/cart/ not just yourtheme/woocommerce I can say for certain this works in Woocommerce version 2.0.12

Also if your saying that editing the core file isn't working is it possible that its getting override some where else in your theme. Could be worth searching your theme directory code for woocommerce_before_mini_cart seeing if thats used some where else.

7
  • my mini-cart.php is located in woocommerce/cart/ and I dont have any other files with woocommerce_before_mini_cart
    – horin
    Jul 30, 2013 at 8:50
  • What version of woo are you using? And what theme, if not custom? Jul 30, 2013 at 8:51
  • woo 2.0.1 and custom theme. Overriding every other theme files works great ... only mini-cart doesnt work
    – horin
    Jul 30, 2013 at 8:53
  • 1
    I changed theme to twenty eleven and it worked here so I changed it back to my custom theme and now it is working in it too. It's strange. Probably some sort of bug. Anyway, it is working now. Thanks for suggestion about changing theme
    – horin
    Jul 30, 2013 at 9:03
  • 2
    Just add/remove something from cart and it will clear the cached mini cart and you will see the updated mini-cart.php changes then
    – OG Sean
    Mar 27, 2020 at 2:16
21

I had this same problem. You must clear cache (or just delete cookies) before you will see your override. Not sure why :)

2
  • 18
    +1 -- the WooCommerce cart is saved in sessionStorage to avoid pulling a new copy on every page, so you need to clear your browser's sessionStorage to see any changes -- or just add another item to the cart, and it will be replaced. [and to the person who downvoted this: you get my downvote!]
    – webaware
    Dec 7, 2013 at 21:45
  • Thank you man, you saved my day. I had this same problem from a few days ago, it made no sense why it would not overrice the cart template but only other templates it was very annoying. To clarify for others, you need to go to Woocommerce >> Status >> Tools >> "Clear template cache".
    – Altin
    Dec 21, 2021 at 9:28
3

As Mark Davidson said to over ride mini-cart.php you need to place it in a file that you have to name in your theme

yourtheme / woocommerce / cart / mini-cart.php

But you have to remember that for changes to take effect you need to go back into the widgets page of wp-admin and re-save the shopping cart widget each time you make a change or they will not show up.

1
  • Just add/remove something from cart and it will clear the cached mini cart and you will see the updated mini-cart.php changes then
    – OG Sean
    Mar 27, 2020 at 2:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.