From b4a792ebf4946ef5116c3031a0d8b9ebd4cc3fbb Mon Sep 17 00:00:00 2001 From: kmanijak Date: Fri, 17 Mar 2023 13:24:00 +0100 Subject: [PATCH 01/10] Change the example of GET products by category from category name to ID (#8774) --- src/StoreApi/docs/products.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StoreApi/docs/products.md b/src/StoreApi/docs/products.md index 465adb6f96c..9cfabe0ae8e 100644 --- a/src/StoreApi/docs/products.md +++ b/src/StoreApi/docs/products.md @@ -23,7 +23,7 @@ GET /products?parent_exclude=10 GET /products?type=simple GET /products?sku=sku-1,sku-2 GET /products?featured=true -GET /products?category=t-shirts +GET /products?category=22 GET /products?product-taxonomy=product-taxonomy-term-id GET /products?tag=special-items GET /products?attributes[0][attribute]=pa_color&attributes[0][slug]=red From da5efea36028294d595adcb448f56ede2595f361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Fri, 17 Mar 2023 13:26:34 +0100 Subject: [PATCH 02/10] Fix issue that prevented spaces being added to Mini Cart, Cart and Checkout buttons (#8777) * Fix issue that prevented spaces being added to Mini Cart, Cart and Checkout buttons * Fix a couple of comments --- .../proceed-to-checkout-block/edit.tsx | 31 +++---- .../checkout-actions-block/edit.tsx | 31 +++---- .../mini-cart-footer-block/edit.tsx | 50 +++++------ .../mini-cart-shopping-button-block/edit.tsx | 27 +++--- .../editable-button/index.tsx | 88 +++++++++++++++++++ 5 files changed, 144 insertions(+), 83 deletions(-) create mode 100644 assets/js/editor-components/editable-button/index.tsx diff --git a/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/edit.tsx b/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/edit.tsx index 62e9d5376d3..3022836667b 100644 --- a/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/edit.tsx +++ b/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/edit.tsx @@ -4,12 +4,8 @@ import { useRef } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -import Button from '@woocommerce/base-components/button'; -import { - InspectorControls, - RichText, - useBlockProps, -} from '@wordpress/block-editor'; +import EditableButton from '@woocommerce/editor-components/editable-button'; +import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import PageSelector from '@woocommerce/editor-components/page-selector'; import { CART_PAGE_ID } from '@woocommerce/block-settings'; @@ -68,19 +64,16 @@ export const Edit = ( { /> ) } - + { + setAttributes( { + buttonLabel: content, + } ); + } } + /> ); }; diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/edit.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/edit.tsx index 004eaad078e..38a5ebbbad7 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/edit.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-actions-block/edit.tsx @@ -4,17 +4,13 @@ import { useRef } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -import { - InspectorControls, - useBlockProps, - RichText, -} from '@wordpress/block-editor'; +import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import PageSelector from '@woocommerce/editor-components/page-selector'; import { PanelBody, ToggleControl } from '@wordpress/components'; import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings'; import { getSetting } from '@woocommerce/settings'; import { ReturnToCartButton } from '@woocommerce/base-components/cart-checkout'; -import Button from '@woocommerce/base-components/button'; +import EditableButton from '@woocommerce/editor-components/editable-button'; import Noninteractive from '@woocommerce/base-components/noninteractive'; /** @@ -104,19 +100,16 @@ export const Edit = ( { /> ) } - + { + setAttributes( { + placeOrderButtonLabel: content, + } ); + } } + /> ); diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx index e13b0bfd1a6..2f914800272 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx @@ -3,8 +3,8 @@ */ import { __ } from '@wordpress/i18n'; import { TotalsItem } from '@woocommerce/blocks-checkout'; -import Button from '@woocommerce/base-components/button'; -import { useBlockProps, RichText } from '@wordpress/block-editor'; +import EditableButton from '@woocommerce/editor-components/editable-button'; +import { useBlockProps } from '@wordpress/block-editor'; import { getCurrencyFromPriceResponse } from '@woocommerce/price-format'; import { usePaymentMethods, @@ -64,35 +64,27 @@ export const Edit = ( { ) } />
- - + value={ cartButtonLabel } + placeholder={ defaultCartButtonLabel } + onChange={ ( content ) => { + setAttributes( { + cartButtonLabel: content, + } ); + } } + /> + { + setAttributes( { + checkoutButtonLabel: content, + } ); + } } + />
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx index b8732a79aa1..d4bb89af179 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx @@ -1,8 +1,8 @@ /** * External dependencies */ -import { useBlockProps, RichText } from '@wordpress/block-editor'; -import Button from '@woocommerce/base-components/button'; +import { useBlockProps } from '@wordpress/block-editor'; +import EditableButton from '@woocommerce/editor-components/editable-button'; /** * Internal dependencies @@ -23,22 +23,17 @@ export const Edit = ( { return (
- + value={ startShoppingButtonLabel } + placeholder={ defaultStartShoppingButtonLabel } + onChange={ ( content ) => { + setAttributes( { + startShoppingButtonLabel: content, + } ); + } } + />
); }; diff --git a/assets/js/editor-components/editable-button/index.tsx b/assets/js/editor-components/editable-button/index.tsx new file mode 100644 index 00000000000..6e012672cac --- /dev/null +++ b/assets/js/editor-components/editable-button/index.tsx @@ -0,0 +1,88 @@ +/** + * External dependencies + */ +import { useEffect, useRef } from '@wordpress/element'; +import Button, { ButtonProps } from '@woocommerce/base-components/button'; +import { RichText } from '@wordpress/block-editor'; +import type { RefObject } from 'react'; + +export interface EditableButtonProps + extends Omit< ButtonProps, 'onChange' | 'placeholder' | 'value' > { + /** + * On change callback. + */ + onChange: ( value: string ) => void; + /** + * The placeholder of the editable button. + */ + placeholder?: string; + /** + * The current value of the editable button. + */ + value: string; +} + +const EditableButton = ( { + onChange, + placeholder, + value, + ...props +}: EditableButtonProps ) => { + const button: RefObject< HTMLButtonElement > = useRef( null ); + + // Fix a bug in Firefox that didn't allow to type spaces in editable buttons. + // @see https://github.com/woocommerce/woocommerce-blocks/issues/8734 + useEffect( () => { + const buttonEl = button?.current; + + if ( ! buttonEl ) { + return; + } + + const onKeyDown = ( event: KeyboardEvent ) => { + // If the user typed something different than space, do nothing. + if ( event.code !== 'Space' ) { + return; + } + event.preventDefault(); + const selection = buttonEl.ownerDocument.getSelection(); + if ( selection && selection.rangeCount > 0 ) { + // Get the caret position and insert a space. + const range = selection.getRangeAt( 0 ); + range.deleteContents(); + const textNode = document.createTextNode( ' ' ); + range.insertNode( textNode ); + // Set the caret position after the space. + range.setStartAfter( textNode ); + range.setEndAfter( textNode ); + selection.removeAllRanges(); + selection.addRange( range ); + } + }; + + buttonEl.addEventListener( 'keydown', onKeyDown ); + + return () => { + if ( ! buttonEl ) { + return; + } + buttonEl.removeEventListener( 'keydown', onKeyDown ); + }; + }, [ onChange, value ] ); + + return ( + + ); +}; + +export default EditableButton; From a06340fcbdb673c7adc521042a04cffdaf6fd5f3 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 17 Mar 2023 14:15:13 +0000 Subject: [PATCH 03/10] Enhancement/local pickup order confirmation (#8727) * Hide shipping address from local pickup order confirmation page * Add pickup details to confirmations * Error handling * Update test because columns may be hidden * use address selector * Custom selector for local pickup * try forcing flat rate during test --- src/Shipping/ShippingController.php | 46 ++++++++++++++++++- .../shopper/cart-checkout/checkout.test.js | 12 ++++- tests/utils/shopper.js | 4 +- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/Shipping/ShippingController.php b/src/Shipping/ShippingController.php index 5c7686be569..6e313d99a41 100644 --- a/src/Shipping/ShippingController.php +++ b/src/Shipping/ShippingController.php @@ -3,7 +3,6 @@ use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi; use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry; -use Automattic\WooCommerce\Blocks\Tests\BlockTypes\Cart; use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils; use Automattic\WooCommerce\StoreApi\Utilities\LocalPickupUtils; use Automattic\WooCommerce\Utilities\ArrayUtil; @@ -59,12 +58,14 @@ function() { add_action( 'admin_enqueue_scripts', [ $this, 'hydrate_client_settings' ] ); add_action( 'woocommerce_load_shipping_methods', array( $this, 'register_local_pickup' ) ); add_filter( 'woocommerce_local_pickup_methods', array( $this, 'register_local_pickup_method' ) ); + add_filter( 'woocommerce_order_hide_shipping_address', array( $this, 'hide_shipping_address_for_local_pickup' ), 10 ); add_filter( 'woocommerce_customer_taxable_address', array( $this, 'filter_taxable_address' ) ); add_filter( 'woocommerce_shipping_packages', array( $this, 'filter_shipping_packages' ) ); add_filter( 'pre_update_option_woocommerce_pickup_location_settings', array( $this, 'flush_cache' ) ); add_filter( 'pre_update_option_pickup_location_pickup_locations', array( $this, 'flush_cache' ) ); add_filter( 'woocommerce_shipping_settings', array( $this, 'remove_shipping_settings' ) ); add_filter( 'wc_shipping_enabled', array( $this, 'force_shipping_enabled' ), 100, 1 ); + add_filter( 'woocommerce_order_shipping_to_display', array( $this, 'show_local_pickup_details' ), 10, 2 ); // This is required to short circuit `show_shipping` from class-wc-cart.php - without it, that function // returns based on the option's value in the DB and we can't override it any other way. @@ -98,6 +99,39 @@ public function force_shipping_enabled( $enabled ) { return $enabled; } + /** + * Inject collection details onto the order received page. + * + * @param string $return Return value. + * @param \WC_Order $order Order object. + * @return string + */ + public function show_local_pickup_details( $return, $order ) { + // Confirm order is valid before proceeding further. + if ( ! $order instanceof \WC_Order ) { + return $return; + } + + $shipping_method_ids = ArrayUtil::select( $order->get_shipping_methods(), 'get_method_id', ArrayUtil::SELECT_BY_OBJECT_METHOD ); + $shipping_method_id = current( $shipping_method_ids ); + + // Ensure order used pickup location method, otherwise bail. + if ( 'pickup_location' !== $shipping_method_id ) { + return $return; + } + + $shipping_method = current( $order->get_shipping_methods() ); + $details = $shipping_method->get_meta( 'pickup_details' ); + $location = $shipping_method->get_meta( 'pickup_location' ); + $address = $shipping_method->get_meta( 'pickup_address' ); + + return sprintf( + // Translators: %s location name. + __( 'Pickup from %s:', 'woo-gutenberg-products-block' ), + $location + ) . '
' . str_replace( ',', ',
', $address ) . '

' . $details; + } + /** * If the Checkout block Remove shipping settings from WC Core's admin panels that are now block settings. * @@ -342,6 +376,16 @@ public function register_local_pickup_method( $methods ) { return $methods; } + /** + * Hides the shipping address on the order confirmation page when local pickup is selected. + * + * @param array $pickup_methods Method ids. + * @return array + */ + public function hide_shipping_address_for_local_pickup( $pickup_methods ) { + return array_merge( $pickup_methods, LocalPickupUtils::get_local_pickup_method_ids() ); + } + /** * Everytime we save or update local pickup settings, we flush the shipping * transient group. diff --git a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js index 8fbb77c9c40..f1e9e726db7 100644 --- a/tests/e2e/specs/shopper/cart-checkout/checkout.test.js +++ b/tests/e2e/specs/shopper/cart-checkout/checkout.test.js @@ -118,7 +118,10 @@ describe( 'Shopper → Checkout', () => { expect( page ).toMatch( 'Woo Collection' ); await shopper.block.fillBillingDetails( BILLING_DETAILS ); await shopper.block.placeOrder(); - await shopper.block.verifyBillingDetails( BILLING_DETAILS ); + await shopper.block.verifyBillingDetails( + BILLING_DETAILS, + '.woocommerce-customer-details address' + ); } ); } ); @@ -144,6 +147,9 @@ describe( 'Shopper → Checkout', () => { } ); describe( 'Shipping and Billing Addresses', () => { + const NORMAL_SHIPPING_NAME = 'Normal Shipping'; + const NORMAL_SHIPPING_PRICE = '$20.00'; + beforeAll( async () => { await preventCompatibilityNotice(); await merchant.login(); @@ -186,6 +192,10 @@ describe( 'Shopper → Checkout', () => { ); await shopper.block.fillShippingDetails( SHIPPING_DETAILS ); await shopper.block.fillBillingDetails( BILLING_DETAILS ); + await shopper.block.selectAndVerifyShippingOption( + NORMAL_SHIPPING_NAME, + NORMAL_SHIPPING_PRICE + ); await shopper.block.placeOrder(); await shopper.block.verifyShippingDetails( SHIPPING_DETAILS ); await shopper.block.verifyBillingDetails( BILLING_DETAILS ); diff --git a/tests/utils/shopper.js b/tests/utils/shopper.js index 114126cc286..e1b969dce33 100644 --- a/tests/utils/shopper.js +++ b/tests/utils/shopper.js @@ -322,8 +322,8 @@ export const shopper = { }, // prettier-ignore - verifyBillingDetails: async ( customerBillingDetails ) => { - await page.waitForSelector( '.woocommerce-column--billing-address' ); + verifyBillingDetails: async ( customerBillingDetails, selector = '.woocommerce-column--billing-address' ) => { + await page.waitForSelector( selector ); await Promise.all( [ expect( page ).toMatch( customerBillingDetails.firstname From 542cb76ec28f01aaace83baeccaea47edcd2d548 Mon Sep 17 00:00:00 2001 From: Tarun Vijwani Date: Fri, 17 Mar 2023 19:32:03 +0400 Subject: [PATCH 04/10] Add validation error to prevent checkout when there is no shipping method available (#8384) * Prevent checkout when no shipping rates available - Add the validation error in ShippingSelector to prevent checkout when no shipping rates available. - Add notice to Checkout processor so that notice appears after clicking on place order button. * Fix TypeScript error in checkout shipping method block - Make multiple prop as optional in RatePrice component to fix TypeScript error. --- .../cart-checkout/checkout-processor.ts | 15 +++++++++- .../checkout-shipping-method-block/block.tsx | 28 +++++++++++++++++++ .../shared/rate-price.tsx | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/assets/js/base/context/providers/cart-checkout/checkout-processor.ts b/assets/js/base/context/providers/cart-checkout/checkout-processor.ts index 6d9de6979af..701e4a635dc 100644 --- a/assets/js/base/context/providers/cart-checkout/checkout-processor.ts +++ b/assets/js/base/context/providers/cart-checkout/checkout-processor.ts @@ -14,7 +14,7 @@ import { emptyHiddenAddressFields, removeAllNotices, } from '@woocommerce/base-utils'; -import { useDispatch, useSelect } from '@wordpress/data'; +import { useDispatch, useSelect, select as selectStore } from '@wordpress/data'; import { CHECKOUT_STORE_KEY, PAYMENT_STORE_KEY, @@ -160,6 +160,19 @@ const CheckoutProcessor = () => { const checkValidation = useCallback( () => { if ( hasValidationErrors() ) { + // If there is a shipping rates validation error, return the error message to be displayed. + if ( + selectStore( VALIDATION_STORE_KEY ).getValidationError( + 'shipping-rates-error' + ) !== undefined + ) { + return { + errorMessage: __( + 'Sorry, this order requires a shipping option.', + 'woo-gutenberg-products-block' + ), + }; + } return false; } if ( hasPaymentError ) { diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx index d6bbbfac0de..7cd95fba945 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/block.tsx @@ -9,6 +9,9 @@ import { } from 'wordpress-components'; import classnames from 'classnames'; import { Icon, store, shipping } from '@wordpress/icons'; +import { useEffect } from '@wordpress/element'; +import { VALIDATION_STORE_KEY } from '@woocommerce/block-data'; +import { useDispatch } from '@wordpress/data'; /** * Internal dependencies @@ -19,6 +22,14 @@ import type { minMaxPrices } from './shared'; import { defaultLocalPickupText, defaultShippingText } from './constants'; import { shippingAddressHasValidationErrors } from '../../../../data/cart/utils'; +const SHIPPING_RATE_ERROR = { + hidden: true, + message: __( + 'Shipping options are not available', + 'woo-gutenberg-products-block' + ), +}; + const LocalPickupSelector = ( { checked, rate, @@ -83,6 +94,23 @@ const ShippingSelector = ( { } ) => { const rateShouldBeHidden = shippingCostRequiresAddress && shippingAddressHasValidationErrors(); + const hasShippingPrices = rate.min !== undefined && rate.max !== undefined; + const { setValidationErrors, clearValidationError } = + useDispatch( VALIDATION_STORE_KEY ); + useEffect( () => { + if ( checked === 'shipping' && ! hasShippingPrices ) { + setValidationErrors( { + 'shipping-rates-error': SHIPPING_RATE_ERROR, + } ); + } else { + clearValidationError( 'shipping-rates-error' ); + } + }, [ + checked, + clearValidationError, + hasShippingPrices, + setValidationErrors, + ] ); const Price = rate.min === undefined || rateShouldBeHidden ? ( diff --git a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/shared/rate-price.tsx b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/shared/rate-price.tsx index fb96f8dca7c..30e2395154c 100644 --- a/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/shared/rate-price.tsx +++ b/assets/js/blocks/checkout/inner-blocks/checkout-shipping-method-block/shared/rate-price.tsx @@ -16,7 +16,7 @@ export const RatePrice = ( { }: { minRate: CartShippingPackageShippingRate | undefined; maxRate: CartShippingPackageShippingRate | undefined; - multiple: boolean; + multiple?: boolean; } ) => { if ( minRate === undefined || maxRate === undefined ) { return null; From bb29e748f34d9a5a48c0fe162c02f77b144f1539 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 16:47:41 +0100 Subject: [PATCH 05/10] Release: 9.6.6 (#8778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Empty commit for release pull request * Add changelog to readme.txt * Unset default customer state if it doesn't match country (#8460) * Unset default state * add controller for customers * rename validation file * explain fix inline * address feedback * revert back state logic * Update src/StoreApi/Utilities/ValidationUtils.php Co-authored-by: Mike Jolley --------- Co-authored-by: Mike Jolley * Update readme.txt * Add testing notes * Update testing notes * Fix Customer account sidebar link incorrect margin in WP 6.2 (#8437) * Fix Customer account sidebar link incorrect margin in WP 6.2 * Update class name to match the guidelines * Prevent cart from breaking when item_data contains an array (#8440) * Ensure array item data is removed * Remove unused key * Clean up code and add comments * Check for null instead of empty * Use plain foreach to filter and map arrays * Add minimum height to Mini Cart Contents block in the Style Book (#8458) * Update testing notes zip file * Update testing notes * Update testing notes file * Bumping version strings to new version. * Empty commit for release pull request * Empty commit for release pull request * disable compatibilty layer (#8507) * update changelog and testing instructions * add zip link * Bumping version strings to new version. * Empty commit for release pull request * Empty commit for release pull request * Add changelog in readme.txt * Add testing notes * Remove change from testing notes This requires AvaTax credentials for testing. So, we'll test for regressions instead * Check for null session before going forward (#8537) * Fix Payment Options settings crash in the editor (#8535) * Ensure express payment buttons are visible next to each other (#8548) * Update ZIP file * Bumping version strings to new version. * Empty commit for release pull request * Empty commit for release pull request * Update readme.txt * Show three Express Payments buttons in-line (#8601) * Add testing notes * Bumping version strings to new version. * Empty commit for release pull request * Empty commit for release pull request * Add changelog in readme.txt * Undo dirty prop removal on error (#8633) Co-authored-by: Saad Tarhi * Add testing notes * fix 404 error (#8445) * Empty commit for release pull request * add testing instruction * update zip link * fix version --------- Co-authored-by: github-actions Co-authored-by: Saad Tarhi Co-authored-by: Seghir Nadir Co-authored-by: Mike Jolley Co-authored-by: Albert Juhé Lluveras Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> Co-authored-by: Luigi Teschio Co-authored-by: Niels Lange --- .../express-payment/style.scss | 35 ++++++------------- assets/js/data/cart/push-changes.ts | 26 +++++++++++--- .../external-link-card/index.tsx | 4 +-- .../testing/releases/963.md | 22 ++++++++++++ .../testing/releases/964.md | 3 ++ .../testing/releases/965.md | 13 +++++++ .../testing/releases/966.md | 11 ++++++ .../testing/releases/README.md | 5 ++- package.json | 2 +- readme.txt | 28 ++++++++++++++- src/BlockTypes/ProductImageGallery.php | 10 ++++-- src/Package.php | 2 +- src/Shipping/ShippingController.php | 4 +++ woocommerce-gutenberg-products-block.php | 2 +- 14 files changed, 129 insertions(+), 38 deletions(-) create mode 100644 docs/internal-developers/testing/releases/963.md create mode 100644 docs/internal-developers/testing/releases/964.md create mode 100644 docs/internal-developers/testing/releases/965.md create mode 100644 docs/internal-developers/testing/releases/966.md diff --git a/assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/style.scss b/assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/style.scss index 17fb4cb709c..990809e7fac 100644 --- a/assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/style.scss +++ b/assets/js/blocks/cart-checkout-shared/payment-methods/express-payment/style.scss @@ -7,9 +7,10 @@ $border-radius: 5px; .wc-block-components-express-payment__event-buttons { list-style: none; - display: flex; - flex-direction: row; - flex-wrap: wrap; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(calc(33% - 10px), 1fr)); + grid-gap: 10px; + box-sizing: border-box; width: 100%; padding: 0; margin: 0; @@ -18,6 +19,7 @@ $border-radius: 5px; > li { margin: 0; + width: 100%; > img { width: 100%; @@ -25,6 +27,12 @@ $border-radius: 5px; } } } + + @include breakpoint("<782px") { + .wc-block-components-express-payment__event-buttons { + grid-template-columns: 1fr; + } + } } .wc-block-components-express-payment--checkout { @@ -85,27 +93,6 @@ $border-radius: 5px; margin-bottom: em($gap); } } - - .wc-block-components-express-payment__event-buttons { - > li { - display: inline-block; - width: 50%; - } - - > li:nth-child(even) { - padding-left: $gap-smaller; - } - - > li:nth-child(odd) { - padding-right: $gap-smaller; - } - - > li:only-child { - display: block; - width: 100%; - padding: 0; - } - } } .wc-block-components-express-payment--cart { diff --git a/assets/js/data/cart/push-changes.ts b/assets/js/data/cart/push-changes.ts index 85373cf9e88..8410a3a0a70 100644 --- a/assets/js/data/cart/push-changes.ts +++ b/assets/js/data/cart/push-changes.ts @@ -126,7 +126,6 @@ const dirtyProps = < const updateCustomerData = debounce( (): void => { const { billingAddress, shippingAddress } = customerData; const validationStore = select( VALIDATION_STORE_KEY ); - const customerDataToUpdate = {} as Partial< BillingAddressShippingAddress >; // Before we push anything, we need to ensure that the data we're pushing (dirty fields) are valid, otherwise we will // abort and wait for the validation issues to be resolved. @@ -150,6 +149,8 @@ const updateCustomerData = debounce( (): void => { } // Find valid data from the list of dirtyProps and prepare to push to the server. + const customerDataToUpdate = {} as Partial< BillingAddressShippingAddress >; + if ( dirtyProps.billingAddress.length ) { customerDataToUpdate.billing_address = pick( billingAddress, @@ -166,14 +167,31 @@ const updateCustomerData = debounce( (): void => { dirtyProps.shippingAddress = []; } + // If there is customer data to update, push it to the server. if ( Object.keys( customerDataToUpdate ).length ) { dispatch( STORE_KEY ) .updateCustomerData( customerDataToUpdate ) - .then( () => { - removeAllNotices(); - } ) + .then( removeAllNotices ) .catch( ( response ) => { processErrorResponse( response ); + + // Data did not persist due to an error. Make the props dirty again so they get pushed to the server. + if ( customerDataToUpdate.billing_address ) { + dirtyProps.billingAddress = [ + ...dirtyProps.billingAddress, + ...( Object.keys( + customerDataToUpdate.billing_address + ) as BaseAddressKey[] ), + ]; + } + if ( customerDataToUpdate.shipping_address ) { + dirtyProps.shippingAddress = [ + ...dirtyProps.shippingAddress, + ...( Object.keys( + customerDataToUpdate.shipping_address + ) as BaseAddressKey[] ), + ]; + } } ); } }, 1000 ); diff --git a/assets/js/editor-components/external-link-card/index.tsx b/assets/js/editor-components/external-link-card/index.tsx index 21c57081aca..3b0495cbf4f 100644 --- a/assets/js/editor-components/external-link-card/index.tsx +++ b/assets/js/editor-components/external-link-card/index.tsx @@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n'; import { Icon, external } from '@wordpress/icons'; import { VisuallyHidden } from '@wordpress/components'; import { sanitizeHTML } from '@woocommerce/utils'; -import { alert } from '@woocommerce/icons'; +import { Alert } from '@woocommerce/icons'; /** * Internal dependencies @@ -50,7 +50,7 @@ const ExternalLinkCard = ( { ) } { warning ? ( - + } /> { warning } ) : null } diff --git a/docs/internal-developers/testing/releases/963.md b/docs/internal-developers/testing/releases/963.md new file mode 100644 index 00000000000..de101bb3fd9 --- /dev/null +++ b/docs/internal-developers/testing/releases/963.md @@ -0,0 +1,22 @@ +# Testing notes and ZIP for release 9.6.3 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/10841107/woocommerce-gutenberg-products-block.zip) + + +## WooCommerce Core + +### Fix the Checkout Blocks "Payment Options" settings crash in the editor. ([8535](https://github.com/woocommerce/woocommerce-blocks/pull/8535)) + +1. Install and enable an incompatible payment gateway plugin with the `Cart` & `Checkout` Blocks. (e.g., [IDPay Payment Gateway for Woocommerce](https://wordpress.org/plugins/woo-idpay-gateway/)) +2. Create a new page and add the `Checkout` Block +3. Select the Checkout Block or any of its Inner Blocks (except for the `Payment Options` Inner Block). Ensure our incompatible payment gateway (e.g., IDPay) is listed under the incompatible gateways notice: + +image + +4. Select the `Payment Options` Inner Block. Ensure its settings are correctly displayed, the incompatible gateways notice is showing and our incompatible payment Gateway is highlighted under `Settings -> Block -> Methods` + +image + +| Before | After | +| ------ | ----- | +| image | image | diff --git a/docs/internal-developers/testing/releases/964.md b/docs/internal-developers/testing/releases/964.md new file mode 100644 index 00000000000..f1e5b9f78df --- /dev/null +++ b/docs/internal-developers/testing/releases/964.md @@ -0,0 +1,3 @@ +# Testing notes and ZIP for release 9.6.4 + +No User Facing Testing required with this patch release. diff --git a/docs/internal-developers/testing/releases/965.md b/docs/internal-developers/testing/releases/965.md new file mode 100644 index 00000000000..bbaf048d576 --- /dev/null +++ b/docs/internal-developers/testing/releases/965.md @@ -0,0 +1,13 @@ +# Testing notes and ZIP for release 9.6.5 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/10899628/woocommerce-gutenberg-products-block.zip) + + +## WooCommerce Core + +### Checkout: Fix state validation after changing shipping country. ([8633](https://github.com/woocommerce/woocommerce-blocks/pull/8633) + +1. With a default valid US shipping address set, add an item to the cart and proceed to checkout. +2. Change the shipping address country to India. You will see an error about the incorrect postcode. +3. Select an India state from the dropdown. You will see an error about the incorrect postcode. +4. Enter a valid postcode `411014`. All errors should go away. diff --git a/docs/internal-developers/testing/releases/966.md b/docs/internal-developers/testing/releases/966.md new file mode 100644 index 00000000000..28287b4ff63 --- /dev/null +++ b/docs/internal-developers/testing/releases/966.md @@ -0,0 +1,11 @@ +# Testing notes and ZIP for release 9.6.6 + +Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-blocks/files/11003055/woocommerce-gutenberg-products-block.zip) + + +## WooCommerce Core + +### Product Image Gallery: fix 404 error. ([8445](https://github.com/woocommerce/woocommerce-blocks/pull/8445)) + +1. Add a new post or page. +2. Check the console and see that any 404 error is visible. diff --git a/docs/internal-developers/testing/releases/README.md b/docs/internal-developers/testing/releases/README.md index bb0227d9170..4448b3cfcab 100644 --- a/docs/internal-developers/testing/releases/README.md +++ b/docs/internal-developers/testing/releases/README.md @@ -121,7 +121,10 @@ Every release includes specific testing instructions for new features and bug fi - [9.6.0](./960.md) - [9.6.1](./961.md) - [9.6.2](./962.md) - + - [9.6.3](./963.md) + - [9.6.4](./964.md) + - [9.6.5](./965.md) + - [9.6.6](./965.md) diff --git a/package.json b/package.json index 9b189182276..977d5b1c24d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@woocommerce/block-library", "title": "WooCommerce Blocks", "author": "Automattic", - "version": "9.6.2", + "version": "9.6.5", "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/", "keywords": [ diff --git a/readme.txt b/readme.txt index f93191866b8..86b368679cc 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks Requires at least: 6.1.1 Tested up to: 6.1.1 Requires PHP: 7.2 -Stable tag: 9.6.2 +Stable tag: 9.6.5 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -80,6 +80,32 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/ == Changelog == += 9.6.6 - 2023-03-17 = + +#### Bug Fixes + +- Product Image Gallery: fix 404 error. ([8445](https://github.com/woocommerce/woocommerce-blocks/pull/8445)) + += 9.6.5 - 2023-03-06 = + +#### Bug Fixes + +- Checkout: Fix state validation after changing shipping country. ([8633](https://github.com/woocommerce/woocommerce-blocks/pull/8633) + += 9.6.4 - 2023-03-03 = + +#### Bug Fixes + +- Fix: Show up to three Express Payments buttons next to each other. ([8601](https://github.com/woocommerce/woocommerce-blocks/pull/8601)) + += 9.6.3 - 2023-02-27 = + +#### Bug Fixes + +- Fix: Ensure that Express Payment buttons are visible next to each other. ([8548](https://github.com/woocommerce/woocommerce-blocks/pull/8548)) +- Check if session is set before returning updated customer address. ([8537](https://github.com/woocommerce/woocommerce-blocks/pull/8537)) +- Fix the Checkout Blocks "Payment Options" settings crash in the editor. ([8535](https://github.com/woocommerce/woocommerce-blocks/pull/8535)) + = 9.6.2 - 2023-02-22 = #### Bug Fixes diff --git a/src/BlockTypes/ProductImageGallery.php b/src/BlockTypes/ProductImageGallery.php index 43e84ebbe32..93300d21fcb 100644 --- a/src/BlockTypes/ProductImageGallery.php +++ b/src/BlockTypes/ProductImageGallery.php @@ -1,9 +1,6 @@ session ) { + return $address; + } // We only need to select from the first package, since pickup_location only supports a single package. $chosen_method = current( WC()->session->get( 'chosen_shipping_methods', array() ) ) ?? ''; $chosen_method_id = explode( ':', $chosen_method )[0]; diff --git a/woocommerce-gutenberg-products-block.php b/woocommerce-gutenberg-products-block.php index ad996c8c3df..c0dae3766f7 100644 --- a/woocommerce-gutenberg-products-block.php +++ b/woocommerce-gutenberg-products-block.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Blocks * Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block * Description: WooCommerce blocks for the Gutenberg editor. - * Version: 9.6.2 + * Version: 9.6.5 * Author: Automattic * Author URI: https://woocommerce.com * Text Domain: woo-gutenberg-products-block From 86c6e64f733f973a403c9e797348d60bda3771ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Mon, 20 Mar 2023 11:24:06 +0100 Subject: [PATCH 06/10] Release process: check svn tag before WP.org version and add instruction about dev notes (#8756) * Release steps: check svn version before checking WP.org version * Add instruction to include dev notes --- .github/patch-initial-checklist.md | 2 +- .github/release-initial-checklist.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/patch-initial-checklist.md b/.github/patch-initial-checklist.md index c7a9a377018..80750b76623 100644 --- a/.github/patch-initial-checklist.md +++ b/.github/patch-initial-checklist.md @@ -55,8 +55,8 @@ Each porter is responsible for testing the PRs that fall under the focus of thei - [ ] Edit the [GitHub release](https://github.com/woocommerce/woocommerce-gutenberg-products-block/releases) and copy changelog into the release notes. - [ ] The `#woo-blocks-repo` slack instance will be notified about the progress with the WordPress.org deploy. Watch for that. If anything goes wrong, an error will be reported and you can followup via the GitHub actions tab and the log for that workflow. - [ ] After the wp.org workflow completes, confirm the following - - [ ] Changelog, Version, and Last Updated on [WP.org plugin page](https://wordpress.org/plugins/woo-gutenberg-products-block/) is correct. - [ ] Confirm svn tag is correct, e.g. [{{version}}](https://plugins.svn.wordpress.org/woo-gutenberg-products-block/tags/{{version}}/) + - [ ] Changelog, Version, and Last Updated on [WP.org plugin page](https://wordpress.org/plugins/woo-gutenberg-products-block/) is correct. - [ ] Confirm [WooCommerce.com plugin page](https://woocommerce.com/products/woocommerce-gutenberg-products-block/) is updated. Note: this can take several hours, feel free to check it the following day. - [ ] Download zip and smoke test. - [ ] Test updating plugin from previous version. diff --git a/.github/release-initial-checklist.md b/.github/release-initial-checklist.md index 102c0cc95da..5dc5964bd49 100644 --- a/.github/release-initial-checklist.md +++ b/.github/release-initial-checklist.md @@ -74,8 +74,8 @@ Each porter is responsible for testing the PRs that fall under the focus of thei - [ ] Edit the [GitHub release](https://github.com/woocommerce/woocommerce-gutenberg-products-block/releases) and copy changelog into the release notes. Ensure there is a release with the correct version, the one you entered above. - [ ] The `#woo-blocks-repo` slack instance will be notified about the progress with the WordPress.org deploy. Watch for that. If anything goes wrong, an error will be reported and you can followup via the GitHub actions tab and the log for that workflow. - [ ] After the wp.org workflow completes, confirm the following - - [ ] Changelog, Version, and Last Updated on [WP.org plugin page](https://wordpress.org/plugins/woo-gutenberg-products-block/) is correct. - [ ] Confirm svn tag is correct, e.g. [{{version}}](https://plugins.svn.wordpress.org/woo-gutenberg-products-block/tags/{{version}}/) + - [ ] Changelog, Version, and Last Updated on [WP.org plugin page](https://wordpress.org/plugins/woo-gutenberg-products-block/) is correct. - [ ] Confirm [WooCommerce.com plugin page](https://woocommerce.com/products/woocommerce-gutenberg-products-block/) is updated. Note: this can take several hours, feel free to check it the following day. - [ ] Download zip and smoke test. - [ ] Test updating plugin from previous version. @@ -132,6 +132,7 @@ This only needs to be done if this release is the last release of the feature pl - Ping porters from each team to know which changelog entries need to be highlighted. Ask them to write a short text and optionally provide a screenshot. They can use previous posts for inspiration, we usually try to highlight new features or API changes. - Ensure the release notes are included in the post verbatim. - Don't forget to use category `WooCommerce Blocks Release Notes` for the post. + - If any of the PRs in this release is labelled with `needs dev-note`, include it in the post. - [ ] Add highlights to the WC core release post (do this even if the release you are doing is not merged into WC core): - Check which WC core version will include the WC Blocks release you just did (reference: PdToLP-K-p2). - Go to its Release Thread and search the _Feature Highlights_ comment (example: p6q8Tx-2gl-p2). From 0ea3cfb788aad33e2bcc8ed7d45abd003349df56 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Mon, 20 Mar 2023 14:27:23 +0100 Subject: [PATCH 07/10] Remove Single Product Block (#8763) * Remove Single Product Block * remove more files that belong the Single Product block * fix php linter error * remove Product Tag List and Product Category List blocks --- assets/js/atomic/blocks/component-init.js | 18 --- assets/js/atomic/blocks/index.js | 2 - .../category-list/attributes.ts | 13 -- .../product-elements/category-list/block.tsx | 71 --------- .../category-list/constants.tsx | 17 --- .../product-elements/category-list/edit.tsx | 41 ----- .../product-elements/category-list/index.ts | 56 ------- .../product-elements/category-list/save.tsx | 21 --- .../product-elements/category-list/style.scss | 23 --- .../product-elements/category-list/types.ts | 3 - .../product-elements/tag-list/attributes.ts | 13 -- .../product-elements/tag-list/block.tsx | 63 -------- .../product-elements/tag-list/constants.tsx | 17 --- .../blocks/product-elements/tag-list/edit.tsx | 40 ----- .../blocks/product-elements/tag-list/index.ts | 36 ----- .../blocks/product-elements/tag-list/save.tsx | 21 --- .../product-elements/tag-list/style.scss | 23 --- .../product-elements/tag-list/supports.ts | 18 --- .../blocks/product-elements/tag-list/types.ts | 3 - assets/js/blocks/single-product/attributes.js | 17 --- assets/js/blocks/single-product/block.tsx | 53 ------- assets/js/blocks/single-product/constants.js | 61 -------- .../blocks/single-product/edit/api-error.js | 23 --- .../edit/editor-block-controls.js | 35 ----- .../js/blocks/single-product/edit/editor.scss | 18 --- .../js/blocks/single-product/edit/index.tsx | 144 ------------------ .../single-product/edit/layout-editor.tsx | 92 ----------- .../edit/shared-product-control.js | 26 ---- assets/js/blocks/single-product/frontend.js | 32 ---- assets/js/blocks/single-product/index.js | 37 ----- assets/js/blocks/single-product/save.js | 15 -- assets/js/previews/index.js | 1 - assets/js/previews/single-product-block.js | 11 -- bin/webpack-entries.js | 3 - src/BlockTypes/ProductCategoryList.php | 59 ------- src/BlockTypes/ProductSummary.php | 1 - src/BlockTypes/ProductTagList.php | 55 ------- src/BlockTypes/SingleProduct.php | 50 ------ src/BlockTypesController.php | 6 - .../__fixtures__/single-product.fixture.json | 1 - .../e2e/specs/backend/single-product.test.js | 36 ----- 41 files changed, 1275 deletions(-) delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/attributes.ts delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/block.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/constants.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/edit.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/index.ts delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/save.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/style.scss delete mode 100644 assets/js/atomic/blocks/product-elements/category-list/types.ts delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/attributes.ts delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/block.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/constants.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/edit.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/index.ts delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/save.tsx delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/style.scss delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/supports.ts delete mode 100644 assets/js/atomic/blocks/product-elements/tag-list/types.ts delete mode 100644 assets/js/blocks/single-product/attributes.js delete mode 100644 assets/js/blocks/single-product/block.tsx delete mode 100644 assets/js/blocks/single-product/constants.js delete mode 100644 assets/js/blocks/single-product/edit/api-error.js delete mode 100644 assets/js/blocks/single-product/edit/editor-block-controls.js delete mode 100644 assets/js/blocks/single-product/edit/editor.scss delete mode 100644 assets/js/blocks/single-product/edit/index.tsx delete mode 100644 assets/js/blocks/single-product/edit/layout-editor.tsx delete mode 100644 assets/js/blocks/single-product/edit/shared-product-control.js delete mode 100644 assets/js/blocks/single-product/frontend.js delete mode 100644 assets/js/blocks/single-product/index.js delete mode 100644 assets/js/blocks/single-product/save.js delete mode 100644 assets/js/previews/single-product-block.js delete mode 100644 src/BlockTypes/ProductCategoryList.php delete mode 100644 src/BlockTypes/ProductTagList.php delete mode 100644 src/BlockTypes/SingleProduct.php delete mode 100644 tests/e2e/specs/backend/__fixtures__/single-product.fixture.json delete mode 100644 tests/e2e/specs/backend/single-product.test.js diff --git a/assets/js/atomic/blocks/component-init.js b/assets/js/atomic/blocks/component-init.js index 93a003731ce..8879acd911c 100644 --- a/assets/js/atomic/blocks/component-init.js +++ b/assets/js/atomic/blocks/component-init.js @@ -81,24 +81,6 @@ registerBlockComponent( { ), } ); -registerBlockComponent( { - blockName: 'woocommerce/product-category-list', - component: lazy( () => - import( - /* webpackChunkName: "product-category-list" */ './product-elements/category-list/block' - ) - ), -} ); - -registerBlockComponent( { - blockName: 'woocommerce/product-tag-list', - component: lazy( () => - import( - /* webpackChunkName: "product-tag-list" */ './product-elements/tag-list/block' - ) - ), -} ); - registerBlockComponent( { blockName: 'woocommerce/product-stock-indicator', component: lazy( () => diff --git a/assets/js/atomic/blocks/index.js b/assets/js/atomic/blocks/index.js index 8b66f58247a..d710143533a 100644 --- a/assets/js/atomic/blocks/index.js +++ b/assets/js/atomic/blocks/index.js @@ -9,8 +9,6 @@ import './product-elements/button'; import './product-elements/summary'; import './product-elements/sale-badge'; import './product-elements/sku'; -import './product-elements/category-list'; -import './product-elements/tag-list'; import './product-elements/stock-indicator'; import './product-elements/add-to-cart'; import './product-elements/add-to-cart-form'; diff --git a/assets/js/atomic/blocks/product-elements/category-list/attributes.ts b/assets/js/atomic/blocks/product-elements/category-list/attributes.ts deleted file mode 100644 index 6cc07445f54..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/attributes.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * External dependencies - */ -import type { BlockAttributes } from '@wordpress/blocks'; - -export const blockAttributes: BlockAttributes = { - productId: { - type: 'number', - default: 0, - }, -}; - -export default blockAttributes; diff --git a/assets/js/atomic/blocks/product-elements/category-list/block.tsx b/assets/js/atomic/blocks/product-elements/category-list/block.tsx deleted file mode 100644 index 2890bc8e84d..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/block.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import classnames from 'classnames'; -import { - useInnerBlockLayoutContext, - useProductDataContext, -} from '@woocommerce/shared-context'; -import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; -import { isEmpty } from 'lodash'; -import { withProductDataContext } from '@woocommerce/shared-hocs'; -import type { HTMLAttributes } from 'react'; - -/** - * Internal dependencies - */ -import './style.scss'; -import { Attributes } from './types'; - -type Props = Attributes & HTMLAttributes< HTMLDivElement >; - -/** - * Product Category Block Component. - * - * @param {Object} props Incoming props. - * @param {string} [props.className] CSS Class name for the component. - * @return {*} The component. - */ -const Block = ( props: Props ): JSX.Element | null => { - const { className } = props; - const { parentClassName } = useInnerBlockLayoutContext(); - const { product } = useProductDataContext(); - - const colorProps = useColorProps( props ); - const typographyProps = useTypographyProps( props ); - - if ( isEmpty( product.categories ) ) { - return null; - } - - return ( -
- { __( 'Categories:', 'woo-gutenberg-products-block' ) }{ ' ' } -
    - { Object.values( product.categories ).map( - ( { name, link, slug } ) => { - return ( -
  • - { name } -
  • - ); - } - ) } -
-
- ); -}; - -export default withProductDataContext( Block ); diff --git a/assets/js/atomic/blocks/product-elements/category-list/constants.tsx b/assets/js/atomic/blocks/product-elements/category-list/constants.tsx deleted file mode 100644 index d72577a54b2..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/constants.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { archive, Icon } from '@wordpress/icons'; - -export const BLOCK_TITLE: string = __( - 'Product Category List', - 'woo-gutenberg-products-block' -); -export const BLOCK_ICON: JSX.Element = ( - -); -export const BLOCK_DESCRIPTION: string = __( - 'Display the list of categories that are assigned to a product.', - 'woo-gutenberg-products-block' -); diff --git a/assets/js/atomic/blocks/product-elements/category-list/edit.tsx b/assets/js/atomic/blocks/product-elements/category-list/edit.tsx deleted file mode 100644 index eae09bc5581..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/edit.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Disabled } from '@wordpress/components'; -import EditProductLink from '@woocommerce/editor-components/edit-product-link'; -import { useBlockProps } from '@wordpress/block-editor'; - -/** - * Internal dependencies - */ -import Block from './block'; -import withProductSelector from '../shared/with-product-selector'; -import { BLOCK_TITLE, BLOCK_ICON } from './constants'; -import { Attributes } from './types'; - -interface Props { - attributes: Attributes; -} - -const Edit = ( { attributes }: Props ): JSX.Element => { - const blockProps = useBlockProps(); - - return ( -
- - - - -
- ); -}; - -export default withProductSelector( { - icon: BLOCK_ICON, - label: BLOCK_TITLE, - description: __( - 'Choose a product to display its categories.', - 'woo-gutenberg-products-block' - ), -} )( Edit ); diff --git a/assets/js/atomic/blocks/product-elements/category-list/index.ts b/assets/js/atomic/blocks/product-elements/category-list/index.ts deleted file mode 100644 index 15fd0ec92bb..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * External dependencies - */ -import { - isFeaturePluginBuild, - registerExperimentalBlockType, -} from '@woocommerce/block-settings'; -import type { BlockConfiguration } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import sharedConfig from './../shared/config'; -import attributes from './attributes'; -import edit from './edit'; -import { - BLOCK_TITLE as title, - BLOCK_ICON as icon, - BLOCK_DESCRIPTION as description, -} from './constants'; -import { Save } from './save'; - -const blockConfig: BlockConfiguration = { - ...sharedConfig, - apiVersion: 2, - title, - description, - icon: { src: icon }, - attributes, - supports: { - ...( isFeaturePluginBuild() && { - color: { - text: true, - link: true, - background: false, - __experimentalSkipSerialization: true, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontStyle: true, - __experimentalFontWeight: true, - __experimentalSkipSerialization: true, - }, - __experimentalSelector: - '.wc-block-components-product-category-list', - } ), - }, - save: Save, - edit, -}; - -registerExperimentalBlockType( - 'woocommerce/product-category-list', - blockConfig -); diff --git a/assets/js/atomic/blocks/product-elements/category-list/save.tsx b/assets/js/atomic/blocks/product-elements/category-list/save.tsx deleted file mode 100644 index 11135ed1bb2..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/save.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; -import { useBlockProps } from '@wordpress/block-editor'; - -type Props = { - attributes: Record< string, unknown > & { - className: string; - }; -}; - -export const Save = ( { attributes }: Props ): JSX.Element => { - return ( -
- ); -}; diff --git a/assets/js/atomic/blocks/product-elements/category-list/style.scss b/assets/js/atomic/blocks/product-elements/category-list/style.scss deleted file mode 100644 index b3fa4fd4c10..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/style.scss +++ /dev/null @@ -1,23 +0,0 @@ -.wc-block-components-product-category-list { - margin-top: 0; - margin-bottom: em($gap-small); - - ul { - margin: 0; - padding: 0; - display: inline; - - li { - display: inline; - list-style: none; - } - - li::after { - content: ", "; - } - - li:last-child::after { - content: ""; - } - } -} diff --git a/assets/js/atomic/blocks/product-elements/category-list/types.ts b/assets/js/atomic/blocks/product-elements/category-list/types.ts deleted file mode 100644 index 104d6e55f30..00000000000 --- a/assets/js/atomic/blocks/product-elements/category-list/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface Attributes { - productId: number; -} diff --git a/assets/js/atomic/blocks/product-elements/tag-list/attributes.ts b/assets/js/atomic/blocks/product-elements/tag-list/attributes.ts deleted file mode 100644 index 6cc07445f54..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/attributes.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * External dependencies - */ -import type { BlockAttributes } from '@wordpress/blocks'; - -export const blockAttributes: BlockAttributes = { - productId: { - type: 'number', - default: 0, - }, -}; - -export default blockAttributes; diff --git a/assets/js/atomic/blocks/product-elements/tag-list/block.tsx b/assets/js/atomic/blocks/product-elements/tag-list/block.tsx deleted file mode 100644 index e62e461b349..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/block.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import classnames from 'classnames'; -import { - useInnerBlockLayoutContext, - useProductDataContext, -} from '@woocommerce/shared-context'; -import { useColorProps, useTypographyProps } from '@woocommerce/base-hooks'; -import { isEmpty } from 'lodash'; -import { withProductDataContext } from '@woocommerce/shared-hocs'; -import type { HTMLAttributes } from 'react'; - -/** - * Internal dependencies - */ -import './style.scss'; -import type { BlocksAttributes } from './types'; - -type Props = BlocksAttributes & HTMLAttributes< HTMLDivElement >; - -const Block = ( props: Props ): JSX.Element | null => { - const { className } = props; - const { parentClassName } = useInnerBlockLayoutContext(); - const { product } = useProductDataContext(); - const colorProps = useColorProps( props ); - const typographyProps = useTypographyProps( props ); - - if ( isEmpty( product.tags ) ) { - return null; - } - - return ( -
- { __( 'Tags:', 'woo-gutenberg-products-block' ) }{ ' ' } -
    - { Object.values( product.tags ).map( - ( { name, link, slug } ) => { - return ( -
  • - { name } -
  • - ); - } - ) } -
-
- ); -}; - -export default withProductDataContext( Block ); diff --git a/assets/js/atomic/blocks/product-elements/tag-list/constants.tsx b/assets/js/atomic/blocks/product-elements/tag-list/constants.tsx deleted file mode 100644 index 53d05f8f182..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/constants.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { tag, Icon } from '@wordpress/icons'; - -export const BLOCK_TITLE: string = __( - 'Product Tag List', - 'woo-gutenberg-products-block' -); -export const BLOCK_ICON: JSX.Element = ( - -); -export const BLOCK_DESCRIPTION: string = __( - 'Display the list of tags that are assigned to a product.', - 'woo-gutenberg-products-block' -); diff --git a/assets/js/atomic/blocks/product-elements/tag-list/edit.tsx b/assets/js/atomic/blocks/product-elements/tag-list/edit.tsx deleted file mode 100644 index 14445ab5ccf..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/edit.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Disabled } from '@wordpress/components'; -import EditProductLink from '@woocommerce/editor-components/edit-product-link'; -import { useBlockProps } from '@wordpress/block-editor'; - -/** - * Internal dependencies - */ -import Block from './block'; -import withProductSelector from '../shared/with-product-selector'; -import { BLOCK_TITLE, BLOCK_ICON } from './constants'; -import type { BlocksAttributes } from './types'; - -interface Props { - attributes: BlocksAttributes; -} - -const Edit = ( { attributes }: Props ): JSX.Element => { - const blockProps = useBlockProps(); - return ( -
- - - - -
- ); -}; - -export default withProductSelector( { - icon: BLOCK_ICON, - label: BLOCK_TITLE, - description: __( - 'Choose a product to display its tags.', - 'woo-gutenberg-products-block' - ), -} )( Edit ); diff --git a/assets/js/atomic/blocks/product-elements/tag-list/index.ts b/assets/js/atomic/blocks/product-elements/tag-list/index.ts deleted file mode 100644 index 6093716d5b8..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * External dependencies - */ -import { registerExperimentalBlockType } from '@woocommerce/block-settings'; -import type { BlockConfiguration } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import sharedConfig from '../shared/config'; -import attributes from './attributes'; -import edit from './edit'; -import { - BLOCK_TITLE as title, - BLOCK_ICON as icon, - BLOCK_DESCRIPTION as description, -} from './constants'; -import { Save } from './save'; -import { supports } from './supports'; - -const blockConfig: BlockConfiguration = { - ...sharedConfig, - apiVersion: 2, - title, - description, - icon: { src: icon }, - attributes, - supports, - edit, - save: Save, -}; - -registerExperimentalBlockType( 'woocommerce/product-tag-list', { - ...sharedConfig, - ...blockConfig, -} ); diff --git a/assets/js/atomic/blocks/product-elements/tag-list/save.tsx b/assets/js/atomic/blocks/product-elements/tag-list/save.tsx deleted file mode 100644 index 03a720e27df..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/save.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/** - * External dependencies - */ -import { useBlockProps } from '@wordpress/block-editor'; -import classnames from 'classnames'; - -type Props = { - attributes: Record< string, unknown > & { - className?: string; - }; -}; - -export const Save = ( { attributes }: Props ): JSX.Element => { - return ( -
- ); -}; diff --git a/assets/js/atomic/blocks/product-elements/tag-list/style.scss b/assets/js/atomic/blocks/product-elements/tag-list/style.scss deleted file mode 100644 index 1102b7d30cc..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/style.scss +++ /dev/null @@ -1,23 +0,0 @@ -.wc-block-components-product-tag-list { - margin-top: 0; - margin-bottom: em($gap-small); - - ul { - margin: 0; - padding: 0; - display: inline; - - li { - display: inline; - list-style: none; - } - - li::after { - content: ", "; - } - - li:last-child::after { - content: ""; - } - } -} diff --git a/assets/js/atomic/blocks/product-elements/tag-list/supports.ts b/assets/js/atomic/blocks/product-elements/tag-list/supports.ts deleted file mode 100644 index ac24ca1539d..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/supports.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * External dependencies - */ -import { isFeaturePluginBuild } from '@woocommerce/block-settings'; - -export const supports = { - ...( isFeaturePluginBuild() && { - color: { - text: true, - background: false, - link: true, - }, - typography: { - fontSize: true, - }, - __experimentalSelector: '.wc-block-components-product-tag-list', - } ), -}; diff --git a/assets/js/atomic/blocks/product-elements/tag-list/types.ts b/assets/js/atomic/blocks/product-elements/tag-list/types.ts deleted file mode 100644 index d901bec80b1..00000000000 --- a/assets/js/atomic/blocks/product-elements/tag-list/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface BlocksAttributes { - productId: number; -} diff --git a/assets/js/blocks/single-product/attributes.js b/assets/js/blocks/single-product/attributes.js deleted file mode 100644 index 6a09d89aaee..00000000000 --- a/assets/js/blocks/single-product/attributes.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Internal dependencies - */ -export const blockAttributes = { - isPreview: { - type: 'boolean', - default: false, - }, - /** - * The product ID to display. - */ - productId: { - type: 'number', - }, -}; - -export default blockAttributes; diff --git a/assets/js/blocks/single-product/block.tsx b/assets/js/blocks/single-product/block.tsx deleted file mode 100644 index 032a2184003..00000000000 --- a/assets/js/blocks/single-product/block.tsx +++ /dev/null @@ -1,53 +0,0 @@ -/** - * External dependencies - */ -import { useEffect } from '@wordpress/element'; -import { withProduct } from '@woocommerce/block-hocs'; -import { - InnerBlockLayoutContextProvider, - ProductDataContextProvider, -} from '@woocommerce/shared-context'; -import { StoreNoticesContainer } from '@woocommerce/blocks-checkout'; -import { useStoreEvents } from '@woocommerce/base-context/hooks'; -import { ProductResponseItem } from '@woocommerce/types'; - -/** - * Internal dependencies - */ -import { BLOCK_NAME } from './constants'; - -interface BlockProps { - isLoading: boolean; - product: ProductResponseItem; - children: JSX.Element | JSX.Element[]; -} - -const Block = ( { isLoading, product, children }: BlockProps ) => { - const { dispatchStoreEvent } = useStoreEvents(); - const className = 'wc-block-single-product wc-block-layout'; - const noticeContext = `woocommerce/single-product/${ product?.id || 0 }`; - - useEffect( () => { - dispatchStoreEvent( 'product-render', { - product, - listName: BLOCK_NAME, - } ); - }, [ product, dispatchStoreEvent ] ); - - return ( - - - -
{ children }
-
-
- ); -}; - -export default withProduct( Block ); diff --git a/assets/js/blocks/single-product/constants.js b/assets/js/blocks/single-product/constants.js deleted file mode 100644 index 154957eee97..00000000000 --- a/assets/js/blocks/single-product/constants.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { Icon, mediaAndText } from '@wordpress/icons'; -import { getBlockMap } from '@woocommerce/atomic-utils'; - -export const BLOCK_NAME = 'woocommerce/single-product'; -export const BLOCK_TITLE = __( - 'Single Product', - 'woo-gutenberg-products-block' -); -export const BLOCK_ICON = ( - -); -export const BLOCK_DESCRIPTION = __( - 'Display a single product.', - 'woo-gutenberg-products-block' -); - -export const DEFAULT_INNER_BLOCKS = [ - [ - 'core/columns', - {}, - [ - [ - 'core/column', - {}, - [ [ 'woocommerce/product-image', { showSaleBadge: false } ] ], - ], - [ - 'core/column', - {}, - [ - [ 'woocommerce/product-sale-badge' ], - [ 'woocommerce/product-title', { headingLevel: 2 } ], - [ 'woocommerce/product-rating' ], - [ 'woocommerce/product-price' ], - [ 'woocommerce/product-summary' ], - [ 'woocommerce/product-stock-indicator' ], - [ - 'woocommerce/product-add-to-cart', - { showFormElements: true }, - ], - [ 'woocommerce/product-sku' ], - [ 'woocommerce/product-category-list' ], - [ 'woocommerce/product-tag-list' ], - ], - ], - ], - ], -]; - -export const ALLOWED_INNER_BLOCKS = [ - 'core/columns', - 'core/column', - ...Object.keys( getBlockMap( BLOCK_NAME ) ), -]; diff --git a/assets/js/blocks/single-product/edit/api-error.js b/assets/js/blocks/single-product/edit/api-error.js deleted file mode 100644 index 294a973cb2a..00000000000 --- a/assets/js/blocks/single-product/edit/api-error.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * External dependencies - */ -import ErrorPlaceholder from '@woocommerce/editor-components/error-placeholder'; - -/** - * Shown when there is an API error getting a product. - * - * @param {Object} props Incoming props for the component. - * @param {string} props.error - * @param {boolean} props.isLoading - * @param {function(any):any} props.getProduct - */ -const ApiError = ( { error, isLoading, getProduct } ) => ( - -); - -export default ApiError; diff --git a/assets/js/blocks/single-product/edit/editor-block-controls.js b/assets/js/blocks/single-product/edit/editor-block-controls.js deleted file mode 100644 index 0b27fde84ac..00000000000 --- a/assets/js/blocks/single-product/edit/editor-block-controls.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { BlockControls } from '@wordpress/block-editor'; -import { ToolbarGroup } from '@wordpress/components'; - -/** - * Adds controls to the editor toolbar. - * - * @param {Object} props Incoming props for the component. - * @param {boolean} props.isEditing - * @param {function(boolean):any} props.setIsEditing - */ -const EditorBlockControls = ( { isEditing, setIsEditing } ) => { - return ( - - setIsEditing( ! isEditing ), - isActive: isEditing, - }, - ] } - /> - - ); -}; - -export default EditorBlockControls; diff --git a/assets/js/blocks/single-product/edit/editor.scss b/assets/js/blocks/single-product/edit/editor.scss deleted file mode 100644 index fe122597870..00000000000 --- a/assets/js/blocks/single-product/edit/editor.scss +++ /dev/null @@ -1,18 +0,0 @@ -.wc-block-single-product__selection { - width: 100%; -} -.wc-block-single-product__reset-layout { - padding: 0; - - svg { - margin-right: 4px; - } -} -.wc-block-single-product__edit-card { - padding: 16px; - border-top: 1px solid $gray-200; - - .wc-block-single-product__edit-card-title { - margin: 0 0 $gap; - } -} diff --git a/assets/js/blocks/single-product/edit/index.tsx b/assets/js/blocks/single-product/edit/index.tsx deleted file mode 100644 index fc1f0dea6e3..00000000000 --- a/assets/js/blocks/single-product/edit/index.tsx +++ /dev/null @@ -1,144 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { useState } from '@wordpress/element'; -import { Placeholder, Button, PanelBody } from '@wordpress/components'; -import { withProduct } from '@woocommerce/block-hocs'; -import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; -import EditProductLink from '@woocommerce/editor-components/edit-product-link'; -import { singleProductBlockPreview } from '@woocommerce/resource-previews'; -import { InspectorControls } from '@wordpress/block-editor'; -import { ProductResponseItem } from '@woocommerce/types'; - -/** - * Internal dependencies - */ -import './editor.scss'; -import ApiError from './api-error'; -import SharedProductControl from './shared-product-control'; -import EditorBlockControls from './editor-block-controls'; -import LayoutEditor from './layout-editor'; -import { BLOCK_TITLE, BLOCK_ICON, BLOCK_DESCRIPTION } from '../constants'; - -interface EditorProps { - className: string; - attributes: { - productId: number; - isPreview: boolean; - }; - setAttributes: ( attributes: { - productId: number; - isPreview: boolean; - } ) => void; - error: string; - getProduct: () => void; - product: ProductResponseItem; - isLoading: boolean; - clientId: string; -} - -/** - * Component to handle edit mode of the "Single Product Block". - * - * @param {Object} props Incoming props for the component. - * @param {string} props.className - * @param {Object} props.attributes Incoming block attributes. - * @param {function(any):any} props.setAttributes Setter for block attributes. - * @param {string} props.error - * @param {function(any):any} props.getProduct - * @param {Object} props.product - * @param {boolean} props.isLoading - * @param {string} props.clientId - */ -const Editor = ( { - className, - attributes, - setAttributes, - error, - getProduct, - product, - isLoading, - clientId, -}: EditorProps ) => { - const { productId, isPreview } = attributes; - const [ isEditing, setIsEditing ] = useState( ! productId ); - - if ( isPreview ) { - return singleProductBlockPreview; - } - - if ( error ) { - return ( - - ); - } - - return ( -
- - - { isEditing ? ( - - { BLOCK_DESCRIPTION } -
- - -
-
- ) : ( - <> - - - - - - - - - ) } -
-
- ); -}; - -export default withProduct( Editor ); diff --git a/assets/js/blocks/single-product/edit/layout-editor.tsx b/assets/js/blocks/single-product/edit/layout-editor.tsx deleted file mode 100644 index b2e47c40394..00000000000 --- a/assets/js/blocks/single-product/edit/layout-editor.tsx +++ /dev/null @@ -1,92 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { useCallback } from '@wordpress/element'; -import { useDispatch } from '@wordpress/data'; -import { InnerBlocks, InspectorControls } from '@wordpress/block-editor'; -import { - InnerBlockLayoutContextProvider, - ProductDataContextProvider, -} from '@woocommerce/shared-context'; -import { createBlocksFromTemplate } from '@woocommerce/atomic-utils'; -import { PanelBody, Button } from '@wordpress/components'; -import { Icon, backup } from '@wordpress/icons'; -import { ProductResponseItem } from '@woocommerce/types'; - -/** - * Internal dependencies - */ -import { - BLOCK_NAME, - DEFAULT_INNER_BLOCKS, - ALLOWED_INNER_BLOCKS, -} from '../constants'; - -interface LayoutEditorProps { - isLoading: boolean; - product: ProductResponseItem; - clientId: string; -} - -const LayoutEditor = ( { - isLoading, - product, - clientId, -}: LayoutEditorProps ) => { - const baseClassName = 'wc-block-single-product wc-block-layout'; - const { replaceInnerBlocks } = useDispatch( 'core/block-editor' ); - - const resetInnerBlocks = useCallback( () => { - replaceInnerBlocks( - clientId, - createBlocksFromTemplate( DEFAULT_INNER_BLOCKS ), - false - ); - }, [ clientId, replaceInnerBlocks ] ); - - return ( - - - - - - - -
- -
-
-
- ); -}; - -export default LayoutEditor; diff --git a/assets/js/blocks/single-product/edit/shared-product-control.js b/assets/js/blocks/single-product/edit/shared-product-control.js deleted file mode 100644 index bc24e872c53..00000000000 --- a/assets/js/blocks/single-product/edit/shared-product-control.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * External dependencies - */ -import ProductControl from '@woocommerce/editor-components/product-control'; - -/** - * Allows a product to be selected for display. - * - * @param {Object} props Incoming props for the component. - * @param {Object} props.attributes Incoming block attributes. - * @param {function(any):any} props.setAttributes Setter for block attributes. - */ -const SharedProductControl = ( { attributes, setAttributes } ) => ( - { - const id = value[ 0 ] ? value[ 0 ].id : 0; - setAttributes( { - productId: id, - } ); - } } - /> -); - -export default SharedProductControl; diff --git a/assets/js/blocks/single-product/frontend.js b/assets/js/blocks/single-product/frontend.js deleted file mode 100644 index 0c471deb9bc..00000000000 --- a/assets/js/blocks/single-product/frontend.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * External dependencies - */ -import { getValidBlockAttributes } from '@woocommerce/base-utils'; -import { - getBlockMap, - renderParentBlock, - renderStandaloneBlocks, -} from '@woocommerce/atomic-utils'; - -/** - * Internal dependencies - */ -import Block from './block'; -import blockAttributes from './attributes'; -import { BLOCK_NAME } from './constants'; - -const getProps = ( el ) => { - return { - attributes: getValidBlockAttributes( blockAttributes, el.dataset ), - }; -}; - -renderParentBlock( { - Block, - blockName: BLOCK_NAME, - selector: '.wp-block-woocommerce-single-product', - getProps, - blockMap: getBlockMap( BLOCK_NAME ), -} ); - -renderStandaloneBlocks(); diff --git a/assets/js/blocks/single-product/index.js b/assets/js/blocks/single-product/index.js deleted file mode 100644 index bab3b450c0c..00000000000 --- a/assets/js/blocks/single-product/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * External dependencies - */ -import { __ } from '@wordpress/i18n'; -import { registerExperimentalBlockType } from '@woocommerce/block-settings'; - -/** - * Internal dependencies - */ -import edit from './edit'; -import save from './save'; -import attributes from './attributes'; -import { - BLOCK_NAME, - BLOCK_TITLE, - BLOCK_ICON, - BLOCK_DESCRIPTION, -} from './constants'; - -const settings = { - title: BLOCK_TITLE, - icon: { - src: BLOCK_ICON, - }, - category: 'woocommerce', - keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ], - description: BLOCK_DESCRIPTION, - supports: { - align: [ 'wide', 'full' ], - html: false, - }, - attributes, - edit, - save, -}; - -registerExperimentalBlockType( BLOCK_NAME, settings ); diff --git a/assets/js/blocks/single-product/save.js b/assets/js/blocks/single-product/save.js deleted file mode 100644 index 86d54a8e731..00000000000 --- a/assets/js/blocks/single-product/save.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * External dependencies - */ -import { InnerBlocks } from '@wordpress/block-editor'; -import classnames from 'classnames'; - -const Save = ( { attributes } ) => { - return ( -
- -
- ); -}; - -export default Save; diff --git a/assets/js/previews/index.js b/assets/js/previews/index.js index c64cd463cd8..776b0f9a7cf 100644 --- a/assets/js/previews/index.js +++ b/assets/js/previews/index.js @@ -6,4 +6,3 @@ export { previewShippingRates } from './shipping-rates'; export { previewSavedPaymentMethods } from './saved-payment-methods'; export { gridBlockPreview } from './grid-block'; -export { singleProductBlockPreview } from './single-product-block'; diff --git a/assets/js/previews/single-product-block.js b/assets/js/previews/single-product-block.js deleted file mode 100644 index e7e86e1d035..00000000000 --- a/assets/js/previews/single-product-block.js +++ /dev/null @@ -1,11 +0,0 @@ -export const singleProductBlockPreview = ( - - - -); diff --git a/bin/webpack-entries.js b/bin/webpack-entries.js index 3b03f77d997..4f1900fcbcd 100644 --- a/bin/webpack-entries.js +++ b/bin/webpack-entries.js @@ -64,9 +64,6 @@ const blocks = { 'reviews-by-product': { customDir: 'reviews/reviews-by-product', }, - 'single-product': { - isExperimental: true, - }, 'stock-filter': {}, }; diff --git a/src/BlockTypes/ProductCategoryList.php b/src/BlockTypes/ProductCategoryList.php deleted file mode 100644 index cd0f10b3d5f..00000000000 --- a/src/BlockTypes/ProductCategoryList.php +++ /dev/null @@ -1,59 +0,0 @@ - - array( - 'text' => true, - 'link' => true, - 'background' => false, - '__experimentalSkipSerialization' => true, - ), - 'typography' => - array( - 'fontSize' => true, - '__experimentalFontStyle' => true, - '__experimentalFontWeight' => true, - '__experimentalSkipSerialization' => true, - ), - '__experimentalSelector' => '.wc-block-components-product-category-list', - ); - } - - /** - * Register script and style assets for the block type before it is registered. - * - * This registers the scripts; it does not enqueue them. - */ - protected function register_block_type_assets() { - parent::register_block_type_assets(); - $this->register_chunk_translations( [ $this->block_name ] ); - } -} diff --git a/src/BlockTypes/ProductSummary.php b/src/BlockTypes/ProductSummary.php index 0b8824ebda3..85e5c6994d8 100644 --- a/src/BlockTypes/ProductSummary.php +++ b/src/BlockTypes/ProductSummary.php @@ -49,7 +49,6 @@ protected function get_block_type_supports() { * This registers the scripts; it does not enqueue them. */ protected function register_block_type_assets() { - parent::register_block_type_assets(); $this->register_chunk_translations( [ $this->block_name ] ); } } diff --git a/src/BlockTypes/ProductTagList.php b/src/BlockTypes/ProductTagList.php deleted file mode 100644 index 796f65243fa..00000000000 --- a/src/BlockTypes/ProductTagList.php +++ /dev/null @@ -1,55 +0,0 @@ - - array( - 'text' => true, - 'background' => false, - 'link' => true, - ), - 'typography' => - array( - 'fontSize' => true, - ), - '__experimentalSelector' => '.wc-block-components-product-tag-list', - ); - } - - /** - * Register script and style assets for the block type before it is registered. - * - * This registers the scripts; it does not enqueue them. - */ - protected function register_block_type_assets() { - parent::register_block_type_assets(); - $this->register_chunk_translations( [ $this->block_name ] ); - } -} diff --git a/src/BlockTypes/SingleProduct.php b/src/BlockTypes/SingleProduct.php deleted file mode 100644 index 0c4e5f4b243..00000000000 --- a/src/BlockTypes/SingleProduct.php +++ /dev/null @@ -1,50 +0,0 @@ -hydrate_from_api( $product_id ); - } - - /** - * 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; - } - - /** - * Hydrate the Single Product block with data from the API. - * - * @param int $product_id ID of the product. - */ - protected function hydrate_from_api( int $product_id ) { - $this->asset_data_registry->hydrate_api_request( "/wc/store/v1/products/$product_id" ); - $this->asset_data_registry->hydrate_api_request( '/wc/store/v1/cart' ); - } -} diff --git a/src/BlockTypesController.php b/src/BlockTypesController.php index d5640646c3e..d8bbd03eece 100644 --- a/src/BlockTypesController.php +++ b/src/BlockTypesController.php @@ -190,7 +190,6 @@ protected function get_block_types() { 'ProductButton', 'ProductCategories', 'ProductCategory', - 'ProductCategoryList', 'ProductImage', 'ProductImageGallery', 'ProductNew', @@ -205,7 +204,6 @@ protected function get_block_types() { 'ProductStockIndicator', 'ProductSummary', 'ProductTag', - 'ProductTagList', 'ProductTitle', 'ProductTopRated', 'ProductsByAttribute', @@ -224,10 +222,6 @@ protected function get_block_types() { MiniCartContents::get_mini_cart_block_types() ); - if ( Package::feature()->is_experimental_build() ) { - $block_types[] = 'SingleProduct'; - } - /** * This disables specific blocks in Widget Areas by not registering them. */ diff --git a/tests/e2e/specs/backend/__fixtures__/single-product.fixture.json b/tests/e2e/specs/backend/__fixtures__/single-product.fixture.json deleted file mode 100644 index 115fcb1a87a..00000000000 --- a/tests/e2e/specs/backend/__fixtures__/single-product.fixture.json +++ /dev/null @@ -1 +0,0 @@ -{"title":"Single Product Block","pageContent":"\n
\n"} \ No newline at end of file diff --git a/tests/e2e/specs/backend/single-product.test.js b/tests/e2e/specs/backend/single-product.test.js deleted file mode 100644 index d4b85837b68..00000000000 --- a/tests/e2e/specs/backend/single-product.test.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * External dependencies - */ -import { getAllBlocks, switchUserToAdmin } from '@wordpress/e2e-test-utils'; -import { visitBlockPage } from '@woocommerce/blocks-test-utils'; - -/** - * Internal dependencies - */ -import { insertBlockDontWaitForInsertClose } from '../../utils.js'; - -if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 3 ) - // eslint-disable-next-line jest/no-focused-tests, jest/expect-expect - test.only( 'skipping all other things', () => {} ); - -const block = { - name: 'Single Product', - slug: 'woocommerce/single-product', - class: '.wc-block-single-product', -}; - -describe( `${ block.name } Block`, () => { - beforeAll( async () => { - await switchUserToAdmin(); - await visitBlockPage( `${ block.name } Block` ); - } ); - - it( 'can be inserted more than once', async () => { - await insertBlockDontWaitForInsertClose( block.name ); - expect( await getAllBlocks() ).toHaveLength( 2 ); - } ); - - it( 'renders without crashing', async () => { - await expect( page ).toRenderBlock( block ); - } ); -} ); From f8e504d710ef9cc6fa390cbb6e6a61f297f9ecfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Mon, 20 Mar 2023 18:07:15 +0100 Subject: [PATCH 08/10] Update release version at the beginning of the release process (#8788) * Update release version at the beginning of the release process * Add back code that updated versions on deploy --- .github/patch-initial-checklist.md | 4 +- .github/release-initial-checklist.md | 11 ++--- bin/change-versions.sh | 69 ++++++++++++++++++++++++++++ bin/github-deploy.sh | 4 +- bin/version-changes.sh | 22 --------- composer.json | 1 + package.json | 1 + 7 files changed, 78 insertions(+), 34 deletions(-) create mode 100755 bin/change-versions.sh delete mode 100755 bin/version-changes.sh diff --git a/.github/patch-initial-checklist.md b/.github/patch-initial-checklist.md index 80750b76623..7a4ef93e4a7 100644 --- a/.github/patch-initial-checklist.md +++ b/.github/patch-initial-checklist.md @@ -11,7 +11,8 @@ The release pull request has been created! This checklist is a guide to follow f - [ ] Ensure you pull your changes from the remote, since GitHub Actions will have added new commits to the branch. - [ ] Check the version and date in the changelog section within `readme.txt`, e.g. `= {{version}} - YYYY-MM-DD =` - [ ] Check the changelog matches the one in the pull request description above. -- [ ] Update compatibility sections (if applicable). **Note:** Do not change the stable tag or plugin version; this is automated. +- [ ] Run `npm run change-versions` to update the version numbers in several files. Write the version number you are releasing: {{version}}. +- [ ] Update compatibility sections (if applicable). - [ ] Push above changes to the release branch. ## Create the Testing Notes @@ -46,7 +47,6 @@ Each porter is responsible for testing the PRs that fall under the focus of thei - [ ] Go through the description of the release pull request and edit it to update all the sections and checklist instructions there. - [ ] Execute `npm run deploy` - - Note: the script automatically updates version numbers (commits on your behalf). - **ALERT**: This script will ask you if this release will be deployed to WordPress.org. You should only answer yes for this release **if it's the latest release and you want to deploy to WordPress.org**. Otherwise, answer no. If you answer yes, you will get asked additional verification by the `npm run deploy` script about deploying a patch release to WordPress.org. ## If this release is deployed to WordPress.org diff --git a/.github/release-initial-checklist.md b/.github/release-initial-checklist.md index 5dc5964bd49..d33ab450e1e 100644 --- a/.github/release-initial-checklist.md +++ b/.github/release-initial-checklist.md @@ -12,7 +12,8 @@ The release pull request has been created! This checklist is a guide to follow f - [ ] Ensure you pull your changes from the remote, since GitHub Actions will have added new commits to the branch. - [ ] Check the version and date in the changelog section within `readme.txt`, e.g. `= {{version}} - YYYY-MM-DD =` - [ ] Check the changelog matches the one in the pull request description above. -- [ ] Update compatibility sections (if applicable). **Note:** Do not change the stable tag or plugin version; this is automated. +- [ ] Run `npm run change-versions` to update the version numbers in several files. Write the version number you are releasing: {{version}}. +- [ ] Update compatibility sections (if applicable). - [ ] Update _Requires at least_, _Tested up to_, and _Requires PHP_ sections at the top of `readme.txt`. Note, this should also be the latest WordPress version available at time of release. - [ ] Update _Requires at least_, _Requires PHP_, _WC requires at least_, and _WC tested up to_ at the top of `woocommerce-gutenberg-products-block.php`. Note, this should include requiring the latest WP version at the time of release. For _WC requires at least_, use L1 (we publicly communicate L0 but technically support L1 to provide some space for folks to update). So this means if the current version of WooCommerce core is 5.8.0, then you'll want to put 5.7.0 here. - [ ] If necessary, update the value of `$minimum_wp_version` at the top of the `woocommerce-gutenberg-products-block.php` file to the latest available version of WordPress. @@ -64,7 +65,6 @@ Each porter is responsible for testing the PRs that fall under the focus of thei - [ ] Execute `npm run deploy` - The script will ask you to enter the version number to tag. Please enter the version we're releasing right now. Do not publish any dev tags as a release. - - Note: the script automatically updates version numbers on Github (commits on your behalf). - **ALERT**: This script will ask you if this release will be deployed to WordPress.org. You should answer yes for this release even if it is a pre-release. - A GitHub release will automatically be created and this will trigger a workflow that automatically deploys the plugin to WordPress.org. @@ -83,12 +83,7 @@ Each porter is responsible for testing the PRs that fall under the focus of thei ## After Workflow completes - [ ] Merge this pull request back into `trunk`. This may have merge conflicts needing resolved if there are any cherry-picked commits in the release branch. -- [ ] Update version on the `trunk` branch to be for the next version of the plugin and include the `dev` suffix (e.g. something like [`2.6-dev`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/commit/e27f053e7be0bf7c1d376f5bdb9d9999190ce158)) for the next version. Be sure to update the version number in the following files: - - [ ] `package-lock.json` - - [ ] `package.json` - - [ ] `readme.txt` - - [ ] `src/Package.php` - - [ ] `woocommerce-gutenberg-products-block.php`. +- [ ] Run `npm run change-versions` to update the version in `trunk` to the next version of the plugin and include the `dev` suffix. For example, if you released 2.5.0, you should update the version in `trunk` to 2.6.0-dev. - [ ] Update the schedules p2 with the shipped date for the release (PdToLP-K-p2). - [ ] Edit the GitHub milestone of the release you just shipped and add the current date as the due date (this is used to track ship date as well). diff --git a/bin/change-versions.sh b/bin/change-versions.sh new file mode 100755 index 00000000000..ef2424221c5 --- /dev/null +++ b/bin/change-versions.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Functions +# Check if string contains substring +is_substring() { + case "$2" in + *$1*) + return 0 + ;; + *) + return 1 + ;; + esac +} + +# Output colorized strings +# +# Color codes: +# 0 - black +# 1 - red +# 2 - green +# 3 - yellow +# 4 - blue +# 5 - magenta +# 6 - cian +# 7 - white +output() { + echo "$(tput setaf "$1")$2$(tput sgr0)" +} + +if [ ! $VERSION ]; then + output 3 "Please enter the version number, for example, 1.0.0:" + read -r VERSION +fi + +output 2 "Updating version numbers in files..." + +IS_PRE_RELEASE=false +# Check if is a pre-release. +if is_substring "-" "${VERSION}"; then + IS_PRE_RELEASE=true + output 4 "Detected pre-release version." +fi + +if [ $IS_PRE_RELEASE = false ]; then + # Replace all instances of $VID:$ with the release version but only if not pre-release. + find ./src woocommerce-gutenberg-products-block.php -name "*.php" -print0 | xargs -0 perl -i -pe 's/\$VID:\$/'${VERSION}'/g' + # Update version number in readme.txt but only if not pre-release. + perl -i -pe 's/Stable tag:*.+/Stable tag: '${VERSION}'/' readme.txt + output 2 "Version numbers updated in readme.txt and \$VID:\$ instances." +else + output 4 "Note: pre-releases will not have the readme.txt stable tag updated." +fi + +# Update version in main plugin file. +perl -i -pe 's/Version:*.+/Version: '${VERSION}'/' woocommerce-gutenberg-products-block.php + +# Update version in package.json. +perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' package.json + +# Update version in package-lock.json. +perl -i -0777 -pe 's/"name": "\@woocommerce\/block-library",\s*\K"version":*.+\n/"version": "'${VERSION}'",\n/g' package-lock.json + +# Update version in src/Package.php. +perl -i -pe "s/version \= '*.+';/version = '${VERSION}';/" src/Package.php + +# Update version in composer.json. +perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' composer.json + +output 2 "Version numbers updated in main plugin file, package.json, package-lock.json, src/Package.php and composer.json." diff --git a/bin/github-deploy.sh b/bin/github-deploy.sh index ff78abb94ae..8872aa697dc 100755 --- a/bin/github-deploy.sh +++ b/bin/github-deploy.sh @@ -151,9 +151,9 @@ if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then exit 1 fi -# Version changes +# Update versions in files in case they were not updated. output 2 "Updating version numbers in files and regenerating php autoload classmap (note pre-releases will not have the readme.txt stable tag updated)..." -run_command "source '$RELEASER_PATH/bin/version-changes.sh'" true +run_command "source '$RELEASER_PATH/bin/change-versions.sh'" true composer dump-autoload diff --git a/bin/version-changes.sh b/bin/version-changes.sh deleted file mode 100755 index 67e8694414d..00000000000 --- a/bin/version-changes.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -VERSION=${VERSION:=\$VID\:\$} -IS_PRE_RELEASE=${IS_PRE_RELEASE:=false} - -# replace all instances of $VID:$ with the release version but only when not pre-release. -if [ $IS_PRE_RELEASE = false ]; then - find ./src woocommerce-gutenberg-products-block.php -name "*.php" -print0 | xargs -0 perl -i -pe 's/\$VID:\$/'${VERSION}'/g' - # Update version number in readme.txt but only if not pre-release - perl -i -pe 's/Stable tag:*.+/Stable tag: '${VERSION}'/' readme.txt -fi - -# Update version in main plugin file -perl -i -pe 's/Version:*.+/Version: '${VERSION}'/' woocommerce-gutenberg-products-block.php - -# Update version in package.json -perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' package.json - -# Update version in src/Package.php -perl -i -pe "s/version \= '*.+';/version = '${VERSION}';/" src/Package.php - -# Add version to composer.json -perl -i -pe 's/"type":*.+/"type":"wordpress-plugin",\n\t"version": "'${VERSION}'",/' composer.json diff --git a/composer.json b/composer.json index e23ae09788c..0a13a9a28cc 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "description": "WooCommerce blocks for the Gutenberg editor.", "homepage": "https://woocommerce.com/", "type": "wordpress-plugin", + "version": "9.9.0-dev", "keywords": [ "gutenberg", "woocommerce", diff --git a/package.json b/package.json index ec4291a63b1..e244b157d5f 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "postbuild:docs": "./bin/add-doc-footer.sh", "changelog": "node ./bin/changelog", "changelog:zenhub": "node ./bin/changelog --changelogSrcType='ZENHUB_RELEASE'", + "change-versions": "source ./bin/change-versions.sh", "deploy": "npm run build:deploy && sh ./bin/github-deploy.sh", "dev": "rimraf build/* && cross-env BABEL_ENV=default webpack", "labels:dry": "github-label-sync --labels ./.github/label-sync-config.json --allow-added-labels --dry-run woocommerce/woocommerce-gutenberg-products-block", From a868dffa7fc6d3b2c83cd0685a2e19471c41651c Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 21 Mar 2023 10:14:29 +0000 Subject: [PATCH 09/10] Add woocommerce_cart_item_permalink filter to cart endpoint (#8726) --- src/StoreApi/Schemas/V1/CartItemSchema.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/StoreApi/Schemas/V1/CartItemSchema.php b/src/StoreApi/Schemas/V1/CartItemSchema.php index 634210c506a..7d181a3db03 100644 --- a/src/StoreApi/Schemas/V1/CartItemSchema.php +++ b/src/StoreApi/Schemas/V1/CartItemSchema.php @@ -335,6 +335,20 @@ public function get_properties() { public function get_item_response( $cart_item ) { $product = $cart_item['data']; + /** + * Filter the product permalink. + * + * This is a hook taken from the legacy cart/mini-cart templates that allows the permalink to be changed for a + * product. This is specific to the cart endpoint. + * + * @since 9.9.0 + * + * @param string $product_permalink Product permalink. + * @param array $cart_item Cart item array. + * @param string $cart_item_key Cart item key. + */ + $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $product->get_permalink(), $cart_item, $cart_item['key'] ); + return [ 'key' => $cart_item['key'], 'id' => $product->get_id(), @@ -348,7 +362,7 @@ public function get_item_response( $cart_item ) { 'backorders_allowed' => (bool) $product->backorders_allowed(), 'show_backorder_badge' => (bool) $product->backorders_require_notification() && $product->is_on_backorder( $cart_item['quantity'] ), 'sold_individually' => $product->is_sold_individually(), - 'permalink' => $product->get_permalink(), + 'permalink' => $product_permalink, 'images' => $this->get_images( $product ), 'variation' => $this->format_variation_data( $cart_item['variation'], $product ), 'item_data' => $this->get_item_data( $cart_item ), From 091da31c5a2d26f35377ea84d3f50d8325b7efb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Tue, 21 Mar 2023 11:31:20 +0100 Subject: [PATCH 10/10] Fix Customer Account block doing a 404 request in the frontend (#8798) --- src/BlockTypes/AbstractBlock.php | 2 +- src/BlockTypes/CustomerAccount.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/BlockTypes/AbstractBlock.php b/src/BlockTypes/AbstractBlock.php index fe5b963cfd2..75ff4f0e6d8 100644 --- a/src/BlockTypes/AbstractBlock.php +++ b/src/BlockTypes/AbstractBlock.php @@ -286,7 +286,7 @@ protected function get_block_type_editor_style() { * * @see $this->register_block_type() * @param string $key Data to get, or default to everything. - * @return array|string + * @return array|string|null */ protected function get_block_type_script( $key = null ) { $script = [ diff --git a/src/BlockTypes/CustomerAccount.php b/src/BlockTypes/CustomerAccount.php index 8da7dba330b..308eb855dc4 100644 --- a/src/BlockTypes/CustomerAccount.php +++ b/src/BlockTypes/CustomerAccount.php @@ -95,7 +95,7 @@ private function render_icon( $attributes ) { * * @param array $attributes Block attributes. * - * @return string Label to render on the block + * @return string Label to render on the block. */ private function render_label( $attributes ) { if ( self::ICON_ONLY === $attributes['displayStyle'] ) { @@ -106,4 +106,15 @@ private function render_label( $attributes ) { ? __( 'My Account', 'woo-gutenberg-products-block' ) : __( 'Login', 'woo-gutenberg-products-block' ); } + + /** + * Get the frontend script handle for this block type. + * + * @param string $key Data to get, or default to everything. + * + * @return null This block has no frontend script. + */ + protected function get_block_type_script( $key = null ) { + return null; + } }