Jump to content

Duplicate price on product.tpl, duplicated one doesn't change based on attributes


Recommended Posts

Hi community

 

I have a test installation ad I'd like to show the price twice, one on top (default template) and the other one below the "add to cart" form

 

The reason is when description is too long, customers can't see the price on bottom, and the price actually change based on the attributes or combinations.

 

My problem is that the duplicated price haven't change at all 
Can see a live sample in here: my test page

 

I found an answer here:

 

https://www.prestashop.com/forums/topic/306932-solved-producttpl-display-the-price-2-times-with-attribute-price-changes-supported/?hl=%2Bprice

 

But the topic is SOLVED and that answer didn't work form me,

 

So far, my code for price on product.tpl

 <div class="single-price price" id="our_price_display" itemprop="price">{convertPrice price=$productPrice|floatval}

						{if ($product->specificPrice || $product->specificPrice.reduction)}
						{strip}
							{if $priceDisplay >= 0 && $priceDisplay <= 2}
								<div class="single-price-before">Antes 
									{hook h="displayProductPriceBlock" product=$product type="old_price"}
									<span id="old_price_display">{if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction|floatval}{/if}{if $productPriceWithoutReduction > $productPrice && $tax_enabled && $display_tax_label == 1} {/if}</span>
								</div>
							{/if}
						{/strip}
						{/if}
					  </div>

What I did was copy/paste the same code just below the add to cart form, so it shows ok, but prices doesnt change.

Following recomendation by Robin in the Solved threat:

 

For the 2nd price you need to set a different ID, it can't be our_price_display. IDs must be unique.

 

Look up the function 'updateDisplay' in product.js, locate and duplicate the following lines:

$('#our_price_display').text(our_price);
        $('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));

and change 'our_price_display' to the new ID.

 

Regards.

Robin.

The CartExpert Team

 

 

what I did was use another ID for my price in product.tpl:

<div class="single-price price" id="our_price_display_2" itemprop="price">{convertPrice price=$productPrice|floatval} 

And the I went to my product.js making the function look like this:

$(document).on('change', '#quantity_wanted', function(e){
	e.preventDefault();
	var specificPrice = findSpecificPrice();

	if(false !== specificPrice){
		$('#our_price_display').text(specificPrice);
	}else{
		if (typeof productHasAttributes != 'undefined' && productHasAttributes){
			updateDisplay();
		}else{
			$('#our_price_display').text(formatCurrency(parseFloat($('#our_price_display').attr('content')), currencyFormat, currencySign, currencyBlank));
			$('#our_price_display_2').text(formatCurrency(parseFloat($('#our_price_display_2').attr('content')), currencyFormat, currencySign, currencyBlank));
			
		}
	}
});

The prices shows, but ONLY the fisrt one, with the ID our_price_display change with the attributes

 

Please, any help!!!

Thanks

 

Link to comment
Share on other sites

In product.js I think you must add some new lines:

Line 291

	if(false !== specificPrice){
		$('#our_price_display').text(specificPrice);
		$('#our_price_display_2').text(specificPrice); /*new code*/
	}else{

Line 805

if (priceWithDiscountsDisplay > 0)
	{
		$('#our_price_display').text(formatCurrency(priceWithDiscountsDisplay, currencyFormat, currencySign, currencyBlank)).trigger('change');
		$('#our_price_display_2').text(formatCurrency(priceWithDiscountsDisplay, currencyFormat, currencySign, currencyBlank)).trigger('change'); /*new code*/
	}
	else
	{
		$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank)).trigger('change');
		$('#our_price_display_2').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank)).trigger('change'); /*new code*/
	}

Gook luck

Edited by globosoftware.net (see edit history)
Link to comment
Share on other sites

  • 4 weeks 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...