-
Notifications
You must be signed in to change notification settings - Fork 30
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
Improves javascript structure #39
Conversation
captn3m0
commented
Jun 5, 2017
- Uses wp_enqueue_script and wp_localize_script
script.js
Outdated
document.razorpayform.submit(); | ||
}; | ||
|
||
console.log(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captn3m0 Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove, my bad
razorpay-payments.php
Outdated
<script> | ||
var data = $json; | ||
</script> | ||
wp_enqueue_script('razorpay_wc_script', plugin_dir_url(__FILE__) . 'script.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captn3m0 Shouldn't we register the script first and then enqueue it?
http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from gf plugin, I think. will check and fix
razorpay-payments.php
Outdated
'https://checkout.razorpay.com/v1/checkout.js', | ||
null, null); | ||
|
||
wp_enqueue_script('razorpay_wc_script'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captn3m0 Why enqueue the script twice?
razorpay-payments.php
Outdated
$data | ||
); | ||
|
||
wp_register_script('razorpay_checkout', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we register this script before razorpay_wc_script
in order for the steps to be in the right logical order, even though they don't necessarily have to be in that order for it to work?
<form name='razorpayform' action="$redirectUrl" method="POST"> | ||
<input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id"> | ||
<input type="hidden" name="razorpay_signature" id="razorpay_signature" > | ||
<!-- This distinguishes all our various wordpress plugins --> | ||
<input type="hidden" name="razorpay_wc_form_submit" value="1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captn3m0 Let us close this asap.
- Uses wp_enqueue_script and wp_localize_script