
03-27-2012, 03:37 PM
|
 |
Ecwid Team
|
|
Join Date: Feb 2010
Location: Ecwid headquarter
Posts: 5,876
|
|
Your code works the way, that the “shipping_method” variable gets redefined (reset) each time when “Ecwid.OnPageLoaded.add” is executed. That is why “shipping_method” variable in undefined, when you go to the Payment Methods page.
In order to save “shipping_method” value you should declare this variable before “Ecwid.OnPageLoaded.add” function and remove its' declaration inside “if (page.type == 'CHECKOUT_SHIPPING_ADDRESS')” condition.
Finally, your javascript code will look like here:
Code:
<script type="text/javascript">
//Ecwid.OnPageLoad.add(function(page){
//alert("test");
//});
//Ecwid.OnAPILoaded.add(function() {
//// Ecwid API is available, do something
//alert ($("#gwt-uid-22").parent().children('label').text());
//});
var shipping_method;
Ecwid.OnPageLoaded.add(function(page) {
//if (page.type == 'CHECKOUT_SHIPPING_ADDRESS') {
//var mytest = $("#gwt-uid-6").val();
//}
//var mytest = $("input[@name=ru.cdev.xnext.frontend.client.checkout.ShippingDetails$ShippingOptionRadioButton]:checked").attr("id");
//var mytest = $("input[@name=ru.cdev.xnext.frontend.client.checkout.ShippingDetails$ShippingOptionRadioButton]:checked").val();
//var mytest = $("#gwt-uid-23").next().find('span').remove();
//var mytest = $("#gwt-uid-23").parent().children('label').html();
//var mytest = $("input[@name=ru.cdev.xnext.frontend.client.checkout.ShippingDetails$ShippingOptionRadioButton]:checked").parent().children('label').text();
//alert ($("#gwt-uid-22").parent().children('label').text());
//alert ($("#gwt-uid-6").val());
//alert("My page load handler: "+page.type);
//alert(mytest);
if (page.type == 'CHECKOUT_SHIPPING_ADDRESS') {
shipping_method = $("input[@name=ru.cdev.xnext.frontend.client.checkout.ShippingDetails$ShippingOptionRadioButton]:checked").parent().children('label').text();
}
…...........
</script>
__________________
Maya N., Ecwid Team
------------------
Welcome to our new Help Center!
|