This is an Opencart guide to create a dropdown of the quantity field of product in Cart Page Opencart 2.2.
Download Dropdown Quantity of Product in Cart Page Opencart 2.2
Features:
- Instead of the textbox, select box shows in the quantity field of Cart.
- When you change quantity options then the cart will update automatically.
- Also, have a delete button.
First, open system\library\cart\cart.php and find the following lines of code:
$product_data[] = array( 'cart_id' => $cart['cart_id'], 'product_id' => $product_query->row['product_id'],
Below these lines of code add the following line:
'product_quantity' => $product_query->row['quantity'],
Second open controller catalog\controller\checkout\cart.php and find the following lines of code:
$data['products'][] = array( 'cart_id' => $product['cart_id'],
Below these lines of codes add the following line:
'product_quantity'=>$product['product_quantity'],
At last find following lines of code at catalog/view/theme/YOUR_ACTIVATED_THEME/template/checkout/cart.tpl
Replace with the following code:
Output:
Please bear with that CSS and hope you will make changes to that CSS as per your theme.
Similarly, we would have provided OCMOD, but because of laziness, we always go through logics :).
Enjoy it, hope we will soon launch OCMOD for all of you.
Thanks
Rupak Nepali