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

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

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

nerrad
Copy link
Contributor

@nerrad nerrad commented Jun 9, 2023

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:

  • Enable the default state of the theme with a more performant implementation of the mini-cart behaviour via the block version.
  • Provide an example for other classic theme shops/developers for how to utilize the new Mini-Cart block in their themes.
  • Via enabling template part support (in concert with the changes needed in WooCommerce Blocks here), provides a way for merchants/users of this theme to have more no-code options for customizing the behaviour and design of the Mini-Cart contents panel.

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:

Additional Notes:

  • There are some CSS/styling issues that would need to be handled. Storefront has some custom styles for blocks that impact some of the styles on the frontend. Note that the positioning of the block in the default area is out of alignment vertically.
  • The editor WYSIWYG view for the template part does not match the actual rendering on the frontend. I suspect we'd have to either add theme.json support to the theme or enqueue relevant styles in the editor context to achieve the parity.
  • We'd have to decide how we'd roll this out for all users. For example, would it be something new users of Storefront default to, something that existing users opt-in to? Should we still leave the implementation of the widget available for folks to utilize?
  • Merchants would not be able to edit the actual implementation of the block here. This isn't a significant change for users of the Storefront theme because they weren't able to do that beforehand anyways.
  • We'd need to test this with a Storefront child theme and consider what behaviour should exist here.

Changelog

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

@nerrad
Copy link
Contributor Author

nerrad commented Jun 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant