Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load wc-cart-fragments-script when the widget cart is active #2115

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

gigitux
Copy link
Contributor

@gigitux gigitux commented Aug 10, 2023

Fixes #2114

With #2113, we start to enqueue the wc-cart-fragments-script only on WooCommerce Pages, but the Mini Cart Widget can be loaded in all the pages of WordPress. So, I update the logic to ensure that the script is loaded when the Mini Cart Widget is active.

Screenshots

How to test the changes in this Pull Request:

  1. Install WP-Optimize - Clean, Compress, Cache plugin.
  2. Enable the cache.
  3. Add the Mini Cart widget via the widget page (Appareance > Widget). Add in the header.
  4. Create a post and add the On Sale Products block (it is important that it is an old block that it is server side). Save it.
  5. Visit the post.
  6. Add the products in the cart.
  7. Ensure that the Mini Cart widget is updated.
  8. Refresh the page.
  9. Ensure that the Mini Cart widget is loaded and shows the right product in the cart.

Changelog

Load wc-cart-fragments-script when Mini Cart widget is active.

@gigitux gigitux self-assigned this Aug 10, 2023
@gigitux gigitux added the type: bug The issue is a confirmed bug. label Aug 10, 2023
Copy link
Contributor

@albarin albarin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@github-actions github-actions bot added the status: ready to merge Automatically applied to a pull when a pull is approved. Indicates ready for merging. label Aug 10, 2023
@gigitux gigitux merged commit db4bc63 into trunk Aug 10, 2023
7 checks passed
@gigitux gigitux deleted the fix/sync-widget-cart branch August 10, 2023 11:52
@A-Printer
Copy link

This PR fixes things with the cart widget, but not with the cart that is present in the menu, here on the right of the screen.

@gigitux
Copy link
Contributor Author

gigitux commented Aug 10, 2023

This PR fixes things with the cart widget, but not with the cart that is present in the menu, here on the right of the screen.

Thanks for the feedback! Could you share some reproduction steps, please?

This is an attempt that I did and it seems that works correctly:

Screen.Capture.on.2023-08-10.at.14-59-35.mp4

@webwit
Copy link

webwit commented Aug 10, 2023

Try it on the homepage or other none woo page (and without mini cart) ?

@A-Printer
Copy link

Here you can see that the cart is updating on the WooCommerce pages, but not on the Contact page:

Enregistrement.de.l.ecran.2023-08-10.a.15.38.34.mov

@webwit
Copy link

webwit commented Aug 10, 2023

Yeah this doesn't fix the cart at the top right as I also reported in #2114. I don't use the mini cart.
The top right cart is part of the storefront templates, that header is used all over my site. Ehm, just a layman, but that function to only include it on some pages based on conditions - if you're running storefront with that cart always in the header, what is the purpose?

@A-Printer
Copy link

A-Printer commented Aug 11, 2023

@gigitux I agree with @webwit, since by default the cart (not the widget) is part of the navigation and is present on every page, it should get refreshed with wc-cart-fragments-script on every page, no exceptions.

@albarin
Copy link
Contributor

albarin commented Aug 11, 2023

Hi @webwit and @A-Printer, thanks for your suggestions! 🙌
Could you have a look at this new PR #2116 and see if it fixes the issue for you? Thanks a lot!

@webwit
Copy link

webwit commented Aug 11, 2023

Hi Alba,

I'm out and didn't test, but that should do it as yesterday I outcommented the call to add_filter to limit_cart_sync_to_wc_pages and that fixed it for me. #2116 removes that and effectively does the same.

@A-Printer
Copy link

@albarin I can confirm that #2116 does fix the issue. Thanks!

@albarin
Copy link
Contributor

albarin commented Aug 11, 2023

Thank you both for your help! We'll create a new release as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to merge Automatically applied to a pull when a pull is approved. Indicates ready for merging. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#2113 breaks refreshing the cart on non-WC cached pages
4 participants