Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Refactor Cart and Checkout Page Templates #10773

Merged
merged 43 commits into from Sep 19, 2023

Conversation

mikejolley
Copy link
Member

@mikejolley mikejolley commented Aug 29, 2023

Introduces a Page Content Wrapper and Classic Shortcode block to improve the merchant facing experience when dealing with templates, pages, and the legacy shortcodes.

What

This is a refactor of the newly introduced cart and checkout templates which uses **page templates** instead of **dynamic templates** (I am calling them dynamic templates because that is what Gutenberg calls templates not based on pages, for example search, 404, and home). This restores compatibility with themes and removes the need to migrate page content in complex ways. It also prevents the need to redirect the old page editor to the template editor, which was causing merchant confusion.

Supersedes #10666

EDIT:

Based on the feedback and the disconnect between pages and templates, this now:

  • Moves the shortcode/block switcher to page level
  • Includes a page placeholder at template level. This allows page content to be edited directly from there!

TODO:

  • Remove/update migration logic @wavvves

Why

To summarise the issues:

Migration of the page content to the template is not working for all users. This can result in a cart page changing after upgrade (either missing content, or using Blocks instead of the shortcode)
The new template broke compatibility with the page hierarchy templates, e.g. page-checkout.php from a theme.
When migrating content, any block templates were ignored. Again causing a mismatch between the checkout post and pre upgrade.
There are incompatibilities with the navigation editor.
Users are getting confused because edits to the page are ignored.
The team have been working through these issues and creating patches and workarounds, however, some of the issues have no straightforward solution (the template hierarchy one most notably). I did a quick exploration into an alternative

Change Checkout Template Slug from checkout to page-checkout and cart to page-cart

This seemingly small change means that the template would be woocommerce//page-checkout and page-checkout in the template hierarchy.

What this fixes

Theme compatibility. Any theme that has a page-checkout.html block template will be respected again, and that template will take priority over our version (which is what we want).

No migration – use new block placeholder instead

The migration routine takes the content from the original checkout page and inserts it into a custom checkout template. This however has caused issues with failed migrations and block templates which are difficult to detect.

The solution I propose is to instead make the default template contain a placeholder which renders the page content directly from the page instead of copying it. This allows us to maintain compatibility with pages, whilst also allowing the merchant to customise the template or switch to blocks in the site editor easily.

The default template gets a new legacy/classic block placeholder which looks like this:

The default template includes a placeholder which loads page content via Inner Blocks. This allows for inline editing of page content from one location.

It also offers a button to convert to a blockified checkout instead. The same is implemented for the cart page.

What this fixes

  • No migration process means no chance of a failed content migration
  • Because pages still work, we no longer need to block access to them or show notices stating that cannot be edited.
  • We can use the page titles on the frontend without hardcoding titles for templates.
  • Incompatibilities with the navigation editor are resolved!
  • Backwards compatibility is preserved
  • Themes that use block templates are still respected!

Deprecation of the previous checkout template

Because some users may have already upgraded and customised the checkout template, there is a small migration routine on upgrade which renames woocommerce//checkout to woocommerce//page-checkout. This is a one off upgrade process which prevents duplicates in the site editor, and moves any customisations to the new template. There is a todo to update the versioning this runs on depending on the release this PR ships with.

Other feedback

This PR has had some suggestions.

Addressing pages as a top-level item in the site editor

Latest Gutenberg has a new page editor which shows some special dynamic pages (404, search) below the rest of the pages. This is currently not extendable, and may not be a good fit because there is still a Checkout/Cart page, so I have not implemented this.

Surfacing reversion

Once you've converted to blocks, you can only revert by reverting the template. There may be ways to make this more obvious, but I'm not sure its worth it vs documenting it somewhere.

You cannot revert, but since edits are kept within pages you can revert to an earlier revision or put the block/shortcode back yourself.

Testing Instructions

Before testing, take note of the frontend appearance of the cart/checkout pages.

  1. Using a non-block based theme such as Storefront, ensure your existing cart/checkout is unchanged as a result of testing this PR.
  2. Use a block based theme such as Twenty Twenty Three
  3. Go to Appearance > Editor > Templates, navigate to both Page: Cart and Page: Checkout. For both, click the three dots in the inspector and "revert customisations". This will remove any existing template customisations or past migration.
  4. Visit the cart/checkout pages on the frontend and ensure the page contents matches the actual cart/checkout page content.
  5. Edit the contents of the checkout page, not the template, either from Admin > Pages or Admin > Appearance > Editor > Pages. After saving, confirm the changes are shown on the frontend.
  6. Go to Appearance > Editor > Templates and edit the Page: Checkout template. Edit something in the template. Save and confirm the frontend shows your change. When adding content to the template, make sure you're not within Group > Checkout Page, as this will save to the page not the template. Insert something after or outside of that group.
  7. Go to Appearance > Editor > Templates and edit the Page: Checkout template. Click the three dots in the side bar and "revert customisations". Ensure the frontend shows the same default template again without your changes.
  8. Switch to a block based theme with a custom cart/checkout template. For example FotaWP
  9. After activating the theme, view the checkout page. You should see a custom checkout template (this is from the theme).
  10. Switch back to Twenty Twenty Three—the previous template will be restored.

Classic Shortcode Block

  1. Delete your main cart and checkout pages
  2. Go to WooCommerce > Status > Tools > and use the tool to recreate the default woocommerce pages
  3. Now if you go to the newly recreated Cart/Checkout pages you'll see a placeholder block which when focussed/clicked will look something like this (copy may differ as this PR is updated):

Screenshot 2023-09-05 at 13 46 00

  1. Ensure you see a shortcode cart/checkout on the frontend still.
  2. Go to Appearance > Editor > Templates and then Page: Cart and Page: Checkout. Both should show the placeholder.
  3. Go to Appearance > Editor > Pages and then the cart/checkout pages. Both should show the placeholder.
  4. Edit the page again. Click the classic shortcode placeholder then click the 'convert to blocks' button. Save and view the frontend. You should now see checkout blocks instead of the page content.
  5. Likewise, viewing the Templates + Pages in site editor should show the blocks.

Page Permalink Management 2185e59

  1. Go to WooCommerce > Settings > Advanced and ensure you see classic dropdowns for Cart and Checkout page selector. Compare this with a non blocks theme installation and ensure there are no differences.
  2. Edit Cart and Checkout pages, and changes the titles. Go back to the selectors and ensure it is reflected there.
  3. Edit Cart and Checkout pages permalinks. Ensure Cart and Checkout work on the selected URLs.

Test Page Wrapper on Site Editor a34c74d

  1. Got to Appearance > Editor > Templates > Manage all templates
  2. Ensure that customizations are deleted for Cart and Checkout templates (if not click the 3 dots next to the template and delete them)
  3. Open the templates for each, then edit content with the page placeholder block. Save.
  4. Exit the site editor and open Cart and Checkout pages for each. Ensure you see the changes added in the site editor.
  5. Verify the changes are reflected on the Cart and Checkout by performing a test order.

Developer testing

  1. Before using this PR, save some customisations to your cart/checkout pages.
  2. Checkout this PR.
  3. Go to the site editor templates section. You'll see "checkout" (your custom template) and "Page: Checkout" (the new template).
  4. You need to force a migration. You can manually call in Bootstrap.php the following:
$this->migration->wc_blocks_update_1120_rename_checkout_template();
$this->migration->wc_blocks_update_1120_rename_cart_template();
  1. When you load a page it will run the above and migrate the templates. Remove the above code then go back to the site editor.
  2. You should now see only one "Page: Checkout" template, and it should contain the customisations you previously made to checkout.
  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a [type] label or a [skip-changelog] label.
  • This PR is assigned to a milestone.

Conditional:

  • This PR has a changelog description (if [skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces, and I've updated this doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

Improved cart and checkout templates to use the correct page hierarchy, and to improve compatibility with existing page content. Users can find these new templates in the site editor named "Page: Checkout" and "Page: Cart" if using a block based theme.

Dev Note

In Blocks 10.6.0 new templates were introduced to control the layout of Cart and Checkout pages specifically for block theme. The goal was to provide a single editing experience for cart/checkout pages and move away from the page editor, and to introduce more condensed versions of headers/footers for those pages to prevent distractions during checkout. This change however introduced some conflicts with themes implementing their own page templates, and well as making it more difficult to find and edit page content for those familiar with the traditional WooCommerce editing experience.

To improve this, we've rolled out several improvements which not only aid discoverability of templates and compatibility with themes, but also prevent the need for complex migrations between pages and templates. To summarise the changes:

  • Cart and checkout templates have had their prefix restored, making them page-cart and page-checkout for greater compatibility with the page template hierarchy and themes. Themes that implement a page-cart.html or similar will take priority over the default templates in WooCommerce. Custom templates created by the merchant take ultimate priority over both.
  • The ability to edit the cart and checkout page content via Admin > Pages or Appearance > Editor > Pages has been restored. This content is displayed within the new default cart and checkout templates.
  • Page content, as well as the template, can be edited via Appearance > Editor > Templates > Page: Cart / Page: Checkout for convenience. On save, both entities will be saved.
  • Default page content for the cart and checkout pages created for new installs of WooCommerce will include a new Shortcode Placeholder Block. This will render the appropriate WooCommerce shortcode, but also allow for 1 click conversion to blocks. Shortcodes remain as the default.
  • The UI within WooCommerce > Settings > Advanced for selecting cart/checkout pages has been restored to a dropdowns instead of text. This is so the pages can be selected again.

For users of block themes who have already upgraded to WC 8.0 and already had their templates migrated, those templates will be renamed on upgrade, but the content will not be updated. That means you'll likely have a template that has the previous page content hardcoded within it. This is completely optional, but if you'd like to change this back to pulling content from the real page, do the following:

  1. Navigate to Appearance > Editor > Templates > Manage Templates
  2. You'll see a list of all templates on your store. Besides Page: Cart and Page: Checkout you'll see an icon to the write which brings up some options.
  3. Click this icon and select "Clear Customisations". The default WooCommerce cart/checkout template will be restored, and this template will again use your Cart and Checkout pages for the content.

Any content you had in these pages previously (if you already upgraded to the last version of WooCommerce) will be restored.

@woocommercebot woocommercebot requested review from a team and alexflorisca and removed request for a team August 29, 2023 15:58
@github-actions
Copy link
Contributor

Confirm version to run migration.

Confirm version to run migration.


// @todo Confirm version to run migration.
'11.0.0' => array(
'wc_blocks_update_1100_rename_checkout_template',
'wc_blocks_update_1100_rename_cart_template',
),
);
/**

🚀 This comment was generated by the automations bot based on a todo comment in 970c136 in #10773. cc @mikejolley

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-10773.zip

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
classic-shortcode.js wc-settings, wp-block-editor, wp-blocks, wp-components, wp-data, wp-element, wp-i18n, wp-notices, wp-polyfill, wp-primitives ⚠️
page-content-wrapper.js wc-settings, wp-block-editor, wp-blocks, wp-element, wp-i18n, wp-polyfill, wp-primitives ⚠️

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 499
  • Total errors: 2299

⚠️ ⚠️ This PR introduces new TS errors on 3 files:

assets/js/blocks/classic-shortcode/index.tsx

assets/js/blocks/page-content-wrapper/index.tsx

assets/js/editor-components/default-notice/index.tsx

comments-aggregator

@mikejolley mikejolley added type: enhancement The issue is a request for an enhancement. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: template Related to API powering block template functionality in the Site Editor labels Aug 29, 2023
@mikejolley mikejolley added this to the 11.1.0 milestone Aug 29, 2023
@mikejolley mikejolley self-assigned this Aug 29, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

Size Change: +9.87 kB (+1%)

Total Size: 1.38 MB

Filename Size Change
build/active-filters.js 7.51 kB -1 B (0%)
build/all-products.js 41.5 kB +2 B (0%)
build/all-reviews.js 8.37 kB -2 B (0%)
build/attribute-filter.js 13.1 kB +3 B (0%)
build/blocks-checkout.js 35.3 kB +7 B (0%)
build/breadcrumbs.js 2.27 kB -1 B (0%)
build/cart-blocks/cart-accepted-payment-methods-style.js 137 B +1 B (+1%)
build/cart-blocks/cart-cross-sells-products-style.js 137 B -1 B (-1%)
build/cart-blocks/cart-cross-sells-style.js 249 B -1 B (0%)
build/cart-blocks/cart-line-items-style.js 135 B -1 B (-1%)
build/cart-blocks/empty-cart-style.js 343 B -1 B (0%)
build/cart-blocks/order-summary-coupon-form-style.js 138 B +1 B (+1%)
build/cart-blocks/order-summary-fee-style.js 136 B -1 B (-1%)
build/cart-blocks/order-summary-subtotal-style.js 136 B -1 B (-1%)
build/cart.js 44.8 kB -281 B (-1%)
build/checkout-blocks/actions--checkout-blocks/terms-style.js 486 B -1 B (0%)
build/checkout-blocks/actions-style.js 681 B -1 B (0%)
build/checkout-blocks/billing-address-style.js 533 B +4 B (+1%)
build/checkout-blocks/contact-information-style.js 605 B -1 B (0%)
build/checkout-blocks/fields-style.js 249 B -1 B (0%)
build/checkout-blocks/order-summary-taxes-style.js 178 B +1 B (+1%)
build/checkout-blocks/pickup-options-style.js 440 B +2 B (0%)
build/checkout-blocks/shipping-address-style.js 477 B +3 B (+1%)
build/checkout-blocks/shipping-method-style.js 1.35 kB +1 B (0%)
build/checkout-blocks/shipping-methods-style.js 417 B +3 B (+1%)
build/checkout-blocks/terms-style.js 672 B -1 B (0%)
build/checkout-blocks/totals-style.js 275 B +1 B (0%)
build/checkout.js 47.4 kB -285 B (-1%)
build/customer-account.js 3.18 kB +2 B (0%)
build/featured-category.js 15.1 kB -3 B (0%)
build/featured-product.js 15.3 kB -3 B (0%)
build/filter-wrapper.js 2.38 kB -5 B (0%)
build/handpicked-products.js 7.99 kB +2 B (0%)
build/legacy-template.js 8.12 kB -29 B (0%)
build/mini-cart-contents-block/cart-button--mini-cart-contents-block/checkout-button--mini-cart-contents---358acf4e-style.js 249 B +1 B (0%)
build/mini-cart-contents-block/cart-button-style.js 385 B +2 B (+1%)
build/mini-cart-contents-block/checkout-button-style.js 466 B +1 B (0%)
build/mini-cart-contents-block/filled-cart-style.js 268 B +1 B (0%)
build/mini-cart-contents-block/products-table-style.js 5.32 kB +3 B (0%)
build/mini-cart-contents-block/shopping-button-style.js 397 B +1 B (0%)
build/mini-cart-contents-block/title-style.js 437 B -2 B (0%)
build/mini-cart-contents.js 17.6 kB +8 B (0%)
build/mini-cart.js 6.34 kB -1 B (0%)
build/price-filter.js 8.53 kB +7 B (0%)
build/product-add-to-cart.js 8.54 kB +3 B (0%)
build/product-average-rating--product-button--product-image--product-price--product-rating--product-ratin--e23975b5.js 934 B +1 B (0%)
build/product-average-rating.js 403 B +1 B (0%)
build/product-best-sellers.js 8.33 kB +7 B (0%)
build/product-button.js 3.86 kB -1 B (0%)
build/product-category.js 9.3 kB +2 B (0%)
build/product-collection.js 15.5 kB +587 B (+4%)
build/product-gallery-frontend.js 651 B +25 B (+4%)
build/product-gallery-large-image-frontend.js 824 B +22 B (+3%)
build/product-gallery-large-image.js 2.34 kB -1 B (0%)
build/product-gallery-rtl.css 678 B +43 B (+7%) 🔍
build/product-gallery-thumbnails.js 3.91 kB +2 B (0%)
build/product-gallery.css 678 B +43 B (+7%) 🔍
build/product-gallery.js 9.35 kB +124 B (+1%)
build/product-image.js 1.53 kB +1 B (0%)
build/product-on-sale.js 8.61 kB +1 B (0%)
build/product-price.js 1.65 kB -3 B (0%)
build/product-query.js 13.1 kB +2 B (0%)
build/product-rating-counter.js 690 B +1 B (0%)
build/product-rating-stars.js 938 B -1 B (0%)
build/product-rating.js 1.04 kB -1 B (0%)
build/product-search.js 2.63 kB +2 B (0%)
build/product-sku.js 522 B -1 B (0%)
build/product-summary.js 918 B +1 B (0%)
build/product-template-rtl.css 419 B +1 B (0%)
build/product-template.css 419 B +1 B (0%)
build/product-template.js 2.87 kB -1 B (0%)
build/product-title.js 963 B +4 B (0%)
build/product-top-rated.js 8.88 kB +3 B (0%)
build/products-by-attribute.js 9.65 kB +1 B (0%)
build/rating-filter.js 6.89 kB +3 B (0%)
build/reviews-by-category.js 12.6 kB -4 B (0%)
build/reviews-by-product.js 14 kB -2 B (0%)
build/stock-filter.js 7.6 kB +5 B (0%)
build/vendors--active-filters-wrapper--attribute-filter-wrapper--mini-cart-contents-block/cart-button--mi--d6bb29e6-style.js 628 B -1 B (0%)
build/vendors--checkout-blocks/shipping-method-style.js 11.7 kB -1 B (0%)
build/wc-blocks-editor-style-rtl.css 6.76 kB +274 B (+4%)
build/wc-blocks-editor-style.css 6.77 kB +275 B (+4%)
build/wc-blocks-vendors.js 64.1 kB +37 B (0%)
build/wc-blocks.js 2.63 kB +2 B (0%)
build/classic-shortcode-rtl.css 240 B +240 B (new file) 🆕
build/classic-shortcode.css 239 B +239 B (new file) 🆕
build/classic-shortcode.js 4.63 kB +4.63 kB (new file) 🆕
build/collection-filters.js 1.85 kB +1.85 kB (new file) 🆕
build/page-content-wrapper.js 2.02 kB +2.02 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.58 kB
build/active-filters-rtl.css 1.99 kB
build/active-filters-wrapper--mini-cart-contents-block/cart-button--mini-cart-contents-block/checkout-but--e791dc6c-style.js 929 B
build/active-filters-wrapper-frontend.js 6.18 kB
build/active-filters-wrapper-rtl.css 1.85 kB
build/active-filters-wrapper.css 1.85 kB
build/active-filters.css 1.99 kB
build/add-to-cart-form-rtl.css 355 B
build/add-to-cart-form.css 354 B
build/all-products-frontend.js 9.94 kB
build/all-products-rtl.css 4.47 kB
build/all-products.css 4.46 kB
build/all-reviews-rtl.css 1.79 kB
build/all-reviews.css 1.79 kB
build/attribute-filter-frontend.js 22.9 kB
build/attribute-filter-rtl.css 4.14 kB
build/attribute-filter-wrapper-frontend.js 8.04 kB
build/attribute-filter-wrapper-rtl.css 4.01 kB
build/attribute-filter-wrapper.css 4.01 kB
build/attribute-filter.css 4.14 kB
build/breadcrumbs-rtl.css 232 B
build/breadcrumbs.css 232 B
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.34 kB
build/cart-blocks/cart-cross-sells-frontend.js 250 B
build/cart-blocks/cart-cross-sells-products--product-price-frontend.js 2.91 kB
build/cart-blocks/cart-cross-sells-products-frontend.js 3.72 kB
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5 kB
build/cart-blocks/cart-express-payment-frontend.js 712 B
build/cart-blocks/cart-express-payment-style.js 137 B
build/cart-blocks/cart-items-frontend.js 284 B
build/cart-blocks/cart-items-style.js 219 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.34 kB
build/cart-blocks/cart-line-items-frontend.js 1.04 kB
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB
build/cart-blocks/cart-order-summary-style.js 318 B
build/cart-blocks/cart-totals-frontend.js 288 B
build/cart-blocks/cart-totals-style.js 228 B
build/cart-blocks/empty-cart-frontend.js 353 B
build/cart-blocks/filled-cart-frontend.js 652 B
build/cart-blocks/filled-cart-style.js 309 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.57 kB
build/cart-blocks/order-summary-discount-frontend.js 2.04 kB
build/cart-blocks/order-summary-discount-style.js 137 B
build/cart-blocks/order-summary-fee-frontend.js 271 B
build/cart-blocks/order-summary-heading-frontend.js 325 B
build/cart-blocks/order-summary-heading-style.js 325 B
build/cart-blocks/order-summary-shipping-frontend.js 12 kB
build/cart-blocks/order-summary-shipping-style.js 178 B
build/cart-blocks/order-summary-subtotal-frontend.js 272 B
build/cart-blocks/order-summary-taxes-frontend.js 433 B
build/cart-blocks/order-summary-taxes-style.js 177 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.41 kB
build/cart-blocks/proceed-to-checkout-style.js 1.09 kB
build/cart-frontend.js 29.6 kB
build/cart-rtl.css 9.77 kB
build/cart.css 9.76 kB
build/catalog-sorting-rtl.css 256 B
build/catalog-sorting.css 256 B
build/catalog-sorting.js 1.71 kB
build/checkout-blocks/actions-frontend.js 1.81 kB
build/checkout-blocks/billing-address-frontend.js 4.3 kB
build/checkout-blocks/contact-information-frontend.js 2.02 kB
build/checkout-blocks/express-payment-frontend.js 1.12 kB
build/checkout-blocks/fields-frontend.js 299 B
build/checkout-blocks/order-note-frontend.js 1.1 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.63 kB
build/checkout-blocks/order-summary-cart-items-style.js 137 B
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.73 kB
build/checkout-blocks/order-summary-coupon-form-style.js 137 B
build/checkout-blocks/order-summary-discount-frontend.js 2.21 kB
build/checkout-blocks/order-summary-discount-style.js 137 B
build/checkout-blocks/order-summary-fee-frontend.js 274 B
build/checkout-blocks/order-summary-fee-style.js 137 B
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/order-summary-shipping-frontend.js 12 kB
build/checkout-blocks/order-summary-shipping-style.js 137 B
build/checkout-blocks/order-summary-style.js 318 B
build/checkout-blocks/order-summary-subtotal-frontend.js 272 B
build/checkout-blocks/order-summary-subtotal-style.js 137 B
build/checkout-blocks/order-summary-taxes-frontend.js 434 B
build/checkout-blocks/payment-frontend.js 9.13 kB
build/checkout-blocks/payment-style.js 459 B
build/checkout-blocks/pickup-options-frontend.js 4.13 kB
build/checkout-blocks/shipping-address-frontend.js 4.28 kB
build/checkout-blocks/shipping-method-frontend.js 2.58 kB
build/checkout-blocks/shipping-methods-frontend.js 5.68 kB
build/checkout-blocks/terms-frontend.js 1.51 kB
build/checkout-blocks/totals-frontend.js 333 B
build/checkout-frontend.js 31.5 kB
build/checkout-rtl.css 9.08 kB
build/checkout.css 9.07 kB
build/customer-account-rtl.css 407 B
build/customer-account.css 407 B
build/featured-category-rtl.css 971 B
build/featured-category.css 970 B
build/featured-product-rtl.css 1.02 kB
build/featured-product.css 1.02 kB
build/filter-wrapper-frontend.js 14 kB
build/filter-wrapper-rtl.css 375 B
build/filter-wrapper.css 375 B
build/legacy-template-rtl.css 238 B
build/legacy-template.css 238 B
build/mini-cart-component-frontend.js 30.5 kB
build/mini-cart-contents-block/cart-button-frontend.js 1.72 kB
build/mini-cart-contents-block/checkout-button-frontend.js 1.8 kB
build/mini-cart-contents-block/empty-cart-frontend.js 359 B
build/mini-cart-contents-block/empty-cart-style.js 355 B
build/mini-cart-contents-block/filled-cart-frontend.js 267 B
build/mini-cart-contents-block/footer-frontend.js 2.36 kB
build/mini-cart-contents-block/footer-rtl.css 400 B
build/mini-cart-contents-block/footer-style.js 2.35 kB
build/mini-cart-contents-block/footer.css 400 B
build/mini-cart-contents-block/items-frontend.js 228 B
build/mini-cart-contents-block/items-style.js 228 B
build/mini-cart-contents-block/products-table--product-image--product-title-style.js 316 B
build/mini-cart-contents-block/products-table-frontend.js 548 B
build/mini-cart-contents-block/products-table-rtl.css 2.12 kB
build/mini-cart-contents-block/products-table.css 2.11 kB
build/mini-cart-contents-block/shopping-button-frontend.js 491 B
build/mini-cart-contents-block/title-frontend.js 1.89 kB
build/mini-cart-contents-block/title-items-counter-frontend.js 1.6 kB
build/mini-cart-contents-block/title-items-counter-style.js 301 B
build/mini-cart-contents-block/title-label-frontend.js 1.54 kB
build/mini-cart-contents-block/title-label-style.js 301 B
build/mini-cart-contents-rtl.css 2.66 kB
build/mini-cart-contents.css 2.65 kB
build/mini-cart-frontend.js 2.79 kB
build/mini-cart-rtl.css 2.56 kB
build/mini-cart.css 2.56 kB
build/packages-style-rtl.css 3.55 kB
build/packages-style.css 3.55 kB
build/price-filter-frontend.js 14.5 kB
build/price-filter-rtl.css 2.69 kB
build/price-filter-wrapper-frontend.js 8.59 kB
build/price-filter-wrapper-rtl.css 2.55 kB
build/price-filter-wrapper.css 2.54 kB
build/price-filter.css 2.69 kB
build/price-format.js 1.15 kB
build/product-add-to-cart--product-average-rating--product-button--product-image--product-price--product---1d132d69.js 272 B
build/product-add-to-cart--product-button--product-rating--product-rating-counter--product-rating-stars.js 150 B
build/product-add-to-cart--product-image--product-title.js 320 B
build/product-add-to-cart-frontend.js 8.51 kB
build/product-add-to-cart-rtl.css 1.35 kB
build/product-add-to-cart.css 1.36 kB
build/product-average-rating-frontend.js 1.73 kB
build/product-button-frontend.js 4.88 kB
build/product-button-interactivity-frontend.js 9.54 kB
build/product-button-rtl.css 1.14 kB
build/product-button.css 1.14 kB
build/product-categories-rtl.css 651 B
build/product-categories.css 649 B
build/product-categories.js 2.72 kB
build/product-details-rtl.css 394 B
build/product-details.css 391 B
build/product-gallery-large-image-next-previous-rtl.css 489 B
build/product-gallery-large-image-next-previous.css 490 B
build/product-gallery-large-image-next-previous.js 4.07 kB
build/product-gallery-large-image-rtl.css 389 B
build/product-gallery-large-image.css 385 B
build/product-gallery-pager-rtl.css 293 B
build/product-gallery-pager.css 294 B
build/product-gallery-pager.js 3.49 kB
build/product-gallery-thumbnails-rtl.css 293 B
build/product-gallery-thumbnails.css 292 B
build/product-image-frontend.js 2.69 kB
build/product-image-gallery-rtl.css 304 B
build/product-image-gallery.css 303 B
build/product-image-rtl.css 988 B
build/product-image.css 986 B
build/product-new.js 8.61 kB
build/product-price-frontend.js 247 B
build/product-price-rtl.css 667 B
build/product-price.css 665 B
build/product-query-rtl.css 347 B
build/product-query.css 347 B
build/product-rating-counter-frontend.js 2.03 kB
build/product-rating-frontend.js 2.37 kB
build/product-rating-rtl.css 244 B
build/product-rating-stars-frontend.js 2.27 kB
build/product-rating-stars-rtl.css 895 B
build/product-rating-stars.css 897 B
build/product-rating.css 244 B
build/product-results-count-rtl.css 228 B
build/product-results-count.css 228 B
build/product-results-count.js 1.66 kB
build/product-reviews-rtl.css 456 B
build/product-reviews.css 455 B
build/product-sale-badge-frontend.js 1.85 kB
build/product-sale-badge-rtl.css 435 B
build/product-sale-badge.css 434 B
build/product-sale-badge.js 699 B
build/product-search-rtl.css 415 B
build/product-search.css 415 B
build/product-sku-frontend.js 1.86 kB
build/product-sku-rtl.css 237 B
build/product-sku.css 237 B
build/product-stock-indicator-frontend.js 2.05 kB
build/product-stock-indicator-rtl.css 229 B
build/product-stock-indicator.css 229 B
build/product-stock-indicator.js 710 B
build/product-summary-frontend.js 2.2 kB
build/product-summary-rtl.css 546 B
build/product-summary.css 546 B
build/product-tag.js 8.62 kB
build/product-title-frontend.js 2.23 kB
build/product-title-rtl.css 688 B
build/product-title.css 689 B
build/rating-filter-frontend.js 21.4 kB
build/rating-filter-rtl.css 4.2 kB
build/rating-filter-wrapper-frontend.js 6.65 kB
build/rating-filter-wrapper-rtl.css 4.07 kB
build/rating-filter-wrapper.css 4.07 kB
build/rating-filter.css 4.19 kB
build/reviews-by-category-rtl.css 1.79 kB
build/reviews-by-category.css 1.79 kB
build/reviews-by-product-rtl.css 1.79 kB
build/reviews-by-product.css 1.79 kB
build/reviews-frontend.js 7.07 kB
build/single-product-rtl.css 375 B
build/single-product.css 375 B
build/single-product.js 11.4 kB
build/stock-filter-frontend.js 21.6 kB
build/stock-filter-rtl.css 4.01 kB
build/stock-filter-wrapper-frontend.js 6.85 kB
build/stock-filter-wrapper-rtl.css 3.88 kB
build/stock-filter-wrapper.css 3.88 kB
build/stock-filter.css 4.01 kB
build/store-notices.js 1.69 kB
build/vendors--active-filters-wrapper-frontend.js 1.69 kB
build/vendors--attribute-filter-wrapper--cart-blocks/order-summary-coupon-form--cart-blocks/order-summary--48e1e4bb-frontend.js 6.85 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 8.31 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.29 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.57 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 19.4 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping--checkout-block--24d3fc0c-frontend.js 8.38 kB
build/vendors--cart-blocks/proceed-to-checkout-style.js 179 B
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.6 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12.5 kB
build/vendors--mini-cart-contents-block/products-table--price-filter-wrapper--product-price-style.js 5.27 kB
build/vendors--mini-cart-contents-block/products-table-style.js 3.16 kB
build/vendors--product-add-to-cart-frontend.js 7.5 kB
build/wc-blocks-classic-template-revert-button-style-rtl.css 237 B
build/wc-blocks-classic-template-revert-button-style.css 236 B
build/wc-blocks-classic-template-revert-button.js 1.53 kB
build/wc-blocks-data.js 22 kB
build/wc-blocks-google-analytics.js 1.55 kB
build/wc-blocks-middleware.js 934 B
build/wc-blocks-registry.js 3.19 kB
build/wc-blocks-rtl.css 2.46 kB
build/wc-blocks-shared-context.js 1.1 kB
build/wc-blocks-shared-hocs.js 1.63 kB
build/wc-blocks.css 2.46 kB
build/wc-interactivity.js 10.8 kB
build/wc-payment-method-bacs.js 817 B
build/wc-payment-method-cheque.js 813 B
build/wc-payment-method-cod.js 914 B
build/wc-payment-method-paypal.js 852 B
build/wc-settings.js 2.68 kB
build/wc-shipping-method-pickup-location.js 30.5 kB

compressed-size-action

@mikejolley
Copy link
Member Author

@pmcpinto @nerrad I've implemented some of the suggestions/feedback and rolled this out for the cart as well, so this should be good to test out now.

@wavvves I'm adding you as another reviewer given your experience with the templates.

Thanks for looking!

@nerrad
Copy link
Contributor

nerrad commented Aug 30, 2023

Thanks Mike, I'll spin up the PR and take a look sometime today.

@nerrad
Copy link
Contributor

nerrad commented Aug 30, 2023

I haven't looked at any code and just focused on a couple flows here. Generally in my testing so far this is looking pretty good but there are still some user gotchas that have surfaced so far. With classic themes things seem to be working as expected, however, some unexpected things happening (or user gotchas) when using a block theme:

What I noted in the video:

CleanShot.2023-08-30.at.16.17.54.mp4
  • appears to be a glitch when resetting the template where an error shows for the classic template block. It gets rectified when completely leaving the site editor and then returning.
  • appears to be a glitch sometimes when switching between a cart/checkout page via the site editor and back to template where the placeholder block is rendered in the editor but cannot be selected (and doesn't show up in the List View).
  • I'm not sure the placeholder should show "Cart Block" before transforming to blocks. Especially given it is actually rendering the default post_content from the cart page.
  • I'm not a fan of the disconnect between the native page editor for the cart and checkout and editing the page from the context of the site editor. It feels like something users might still have a problem with when they switch to blocks in the template, especially if they have custom content in the actual post_content. While I understand that resetting the template restores the original flow (which works for "reverting"), it still isn't really obvious to the user that this is a workaround if they need to get back to that content.
  • The above is also a bit of a disconnect for admin users who click the exposed "Edit Page" URLs anywhere they appear.

Not in the video:

  • I realize the wording of the placeholder explicitly refers to "Classic Cart Page" but if a user has already switched to the Cart and Checkout blocks in the classic page (with those customizations), it's not immediately clear that they should continue going to the classic page if they want to update that content. Since migration of content from the page is no longer happening, I think it'll be jarring behaviour when the user clicks to transform to blocks and it's like a reset of their content, especially if they go back to the original page which they are still able to access.
  • After transforming the template to blocks, if the user changes the slug for the cart via advanced settings, it is disconnected from the template and loads the original cart content instead. Also, the "Edit Site" link in the admin bar on the frontend loads the site editor "all pages" template.

There are a bunch of things in here so before I jump into suggested changes I'm interested in getting your thoughts on the above observations (in case some aren't reproducible or misunderstandings) before I jump into suggested solutions.

@mikejolley
Copy link
Member Author

Thanks for the detailed review @nerrad. I agree with those criticisms, and some apply to the current approach also. it certainly is disjointed how we require both a page and a template with both approaches. Certainly something we need to solve.

appears to be a glitch when resetting the template where an error shows for the classic template block. It gets rectified when completely leaving the site editor and then returning.

We've been noticing issues like this for a while; it seems direct navigation to the site editor prevents certain functionality from loading correctly until you back out and go back in. This appears to be a Gutenberg issue which we'll need to raise upstream with steps to reproduce. On our side I'm not sure what we can do aside from avoid direct links to templates.

I'm not sure the placeholder should show "Cart Block" before transforming to blocks. Especially given it is actually rendering the default post_content from the cart page.

Agreed. I think if we pursue this PR further we should name it something like "Cart Page Placeholder" just so its clear what it is going to render unless you replace it.

I'm not a fan of the disconnect between the native page editor for the cart and checkout and editing the page

Something I've noticed with other page templates is that when the template uses post content/title blocks, the content can be edited in the site editor without going to the template itself:

Screenshot 2023-08-31 at 13 21 12

This improves the page editing experience, but it makes the template editing experience slightly worse because you only see generic placeholders in the template itself:

Screenshot 2023-08-31 at 13 22 27

This comes down to the disconnect between pages and templates.

cc @wavvves @ralucaStan It kind of feels like we should have one or the other, not both. I know one of the main motivations for templates was originally the distraction free views for checkout. Were there more reasons? I think the pages section in site editor is quite new; I wonder if this was maybe added after speccing the project? Does the existence of that lessen the need for dedicated templates?

Copy link
Member

@alexflorisca alexflorisca left a comment

Choose a reason for hiding this comment

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

Nice work @mikejolley. I've followed the testing instructions and mostly everything works ok. I did run into a few things that may or may not be caused by this PR, but seemed relevant, and left some general thoughts as I was going through it.

  • I agree with Darren that there is a disconnect between pages and templates and it feels very confusing going between them. Don't really have a solution here but I was trying to go through it wearing the hat of a typical user.
  • Saying that, I get that the pages are necessary, otherwise the user would loose the cart and checkout if they switch to a non-block template
  • I also ran into the issue at the end of Darren's video where the legacy template block is not recognised.
  • I also ran into the following issue, which I took a leaf out of Darren's book and recorded it
Finding.a.Solution.for.the.Cart.Page.Issue.mp4

I didn't look at the code yet, but I will once we're committed to this solution.

@mikejolley mikejolley force-pushed the experiment/checkout-page-template branch from cd78612 to 0f77247 Compare September 4, 2023 16:07
@mikejolley
Copy link
Member Author

mikejolley commented Sep 4, 2023

@nerrad @ralucaStan @wavvves I've pushed the revisions that we discussed.

  • Pages contain the shortcode/block switches. With the branch, if you delete your existing pages and go to Status > Tools > Recreate WooCommerce pages, you'll see the new page template with the switcher inside
  • Default templates contain a placeholder. This placeholder contains post title and post content inner blocks. It also provides context, so you can actually edit page content when viewing the template. When you save you'll see it saves to the page entity, not the template.
  • Pages are editable and link to the template if you want to edit header/footer.
  • The issue with the "add template" doesn't seem to occur. I think thats because these templates already exist (page-checkout, page-cart).

Screenshot 2023-09-04 at 17 11 48

Let me know if there are any questions. I added a todo item to remove/adjust the page migration code that exists already.

@wavvves
Copy link
Contributor

wavvves commented Sep 6, 2023

Endpoint revert b359dc7

@nerrad
Copy link
Contributor

nerrad commented Sep 8, 2023

Pages contain the shortcode/block switches. With the branch, if you delete your existing pages and go to Status > Tools > Recreate WooCommerce pages, you'll see the new page template with the switcher inside

More notes will come but just wanted to comment quickly on this before I forget. This step does work, however what is the expected behaviour with this branch merged as is for the following scenarios (including considerations for folks that may have an earlier version of the templates work):

  • Someone updating Woo Blocks on their site with a version of WooCommerce core that does not contain these changes.
  • Someone updating Woo Core on their site that contains these changes.
  • Fresh install of WooCommerce Core with these changes.

As a note, my initial test of this branch was (not following the instructions about deleting pages):

  • Spin up a brand new site.
  • Install Woo Core 8.0.3 but not activating
  • Install the Woo Blocks zip from this PR and activate it.
  • Activate Woo Core.
  • no other plugins active on this fresh site.

When I visited the template and the pages, I was just presented with the shortcode block for the cart and checkout.

Hence, my questions above regarding expectations for this branch behaviour as is. I want to make sure that we are aligned on what the expectations should be when this branch is merged.

@ralucaStan
Copy link
Contributor

I'm looking at the branch. I used my local sites that has WC Version 8.0.2 and had this value
Screenshot 2023-09-08 at 14 50 55

The Cart block worked as expected, but I wanted to show the errors I see with The Checkout block:

https://www.loom.com/share/0dfa26452a5e4b6eaf7c2d41b2268e09?sid=c095d570-5e49-418a-bb89-730efef34554

@ralucaStan
Copy link
Contributor

We had a demo of the branch with @nerrad, @elizaan36 and @pmcpinto.

We decided some minor changes are needed on this branch; @pmcpinto and @elizaan36 can help with the text changes

  1. Site editor settings bar notice
Screenshot 2023-09-08 at 18 06 29 - The text should be improved and the call to action should go to the template; @pmcpinto and @elizaan36 can help with the copy changes
  1. Placeholder component
    The placeholder text should be changed; A documentation page should be created to highlight the impact of changing from shortcode to blocks; the page should also explain how to revert to using the classic checkout blocks
    The placeholder should link to that page, so merchant are aware of the impact of the switch.

@nerrad said he will add some missing testing scenarios

There was an open question if the placeholder is showing on top of the shortcode or on top of the whole page content and what should the experience look like

@nielslange
Copy link
Member

After switching to the FotoWP theme, I’m no longer able to "revert customisations" when trying this via “Appearance » Editor » Templates » Manage all templates”

Expected; Fota has its own template so there is nothing to revert.

Thanks for clarifying this.

@nielslange
Copy link
Member

By default, I do not see the placeholder message, but only the placeholder image. Is that expected?

Yes the modal only appears on focus/click. Updated instructions.

I see. In that case, please disregard my prior comment.

@nielslange
Copy link
Member

On my end, the placeholder message also contains a link called “Learn more”, which is not visible on the screenshot in the PR.

Copy is going to change as well as the link, not important for testing.

OK. Got it. 👍

@mikejolley
Copy link
Member Author

It was not obvious to me that I need to click the three dots within the templates sidebar. Based on "Go to Appearance > Edit > Templates and edit the Page: Checkout template.", I opened the page editor and clicked the three dots there.

@nielslange You went to the pages editor instead of the templates editor? How can I clarify this; It does say "templates".

@nielslange
Copy link
Member

When using a classic theme, e.g. Storefront, I do see the shortcode cart and checkout. When using a block theme, e.g. Twenty Twenty-Three, I see Empty template: Cart respectively Empty template: Checkout.

@nielslange for this and the final points it seems as though your templates as not as expected and/or empty. I will try to repro but it might be useful to check what template is applying (query monitor plugin tells you) and what is in the DB (wp_templates).

After reverting prior changes and executing the testing steps again, the problem no longer appears, and I can see the shortcode cart and checkout, when using a classic theme, and the Cart and Checkout blocks, when using a block theme.

Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

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

The first test case states the following:

  1. Go to Appearance > Editor > Templates and edit the Page: Checkout template. Edit something in the template, for example, something under the content. Save and confirm the frontend shows your change.
  2. Go to Appearance > Editor > Templates and edit the Page: Checkout template. Click the three dots in the side bar and "revert customisations". Ensure the frontend shows the same default template again without your changes.

I went ahead and added the following paragraph inside the Shipping Method inner block:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

As expected, this paragraph appeared both in the page editor and on the frontend. I then cleared the customisations, but the paragraph remained. The following screenshot shows, that there are no customisations, that can be reverted. Yet, the paragraph remains visible. Is that expected, as I've added a block rather than adjusting a setting within the Checkout block? 🤔

Screenshot 2023-09-18 at 20 49 35

@mikejolley
Copy link
Member Author

As expected, this paragraph appeared both in the page editor and on the frontend. I then cleared the customisations, but the paragraph remained. The following screenshot shows, that there are no customisations, that can be reverted. Yet, the paragraph remains visible. Is that expected, as I've added a block rather than adjusting a setting within the Checkout block?

@nielslange You've edited the page rather than the template. When you saved it would have also said its changing the page content. You can see what you're within using the breadcrumbs at the base of the editor.

@mikejolley
Copy link
Member Author

I've added a dev note to the PR description.

@nielslange
Copy link
Member

@nielslange You've edited the page rather than the template. When you saved it would have also said its changing the page content. You can see what you're within using the breadcrumbs at the base of the editor.

The problem I'm facing is, that I'm unable to revert the change, unless I go into either the template or the page and manually remove the added paragraph.

In the site editor, when viewing "Pages:, I can only trash the page:
Screenshot 2023-09-18 at 21 55 00

In the site editor, when viewing "Templates", I see "Clear customizations":
Screenshot 2023-09-18 at 21 57 23

Clicking on "Clear customizations" shows me a notice that the site had been reverted, but my added paragraph remains:
Screenshot 2023-09-18 at 21 58 12

Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

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

@opr This depends on where the edit was made. If the edit was made to the template, no it won't be visible in the page editor, but it will be visible on the frontend. The page content can also be edited via the template, so check the path at the bottom of the editor to see if you're within the page placeholder block.

Can you confirm?

That's it, it's working fine now!

One more comment about the Classic Shortcode Block, I think the UX would be better if the "modal" always showed without needing to hover/select the block.

@mikejolley
Copy link
Member Author

mikejolley commented Sep 18, 2023

One more comment about the Classic Shortcode Block, I think the UX would be better if the "modal" always showed without needing to hover/select the block.

Yeah I did think about this, but we're following the pattern of the classic template block which is on select also. @opr change both or leave it?

@opr
Copy link
Contributor

opr commented Sep 18, 2023

Yeah I did think about this, but we're following the pattern of the classic template block which is on select also. @opr change both or leave it?

@mikejolley Have we already had guidance from design about this and they're fine with the classic template block's behaviour? If so, we can leave it, but if not then I think we should change it 🙏🏼

@wavvves
Copy link
Contributor

wavvves commented Sep 18, 2023

Yeah I did think about this, but we're following the pattern of the classic template block which is on select also. @opr change both or leave it?

Sorry about this @opr I changed the testing instructions to make sure the edits should be inside the page placeholder block.

@mikejolley
Copy link
Member Author

@opr we have not but classic template exists already so I assume it must have? I'm happy to leave it and tackle in a follow up if not. Ideally all would be done at the same time since they share this pattern.

Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

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

@opr we have not but classic template exists already so I assume it must have? I'm happy to leave it and tackle in a follow up if not. Ideally all would be done at the same time since they share this pattern.

Yeah OK let's do it in a follow up, it would expand the scope of this PR so better to deal with it separately.

Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, and addressing my previous feedback. The PR works as expected now, @mikejolley. 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: template Related to API powering block template functionality in the Site Editor needs: dev note PR that has some text that needs to be included in the release notes. needs: documentation The issue/PR requires documentation to be added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
8 participants