Jump to content

Product Combinations -> QUANTITY (Specific for combinations) - tpl


hellykun

Recommended Posts

Dear Prestashop users,

 

There are many questions for this matter and I would like to also post mine.

As far as I have seen there is not a sufficient answer to that.

 

I am using Prestashop 1.5 and I have some products with combinations.

 

We have developed a specific system to check the availability of each product based on its combination.

The problem is that if the product has combinations then the quantity is the sum of all the combinations.

 

For example

 

I have a PRODUCT with 2 combinations

 

Combination 1 = 10 pieces

Combinations 2 = 15 pieces

 

If quantity = 10 pieces then the availability should be low

If quantity = 15 pieces then the availability should be middle

 

but the result is quantity = 25 pieces which means high

 

 

Is it possible to get a combinations specific quantity within a TPL file?

 

Thanks a lot in advance

Link to comment
Share on other sites

  • 2 weeks later...

Absolutely!

 

We have two files

 

product.tpl

 

and product.js

 

First, in product.js you can get the combination number with this code below for example

			
		selectedCombination['quantity'] = combinations[combination]['quantity'];
		
		if (selectedCombination['quantity'] <= 0){

	$('#availability').html(HERE INSERT YOUR HTML CODE);
		
}else if (selectedCombination['quantity'] >= 23){

$('#availability').html(HERE INSERT YOUR HTML CODE);

}else if (selectedCombination['quantity'] >= 100){

$('#availability').html(HERE INSERT YOUR HTML CODE);

}
			
			

then in product.tpl you should add a specific #availability [iD to your div or span or whatever you want] to display what you want. for example 

{if isset($groups)} <!-- this checks if there are combinations -->
<span id="availability"></span> <!-- this shows the html text of $('#availability').html  -->
		
			{else}

DO what you are supposed to do

I hope I have helped!

Link to comment
Share on other sites

  • 1 month later...

Absolutely!

 

We have two files

 

product.tpl

 

and product.js

 

First, in product.js you can get the combination number with this code below for example

			
		selectedCombination['quantity'] = combinations[combination]['quantity'];
		
		if (selectedCombination['quantity'] <= 0){

	$('#availability').html(HERE INSERT YOUR HTML CODE);
		
}else if (selectedCombination['quantity'] >= 23){

$('#availability').html(HERE INSERT YOUR HTML CODE);

}else if (selectedCombination['quantity'] >= 100){

$('#availability').html(HERE INSERT YOUR HTML CODE);

}
			
			

then in product.tpl you should add a specific #availability [iD to your div or span or whatever you want] to display what you want. for example 

{if isset($groups)} <!-- this checks if there are combinations -->
<span id="availability"></span> <!-- this shows the html text of $('#availability').html  -->
		
			{else}

DO what you are supposed to do

I hope I have helped!

 

In what line of product.js you put the code?

Link to comment
Share on other sites

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

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...