Turn current page into the default Cart/Checkout page
This PR adds a "make current page default cart/checkout", it has a long flow that goes via several conditions:
To test this PR, you need this PR from WooCommerce core https://github.com/woocommerce/woocommerce/pull/34234
- The notice is visible on Cart/Checkout and all of their inner blocks.
- If the page isn't saved and published, it will get published, this is a condition in order to make it the default cart/checkout page.
- Once clicked, the current page is made to be the default cart/checkout page.
- The current page permalink will change to whatever the previous Cart/Checkout link was, so if that link was /cart the current page is /cart, if it was /carro, so will the current page.
- If we didn't have a previous page, then it will just use /cart or /checkout like WooCommerce core.
- The previous page link will get -2 appended to it to avoid conflict.
- The page is saved.
- The notice is now green, you can dismiss it.
The notice is also visible on all cart and checkout inner blocks.
Fixes #6864 Fixes #6865
Screenshots
https://user-images.githubusercontent.com/6165348/183219991-4b904273-67ef-43e1-94fb-7498531f104f.mov
User Facing Testing
- Make sure you have a Cart and Checkout pages in WooCommerce -> Settings -> Advanced.
- Those pages urls can be
/cartand/checkout. - Open a new page, give it a title, insert Cart block.
- Select Cart block, you should see the notice, select an inner block, you should see the notice as well.
- Click on the notice, it will load for a couple of seconds, once it's green, visit your new page.
- Make sure it's on the previous url, so
/cart. - Go back to settings, make sure your new page is that value there.
- Do the same thing for Checkout block.
- Open a new page, add Cart block, save the page and publish it.
- Select the block or one of its inner blocks, start the flow again.
- It should work, confirm that by visiting the frontend.
WooCommerce Visibility
- [x] WooCommerce Core
- [x] Feature plugin
- [ ] Experimental
Changelog
Allow making the Cart/Checkout block page the default one from within the editor.
The release ZIP for this PR is accessible via:
https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-6867.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 | |
|---|---|---|---|
cart.js |
wp-core-data, wp-editor |
⚠️ | |
checkout.js |
wp-core-data, wp-editor |
⚠️ |
This comment was automatically generated by the ./github/compare-assets action.
Size Change: +1.21 kB (0%)
Total Size: 869 kB
| Filename | Size | Change |
|---|---|---|
build/all-products.js |
33.7 kB | +8 B (0%) |
build/all-reviews.js |
7.79 kB | -3 B (0%) |
build/attribute-filter.js |
12.9 kB | +9 B (0%) |
build/cart.js |
41.8 kB | +584 B (+1%) |
build/checkout.js |
43.2 kB | +597 B (+1%) |
build/featured-category.js |
13.2 kB | +2 B (0%) |
build/featured-product.js |
13.5 kB | -1 B (0%) |
build/handpicked-products.js |
7.37 kB | +4 B (0%) |
build/legacy-template.js |
2.79 kB | -3 B (0%) |
build/mini-cart.js |
4.58 kB | +1 B (0%) |
build/price-filter.js |
9.09 kB | +5 B (0%) |
build/product-add-to-cart--product-button--product-image--product-title.js |
2.66 kB | -2 B (0%) |
build/product-add-to-cart.js |
6.88 kB | -1 B (0%) |
build/product-best-sellers.js |
7.71 kB | +1 B (0%) |
build/product-button.js |
1.57 kB | -1 B (0%) |
build/product-categories.js |
2.41 kB | -4 B (0%) |
build/product-category-list.js |
504 B | +1 B (0%) |
build/product-category.js |
8.69 kB | +4 B (0%) |
build/product-on-sale.js |
8.03 kB | -1 B (0%) |
build/product-query.js |
648 B | +1 B (0%) |
build/product-rating.js |
742 B | -1 B (0%) |
build/product-sale-badge.js |
803 B | -1 B (0%) |
build/product-search.js |
2.18 kB | +2 B (0%) |
build/product-sku.js |
380 B | -1 B (0%) |
build/product-stock-indicator.js |
625 B | -1 B (0%) |
build/product-summary.js |
919 B | -2 B (0%) |
build/product-tag.js |
8.08 kB | +1 B (0%) |
build/product-title.js |
920 B | -2 B (0%) |
build/product-top-rated.js |
7.95 kB | +2 B (0%) |
build/products-by-attribute.js |
8.63 kB | -1 B (0%) |
build/reviews-by-product.js |
12.3 kB | +1 B (0%) |
build/single-product.js |
10.1 kB | +9 B (0%) |
build/stock-filter.js |
7.45 kB | -2 B (0%) |
build/wc-blocks-editor-style-rtl.css |
5.07 kB | -1 B (0%) |
build/wc-blocks-editor-style.css |
5.07 kB | -2 B (0%) |
build/wc-blocks-vendors.js |
54.5 kB | +5 B (0%) |
build/wc-blocks.js |
2.63 kB | +1 B (0%) |
ℹ️ View Unchanged
| Filename | Size |
|---|---|
build/active-filters-frontend.js |
7.34 kB |
build/active-filters.js |
7.99 kB |
build/all-products-frontend.js |
18.1 kB |
build/attribute-filter-frontend.js |
21.9 kB |
build/blocks-checkout.js |
17.4 kB |
build/cart-blocks/cart-accepted-payment-methods-frontend.js |
1.16 kB |
build/cart-blocks/cart-express-payment-frontend.js |
5.09 kB |
build/cart-blocks/cart-items-frontend.js |
299 B |
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js |
5.27 kB |
build/cart-blocks/cart-line-items-frontend.js |
428 B |
build/cart-blocks/cart-order-summary-frontend.js |
1.1 kB |
build/cart-blocks/cart-totals-frontend.js |
321 B |
build/cart-blocks/empty-cart-frontend.js |
346 B |
build/cart-blocks/filled-cart-frontend.js |
781 B |
build/cart-blocks/order-summary-coupon-form-frontend.js |
2.65 kB |
build/cart-blocks/order-summary-discount-frontend.js |
2.15 kB |
build/cart-blocks/order-summary-fee-frontend.js |
274 B |
build/cart-blocks/order-summary-heading-frontend.js |
454 B |
build/cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping-frontend.js |
6.37 kB |
build/cart-blocks/order-summary-shipping-frontend.js |
426 B |
build/cart-blocks/order-summary-subtotal-frontend.js |
274 B |
build/cart-blocks/order-summary-taxes-frontend.js |
433 B |
build/cart-blocks/proceed-to-checkout-frontend.js |
1.15 kB |
build/cart-frontend.js |
47 kB |
build/checkout-blocks/actions-frontend.js |
1.42 kB |
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js |
4.12 kB |
build/checkout-blocks/billing-address-frontend.js |
891 B |
build/checkout-blocks/contact-information-frontend.js |
2.83 kB |
build/checkout-blocks/express-payment-frontend.js |
5.38 kB |
build/checkout-blocks/fields-frontend.js |
345 B |
build/checkout-blocks/order-note-frontend.js |
1.07 kB |
build/checkout-blocks/order-summary-cart-items-frontend.js |
3.66 kB |
build/checkout-blocks/order-summary-coupon-form-frontend.js |
2.8 kB |
build/checkout-blocks/order-summary-discount-frontend.js |
2.26 kB |
build/checkout-blocks/order-summary-fee-frontend.js |
276 B |
build/checkout-blocks/order-summary-frontend.js |
1.1 kB |
build/checkout-blocks/order-summary-shipping-frontend.js |
604 B |
build/checkout-blocks/order-summary-subtotal-frontend.js |
274 B |
build/checkout-blocks/order-summary-taxes-frontend.js |
433 B |
build/checkout-blocks/payment-frontend.js |
7.7 kB |
build/checkout-blocks/shipping-address-frontend.js |
1.03 kB |
build/checkout-blocks/shipping-methods-frontend.js |
4.74 kB |
build/checkout-blocks/terms-frontend.js |
1.23 kB |
build/checkout-blocks/totals-frontend.js |
325 B |
build/checkout-frontend.js |
49.2 kB |
build/general-style-rtl.css |
1.29 kB |
build/general-style.css |
1.29 kB |
build/mini-cart-component-frontend.js |
16.8 kB |
build/mini-cart-contents-block/empty-cart-frontend.js |
365 B |
build/mini-cart-contents-block/filled-cart-frontend.js |
229 B |
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js |
4.69 kB |
build/mini-cart-contents-block/footer-frontend.js |
6.98 kB |
build/mini-cart-contents-block/items-frontend.js |
237 B |
build/mini-cart-contents-block/products-table-frontend.js |
289 B |
build/mini-cart-contents-block/shopping-button-frontend.js |
288 B |
build/mini-cart-contents-block/title-frontend.js |
367 B |
build/mini-cart-contents.js |
22.9 kB |
build/mini-cart-frontend.js |
1.71 kB |
build/price-filter-frontend.js |
13.3 kB |
build/price-format.js |
1.19 kB |
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js |
223 B |
build/product-add-to-cart-frontend.js |
6.95 kB |
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js |
436 B |
build/product-button--product-image--product-rating--product-sale-badge--product-title.js |
301 B |
build/product-button-frontend.js |
1.87 kB |
build/product-category-list-frontend.js |
879 B |
build/product-image-frontend.js |
1.88 kB |
build/product-image.js |
1.59 kB |
build/product-new.js |
7.71 kB |
build/product-price-frontend.js |
1.9 kB |
build/product-price.js |
1.51 kB |
build/product-rating-frontend.js |
1.16 kB |
build/product-sale-badge-frontend.js |
1.13 kB |
build/product-sku-frontend.js |
381 B |
build/product-stock-indicator-frontend.js |
993 B |
build/product-summary-frontend.js |
1.29 kB |
build/product-tag-list-frontend.js |
872 B |
build/product-tag-list.js |
500 B |
build/product-title-frontend.js |
1.31 kB |
build/reviews-by-category.js |
11.2 kB |
build/reviews-frontend.js |
7.02 kB |
build/single-product-frontend.js |
21.4 kB |
build/stock-filter-frontend.js |
7.51 kB |
build/vendors--cart-blocks/cart-line-items--cart-blocks/cart-order-summary--cart-blocks/order-summary-shi--c02aad66-frontend.js |
5.26 kB |
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js |
3.14 kB |
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js |
4.85 kB |
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js |
19.1 kB |
build/vendors--mini-cart-contents-block/footer-frontend.js |
6.86 kB |
build/vendors--product-add-to-cart-frontend.js |
7.53 kB |
build/wc-blocks-data.js |
9.87 kB |
build/wc-blocks-google-analytics.js |
1.56 kB |
build/wc-blocks-middleware.js |
930 B |
build/wc-blocks-registry.js |
2.7 kB |
build/wc-blocks-shared-context.js |
1.52 kB |
build/wc-blocks-shared-hocs.js |
1.14 kB |
build/wc-blocks-style-rtl.css |
22.4 kB |
build/wc-blocks-style.css |
22.3 kB |
build/wc-blocks-vendors-style-rtl.css |
1.95 kB |
build/wc-blocks-vendors-style.css |
1.95 kB |
build/wc-payment-method-bacs.js |
816 B |
build/wc-payment-method-cheque.js |
811 B |
build/wc-payment-method-cod.js |
909 B |
build/wc-payment-method-paypal.js |
837 B |
build/wc-settings.js |
2.6 kB |
Based on the internal conversation p1660321370894249/1660311130.074619-slack-C8X6Q7XQU we will need to change the implementation:
- for perior to WC 6.8.0 we just show the current (old) notice that redirects you to the settings page.
- for WC >= 6.8.0 we show the new notification with the button, that the PR implements
@senadir Thank you for working on it. If I add a Checkout block and use a button to update the settings, it changes the slug to Cart.
https://user-images.githubusercontent.com/11503784/185606335-c97d55bb-1727-45fe-8325-97a35d281511.mov
For the Cart page, it is not updating the slug for me:
https://user-images.githubusercontent.com/11503784/185606425-d6069151-e166-4e75-8d3f-c6514dcdae61.mov
Can you please remove any existing saved Cart/Checkout page settings you have, it seems your previously default Checkout page has a cart path, and this is what's causing the issue.
Thank you for your review, @tarunvijwani! I'm merging this PR to include it in the 8.4.0 release!