Skip to content

Commit ac1c66b

Browse files
committed
Fix loading paymentMethodID after DOM ready
1 parent fa4aca4 commit ac1c66b

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

app/assets/javascripts/spree/backend/spree_paypal_express.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SpreePaypalExpress = {
1616
}
1717
}
1818

19-
$(document).ready(function() {
19+
Spree.ready(function() {
2020
checkedPaymentMethod = $('[data-hook="payment_method_field"] input[type="radio"]:checked');
2121
SpreePaypalExpress.hideSettings(checkedPaymentMethod);
2222
paymentMethods = $('[data-hook="payment_method_field"] input[type="radio"]').click(function (e) {

app/assets/javascripts/spree/frontend/spree_paypal_express.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ SpreePaypalExpress = {
2323
}
2424
}
2525

26-
$(document).ready(function() {
26+
Spree.ready(function() {
27+
SpreePaypalExpress.paymentMethodID = $('#paypal_button').data('payment-method-id');
2728
SpreePaypalExpress.updateSaveAndContinueVisibility();
2829
paymentMethods = $('div[data-hook="checkout_payment_step"] input[type="radio"]').click(function (e) {
2930
SpreePaypalExpress.updateSaveAndContinueVisibility();
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11

2-
<%= link_to(image_tag("https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"), paypal_express_url(:payment_method_id => payment_method.id), :method => :post, :id => "paypal_button") %>
3-
4-
<script>
5-
SpreePaypalExpress.paymentMethodID = "<%= payment_method.id %>"
6-
</script>
2+
<%= link_to(image_tag("https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"), paypal_express_url(:payment_method_id => payment_method.id), :method => :post, :id => "paypal_button", data: { 'payment-method-id' => payment_method.id }) %>

0 commit comments

Comments
 (0)