Post by tudibillo » Mon Aug 24, 2020 9:48 pm

Hi there,

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
Last edited by tudibillo on Thu Aug 27, 2020 8:25 pm, edited 1 time in total.

Newbie

Posts

Joined
Mon Aug 24, 2020 9:39 pm

Post by grgr » Tue Aug 25, 2020 9:23 pm

On the basis that is exactly what the step does then if you use the minimum as your first step value then you could do:

Code: Select all

<input type="number" step="<?php echo $minimum; ?>"
Then of course you need to prevent manual input in the to box and prevent update in the cart, so not really the solution that you require.

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.

-

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by letxobnav » Tue Aug 25, 2020 11:41 pm

in html5 setting a step would actually not allow you to manually enter a value between the steps but I think that only works with a standard submit button on the form.
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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by tudibillo » Wed Aug 26, 2020 4:00 am

Dear grgr,

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!

Newbie

Posts

Joined
Mon Aug 24, 2020 9:39 pm

Post by khnaz35 » Wed Aug 26, 2020 9:48 pm

tudibillo wrote:
Wed Aug 26, 2020 4:00 am
Dear grgr,

thank you very much! That worked fine. I did the change in the product.twig as you suggested and now it works fine!
That's great! kindly add word [SOLVED] in the beginning of your post title.
Thanks

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by letxobnav » Wed Aug 26, 2020 10:17 pm

I have no clue where to add these lines. After the step changes of the twig file?
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.
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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by tudibillo » Thu Aug 27, 2020 2:58 am

letxobnav wrote:
Wed Aug 26, 2020 10:17 pm
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.
No, your are right. It would be great to prevent customers to enter quantities that doesn't match to the minimum.

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.

Newbie

Posts

Joined
Mon Aug 24, 2020 9:39 pm

Post by letxobnav » Thu Aug 27, 2020 8:39 am

the cart controller does not pass that by default:

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'],
then you can add minimum to the view

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));
			}
with language definition:

Code: Select all

$_['error_quantity_out_of_step']            = 'Quantity in steps of %s, nearest valid values are %s and %s';
you still need to add the error handling for this in the product view ajax javascript to show that error.

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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by tudibillo » Thu Aug 27, 2020 8:28 pm

Thank you so much!! That works fine enough for me.

Thank you for your time and explanations!

Newbie

Posts

Joined
Mon Aug 24, 2020 9:39 pm

Post by pstruh » Fri Jan 22, 2021 7:50 pm

Hi,
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>
                

Newbie

Posts

Joined
Sun Apr 07, 2013 6:44 pm
Who is online

Users browsing this forum: Baidu [Spider] and 9 guests