Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
migrate from old block to new block
Browse files Browse the repository at this point in the history
  • Loading branch information
senadir committed Oct 20, 2021
1 parent be4dc74 commit 9baed2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/js/blocks/cart-checkout/cart/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const Edit = ( { className, attributes, setAttributes, clientId } ) => {
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
template={ defaultTemplate }
templateLock="insert"
templateLock={ false }
/>
</CartProvider>
</CartBlockContext.Provider>
Expand Down
28 changes: 24 additions & 4 deletions assets/js/blocks/cart-checkout/cart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import { InnerBlocks } from '@wordpress/block-editor';
import { Icon, cart } from '@woocommerce/icons';
import { registerFeaturePluginBlockType } from '@woocommerce/block-settings';

import { createBlock } from '@wordpress/blocks';
/**
* Internal dependencies
*/
Expand Down Expand Up @@ -43,15 +44,34 @@ const settings = {
// Migrates v1 to v2 checkout.
deprecated: [
{
attributes: blockAttributes,
save( { attributes } ) {
save: ( { attributes } ) => {
return (
<div
className={ classnames(
'is-loading',
attributes.className
) }
/>
>
<InnerBlocks.Content />
</div>
);
},
migrate: ( attributes, innerBlocks ) => {
return [
attributes,
[
createBlock( 'woocommerce/filled-cart-block' ),
createBlock(
'woocommerce/empty-cart-block',
{},
innerBlocks
),
],
];
},
isEligible: ( _, innerBlocks ) => {
return ! innerBlocks.find(
( block ) => block.name === 'woocommerce/filled-cart-block'
);
},
},
Expand Down

0 comments on commit 9baed2f

Please sign in to comment.