33 lines
696 B
JavaScript
33 lines
696 B
JavaScript
function addToCart(e, id, qty_id = null) {
|
|
e.preventDefault();
|
|
// quantity check
|
|
var qty = 1;
|
|
if (qty_id) {
|
|
qty = $(qty_id).val();
|
|
}
|
|
$.ajax({
|
|
url: "/cart/add_to_cart",
|
|
type: "POST",
|
|
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
|
|
data: {
|
|
id: id,
|
|
qty: qty
|
|
},
|
|
cache: false
|
|
});
|
|
};
|
|
|
|
function changeQty(id, qty, from) {
|
|
$.ajax({
|
|
url: "/cart/change_qty",
|
|
type: "POST",
|
|
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
|
|
data: {
|
|
id: id,
|
|
qty: qty,
|
|
ca: from
|
|
},
|
|
cache: false
|
|
});
|
|
}
|