Created
December 15, 2025 08:40
-
-
Save xlplugins/fc5ec58fcad471cad4557a4e5f8e3179 to your computer and use it in GitHub Desktop.
Funnelkit Checkout: Moyasar Payment Gateway - FunnelKit Checkout Compatibility Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('wp_enqueue_scripts', function() { | |
| // Only run on checkout pages | |
| if (!is_checkout()) { | |
| return; | |
| } | |
| // Check if FunnelKit is active and we're on a FunnelKit checkout page | |
| if (!class_exists('WFACP_Common')) { | |
| return; | |
| } | |
| $checkout_id = WFACP_Common::get_id(); | |
| if ($checkout_id <= 0) { | |
| return; // Not a FunnelKit checkout page | |
| } | |
| // Check if Moyasar payment block class exists | |
| if (!class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) { | |
| return; | |
| } | |
| // Load the payment block class if not already loaded | |
| if (defined('MOYASAR_PAYMENT_DIR') && !class_exists('Moyasar_Payment_Block')) { | |
| $moyasar_block_file = MOYASAR_PAYMENT_DIR . '/blocks/moyasar-payment-block.php'; | |
| if (file_exists($moyasar_block_file)) { | |
| require_once $moyasar_block_file; | |
| } | |
| } | |
| // Call get_payment_method_script_handles() to register wc-payment-method-moyasar | |
| // This is the same method called by WooCommerce Blocks on native checkout | |
| if (class_exists('Moyasar_Payment_Block')) { | |
| $payment_block = new Moyasar_Payment_Block(); | |
| if (method_exists($payment_block, 'initialize')) { | |
| $payment_block->initialize(); | |
| } | |
| if (method_exists($payment_block, 'get_payment_method_script_handles')) { | |
| // This registers wc-payment-method-moyasar and enqueues dependencies | |
| $handles = $payment_block->get_payment_method_script_handles(); | |
| // Enqueue the main script handle (WooCommerce Blocks normally does this) | |
| if (!empty($handles) && is_array($handles)) { | |
| foreach ($handles as $handle) { | |
| if (!wp_script_is($handle, 'enqueued')) { | |
| wp_enqueue_script($handle); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, 25); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment