I am building a new shop for our company with OC 3.0.3.2. As we used magento 1.9 before we are used to quantity increments for our items and we are missing this feature in OC. Also I could not find any good extension to handle this as the MultipleQuantity extensions only show a warning message.
I would prefer if the quantity would raise by the minimum quantity we entered in the various items. We are using the Basel theme which shows buttons to raise und lower the quantity but only by "1". Has anybody an idea how to solve this problem?
I found the following in products.tpl and am wondering if I have to replace the -step="1"- with something to achive it:
<input type="number" step="1" min="<?php echo $minimum; ?>" name="quantity" value="<?php echo $minimum; ?>" id="input-quantity" class="form-control input-quantity" />
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary"><?php if (($qty < 1) && ($stock_badge_status)) { ?><?php echo $basel_text_out_of_stock; ?><?php } else { ?><?php echo $button_cart; ?><?php } ?></button>
</div>
<?php if ($minimum > 1) { ?>
If this file is the wrong place, where could I search for editing the raising steps?
Thanks and in advance,
Dennis
Code: Select all
<input type="number" step="<?php echo $minimum; ?>"
I did have a look for the same thing not long ago and came up with a blank also. Can't remember why I was looking for it now, guess someone must have raised it, may have been a thought that I might add it to he stock check extension. A thought that I guess I promptly dismissed as I could forsee the support required for the exact same reason as mentioned above. Lots of different themes and various different checkouts all presenting different boxes where the quantity could be updated.
I remember, someone emailed an enquiry about it, thought I remembered seeing something before and had a look to send them in that direction, but failed to find anything.
Technically, I don't think it would be that difficult to do with a step function or even a drop down, but you need to prevent manual input wherever that may be, such as the shopping cart and if you have a checkout page with a cart in it also.
I notice you said product.tpl..... you are using oc3.x and it should be .twig files for the templates - you might find that gives you some problems with extensions in the furture, caused me some issues.
-
-
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS
https://www.wufoo.com/html5/minmaxstep-attributes/
in OC you can set the step to the minimum and then validate via:
Code: Select all
if ($quantity % $minimum != 0) {
// $quantity is not a multiple of $minimum
}
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.
thank you very much! That worked fine. I did the change in the product.twig as you suggested and now it works fine!
But you are right, now preventing customers to enter individual numbers would make this solution perfect.
Dear letxobnav,
thank you for your code. But as I am not a programmer I have no clue where to add these lines. After the step changes of the twig file?
Thank you very much!
That's great! kindly add word [SOLVED] in the beginning of your post title.
Thanks
Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature
My point is that in OC's product page, if you set a minimum of 4 and a step equal to the minimum in the view, the up and down buttons will nicely follow 4,8,12,etc.I have no clue where to add these lines. After the step changes of the twig file?
But, you can still enter 3 or 6 or 10 manually and enter that to the cart.
So you would need to validate the entered quantity in the product controller on whether it is a multiple of the minimum.
This also applies to the cart view and controller where you can alter the quantity by the way.
But if that is not the case in your version, disregard this.
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.
No, your are right. It would be great to prevent customers to enter quantities that doesn't match to the minimum.letxobnav wrote: ↑Wed Aug 26, 2020 10:17 pmBut, you can still enter 3 or 6 or 10 manually and enter that to the cart.
So you would need to validate the entered quantity in the product controller on whether it is a multiple of the minimum.
This also applies to the cart view and controller where you can alter the quantity by the way.
But if that is not the case in your version, disregard this.
I came across the cart and saw that there is the rule of minimum and step=minimum not applied. I tried to enter the same code to cart.twig like I did in product.twig but it doesn't make any difference. In the cart customers can still enter unvalid quantites.
Code: Select all
$data['products'][] = array(
'cart_id' => $product['cart_id'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'recurring' => $recurring,
'quantity' => $product['quantity'],
'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
you need to add:
Code: Select all
'minimum' => $product['minimum'],
the cart does use a normal form submit so the form itself should do the validation which is nice.
for the product page we do the validation in the checkout/cart class add funtion after adding hidden fields for minimum and quantity step in the view form
Code: Select all
// validate quantity steps and minimum
if (isset($this->request->post['quantity_step'])) {
$quantity_step = $this->request->post['quantity_step'];
} else {
$quantity_step = 1;
}
if (isset($this->request->post['minimum'])) {
$minimum = $this->request->post['minimum'];
} else {
$minimum = 1;
}
$diff = ($quantity % $quantity_step);
if ($diff != 0) {
$json['error']['quantity'] = sprintf($this->language->get('error_quantity_out_of_step'), $quantity_step, ($quantity - $diff), ($quantity - $diff + $quantity_step));
}
Code: Select all
$_['error_quantity_out_of_step'] = 'Quantity in steps of %s, nearest valid values are %s and %s';
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.
I have exactly the same problem, using Journal theme. Can someone guide me where I need to do modification to make it work ? Many thanks.
In product.twig I have found config below but I dont know how to achieve to increase steps with + - buton like 5,10,15 based on product minimum quantity.
Code: Select all
<div class="button-group-page">
<div class="buttons-wrapper">
<div class="stepper-group cart-group">
{% if j3.settings.get('catalogCartStatus') %}
<div class="stepper">
<label class="control-label" for="product-quantity">{{ entry_qty }}</label>
<input id="product-quantity" type="text" name="quantity" value="{{ journal3_product_quantity > 0 ? journal3_product_quantity : minimum }}" data-minimum="{{ minimum }}" class="form-control"/>
<input id="product-id" type="hidden" name="product_id" value="{{ product_id }}" />
<span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</span>
Users browsing this forum: Baidu [Spider] and 9 guests