Fórum OpenCart Brasil

Por um e-commerce livre, confiável e profissional

Suporte geral sobre problemas técnicos para OpenCart v1.x.
#53227
Arquivo product.tpl

Pós edição......
Código: Selecionar todos
//--></script> 
<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			$('.option input, .option textarea').removeClass("input-error");
			
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i + ' input, #option-' + i + ' textarea').addClass("input-error");
						$('#option-' + i).after('<span class="error" style="clear:both;position:relative;margin-top:8px;padding-bottom:4px">' + json['error']['option'][i] + '</span>');
					}
				}
			} 
			
			    if (json['success']) {
    window.location='index.php?route=checkout/cart';
    }
		}
	});
});
//--></script>

Arquivo Commom.js
Código: Selecionar todos
function addToCart(product_id, quantity) {
	quantity = typeof(quantity) != 'undefined' ? quantity : 1;

	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: 'product_id=' + product_id + '&quantity=' + quantity,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			}
			
			    if (json['success']) {
    window.location='index.php?route=checkout/cart';
    }
		}
	});
}

Não funcionou....
#53233
Troque a função toda no arquivo common.js por:
Código: Selecionar todos
function addToCart(product_id, quantity) {
   quantity = typeof(quantity) != 'undefined' ? quantity : 1;

   $.ajax({
      url: 'index.php?route=checkout/cart/add',
      type: 'post',
      data: 'product_id=' + product_id + '&quantity=' + quantity,
      dataType: 'json',
      success: function(json) {
         if (json['redirect']) {
            location = json['redirect'];
         }else{
            location = 'index.php?route=checkout/cart';
         }
      }
   });
}
E no product.tpl troque por:
Código: Selecionar todos
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
					}
				}
                
                if (json['error']['profile']) {
                    $('select[name="profile_id"]').after('<span class="error">' + json['error']['profile'] + '</span>');
                }
			} 
			
			if (json['success']) {
                                 window.location = 'index.php?route=checkout/cart';
			}	
		}
	});
});
#53261
Olhando o seu tema descobri o por que de nada funcionar, ele não usa o arquivo common.js, usa um criado por eles chamadao jquery-workarrounds.js que possui praticamente o mesmo conteúdo.

Procure a função addToCart nesse arquivo que fica em catalog/view/theme/dilecta/js/jquery-workarrounds.js e altere a linha que tinha lhe falado para alterar no common.js anteriormente.
#53266
Sensacional..... Vilson569 só posso agradecer, deu certo.
Agradeço o empenho em me ajudar a resolver a questão, dou o tópico por resolvido e agradeço a todos pela ajuda e tentativa em solucionar a questão, em especial o amigo vilson569.
Boa tarde para todos.