Commit d114da80 authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

update

parent 1076f2c9
...@@ -220,6 +220,7 @@ $(document).ready(function () { ...@@ -220,6 +220,7 @@ $(document).ready(function () {
var typingInterval = 800; //milliseconds var typingInterval = 800; //milliseconds
var productListGlobe = []; var productListGlobe = [];
var cartProductList = []; // this array represent DB where products will be stored var cartProductList = []; // this array represent DB where products will be stored
var productsToObtain = [];
var productUUIDListCart = []; var productUUIDListCart = [];
// On keyup, start the contdown // On keyup, start the contdown
...@@ -332,7 +333,7 @@ $(document).ready(function () { ...@@ -332,7 +333,7 @@ $(document).ready(function () {
if (submit_data_array.indexOf(data.uuid) > -1) { if (submit_data_array.indexOf(data.uuid) > -1) {
console.log("DATA sí esta: ", data.uuid); console.log("DATA sí esta: ", data.uuid);
console.log("SS: ", data.product.size); console.log("SS: ", data.product.size);
productUUIDListCart.push(data.uuid); productsToObtain.push(data.uuid);
erase_product_list_globe_by_id(data.uuid); erase_product_list_globe_by_id(data.uuid);
cartProductList.push({ cartProductList.push({
...@@ -362,6 +363,7 @@ $(document).ready(function () { ...@@ -362,6 +363,7 @@ $(document).ready(function () {
}, },
success: function () { success: function () {
cartProductList = []; cartProductList = [];
productUUIDListCart.push.apply(productUUIDListCart, productsToObtain);
// PRODUCT_COUNTER += 1; // this variable counts the number of products in shopping cart // PRODUCT_COUNTER += 1; // this variable counts the number of products in shopping cart
// PRODUCT_COUNTER_STR = PRODUCT_COUNTER.toString(); // PRODUCT_COUNTER_STR = PRODUCT_COUNTER.toString();
...@@ -378,6 +380,7 @@ $(document).ready(function () { ...@@ -378,6 +380,7 @@ $(document).ready(function () {
createProductContainer(); createProductContainer();
IS_PRODUCT_CONTAINER = true; IS_PRODUCT_CONTAINER = true;
} }
// TODO : return IS_PRODUCT_CONTAINER to 'false' in some point
// request a DB para mostrar los productos en el carrito // request a DB para mostrar los productos en el carrito
// variable prod_from_cartDB_url en map.html // variable prod_from_cartDB_url en map.html
...@@ -386,11 +389,11 @@ $(document).ready(function () { ...@@ -386,11 +389,11 @@ $(document).ready(function () {
url : prod_from_cartDB_url, url : prod_from_cartDB_url,
data : { data : {
'csrfmiddlewaretoken' : document.getElementsByName('csrfmiddlewaretoken')[0].value, 'csrfmiddlewaretoken' : document.getElementsByName('csrfmiddlewaretoken')[0].value,
'product_uuid_list' : productUUIDListCart.toString() 'product_uuid_list' : productsToObtain.toString()
}, },
dataType : 'json', dataType : 'json',
success : function (data) { success : function (data) {
// productUUIDListCart = []; productsToObtain = [];
data.product_list.forEach(function (product) { data.product_list.forEach(function (product) {
var temp_2 = document.querySelector('#product_cart_2'); var temp_2 = document.querySelector('#product_cart_2');
...@@ -437,7 +440,7 @@ $(document).ready(function () { ...@@ -437,7 +440,7 @@ $(document).ready(function () {
} }
}); });
// L1C product download petition // L1C product download request
$.ajax({ $.ajax({
type : "POST", type : "POST",
url : purch_prod_url, url : purch_prod_url,
...@@ -454,4 +457,6 @@ $(document).ready(function () { ...@@ -454,4 +457,6 @@ $(document).ready(function () {
}); });
} }
}); });
// TODO: Clean productUUIDListCart array after purchased is done
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment