Jump to content

Step Quantities


Recommended Posts

Hello,

 

How can you configure Prestashop to use step quantities in a specific product.

on step quantities i mean that a specific product only can be sold in pack of 10 units, so the client will only have the ability to select 10, 20, 30, 40, .....

even when you press the "+" button, the quantity will increase whatever is defined in product specifications. in this case 10.

 

Thanks in advance

 

Rui Banha

Link to comment
Share on other sites

Why don't instead of creating a product with 1 item, you don't specify that its a pack of 10?

A qty of 1 would correspond to 10 itens (and the price would be of the 10 itens, of course).

The name could be product x (pack 10)...

  • Like 1
Link to comment
Share on other sites

As far as i know there isn't.

What i was trying to say is when you create/update a product you can call it comething like "Product A (10 Pack)".

If you have 100 to sell, you place only 10 in the quantity field.

Everytime someone buys 1, it will get 10 of product a.

 

There's a minimal quantity (in the product edit page). But if you set at 10, someone can buy 11.

 

Another way would be to create a pack (in the product edit page you get 3 options Product, Pack or Virtual Product).

And you can set a pack to have 10 of an existing product.

But you still would require the unit product to be available.

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Use input type number. It's an html5 tag, simply write

 

<input type="number" name="quantity" min="0" max="15" step="5">

of course, you need a proper html doctype declaration

Hi Nemo:

Can you explain a little more. Where do you write that?

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Ah, yes, on the links, just use '&qty=2' or 3. If you use the ajax cart, you will have to modify ajax-cart.js though, following the steps described here

http://nemops.com/prestashop-cart-multiple-products-quantities/#.VRum3vnQqr0

I'm using PS 1.6.0.1.4

I've made a childish modification, in my own way  :ph34r:

Take a look to the code

<div id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
							<label class="qty-label">{l s='Quantity'}:</label>
							<div class="quantity-input-wrapper">
							<input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" />
							<a href="#" data-field-qty="qty" class="transition-300 product_quantity_down">
								<span><i class="icon-caret-down"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="transition-300 product_quantity_up ">
								<span><i class="icon-caret-up"></i></span>
							</a>
							</div> 
							
							<!-- Butoane reducere -->
							{if !$content_only}
								{if (isset($quantity_discounts) && count($quantity_discounts) > 0)}
								<br><br><button type="submit" name="qty" id="quantity_wanted2 add_to_cart2" class="exclusive2 buttons_bottom_block no-print" value="2">
									<span>Adauga 2 produse <br><b>si ai reducere 10%</b></span>
								</button>
								{/if} 
							{/if}
								<!-- end butoane --> 
								<span class="clearfix"></span>
						</div>

To my surprise, IT WORK. But it's just a problem  :unsure: When i add with this button i'm redirected on /index.php?controller=order-opc

I dont know how to make to stay on the same page, like a normal Add to cart action.

Edited by florin.dediu (see edit history)
Link to comment
Share on other sites

  • 1 year later...

I am halfway there. Using the minimum qty as step.

<input type="number" min="0" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" step="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}"  max="1000" />

Now it is the + and - buttons thats needs to be fixed.

Link to comment
Share on other sites

  • 1 year later...

I did this in Prestashop 1.7 classic theme by replacing default quantity touchSpin in:

  • /checkout/_partials/cart-detailed-product-line.tpl
  • /catalog/_partials/product-add-to-cart.tpl - this one is used in quick view too so be aware of that

 

Input number paramaters are:

min="{$product.minimal_quantity}"
step="{$product.minimal_quantity}"

 

In cart-detailed-product-line.tpl touchSpin selector is on input[name] (product-quantity-spin) so you should change selector (e.x. add extra class) in \themes\classic\_dev\js\cart.js

var spinnerSelector = 'input[name="product-quantity-spin"]';

 

I tried to use $().touchSpin() step property, but in cart butons +, - trigger different events.

 

You can hide default input[number] arrows with:

.input-number {
  -moz-appearance:textfield;
}

.input-number::-webkit-inner-spin-button,
.input-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

 

If someone change input value by typing and value is between steps you can correct this using function below:

function roundStep(number, step, min) {
    return Math.round((number - min) / step ) * step + min;
}

 

Edited by stdeykun (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

I have figured this out and because this is the first result when i googled "prestashop order quantity step", i thought ill leave my solution here.
My Presta version: 1784

  • The file i have modified:
    • In /public_html/themes/classic/templates/catalog/_partials/product-add-to-cart.tpl
    • or search for the file that contents #quantity_wanted input
  • Add this data tag
    • data-step="10" for a fixed amount
    • or data-step="{$product.minimal_quantity}" because im using the minimal_quantity in BO as the step amount
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
On 11/14/2022 at 9:22 PM, [email protected] said:

I have figured this out and because this is the first result when i googled "prestashop order quantity step", i thought ill leave my solution here.
My Presta version: 1784

  • The file i have modified:
    • In /public_html/themes/classic/templates/catalog/_partials/product-add-to-cart.tpl
    • or search for the file that contents #quantity_wanted input
  • Add this data tag
    • data-step="10" for a fixed amount
    • or data-step="{$product.minimal_quantity}" because im using the minimal_quantity in BO as the step amount

Gracias por el aporte! lo estaba buscando!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...