Please can someone help me on how to add dropdown to Product Quantity.
Below is the code I found in my product.twig
<input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity" class="form-control" />
Thanks.....
Code: Select all
<input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity" class="form-control" />
Code: Select all
<select name="quantity" id="input-quantity" class="form-control" />
<option value="{{ minimum }}">{{ minimum }}</option>
</select>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thanks
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Code: Select all
<option value="2">2</option>
<option value="3">3</option>
<option value="3">3</option>
Thanks
seanstorm100 wrote: ↑Sat Apr 11, 2020 11:40 amHey straightlight, I am using version 3.0.3.2 Default theme, this only shows the minimum quantity in the dropdown. How can I get it to display a range? Like 1 through to 10?
Thanks
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Code: Select all
{% for i in minimum..10 %}
* <option value="{{ i }}">{{ i }}</option>
{% endfor %}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Thanks I will test and get back to you!
letxobnav wrote: ↑Sat Apr 11, 2020 4:33 pmyou could try:
Code: Select all
{% for i in minimum..10 %} * <option value="{{ i }}">{{ i }}</option> {% endfor %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
It started at the minimum, however, the numbers are no longer in a dropdown but a printed just text on the page.
See image:
https://pasteboard.co/J3jLPv3.png
seanstorm100 wrote: ↑Sat Apr 11, 2020 9:18 pmHey letxobnav,
Thanks I will test and get back to you!
letxobnav wrote: ↑Sat Apr 11, 2020 4:33 pmyou could try:
Code: Select all
{% for i in minimum..10 %} * <option value="{{ i }}">{{ i }}</option> {% endfor %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Code: Select all
<select name="quantity" id="input-quantity" class="form-control" />
{% for i in minimum..10 %}
* <option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
letxobnav wrote: ↑Sat Apr 11, 2020 10:50 pmyou have to put the select around it.
Code: Select all
<select name="quantity" id="input-quantity" class="form-control" /> {% for i in minimum..10 %} * <option value="{{ i }}">{{ i }}</option> {% endfor %} </select>
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
I haven't tested as yet, just a thought... Even though we have the drop down starting at minimum and ends at 10... The way my store was set up was to disable adding to cart what we dont have. So for example we have 3 in stock you cannot add 4. We I used custom code to display stock under 10 and counting down but over 10 it shows In Stock. My question ials, is it possible to start at minimum but if the stock is below 10 it shows the number they can add to cart? So if we have 4 in stock and order minimum is 2 the dropdown will show 2,3,4 but if we have 11 or more in stock they see minimum to 10 in quantity drop down.
Please let me know.
Thank you
seanstorm100 wrote: ↑Sat Apr 11, 2020 9:28 pmHi letxobnav,
It started at the minimum, however, the numbers are no longer in a dropdown but a printed just text on the page.
See image:
https://pasteboard.co/J3jLPv3.png
seanstorm100 wrote: ↑Sat Apr 11, 2020 9:18 pmHey letxobnav,
Thanks I will test and get back to you!
letxobnav wrote: ↑Sat Apr 11, 2020 4:33 pmyou could try:
Code: Select all
{% for i in minimum..10 %} * <option value="{{ i }}">{{ i }}</option> {% endfor %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
letxobnav wrote: ↑Sat Apr 11, 2020 10:50 pmyou have to put the select around it.
Code: Select all
<select name="quantity" id="input-quantity" class="form-control" /> {% for i in minimum..10 %} * <option value="{{ i }}">{{ i }}</option> {% endfor %} </select>
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
in your controller you would add a maximum variable to be passed to the view just like minimum.
Code: Select all
if ($product_info['minimum']) {
$data['minimum'] = $product_info['minimum'];
} else {
$data['minimum'] = 1;
}
Code: Select all
if ($product_info['quantity'] > 0) {
if ($product_info['quantity'] > 10) {
$data['maximum'] = 10;
} else {
$data['maximum'] = $product_info['quantity'];
}
} else {
$data['maximum'] = 1;
}
then use maximum in the view.
Code: Select all
{% for i in minimum..maximum %}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
letxobnav wrote: ↑Sun Apr 12, 2020 9:03 amgood, for the maximum.
in your controller you would add a maximum variable to be passed to the view just like minimum.Code: Select all
if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; }
depending on what you want to display if there is no stock.Code: Select all
if ($product_info['quantity'] > 0) { if ($product_info['quantity'] > 10) { $data['maximum'] = 10; } else { $data['maximum'] = $product_info['quantity']; } } else { $data['maximum'] = 1; }
then use maximum in the view.Code: Select all
{% for i in minimum..maximum %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
letxobnav wrote: ↑Sun Apr 12, 2020 9:03 amgood, for the maximum.
in your controller you would add a maximum variable to be passed to the view just like minimum.Code: Select all
if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; }
depending on what you want to display if there is no stock.Code: Select all
if ($product_info['quantity'] > 0) { if ($product_info['quantity'] > 10) { $data['maximum'] = 10; } else { $data['maximum'] = $product_info['quantity']; } } else { $data['maximum'] = 1; }
then use maximum in the view.Code: Select all
{% for i in minimum..maximum %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Is there a way to do the below:
You have 5 Shirts, 2 Red, 3 Blue, 1 Red - Medium, 1 Red - Large, 2 Blue - Small, 1 Blue - Medium
A Customer selects Blue, Small, They see Qty = 5, after added to cart successfully and they try to checkout, it says that we do not have that amount etc...
Is there any way to reveal the quantity based on option selection? So after selecting Blue, Small, Quantity would be 1, 2 (Drop Down) and if they change to lets say blue large, the quantity goes to 1.
Optionally an error can be thrown if we can't achieve this in Quantity (Dropdown) Limitation.
I am looking at this module: https://www.opencart.com/index.php?rout ... n_id=13703
I wanted to know if there's a quick way to do this.
seanstorm100 wrote: ↑Sun Apr 12, 2020 9:28 pmWorked really well, thank you!
letxobnav wrote: ↑Sun Apr 12, 2020 9:03 amgood, for the maximum.
in your controller you would add a maximum variable to be passed to the view just like minimum.Code: Select all
if ($product_info['minimum']) { $data['minimum'] = $product_info['minimum']; } else { $data['minimum'] = 1; }
depending on what you want to display if there is no stock.Code: Select all
if ($product_info['quantity'] > 0) { if ($product_info['quantity'] > 10) { $data['maximum'] = 10; } else { $data['maximum'] = $product_info['quantity']; } } else { $data['maximum'] = 1; }
then use maximum in the view.Code: Select all
{% for i in minimum..maximum %}
Regards,
Nightwing
Access to my Free Extensions: https://www.opencart.com/index.php?rout ... =nightwing
Users browsing this forum: No registered users and 1 guest