|
@@ -4,7 +4,6 @@ $('.js_variant_change').click(function(e) {
|
|
var attribute_color = $('input:radio[id=product_color]:checked').val();
|
|
var attribute_color = $('input:radio[id=product_color]:checked').val();
|
|
var target = $(e.currentTarget).prop('id');
|
|
var target = $(e.currentTarget).prop('id');
|
|
var attribute_id = target.substring(target.indexOf('_') + 1);
|
|
var attribute_id = target.substring(target.indexOf('_') + 1);
|
|
-
|
|
|
|
if(attribute_color === undefined){
|
|
if(attribute_color === undefined){
|
|
var indexOfValue = attributeList.indexOf('[' + attribute_id + ']');
|
|
var indexOfValue = attributeList.indexOf('[' + attribute_id + ']');
|
|
console.log('entro');
|
|
console.log('entro');
|
|
@@ -12,7 +11,6 @@ $('.js_variant_change').click(function(e) {
|
|
var indexOfValue = attributeList.indexOf('[' + attribute_id + ', ' + attribute_color);
|
|
var indexOfValue = attributeList.indexOf('[' + attribute_id + ', ' + attribute_color);
|
|
}
|
|
}
|
|
var buffer = '';
|
|
var buffer = '';
|
|
-
|
|
|
|
for (i = indexOfValue - 2; i > 0; i--) {
|
|
for (i = indexOfValue - 2; i > 0; i--) {
|
|
var charValue = attributeList.charAt(i);
|
|
var charValue = attributeList.charAt(i);
|
|
if (charValue == '[') {
|
|
if (charValue == '[') {
|
|
@@ -23,12 +21,12 @@ $('.js_variant_change').click(function(e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$('.product_id').val(buffer);
|
|
$('.product_id').val(buffer);
|
|
-
|
|
|
|
- // submit del formulario
|
|
|
|
$(this).closest('form').submit();
|
|
$(this).closest('form').submit();
|
|
});
|
|
});
|
|
|
|
+
|
|
// comprar por curva
|
|
// comprar por curva
|
|
$('#curva').off('click').click(function(e) {
|
|
$('#curva').off('click').click(function(e) {
|
|
|
|
+ var attribute_color = $('input:radio[id=product_color]:checked').val();
|
|
var attributeList = $('#attribute_list').val();
|
|
var attributeList = $('#attribute_list').val();
|
|
var variantList = $('#variant_list').val();
|
|
var variantList = $('#variant_list').val();
|
|
var variant = variantList.substring(variantList.indexOf('('));
|
|
var variant = variantList.substring(variantList.indexOf('('));
|
|
@@ -36,10 +34,7 @@ $('#curva').off('click').click(function(e) {
|
|
var buffer;
|
|
var buffer;
|
|
var valor;
|
|
var valor;
|
|
var array_ids = [];
|
|
var array_ids = [];
|
|
- // var productCurva = $('#product_curva').val();
|
|
|
|
var productCurva = $('#product_curva_qty').val().split(",");
|
|
var productCurva = $('#product_curva_qty').val().split(",");
|
|
- // console.log(productCurva);
|
|
|
|
- // console.log(productCurva);
|
|
|
|
for (i = 1; i < variant.length - 1; i++) {
|
|
for (i = 1; i < variant.length - 1; i++) {
|
|
valor = variant[i];
|
|
valor = variant[i];
|
|
if (valor == ',') {
|
|
if (valor == ',') {
|
|
@@ -49,7 +44,11 @@ $('#curva').off('click').click(function(e) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- indexOfValue = attributeList.indexOf('[' + valor + ']');
|
|
|
|
|
|
+ if(attribute_color == undefined){
|
|
|
|
+ indexOfValue = attributeList.indexOf('[' + valor + ']');
|
|
|
|
+ }else{
|
|
|
|
+ indexOfValue = attributeList.indexOf('[' + valor + ', ' + attribute_color);
|
|
|
|
+ }
|
|
buffer = '';
|
|
buffer = '';
|
|
for (j = indexOfValue - 2; j >= 0; j--) {
|
|
for (j = indexOfValue - 2; j >= 0; j--) {
|
|
var charValue = attributeList.charAt(j);
|
|
var charValue = attributeList.charAt(j);
|
|
@@ -66,16 +65,12 @@ $('#curva').off('click').click(function(e) {
|
|
array_ids.sort(function(a, b) {
|
|
array_ids.sort(function(a, b) {
|
|
return a - b
|
|
return a - b
|
|
});
|
|
});
|
|
- console.log(array_ids);
|
|
|
|
for (var j = 0; j < array_ids.length; j++) {
|
|
for (var j = 0; j < array_ids.length; j++) {
|
|
var add_qty = productCurva[j];
|
|
var add_qty = productCurva[j];
|
|
- // if (productCurva == 'c1') {
|
|
|
|
- if (j == 0 || j == array_ids.length - 1) {
|
|
|
|
- add_qty = 1;
|
|
|
|
- }
|
|
|
|
- var data = '&product_id=' + array_ids[j] + '&add_qty=' + add_qty;
|
|
|
|
- // }
|
|
|
|
- console.log(data);
|
|
|
|
|
|
+ if (j == 0 || j == array_ids.length - 1) {
|
|
|
|
+ add_qty = 1;
|
|
|
|
+ }
|
|
|
|
+ var data = '&product_id=' + array_ids[j] + '&add_qty=' + add_qty;
|
|
$.ajax({
|
|
$.ajax({
|
|
url: '/shop/cart/update',
|
|
url: '/shop/cart/update',
|
|
type: 'POST',
|
|
type: 'POST',
|