Allow to add paylater block inside block cart/checkout

This commit is contained in:
Alex P 2023-12-13 17:37:13 +02:00
parent 910c6ccb6d
commit ccc0e263dd
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -1,4 +1,5 @@
import { registerBlockType } from '@wordpress/blocks';
import { registerCheckoutFilters } from '@woocommerce/blocks-checkout';
import Edit from './edit';
import save from './save';
@ -13,8 +14,22 @@ const paypalIcon = (
</svg>
)
registerBlockType( 'woocommerce-paypal-payments/paylater-messages', {
const blockId = 'woocommerce-paypal-payments/paylater-messages';
registerBlockType( blockId, {
icon: paypalIcon,
edit: Edit,
save,
} );
document.addEventListener( 'DOMContentLoaded', () => {
// allow to add this block inside WC cart/checkout blocks
registerCheckoutFilters( blockId, {
additionalCartCheckoutInnerBlockTypes: (
defaultValue
) => {
defaultValue.push( blockId );
return defaultValue;
},
} );
} );