1. Sửa file catalog/controller/product/category.php
Tìm dòng:
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
Thêm vào trước đó đoạn code sau:
$this->data['action'] = $this->url->link('checkout/cart');
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->data['redirect'] = HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . $url;
2. Sửa file catalog/view/theme/<YOUR THEME>/template/product/category.tpl
Tìm dòng:
<div class="cart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
Thay thế bằng đoạn code:
<div class="cart">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="product_<?php echo $product['product_id']; ?>">
<div style="display: inline; text-align: center;">
<?php echo $text_quantity; ?> <input type="text" name="quantity" size="3" value="1" />
<a onclick="$('#product_<?php echo $product['product_id']; ?>').submit();" class="button"><span><?php echo $button_cart; ?></span></a>
<input type="hidden" name="product_id" value="<?php echo $product['product_id']; ?>" />
<input type="hidden" name="redirect" value="<?php echo str_replace('&', '&', $redirect); ?>" />
</div>
</form>
</div>
Kết quả sẽ được giống như hình sau: