diff --git a/assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx b/assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx index a224d53069c..f18826c114e 100644 --- a/assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx +++ b/assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx @@ -12,7 +12,7 @@ import { CartCheckoutSidebarCompatibilityNotice } from '@woocommerce/editor-comp import { NoPaymentMethodsNotice } from '@woocommerce/editor-components/no-payment-methods-notice'; import { PAYMENT_STORE_KEY } from '@woocommerce/block-data'; import { DefaultNotice } from '@woocommerce/editor-components/default-notice'; -import { IncompatiblePaymentGatewaysNotice } from '@woocommerce/editor-components/incompatible-payment-gateways-notice'; +import { IncompatibleExtensionsNotice } from '@woocommerce/editor-components/incompatible-extension-notice'; import { useSelect } from '@wordpress/data'; import { CartCheckoutFeedbackPrompt } from '@woocommerce/editor-components/feedback-prompt'; import { useState } from '@wordpress/element'; @@ -38,14 +38,14 @@ const withSidebarNotices = createHigherOrderComponent( } = props; const [ - isIncompatiblePaymentGatewaysNoticeDismissed, - setIsIncompatiblePaymentGatewaysNoticeDismissed, + isIncompatibleExtensionsNoticeDismissed, + setIsIncompatibleExtensionsNoticeDismissed, ] = useState( true ); - const toggleIncompatiblePaymentGatewaysNoticeDismissedStatus = ( + const toggleIncompatibleExtensionsNoticeDismissedStatus = ( isDismissed: boolean ) => { - setIsIncompatiblePaymentGatewaysNoticeDismissed( isDismissed ); + setIsIncompatibleExtensionsNoticeDismissed( isDismissed ); }; const { isCart, isCheckout, isPaymentMethodsBlock, hasPaymentMethods } = @@ -91,9 +91,9 @@ const withSidebarNotices = createHigherOrderComponent( return ( <> - - { isIncompatiblePaymentGatewaysNoticeDismissed ? ( + { isIncompatibleExtensionsNoticeDismissed ? ( diff --git a/assets/js/data/index.ts b/assets/js/data/index.ts index 4cd685a5c09..57683bde56d 100644 --- a/assets/js/data/index.ts +++ b/assets/js/data/index.ts @@ -6,13 +6,13 @@ import '@wordpress/notices'; /** * Internal dependencies */ -export { SCHEMA_STORE_KEY } from './schema'; -export { COLLECTIONS_STORE_KEY } from './collections'; export { CART_STORE_KEY } from './cart'; export { CHECKOUT_STORE_KEY } from './checkout'; +export { COLLECTIONS_STORE_KEY } from './collections'; export { PAYMENT_STORE_KEY } from './payment'; -export { VALIDATION_STORE_KEY } from './validation'; export { QUERY_STATE_STORE_KEY } from './query-state'; +export { SCHEMA_STORE_KEY } from './schema'; export { STORE_NOTICES_STORE_KEY } from './store-notices'; +export { VALIDATION_STORE_KEY } from './validation'; export * from './constants'; export * from './utils'; diff --git a/assets/js/editor-components/incompatible-payment-gateways-notice/editor.scss b/assets/js/editor-components/incompatible-extension-notice/editor.scss similarity index 100% rename from assets/js/editor-components/incompatible-payment-gateways-notice/editor.scss rename to assets/js/editor-components/incompatible-extension-notice/editor.scss diff --git a/assets/js/editor-components/incompatible-extension-notice/index.tsx b/assets/js/editor-components/incompatible-extension-notice/index.tsx new file mode 100644 index 00000000000..bddec61bd86 --- /dev/null +++ b/assets/js/editor-components/incompatible-extension-notice/index.tsx @@ -0,0 +1,106 @@ +/** + * External dependencies + */ +import { __, sprintf } from '@wordpress/i18n'; +import { Notice, ExternalLink } from '@wordpress/components'; +import { createInterpolateElement, useEffect } from '@wordpress/element'; +import { Alert } from '@woocommerce/icons'; +import { Icon } from '@wordpress/icons'; +/** + * Internal dependencies + */ +import { useCombinedIncompatibilityNotice } from './use-combined-incompatibility-notice'; +import './editor.scss'; + +interface ExtensionNoticeProps { + toggleDismissedStatus: ( status: boolean ) => void; + block: 'woocommerce/cart' | 'woocommerce/checkout'; +} + +export function IncompatibleExtensionsNotice( { + toggleDismissedStatus, + block, +}: ExtensionNoticeProps ) { + const [ + isVisible, + dismissNotice, + incompatiblePaymentMethods, + numberOfIncompatiblePaymentMethods, + ] = useCombinedIncompatibilityNotice( block ); + + useEffect( () => { + toggleDismissedStatus( ! isVisible ); + }, [ isVisible, toggleDismissedStatus ] ); + + if ( ! isVisible ) { + return null; + } + + // console.log( incompatiblePaymentMethods ); + + const noticeContent = ( + <> + { numberOfIncompatiblePaymentMethods > 1 + ? createInterpolateElement( + __( + 'The following extensions may be incompatible with the block-based checkout. Learn more', + 'woo-gutenberg-products-block' + ), + { + a: ( + + ), + } + ) + : createInterpolateElement( + sprintf( + // translators: %s is the name of the extension that is incompatible with the block-based checkout. + __( + '%s may be incompatible with the block-based checkout. Learn more', + 'woo-gutenberg-products-block' + ), + Object.values( incompatiblePaymentMethods )[ 0 ] + ), + { + strong: , + a: ( + + ), + } + ) } + + ); + + return ( + +
+ } + /> +
+

{ noticeContent }

+ { numberOfIncompatiblePaymentMethods > 1 && ( +
    + { Object.entries( incompatiblePaymentMethods ).map( + ( [ id, title ] ) => ( +
  • + { title } +
  • + ) + ) } +
+ ) } +
+
+
+ ); +} diff --git a/assets/js/editor-components/incompatible-payment-gateways-notice/use-incompatible-payment-gateways-notice.ts b/assets/js/editor-components/incompatible-extension-notice/use-combined-incompatibility-notice.ts similarity index 54% rename from assets/js/editor-components/incompatible-payment-gateways-notice/use-incompatible-payment-gateways-notice.ts rename to assets/js/editor-components/incompatible-extension-notice/use-combined-incompatibility-notice.ts index 71ac1bc456f..418838c5ab7 100644 --- a/assets/js/editor-components/incompatible-payment-gateways-notice/use-incompatible-payment-gateways-notice.ts +++ b/assets/js/editor-components/incompatible-extension-notice/use-combined-incompatibility-notice.ts @@ -1,18 +1,18 @@ /** * External dependencies */ -import { useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { useState, useEffect } from '@wordpress/element'; import { useLocalStorageState } from '@woocommerce/base-hooks'; /** * Internal dependencies */ -import { STORE_KEY as PAYMENT_STORE_KEY } from '../../data/payment/constants'; +import { useIncompatiblePaymentGatewaysNotice } from './use-incompatible-payment-gateways-notice'; +import { useIncompatibleExtensionNotice } from './use-incompatible-extensions-notice'; -type StoredIncompatibleGateway = { [ k: string ]: string[] }; +type StoredIncompatibleExtension = { [ k: string ]: string[] }; const initialDismissedNotices: React.SetStateAction< - StoredIncompatibleGateway[] + StoredIncompatibleExtension[] > = []; const areEqual = ( array1: string[], array2: string[] ) => { @@ -25,44 +25,68 @@ const areEqual = ( array1: string[], array2: string[] ) => { return uniqueCollectionValues.size === array1.length; }; -export const useIncompatiblePaymentGatewaysNotice = ( +const sortAlphabetically = ( obj: { + [ key: string ]: string; +} ): { [ key: string ]: string } => + Object.fromEntries( + Object.entries( obj ).sort( ( [ , a ], [ , b ] ) => + a.localeCompare( b ) + ) + ); + +export const useCombinedIncompatibilityNotice = ( blockName: string ): [ boolean, () => void, { [ k: string ]: string }, number ] => { + const [ + incompatibleExtensions, + incompatibleExtensionSlugs, + incompatibleExtensionCount, + ] = useIncompatibleExtensionNotice(); + + const [ + incompatiblePaymentMethods, + incompatiblePaymentMethodSlugs, + incompatiblePaymentMethodCount, + ] = useIncompatiblePaymentGatewaysNotice(); + + const allIncompatibleItems = { + ...incompatibleExtensions, + ...incompatiblePaymentMethods, + }; + + const allIncompatibleItemSlugs = [ + ...incompatibleExtensionSlugs, + ...incompatiblePaymentMethodSlugs, + ]; + + const allIncompatibleItemCount = + incompatibleExtensionCount + incompatiblePaymentMethodCount; + const [ dismissedNotices, setDismissedNotices ] = useLocalStorageState< - StoredIncompatibleGateway[] + StoredIncompatibleExtension[] >( - `wc-blocks_dismissed_incompatible_payment_gateways_notices`, + `wc-blocks_dismissed_incompatible_extensions_notices`, initialDismissedNotices ); - const [ isVisible, setIsVisible ] = useState( false ); - const { incompatiblePaymentMethods } = useSelect( ( select ) => { - const { getIncompatiblePaymentMethods } = select( PAYMENT_STORE_KEY ); - return { - incompatiblePaymentMethods: getIncompatiblePaymentMethods(), - }; - }, [] ); - const incompatiblePaymentMethodsIDs = Object.keys( - incompatiblePaymentMethods - ); - const numberOfIncompatiblePaymentMethods = - incompatiblePaymentMethodsIDs.length; + const [ isVisible, setIsVisible ] = useState( false ); const isDismissedNoticeUpToDate = dismissedNotices.some( ( notice ) => Object.keys( notice ).includes( blockName ) && areEqual( notice[ blockName as keyof object ], - incompatiblePaymentMethodsIDs + allIncompatibleItemSlugs ) ); const shouldBeDismissed = - numberOfIncompatiblePaymentMethods === 0 || isDismissedNoticeUpToDate; + allIncompatibleItemCount === 0 || isDismissedNoticeUpToDate; + const dismissNotice = () => { const dismissedNoticesSet = new Set( dismissedNotices ); dismissedNoticesSet.add( { - [ blockName ]: incompatiblePaymentMethodsIDs, + [ blockName ]: allIncompatibleItemSlugs, } ); setDismissedNotices( [ ...dismissedNoticesSet ] ); }; @@ -75,7 +99,7 @@ export const useIncompatiblePaymentGatewaysNotice = ( if ( ! shouldBeDismissed && ! isDismissedNoticeUpToDate ) { setDismissedNotices( ( previousDismissedNotices ) => previousDismissedNotices.reduce( - ( acc: StoredIncompatibleGateway[], curr ) => { + ( acc: StoredIncompatibleExtension[], curr ) => { if ( Object.keys( curr ).includes( blockName ) ) { return acc; } @@ -97,7 +121,7 @@ export const useIncompatiblePaymentGatewaysNotice = ( return [ isVisible, dismissNotice, - incompatiblePaymentMethods, - numberOfIncompatiblePaymentMethods, + sortAlphabetically( allIncompatibleItems ), + allIncompatibleItemCount, ]; }; diff --git a/assets/js/editor-components/incompatible-extension-notice/use-incompatible-extensions-notice.ts b/assets/js/editor-components/incompatible-extension-notice/use-incompatible-extensions-notice.ts new file mode 100644 index 00000000000..700fa6f3c98 --- /dev/null +++ b/assets/js/editor-components/incompatible-extension-notice/use-incompatible-extensions-notice.ts @@ -0,0 +1,34 @@ +/** + * External dependencies + */ +import { getSetting } from '@woocommerce/settings'; + +export const useIncompatibleExtensionNotice = (): [ + { [ k: string ]: string } | null, + string[], + number +] => { + interface GlobalIncompatibleExtensions { + id: string; + title: string; + } + + const incompatibleExtensions: Record< string, string > = {}; + + if ( getSetting( 'incompatibleExtensions' ) ) { + getSetting< GlobalIncompatibleExtensions[] >( + 'incompatibleExtensions' + ).forEach( ( extension ) => { + incompatibleExtensions[ extension.id ] = extension.title; + } ); + } + + const incompatibleExtensionSlugs = Object.keys( incompatibleExtensions ); + const incompatibleExtensionCount = incompatibleExtensionSlugs.length; + + return [ + incompatibleExtensions, + incompatibleExtensionSlugs, + incompatibleExtensionCount, + ]; +}; diff --git a/assets/js/editor-components/incompatible-extension-notice/use-incompatible-payment-gateways-notice.ts b/assets/js/editor-components/incompatible-extension-notice/use-incompatible-payment-gateways-notice.ts new file mode 100644 index 00000000000..c89b93ce1df --- /dev/null +++ b/assets/js/editor-components/incompatible-extension-notice/use-incompatible-payment-gateways-notice.ts @@ -0,0 +1,35 @@ +/** + * External dependencies + */ +import { useSelect } from '@wordpress/data'; + +/** + * Internal dependencies + */ +import { STORE_KEY as PAYMENT_STORE_KEY } from '../../data/payment/constants'; + +export const useIncompatiblePaymentGatewaysNotice = (): [ + { [ k: string ]: string }, + string[], + number +] => { + const { incompatiblePaymentMethods } = useSelect( ( select ) => { + const { getIncompatiblePaymentMethods } = select( PAYMENT_STORE_KEY ); + return { + incompatiblePaymentMethods: getIncompatiblePaymentMethods(), + }; + }, [] ); + + const incompatiblePaymentMethodSlugs = Object.keys( + incompatiblePaymentMethods + ); + + const incompatiblePaymentMethodCount = + incompatiblePaymentMethodSlugs.length; + + return [ + incompatiblePaymentMethods, + incompatiblePaymentMethodSlugs, + incompatiblePaymentMethodCount, + ]; +}; diff --git a/assets/js/editor-components/incompatible-payment-gateways-notice/index.tsx b/assets/js/editor-components/incompatible-payment-gateways-notice/index.tsx deleted file mode 100644 index 103352aa272..00000000000 --- a/assets/js/editor-components/incompatible-payment-gateways-notice/index.tsx +++ /dev/null @@ -1,85 +0,0 @@ -/** - * External dependencies - */ -import { _n } from '@wordpress/i18n'; -import { Notice, ExternalLink } from '@wordpress/components'; -import { createInterpolateElement, useEffect } from '@wordpress/element'; -import { Alert } from '@woocommerce/icons'; -import { Icon } from '@wordpress/icons'; -/** - * Internal dependencies - */ -import { useIncompatiblePaymentGatewaysNotice } from './use-incompatible-payment-gateways-notice'; -import './editor.scss'; - -interface PaymentGatewaysNoticeProps { - toggleDismissedStatus: ( status: boolean ) => void; - block: 'woocommerce/cart' | 'woocommerce/checkout'; -} - -export function IncompatiblePaymentGatewaysNotice( { - toggleDismissedStatus, - block, -}: PaymentGatewaysNoticeProps ) { - const [ - isVisible, - dismissNotice, - incompatiblePaymentMethods, - numberOfIncompatiblePaymentMethods, - ] = useIncompatiblePaymentGatewaysNotice( block ); - - useEffect( () => { - toggleDismissedStatus( ! isVisible ); - }, [ isVisible, toggleDismissedStatus ] ); - - if ( ! isVisible ) { - return null; - } - - const noticeContent = createInterpolateElement( - _n( - 'The following extension is incompatible with the block-based checkout. Learn more', - 'The following extensions are incompatible with the block-based checkout. Learn more', - numberOfIncompatiblePaymentMethods, - 'woo-gutenberg-products-block' - ), - { - a: ( - // Suppress the warning as this will be interpolated into the string with content. - // eslint-disable-next-line jsx-a11y/anchor-has-content - - ), - } - ); - - return ( - -
- } - /> -
-

{ noticeContent }

-
    - { Object.entries( incompatiblePaymentMethods ).map( - ( [ id, title ] ) => ( -
  • - { title } -
  • - ) - ) } -
-
-
-
- ); -} diff --git a/composer.lock b/composer.lock index ad99643fc7f..b695909307b 100644 --- a/composer.lock +++ b/composer.lock @@ -8,20 +8,20 @@ "packages": [ { "name": "automattic/jetpack-a8c-mc-stats", - "version": "v1.4.21", + "version": "v1.4.22", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-a8c-mc-stats.git", - "reference": "c6ed99f2f383b24e1b49204de2be67fe014a55b1" + "reference": "d7fdf2fc7ae33d75e24e82d81269e33ec718446f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-a8c-mc-stats/zipball/c6ed99f2f383b24e1b49204de2be67fe014a55b1", - "reference": "c6ed99f2f383b24e1b49204de2be67fe014a55b1", + "url": "https://api.github.com/repos/Automattic/jetpack-a8c-mc-stats/zipball/d7fdf2fc7ae33d75e24e82d81269e33ec718446f", + "reference": "d7fdf2fc7ae33d75e24e82d81269e33ec718446f", "shasum": "" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", + "automattic/jetpack-changelogger": "^3.3.9", "yoast/phpunit-polyfills": "1.1.0" }, "suggest": { @@ -49,27 +49,27 @@ ], "description": "Used to record internal usage stats for Automattic. Not visible to site owners.", "support": { - "source": "https://github.com/Automattic/jetpack-a8c-mc-stats/tree/v1.4.21" + "source": "https://github.com/Automattic/jetpack-a8c-mc-stats/tree/v1.4.22" }, - "time": "2023-08-23T17:56:34+00:00" + "time": "2023-09-19T18:18:33+00:00" }, { "name": "automattic/jetpack-admin-ui", - "version": "v0.2.22", + "version": "v0.2.23", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-admin-ui.git", - "reference": "942f91e1f29d618084135dcddab288c91cbe4034" + "reference": "2684f3ee3b458074d95e727e70ae994802501688" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-admin-ui/zipball/942f91e1f29d618084135dcddab288c91cbe4034", - "reference": "942f91e1f29d618084135dcddab288c91cbe4034", + "url": "https://api.github.com/repos/Automattic/jetpack-admin-ui/zipball/2684f3ee3b458074d95e727e70ae994802501688", + "reference": "2684f3ee3b458074d95e727e70ae994802501688", "shasum": "" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", - "automattic/jetpack-logo": "^1.6.2", + "automattic/jetpack-changelogger": "^3.3.9", + "automattic/jetpack-logo": "^1.6.3", "automattic/wordbless": "dev-master", "yoast/phpunit-polyfills": "1.1.0" }, @@ -102,29 +102,29 @@ ], "description": "Generic Jetpack wp-admin UI elements", "support": { - "source": "https://github.com/Automattic/jetpack-admin-ui/tree/v0.2.22" + "source": "https://github.com/Automattic/jetpack-admin-ui/tree/v0.2.23" }, - "time": "2023-09-11T14:35:12+00:00" + "time": "2023-09-19T18:19:10+00:00" }, { "name": "automattic/jetpack-autoloader", - "version": "v2.11.22", + "version": "v2.11.23", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-autoloader.git", - "reference": "32cc6b4a30e5cb5be669b4c8bed7330202e9f0c1" + "reference": "4198bea356038fcf73fcb32df73b08818abbf8f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/32cc6b4a30e5cb5be669b4c8bed7330202e9f0c1", - "reference": "32cc6b4a30e5cb5be669b4c8bed7330202e9f0c1", + "url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/4198bea356038fcf73fcb32df73b08818abbf8f3", + "reference": "4198bea356038fcf73fcb32df73b08818abbf8f3", "shasum": "" }, "require": { "composer-plugin-api": "^1.1 || ^2.0" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", + "automattic/jetpack-changelogger": "^3.3.9", "yoast/phpunit-polyfills": "1.1.0" }, "type": "composer-plugin", @@ -161,9 +161,9 @@ "wordpress" ], "support": { - "source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.11.22" + "source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.11.23" }, - "time": "2023-08-23T17:57:14+00:00" + "time": "2023-09-19T18:19:19+00:00" }, { "name": "automattic/jetpack-config", @@ -214,28 +214,28 @@ }, { "name": "automattic/jetpack-connection", - "version": "v1.57.4", + "version": "v1.57.5", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-connection.git", - "reference": "92514d5fed2a0fbe69629a4a0849145abbe7024e" + "reference": "7fee0a8ef4c469565115f568212b768d66fb5bbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-connection/zipball/92514d5fed2a0fbe69629a4a0849145abbe7024e", - "reference": "92514d5fed2a0fbe69629a4a0849145abbe7024e", + "url": "https://api.github.com/repos/Automattic/jetpack-connection/zipball/7fee0a8ef4c469565115f568212b768d66fb5bbc", + "reference": "7fee0a8ef4c469565115f568212b768d66fb5bbc", "shasum": "" }, "require": { - "automattic/jetpack-a8c-mc-stats": "^1.4.21", - "automattic/jetpack-admin-ui": "^0.2.22", + "automattic/jetpack-a8c-mc-stats": "^1.4.22", + "automattic/jetpack-admin-ui": "^0.2.23", "automattic/jetpack-constants": "^1.6.23", - "automattic/jetpack-redirect": "^1.7.26", - "automattic/jetpack-roles": "^1.4.24", - "automattic/jetpack-status": "^1.18.3" + "automattic/jetpack-redirect": "^1.7.27", + "automattic/jetpack-roles": "^1.4.25", + "automattic/jetpack-status": "^1.18.4" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", + "automattic/jetpack-changelogger": "^3.3.9", "automattic/wordbless": "@dev", "brain/monkey": "2.6.1", "yoast/phpunit-polyfills": "1.1.0" @@ -271,9 +271,9 @@ ], "description": "Everything needed to connect to the Jetpack infrastructure", "support": { - "source": "https://github.com/Automattic/jetpack-connection/tree/v1.57.4" + "source": "https://github.com/Automattic/jetpack-connection/tree/v1.57.5" }, - "time": "2023-09-13T04:23:36+00:00" + "time": "2023-09-19T18:19:42+00:00" }, { "name": "automattic/jetpack-constants", @@ -325,23 +325,23 @@ }, { "name": "automattic/jetpack-redirect", - "version": "v1.7.26", + "version": "v1.7.27", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-redirect.git", - "reference": "c958a69a5fedfc3e95d5dd595a177e16e457e611" + "reference": "43dd3ae2bef71281fe70f62733bfaa44c988f1b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-redirect/zipball/c958a69a5fedfc3e95d5dd595a177e16e457e611", - "reference": "c958a69a5fedfc3e95d5dd595a177e16e457e611", + "url": "https://api.github.com/repos/Automattic/jetpack-redirect/zipball/43dd3ae2bef71281fe70f62733bfaa44c988f1b1", + "reference": "43dd3ae2bef71281fe70f62733bfaa44c988f1b1", "shasum": "" }, "require": { - "automattic/jetpack-status": "^1.18.1" + "automattic/jetpack-status": "^1.18.4" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", + "automattic/jetpack-changelogger": "^3.3.9", "brain/monkey": "2.6.1", "yoast/phpunit-polyfills": "1.1.0" }, @@ -370,26 +370,26 @@ ], "description": "Utilities to build URLs to the jetpack.com/redirect/ service", "support": { - "source": "https://github.com/Automattic/jetpack-redirect/tree/v1.7.26" + "source": "https://github.com/Automattic/jetpack-redirect/tree/v1.7.27" }, - "time": "2023-08-23T17:57:15+00:00" + "time": "2023-09-19T18:19:22+00:00" }, { "name": "automattic/jetpack-roles", - "version": "v1.4.24", + "version": "v1.4.25", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-roles.git", - "reference": "7c5f339d79cba60c952715eafdebb9bcc095197f" + "reference": "708b33f16a879fc2ab5939a972c968c9aeefbe38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-roles/zipball/7c5f339d79cba60c952715eafdebb9bcc095197f", - "reference": "7c5f339d79cba60c952715eafdebb9bcc095197f", + "url": "https://api.github.com/repos/Automattic/jetpack-roles/zipball/708b33f16a879fc2ab5939a972c968c9aeefbe38", + "reference": "708b33f16a879fc2ab5939a972c968c9aeefbe38", "shasum": "" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", + "automattic/jetpack-changelogger": "^3.3.9", "brain/monkey": "2.6.1", "yoast/phpunit-polyfills": "1.1.0" }, @@ -418,30 +418,30 @@ ], "description": "Utilities, related with user roles and capabilities.", "support": { - "source": "https://github.com/Automattic/jetpack-roles/tree/v1.4.24" + "source": "https://github.com/Automattic/jetpack-roles/tree/v1.4.25" }, - "time": "2023-08-23T17:56:38+00:00" + "time": "2023-09-19T18:18:38+00:00" }, { "name": "automattic/jetpack-status", - "version": "v1.18.3", + "version": "v1.18.4", "source": { "type": "git", "url": "https://github.com/Automattic/jetpack-status.git", - "reference": "bf2346804dccb61d0147a1d64015c7598321290d" + "reference": "cc73830e40e620c8b4f85fcc7c145e772f347838" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/jetpack-status/zipball/bf2346804dccb61d0147a1d64015c7598321290d", - "reference": "bf2346804dccb61d0147a1d64015c7598321290d", + "url": "https://api.github.com/repos/Automattic/jetpack-status/zipball/cc73830e40e620c8b4f85fcc7c145e772f347838", + "reference": "cc73830e40e620c8b4f85fcc7c145e772f347838", "shasum": "" }, "require": { "automattic/jetpack-constants": "^1.6.23" }, "require-dev": { - "automattic/jetpack-changelogger": "^3.3.8", - "automattic/jetpack-ip": "^0.1.5", + "automattic/jetpack-changelogger": "^3.3.9", + "automattic/jetpack-ip": "^0.1.6", "brain/monkey": "2.6.1", "yoast/phpunit-polyfills": "1.1.0" }, @@ -470,9 +470,9 @@ ], "description": "Used to retrieve information about the current status of Jetpack and the site overall.", "support": { - "source": "https://github.com/Automattic/jetpack-status/tree/v1.18.3" + "source": "https://github.com/Automattic/jetpack-status/tree/v1.18.4" }, - "time": "2023-09-11T14:35:14+00:00" + "time": "2023-09-19T18:19:15+00:00" }, { "name": "composer/installers", diff --git a/docs/internal-developers/testing/cart-checkout/shipping.md b/docs/internal-developers/testing/cart-checkout/shipping.md index 7ced70d24f0..22e6083c397 100644 --- a/docs/internal-developers/testing/cart-checkout/shipping.md +++ b/docs/internal-developers/testing/cart-checkout/shipping.md @@ -1,13 +1,5 @@ # Shipping -## Table of Contents - -- [Setup](#setup) -- [What to test](#what-to-test) - - [With shipping zones available](#with-shipping-zones-available) - - [If you don't have any shipping zones set up and/or shipping is disabled](#if-you-dont-have-any-shipping-zones-set-up-andor-shipping-is-disabled) - - [If you don't have any shipping zones set up, but shipping is enabled](#if-you-dont-have-any-shipping-zones-set-up-but-shipping-is-enabled) - ## Setup - You will need to setup shipping zones for a couple of countries. diff --git a/src/BlockTypes/Checkout.php b/src/BlockTypes/Checkout.php index e4dad4d44a8..38133e31b14 100644 --- a/src/BlockTypes/Checkout.php +++ b/src/BlockTypes/Checkout.php @@ -342,6 +342,31 @@ function( $acc, $method ) { $this->asset_data_registry->add( 'globalPaymentMethods', $formatted_payment_methods ); } + if ( $is_block_editor && ! $this->asset_data_registry->exists( 'incompatibleExtensions' ) ) { + if ( ! class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { + return; + } + + if ( ! function_exists( 'get_plugin_data' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + $declared_extensions = \Automattic\WooCommerce\Utilities\FeaturesUtil::get_compatible_plugins_for_feature( 'cart_checkout_blocks' ); + $incompatible_extensions = array_reduce( + $declared_extensions['incompatible'], + function( $acc, $item ) { + $plugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $item ); + $acc[] = [ + 'id' => $plugin['TextDomain'], + 'title' => $plugin['Name'], + ]; + return $acc; + }, + [] + ); + $this->asset_data_registry->add( 'incompatibleExtensions', $incompatible_extensions ); + } + if ( ! is_admin() && ! WC()->is_rest_api_request() ) { $this->asset_data_registry->hydrate_api_request( '/wc/store/v1/cart' ); $this->asset_data_registry->hydrate_data_from_api_request( 'checkoutData', '/wc/store/v1/checkout' );