Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PO-212]:-Enqueue checkout.js to checkout page #573

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions woo-razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ protected function initHooks()
add_action( "woocommerce_update_options_payment_gateways_{$this->id}", 'syncPluginFetchCron');
}

add_action('wp_enqueue_scripts', array($this, 'enqueue_checkout_js_script_on_checkout'));

add_filter( 'woocommerce_thankyou_order_received_text', array($this, 'getCustomOrdercreationMessage'), 20, 2 );
}

Expand Down Expand Up @@ -712,6 +714,20 @@ public function newTrackPluginInstrumentation($key, $secret)
return new TrackPluginInstrumentation($api, $key);
}

public function enqueue_checkout_js_script_on_checkout() {
// Check if we're on the checkout page
if (is_checkout()) {
// Enqueue your custom script
wp_enqueue_script(
'razorpay-checkout-js', // Handle name for the script
'https://checkout.razorpay.com/v1/checkout.js', // Path to your script file
[], // Dependencies (like jQuery)
null, // Version number, set to null if not needed
true // Load script in footer
);
}
}

public function pluginInstrumentation()
{
if (empty($_POST['woocommerce_razorpay_key_id']) or
Expand Down
Loading