Plugin Directory

Changeset 3233906


Ignore:
Timestamp:
02/03/2025 11:50:00 AM (14 months ago)
Author:
marekgach
Message:

Add support for checkout blocks

Location:
axima-payment-gateway/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • axima-payment-gateway/trunk/axima-payment-gateway.php

    r3123182 r3233906  
    1616 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
    1717 * Text Domain:       axima-payment-gateway
     18 * WC requires at least:    6.0
     19 * WC tested up to:         9.6
    1820 */
    1921
  • axima-payment-gateway/trunk/src/Plugin.php

    r3216527 r3233906  
    77
    88use DateTime;
     9use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
     10use Automattic\WooCommerce\Utilities\FeaturesUtil;
     11use Pays\PaymentGate\PaymentMethodType;
     12
    913
    1014class Plugin
     
    256260        }
    257261
     262        add_action('before_woocommerce_init', function() use ($file) {
     263            if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
     264                // declare checkout blocks compatibility
     265                FeaturesUtil::declare_compatibility('cart_checkout_blocks', $file, true);
     266                // declare HPOS compatibility
     267                FeaturesUtil::declare_compatibility('custom_order_tables', $file, true);
     268            }
     269        });
     270
     271        add_action('woocommerce_blocks_loaded', function() use($file) {
     272            if (class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
     273                add_action(
     274                    'woocommerce_blocks_payment_method_type_registration', function (PaymentMethodRegistry $payment_method_registry) {
     275                    $payment_method_registry->register(new PaymentMethodType());
     276                    });
     277            }
     278        });
     279
    258280        add_action('plugins_loaded', function () use ($that) {
    259281            $handlerConfirm = array($that, 'confirmPayment');
     
    272294            call_user_func(function () {
    273295                require_once __DIR__ . '/Gateway.php';
     296                if (class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
     297                    require_once __DIR__ . '/PaymentMethodType.php';
     298                }
    274299            });
    275300
Note: See TracChangeset for help on using the changeset viewer.