From cdce1eae3aa0e8037f459c747cf09bf3d23f71e2 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 5 Jan 2023 16:27:34 +0000 Subject: [PATCH 1/3] Wrap Checkout Edit in SlotFillProvider Required to render Slot/Fills in the editor --- assets/js/blocks/checkout/edit.tsx | 63 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/assets/js/blocks/checkout/edit.tsx b/assets/js/blocks/checkout/edit.tsx index d61bce1714d..0dfe422e172 100644 --- a/assets/js/blocks/checkout/edit.tsx +++ b/assets/js/blocks/checkout/edit.tsx @@ -19,6 +19,7 @@ import { ToggleControl, CheckboxControl, } from '@wordpress/components'; +import { SlotFillProvider } from '@woocommerce/blocks-checkout'; import type { TemplateArray } from '@wordpress/blocks'; import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt'; @@ -147,38 +148,40 @@ export const Edit = ( { - - - + + - - - - - - + + + + + + + ); From 05d547799eb1052589d127f69217e345dd539f7b Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 5 Jan 2023 16:45:58 +0000 Subject: [PATCH 2/3] Remove editor check when rendering ExperimentalOrderShippingPackages We want to render it in the editor and on the front end, so checking is no longer necessary --- .../shipping-rates-control/index.tsx | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx index f8c1bb001eb..d6ba746a8e0 100644 --- a/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx +++ b/assets/js/base/components/cart-checkout/shipping-rates-control/index.tsx @@ -10,7 +10,7 @@ import { getShippingRatesPackageCount, getShippingRatesRateCount, } from '@woocommerce/base-utils'; -import { useStoreCart, useEditorContext } from '@woocommerce/base-context'; +import { useStoreCart } from '@woocommerce/base-context'; import { CartResponseShippingRate } from '@woocommerce/types'; import { ReactElement } from 'react'; @@ -166,8 +166,6 @@ const ShippingRatesControl = ( { }, context, }; - const { isEditor } = useEditorContext(); - return ( - { isEditor ? ( + + - ) : ( - <> - - - - - - ) } + ); }; From d9d478329f4ec3cbdd78f293437f9092f6a2c3f6 Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 5 Jan 2023 16:52:58 +0000 Subject: [PATCH 3/3] Wrap Cart in SlotFillProvider when in editor This is so Slot/Fills can be rendered in the preview --- assets/js/blocks/cart/edit.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/assets/js/blocks/cart/edit.js b/assets/js/blocks/cart/edit.js index 7d70a0805d2..fceba16508d 100644 --- a/assets/js/blocks/cart/edit.js +++ b/assets/js/blocks/cart/edit.js @@ -12,6 +12,7 @@ import { import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; import { EditorProvider, CartProvider } from '@woocommerce/base-context'; import { previewCart } from '@woocommerce/resource-previews'; +import { SlotFillProvider } from '@woocommerce/blocks-checkout'; /** * Internal dependencies @@ -86,13 +87,15 @@ export const Edit = ( { className, attributes, setAttributes, clientId } ) => { hasDarkControls, } } > - - - + + + + +