I am trying to recreate the updateCart() function via ajax, and I ran into a problem,
my function doesn´t update the payment total in the Ajax cart I call/or in another words the payment type doens´t get submitted to the cart..
I call this finction like this:
<input type="radio" value="SHIP3" id="SHIP3" name="EcomCartShippingmethodID" onclick="updateCartV2();">
DW´s:
function updateCart() {
var form = document.getElementById('ordersubmit');
var field = document.createElement('input');
field.type = 'hidden';
field.name = 'CartV2.GotoStep1';
field.id = 'CartV2.GotoStep1';
field.value = 'Update';
form.appendChild(field);
form.submit();
}
My Ajax version:
function updateCartV2(productid) {
var url = '/Default.aspx?id=221';
var addToCart = url + '&productid=' + productid + '&cartcmd=add';
//Check if no parameter is sent
if (typeof productid != 'undefined') {
cartUrl = addToCart;
}
//Here we update the cart
$.ajax({
type: 'POST',
url: url,
cache: false,
dataType: "html",
success: function (htmlData) {
//Here we render the cart
$.ajax({
url: url,
cache: false,
dataType: "html",
success: function (html) {
var cart = $('.cart', $(html));
$("#yourOrder").html(cart);
},
error: function () {
//error...
}
});
},
error: function () {
//error...
}
});
}
Antonio