Jump to content

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Sorry about my knowledge, but where in prestashop you define that an product is 10 quantities?

i really need that the 10 quantities would be normally visible in the final order

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I needed also this feature,  but solved it using the customization fields from Prestashop  (1.6)

Not the best solution, but the customization fields are not being used in my shop, so it's fine for me.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

product.tpl, just find the input with name="quantity" and replace it with that

Share this post


Link to post
Share on other sites

Nice tip!

Do you know how to make another Add to cart button but with 2 quantity value? I want to highlight the offer (more then 2 products = discount 10%). 

Share this post


Link to post
Share on other sites

2 quantity values? What do you mean exactly? Having it pre-loaded with quantity=2 ?

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

Well it's a submit, so unless you use some javascript to prevent it from post, no

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

product.js, around line 365 of the default template:

 

$(document).on('click', '.product_quantity_up', function(e){
	e.preventDefault();
...

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

Hi,
@stdeykun Can you give me a code with the change? I cannot solve it myself in presta 1.7. How did you use step property?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More