woocommerce/plugins/woocommerce-blocks/assets/js/blocks/classic-shortcode/index.tsx

294 lines
7.6 KiB
TypeScript
Raw Normal View History

Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
/**
* External dependencies
*/
import {
BlockInstance,
createBlock,
registerBlockType,
} from '@wordpress/blocks';
import type { BlockEditProps } from '@wordpress/blocks';
import {
useBlockProps,
BlockPreview,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
Button,
Placeholder,
Popover,
ExternalLink,
TabbableContainer,
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { shortcode, Icon } from '@wordpress/icons';
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
import { useDispatch, useSelect } from '@wordpress/data';
import { useState, createInterpolateElement } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { woo } from '@woocommerce/icons';
import { findBlock } from '@woocommerce/utils';
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
/**
* Internal dependencies
*/
import './editor.scss';
import './style.scss';
import { CartPlaceholder, CheckoutPlaceholder } from './placeholder';
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
import { TEMPLATES, TYPES } from './constants';
import { getTemplateDetailsBySlug } from './utils';
import * as blockifiedCheckout from './checkout';
import * as blockifiedCart from './cart';
import metadata from './block.json';
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
import type { BlockifiedTemplateConfig } from './types';
type Attributes = {
shortcode: string;
align: string;
};
const blockifiedFallbackConfig = {
isConversionPossible: () => false,
getBlockifiedTemplate: () => [],
getDescription: () => '',
onClickCallback: () => void 0,
};
const conversionConfig: { [ key: string ]: BlockifiedTemplateConfig } = {
[ TYPES.cart ]: blockifiedCart,
[ TYPES.checkout ]: blockifiedCheckout,
fallback: blockifiedFallbackConfig,
};
const ConvertTemplate = ( { blockifyConfig, clientId, attributes } ) => {
const { getButtonLabel, onClickCallback, getBlockifiedTemplate } =
blockifyConfig;
const [ isPopoverOpen, setIsPopoverOpen ] = useState( false );
const { replaceBlock, selectBlock } = useDispatch( blockEditorStore );
const { createInfoNotice } = useDispatch( noticesStore );
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
const { getBlocks } = useSelect( ( sel ) => {
return {
getBlocks: sel( blockEditorStore ).getBlocks,
};
}, [] );
return (
<TabbableContainer className="wp-block-woocommerce-classic-shortcode__placeholder-migration-button-container">
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
<Button
variant="primary"
onClick={ () => {
onClickCallback( {
clientId,
getBlocks,
attributes,
replaceBlock,
selectBlock,
} );
createInfoNotice(
__(
'Classic shortcode transformed to blocks.',
'woocommerce'
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
),
{
actions: [
{
2023-12-12 23:05:20 +00:00
label: __( 'Undo', 'woocommerce' ),
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
onClick: () => {
const targetBlocks = [
'woocommerce/cart',
'woocommerce/checkout',
];
const cartCheckoutBlock = findBlock( {
blocks: getBlocks(),
findCondition: (
foundBlock: BlockInstance
) =>
targetBlocks.includes(
foundBlock.name
),
} );
if ( ! cartCheckoutBlock ) {
return;
}
replaceBlock(
cartCheckoutBlock.clientId,
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
createBlock(
'woocommerce/classic-shortcode',
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
{
shortcode:
attributes.shortcode,
}
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
)
);
},
},
],
type: 'snackbar',
}
);
} }
onMouseEnter={ () => setIsPopoverOpen( true ) }
onMouseLeave={ () => setIsPopoverOpen( false ) }
text={ getButtonLabel ? getButtonLabel() : '' }
tabIndex={ 0 }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
>
{ isPopoverOpen && (
<Popover resize={ false } placement="right-end">
<div
style={ {
minWidth: '250px',
width: '250px',
maxWidth: '250px',
minHeight: '300px',
height: '300px',
maxHeight: '300px',
cursor: 'pointer',
} }
>
<BlockPreview
blocks={ getBlockifiedTemplate( {
...attributes,
isPreview: true,
} ) }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
viewportWidth={ 1200 }
additionalStyles={ [
{
css: 'body { padding: 20px !important; height: fit-content !important; overflow:hidden}',
},
] }
/>
</div>
</Popover>
) }
</Button>
<Button
variant="secondary"
href="https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout/"
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
target="_blank"
tabIndex={ 0 }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
>
{ __( 'Learn more', 'woocommerce' ) }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
</Button>
</TabbableContainer>
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
);
};
const Edit = ( { clientId, attributes }: BlockEditProps< Attributes > ) => {
const blockProps = useBlockProps();
const templateDetails = getTemplateDetailsBySlug(
attributes.shortcode,
TEMPLATES
);
const templateTitle = attributes.shortcode;
const templatePlaceholder = templateDetails?.placeholder ?? 'cart';
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
const templateType = templateDetails?.type ?? 'fallback';
const { isConversionPossible, getDescription, getTitle, blockifyConfig } =
conversionConfig[ templateType ];
const canConvert = isConversionPossible();
const placeholderTitle = getTitle
? getTitle()
: __( 'Classic Shortcode Placeholder', 'woocommerce' );
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
const placeholderDescription = getDescription( templateTitle, canConvert );
const learnMoreContent = createInterpolateElement(
__(
'You can learn more about the benefits of switching to blocks, compatibility with extensions, and how to switch back to shortcodes <a>in our documentation</a>.',
'woocommerce'
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
),
{
a: (
// Suppress the warning as this <a> will be interpolated into the string with content.
// eslint-disable-next-line jsx-a11y/anchor-has-content
<ExternalLink href="https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout/" />
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
),
}
);
return (
<div { ...blockProps }>
<Placeholder className="wp-block-woocommerce-classic-shortcode__placeholder">
<div className="wp-block-woocommerce-classic-shortcode__placeholder-wireframe">
{ templatePlaceholder === 'cart' ? (
<CartPlaceholder />
) : (
<CheckoutPlaceholder />
) }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
</div>
<div className="wp-block-woocommerce-classic-shortcode__placeholder-copy">
<div className="wp-block-woocommerce-classic-shortcode__placeholder-copy__icon-container">
<span className="woo-icon">
<Icon icon={ woo } />{ ' ' }
2023-12-12 23:05:20 +00:00
{ __( 'WooCommerce', 'woocommerce' ) }
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
</span>
<span>{ placeholderTitle }</span>
</div>
<p
dangerouslySetInnerHTML={ {
__html: placeholderDescription,
} }
/>
<p>{ learnMoreContent }</p>
{ canConvert && blockifyConfig && (
<ConvertTemplate
clientId={ clientId }
blockifyConfig={ blockifyConfig }
attributes={ attributes }
/>
) }
</div>
</Placeholder>
</div>
);
};
const settings = {
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
icon: (
<Icon
icon={ shortcode }
className="wc-block-editor-components-block-icon"
/>
Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) * Rename checkout template slug * Remove redirect and custom title * Classic shortcode block for checkout * Empty title * WIP placeholder * Change blockified template * Prefix cart and checkout templates with "Page: " * Template migration routine * Apply same treatment to cart template * Notices * Update placeholder text * Classic shortcodes block * Page content wrapper for templates * Update default * Do not save attributes * Update templates * Remove cart classic template * Reverted endpoints for Cart & Checkout templates. This reverts PR 9406 * Migrate page content wrapper. * Removed useless method arg. Minor tweaks. * Skip migration if the theme has a template file for this page. * Removed impossible condition. * Migrate page content wrapper. * Remove TemplateNotice in favour of DefaultNotice * Documentation links in shortcode placeholder * Hide cart and checkout page selector when using block themes * Unused var * Add tests for template changes * Revert changes to classic-template * Allow frontend redirect * Unused file * Bump version for updater * Support x template naming as well as page-x * Need to add item to cart to test checkout * Fix header test by fixing utility for adding to cart * Remove permalink tests * Click body * Wait for content to finish loading * Wait for add to cart response when adding to cart without item name * Wait for save before visiting frontend * Set content instead of inserting block * Perform test in site editor rather than page editor * Prevent notice to set the default cart/checkout page from showing on the site editor. --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-09-19 09:58:18 +00:00
),
edit: ( {
attributes,
clientId,
setAttributes,
}: BlockEditProps< Attributes > ) => {
return (
<Edit
attributes={ attributes }
setAttributes={ setAttributes }
clientId={ clientId }
/>
);
},
save: () => null,
variations: [
{
name: 'checkout',
title: __( 'Classic Checkout', 'woocommerce' ),
attributes: {
shortcode: 'checkout',
},
isActive: ( blockAttributes, variationAttributes ) =>
blockAttributes.shortcode === variationAttributes.shortcode,
scope: [ 'inserter' ],
},
{
name: 'cart',
title: __( 'Classic Cart', 'woocommerce' ),
attributes: {
shortcode: 'cart',
},
isActive: ( blockAttributes, variationAttributes ) =>
blockAttributes.shortcode === variationAttributes.shortcode,
scope: [ 'inserter' ],
isDefault: true,
},
],
};
registerBlockType( metadata, settings );