@@ -164,11 +164,22 @@ public function __construct( $apiBaseUri ) {
164164
165165 add_action ( 'woocommerce_api_aplazame ' , array ( $ this , 'api_router ' ) );
166166
167+ // Cart and Checkout Blocks
168+ add_action ( 'woocommerce_blocks_loaded ' , array ( $ this , 'add_gateway_block ' ) );
169+ add_action (
170+ 'before_woocommerce_init ' ,
171+ function () {
172+ if ( class_exists ('\Automattic\WooCommerce\Utilities\FeaturesUtil ' ) ) {
173+ \Automattic \WooCommerce \Utilities \FeaturesUtil::declare_compatibility ( 'cart_checkout_blocks ' , __FILE__ , true );
174+ }
175+ }
176+ );
177+
167178 // Declare HPOS compatibility
168179 add_action (
169180 'before_woocommerce_init ' ,
170181 function () {
171- if ( class_exists ( \Automattic \WooCommerce \Utilities \FeaturesUtil::class ) ) {
182+ if ( class_exists (' \Automattic\WooCommerce\Utilities\FeaturesUtil ' ) ) {
172183 \Automattic \WooCommerce \Utilities \FeaturesUtil::declare_compatibility ( 'custom_order_tables ' , __FILE__ , true );
173184 }
174185 }
@@ -276,6 +287,20 @@ public function add_gateway( $methods ) {
276287 return $ methods ;
277288 }
278289
290+ public function add_gateway_block () {
291+ if ( ! class_exists ( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType ' ) ) {
292+ return ;
293+ }
294+
295+ include_once 'classes/wc-aplazame-gateway-block.php ' ;
296+ add_action (
297+ 'woocommerce_blocks_payment_method_type_registration ' ,
298+ function ( Automattic \WooCommerce \Blocks \Payments \PaymentMethodRegistry $ payment_method_registry ) {
299+ $ payment_method_registry ->register ( new WC_Aplazame_Gateway_Blocks_Support );
300+ }
301+ );
302+ }
303+
279304 public function aplazameJs () {
280305
281306 Aplazame_Helpers::render_to_template ( 'layout/header.php ' );
0 commit comments