This repository has been archived on 2026-04-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
woo-alipay-huabei-payments/bootstrap.php
feibisi 8ebd0aa4af Add Woo Alipay Huabei Installment extension
Initial commit of the Woo Alipay - Huabei Installment Extension for WooCommerce. Adds a standalone Alipay Huabei installment payment gateway with admin settings, frontend styles and scripts, WooCommerce Blocks support, and integration hooks. Includes gateway logic, block registration, and plugin bootstrap.
2025-10-04 18:22:48 +08:00

48 lines
1.7 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
// Define extension path/url constants
if ( ! defined( 'WOO_ALIPAY_HUABEI_PLUGIN_FILE' ) ) {
define( 'WOO_ALIPAY_HUABEI_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'WOO_ALIPAY_HUABEI_PLUGIN_PATH' ) ) {
define( 'WOO_ALIPAY_HUABEI_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'WOO_ALIPAY_HUABEI_PLUGIN_URL' ) ) {
define( 'WOO_ALIPAY_HUABEI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Ensure WooCommerce and core Woo Alipay are active before loading classes
add_action( 'plugins_loaded', function () {
if ( class_exists( 'WC_Payment_Gateway' ) && class_exists( 'Woo_Alipay' ) ) {
// Load gateway class from this extension
$gateway_file = WOO_ALIPAY_HUABEI_PLUGIN_PATH . 'inc/class-wc-alipay-installment.php';
if ( file_exists( $gateway_file ) ) {
require_once $gateway_file;
}
}
}, 15 );
// Register gateway into WooCommerce (core will no longer add extension gateways)
add_filter( 'woocommerce_payment_gateways', function( $methods ) {
if ( class_exists( 'WC_Alipay_Installment' ) ) {
$methods[] = 'WC_Alipay_Installment';
}
return $methods;
}, 11, 1 );
// Register Blocks support from this extension
add_action(
'woocommerce_blocks_payment_method_type_registration',
function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $registry ) {
$file = WOO_ALIPAY_HUABEI_PLUGIN_PATH . 'inc/class-wc-alipay-installment-blocks-support.php';
if ( file_exists( $file ) ) {
require_once $file;
}
if ( class_exists( 'WC_Alipay_Installment_Blocks_Support' ) ) {
$registry->register( new WC_Alipay_Installment_Blocks_Support() );
}
},
10,
1
);