Jump to content

Change quantity with buttons


Recommended Posts

Hi,

I want to add 2 buttons to my product page, what can increase and decrease the quantity value.

I add this javascript to my page:

 

 

<script type="text/javascript">

$(document).ready(function(){

$('.qty_up img').on('click',function(){

$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())+1);

});

$('.qty_down img').on('click',function(){

$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())-1);

});

});

</script>

 

and this code to product.tpl

 

<span class="qty_down floatleft"><img src="{$img_dir}/qty_down.png" width="18" height="18" alt="" title="" /></span>

<span class="qty_up floatleft"><img src="{$img_dir}/qty_up.png" width="18" height="18" alt="" title="" /></span>

 

This works well, but there is a problem.

The price is not updated.

So when i click the increase button the quantity value is increased, when i add to cart the right value added...

But if the price is 100EUR and increase the qty to 2 the price still 100EUR.

Can anybody help me?

Thanks

Link to comment
Share on other sites

  • 2 months later...

Hello,

I using PS 1.5.4.1 I have added your code to product.tpl and it works like a charm. It adds the right amount of items to the cart. I was not able to dupliate your error. Number if items and price are currect in the cart ajax and the cart page and checkout.

 

On the same note, I have made some updates to your javascript code. I have added code to check if the value is NaN (not a real number), and if reducing values, then not to reduce below 1.

 

Here is the entire code:

  <!-- quantity wanted -->
  <p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>
   {literal}
 <script type="text/javascript">
  $(document).ready(function(){
   $('#quantity_wanted').val(1);
   $('.qty_up img').on('click',function(){
    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
    else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())+1);}
   });
   $('.qty_down img').on('click',function(){
    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
    else {  if(parseInt($('#quantity_wanted').val())<=1){  }
	  else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())-1);[spam-filter]
   });
  });
 </script>
   {/literal}
   <label>
 {l s='Quantity:'}
   </label>
   <span class="qty_down floatleft">
 <img src="{$img_dir}/minus.jpg" width="12" height="12" alt="" title="" />
   </span>
   <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}"
  size="2"
  maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />
   <span class="qty_up floatleft">
 <img src="{$img_dir}/plus.jpg" width="12" height="12" alt="" title="" />
   </span>
  </p>

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...
  • 2 weeks later...
  • 2 weeks later...

somewhere on forum i pasted solution for this

unfortunately i can't find it :(

$(document).ready(function(){
$("#quantity_wanted").change(function(){
    $("#our_price_display").html(currencySign+" "+(productPrice*$("#quantity_wanted").val()));
});
});

use it somewhere in product.js file :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

somewhere on forum i pasted solution for this

unfortunately i can't find it :(

$(document).ready(function(){
$("#quantity_wanted").change(function(){
    $("#our_price_display").html(currencySign+" "+(productPrice*$("#quantity_wanted").val()));
});
});

use it somewhere in product.js file :)

Hey, your solution worked perfectly! Thanks! But can you help me with the way it shows?

 

Now it shows like $60, $120 etc., but I need it to be like this: 60,00 $, 120,00 $, etc.

 

Can you help, please?

Link to comment
Share on other sites

Thanks again! Now it shows me rounded value. But it still shows it with the dot, not a comma.

It shows the value like: 60.00 $, 120.00 $

But it should show the value like: 60,00 $, 120,00 $

 

My currency settings needs this "," instead of ".", and it is used on the whole website and it will be strange if the currency format will change after user's actions.

Do you have any idea how to change "." to ","?

Link to comment
Share on other sites

  • 2 weeks later...

Hi Vekia!

 

Thank you for the reply's, but I can't get this solution to work. The price doesn't update.

 

I added the following code to my product.tpl, in the correct themes folder:

   <!-- quantity wanted -->
   <p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>
    {literal}
	 <script type="text/javascript">
	  $(document).ready(function(){
	   $('#quantity_wanted').val(1);
	   $('.qty_up img').on('click',function(){
	    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
	    else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())+1);}
	   });
	   $('.qty_down img').on('click',function(){
	    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
	    else {  if(parseInt($('#quantity_wanted').val())<=1){  }
		  else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())-1);[spam-filter]
	   });
	  });
	 </script>
    {/literal}
    <label>
	 {l s='Quantity:'}
    </label>
    <span class="qty_down floatleft">
	 <img src="{$img_dir}/minus.jpg" width="12" height="12" alt="" title="" />
    </span>
    <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}"
	  size="2"
	  maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />
    <span class="qty_up floatleft">
	 <img src="{$img_dir}/plus.jpg" width="12" height="12" alt="" title="" />
    </span>
   </p>

And I added this code to my product.js in the correct themes folder:

$(document).ready(function(){
$("#quantity_wanted").change(function(){
    $("#our_price_display").html(currencySign+" "+(productPrice*$("#quantity_wanted").val()));
});
});

The quantity buttons do work (but i already had them), but the price doesn't update.

 

I use PS 1.5.6.1.

 

What did I do wrong? Thanks all !!

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

Thank you for the reply! No I'm sorry, I don't have my shop opened yet, the shop remains in maintenance mode for SEO reasons. Everything is still in development.

 

To make it clear: I want to have the price display (so the price of the product, on the product page) updated when I change the quantity field on the product page with the discounts that I made for a certain amount of my product in the back office.

 

Example; i have a discount of 1 euro for my product which applies the customer buys more than 5 pieces. The original product price per piece is 10 euro. So when I change the quantity field on the product page, the displayed price should for 1 until 4 units be: 10 euro. But with 5 pieces or more in the quantity field, the price display should change to: 9 euro. 

 

In the cart this works flawlessly ! The price updates automatically but I try to get the same thing done at the product page. In the product page the price only updates when I change attributes, not when I change quantity. Did I misread anything? I mean: is your line of code made for this purpose?

 

Is there any extra code that I should provide?

 

Do you have any idea what could be missing / what I could be doing wrong?

 

Thx!

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

Update:

 

I tried it now with the original default theme 1.5.6.1.: the original product.tpl file and with the original product.js file.

This made no difference !

 

I have force compile on, cache off, cleaned smarty and autoload cache.

I tried it with 3 different browsers, FF, Chrome, IE with also empty cache.

 

Does the price display update for  anyone else on the product page with this code?? Or does it not work at all?

 

If you have it working: please provide me a link, maybe I can see there what I'm doing wrong. Thanks in advance !

Link to comment
Share on other sites

This doesn't work: http://www.prestashop.com/forums/topic/299907-upgrade-price-when-you-change-the-amount/

 

lui1969 got exactly the same problem.

 

And those people too:

http://www.prestashop.com/forums/topic/290525-quantity-auto-updates-price-on-product-page/

 

http://www.prestashop.com/forums/topic/247557-product-quantity-increase-or-decrease-on-click-on-product-page/

 

http://www.prestashop.com/forums/topic/276869-change-quantity-wanted-also-change-price-on-product-page/

 

This subject remains unsolved.. :( I need it fixed before I launch my store. All my products got quantity discounts..

 

If you could look into the problem Vekia; I would really appreciate it !! (and with me more people!) If I was a coder I would have done it myself (of course) but this is something that I'm not able to do.. it would be helpfull for so many merchants, because this is a "must have feature" for every Prestashop shop owner.

 

Edit: The weirdest of this whole case is, imo, that the shopping-cart-page already got this feature! So the code could be copied / enhanced in some way to get it working for the product pages.

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

Hello, Jan Jansen!

 

I've met the same problem, but I figured out that the code you placed in product.js should be also put to the product.tpl itself if you don't know how to change product.js properly.

Here is the code from my product.tpl:

   <!-- quantity wanted -->
   <p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>
    {literal}
	 <script type="text/javascript">
	  $(document).ready(function(){

	   $('#quantity_wanted').val(1);
	   $('.qty_up img').on('click',function(){
	    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
	    else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())+1);
		$("#our_price_display").html(((productPrice*$("#quantity_wanted").val()).toFixed(2)+" "+currencySign).replace('.',','));}	   
	});
	   $('.qty_down img').on('click',function(){
	    if (isNaN(parseInt($('#quantity_wanted').val()))){$('#quantity_wanted').val(1);}
	    else {  if(parseInt($('#quantity_wanted').val())<=1){  }
		  else {$('#quantity_wanted').val(parseInt($('#quantity_wanted').val())-1);
		$("#our_price_display").html(((productPrice*$("#quantity_wanted").val()).toFixed(2)+" "+currencySign).replace('.',','));[spam-filter]
	   });
	  });
	 </script>
    {/literal}
    <label>
	 {l s='Quantity:'}
    </label>
    <span class="qty_down floatleft">
	 <img src="{$img_dir}minus.png" width="12" height="12" alt="" title="" />
    </span>
    <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}"
	  size="2"
	  maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />
    <span class="qty_up floatleft">
	 <img src="{$img_dir}plus.png" width="12" height="12" alt="" title="" />
    </span>
   </p>

You can find the place to put the code by the starting    <!-- quantity wanted --> string. It should be in the original product.tpl also.

 

But! You need to add changes to the product.js also, because as I figured out, it has the function, which will fire when user will change quantity by typing the amount in the field manually without buttons.

 

Hope it will help.

 

P.S.: be sure to use your currency format, mine is for Ukraine.

Edited by lonlywolf (see edit history)
  • Like 1
Link to comment
Share on other sites

Hi lonlywolf,

 

Thanks a lot !! We've came a lot closer to the solution ! I can now get the total price displayed BUT without the product discounts applied.

 

And the discounts were the main reason for me to get this done...

 

Example: I give discount to my products when people buy an "x amount" of my product. I want to have the discount applied to the final displayed product price. The price that is displayed now is incorrect; because discounts are not calculated / included in the final price.

 

Any input is much appreciated!! Thx all !

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

A other question:

 

How can I move the € sign in front the price-display? When I click on the quantity buttons now the € sign jumps to the back of the price display.

 

I think I need to change these 2 lines:

$("#our_price_display").html(((productPrice*$("#quantity_wanted").val()).toFixed(2)+" "+currencySign).replace('.',','));}	   

and

$("#our_price_display").html(((productPrice*$("#quantity_wanted").val()).toFixed(2)+" "+currencySign).replace('.',','));[spam-filter]

Any information regarding the € sign and, of course ! the calculation of the product discounts in the final price display is highly appreciated. Thanks everyone!

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

This is getting even more complex. :( The attributes are also not working with this solution. Only the original product price gets doubled by adding quantities.

 

Now this feature need support for:

 

- Quantity discounts

- Attributes

 

It's still a must have feature for my shop, and I think for a lot of other Prestashop-shop-owners too.

Link to comment
Share on other sites

  • 1 month later...

Hi all. I made a small change to the code, I changed the "change" event with "input", in this way, this would fire every time the input changes.

$(document).ready(function(){
$("#quantity_wanted").on("input",function(){
	var price=productPrice*$("#quantity_wanted").val();
	price=price.toFixed(2);
	price=price.replace('.',',');
    $("#our_price_display").html((price+" "+currencySign));
});
});

Now I have a little problem.

 

This function recalculates the price based on the price of the product and not according with the attributes selected, because productPrice variable is always the base price of the product.

 

Is there a way or a different variable which should I use?

 

My english really sucks, I hope I explained myself

Link to comment
Share on other sites

with this price change according with attribute...

I copy and paste the function of ps that was already there.

Specific prices still do not change.

 

it is clear that if someone finds a better solution, it is better...

$(document).ready(function(){
$("#quantity_wanted").on("input",function(){
	if (!selectedCombination['unavailable'] && productShowPrice == 1){
		var priceTaxExclWithoutGroupReduction = '';

		// retrieve price without group_reduction in order to compute the group reduction after
		// the specific price discount (done in the JS in order to keep backward compatibility)		
		priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);

		var tax = (taxRate / 100) + 1;
		var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);

		if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute'])
		{
			if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0)
				var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate);
			else
				var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate);
		}
		else if (product_specific_price.price && product_specific_price.price >= 0)
			var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate);

		if (!displayPrice && !noTaxForThisProduct)
			productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var
		else
			productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var

		productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction;
		var reduction = 0;
		if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
		{
			reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate);
			reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price;
			if (reduction_price && (displayPrice || noTaxForThisProduct))
				reduction = ps_round(reduction / tax, 6);

		}
		else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
		{
			if (product_specific_price.reduction_type == 'amount')
				reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
			else
				reduction_price = 0;

			if (product_specific_price.reduction_type == 'percentage')
				reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction);

			reduction = reduction_price + reduction_percent;
			if (reduction_price && (displayPrice || noTaxForThisProduct))
				reduction = ps_round(reduction / tax, 6);
		}

		if (selectedCombination.specific_price)
		{
			if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage')
			{
				$('#reduction_amount').hide();
				$('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');
				$('#reduction_percent').show();
			} else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) {
				$('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank));
				$('#reduction_percent').hide();
				$('#reduction_amount').show();
			} else {
				$('#reduction_percent').hide();
				$('#reduction_amount').hide();
			}
		}

		if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
			$('#discount_reduced_price,#old_price').show();
		else
			$('#discount_reduced_price,#old_price').hide();
		if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage')
			$('#reduction_percent').show();
		else
			$('#reduction_percent').hide();
		if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price']))
			$('#not_impacted_by_discount').show();
		else
			$('#not_impacted_by_discount').hide();

		productPriceDisplay -= reduction;
		productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);

		var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];

		if (ecotaxAmount != default_eco_tax)
			productPriceDisplay += ecotaxAmount - default_eco_tax;
		else
			productPriceDisplay += ecotaxAmount;

		if (ecotaxAmount != default_eco_tax)
			productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax;
		else
			productPriceWithoutReductionDisplay += ecotaxAmount;

		var our_price = '';
		if (productPriceDisplay > 0) {
			our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank);
		} else {
			our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank);
		}
		$('#our_price_display').text(our_price);
		$('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank));

		if (productPriceWithoutReductionDisplay > productPriceDisplay)
			$('#old_price,#old_price_display,#old_price_display_taxes').show();
		else
			$('#old_price,#old_price_display,#old_price_display_taxes').hide();
		// Special feature: "Display product price tax excluded on product page"
		var productPricePretaxed = '';
		if (!noTaxForThisProduct)
			productPricePretaxed = productPriceDisplay / tax;
		else
			productPricePretaxed = productPriceDisplay;
		var price = productPriceDisplay*$("#quantity_wanted").val();
	}else{									  
	var price=productPrice*$("#quantity_wanted").val();
	}
	//var price = $('#our_price_display').text();
//	price=price.replace(" \u20ac","");
//	price=price.replace(',','.'); 
//	price=price*$("#quantity_wanted").val();
	price=price.toFixed(2);
	price=price.replace('.',',');
    $("#our_price_display").html((price+" "+currencySign));
});
});
  • Like 1
Link to comment
Share on other sites

this is the clean version, sorry

$(document).ready(function(){
$("#quantity_wanted").on("input",function(){
	if (!selectedCombination['unavailable'] && productShowPrice == 1){
		var priceTaxExclWithoutGroupReduction = '';

		// retrieve price without group_reduction in order to compute the group reduction after
		// the specific price discount (done in the JS in order to keep backward compatibility)		
		priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);

		var tax = (taxRate / 100) + 1;
		var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);

		if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute'])
		{
			if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0)
				var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate);
			else
				var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate);
		}
		else if (product_specific_price.price && product_specific_price.price >= 0)
			var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate);

		if (!displayPrice && !noTaxForThisProduct)
			productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var
		else
			productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var

		productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction;
		var reduction = 0;
		if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
		{
			reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate);
			reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price;
			if (reduction_price && (displayPrice || noTaxForThisProduct))
				reduction = ps_round(reduction / tax, 6);

		}
		else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
		{
			if (product_specific_price.reduction_type == 'amount')
				reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
			else
				reduction_price = 0;

			if (product_specific_price.reduction_type == 'percentage')
				reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction);

			reduction = reduction_price + reduction_percent;
			if (reduction_price && (displayPrice || noTaxForThisProduct))
				reduction = ps_round(reduction / tax, 6);
		}

		if (selectedCombination.specific_price)
		{
			if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage')
			{
				$('#reduction_amount').hide();
				$('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');
				$('#reduction_percent').show();
			} else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) {
				$('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank));
				$('#reduction_percent').hide();
				$('#reduction_amount').show();
			} else {
				$('#reduction_percent').hide();
				$('#reduction_amount').hide();
			}
		}

		if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
			$('#discount_reduced_price,#old_price').show();
		else
			$('#discount_reduced_price,#old_price').hide();
		if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage')
			$('#reduction_percent').show();
		else
			$('#reduction_percent').hide();
		if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price']))
			$('#not_impacted_by_discount').show();
		else
			$('#not_impacted_by_discount').hide();

		productPriceDisplay -= reduction;
		productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);

		var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];

		if (ecotaxAmount != default_eco_tax)
			productPriceDisplay += ecotaxAmount - default_eco_tax;
		else
			productPriceDisplay += ecotaxAmount;

		if (ecotaxAmount != default_eco_tax)
			productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax;
		else
			productPriceWithoutReductionDisplay += ecotaxAmount;

		var our_price = '';
		if (productPriceDisplay > 0) {
			our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank);
		} else {
			our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank);
		}
		$('#our_price_display').text(our_price);
		$('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank));

		if (productPriceWithoutReductionDisplay > productPriceDisplay)
			$('#old_price,#old_price_display,#old_price_display_taxes').show();
		else
			$('#old_price,#old_price_display,#old_price_display_taxes').hide();
		// Special feature: "Display product price tax excluded on product page"
		var productPricePretaxed = '';
		if (!noTaxForThisProduct)
			productPricePretaxed = productPriceDisplay / tax;
		else
			productPricePretaxed = productPriceDisplay;
		var price = productPriceDisplay*$("#quantity_wanted").val();
	}
	price=price.toFixed(2);
	price=price.replace('.',',');
    $("#our_price_display").html((price+" "+currencySign));
});
});
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi all, I've managed to get the above working, but only when adding the quantity in the box. There a was already buttons to change the quantity but they do not affect the price.

 

Secondly, when i put a quantity in manually there is no limit, even though when using the buttons there is.

 

In short:

1. How do i get the buttons to also change the price?

2. How do i set a quantity fix when adding quantity manually.

3. When I change the attribute, the price changes back to the base price, but the quantity stays the same.

 

Any help would be appreciated.

Thanks

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

  • 3 weeks later...

Bump.....this does not work anymore with the latest upgrade, the price on the product page no longer changes. I have tried to change the js to reflect the latest changes but this does not seem to help?

 

Anyone?

Link to comment
Share on other sites

HI

 

I change the product.js for the display of the prices change depending on the quantity or attributes chosen by the customer  while considering specific attribute price and specifiques prices
 
one downside I disable the crossed out price (old_price) if your group displays the price HT
 
I added in comment in beginning of the file the lines added or changed
please test on local PS before

 

file here

http://www.prestashop.com/forums/topic/325496-showing-total-price-when-changing-quantity/?p=1656830

 

@++

 

Loulou66

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