diff --git a/assets/js/atomic/utils/render-parent-block.tsx b/assets/js/atomic/utils/render-parent-block.tsx index 7245914d225..f39acaaa46e 100644 --- a/assets/js/atomic/utils/render-parent-block.tsx +++ b/assets/js/atomic/utils/render-parent-block.tsx @@ -138,16 +138,13 @@ const renderInnerBlocks = ( { const parsedElement = parse( element.outerHTML ); if ( isValidElement( parsedElement ) ) { - const elementChildren = - element.children && element.children.length - ? renderInnerBlocks( { - block, - blockMap, - children: element.children, - depth: depth + 1, - blockWrapper, - } ) - : null; + const elementChildren = renderInnerBlocks( { + block, + blockMap, + children: element.children || [], + depth: depth + 1, + blockWrapper, + } ); return elementChildren ? cloneElement( parsedElement, @@ -243,15 +240,12 @@ export const renderParentBlock = ( { * In addition to getProps, we need to render and return the children. This adds children to props. */ const getPropsWithChildren = ( element: Element, i: number ) => { - const children = - element.children && element.children.length - ? renderInnerBlocks( { - block: blockName, - blockMap, - children: element.children, - blockWrapper, - } ) - : null; + const children = renderInnerBlocks( { + block: blockName, + blockMap, + children: element.children || [], + blockWrapper, + } ); return { ...getProps( element, i ), children }; }; /** diff --git a/assets/js/base/components/cart-checkout/form-step/style.scss b/assets/js/base/components/cart-checkout/form-step/style.scss index f92720841ac..e6d086a45a5 100644 --- a/assets/js/base/components/cart-checkout/form-step/style.scss +++ b/assets/js/base/components/cart-checkout/form-step/style.scss @@ -119,3 +119,11 @@ } } } + +.editor-styles-wrapper { + .wp-block h4.wc-block-components-checkout-step__title { + @include font-size(regular); + line-height: 24px; + margin: 0 $gap-small 0 0; + } +} diff --git a/assets/js/base/components/checkbox-control/style.scss b/assets/js/base/components/checkbox-control/style.scss index 83fa5719bac..9bf12a6d034 100644 --- a/assets/js/base/components/checkbox-control/style.scss +++ b/assets/js/base/components/checkbox-control/style.scss @@ -3,6 +3,7 @@ align-items: flex-start; display: flex; position: relative; + margin-top: em($gap-large); .wc-block-components-checkbox__input[type="checkbox"] { font-size: 1em; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/constants.js b/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/constants.js deleted file mode 100644 index e564d2bdb5f..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/constants.js +++ /dev/null @@ -1,8 +0,0 @@ -export const PRODUCT_OUT_OF_STOCK = 'woocommerce_product_out_of_stock'; -export const PRODUCT_NOT_PURCHASABLE = - 'woocommerce_rest_cart_product_is_not_purchasable'; -export const PRODUCT_NOT_ENOUGH_STOCK = - 'woocommerce_rest_cart_product_no_stock'; -export const PRODUCT_SOLD_INDIVIDUALLY = - 'woocommerce_rest_cart_product_sold_individually'; -export const GENERIC_CART_ITEM_ERROR = 'woocommerce_rest_cart_item_error'; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/index.js b/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/index.js deleted file mode 100644 index 3e283360add..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/checkout-order-error/index.js +++ /dev/null @@ -1,136 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { CART_URL } from '@woocommerce/block-settings'; -import { Icon, removeCart } from '@woocommerce/icons'; -import { getSetting } from '@woocommerce/settings'; -import { decodeEntities } from '@wordpress/html-entities'; - -/** - * Internal dependencies - */ -import { - PRODUCT_OUT_OF_STOCK, - PRODUCT_NOT_PURCHASABLE, - PRODUCT_NOT_ENOUGH_STOCK, - PRODUCT_SOLD_INDIVIDUALLY, - GENERIC_CART_ITEM_ERROR, -} from './constants'; - -const cartItemErrorCodes = [ - PRODUCT_OUT_OF_STOCK, - PRODUCT_NOT_PURCHASABLE, - PRODUCT_NOT_ENOUGH_STOCK, - PRODUCT_SOLD_INDIVIDUALLY, - GENERIC_CART_ITEM_ERROR, -]; - -/** - * When an order was not created for the checkout, for example, when an item - * was out of stock, this component will be shown instead of the checkout form. - * - * The error message is derived by the hydrated API request passed to the - * checkout block. - */ -const CheckoutOrderError = () => { - const preloadedApiRequests = getSetting( 'preloadedApiRequests', {} ); - const checkoutData = { - code: '', - message: '', - ...( preloadedApiRequests[ '/wc/store/checkout' ]?.body || {} ), - }; - - const errorData = { - code: checkoutData.code || 'unknown', - message: - decodeEntities( checkoutData.message ) || - __( - 'There was a problem checking out. Please try again. If the problem persists, please get in touch with us so we can assist.', - 'woo-gutenberg-products-block' - ), - }; - - return ( -
- - - - -
- ); -}; - -/** - * Get the error message to display. - * - * @param {Object} props Incoming props for the component. - * @param {Object} props.errorData Object containing code and message. - */ -const ErrorTitle = ( { errorData } ) => { - let heading = __( 'Checkout error', 'woo-gutenberg-products-block' ); - - if ( cartItemErrorCodes.includes( errorData.code ) ) { - heading = __( - 'There is a problem with your cart', - 'woo-gutenberg-products-block' - ); - } - - return ( - { heading } - ); -}; - -/** - * Get the error message to display. - * - * @param {Object} props Incoming props for the component. - * @param {Object} props.errorData Object containing code and message. - */ -const ErrorMessage = ( { errorData } ) => { - let message = errorData.message; - - if ( cartItemErrorCodes.includes( errorData.code ) ) { - message = - message + - ' ' + - __( - 'Please edit your cart and try again.', - 'woo-gutenberg-products-block' - ); - } - - return

{ message }

; -}; - -/** - * Get the CTA button to display. - * - * @param {Object} props Incoming props for the component. - * @param {Object} props.errorData Object containing code and message. - */ -const ErrorButton = ( { errorData } ) => { - let buttonText = __( 'Retry', 'woo-gutenberg-products-block' ); - let buttonUrl = 'javascript:window.location.reload(true)'; - - if ( cartItemErrorCodes.includes( errorData.code ) ) { - buttonText = __( 'Edit your cart', 'woo-gutenberg-products-block' ); - buttonUrl = CART_URL; - } - - return ( - - - { buttonText } - - - ); -}; - -export default CheckoutOrderError; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/empty-cart/index.js b/assets/js/blocks/cart-checkout/checkout-i2/empty-cart/index.js deleted file mode 100644 index 2cd8ba11d5b..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/empty-cart/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { SHOP_URL } from '@woocommerce/block-settings'; -import { Icon, cart } from '@woocommerce/icons'; - -const EmptyCart = () => { - return ( -
- - - { __( 'Your cart is empty!', 'woo-gutenberg-products-block' ) } - -

- { __( - "Checkout is not available whilst your cart is empty—please take a look through our store and come back when you're ready to place an order.", - 'woo-gutenberg-products-block' - ) } -

- { SHOP_URL && ( - - - { __( 'Browse store', 'woo-gutenberg-products-block' ) } - - - ) } -
- ); -}; - -export default EmptyCart; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/index.tsx deleted file mode 100644 index 8ee8c4575e5..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, button } from '@wordpress/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import attributes from './attributes'; -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-actions-block', { - title: __( 'Actions', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Allow customers to place their order.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/index.tsx deleted file mode 100644 index 926a2a7089c..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, address } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-billing-address-block', { - title: __( 'Billing Address', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - "Collect your customer's billing address.", - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/index.tsx deleted file mode 100644 index 4ea953ae966..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/index.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, contact } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( - 'woocommerce/checkout-contact-information-block', - { - title: __( 'Contact Information', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - "Collect your customer's contact information.", - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, - } -); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/index.tsx deleted file mode 100644 index c2dfe1c7468..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, card } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-express-payment-block', { - title: __( 'Express Checkout', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Provide an express payment option for your customers.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes: { - lock: { - type: 'object', - default: { - remove: true, - move: true, - }, - }, - }, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/index.tsx deleted file mode 100644 index 201c971e10e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, column } from '@wordpress/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-fields-block', { - title: __( 'Checkout Fields Block', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Column containing checkout address fields.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-i2' ], - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/index.tsx deleted file mode 100644 index 696bc42d04e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/index.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, notes } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-order-note-block', { - title: __( 'Order Note', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Allow customers to add a note to their order.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes: { - lock: { - type: 'object', - default: { - move: true, - remove: true, - }, - }, - }, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/index.tsx deleted file mode 100644 index 5d896946978..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, totals } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-order-summary-block', { - title: __( 'Order Summary', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Show customers a summary of their order.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-totals-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/index.tsx deleted file mode 100644 index e1fc8784b5e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, card } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-payment-block', { - title: __( 'Payment Options', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Payment options for your store.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/index.tsx deleted file mode 100644 index 2d99e486215..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, address } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-shipping-address-block', { - title: __( 'Shipping Address', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - "Collect your customer's shipping address.", - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/index.tsx deleted file mode 100644 index cec359f6c6e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, truck } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; -import attributes from './attributes'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-shipping-methods-block', { - title: __( 'Shipping Options', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Shipping options for your store.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/index.tsx deleted file mode 100644 index 4e106d77315..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/index.tsx +++ /dev/null @@ -1,42 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, asterisk } from '@woocommerce/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-terms-block', { - title: __( 'Terms and Conditions', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Ensure customers agree to your terms and conditions and privacy policy.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - }, - parent: [ 'woocommerce/checkout-fields-block' ], - attributes: { - checkbox: { - type: 'boolean', - default: false, - }, - text: { - type: 'string', - required: false, - }, - }, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/index.tsx b/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/index.tsx deleted file mode 100644 index 7664ba2b658..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, column } from '@wordpress/icons'; -import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import { Edit, Save } from './edit'; - -registerFeaturePluginBlockType( 'woocommerce/checkout-totals-block', { - title: __( 'Checkout Totals Block', 'woo-gutenberg-products-block' ), - category: 'woocommerce', - description: __( - 'Column containing the checkout totals.', - 'woo-gutenberg-products-block' - ), - icon: { - src: , - foreground: '#874FB9', - }, - supports: { - align: false, - html: false, - multiple: false, - reusable: false, - inserter: false, - }, - parent: [ 'woocommerce/checkout-i2' ], - attributes: {}, - apiVersion: 2, - edit: Edit, - save: Save, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/styles/style.scss b/assets/js/blocks/cart-checkout/checkout-i2/styles/style.scss deleted file mode 100644 index 0d6cae75645..00000000000 --- a/assets/js/blocks/cart-checkout/checkout-i2/styles/style.scss +++ /dev/null @@ -1,98 +0,0 @@ -// Loading skeleton. - -.is-loading.wp-block-woocommerce-checkout-i2 { - .wp-block-woocommerce-checkout-totals-block, - .wp-block-woocommerce-checkout-fields-block { - > div { - @include placeholder(); - margin: 0 0 1.5em 0; - display: none; - } - - .wp-block-woocommerce-checkout-contact-information-block, - .wp-block-woocommerce-checkout-payment-block { - min-height: 10em; - display: block; - } - .wp-block-woocommerce-checkout-shipping-address-block { - min-height: 24em; - display: block; - } - .wp-block-woocommerce-checkout-actions-block { - width: 50%; - min-height: 4em; - margin-left: 50%; - display: block; - } - .wp-block-woocommerce-checkout-order-summary-block { - min-height: 47em; - display: block; - } - } - - // @todo these styles replace the need for SidebarLayout styles. We define styles here so placeholder elements (loading state) for the checkout has the same sidebar type layout before JS loads. - &.wp-block-woocommerce-checkout-i2 { - display: flex; - flex-wrap: wrap; - margin: 0 auto $gap; - position: relative; - - .wp-block-woocommerce-checkout-fields-block { - box-sizing: border-box; - margin: 0; - padding-right: percentage(math.div($gap-largest, 1060px)); // ~1060px is the default width of the content area in Storefront. - width: 65%; - } - .wp-block-woocommerce-checkout-totals-block { - box-sizing: border-box; - margin: 0; - padding-left: percentage(math.div($gap-large, 1060px)); - width: 35%; - - .wc-block-components-panel > h2 { - @include font-size(regular); - @include reset-box(); - @include reset-typography(); - .wc-block-components-panel__button { - font-weight: 400; - } - } - } - } - - .is-medium, - .is-small, - .is-mobile { - &.wp-block-woocommerce-checkout-i2 { - flex-direction: column; - margin: 0 auto $gap; - - .wp-block-woocommerce-checkout-fields-block { - padding: 0; - width: 100%; - } - .wp-block-woocommerce-checkout-totals-block { - padding: 0; - width: 100%; - } - } - } - - .is-large { - .wp-block-woocommerce-checkout-totals-block { - .wc-block-components-totals-item, - .wc-block-components-panel { - padding-left: $gap; - padding-right: $gap; - } - } - } - - // For Twenty Twenty we need to increase specificity a bit more. - .theme-twentytwenty { - .wp-block-woocommerce-checkout-totals-block .wc-block-components-panel > h2 { - @include font-size(large); - @include reset-box(); - } - } -} diff --git a/assets/js/blocks/cart-checkout/checkout/attributes.js b/assets/js/blocks/cart-checkout/checkout/attributes.js deleted file mode 100644 index df8ccbff67c..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/attributes.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * External dependencies - */ -import { getSetting } from '@woocommerce/settings'; - -const blockAttributes = { - 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, - }, - showOrderNotes: { - type: 'boolean', - default: true, - }, - showPolicyLinks: { - type: 'boolean', - default: true, - }, - showReturnToCart: { - type: 'boolean', - default: true, - }, - cartPageId: { - type: 'number', - default: 0, - }, - hasDarkControls: { - type: 'boolean', - default: getSetting( 'hasDarkEditorStyleSupport', false ), - }, - showRateAfterTaxName: { - type: 'boolean', - default: getSetting( 'displayCartPricesIncludingTax', false ), - }, -}; - -export default blockAttributes; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/attributes.ts b/assets/js/blocks/cart-checkout/checkout/attributes.ts similarity index 95% rename from assets/js/blocks/cart-checkout/checkout-i2/attributes.ts rename to assets/js/blocks/cart-checkout/checkout/attributes.ts index d6caf35dc0b..f9e1dc67749 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/attributes.ts +++ b/assets/js/blocks/cart-checkout/checkout/attributes.ts @@ -3,7 +3,7 @@ */ import { getSetting } from '@woocommerce/settings'; -export const blockName = 'woocommerce/checkout-i2'; +export const blockName = 'woocommerce/checkout'; export const blockAttributes = { isPreview: { type: 'boolean', diff --git a/assets/js/blocks/cart-checkout/checkout/block.js b/assets/js/blocks/cart-checkout/checkout/block.js deleted file mode 100644 index 58157e7de87..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/block.js +++ /dev/null @@ -1,151 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; -import { useEffect } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; -import { - PlaceOrderButton, - Policies, - ReturnToCartButton, -} from '@woocommerce/base-components/cart-checkout'; -import { - useCheckoutContext, - useEditorContext, - useValidationContext, -} from '@woocommerce/base-context'; -import { useStoreCart, useStoreNotices } from '@woocommerce/base-context/hooks'; -import { - Sidebar, - SidebarLayout, - Main, -} from '@woocommerce/base-components/sidebar-layout'; -import withScrollToTop from '@woocommerce/base-hocs/with-scroll-to-top'; -import { isWcVersion, getSetting } from '@woocommerce/settings'; - -/** - * Internal dependencies - */ -import CheckoutForm from './form'; -import CheckoutSidebar from './sidebar'; -import CheckoutOrderError from './checkout-order-error'; -import { CheckoutExpressPayment } from '../payment-methods'; -import { LOGIN_TO_CHECKOUT_URL } from './utils'; -import './style.scss'; - -/** - * Main Checkout Component. - * - * @param {Object} props Component props. - * @param {Object} props.attributes Incoming block attributes. - * @param {function(any):any} props.scrollToTop Function for scrolling to top. - */ -const Checkout = ( { attributes, scrollToTop } ) => { - const { isEditor } = useEditorContext(); - const { - cartItems, - cartTotals, - cartCoupons, - cartFees, - cartNeedsPayment, - } = useStoreCart(); - const { - hasOrder, - hasError: checkoutHasError, - isIdle: checkoutIsIdle, - customerId, - } = useCheckoutContext(); - const { - hasValidationErrors, - showAllValidationErrors, - } = useValidationContext(); - const { hasNoticesOfType } = useStoreNotices(); - - const hasErrorsToDisplay = - checkoutIsIdle && - checkoutHasError && - ( hasValidationErrors || hasNoticesOfType( 'default' ) ); - - // Checkout signup is feature gated to WooCommerce 4.7 and newer; - // uses updated my-account/lost-password screen from 4.7+ for - // setting initial password. - const allowCreateAccount = - attributes.allowCreateAccount && isWcVersion( '4.7.0', '>=' ); - - useEffect( () => { - if ( hasErrorsToDisplay ) { - showAllValidationErrors(); - scrollToTop( { focusableSelector: 'input:invalid' } ); - } - }, [ hasErrorsToDisplay, scrollToTop, showAllValidationErrors ] ); - - if ( ! isEditor && ! hasOrder ) { - return ; - } - - if ( - ! isEditor && - ! customerId && - ! getSetting( 'checkoutAllowsGuest', false ) && - ! ( allowCreateAccount && getSetting( 'checkoutAllowsSignup', false ) ) - ) { - return ( - <> - { __( - 'You must be logged in to checkout. ', - 'woo-gutenberg-products-block' - ) } - - { __( - 'Click here to log in.', - 'woo-gutenberg-products-block' - ) } - - - ); - } - const checkoutClassName = classnames( 'wc-block-checkout', { - 'has-dark-controls': attributes.hasDarkControls, - } ); - return ( - <> - -
- { cartNeedsPayment && } - -
- { attributes.showReturnToCart && ( - - ) } - -
- { attributes.showPolicyLinks && } -
- - - -
- - ); -}; - -export default withScrollToTop( Checkout ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/block.tsx b/assets/js/blocks/cart-checkout/checkout/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/block.tsx rename to assets/js/blocks/cart-checkout/checkout/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js b/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js index 3e283360add..30f34ed20eb 100644 --- a/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js +++ b/assets/js/blocks/cart-checkout/checkout/checkout-order-error/index.js @@ -10,6 +10,7 @@ import { decodeEntities } from '@wordpress/html-entities'; /** * Internal dependencies */ +import './style.scss'; import { PRODUCT_OUT_OF_STOCK, PRODUCT_NOT_PURCHASABLE, diff --git a/assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss b/assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss new file mode 100644 index 00000000000..3f334f91ec9 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/checkout-order-error/style.scss @@ -0,0 +1,21 @@ +.wc-block-checkout-error { + padding: $gap-largest; + text-align: center; + width: 100%; + + .wc-block-checkout-error__image { + max-width: 150px; + margin: 0 auto 1em; + display: block; + color: inherit; + } + .wc-block-checkout-error__title { + display: block; + margin: 0; + font-weight: bold; + } + .wc-block-checkout-error__description { + display: block; + margin: 0.25em 0 1em 0; + } +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/columns/columns-block.tsx b/assets/js/blocks/cart-checkout/checkout/columns/columns-block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/columns/columns-block.tsx rename to assets/js/blocks/cart-checkout/checkout/columns/columns-block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/columns/index.ts b/assets/js/blocks/cart-checkout/checkout/columns/index.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/columns/index.ts rename to assets/js/blocks/cart-checkout/checkout/columns/index.ts diff --git a/assets/js/blocks/cart-checkout/checkout-i2/context.ts b/assets/js/blocks/cart-checkout/checkout/context.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/context.ts rename to assets/js/blocks/cart-checkout/checkout/context.ts diff --git a/assets/js/blocks/cart-checkout/checkout/edit.js b/assets/js/blocks/cart-checkout/checkout/edit.js deleted file mode 100644 index dfe77b80373..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/edit.js +++ /dev/null @@ -1,399 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; -import { __ } from '@wordpress/i18n'; -import { InspectorControls } from '@wordpress/block-editor'; -import { - PanelBody, - ToggleControl, - CheckboxControl, - Notice, - Disabled, -} from '@wordpress/components'; -import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; -import { - PRIVACY_URL, - TERMS_URL, - CHECKOUT_PAGE_ID, -} from '@woocommerce/block-settings'; -import { isWcVersion, getAdminLink, getSetting } from '@woocommerce/settings'; -import { createInterpolateElement, useRef } from '@wordpress/element'; -import { - EditorProvider, - useEditorContext, - StoreNoticesProvider, - CheckoutProvider, -} from '@woocommerce/base-context'; -import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt'; -import PageSelector from '@woocommerce/editor-components/page-selector'; -import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices'; -import { - previewCart, - previewSavedPaymentMethods, -} from '@woocommerce/resource-previews'; - -/** - * Internal dependencies - */ -import Block from './block.js'; -import './editor.scss'; - -const BlockSettings = ( { attributes, setAttributes } ) => { - const { - showCompanyField, - showApartmentField, - showPhoneField, - requireCompanyField, - requirePhoneField, - allowCreateAccount, - showOrderNotes, - showPolicyLinks, - showReturnToCart, - cartPageId, - hasDarkControls, - showRateAfterTaxName, - } = attributes; - const { currentPostId } = useEditorContext(); - const { current: savedCartPageId } = useRef( cartPageId ); - // Checkout signup is feature gated to WooCommerce 4.7 and newer; - // uses updated my-account/lost-password screen from 4.7+ for - // setting initial password. - // Also implicitly gated to feature plugin, because Checkout - // block is gated to plugin - const showCreateAccountOption = - getSetting( 'checkoutAllowsSignup', false ) && - isWcVersion( '4.7.0', '>=' ); - return ( - - { currentPostId !== CHECKOUT_PAGE_ID && ( - - { createInterpolateElement( - __( - 'If you would like to use this block as your default checkout you must update your page settings in WooCommerce.', - 'woo-gutenberg-products-block' - ), - { - a: ( - // eslint-disable-next-line jsx-a11y/anchor-has-content - - ), - } - ) } - - ) } - -

- { __( - 'Include additional address fields in the checkout form.', - 'woo-gutenberg-products-block' - ) } -

- - setAttributes( { - showCompanyField: ! showCompanyField, - } ) - } - /> - { showCompanyField && ( - - setAttributes( { - requireCompanyField: ! requireCompanyField, - } ) - } - className="components-base-control--nested" - /> - ) } - - setAttributes( { - showApartmentField: ! showApartmentField, - } ) - } - /> - - setAttributes( { - showPhoneField: ! showPhoneField, - } ) - } - /> - { showPhoneField && ( - - setAttributes( { - requirePhoneField: ! requirePhoneField, - } ) - } - className="components-base-control--nested" - /> - ) } -
- { showCreateAccountOption && ( - - - setAttributes( { - allowCreateAccount: ! allowCreateAccount, - } ) - } - /> - - ) } - -

- { __( - 'Reduce the number of fields to checkout.', - 'woo-gutenberg-products-block' - ) } -

- - setAttributes( { - showOrderNotes: ! showOrderNotes, - } ) - } - /> -
- - - setAttributes( { - showPolicyLinks: ! showPolicyLinks, - } ) - } - /> - { showPolicyLinks && ( ! PRIVACY_URL || ! TERMS_URL ) && ( - - { createInterpolateElement( - __( - 'Pages must be first setup in store settings: Privacy policy, Terms and conditions.', - 'woo-gutenberg-products-block' - ), - { - a1: ( - // eslint-disable-next-line jsx-a11y/anchor-has-content -
- ), - a2: ( - // eslint-disable-next-line jsx-a11y/anchor-has-content - - ), - } - ) } - - ) } - - setAttributes( { - showReturnToCart: ! showReturnToCart, - } ) - } - /> - - { showReturnToCart && - ! ( - currentPostId === CHECKOUT_PAGE_ID && savedCartPageId === 0 - ) && ( - - setAttributes( { cartPageId: id } ) - } - labels={ { - title: __( - 'Return to Cart button', - 'woo-gutenberg-products-block' - ), - default: __( - 'WooCommerce Cart Page', - 'woo-gutenberg-products-block' - ), - } } - /> - ) } - { getSetting( 'taxesEnabled' ) && - getSetting( 'displayItemizedTaxes', false ) && - ! getSetting( 'displayCartPricesIncludingTax', false ) && ( - - - setAttributes( { - showRateAfterTaxName: ! showRateAfterTaxName, - } ) - } - /> - - ) } - - - setAttributes( { - hasDarkControls: ! hasDarkControls, - } ) - } - /> - - -
- ); -}; - -const CheckoutEditor = ( { attributes, setAttributes } ) => { - const { className, isPreview } = attributes; - return ( - <> - -
- - - - - - - - - - -
-
- - - ); -}; - -export default CheckoutEditor; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/edit.tsx b/assets/js/blocks/cart-checkout/checkout/edit.tsx similarity index 84% rename from assets/js/blocks/cart-checkout/checkout-i2/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/edit.tsx index 86032a65b28..f55c45d635c 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/edit.tsx +++ b/assets/js/blocks/cart-checkout/checkout/edit.tsx @@ -28,6 +28,7 @@ import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedb import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings'; import { createInterpolateElement } from '@wordpress/element'; import { getAdminLink } from '@woocommerce/settings'; +import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices'; /** * Internal dependencies @@ -261,47 +262,50 @@ export const Edit = ( { ); return ( - - - - - - + + + + + - - - - - - - - + + + + + + + + + + ); }; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/editor-utils.ts b/assets/js/blocks/cart-checkout/checkout/editor-utils.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/editor-utils.ts rename to assets/js/blocks/cart-checkout/checkout/editor-utils.ts diff --git a/assets/js/blocks/cart-checkout/checkout/editor.scss b/assets/js/blocks/cart-checkout/checkout/editor.scss deleted file mode 100644 index f84ad002c71..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/editor.scss +++ /dev/null @@ -1,29 +0,0 @@ -.editor-styles-wrapper { - .wp-block h4.wc-block-components-checkout-step__title { - @include font-size(regular); - line-height: 24px; - margin: 0 $gap-small 0 0; - } -} -.wc-block-checkout__controls-text { - color: #999; - font-style: italic; -} - -.components-base-control--nested { - padding-left: 52px; - margin-top: -12px; -} - -.wc-block-checkout__page-notice { - margin: 0; -} - -.components-panel__body-title .components-button { - opacity: 1; -} - -.wp-block-woocommerce-checkout.is-editor-preview { - max-height: 1000px; - overflow: hidden; -} diff --git a/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js b/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js index 2cd8ba11d5b..af7da22e9f5 100644 --- a/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js +++ b/assets/js/blocks/cart-checkout/checkout/empty-cart/index.js @@ -5,6 +5,11 @@ import { __ } from '@wordpress/i18n'; import { SHOP_URL } from '@woocommerce/block-settings'; import { Icon, cart } from '@woocommerce/icons'; +/** + * Internal dependencies + */ +import './style.scss'; + const EmptyCart = () => { return (
diff --git a/assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss b/assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss new file mode 100644 index 00000000000..c598711f7ad --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/empty-cart/style.scss @@ -0,0 +1,21 @@ +.wc-block-checkout-empty { + padding: $gap-largest; + text-align: center; + width: 100%; + + .wc-block-checkout-empty__image { + max-width: 150px; + margin: 0 auto 1em; + display: block; + color: inherit; + } + .wc-block-checkout-empty__title { + display: block; + margin: 0; + font-weight: bold; + } + .wc-block-checkout-empty__description { + display: block; + margin: 0.25em 0 1em 0; + } +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/additional-fields.tsx b/assets/js/blocks/cart-checkout/checkout/form-step/additional-fields.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/additional-fields.tsx rename to assets/js/blocks/cart-checkout/checkout/form-step/additional-fields.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/attributes.ts b/assets/js/blocks/cart-checkout/checkout/form-step/attributes.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/attributes.ts rename to assets/js/blocks/cart-checkout/checkout/form-step/attributes.ts diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/editor.scss b/assets/js/blocks/cart-checkout/checkout/form-step/editor.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/editor.scss rename to assets/js/blocks/cart-checkout/checkout/form-step/editor.scss diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/form-step-block.tsx b/assets/js/blocks/cart-checkout/checkout/form-step/form-step-block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/form-step-block.tsx rename to assets/js/blocks/cart-checkout/checkout/form-step/form-step-block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/form-step-heading.tsx b/assets/js/blocks/cart-checkout/checkout/form-step/form-step-heading.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/form-step-heading.tsx rename to assets/js/blocks/cart-checkout/checkout/form-step/form-step-heading.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/form-step/index.tsx b/assets/js/blocks/cart-checkout/checkout/form-step/index.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/form-step/index.tsx rename to assets/js/blocks/cart-checkout/checkout/form-step/index.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/form/billing-fields-step.js b/assets/js/blocks/cart-checkout/checkout/form/billing-fields-step.js deleted file mode 100644 index 0f7d28ee1a4..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/billing-fields-step.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; -import PropTypes from 'prop-types'; - -const BillingFieldsStep = ( { children } ) => { - const { isDisabled } = useCheckoutSubmit(); - return ( - - { children } - - ); -}; - -BillingFieldsStep.propTypes = { - children: PropTypes.node.isRequired, -}; - -export default BillingFieldsStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/contact-fields-step.js b/assets/js/blocks/cart-checkout/checkout/form/contact-fields-step.js deleted file mode 100644 index 14844e6dbb4..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/contact-fields-step.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { ValidatedTextInput } from '@woocommerce/base-components/text-input'; -import { useCheckoutContext } from '@woocommerce/base-context'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; -import { getSetting } from '@woocommerce/settings'; -import CheckboxControl from '@woocommerce/base-components/checkbox-control'; - -/** - * Internal dependencies - */ -import LoginPrompt from './login-prompt'; -const ContactFieldsStep = ( { - emailValue, - onChangeEmail, - allowCreateAccount, -} ) => { - const { - customerId, - shouldCreateAccount, - setShouldCreateAccount, - } = useCheckoutContext(); - const { isDisabled } = useCheckoutSubmit(); - - const createAccountUI = ! customerId && - allowCreateAccount && - getSetting( 'checkoutAllowsGuest', false ) && - getSetting( 'checkoutAllowsSignup', false ) && ( - setShouldCreateAccount( value ) } - /> - ); - - return ( - } - > - - { createAccountUI } - - ); -}; - -export default ContactFieldsStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/index.js b/assets/js/blocks/cart-checkout/checkout/form/index.js deleted file mode 100644 index 93019676a64..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/index.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * External dependencies - */ -import PropTypes from 'prop-types'; -import { useEffect, useMemo } from '@wordpress/element'; -import { - useCheckoutContext, - useShippingDataContext, -} from '@woocommerce/base-context'; -import { - useStoreEvents, - useCheckoutAddress, -} from '@woocommerce/base-context/hooks'; -import { AddressForm } from '@woocommerce/base-components/cart-checkout'; -import Form from '@woocommerce/base-components/form'; - -/** - * Internal dependencies - */ -import BillingFieldsStep from './billing-fields-step'; -import ContactFieldsStep from './contact-fields-step'; -import ShippingFieldsStep from './shipping-fields-step'; -import PhoneNumber from './phone-number'; -import OrderNotesStep from './order-notes-step'; -import PaymentMethodStep from './payment-method-step'; -import ShippingOptionsStep from './shipping-options-step'; -import './style.scss'; - -const CheckoutForm = ( { - requireCompanyField, - requirePhoneField, - showApartmentField, - showCompanyField, - showOrderNotes, - showPhoneField, - allowCreateAccount, -} ) => { - const { onSubmit } = useCheckoutContext(); - const { - defaultAddressFields, - billingFields, - setBillingFields, - setEmail, - setPhone, - setShippingAsBilling, - setShippingFields, - shippingAsBilling, - shippingFields, - showBillingFields, - } = useCheckoutAddress(); - const { needsShipping } = useShippingDataContext(); - const { dispatchCheckoutEvent } = useStoreEvents(); - - const addressFieldsConfig = useMemo( () => { - return { - company: { - hidden: ! showCompanyField, - required: requireCompanyField, - }, - address_2: { - hidden: ! showApartmentField, - }, - }; - }, [ showCompanyField, requireCompanyField, showApartmentField ] ); - - // Ignore changes to dispatchCheckoutEvent callback so this is ran on first mount only. - useEffect( () => { - dispatchCheckoutEvent( 'render-checkout-form' ); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [] ); - - return ( -
- { - setEmail( value ); - dispatchCheckoutEvent( 'set-email-address' ); - } } - allowCreateAccount={ allowCreateAccount } - /> - { needsShipping && ( - - { - setShippingFields( values ); - dispatchCheckoutEvent( 'set-shipping-address' ); - } } - values={ shippingFields } - fields={ Object.keys( defaultAddressFields ) } - fieldConfig={ addressFieldsConfig } - /> - { showPhoneField && ( - { - setPhone( value ); - dispatchCheckoutEvent( 'set-phone-number', { - step: 'shipping', - } ); - } } - /> - ) } - - ) } - { showBillingFields && ( - - { - setBillingFields( values ); - dispatchCheckoutEvent( 'set-billing-address' ); - } } - values={ billingFields } - fields={ Object.keys( defaultAddressFields ) } - fieldConfig={ addressFieldsConfig } - /> - { showPhoneField && ! needsShipping && ( - { - setPhone( value ); - dispatchCheckoutEvent( 'set-phone-number', { - step: 'billing', - } ); - } } - /> - ) } - - ) } - - - { showOrderNotes && } - - ); -}; - -CheckoutForm.propTypes = { - requireCompanyField: PropTypes.bool.isRequired, - requirePhoneField: PropTypes.bool.isRequired, - showApartmentField: PropTypes.bool.isRequired, - showCompanyField: PropTypes.bool.isRequired, - showOrderNotes: PropTypes.bool.isRequired, - showPhoneField: PropTypes.bool.isRequired, - allowCreateAccount: PropTypes.bool.isRequired, -}; - -export default CheckoutForm; diff --git a/assets/js/blocks/cart-checkout/checkout/form/login-prompt.js b/assets/js/blocks/cart-checkout/checkout/form/login-prompt.js deleted file mode 100644 index 68eaf4a12f4..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/login-prompt.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { getSetting } from '@woocommerce/settings'; -import { useCheckoutContext } from '@woocommerce/base-context'; - -/** - * Internal dependencies - */ -import { LOGIN_TO_CHECKOUT_URL } from '../utils'; - -const LoginPrompt = () => { - const { customerId } = useCheckoutContext(); - - if ( ! getSetting( 'checkoutShowLoginReminder', true ) || customerId ) { - return null; - } - - return ( - <> - { __( - 'Already have an account? ', - 'woo-gutenberg-products-block' - ) } -
- { __( 'Log in.', 'woo-gutenberg-products-block' ) } - - - ); -}; - -export default LoginPrompt; diff --git a/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/index.js b/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/index.js deleted file mode 100644 index 8eac3f05269..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Placeholder, Button } from 'wordpress-components'; -import { Icon, truck } from '@woocommerce/icons'; -import { ADMIN_URL } from '@woocommerce/settings'; - -/** - * Internal dependencies - */ -import './style.scss'; - -const NoShippingPlaceholder = () => { - return ( - } - label={ __( 'Shipping options', 'woo-gutenberg-products-block' ) } - className="wc-block-checkout__no-shipping-placeholder" - > - - { __( - 'Your store does not have any Shipping Options configured. Once you have added your Shipping Options they will appear here.', - 'woo-gutenberg-products-block' - ) } - - - - ); -}; - -export default NoShippingPlaceholder; diff --git a/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/style.scss b/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/style.scss deleted file mode 100644 index a5e23fedd40..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/no-shipping-placeholder/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -.components-placeholder.wc-block-checkout__no-shipping-placeholder { - margin-bottom: $gap; - - * { - pointer-events: all; // Overrides parent disabled component in editor context - } - - .components-placeholder__fieldset { - display: block; - - .components-button { - background-color: $gray-900; - color: $white; - } - - .wc-block-checkout__no-shipping-placeholder-description { - display: block; - margin: 0.25em 0 1em 0; - } - } -} diff --git a/assets/js/blocks/cart-checkout/checkout/form/order-notes-step.js b/assets/js/blocks/cart-checkout/checkout/form/order-notes-step.js deleted file mode 100644 index 75e0d50f632..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/order-notes-step.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { - useCheckoutContext, - useShippingDataContext, -} from '@woocommerce/base-context'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; - -/** - * Internal dependencies - */ -import CheckoutOrderNotes from './order-notes'; - -const OrderNotesStep = () => { - const { needsShipping } = useShippingDataContext(); - const { orderNotes, dispatchActions } = useCheckoutContext(); - const { isDisabled } = useCheckoutSubmit(); - const { setOrderNotes } = dispatchActions; - - return ( - - - - ); -}; - -export default OrderNotesStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/payment-method-step.js b/assets/js/blocks/cart-checkout/checkout/form/payment-method-step.js deleted file mode 100644 index b25dac234f3..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/payment-method-step.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import { StoreNoticesProvider } from '@woocommerce/base-context'; -import { - useStoreCart, - useEmitResponse, - usePaymentMethods, - useCheckoutSubmit, -} from '@woocommerce/base-context/hooks'; - -/** - * Internal dependencies - */ -import { PaymentMethods } from '../../payment-methods'; - -const PaymentMethodStep = () => { - const { isDisabled } = useCheckoutSubmit(); - const { cartNeedsPayment } = useStoreCart(); - const { paymentMethods } = usePaymentMethods(); - const { noticeContexts } = useEmitResponse(); - - if ( ! cartNeedsPayment ) { - return null; - } - - return ( - 1 - ? __( - 'Select a payment method below.', - 'woo-gutenberg-products-block' - ) - : '' - } - > - - - - - ); -}; - -export default PaymentMethodStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/phone-number/index.js b/assets/js/blocks/cart-checkout/checkout/form/phone-number/index.js deleted file mode 100644 index 2ce93011516..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/phone-number/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { ValidatedTextInput } from '@woocommerce/base-components/text-input'; - -/** - * Renders a phone number input. - * - * @param {Object} props Component props. - * @param {boolean} props.isRequired Is the phone number required or optional. - * @param {Function} props.onChange Event fired when the input changes. - * @param {string} props.value Value of the input. - * @return {*} The component. - */ -const PhoneNumber = ( { isRequired = false, value = '', onChange } ) => { - return ( - - ); -}; - -export default PhoneNumber; diff --git a/assets/js/blocks/cart-checkout/checkout/form/shipping-fields-step.js b/assets/js/blocks/cart-checkout/checkout/form/shipping-fields-step.js deleted file mode 100644 index 29641eec605..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/shipping-fields-step.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { FormStep } from '@woocommerce/base-components/cart-checkout'; -import CheckboxControl from '@woocommerce/base-components/checkbox-control'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; -import PropTypes from 'prop-types'; - -const ShippingFieldsStep = ( { - shippingAsBilling, - setShippingAsBilling, - children, -} ) => { - const { isDisabled } = useCheckoutSubmit(); - - return ( - - { children } - setShippingAsBilling( isChecked ) } - /> - - ); -}; - -ShippingFieldsStep.propTypes = { - shippingAsBilling: PropTypes.bool.isRequired, - setShippingAsBilling: PropTypes.func.isRequired, - children: PropTypes.node.isRequired, -}; - -export default ShippingFieldsStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/shipping-options-step.tsx b/assets/js/blocks/cart-checkout/checkout/form/shipping-options-step.tsx deleted file mode 100644 index 555630d8f07..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/shipping-options-step.tsx +++ /dev/null @@ -1,120 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { - FormStep, - ShippingRatesControl, -} from '@woocommerce/base-components/cart-checkout'; -import { - getShippingRatesPackageCount, - getShippingRatesRateCount, -} from '@woocommerce/base-utils'; -import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount'; -import { - useEditorContext, - useShippingDataContext, -} from '@woocommerce/base-context'; -import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; -import { decodeEntities } from '@wordpress/html-entities'; -import { Notice } from 'wordpress-components'; -import classnames from 'classnames'; -import { getSetting } from '@woocommerce/settings'; -import type { PackageRateOption } from '@woocommerce/type-defs/shipping'; -import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/cart'; - -/** - * Internal dependencies - */ -import NoShippingPlaceholder from './no-shipping-placeholder'; - -/** - * Renders a shipping rate control option. - * - * @param {Object} option Shipping Rate. - */ -const renderShippingRatesControlOption = ( - option: CartShippingPackageShippingRate -): PackageRateOption => { - const priceWithTaxes = getSetting( 'displayCartPricesIncludingTax', false ) - ? parseInt( option.price, 10 ) + parseInt( option.taxes, 10 ) - : parseInt( option.price, 10 ); - return { - label: decodeEntities( option.name ), - value: option.rate_id, - description: decodeEntities( option.description ), - secondaryLabel: ( - - ), - secondaryDescription: decodeEntities( option.delivery_time ), - }; -}; - -const ShippingOptionsStep = (): JSX.Element | null => { - const { isDisabled } = useCheckoutSubmit(); - const { isEditor } = useEditorContext(); - const { - shippingRates, - shippingRatesLoading, - needsShipping, - hasCalculatedShipping, - } = useShippingDataContext(); - - if ( ! needsShipping ) { - return null; - } - - return ( - 1 - ? __( - 'Select shipping options below.', - 'woo-gutenberg-products-block' - ) - : '' - } - > - { isEditor && ! getShippingRatesPackageCount( shippingRates ) ? ( - - ) : ( - - { __( - 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', - 'woo-gutenberg-products-block' - ) } - - ) : ( - __( - 'Shipping options will appear here after entering your full shipping address.', - 'woo-gutenberg-products-block' - ) - ) - } - renderOption={ renderShippingRatesControlOption } - shippingRates={ shippingRates } - shippingRatesLoading={ shippingRatesLoading } - /> - ) } - - ); -}; - -export default ShippingOptionsStep; diff --git a/assets/js/blocks/cart-checkout/checkout/form/style.scss b/assets/js/blocks/cart-checkout/checkout/form/style.scss deleted file mode 100644 index 2a57d2e8c6e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/form/style.scss +++ /dev/null @@ -1,64 +0,0 @@ -.wc-block-checkout__form { - margin: 0; - max-width: 100%; -} -.wc-block-checkout__create-account, -.wc-block-checkout__use-address-for-billing { - margin-top: em($gap-large); -} - -.wc-block-checkout__shipping-option { - .wc-block-components-radio-control__option { - @include with-translucent-border( 0 0 1px ); - margin: 0; - padding: em($gap-small) 0 em($gap-small) em($gap-largest); - } - - .wc-block-components-shipping-rates-control__no-results-notice { - margin: em($gap-small) 0; - } -} - -.is-small, -.is-medium, -.is-large { - .wc-block-checkout__billing-fields, - .wc-block-checkout__shipping-fields { - .wc-block-components-address-form { - margin-left: #{-$gap-small * 0.5}; - margin-right: #{-$gap-small * 0.5}; - - &::after { - content: ""; - clear: both; - display: block; - } - - .wc-block-components-text-input, - .wc-block-components-country-input, - .wc-block-components-state-input { - float: left; - margin-left: #{$gap-small * 0.5}; - margin-right: #{$gap-small * 0.5}; - position: relative; - width: calc(50% - #{$gap-small}); - - &:nth-of-type(2), - &:first-of-type { - margin-top: 0; - } - } - - .wc-block-components-address-form__company, - .wc-block-components-address-form__address_1, - .wc-block-components-address-form__address_2 { - width: calc(100% - #{$gap-small}); - } - - .wc-block-components-checkbox { - clear: both; - } - - } - } -} diff --git a/assets/js/blocks/cart-checkout/checkout/frontend.js b/assets/js/blocks/cart-checkout/checkout/frontend.js deleted file mode 100644 index ff901b3709a..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/frontend.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { - withStoreCartApiHydration, - withRestApiHydration, -} from '@woocommerce/block-hocs'; -import { useStoreCart } from '@woocommerce/base-context/hooks'; -import { - CheckoutProvider, - StoreNoticesProvider, - ValidationContextProvider, -} from '@woocommerce/base-context'; -import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; -import { CURRENT_USER_IS_ADMIN } from '@woocommerce/settings'; -import { - renderFrontend, - getValidBlockAttributes, -} from '@woocommerce/base-utils'; -import { StoreSnackbarNoticesProvider } from '@woocommerce/base-context/providers'; -import { SlotFillProvider } from '@woocommerce/blocks-checkout'; - -/** - * Internal dependencies - */ -import Block from './block.js'; -import blockAttributes from './attributes'; -import EmptyCart from './empty-cart/index.js'; - -const reloadPage = () => void window.location.reload( true ); - -const errorBoundaryProps = { - header: __( 'Something went wrong…', 'woo-gutenberg-products-block' ), - text: __( - 'The checkout has encountered an unexpected error. If the error persists, please get in touch with us for help.', - 'woo-gutenberg-products-block' - ), - showErrorMessage: CURRENT_USER_IS_ADMIN, - button: ( - - ), -}; - -/** - * Wrapper component for the checkout block. - * - * @param {Object} props Props for the block. - */ -const CheckoutFrontend = ( props ) => { - const { cartItems, cartIsLoading } = useStoreCart(); - - return ( - <> - { ! cartIsLoading && cartItems.length === 0 ? ( - - ) : ( - - - - - - - - - - - - - - ) } - - ); -}; - -const getProps = ( el ) => { - return { - attributes: getValidBlockAttributes( blockAttributes, el.dataset ), - }; -}; - -const getErrorBoundaryProps = () => { - return errorBoundaryProps; -}; - -renderFrontend( { - selector: '.wp-block-woocommerce-checkout', - Block: withStoreCartApiHydration( - withRestApiHydration( CheckoutFrontend ) - ), - getProps, - getErrorBoundaryProps, -} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/frontend.tsx similarity index 97% rename from assets/js/blocks/cart-checkout/checkout-i2/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/frontend.tsx index e745cdaf663..261da2a8ea4 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/frontend.tsx +++ b/assets/js/blocks/cart-checkout/checkout/frontend.tsx @@ -59,7 +59,7 @@ const Wrapper = ( { renderParentBlock( { Block: withStoreCartApiHydration( withRestApiHydration( Block ) ), blockName, - selector: '.wp-block-woocommerce-checkout-i2', + selector: '.wp-block-woocommerce-checkout', getProps, blockMap: getRegisteredBlockComponents( blockName ) as Record< string, diff --git a/assets/js/blocks/cart-checkout/checkout-i2/hacks.ts b/assets/js/blocks/cart-checkout/checkout/hacks.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/hacks.ts rename to assets/js/blocks/cart-checkout/checkout/hacks.ts diff --git a/assets/js/blocks/cart-checkout/checkout/index.js b/assets/js/blocks/cart-checkout/checkout/index.js deleted file mode 100644 index 44ad55c357e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/index.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, card } from '@woocommerce/icons'; -import classnames from 'classnames'; -import { - registerFeaturePluginBlockType, - isExperimentalBuild, -} from '@woocommerce/block-settings'; -import { createBlock } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import edit from './edit'; -import blockAttributes from './attributes'; -import './editor.scss'; - -const transforms = isExperimentalBuild() - ? { - transforms: { - from: [ - { - type: 'block', - blocks: [ 'woocommerce/checkout' ], - transform: ( attributes ) => { - return createBlock( 'woocommerce/checkout', { - attributes, - } ); - }, - }, - ], - to: [ - { - type: 'block', - blocks: [ 'woocommerce/checkout-i2' ], - transform: ( attributes ) => { - return createBlock( - 'woocommerce/checkout-i2', - attributes - ); - }, - }, - ], - }, - } - : {}; - -const settings = { - title: __( 'Checkout', 'woo-gutenberg-products-block' ), - icon: { - src: , - foreground: '#96588a', - }, - 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', 'full' ], - html: false, - multiple: false, - }, - example: { - attributes: { - isPreview: true, - }, - }, - attributes: blockAttributes, - edit, - - //Save the props to post content. - save( { attributes } ) { - return ( -
- ); - }, - ...transforms, -}; - -registerFeaturePluginBlockType( 'woocommerce/checkout', settings ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/index.tsx b/assets/js/blocks/cart-checkout/checkout/index.tsx similarity index 62% rename from assets/js/blocks/cart-checkout/checkout-i2/index.tsx rename to assets/js/blocks/cart-checkout/checkout/index.tsx index 86f002a1b50..3fc573c9c1d 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/index.tsx +++ b/assets/js/blocks/cart-checkout/checkout/index.tsx @@ -2,9 +2,9 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; +import classnames from 'classnames'; import { Icon, fields } from '@woocommerce/icons'; import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; -import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies @@ -14,7 +14,7 @@ import { blockName, blockAttributes } from './attributes'; import './inner-blocks'; const settings = { - title: __( 'Checkout i2', 'woo-gutenberg-products-block' ), + title: __( 'Checkout', 'woo-gutenberg-products-block' ), icon: { src: , foreground: '#874FB9', @@ -34,28 +34,22 @@ const settings = { apiVersion: 2, edit: Edit, save: Save, - transforms: { - to: [ - { - type: 'block', - blocks: [ 'woocommerce/checkout' ], - transform: ( attributes ) => { - return createBlock( 'woocommerce/checkout', { - attributes, - } ); - }, + // Migrates v1 to v2 checkout. + deprecated: [ + { + attributes: blockAttributes, + save( { attributes }: { attributes: { className: string } } ) { + return ( +
+ ); }, - ], - from: [ - { - type: 'block', - blocks: [ 'woocommerce/checkout-i2' ], - transform: ( attributes ) => { - return createBlock( 'woocommerce/checkout-i2', attributes ); - }, - }, - ], - }, + }, + ], }; registerFeaturePluginBlockType( blockName, settings ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.json new file mode 100644 index 00000000000..1d70746aaee --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-actions-block", + "version": "1.0.0", + "title": "Actions", + "description": "Allow customers to place their order.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/index.tsx new file mode 100644 index 00000000000..29297b19d0b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, button } from '@wordpress/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import attributes from './attributes'; +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/style.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-actions-block/style.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-actions-block/style.scss diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.json new file mode 100644 index 00000000000..829e8503e3b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-billing-address-block", + "version": "1.0.0", + "title": "Billing Address", + "description": "Collect your customer's billing address.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-billing-address-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/index.tsx new file mode 100644 index 00000000000..b559d085d9b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-billing-address-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, address } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.json new file mode 100644 index 00000000000..5f09920bb00 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-contact-information-block", + "version": "1.0.0", + "title": "Contact Information", + "description": "Collect your customer's contact information.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/index.tsx new file mode 100644 index 00000000000..a3e4ac1a0b0 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, contact } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/login-prompt.js b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/login-prompt.js similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-contact-information-block/login-prompt.js rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-contact-information-block/login-prompt.js diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.json new file mode 100644 index 00000000000..12219bd8108 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-express-payment-block", + "version": "1.0.0", + "title": "Express Checkout", + "description": "Provide an express payment option for your customers.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/editor.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/editor.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-express-payment-block/editor.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/editor.scss diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx new file mode 100644 index 00000000000..7d5f848e195 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-express-payment-block/index.tsx @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import { Icon, card } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json new file mode 100644 index 00000000000..9624f6f59bb --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-fields-block", + "version": "1.0.0", + "title": "Checkout Fields", + "description": "Column containing checkout address fields.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx similarity index 98% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx index 0c8f09d3daf..88706877290 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/edit.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/edit.tsx @@ -11,6 +11,7 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout'; import { useCheckoutBlockControlsContext } from '../../context'; import { useForcedLayout } from '../../use-forced-layout'; import { getAllowedBlocks } from '../../editor-utils'; +import './style.scss'; export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => { const blockProps = useBlockProps(); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/frontend.tsx similarity index 87% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/frontend.tsx index 4e1d1455146..c5506189b31 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-fields-block/frontend.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/frontend.tsx @@ -3,6 +3,11 @@ */ import { Main } from '@woocommerce/base-components/sidebar-layout'; +/** + * Internal dependencies + */ +import './style.scss'; + const FrontendBlock = ( { children, }: { diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx new file mode 100644 index 00000000000..7d0e826966b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/index.tsx @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import { Icon, column } from '@wordpress/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/style.scss new file mode 100644 index 00000000000..b0cb530abab --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-fields-block/style.scss @@ -0,0 +1,50 @@ +.wc-block-checkout__form { + margin: 0; + max-width: 100%; +} +.is-mobile, +.is-small, +.is-medium { + .wc-block-checkout__main { + order: 1; + } +} +.is-small, +.is-medium, +.is-large { + .wc-block-components-address-form { + margin-left: #{-$gap-small * 0.5}; + margin-right: #{-$gap-small * 0.5}; + + &::after { + content: ""; + clear: both; + display: block; + } + + .wc-block-components-text-input, + .wc-block-components-country-input, + .wc-block-components-state-input { + float: left; + margin-left: #{$gap-small * 0.5}; + margin-right: #{$gap-small * 0.5}; + position: relative; + width: calc(50% - #{$gap-small}); + + &:nth-of-type(2), + &:first-of-type { + margin-top: 0; + } + } + + .wc-block-components-address-form__company, + .wc-block-components-address-form__address_1, + .wc-block-components-address-form__address_2 { + width: calc(100% - #{$gap-small}); + } + + .wc-block-components-checkbox { + clear: both; + } + } +} diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json new file mode 100644 index 00000000000..5395d390e72 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-order-note-block", + "version": "1.0.0", + "title": "Order Note", + "description": "Allow customers to add a note to their order.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.tsx similarity index 94% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.tsx index 06c31891aeb..d9b75412807 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/block.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/block.tsx @@ -11,7 +11,7 @@ import { /** * Internal dependencies */ -import CheckoutOrderNotes from '../../../checkout/form/order-notes'; +import CheckoutOrderNotes from '../../order-notes'; const Block = (): JSX.Element => { const { needsShipping } = useShippingDataContext(); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/editor.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/editor.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-note-block/editor.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/editor.scss diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx new file mode 100644 index 00000000000..9dd51c331c8 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-note-block/index.tsx @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import { Icon, notes } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json new file mode 100644 index 00000000000..1fb6a567f58 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.json @@ -0,0 +1,24 @@ +{ + "name": "woocommerce/checkout-order-summary-block", + "version": "1.0.0", + "title": "Order Summary", + "description": "Show customers a summary of their order.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true + } + } + }, + "parent": [ "woocommerce/checkout-totals-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-order-summary-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx new file mode 100644 index 00000000000..6b497f9bf33 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-order-summary-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, totals } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json new file mode 100644 index 00000000000..0f98c002f3b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-payment-block", + "version": "1.0.0", + "title": "Payment Options", + "description": "Payment options for your store.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-payment-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx new file mode 100644 index 00000000000..e6b78575752 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-payment-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, card } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/README.md b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/README.md similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/README.md rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/README.md diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/block.json similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.json rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/block.json diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/index.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/index.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-sample-block/index.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json new file mode 100644 index 00000000000..af2c676fbdd --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-shipping-address-block", + "version": "1.0.0", + "title": "Shipping Address", + "description": "Collect your customer's shipping address.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/block.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-address-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx new file mode 100644 index 00000000000..b559d085d9b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-address-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, address } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/attributes.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/attributes.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/attributes.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json new file mode 100644 index 00000000000..0403ee0a163 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.json @@ -0,0 +1,25 @@ +{ + "name": "woocommerce/checkout-shipping-methods-block", + "version": "1.0.0", + "title": "Shipping Options", + "description": "Shipping options for your store.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "lock": { + "default": { + "remove": true, + "move": true + } + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/block.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx similarity index 99% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/block.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx index 23654167e57..4fa110bff5d 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/block.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/block.tsx @@ -21,6 +21,7 @@ import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/car * Internal dependencies */ import NoShippingPlaceholder from './no-shipping-placeholder'; +import './style.scss'; /** * Renders a shipping rate control option. diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx new file mode 100644 index 00000000000..f9d643b35a8 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/index.tsx @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { Icon, truck } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import attributes from './attributes'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + attributes, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/index.js diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/no-shipping-placeholder/style.scss diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss new file mode 100644 index 00000000000..ce5f2ba2f1d --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-shipping-methods-block/style.scss @@ -0,0 +1,11 @@ +.wc-block-checkout__shipping-option { + .wc-block-components-radio-control__option { + @include with-translucent-border( 0 0 1px ); + margin: 0; + padding: em($gap-small) 0 em($gap-small) em($gap-largest); + } + + .wc-block-components-shipping-rates-control__no-results-notice { + margin: em($gap-small) 0; + } +} diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json new file mode 100644 index 00000000000..b19079f01be --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/block.json @@ -0,0 +1,27 @@ +{ + "name": "woocommerce/checkout-terms-block", + "version": "1.0.0", + "title": "Terms and Conditions", + "description": "Ensure customers agree to your terms and conditions and privacy policy.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "checkbox": { + "type": "boolean", + "default": false + }, + "text": { + "type": "string", + "required": false + } + }, + "parent": [ "woocommerce/checkout-fields-block" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/constants.js b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/constants.js similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/constants.js rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/constants.js diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/edit.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/editor.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/editor.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/editor.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/editor.scss diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/frontend.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/frontend.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/index.tsx new file mode 100644 index 00000000000..fcbe5cf05bf --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/index.tsx @@ -0,0 +1,19 @@ +/** + * External dependencies + */ +import { Icon, asterisk } from '@woocommerce/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/style.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-terms-block/style.scss rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-terms-block/style.scss diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json new file mode 100644 index 00000000000..ae3c26d20ed --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/block.json @@ -0,0 +1,27 @@ +{ + "name": "woocommerce/checkout-totals-block", + "version": "1.0.0", + "title": "Checkout Totals", + "description": "Column containing the checkout totals.", + "category": "woocommerce", + "supports": { + "align": false, + "html": false, + "multiple": false, + "reusable": false, + "inserter": false + }, + "attributes": { + "checkbox": { + "type": "boolean", + "default": false + }, + "text": { + "type": "string", + "required": false + } + }, + "parent": [ "woocommerce/checkout" ], + "textdomain": "woo-gutenberg-products-block", + "apiVersion": 2 +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/edit.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx similarity index 97% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/edit.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx index e0c0f3a83be..336a177337c 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/edit.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/edit.tsx @@ -8,6 +8,7 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout'; /** * Internal dependencies */ +import './style.scss'; import { useForcedLayout } from '../../use-forced-layout'; import { getAllowedBlocks } from '../../editor-utils'; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/frontend.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/frontend.tsx similarity index 84% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/frontend.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/frontend.tsx index 60c166b5cc7..d24b26e82a5 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-totals-block/frontend.tsx +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/frontend.tsx @@ -3,6 +3,11 @@ */ import { Sidebar } from '@woocommerce/base-components/sidebar-layout'; +/** + * Internal dependencies + */ +import './style.scss'; + const FrontendBlock = ( { children, }: { diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx new file mode 100644 index 00000000000..7d0e826966b --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/index.tsx @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import { Icon, column } from '@wordpress/icons'; +import { registerFeaturePluginBlockType } from '@woocommerce/block-settings'; + +/** + * Internal dependencies + */ +import { Edit, Save } from './edit'; +import metadata from './block.json'; + +registerFeaturePluginBlockType( metadata, { + icon: { + src: , + foreground: '#874FB9', + }, + edit: Edit, + save: Save, +} ); diff --git a/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss new file mode 100644 index 00000000000..555f1d8b6f2 --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/checkout-totals-block/style.scss @@ -0,0 +1,23 @@ +.wc-block-checkout__sidebar { + .wc-block-components-product-name { + display: block; + color: inherit; + flex-grow: 1; + // Required by IE11. + flex-basis: 0; + } + .wc-block-components-totals-taxes, + .wc-block-components-totals-footer-item { + margin: 0; + padding: 0; + } +} + +.is-mobile, +.is-small, +.is-medium { + .wc-block-checkout__sidebar { + margin-bottom: $gap-large; + order: 0; + } +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/index.tsx b/assets/js/blocks/cart-checkout/checkout/inner-blocks/index.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/index.tsx rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/index.tsx diff --git a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/register-components.ts b/assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts similarity index 53% rename from assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/register-components.ts rename to assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts index 76205445ebf..db937f3b653 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/register-components.ts +++ b/assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts @@ -2,7 +2,6 @@ * External dependencies */ import { lazy } from '@wordpress/element'; -import { registerBlockComponent } from '@woocommerce/blocks-registry'; import { WC_BLOCKS_BUILD_URL } from '@woocommerce/block-settings'; import { registerCheckoutBlock } from '@woocommerce/blocks-checkout'; @@ -13,46 +12,59 @@ __webpack_public_path__ = WC_BLOCKS_BUILD_URL; /** * Internal dependencies */ -import sampleBlockMetaData from './checkout-sample-block/block.json'; +import sampleBlockMetadata from './checkout-sample-block/block.json'; +import checkoutActionsMetadata from './checkout-actions-block/block.json'; +import checkoutBillingAddressMetadata from './checkout-billing-address-block/block.json'; +import checkoutContactInformationMetadata from './checkout-contact-information-block/block.json'; +import checkoutExpressPaymentMetadata from './checkout-express-payment-block/block.json'; +import checkoutFieldsMetadata from './checkout-fields-block/block.json'; +import checkoutOrderNoteMetadata from './checkout-order-note-block/block.json'; +import checkoutOrderSummaryMetadata from './checkout-order-summary-block/block.json'; +import checkoutPaymentMetadata from './checkout-payment-block/block.json'; +import checkoutShippingAddressMetadata from './checkout-shipping-address-block/block.json'; +import checkoutShippingMethodsMetadata from './checkout-shipping-methods-block/block.json'; +import checkoutTermsMetadata from './checkout-terms-block/block.json'; +import checkoutTotalsMetadata from './checkout-totals-block/block.json'; +// @todo When forcing all blocks at once, they will append based on the order they are registered. Introduce formal sorting param. registerCheckoutBlock( { - metadata: sampleBlockMetaData, + metadata: checkoutFieldsMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/sample" */ './checkout-sample-block/frontend' + /* webpackChunkName: "checkout-blocks/fields" */ './checkout-fields-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-fields-block', +registerCheckoutBlock( { + metadata: checkoutExpressPaymentMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/fields" */ './checkout-fields-block/frontend' + /* webpackChunkName: "checkout-blocks/express-payment" */ './checkout-express-payment-block/block' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-terms-block', +registerCheckoutBlock( { + metadata: checkoutContactInformationMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/terms" */ './checkout-terms-block/frontend' + /* webpackChunkName: "checkout-blocks/contact-information" */ './checkout-contact-information-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-totals-block', +registerCheckoutBlock( { + metadata: checkoutShippingAddressMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/totals" */ './checkout-totals-block/frontend' + /* webpackChunkName: "checkout-blocks/shipping-address" */ './checkout-shipping-address-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-billing-address-block', +registerCheckoutBlock( { + metadata: checkoutBillingAddressMetadata, component: lazy( () => import( /* webpackChunkName: "checkout-blocks/billing-address" */ './checkout-billing-address-block/frontend' @@ -60,26 +72,26 @@ registerBlockComponent( { ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-actions-block', +registerCheckoutBlock( { + metadata: checkoutShippingMethodsMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/actions" */ './checkout-actions-block/frontend' + /* webpackChunkName: "checkout-blocks/shipping-methods" */ './checkout-shipping-methods-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-contact-information-block', +registerCheckoutBlock( { + metadata: checkoutPaymentMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/contact-information" */ './checkout-contact-information-block/frontend' + /* webpackChunkName: "checkout-blocks/payment" */ './checkout-payment-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-order-note-block', +registerCheckoutBlock( { + metadata: checkoutOrderNoteMetadata, component: lazy( () => import( /* webpackChunkName: "checkout-blocks/order-note" */ './checkout-order-note-block/block' @@ -87,47 +99,47 @@ registerBlockComponent( { ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-order-summary-block', +registerCheckoutBlock( { + metadata: checkoutTermsMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/order-summary" */ './checkout-order-summary-block/block' + /* webpackChunkName: "checkout-blocks/terms" */ './checkout-terms-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-payment-block', +registerCheckoutBlock( { + metadata: checkoutActionsMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/payment" */ './checkout-payment-block/frontend' + /* webpackChunkName: "checkout-blocks/actions" */ './checkout-actions-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-shipping-address-block', +registerCheckoutBlock( { + metadata: checkoutTotalsMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/shipping-address" */ './checkout-shipping-address-block/frontend' + /* webpackChunkName: "checkout-blocks/totals" */ './checkout-totals-block/frontend' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-express-payment-block', +registerCheckoutBlock( { + metadata: checkoutOrderSummaryMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/express-payment" */ './checkout-express-payment-block/block' + /* webpackChunkName: "checkout-blocks/order-summary" */ './checkout-order-summary-block/block' ) ), } ); -registerBlockComponent( { - blockName: 'woocommerce/checkout-shipping-methods-block', +registerCheckoutBlock( { + metadata: sampleBlockMetadata, component: lazy( () => import( - /* webpackChunkName: "checkout-blocks/shipping-methods" */ './checkout-shipping-methods-block/frontend' + /* webpackChunkName: "checkout-blocks/sample" */ './checkout-sample-block/frontend' ) ), } ); diff --git a/assets/js/blocks/cart-checkout/checkout/form/order-notes/index.js b/assets/js/blocks/cart-checkout/checkout/order-notes/index.js similarity index 100% rename from assets/js/blocks/cart-checkout/checkout/form/order-notes/index.js rename to assets/js/blocks/cart-checkout/checkout/order-notes/index.js diff --git a/assets/js/blocks/cart-checkout/checkout/form/order-notes/style.scss b/assets/js/blocks/cart-checkout/checkout/order-notes/style.scss similarity index 100% rename from assets/js/blocks/cart-checkout/checkout/form/order-notes/style.scss rename to assets/js/blocks/cart-checkout/checkout/order-notes/style.scss diff --git a/assets/js/blocks/cart-checkout/checkout-i2/phone-number/index.tsx b/assets/js/blocks/cart-checkout/checkout/phone-number/index.tsx similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/phone-number/index.tsx rename to assets/js/blocks/cart-checkout/checkout/phone-number/index.tsx diff --git a/assets/js/blocks/cart-checkout/checkout/sidebar/index.js b/assets/js/blocks/cart-checkout/checkout/sidebar/index.js deleted file mode 100644 index 45e6c4ecd9e..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/sidebar/index.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * External dependencies - */ - -import { - OrderSummary, - TotalsCoupon, - TotalsDiscount, - TotalsFooterItem, - TotalsShipping, -} from '@woocommerce/base-components/cart-checkout'; -import { - Subtotal, - TotalsFees, - TotalsTaxes, - ExperimentalOrderMeta, - ExperimentalDiscountsMeta, - TotalsWrapper, -} from '@woocommerce/blocks-checkout'; - -import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; -import { useShippingDataContext } from '@woocommerce/base-context'; -import { - useStoreCartCoupons, - useStoreCart, -} from '@woocommerce/base-context/hooks'; -import { getSetting } from '@woocommerce/settings'; - -const CheckoutSidebar = ( { - cartCoupons = [], - cartItems = [], - cartFees = [], - cartTotals = {}, - showRateAfterTaxName = false, -} ) => { - const { - applyCoupon, - removeCoupon, - isApplyingCoupon, - isRemovingCoupon, - } = useStoreCartCoupons(); - - const { needsShipping } = useShippingDataContext(); - const totalsCurrency = getCurrencyFromPriceResponse( cartTotals ); - - // Prepare props to pass to the ExperimentalOrderMeta slot fill. - // We need to pluck out receiveCart. - // eslint-disable-next-line no-unused-vars - const { extensions, receiveCart, ...cart } = useStoreCart(); - const slotFillProps = { - extensions, - cart, - }; - - const discountsSlotFillProps = { - extensions, - cart, - }; - - return ( - <> - - - - - - - - - { getSetting( 'couponsEnabled', true ) && ( - - - - ) } - - { needsShipping && ( - - - - ) } - { ! getSetting( 'displayCartPricesIncludingTax', false ) && - parseInt( cartTotals.total_tax, 10 ) > 0 && ( - - - - ) } - - - - - - ); -}; - -export default CheckoutSidebar; diff --git a/assets/js/blocks/cart-checkout/checkout/sidebar/test/__snapshots__/index.js.snap b/assets/js/blocks/cart-checkout/checkout/sidebar/test/__snapshots__/index.js.snap deleted file mode 100644 index b509cd8823d..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/sidebar/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,116 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Testing checkout sidebar Shows rate percentages after tax lines if the block is set to do so 1`] = ` -
-
-
-
- - Subtotal - - - $24.00 - -
-
-
-
-
-
- -
-
-
-
-
-
- - Sales tax 20% - - - $6.00 - -
-
- -
-
-
- -
-`; diff --git a/assets/js/blocks/cart-checkout/checkout/sidebar/test/index.js b/assets/js/blocks/cart-checkout/checkout/sidebar/test/index.js deleted file mode 100644 index 3a6e9a12647..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/sidebar/test/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * External dependencies - */ -import { render } from '@testing-library/react'; -import { previewCart } from '@woocommerce/resource-previews'; - -/** - * Internal dependencies - */ -import { allSettings } from '../../../../../settings/shared/settings-init'; -import CheckoutSidebar from '../index'; - -describe( 'Testing checkout sidebar', () => { - it( 'Shows rate percentages after tax lines if the block is set to do so', async () => { - allSettings.displayCartPricesIncludingTax = false; - allSettings.displayItemizedTaxes = true; - const { totals: cartTotals, items: cartItems } = previewCart; - const { container } = render( - - ); - expect( container ).toMatchSnapshot(); - } ); -} ); diff --git a/assets/js/blocks/cart-checkout/checkout/style.scss b/assets/js/blocks/cart-checkout/checkout/style.scss deleted file mode 100644 index f573488f0f9..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/style.scss +++ /dev/null @@ -1,156 +0,0 @@ -.wp-block-woocommerce-checkout .with-scroll-to-top__scroll-point { - top: -96px; -} - -.wc-block-checkout__sidebar { - .wc-block-components-product-name { - display: block; - color: inherit; - flex-grow: 1; - // Required by IE11. - flex-basis: 0; - } - .wc-block-components-totals-taxes, - .wc-block-components-totals-footer-item { - margin: 0; - padding: 0; - } -} - -.wc-block-checkout__actions { - display: flex; - justify-content: space-between; - align-items: center; - - .wc-block-components-checkout-place-order-button { - width: 50%; - padding: 1em; - height: auto; - - .wc-block-components-button__text { - line-height: 24px; - - > svg { - fill: $white; - vertical-align: top; - } - } - } -} - - -// Loading placeholder state. -.wc-block-checkout--is-loading { - .wc-block-components-express-payment, - .wc-block-checkout__actions button { - @include placeholder(); - @include force-content(); - } - .wc-block-components-express-payment { - min-height: 150px; - } - .wc-block-components-express-payment-continue-rule > span { - @include placeholder(); - @include force-content(); - width: 150px; - } - .wc-block-checkout__form { - .wc-block-components-checkout-step__title { - @include placeholder(); - @include force-content(); - display: block; - width: 10em; - - &::before { - @include placeholder(); - @include force-content(); - border-radius: 50%; - display: block; - height: 100%; - width: 1.5em; - } - } - .wc-block-components-checkout-step__container::after { - @include placeholder(); - } - .wc-block-components-checkout-step__content > span { - @include placeholder(); - @include force-content(); - display: block; - min-height: 100px; - } - .wc-block-components-checkout-step::before, - .wc-block-components-checkout-step::after { - @include placeholder(); - } - } - .wc-block-checkout__sidebar .components-card { - @include placeholder(); - @include force-content(); - min-height: 460px; - } -} -.wc-block-components-sidebar-layout.wc-block-checkout--skeleton { - display: none; -} -.is-loading + .wc-block-components-sidebar-layout.wc-block-checkout--skeleton { - display: flex; -} - -.wc-block-checkout-empty, -.wc-block-checkout-error { - padding: $gap-largest; - text-align: center; - width: 100%; - - .wc-block-checkout-empty__image, - .wc-block-checkout-error__image { - max-width: 150px; - margin: 0 auto 1em; - display: block; - color: inherit; - } - .wc-block-checkout-empty__title, - .wc-block-checkout-error__title { - display: block; - margin: 0; - font-weight: bold; - } - .wc-block-checkout-empty__description, - .wc-block-checkout-error__description { - display: block; - margin: 0.25em 0 1em 0; - } -} - -.is-mobile { - .wc-block-checkout__actions { - .wc-block-components-checkout-return-to-cart-button { - display: none; - } - - .wc-block-components-checkout-place-order-button { - width: 100%; - } - } -} - -.is-mobile, -.is-small, -.is-medium { - .wc-block-checkout__main { - order: 1; - } - - .wc-block-checkout__sidebar { - margin-bottom: $gap-large; - order: 0; - } -} - -.is-large { - .wc-block-checkout__actions { - @include with-translucent-border(1px 0 0); - padding-top: em($gap-large); - } -} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/styles/editor.scss b/assets/js/blocks/cart-checkout/checkout/styles/editor.scss similarity index 69% rename from assets/js/blocks/cart-checkout/checkout-i2/styles/editor.scss rename to assets/js/blocks/cart-checkout/checkout/styles/editor.scss index 0fb5ea6ab05..69acbf866b6 100644 --- a/assets/js/blocks/cart-checkout/checkout-i2/styles/editor.scss +++ b/assets/js/blocks/cart-checkout/checkout/styles/editor.scss @@ -1,6 +1,4 @@ -.wp-block-woocommerce-checkout-i2 { - margin-top: 0; - +.wp-block-woocommerce-checkout { .wc-block-components-sidebar-layout { display: block; } @@ -13,7 +11,6 @@ padding: 0; } } - .wc-block-components-main, .wc-block-components-sidebar, .block-editor-block-list__layout { @@ -21,7 +18,6 @@ margin-top: 0; } } - .wp-block-woocommerce-checkout-totals-block, .wp-block-woocommerce-checkout-fields-block { .block-editor-block-list__layout { @@ -30,10 +26,6 @@ } } -.wc-block-checkout__address-fields-notice { - margin: $gap 0 0; -} - body.wc-lock-selected-block--move { .block-editor-block-mover__move-button-container, .block-editor-block-mover { @@ -52,10 +44,25 @@ body.wc-lock-selected-block--remove { } } -.is-mobile, -.is-small, -.is-medium { - .wc-block-checkout__sidebar { - margin-bottom: 0; - } +.wc-block-checkout__controls-text { + color: #999; + font-style: italic; +} + +.components-base-control--nested { + padding-left: 52px; + margin-top: -12px; +} + +.wc-block-checkout__page-notice { + margin: 0; +} + +.components-panel__body-title .components-button { + opacity: 1; +} + +.wp-block-woocommerce-checkout.is-editor-preview { + max-height: 1000px; + overflow: hidden; } diff --git a/assets/js/blocks/cart-checkout/checkout/styles/style.scss b/assets/js/blocks/cart-checkout/checkout/styles/style.scss new file mode 100644 index 00000000000..3bd8d24010a --- /dev/null +++ b/assets/js/blocks/cart-checkout/checkout/styles/style.scss @@ -0,0 +1,94 @@ +.wp-block-woocommerce-checkout { + margin: 0; + + .with-scroll-to-top__scroll-point { + top: -96px; + } +} + +.wp-block-woocommerce-checkout.is-loading { + display: flex; + flex-wrap: wrap; + margin: 0 auto $gap; + position: relative; + .wp-block-woocommerce-checkout-totals-block { + width: 35%; + padding-left: percentage(math.div($gap-large, 1060px)); + } + .wp-block-woocommerce-checkout-fields-block { + width: 65%; + padding-right: percentage(math.div($gap-largest, 1060px)); // ~1060px is the default width of the content area in Storefront. + } + .wp-block-woocommerce-checkout-totals-block, + .wp-block-woocommerce-checkout-fields-block { + box-sizing: border-box; + margin: 0; + + > div { + @include placeholder(); + margin: 0 0 1.5em 0; + display: none; + } + .wp-block-woocommerce-checkout-contact-information-block, + .wp-block-woocommerce-checkout-payment-block { + min-height: 10em; + display: block; + } + .wp-block-woocommerce-checkout-shipping-address-block { + min-height: 24em; + display: block; + } + .wp-block-woocommerce-checkout-actions-block { + width: 50%; + min-height: 4em; + margin-left: 50%; + display: block; + } + .wp-block-woocommerce-checkout-order-summary-block { + min-height: 47em; + display: block; + } + .wc-block-components-panel > h2 { + @include font-size(regular); + @include reset-box(); + @include reset-typography(); + .wc-block-components-panel__button { + font-weight: 400; + } + } + .wc-block-components-totals-item, + .wc-block-components-panel { + padding-left: $gap; + padding-right: $gap; + } + } +} +// Skeleton is shown before mobile classes are appended. +@media only screen and (max-width: 700px) { + .wp-block-woocommerce-checkout.is-loading { + flex-direction: column; + margin: 0 auto $gap; + + .wp-block-woocommerce-checkout-fields-block { + padding: 0; + width: 100%; + } + .wp-block-woocommerce-checkout-totals-block { + padding: 0; + width: 100%; + .wc-block-components-totals-item, + .wc-block-components-panel { + padding-left: 0; + padding-right: 0; + } + } + } +} + +// For Twenty Twenty we need to increase specificity a bit more. +.theme-twentytwenty .wp-block-woocommerce-checkout.is-loading { + .wp-block-woocommerce-checkout-totals-block .wc-block-components-panel > h2 { + @include font-size(large); + @include reset-box(); + } +} diff --git a/assets/js/blocks/cart-checkout/checkout-i2/types.ts b/assets/js/blocks/cart-checkout/checkout/types.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/types.ts rename to assets/js/blocks/cart-checkout/checkout/types.ts diff --git a/assets/js/blocks/cart-checkout/checkout-i2/use-forced-layout.ts b/assets/js/blocks/cart-checkout/checkout/use-forced-layout.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/use-forced-layout.ts rename to assets/js/blocks/cart-checkout/checkout/use-forced-layout.ts diff --git a/assets/js/blocks/cart-checkout/checkout/utils.js b/assets/js/blocks/cart-checkout/checkout/utils.js deleted file mode 100644 index 01c98e169c1..00000000000 --- a/assets/js/blocks/cart-checkout/checkout/utils.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * External dependencies - */ -import { LOGIN_URL } from '@woocommerce/block-settings'; - -export const LOGIN_TO_CHECKOUT_URL = `${ LOGIN_URL }?redirect_to=${ encodeURIComponent( - window.location.href -) }`; diff --git a/assets/js/blocks/cart-checkout/checkout-i2/utils.ts b/assets/js/blocks/cart-checkout/checkout/utils.ts similarity index 100% rename from assets/js/blocks/cart-checkout/checkout-i2/utils.ts rename to assets/js/blocks/cart-checkout/checkout/utils.ts diff --git a/bin/webpack-entries.js b/bin/webpack-entries.js index 56b36e6432c..720aa02225e 100644 --- a/bin/webpack-entries.js +++ b/bin/webpack-entries.js @@ -46,10 +46,6 @@ const blocks = { checkout: { customDir: 'cart-checkout/checkout', }, - 'checkout-i2': { - customDir: 'cart-checkout/checkout-i2', - isExperimental: true, - }, 'mini-cart': { customDir: 'cart-checkout/mini-cart', }, diff --git a/package.json b/package.json index a0614ff5199..5a99ddb7de9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "./assets/js/filters/**", "./assets/js/settings/blocks/**", "./assets/js/middleware/**", - "./assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/**/index.tsx" + "./assets/js/blocks/cart-checkout/checkout/inner-blocks/**/index.tsx", + "./assets/js/blocks/cart-checkout/checkout/inner-blocks/register-components.ts" ], "repository": { "type": "git", diff --git a/packages/checkout/blocks-registry/types.ts b/packages/checkout/blocks-registry/types.ts index 65a170c2d04..06f45ce1676 100644 --- a/packages/checkout/blocks-registry/types.ts +++ b/packages/checkout/blocks-registry/types.ts @@ -5,6 +5,7 @@ import type { LazyExoticComponent } from 'react'; import type { BlockConfiguration } from '@wordpress/blocks'; export enum innerBlockAreas { + CHECKOUT = 'woocommerce/checkout', CHECKOUT_FIELDS = 'woocommerce/checkout-fields-block', CHECKOUT_TOTALS = 'woocommerce/checkout-totals-block', CONTACT_INFORMATION = 'woocommerce/checkout-contact-information-block', diff --git a/packages/checkout/totals/taxes/index.tsx b/packages/checkout/totals/taxes/index.tsx index 53dccca7c8d..a67ed5c30c4 100644 --- a/packages/checkout/totals/taxes/index.tsx +++ b/packages/checkout/totals/taxes/index.tsx @@ -34,7 +34,10 @@ const TotalsTaxes = ( { }: TotalsTaxesProps ): ReactElement | null => { const { total_tax: totalTax, tax_lines: taxLines } = values; - if ( ! getSetting( 'taxesEnabled', true ) ) { + if ( + ! getSetting( 'taxesEnabled', true ) && + parseInt( totalTax, 10 ) <= 0 + ) { return null; } diff --git a/src/BlockTypes/Checkout.php b/src/BlockTypes/Checkout.php index 7187ec1d630..fe85f907c03 100644 --- a/src/BlockTypes/Checkout.php +++ b/src/BlockTypes/Checkout.php @@ -76,7 +76,17 @@ protected function render( $attributes, $content ) { wp_dequeue_script( 'selectWoo' ); wp_dequeue_style( 'select2' ); - return $this->inject_html_data_attributes( $content . $this->get_skeleton(), $attributes ); + // If the content is empty, we may have transformed from an older checkout block. Insert the default list of blocks. + $is_empty = strstr( $content, '
' ); + + if ( $is_empty ) { + $content = '
+
+
+
'; + } + + return $this->inject_html_data_attributes( $content, $attributes ); } /** @@ -169,14 +179,72 @@ function() { $this->asset_data_registry->add( 'hasDarkEditorStyleSupport', current_theme_supports( 'dark-editor-style' ), true ); $this->asset_data_registry->register_page_id( isset( $attributes['cartPageId'] ) ? $attributes['cartPageId'] : 0 ); + $is_block_editor = $this->is_block_editor(); + // Hydrate the following data depending on admin or frontend context. - if ( is_admin() && function_exists( 'get_current_screen' ) ) { - $screen = get_current_screen(); + if ( $is_block_editor && ! $this->asset_data_registry->exists( 'shippingMethodsExist' ) ) { + $methods_exist = wc_get_shipping_method_count( false, true ) > 0; + $this->asset_data_registry->add( 'shippingMethodsExist', $methods_exist ); + } - if ( $screen && $screen->is_block_editor() && ! $this->asset_data_registry->exists( 'shippingMethodsExist' ) ) { - $methods_exist = wc_get_shipping_method_count( false, true ) > 0; - $this->asset_data_registry->add( 'shippingMethodsExist', $methods_exist ); - } + if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalShippingMethods' ) ) { + $shipping_methods = WC()->shipping()->get_shipping_methods(); + $formatted_shipping_methods = array_reduce( + $shipping_methods, + function( $acc, $method ) { + if ( $method->supports( 'settings' ) ) { + $acc[] = [ + 'id' => $method->id, + 'title' => $method->method_title, + 'description' => $method->method_description, + ]; + } + return $acc; + }, + [] + ); + $this->asset_data_registry->add( 'globalShippingMethods', $formatted_shipping_methods ); + } + + if ( $is_block_editor && ! $this->asset_data_registry->exists( 'activeShippingZones' ) && class_exists( '\WC_Shipping_Zones' ) ) { + $shipping_zones = \WC_Shipping_Zones::get_zones(); + $formatted_shipping_zones = array_reduce( + $shipping_zones, + function( $acc, $zone ) { + $acc[] = [ + 'id' => $zone['id'], + 'title' => $zone['zone_name'], + 'description' => $zone['formatted_zone_location'], + ]; + return $acc; + }, + [] + ); + $formatted_shipping_zones[] = [ + 'id' => 0, + 'title' => __( 'International', 'woo-gutenberg-products-block' ), + 'description' => __( 'Locations outside all other zones', 'woo-gutenberg-products-block' ), + ]; + $this->asset_data_registry->add( 'activeShippingZones', $formatted_shipping_zones ); + } + + if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalPaymentMethods' ) ) { + $payment_methods = WC()->payment_gateways->payment_gateways(); + $formatted_payment_methods = array_reduce( + $payment_methods, + function( $acc, $method ) { + if ( 'yes' === $method->enabled ) { + $acc[] = [ + 'id' => $method->id, + 'title' => $method->method_title, + 'description' => $method->method_description, + ]; + } + return $acc; + }, + [] + ); + $this->asset_data_registry->add( 'globalPaymentMethods', $formatted_payment_methods ); } if ( ! is_admin() && ! WC()->is_rest_api_request() ) { @@ -187,6 +255,18 @@ function() { do_action( 'woocommerce_blocks_checkout_enqueue_data' ); } + /** + * Are we currently on the admin block editor screen? + */ + protected function is_block_editor() { + if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { + return false; + } + $screen = get_current_screen(); + + return $screen && $screen->is_block_editor(); + } + /** * Removes accents from an array of values, sorts by the values, then returns the original array values sorted. * @@ -236,70 +316,6 @@ protected function hydrate_from_api() { remove_filter( 'woocommerce_store_api_disable_nonce_check', '__return_true' ); } - /** - * Render skeleton markup for the checkout block. - */ - protected function get_skeleton() { - return ' - - ' . $this->get_skeleton_inline_script(); - } - /** * Callback for woocommerce_payment_methods_list_item filter to add token id * to the generated list. diff --git a/src/BlockTypes/CheckoutI2.php b/src/BlockTypes/CheckoutI2.php deleted file mode 100644 index 6270755d2b4..00000000000 --- a/src/BlockTypes/CheckoutI2.php +++ /dev/null @@ -1,350 +0,0 @@ -block_name ) ) { - _doing_it_wrong( __METHOD__, esc_html( __( 'Block name is required.', 'woo-gutenberg-products-block' ) ), '4.5.0' ); - return false; - } - - // Also init the main checkout block so i2 is compatible with existing integrations. - do_action( 'woocommerce_blocks_checkout_block_registration', $this->integration_registry ); - - $this->integration_registry->initialize( $this->block_name . '_block' ); - $this->register_block_type_assets(); - $this->register_block_type(); - add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_assets' ] ); - } - - /** - * Get the editor script handle for this block type. - * - * @param string $key Data to get, or default to everything. - * @return array|string; - */ - protected function get_block_type_editor_script( $key = null ) { - $script = [ - 'handle' => 'wc-' . $this->block_name . '-block', - 'path' => $this->asset_api->get_block_asset_build_path( $this->block_name ), - 'dependencies' => [ 'wc-blocks' ], - ]; - return $key ? $script[ $key ] : $script; - } - - /** - * Get the frontend script handle for this block type. - * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string - */ - protected function get_block_type_script( $key = null ) { - $script = [ - 'handle' => 'wc-' . $this->block_name . '-block-frontend', - 'path' => $this->asset_api->get_block_asset_build_path( $this->block_name . '-frontend' ), - 'dependencies' => [], - ]; - return $key ? $script[ $key ] : $script; - } - - /** - * Enqueue frontend assets for this block, just in time for rendering. - * - * @param array $attributes Any attributes that currently are available from the block. - */ - protected function enqueue_assets( array $attributes ) { - do_action( 'woocommerce_blocks_enqueue_checkout_block_scripts_before' ); - parent::enqueue_assets( $attributes ); - do_action( 'woocommerce_blocks_enqueue_checkout_block_scripts_after' ); - } - - /** - * Append frontend scripts when rendering the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @return string Rendered block type output. - */ - protected function render( $attributes, $content ) { - if ( $this->is_checkout_endpoint() ) { - // Note: Currently the block only takes care of the main checkout form -- if an endpoint is set, refer to the - // legacy shortcode instead and do not render block. - return '[woocommerce_checkout]'; - } - - // Deregister core checkout scripts and styles. - wp_dequeue_script( 'wc-checkout' ); - wp_dequeue_script( 'wc-password-strength-meter' ); - wp_dequeue_script( 'selectWoo' ); - wp_dequeue_style( 'select2' ); - - return $this->inject_html_data_attributes( $content, $attributes ); - } - - /** - * Check if we're viewing a checkout page endpoint, rather than the main checkout page itself. - * - * @return boolean - */ - protected function is_checkout_endpoint() { - return is_wc_endpoint_url( 'order-pay' ) || is_wc_endpoint_url( 'order-received' ); - } - - /** - * Extra data passed through from server to client for block. - * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. - */ - protected function enqueue_data( array $attributes = [] ) { - parent::enqueue_data( $attributes ); - - $this->asset_data_registry->add( - 'allowedCountries', - function() { - return $this->deep_sort_with_accents( WC()->countries->get_allowed_countries() ); - }, - true - ); - $this->asset_data_registry->add( - 'allowedStates', - function() { - return $this->deep_sort_with_accents( WC()->countries->get_allowed_country_states() ); - }, - true - ); - $this->asset_data_registry->add( - 'shippingCountries', - function() { - return $this->deep_sort_with_accents( WC()->countries->get_shipping_countries() ); - }, - true - ); - $this->asset_data_registry->add( - 'shippingStates', - function() { - return $this->deep_sort_with_accents( WC()->countries->get_shipping_country_states() ); - }, - true - ); - $this->asset_data_registry->add( - 'countryLocale', - function() { - // Merge country and state data to work around https://github.com/woocommerce/woocommerce/issues/28944. - $country_locale = wc()->countries->get_country_locale(); - $states = wc()->countries->get_states(); - - foreach ( $states as $country => $states ) { - if ( empty( $states ) ) { - $country_locale[ $country ]['state']['required'] = false; - $country_locale[ $country ]['state']['hidden'] = true; - } - } - return $country_locale; - }, - true - ); - $this->asset_data_registry->add( 'baseLocation', wc_get_base_location(), true ); - $this->asset_data_registry->add( - 'checkoutAllowsGuest', - false === filter_var( - WC()->checkout()->is_registration_required(), - FILTER_VALIDATE_BOOLEAN - ), - true - ); - $this->asset_data_registry->add( - 'checkoutAllowsSignup', - filter_var( - WC()->checkout()->is_registration_enabled(), - FILTER_VALIDATE_BOOLEAN - ), - true - ); - $this->asset_data_registry->add( 'checkoutShowLoginReminder', filter_var( get_option( 'woocommerce_enable_checkout_login_reminder' ), FILTER_VALIDATE_BOOLEAN ), true ); - $this->asset_data_registry->add( 'displayCartPricesIncludingTax', 'incl' === get_option( 'woocommerce_tax_display_cart' ), true ); - $this->asset_data_registry->add( 'displayItemizedTaxes', 'itemized' === get_option( 'woocommerce_tax_total_display' ), true ); - $this->asset_data_registry->add( 'taxesEnabled', wc_tax_enabled(), true ); - $this->asset_data_registry->add( 'couponsEnabled', wc_coupons_enabled(), true ); - $this->asset_data_registry->add( 'shippingEnabled', wc_shipping_enabled(), true ); - $this->asset_data_registry->add( 'hasDarkEditorStyleSupport', current_theme_supports( 'dark-editor-style' ), true ); - $this->asset_data_registry->register_page_id( isset( $attributes['cartPageId'] ) ? $attributes['cartPageId'] : 0 ); - - $is_block_editor = $this->is_block_editor(); - - // Hydrate the following data depending on admin or frontend context. - if ( $is_block_editor && ! $this->asset_data_registry->exists( 'shippingMethodsExist' ) ) { - $methods_exist = wc_get_shipping_method_count( false, true ) > 0; - $this->asset_data_registry->add( 'shippingMethodsExist', $methods_exist ); - } - - if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalShippingMethods' ) ) { - $shipping_methods = WC()->shipping()->get_shipping_methods(); - $formatted_shipping_methods = array_reduce( - $shipping_methods, - function( $acc, $method ) { - if ( $method->supports( 'settings' ) ) { - $acc[] = [ - 'id' => $method->id, - 'title' => $method->method_title, - 'description' => $method->method_description, - ]; - } - return $acc; - }, - [] - ); - $this->asset_data_registry->add( 'globalShippingMethods', $formatted_shipping_methods ); - } - - if ( $is_block_editor && ! $this->asset_data_registry->exists( 'activeShippingZones' ) && class_exists( '\WC_Shipping_Zones' ) ) { - $shipping_zones = \WC_Shipping_Zones::get_zones(); - $formatted_shipping_zones = array_reduce( - $shipping_zones, - function( $acc, $zone ) { - $acc[] = [ - 'id' => $zone['id'], - 'title' => $zone['zone_name'], - 'description' => $zone['formatted_zone_location'], - ]; - return $acc; - }, - [] - ); - $formatted_shipping_zones[] = [ - 'id' => 0, - 'title' => __( 'International', 'woo-gutenberg-products-block' ), - 'description' => __( 'Locations outside all other zones', 'woo-gutenberg-products-block' ), - ]; - $this->asset_data_registry->add( 'activeShippingZones', $formatted_shipping_zones ); - } - - if ( $is_block_editor && ! $this->asset_data_registry->exists( 'globalPaymentMethods' ) ) { - $payment_methods = WC()->payment_gateways->payment_gateways(); - $formatted_payment_methods = array_reduce( - $payment_methods, - function( $acc, $method ) { - if ( 'yes' === $method->enabled ) { - $acc[] = [ - 'id' => $method->id, - 'title' => $method->method_title, - 'description' => $method->method_description, - ]; - } - return $acc; - }, - [] - ); - $this->asset_data_registry->add( 'globalPaymentMethods', $formatted_payment_methods ); - } - - if ( ! is_admin() && ! WC()->is_rest_api_request() ) { - $this->hydrate_from_api(); - $this->hydrate_customer_payment_methods(); - } - - do_action( 'woocommerce_blocks_checkout_enqueue_data' ); - } - - /** - * Are we currently on the admin block editor screen? - */ - protected function is_block_editor() { - if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { - return false; - } - $screen = get_current_screen(); - - return $screen && $screen->is_block_editor(); - } - - /** - * Removes accents from an array of values, sorts by the values, then returns the original array values sorted. - * - * @param array $array Array of values to sort. - * @return array Sorted array. - */ - protected function deep_sort_with_accents( $array ) { - if ( ! is_array( $array ) || empty( $array ) ) { - return $array; - } - - if ( is_array( reset( $array ) ) ) { - return array_map( [ $this, 'deep_sort_with_accents' ], $array ); - } - - $array_without_accents = array_map( 'remove_accents', array_map( 'wc_strtolower', array_map( 'html_entity_decode', $array ) ) ); - asort( $array_without_accents ); - return array_replace( $array_without_accents, $array ); - } - - /** - * Get customer payment methods for use in checkout. - */ - protected function hydrate_customer_payment_methods() { - if ( ! is_user_logged_in() || $this->asset_data_registry->exists( 'customerPaymentMethods' ) ) { - return; - } - add_filter( 'woocommerce_payment_methods_list_item', [ $this, 'include_token_id_with_payment_methods' ], 10, 2 ); - $this->asset_data_registry->add( - 'customerPaymentMethods', - wc_get_customer_saved_methods_list( get_current_user_id() ) - ); - remove_filter( 'woocommerce_payment_methods_list_item', [ $this, 'include_token_id_with_payment_methods' ], 10, 2 ); - } - - /** - * Hydrate the checkout block with data from the API. - */ - protected function hydrate_from_api() { - // Print existing notices now, otherwise they are caught by the Cart - // Controller and converted to exceptions. - wc_print_notices(); - - add_filter( 'woocommerce_store_api_disable_nonce_check', '__return_true' ); - $this->asset_data_registry->hydrate_api_request( '/wc/store/cart' ); - $this->asset_data_registry->hydrate_api_request( '/wc/store/checkout' ); - remove_filter( 'woocommerce_store_api_disable_nonce_check', '__return_true' ); - } - - /** - * Callback for woocommerce_payment_methods_list_item filter to add token id - * to the generated list. - * - * @param array $list_item The current list item for the saved payment method. - * @param \WC_Token $token The token for the current list item. - * - * @return array The list item with the token id added. - */ - public static function include_token_id_with_payment_methods( $list_item, $token ) { - $list_item['tokenId'] = $token->get_id(); - $brand = ! empty( $list_item['method']['brand'] ) ? - strtolower( $list_item['method']['brand'] ) : - ''; - // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- need to match on translated value from core. - if ( ! empty( $brand ) && esc_html__( 'Credit card', 'woocommerce' ) !== $brand ) { - $list_item['method']['brand'] = wc_get_credit_card_type_label( $brand ); - } - return $list_item; - } -} diff --git a/src/BlockTypesController.php b/src/BlockTypesController.php index 0e6388efc4b..bd2d595f563 100644 --- a/src/BlockTypesController.php +++ b/src/BlockTypesController.php @@ -179,7 +179,6 @@ protected function get_block_types() { if ( Package::feature()->is_experimental_build() ) { $block_types[] = 'SingleProduct'; - $block_types[] = 'CheckoutI2'; $block_types[] = 'MiniCart'; } diff --git a/src/Payments/Api.php b/src/Payments/Api.php index 8e189069838..72a2bbe0e70 100644 --- a/src/Payments/Api.php +++ b/src/Payments/Api.php @@ -63,7 +63,7 @@ protected function init() { * @return array */ public function add_payment_method_script_dependencies( $dependencies, $handle ) { - if ( ! in_array( $handle, [ 'wc-checkout-block', 'wc-checkout-block-frontend', 'wc-checkout-i2-block', 'wc-checkout-i2-block-frontend', 'wc-cart-block', 'wc-cart-block-frontend' ], true ) ) { + if ( ! in_array( $handle, [ 'wc-checkout-block', 'wc-checkout-block-frontend', 'wc-cart-block', 'wc-cart-block-frontend' ], true ) ) { return $dependencies; } return array_merge( $dependencies, $this->payment_method_registry->get_all_active_payment_method_script_dependencies() ); @@ -214,7 +214,7 @@ public function verify_payment_methods_dependencies() { sprintf( 'console.error( "%s" );', $error_message ) ); - $cart_checkout_scripts = [ 'wc-cart-block', 'wc-cart-block-frontend', 'wc-checkout-block', 'wc-checkout-block-frontend', 'wc-checkout-i2-block', 'wc-checkout-i2-block-frontend' ]; + $cart_checkout_scripts = [ 'wc-cart-block', 'wc-cart-block-frontend', 'wc-checkout-block', 'wc-checkout-block-frontend' ]; foreach ( $cart_checkout_scripts as $script_handle ) { if ( ! array_key_exists( $script_handle, $wp_scripts->registered ) || diff --git a/tests/e2e/config/custom-matchers/to-toggle-element.js b/tests/e2e/config/custom-matchers/to-toggle-element.js index 03c9e7ec04c..8a9d18fd9f0 100644 --- a/tests/e2e/config/custom-matchers/to-toggle-element.js +++ b/tests/e2e/config/custom-matchers/to-toggle-element.js @@ -1,3 +1,8 @@ +/** + * Internal dependencies + */ +import { findLabelWithText } from '../../../utils'; + expect.extend( { async toToggleElement( toggleLabel, selector ) { if ( ! selector ) { @@ -16,13 +21,19 @@ expect.extend( { pass: false, }; - await toggleLabel.click(); + await ( typeof toggleLabel === 'string' + ? await findLabelWithText( toggleLabel ) + : toggleLabel + ).click(); if ( initiallyHadSelectorMatch === ( await hasSelectorMatch() ) ) { return noChangeError; } - await toggleLabel.click(); + await ( typeof toggleLabel === 'string' + ? await findLabelWithText( toggleLabel ) + : toggleLabel + ).click(); if ( initiallyHadSelectorMatch !== ( await hasSelectorMatch() ) ) { return noChangeError; diff --git a/tests/e2e/config/custom-matchers/to-toggle-required-attr-of.js b/tests/e2e/config/custom-matchers/to-toggle-required-attr-of.js index bea8eabb00c..b134a1b7e75 100644 --- a/tests/e2e/config/custom-matchers/to-toggle-required-attr-of.js +++ b/tests/e2e/config/custom-matchers/to-toggle-required-attr-of.js @@ -1,3 +1,8 @@ +/** + * Internal dependencies + */ +import { findLabelWithText } from '../../../utils'; + expect.extend( { async toToggleRequiredAttrOf( checkboxLabel, selector ) { if ( ! selector ) { @@ -17,13 +22,19 @@ expect.extend( { pass: false, }; - await checkboxLabel.click(); + await ( typeof checkboxLabel === 'string' + ? await findLabelWithText( checkboxLabel ) + : checkboxLabel + ).click(); if ( wasInitiallyRequired === ( await isRequired() ) ) { return noChangeError; } - await checkboxLabel.click(); + await ( typeof checkboxLabel === 'string' + ? await findLabelWithText( checkboxLabel ) + : checkboxLabel + ).click(); if ( wasInitiallyRequired !== ( await isRequired() ) ) { return noChangeError; diff --git a/tests/e2e/specs/backend/checkout.test.js b/tests/e2e/specs/backend/checkout.test.js index 114e618aa9c..49b0f655e7f 100644 --- a/tests/e2e/specs/backend/checkout.test.js +++ b/tests/e2e/specs/backend/checkout.test.js @@ -9,6 +9,7 @@ import { import { findLabelWithText, visitBlockPage, + selectBlockByName, } from '@woocommerce/blocks-test-utils'; import { @@ -19,7 +20,7 @@ import { const block = { name: 'Checkout', slug: 'woocommerce/checkout', - class: '.wc-block-checkout', + class: '.wp-block-woocommerce-checkout', }; if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) { @@ -79,77 +80,80 @@ describe( `${ block.name } Block`, () => { describe( 'attributes', () => { beforeEach( async () => { await openDocumentSettingsSidebar(); - await page.click( block.class ); + await selectBlockByName( block.slug ); + } ); + + it( 'can enable dark mode inputs', async () => { + const toggleLabel = await findLabelWithText( + 'Dark mode inputs' + ); + await toggleLabel.click(); + + await expect( page ).toMatchElement( + `.wc-block-checkout.has-dark-controls` + ); + + await toggleLabel.click(); + + await expect( page ).not.toMatchElement( + `.wc-block-checkout.has-dark-controls` + ); + } ); + } ); + + describe( 'shipping address block attributes', () => { + beforeEach( async () => { + await openDocumentSettingsSidebar(); + await selectBlockByName( + 'woocommerce/checkout-shipping-address-block' + ); } ); describe( 'Company input', () => { - const selector = `${ block.class } .wc-block-components-address-form__company input`; + const selector = `${ block.class } #shipping-company`; it( 'visibility can be toggled', async () => { - const toggleLabel = await findLabelWithText( 'Company' ); - await expect( toggleLabel ).toToggleElement( selector ); + await expect( 'Company' ).toToggleElement( selector ); } ); it( 'required attribute can be toggled', async () => { // Company is disabled by default, so first we need to enable it. const toggleLabel = await findLabelWithText( 'Company' ); await toggleLabel.click(); - const checkboxLabel = await findLabelWithText( + await expect( 'Require company name?' - ); - - await expect( checkboxLabel ).toToggleRequiredAttrOf( - selector - ); + ).toToggleRequiredAttrOf( selector ); } ); } ); describe( 'Apartment input', () => { it( 'visibility can be toggled', async () => { - const selector = `${ block.class } .wc-block-components-address-form__address_2 input`; - const toggleLabel = await findLabelWithText( - 'Apartment, suite, etc.' + const selector = `${ block.class } #shipping-address_2`; + await expect( 'Apartment, suite, etc.' ).toToggleElement( + selector ); - await expect( toggleLabel ).toToggleElement( selector ); } ); } ); describe( 'Phone input', () => { - const selector = `${ block.class } #phone`; + const selector = `${ block.class } #shipping-phone`; it( 'visibility can be toggled', async () => { - const toggleLabel = await findLabelWithText( 'Phone' ); - await expect( toggleLabel ).toToggleElement( selector ); + await expect( 'Phone' ).toToggleElement( selector ); } ); it( 'required attribute can be toggled', async () => { - const checkboxLabel = await findLabelWithText( + await expect( 'Require phone number?' - ); - await expect( checkboxLabel ).toToggleRequiredAttrOf( - selector - ); - } ); - } ); - - describe( 'Order notes checkbox', () => { - it( 'visibility can be toggled', async () => { - const selector = `${ block.class } .wc-block-checkout__add-note`; - const toggleLabel = await findLabelWithText( - 'Allow shoppers to optionally add order notes' - ); - await expect( toggleLabel ).toToggleElement( selector ); + ).toToggleRequiredAttrOf( selector ); } ); } ); + } ); - describe( 'Links to polices', () => { - it( 'visibility can be toggled', async () => { - const selector = `${ block.class } .wc-block-components-checkout-policies`; - const toggleLabel = await findLabelWithText( - 'Show links to policies' - ); - await expect( toggleLabel ).toToggleElement( selector ); - } ); + describe( 'action block attributes', () => { + beforeEach( async () => { + await openDocumentSettingsSidebar(); + await selectBlockByName( 'woocommerce/checkout-actions-block' ); } ); describe( 'Return to cart link', () => { @@ -161,25 +165,6 @@ describe( `${ block.name } Block`, () => { await expect( toggleLabel ).toToggleElement( selector ); } ); } ); - - it( 'can enable dark mode inputs', async () => { - await openDocumentSettingsSidebar(); - await page.click( block.class ); - const toggleLabel = await findLabelWithText( - 'Dark mode inputs' - ); - await toggleLabel.click(); - - await expect( page ).toMatchElement( - `${ block.class }.has-dark-controls` - ); - - await toggleLabel.click(); - - await expect( page ).not.toMatchElement( - `${ block.class }.has-dark-controls` - ); - } ); } ); } ); } ); diff --git a/tests/utils/index.js b/tests/utils/index.js index 8d933e7c454..1d7e7dbadc7 100644 --- a/tests/utils/index.js +++ b/tests/utils/index.js @@ -4,3 +4,4 @@ export { visitBlockPage, visitPostOfType } from './visit-block-page'; export { getBlockPagePermalink } from './get-block-page-permalink'; export { getNormalPagePermalink } from './get-normal-page-permalink'; export { shopper } from './shopper'; +export { selectBlockByName } from './select-block-by-name'; diff --git a/tests/utils/select-block-by-name.js b/tests/utils/select-block-by-name.js new file mode 100644 index 00000000000..24ebcb83ef8 --- /dev/null +++ b/tests/utils/select-block-by-name.js @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { getAllBlocks, selectBlockByClientId } from '@wordpress/e2e-test-utils'; + +export const selectBlockByName = async ( blockName ) => { + const blocksInEditor = await getAllBlocks(); + const flatBlockArray = ( blocks ) => + blocks + .map( ( block ) => [ + { [ block.name ]: block.clientId }, + block.innerBlocks ? flatBlockArray( block.innerBlocks ) : [], + ] ) + .flat( Infinity ); + const blocksObject = Object.fromEntries( + flatBlockArray( blocksInEditor ) + .map( ( block ) => Object.entries( block ) ) + .flat() + ); + const clientId = blocksObject[ blockName ]; + return selectBlockByClientId( clientId ); +}; diff --git a/tsconfig.json b/tsconfig.json index 3ca4c14185d..88a4af4398b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.base.json", "include": [ "./assets/js/**/*", - "./assets/js/blocks/cart-checkout/checkout-i2/inner-blocks/checkout-sample-block/block.json" + "./assets/js/blocks/cart-checkout/checkout/inner-blocks/**/block.json" ], "exclude": [ "./assets/js/data" ], "references": [