2016-04-27 5 views
0

Ich arbeite an einer Version 2.2 von OpenChart (OC), und ich bin neu in OC, und ich möchte Quantity Box in Kategorie Seiten und vorgestellten Produkte Teile hinzufügen.Wie man Quantity Box in Kategorie Seiten opencart 2.2

Also habe ich versucht, diesen Code von theme/default/template/product/product.tpl zu kopieren, weil ich das gleiche Ergebnis wollen, die OC in Produktseite angewendet haben.

<label class="control-label" for="input-quantity"><?php echo $entry_qty; ?></label> 
      <input type="text" name="quantity" value="<?php echo $minimum; ?>" size="2" id="input-quantity" class="form-control" /> 
      <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" /> 

und versuchte es in theme/default/template/product/category.tpl Seite unten Preis einzufügen bekam aber einen Fehler Undefined variable.

Von R & D Ich habe erfahren, dass ich es in catalog/controller/category.tpl Seite auch aktualisieren muss. Ich weiß nicht, was ich machen soll.

Bitte helfen Sie mir. Vielen Dank im Voraus.

+0

Mögliche Duplikat [Öffnen Wagen Version 2, Menge auf Kategorie Anzeigen abgelegter] (http://stackoverflow.com/questions/28642992/open-cart-version-2-quantity-filed -on-category-view) – billynoah

Antwort

2

Sie folgende Änderungen ersetzen in

category.tpl

Code Ersetzen mit folgenden

<div class="image"><a href="<?php echo $product['href']; ?>" id="location-<?php echo $product['product_id']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></a></div> 

Add folgenden Code vor ‚div class = "Taste-Gruppe" > '

<div class="form-group"> 
    <label class="control-label" for="input-quantity">Qty</label> 
    <input type="text" name="quantity" value="<?php echo $product['minimum']; ?>" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control" /> 
    </div> 

Änderung folgenden Code

<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> 

zu folgenden

<button type="button" onclick="addTocart('<?php echo $product['product_id']; ?>')"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button> 

Javascript hinzufügen vor

<script type="text/javascript"> 
function addTocart(product_id){ 
    var product_id = product_id; 
    var qty = $('#input-quantity-'+product_id).val(); 
    var location = $('#location-'+product_id).attr('href'); 
    $.ajax({ 
     url: 'index.php?route=checkout/cart/add', 
     type: 'post', 
     data: 'product_id='+product_id+'&quantity='+qty, 
     dataType: 'json', 
     beforeSend: function() { 
      $('#button-cart').button('loading'); 
     }, 
     complete: function() { 
      $('#button-cart').button('reset'); 
     }, 
     success: function(json) { 
      $('.alert, .text-danger').remove(); 
      $('.form-group').removeClass('has-error'); 

      if (json['error']) { 
       if (json['error']['option']) { 
        window.location = location; 
       } 

       if (json['error']['recurring']) { 
        window.location = location; 
       } 

       // Highlight any found errors 
       $('.text-danger').parent().addClass('has-error'); 
      } 

      if (json['success']) { 
       $('.breadcrumb').after('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>'); 

       $('#cart > button').html('<i class="fa fa-shopping-cart"></i> ' + json['total']); 

       $('html, body').animate({ scrollTop: 0 }, 'slow'); 

       $('#cart > ul').load('index.php?route=common/cart/info ul li'); 
      } 
     }, 
     error: function(xhr, ajaxOptions, thrownError) { 
      alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 
     } 
    }); 
} 
</script> 

Prost

+0

Vipul, ich werde dieses Ding später versuchen, ich habe einen Fehler in vqmod, könntest du mir bitte dabei helfen http://stackoverflow.com/questions/36908035/vqmod-logs-open-cart-error – Adi

+0

@Adi Mein Code funktioniert, dann gib mir mal whote zu mir. –

+0

Ya werde ich sicherlich geben. Eine weitere Sache, die ich Sie fragen muss, ist, dass ich eine Erweiterung installiert habe, die "Gewichtung auswählen" in der Kategorieseite ist, also, wenn ich diesen Code redigiere, dann schadet es der Erweiterungsfunktionalität? – Adi

Verwandte Themen