From ccc0e263dde31d25786e5248c61eb6133f8480a1 Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 13 Dec 2023 17:37:13 +0200 Subject: [PATCH] Allow to add paylater block inside block cart/checkout --- .../resources/js/paylater-block.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-paylater-block/resources/js/paylater-block.js b/modules/ppcp-paylater-block/resources/js/paylater-block.js index 27bcbebb1..605f20981 100644 --- a/modules/ppcp-paylater-block/resources/js/paylater-block.js +++ b/modules/ppcp-paylater-block/resources/js/paylater-block.js @@ -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 = ( ) -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; + }, + } ); +} );