Commit Graph

10 Commits

Author SHA1 Message Date
Mike Jolley 68064c115b Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773)
* Rename checkout template slug

* Remove redirect and custom title

* Classic shortcode block for checkout

* Empty title

* WIP placeholder

* Change blockified template

* Prefix cart and checkout templates with "Page: "

* Template migration routine

* Apply same treatment to cart template

* Notices

* Update placeholder text

* Classic shortcodes block

* Page content wrapper for templates

* Update default

* Do not save attributes

* Update templates

* Remove cart classic template

* Reverted endpoints for Cart & Checkout templates. This reverts PR 9406

* Migrate page content wrapper.

* Removed useless method arg. Minor tweaks.

* Skip migration if the theme has a template file for this page.

* Removed impossible condition.

* Migrate page content wrapper.

* Remove TemplateNotice in favour of DefaultNotice

* Documentation links in shortcode placeholder

* Hide cart and checkout page selector when using block themes

* Unused var

* Add tests for template changes

* Revert changes to classic-template

* Allow frontend redirect

* Unused file

* Bump version for updater

* Support x template naming as well as page-x

* Need to add item to cart to test checkout

* Fix header test by fixing utility for adding to cart

* Remove permalink tests

* Click body

* Wait for content to finish loading

* Wait for add to cart response when adding to cart without item name

* Wait for save before visiting frontend

* Set content instead of inserting block

* Perform test in site editor rather than page editor

* Prevent notice to set the default cart/checkout page from showing on the site editor.

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 10:58:18 +01:00
Paulo Arromba f1df8fb975 Add Cart/Checkout/Order-Received Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9301)
* WIP: dirty attempt to dry run Cart & Checkout templates

* Added Cart and Checkout to the template hierarchies

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Updated cart & Checkout templates

* Order Received FSE template (https://github.com/woocommerce/woocommerce-blocks/pull/8937)

* Order Received template bootstrap

* typo

* WIP: new block

* add logic here

* Order received classic template

* reverted constants.ts

* Added the post title (buggy)

* Corrected page title

* Updated constants.ts

* Fixed template typo

* removed placeholder for order received block

* add order-received template description

* updated placeholder description

* Formatting fixes

* Template description.

* replaced hardcoded string with OrderReceivedTemplate::SLUG

---------

Co-authored-by: Luigi <gigitux@gmail.com>

* Code formatting (https://github.com/woocommerce/woocommerce-blocks/pull/8350)

* Code formatting

* page_template_hierarchy priority to 1 (https://github.com/woocommerce/woocommerce-blocks/pull/9323)

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate Cart and Checkout Pages to the Template Editor when using a FSE theme (https://github.com/woocommerce/woocommerce-blocks/pull/9339)

* Introduce woocommerce_blocks_template_content hook

* Migrate cart and checkout page content to the template editor

* Add redirection from edit page to edit template

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Removed header and footer from checkout template. (https://github.com/woocommerce/woocommerce-blocks/pull/9378)

* Removed header and footer from checkout template.

* Removed header and footer from checkout template migration

* Permalink solution for the checkout endpoint/template (https://github.com/woocommerce/woocommerce-blocks/pull/9406)

* Checkout endpoint work

* Move setting field to util

* Include link to edit the template

* Remove todo

* Refactor checkout templates to share logic (https://github.com/woocommerce/woocommerce-blocks/pull/9411)

* Sync endpoints with pages (https://github.com/woocommerce/woocommerce-blocks/pull/9426)

* Switch to page syncing

* Update settings descriptions

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate pages to templates once (https://github.com/woocommerce/woocommerce-blocks/pull/9488)

* Migrate content on init, once

* Skip migration if page does not exist

* Put back HTML for header and footer parts

* Fix page redirect due to wrong ID

* fix loading template part

* Removed unnecessary var

* update cart and checkout html templates

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Include a notice to redirect user to template editor (https://github.com/woocommerce/woocommerce-blocks/pull/9508)

* Template Placeholder Design for the Order Received Template (https://github.com/woocommerce/woocommerce-blocks/pull/9602)

* Load frontend styles in editor iframe

* Update placeholder to include skeleton and updated icons

* Update classic template configs

* 1px border for .wp-block-woocommerce-classic-template__placeholder-copy

* Show copy on focus

* Sample data

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Add simplified header on checkout template (https://github.com/woocommerce/woocommerce-blocks/pull/9607)

* Added simplified header on checkout template

* Moved simplified header to template part

* updated constants.ts

* added template part to checkout.html

* Add missing translation

* frontpage_template_hierarchy no longer needed

* Allow plugin based template parts (https://github.com/woocommerce/woocommerce-blocks/pull/9667)

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Synced templates on blockified folder

* Add blockified order-received.html

* removed WooCommerce prefix

* Refactor/rebrand order received template to order confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/9734)

* rebrand order received to order confirmation

* updated descriptions for templates

* updated descriptions for order confirmation placeholder

* Resolve merge conflict

* Resolve merge conflicts

* Resolve more merge conflicts after rebase

* Fix formatting

* Use patterns for localisation (https://github.com/woocommerce/woocommerce-blocks/pull/9883)

* e2e tests for cart and checkout templates (https://github.com/woocommerce/woocommerce-blocks/pull/9939)

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Resolve merge conflicts

* Add e2e for permalink settings

* Test that templates exist

* Add test to check that templates can be edited

* Add tests to confirm templates can be edited

* Ensure cart has contents before running tests on frontend views

* Commend out problem test

* Make sure search has multiple results

* Remove useThrottle - bad rebase

* Revert changes to docs after rebase

* Revert function call for noReviewsPlaceholder

* Bad rebase

* Reverts

* Remove revertTemplate

* Spacing

* Wait for networkidle after navigation

* Always wait for network

* Use button roles in site editor

* More specific button locator

* Update option comparison

* Fix template content

* Disable failing tests

* Disable failing classic template tests

* Use enterEditMode

* More enterEditMode usage

* enterEditMode

* Use test.skip

* More robust selectors

* Alt iframe selector

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Skip flakey test

---------

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-06-29 14:41:22 +01:00
Mike Jolley 62c62d3326 Checkout Block: Avoid using editor buttons in the post content to prevent inheriting global styles (https://github.com/woocommerce/woocommerce-blocks/pull/8957)
* Remove express payment placeholders when there are no express payment methods

* Only use one instance of CartCheckoutFeedbackPrompt

* Show NoPaymentMethods notice in the inspector instead of the block

* Move privacy notices to inspector

* Unused hook

* Update tests to use mocks
2023-04-06 12:16:42 +01:00
Mike Jolley 280040653c Avoid returning before hooks are run (https://github.com/woocommerce/woocommerce-blocks/pull/8820) 2023-03-23 10:24:04 +00:00
Saad Tarhi 39b6c1c320 Improve the dismissal behavior of the incompatible gateways notice (https://github.com/woocommerce/woocommerce-blocks/pull/8299)
* Fix notice persistence after dismissal

- This fix applied to the `incompatible payment gateway notice`.
- We used the same dismissal logic in the `sidebar compatibility notice`

* Get incompatible payments when initialized

We initially get the list of `globalPaymentMethods` shared from
the back-end as incompatible payments, because the front-end
`availablePaymentMethods` is empty before the
`paymentMethodsInitialized` state

* Introduce advanced notice dismissal handling

We want to display a dismissed incompatible gateways notice, when the
list of incompatible gateways is updated (e.g., a new incompatible
gateway is enabled)

* Use the full block name for the `Cart` & `Checkout`

* Update variable name for comprehension

* Fix TS errors

* Remove unused imports
2023-02-24 11:57:24 +01:00
Tung Du 8662d853f4 Fix: unable to customize All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/8140) 2023-01-10 17:14:43 +07:00
Saad Tarhi 230606c7f7 Highlight incompatible payment gateways (https://github.com/woocommerce/woocommerce-blocks/pull/7412)
* Set up incompatiblePaymentMethods in data store

* Save incompatible payment methods in data store

* Create the IncompatibilityPaymentGatewaysNotice

* Fix hidden notice bug

* Rename "paymentAdminLink" to GlobalPaymentMethod and move to types dir

* Add all registered methods to incompatiblePaymentMethods state

* Rename selector to getIncompatiblePaymentMethods

* Remove incompatible methods when adding available ones

* Remove unused reducer cases

* Stop adding incompatible methods now that we add them in default state

* Display incompatible methods in the notice from the data store

* Refactor incompatible payment gateways notice

* Update the incompatible extensions notice's design

* Hide Make as default notice

We hide this notice while the notification for incompatible payment
gateways is visible

* Hide the sidebar compatibility notice

Hide this notice while  the notification for incompatible payment
gateways is visible. And show it otherwise.

* Capitalize the label for the button on the page settings notice

* Fix missing 'globalPaymentMethods' bug on frontend

* Highlight incompatible payments in sidebar

Highlight incompatible payment gateways within the Payment Options Block

* Rename the incompatible gateways notice's component

* Support plural and singular forms for the notice

* Update incompatible extensions notice's design

* Use the simplified types import

Co-authored-by: Niels Lange <info@nielslange.de>

* Add translation support to notice message

* Fix failing unit tests

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2022-12-28 17:30:46 +01:00
Saad Tarhi 5129341ee5 Show sidebar notices only when a WooCommerce block is selected (https://github.com/woocommerce/woocommerce-blocks/pull/7435)
We where running the "withSidebarNotices" HOC each time the
"editor.BlockEdit" hook is fired. The problem is that this hook is
fired on page editor scroll, when hovering over the blocks, when a
block preview is loading, etc.

So, we only want the "withSidebarNotices" HOC to be executed when a Woo
Block in selected!
2022-10-20 20:17:26 +01:00
Seghir Nadir 42f3ffefc9 Turn current page into the default Cart/Checkout page (https://github.com/woocommerce/woocommerce-blocks/pull/6867)
* Add default page notice

* show notice all inner blocks

* support flow when page isnt saved

* switch from where we get the current post id

* update lock

* fix types

* update logic to support cart as well

* fix package.json

* update design and move away from wc.data

* restore notice

* handle older versions of WooCommerce

* fix package lock

* fix typo
2022-08-29 09:35:05 +01:00
Thomas Roberts d45ef84219 Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869)
* Add default page notice

* show notice all inner blocks

* support flow when page isnt saved

* switch from where we get the current post id

* update lock

* fix types

* Remove old compatibility notices from Cart and Checkout

* Move useCompatibilityNotice to sidebar-compatibility-notice directory

* Remove old CartCheckoutCompatibilityNotice

* Create sidebar compatibility notice hoc

* Add isCartOrCheckoutOrInnerBlock function

* Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func

* Remove BlockSettings from checkout edit and export from checkout-shared

* Change so component still renders, it is just hidden with display: none

This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time.

* Set the priorities of the hoc filters so compat notice renders first

* Make isCartOrCheckoutInnerBlock a hook

* Remove old compatibility notice related tests

* Remove BlockSettings from Cart

* Remove withDefaultNotice hoc

* Include DefaultNotice in compatibility notice

* Remove DefaultNotice from Checkout

* Rename withSidebarCompatibilityNotice to withSidebarNotices

This is because it includes the sidebar compatibility notice and the default notices

* Remove useIsCartOrCheckoutOrInnerBlock hook

* Remove compatibility notice code from tests

* Revert DefaultNotice back to the old one

* Remove unused components

* Remove withBlockSettings HOC and fix TS types

This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks

* Remove CartCheckoutFeedbackPrompt from BlockSettings

It will be included in sidebar-notices instead

* Fix TS Types in DefaultNotice

* Add BlockSettings to cart and checkout edit

* Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)

* Show "Feedback prompt" for all inner blocks

* Fix the "feedback" notice position for these blocks

The "checkout fields", "checkout billing address" and
"checkout shipping address" have the addressFields option which
gets rerendered and placed at the bottom of the inspector controls.

* Tidy up the address-fields hoc

* Use correct block name to check for billing or shipping address

* Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)"

This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f.

* Add hack to get feedback prompt to render last

* Fix TS errors for context and attributes

* Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols

* Do not include feedback prompt if on an address block or contact info

* Remove unused hoc for address fields

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 15:23:08 +01:00