Does anyone have a solution on how to display the cart product Quantity count in featured, Latest, Product Listing page, etc? I need to show How much quantity in the cart the customer already has.
so how can add this easily?
Note: I attached Featured Screenshot AS Well (For Better Understanding)
Could anyone please help me out?
Thanks in advance!
Working example how to add product quantity to category...
In catalog/controller/product/category.php
find:
$data['products'][] = array(
add before:
$cart_quantity = '';
if ($this->cart->hasProducts()) {
$cart_products = $this->cart->getProducts();
foreach ($cart_products as $cart_product) {
if (isset($cart_product['product_id']) && $result['product_id'] == $cart_product['product_id']) {
$cart_quantity = $cart_product['quantity'];
}
}
}
after $data['products'][] = array(
add:
'cart_quantity' => $cart_quantity,
in corresponding template file catalog/view/theme/default/template/product/category.twig
find: <div class="product-thumb">
add after:
{% if product.cart_quantity %} <div style=" padding: 10px; position: absolute; z-index: 1000; color: red; font-weight: bold;">In cart: {{ product.cart_quantity }} pcs.</div>{% endif %}
To add to featured, Latest... in the corresponding files do the same.
To add this modifications you must use OCMOD. After this changes will be made, you must in admin refresh modifications and clear the cache.