Skip to main content
Tweeted twitter.com/#!/StackMagento/status/566982435498622976
deleted 54 characters in body
Source Link
pspahn
  • 4.7k
  • 3
  • 32
  • 58

In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

jQuery('#billing-address-select').change(function(){
    option = jQuery('#billing-address-select option:selected').val();
    billing.setAddress(option);
    jQuery('#billing\\:address_id').val(option);
});

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?

In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

jQuery('#billing-address-select').change(function(){
    option = jQuery('#billing-address-select option:selected').val();
    billing.setAddress(option);
    jQuery('#billing\\:address_id').val(option);
});

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?

In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

jQuery('#billing-address-select').change(function(){
    option = jQuery('#billing-address-select option:selected').val();
    billing.setAddress(option);
});

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?

Source Link
pspahn
  • 4.7k
  • 3
  • 32
  • 58

One Page Checkout - Manually setAddress()

In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

jQuery('#billing-address-select').change(function(){
    option = jQuery('#billing-address-select option:selected').val();
    billing.setAddress(option);
    jQuery('#billing\\:address_id').val(option);
});

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?