From a46f13c6c58a6b5828e389c7f500e93ebbc03baf Mon Sep 17 00:00:00 2001 From: Thomas Roberts <5656702+opr@users.noreply.github.com> Date: Fri, 28 Jan 2022 16:37:06 +0000 Subject: [PATCH] Move Checkout block attributes into metadata (`block.json`) (https://github.com/woocommerce/woocommerce-blocks/pull/5594) * Add block title to AbstractBlock class * Add block title to Checkout block * Include all block.json files in tsconfig * Add get_block_title method to Checkout.php * Remove redundant block_title field * Add block.json and remove static attributes from attributes.ts * Register block using attributes from block.json * Add metadata_path to AbstractBlock * Add function to AssetsApi to get the metadata path from the plugin root * Register the block using metadata if it's set in the block's class * Remove get_block_title method * Only add supports and attributes to the block when not registering with metadata * Change get_block_metadata to get_block_metadata_path * Change indentation to tabs in block.json * Update comment to clarify why attributes and supports are set later * Check if path to metadata is not empty instead of set and not empty * Move checkout block out of cart-checkout directory * Update get_block_metadata_path function to find block.json automatically * Remove metadata path from AbstractBlock * Check if there's a metadata file and register blocks with metadata if so * Move deprecated attributes out of metadata and into attributes.ts * Re-add deprecated attributes to checkout index * Move order notes test * Move test for checkout phone number in edito * Fix indentation in checkout/block.json * Move checkout terms tests * Try forcing storefront theme in e2e tests * Revert "Try forcing storefront theme in e2e tests" This reverts commit 5b0fd47a2c39aadb0141a4ed28cbc0e6baa89625. * Try capturing screenshot on test failures * Try uploading error in try catch * Try uploading artefacts on error * Test uploading artefacts * Screenshot just before looking for edit post layout * Revert "Screenshot just before looking for edit post layout" This reverts commit 61dff027789ce13a0d84e7b6f11e431637c5a450. * Revert "Test uploading artefacts" This reverts commit adf5cc55bcdb677f889bf5a62803b4150d98e665. * Revert "Try uploading artefacts on error" This reverts commit 7441a832a113a95fef89cc1b8db6dc79271be516. * Revert "Try uploading error in try catch" This reverts commit ca412ce505d56286b164f588a201a451f6bceeb6. * Revert "Try capturing screenshot on test failures" This reverts commit 0de6e97df19b116091a7bb3b8652713867d2d80f. Co-authored-by: Alex Florisca --- .../checkout/attributes.ts | 40 ++++------------ .../assets/js/blocks/checkout/block.json | 46 +++++++++++++++++++ .../{cart-checkout => }/checkout/block.tsx | 0 .../checkout-order-error/constants.js | 0 .../checkout/checkout-order-error/index.js | 0 .../checkout/checkout-order-error/style.scss | 0 .../{cart-checkout => }/checkout/context.ts | 0 .../{cart-checkout => }/checkout/edit.tsx | 5 +- .../checkout/empty-cart/index.js | 0 .../checkout/empty-cart/style.scss | 0 .../checkout/form-step/additional-fields.tsx | 2 +- .../checkout/form-step/attributes.ts | 0 .../checkout/form-step/editor.scss | 0 .../checkout/form-step/form-step-block.tsx | 0 .../checkout/form-step/form-step-heading.tsx | 0 .../checkout/form-step/index.tsx | 0 .../{cart-checkout => }/checkout/frontend.tsx | 0 .../{cart-checkout => }/checkout/index.tsx | 29 +++++------- .../checkout-actions-block/attributes.tsx | 0 .../checkout-actions-block/block.json | 0 .../checkout-actions-block/block.tsx | 0 .../checkout-actions-block/edit.tsx | 0 .../checkout-actions-block/frontend.tsx | 0 .../checkout-actions-block/index.tsx | 0 .../checkout-actions-block/style.scss | 0 .../attributes.tsx | 0 .../checkout-billing-address-block/block.json | 0 .../checkout-billing-address-block/block.tsx | 0 .../checkout-billing-address-block/edit.tsx | 0 .../frontend.tsx | 0 .../checkout-billing-address-block/index.tsx | 0 .../attributes.tsx | 0 .../block.json | 0 .../block.tsx | 0 .../edit.tsx | 0 .../frontend.tsx | 0 .../index.tsx | 0 .../login-prompt.js | 0 .../checkout-express-payment-block/block.json | 0 .../checkout-express-payment-block/block.tsx | 2 +- .../checkout-express-payment-block/edit.tsx | 0 .../editor.scss | 0 .../checkout-express-payment-block/index.tsx | 0 .../checkout-fields-block/block.json | 0 .../checkout-fields-block/edit.tsx | 5 +- .../checkout-fields-block/frontend.tsx | 0 .../checkout-fields-block/index.tsx | 0 .../checkout-fields-block/style.scss | 0 .../checkout-order-note-block/block.json | 0 .../checkout-order-note-block/block.tsx | 0 .../checkout-order-note-block/edit.tsx | 0 .../checkout-order-note-block/editor.scss | 0 .../checkout-order-note-block/index.tsx | 0 .../attributes.tsx | 0 .../checkout-order-summary-block/block.json | 0 .../checkout-order-summary-block/block.tsx | 0 .../checkout-order-summary-block/edit.tsx | 0 .../checkout-order-summary-block/index.tsx | 0 .../checkout-payment-block/attributes.tsx | 0 .../checkout-payment-block/block.json | 0 .../checkout-payment-block/block.tsx | 2 +- .../checkout-payment-block/edit.tsx | 0 .../checkout-payment-block/frontend.tsx | 0 .../checkout-payment-block/index.tsx | 0 .../attributes.tsx | 0 .../block.json | 0 .../checkout-shipping-address-block/block.tsx | 0 .../checkout-shipping-address-block/edit.tsx | 0 .../frontend.tsx | 0 .../checkout-shipping-address-block/index.tsx | 0 .../attributes.tsx | 0 .../block.json | 0 .../checkout-shipping-methods-block/block.tsx | 0 .../checkout-shipping-methods-block/edit.tsx | 0 .../frontend.tsx | 0 .../checkout-shipping-methods-block/index.tsx | 0 .../no-shipping-placeholder/index.js | 0 .../no-shipping-placeholder/style.scss | 0 .../style.scss | 0 .../checkout-terms-block/block.json | 0 .../checkout-terms-block/constants.js | 0 .../checkout-terms-block/edit.tsx | 0 .../checkout-terms-block/editor.scss | 0 .../checkout-terms-block/frontend.tsx | 0 .../checkout-terms-block/index.tsx | 0 .../checkout-terms-block/style.scss | 0 .../checkout-terms-block/test/edit.js | 0 .../checkout-terms-block/test/frontend.js | 0 .../checkout-totals-block/block.json | 0 .../checkout-totals-block/edit.tsx | 5 +- .../checkout-totals-block/frontend.tsx | 0 .../checkout-totals-block/index.tsx | 0 .../checkout-totals-block/style.scss | 0 .../checkout/inner-blocks/index.tsx | 0 .../inner-blocks/register-components.ts | 0 .../checkout/order-notes/index.js | 0 .../checkout/order-notes/style.scss | 0 .../checkout/order-notes/test/index.js | 0 .../checkout/phone-number/index.tsx | 0 .../checkout/phone-number/test/index.js | 0 .../checkout/styles/editor.scss | 0 .../checkout/styles/style.scss | 0 .../{cart-checkout => }/checkout/types.ts | 0 .../{cart-checkout => }/checkout/utils.ts | 0 .../woocommerce-blocks/bin/webpack-entries.js | 4 +- plugins/woocommerce-blocks/src/Assets/Api.php | 15 ++++++ .../src/BlockTypes/AbstractBlock.php | 20 +++++++- plugins/woocommerce-blocks/tsconfig.json | 2 +- 108 files changed, 116 insertions(+), 61 deletions(-) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/attributes.ts (55%) create mode 100644 plugins/woocommerce-blocks/assets/js/blocks/checkout/block.json rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/checkout-order-error/constants.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/checkout-order-error/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/checkout-order-error/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/context.ts (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/edit.tsx (98%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/empty-cart/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/empty-cart/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/additional-fields.tsx (89%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/attributes.ts (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/editor.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/form-step-block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/form-step-heading.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/form-step/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/index.tsx (82%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-actions-block/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-billing-address-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-contact-information-block/login-prompt.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-express-payment-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-express-payment-block/block.tsx (83%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-express-payment-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-express-payment-block/editor.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-express-payment-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-fields-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-fields-block/edit.tsx (95%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-fields-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-fields-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-fields-block/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-note-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-note-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-note-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-note-block/editor.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-note-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-summary-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-summary-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-summary-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-order-summary-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/block.tsx (69%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-payment-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-address-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-shipping-methods-block/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/constants.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/edit.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/editor.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/test/edit.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-terms-block/test/frontend.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-totals-block/block.json (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-totals-block/edit.tsx (94%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-totals-block/frontend.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-totals-block/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/checkout-totals-block/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/inner-blocks/register-components.ts (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/order-notes/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/order-notes/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/order-notes/test/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/phone-number/index.tsx (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/phone-number/test/index.js (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/styles/editor.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/styles/style.scss (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/types.ts (100%) rename plugins/woocommerce-blocks/assets/js/blocks/{cart-checkout => }/checkout/utils.ts (100%) diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/attributes.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/attributes.ts similarity index 55% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/attributes.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/attributes.ts index f9e1dc67749..c28a8218483 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/attributes.ts +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/attributes.ts @@ -5,40 +5,20 @@ import { getSetting } from '@woocommerce/settings'; export const blockName = 'woocommerce/checkout'; export const blockAttributes = { - isPreview: { - type: 'boolean', - default: false, - save: false, - }, hasDarkControls: { type: 'boolean', default: getSetting( 'hasDarkEditorStyleSupport', false ), }, - showCompanyField: { + showRateAfterTaxName: { type: 'boolean', - default: false, + default: getSetting( 'displayCartPricesIncludingTax', false ), }, - requireCompanyField: { - type: 'boolean', - default: false, - }, - allowCreateAccount: { - type: 'boolean', - default: false, - }, - showApartmentField: { - type: 'boolean', - default: true, - }, - showPhoneField: { - type: 'boolean', - default: true, - }, - requirePhoneField: { - type: 'boolean', - default: false, - }, - // Deprecated - here for v1 migration support +}; + +/** + * @deprecated here for v1 migration support + */ +export const deprecatedAttributes = { showOrderNotes: { type: 'boolean', default: true, @@ -55,8 +35,4 @@ export const blockAttributes = { type: 'number', default: 0, }, - showRateAfterTaxName: { - type: 'boolean', - default: getSetting( 'displayCartPricesIncludingTax', false ), - }, }; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.json new file mode 100644 index 00000000000..437677063f5 --- /dev/null +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.json @@ -0,0 +1,46 @@ +{ + "name": "woocommerce/checkout", + "version": "1.0.0", + "title": "Checkout", + "description": "Display a checkout form so your customers can submit orders.", + "category": "woocommerce", + "keywords": [ "WooCommerce" ], + "supports": { + "align": [ "wide" ], + "html": false, + "multiple": false + }, + "attributes": { + "isPreview": { + "type": "boolean", + "default": false, + "save": false + }, + "showCompanyField": { + "type": "boolean", + "default": false + }, + "requireCompanyField": { + "type": "boolean", + "default": false + }, + "allowCreateAccount": { + "type": "boolean", + "default": false + }, + "showApartmentField": { + "type": "boolean", + "default": true + }, + "showPhoneField": { + "type": "boolean", + "default": true + }, + "requirePhoneField": { + "type": "boolean", + "default": false + } + }, + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/constants.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/constants.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/constants.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/constants.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/checkout-order-error/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/context.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/context.ts similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/context.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/context.ts diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx similarity index 98% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx index b906718580c..f4b1cd1ca0a 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx @@ -35,7 +35,10 @@ import type { TemplateArray } from '@wordpress/blocks'; * Internal dependencies */ import './styles/editor.scss'; -import { addClassToBody, useBlockPropsWithLocking } from '../shared'; +import { + addClassToBody, + useBlockPropsWithLocking, +} from '../cart-checkout/shared'; import { CheckoutBlockContext, CheckoutBlockControlsContext } from './context'; import type { Attributes } from './types'; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/empty-cart/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/empty-cart/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/empty-cart/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/empty-cart/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/additional-fields.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/additional-fields.tsx similarity index 89% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/additional-fields.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/additional-fields.tsx index 968e30c537d..3c3cfb489b5 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/additional-fields.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/additional-fields.tsx @@ -7,7 +7,7 @@ import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; * Internal dependencies */ import './editor.scss'; -import { useForcedLayout, getAllowedBlocks } from '../../shared'; +import { useForcedLayout, getAllowedBlocks } from '../../cart-checkout/shared'; export const AdditionalFields = ( { block, diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/attributes.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/attributes.ts similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/attributes.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/attributes.ts diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/editor.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/editor.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/editor.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/editor.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/form-step-block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/form-step-block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/form-step-block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/form-step-block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/form-step-heading.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/form-step-heading.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/form-step-heading.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/form-step-heading.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/form-step/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/form-step/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/index.tsx similarity index 82% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/index.tsx index b44d1b16231..15820a8581b 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/index.tsx @@ -1,7 +1,6 @@ /** * External dependencies */ -import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; import { Icon, fields } from '@woocommerce/icons'; import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; @@ -11,11 +10,11 @@ import { BlockInstance, createBlock } from '@wordpress/blocks'; * Internal dependencies */ import { Edit, Save } from './edit'; -import { blockName, blockAttributes } from './attributes'; +import { blockAttributes, deprecatedAttributes } from './attributes'; import './inner-blocks'; +import metadata from './block.json'; const settings = { - title: __( 'Checkout', 'woo-gutenberg-products-block' ), icon: { src: ( ), }, - category: 'woocommerce', - keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ], - description: __( - 'Display a checkout form so your customers can submit orders.', - 'woo-gutenberg-products-block' - ), - supports: { - align: [ 'wide' ], - html: false, - multiple: false, + attributes: { + ...metadata.attributes, + ...blockAttributes, + ...deprecatedAttributes, }, - attributes: blockAttributes, - apiVersion: 2, edit: Edit, save: Save, // Migrates v1 to v2 checkout. deprecated: [ { - attributes: blockAttributes, + attributes: { + ...metadata.attributes, + ...blockAttributes, + ...deprecatedAttributes, + }, save( { attributes }: { attributes: { className: string } } ) { return (
{ const { cartNeedsPayment } = useStoreCart(); diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/editor.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/editor.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/editor.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/editor.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-express-payment-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/edit.tsx similarity index 95% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/edit.tsx index 1ba7f7fb1ed..eb35dfef8df 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/edit.tsx @@ -11,7 +11,10 @@ import type { TemplateArray } from '@wordpress/blocks'; * Internal dependencies */ import { useCheckoutBlockControlsContext } from '../../context'; -import { useForcedLayout, getAllowedBlocks } from '../../../shared'; +import { + useForcedLayout, + getAllowedBlocks, +} from '../../../cart-checkout/shared'; import './style.scss'; export const Edit = ( { diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/editor.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/editor.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/editor.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/editor.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-note-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-order-summary-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/attributes.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/attributes.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/attributes.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/attributes.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/block.tsx similarity index 69% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/block.tsx index 191a060bca2..a8554d856df 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/block.tsx @@ -5,7 +5,7 @@ /** * Internal dependencies */ -import { PaymentMethods } from '../../../payment-methods'; +import { PaymentMethods } from '../../../cart-checkout/payment-methods'; const Block = (): JSX.Element | null => { return ; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-payment-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-shipping-methods-block/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/constants.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/constants.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/constants.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/constants.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/edit.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/edit.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/editor.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/editor.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/editor.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/editor.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/test/edit.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/test/edit.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/test/edit.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/test/edit.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/test/frontend.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/test/frontend.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/test/frontend.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-terms-block/test/frontend.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/block.json similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/block.json diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/edit.tsx similarity index 94% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/edit.tsx index 95c35ba15d4..ad271e3f359 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/edit.tsx @@ -11,7 +11,10 @@ import type { TemplateArray } from '@wordpress/blocks'; * Internal dependencies */ import './style.scss'; -import { useForcedLayout, getAllowedBlocks } from '../../../shared'; +import { + useForcedLayout, + getAllowedBlocks, +} from '../../../cart-checkout/shared'; import { useCheckoutBlockContext } from '../../context'; export const Edit = ( { diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/frontend.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/frontend.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/frontend.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/frontend.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-totals-block/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/register-components.ts similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/register-components.ts diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/test/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/test/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/order-notes/test/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/order-notes/test/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/phone-number/index.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/phone-number/index.tsx similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/phone-number/index.tsx rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/phone-number/index.tsx diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/phone-number/test/index.js b/plugins/woocommerce-blocks/assets/js/blocks/checkout/phone-number/test/index.js similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/phone-number/test/index.js rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/phone-number/test/index.js diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/styles/editor.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/styles/editor.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/styles/editor.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/styles/editor.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/styles/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/checkout/styles/style.scss similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/styles/style.scss rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/styles/style.scss diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/types.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/types.ts similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/types.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/types.ts diff --git a/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/utils.ts b/plugins/woocommerce-blocks/assets/js/blocks/checkout/utils.ts similarity index 100% rename from plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/checkout/utils.ts rename to plugins/woocommerce-blocks/assets/js/blocks/checkout/utils.ts diff --git a/plugins/woocommerce-blocks/bin/webpack-entries.js b/plugins/woocommerce-blocks/bin/webpack-entries.js index 3c4d256809e..e6be19dcd5c 100644 --- a/plugins/woocommerce-blocks/bin/webpack-entries.js +++ b/plugins/woocommerce-blocks/bin/webpack-entries.js @@ -43,9 +43,7 @@ const blocks = { cart: { customDir: 'cart-checkout/cart', }, - checkout: { - customDir: 'cart-checkout/checkout', - }, + checkout: {}, 'mini-cart': { customDir: 'cart-checkout/mini-cart', isExperimental: true, diff --git a/plugins/woocommerce-blocks/src/Assets/Api.php b/plugins/woocommerce-blocks/src/Assets/Api.php index dd9612e272d..4aa20b89fba 100644 --- a/plugins/woocommerce-blocks/src/Assets/Api.php +++ b/plugins/woocommerce-blocks/src/Assets/Api.php @@ -60,6 +60,21 @@ class Api { return $this->package->get_url( $relative_path ); } + /** + * Get the path to a block's metadata + * + * @param string $block_name The block to get metadata for. + * + * @return string|boolean False if metadata file is not found for the block. + */ + public function get_block_metadata_path( $block_name ) { + $path_to_metadata_from_plugin_root = $this->package->get_path( 'assets/js/blocks/' . $block_name . '/block.json' ); + if ( ! file_exists( $path_to_metadata_from_plugin_root ) ) { + return false; + } + return $path_to_metadata_from_plugin_root; + } + /** * Get src, version and dependencies given a script relative src. * diff --git a/plugins/woocommerce-blocks/src/BlockTypes/AbstractBlock.php b/plugins/woocommerce-blocks/src/BlockTypes/AbstractBlock.php index 20841ffd398..280f04516fc 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/AbstractBlock.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/AbstractBlock.php @@ -181,14 +181,30 @@ abstract class AbstractBlock { 'editor_script' => $this->get_block_type_editor_script( 'handle' ), 'editor_style' => $this->get_block_type_editor_style(), 'style' => $this->get_block_type_style(), - 'attributes' => $this->get_block_type_attributes(), - 'supports' => $this->get_block_type_supports(), ]; if ( isset( $this->api_version ) && '2' === $this->api_version ) { $block_settings['api_version'] = 2; } + $metadata_path = $this->asset_api->get_block_metadata_path( $this->block_name ); + // Prefer to register with metadata if the path is set in the block's class. + if ( ! empty( $metadata_path ) ) { + register_block_type( + $metadata_path, + $block_settings + ); + return; + } + + /* + * Insert attributes and supports if we're not registering the block using metadata. + * These are left unset until now and only added here because if they were set when registering with metadata, + * the attributes and supports from $block_settings would override the values from metadata. + */ + $block_settings['attributes'] = $this->get_block_type_attributes(); + $block_settings['supports'] = $this->get_block_type_supports(); + register_block_type( $this->get_block_type(), $block_settings diff --git a/plugins/woocommerce-blocks/tsconfig.json b/plugins/woocommerce-blocks/tsconfig.json index cef4cd07024..c3de0213c48 100644 --- a/plugins/woocommerce-blocks/tsconfig.json +++ b/plugins/woocommerce-blocks/tsconfig.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.base.json", "include": [ "./assets/js/**/*", - "./assets/js/blocks/cart-checkout/checkout/inner-blocks/**/block.json", + "./assets/js/blocks/cart-checkout/checkout/**/block.json", "./assets/js/blocks/cart-checkout/mini-cart-contents/inner-blocks/**/block.json", "./storybook/**/*" ],