VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: baoquocmt159 on November 26, 2013, 05:30:26 AM

Title: how to use ajax for module cart
Post by: baoquocmt159 on November 26, 2013, 05:30:26 AM
Hi all
I'm used ajax for button Update quanty product in module cart, but not complate

My code :


var url="index.php?api_controller=checkout&api_ajax=update_form&id=5&quantity=3";

jQuery.ajax({
url:url,
type:'POST',
cache:false,
data:jQuery('#mod_ajax_form').serialize(),
dataType:'json',
success : function (rs){
requestUpdate = false;
if(rs.error) {
//raise error msg
} else {
//process remove product task
if(task=='remove_product') {
jQuery('.marg-bot').destroy();
}
//end - process remove product task

//update cart module
if(Virtuemart) Virtuemart.productUpdate(jQuery('.vmCartModule'));

//alert(rs.price.products);
//update product list
if(rs.price.products) {
for(var _id in rs.price.products) {
//update_DOM(vmconfig.show_tax, 'subtotal_tax_amount_'+_id, 'text',rs.price.products[_id].subtotal_tax_amount);
update_DOM(true, 'subtotal_discount_'+_id, 'text', rs.price.products[_id].subtotal_discount);
update_DOM(true, 'total', 'html', rs.price.products[_id].subtotal_with_tax);
}
}//end - update product list

update_DOM(true, 'prices', 'html', rs.price.billTotal);
                                                       or
jQuery('.prices').html(billTotal);
                                                       -> not complate

}//data

}

})//ajax


Please help me ! Thank you