Fórum OpenCart Brasil

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

Suporte para módulos, formas de pagamentos e formas de envio para OpenCart v1.x.
#54950
Aparentemente é simples apenas faltou a tag <script type="text/javascript"> no inicio do código abaixo;

Em vez de:

$('#button-cart').bind('click', function() {

Deve ficar

<script type="text/javascript">
$('#button-cart').bind('click', function() {
#54952
ARQUIVO XML VQMOD
Código: Selecionar todos
	<file name="catalog/view/theme/*/template/product/product.tpl">
		<operation>
			<search position="before" offset="1"><![CDATA[
				$('#button-cart').bind('click', function() {
			]]></search>
			<add><![CDATA[
				<!--CALCULA FRETE-->
				<?php if ($shipping): ?>
				<script type="text/javascript"><!--
					
				//Adiciona Mascara no Campo cepDestino
				$("#postcode").mask("99999-999");

				//Aplica CSS na div postcode
				$("#postcode").css({
					'width':'100px'
				});
				
				//Aplica CSS na div calcula_cep
				$("#calcula_cep").css({
					'border-bottom':'1px solid #E7E7E7',
					'border-top':'0px solid #E7E7E7',
					margin:'0 0 20px 0',
					padding:'0 0 15px 0'
				});

				//Aplica CSS na div resultado e aviso
				$("#resultado, #aviso").css({
					display:'none',
					padding:'10px 0 0'
				});

				//Quando o botão calcular for clicado
				$("#calcular").click (function () {
					//Envia a solicitação via AJAX
					$.ajax({
						url: 'index.php?route=frete/calcula_frete',
						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) {
							if (json['shipping_method']) {
								
								if (json['shipping_method']) {
									html  = '<h2><?php echo $calculaFrete_titulo ?></h2>';
									html += '  <table class="radio">';
									
									for (i in json['shipping_method']) {
										html += '<tr>';
										html += '  <td colspan="3"><b>' + json['shipping_method'][i]['title'] + '</b></td>';
										html += '</tr>';
									
										if (!json['shipping_method'][i]['error']) {
											for (j in json['shipping_method'][i]['quote']) {
												html += '<tr class="highlight">';
												
												html += '<td><input type="hidden" /></td>';
													
												html += '  <td><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['title'] + '</label></td>';
												html += '  <td style="text-align: right;"><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['text'] + '</label></td>';
												html += '</tr>';
											}		
										} else {
											html += '<tr>';
											html += '  <td colspan="3"><div class="error">' + json['shipping_method'][i]['error'] + '</div></td>';
											html += '</tr>';						
										}
									}
									
									html += '  </table>';
									html += '  <br />';
									
									$.colorbox({
										overlayClose: true,
										opacity: 0.5,
										width: '600px',
										href: false,
										html: html
									});
								}
								
							}
						}
					});
					
					return false;
				});

				//--></script>
				<?php endif; ?>
				<!-- FIM CALCULA FRETE-->
			]]></add>
		</operation>
	</file>

ARQUIVO (/public_html/catalog/view/theme/theme0/template/product/product.tpl) onde recebe o código
Código: Selecionar todos
<script type="text/javascript"><!--
  
  $('select[name="profile_id"], input[name="quantity"]').change(function(){
    $.ajax({
		url: 'index.php?route=product/product/getRecurringDescription',
		type: 'post',
		data: $('input[name="product_id"], input[name="quantity"], select[name="profile_id"]'),
		dataType: 'json',
        beforeSend: function() {
            $('#profile-description').html('');
        },
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
            
			if (json['success']) {
                $('#profile-description').html(json['success']);
			}	
		}
	});
});
  
$('#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']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<span><i class="fa fa-times-circle"></i></span></div>');
					
				$('.success').fadeIn('slow');
					
				$('#cart-total').html(json['total']);
				$('#cart-total2').html(json['total']);
				$('#cart').load('index.php?route=module/cart #cart > *');
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
			setTimeout(function() {$('.success').fadeOut(1000)},3000)
		}
	});
});
//--></script>