woocommerce / storefront

Official theme for WooCommerce
https://wordpress.org/themes/storefront/
959 stars 472 forks source link

[DRAFT] Replace mini-cart widget with mini-cart block and add support for template parts. #2100

Open nerrad opened 1 year ago

nerrad commented 1 year ago

Note: this PR should not be merged as is

This is a very limited proof of concept to aid discussions about having Storefront default to using the Mini-Cart block instead of the Woo Core mini-cart widget.

The team has been working on some improvements around the use of get_refreshed_fragments API in Woo Core, however the mini cart widget will still enqueue this script (and the resulting ajax calls). Implementing some variation of what is suggested in this PR will accomplish a number of things:

Screenshots

The Mini-Cart block in action on the frontend: CleanShot 2023-06-09 at 14 40 54

The template part: CleanShot 2023-06-09 at 15 02 53

How to test the changes in this Pull Request:

1. 2. 3.

Additional Notes:

Changelog

Enhancement - Implement Mini-Cart block as a replacement for the Mini-Cart widget. Also enables block template part support for the theme.

nerrad commented 1 year ago

Despite authoring this PR and not having any technical concerns about the implementation (other than followups around cleaning up the CSS), I’m not sure we should actually ship Storefront with these changes.

While it would be a good example for classic themes, there are a number of considerations we’d have to make around whether this is opt-in/opt-out, do we default new stores using Storefront to use the Mini-Cart block, what happens with child themes etc. The actual code I did is trivial, the product questions and work around answering those, supporting it after release etc, makes the effort questionable.

However, I’m surfacing this so others can give their take if they disagree.