2023-10-24 14:49:37 +00:00
|
|
|
{% put scripts %}
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
$('#loader_add').hide();
|
|
|
|
|
function addToCart(prodId, qty) {
|
|
|
|
|
|
|
|
|
|
// var fd = new FormData();
|
|
|
|
|
// fd.append('phone', phone);
|
|
|
|
|
|
|
|
|
|
var product = {};
|
|
|
|
|
product.product_id = prodId;
|
|
|
|
|
product.quantity = qty;
|
|
|
|
|
|
|
|
|
|
console.log(String('Bearer {{token}}'));
|
|
|
|
|
console.log(prodId);
|
|
|
|
|
console.log(qty);
|
|
|
|
|
console.log(JSON.stringify(product));
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
async: true,
|
2023-10-24 15:43:23 +00:00
|
|
|
url: 'http://216.250.11.229/app/api/customer/cart/add/' + String(prodId),
|
2023-10-24 14:49:37 +00:00
|
|
|
type: 'POST',
|
|
|
|
|
headers: { Authorization: 'Bearer {{token}}' },
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
data: JSON.stringify(product),
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
|
|
oc.flashMsg({
|
|
|
|
|
message: "{{'added.cart.success'|_}}",
|
|
|
|
|
type: 'success',
|
|
|
|
|
interval: 3
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
error: function (data) {
|
|
|
|
|
console.log(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{% endput %}
|