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-f2f-payments/bootstrap.php
feibisi 89d27aa686 Add Woo Alipay Face To Face payment extension
Initial commit of the Woo Alipay - Face To Face (F2F) extension for WooCommerce. Adds independent Alipay F2F (QR code) payment gateway, supporting WooCommerce Blocks, custom styles, scripts, and admin settings integration. Includes gateway class, Blocks support, frontend assets, and template for QR code payment page.
2025-10-04 18:21:57 +08:00

48 lines
1.7 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
// Define extension path/url constants
if ( ! defined( 'WOO_ALIPAY_F2F_PLUGIN_FILE' ) ) {
define( 'WOO_ALIPAY_F2F_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'WOO_ALIPAY_F2F_PLUGIN_PATH' ) ) {
define( 'WOO_ALIPAY_F2F_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'WOO_ALIPAY_F2F_PLUGIN_URL' ) ) {
define( 'WOO_ALIPAY_F2F_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_F2F_PLUGIN_PATH . 'inc/class-wc-alipay-facetopay.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_FaceToPay' ) ) {
$methods[] = 'WC_Alipay_FaceToPay';
}
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_F2F_PLUGIN_PATH . 'inc/class-wc-alipay-facetopay-blocks-support.php';
if ( file_exists( $file ) ) {
require_once $file;
}
if ( class_exists( 'WC_Alipay_FaceToPay_Blocks_Support' ) ) {
$registry->register( new WC_Alipay_FaceToPay_Blocks_Support() );
}
},
10,
1
);