// Improve Specific prices

This commit is contained in:
rGaillard
2011-11-14 17:40:42 +00:00
parent 2c2586544d
commit 11fc755c46
11 changed files with 89 additions and 58 deletions
+31 -29
View File
@@ -65,7 +65,6 @@ function addCombination(idCombination, arrayOfIdAttributes, quantity, price, eco
combination['unit_price'] = unit_price;
combination['minimal_quantity'] = minimal_quantity;
combination['available_date'] = available_date;
combination['specific_price'] = new Array();
combination['specific_price'] = combination_specific_price;
combinations.push(combination);
}
@@ -300,38 +299,32 @@ function updateDisplay()
var tax = (taxRate / 100) + 1;
var display_specific_price;
if (selectedCombination['specific_price'])
if (selectedCombination.specific_price)
{
display_specific_price = selectedCombination['specific_price'].price;
display_specific_price = selectedCombination.specific_price['price'];
if (selectedCombination['specific_price'].reduction_type == 'percentage')
{
$('#reduction_percent_display').html(selectedCombination['specific_price'].reduction*100);
$('#reduction_percent').show();
}
else
$('#reduction_percent').hide();
$('#reduction_percent_display').html(selectedCombination['specific_price'].reduction_percent);
}
else
{
display_specific_price = specific_price;
if (display_specific_price)
{
if (product_specific_price.reduction_type == 'percentage')
{
$('#reduction_percent_display').html(product_specific_price['specific_price'].reduction*100);
$('#reduction_percent').show();
}
else
$('#reduction_percent').hide();
if (productPriceWithoutRedution < productPrice)
$('#old_price_display,#old_price_display_taxes').show();
}
display_specific_price = product_specific_price['price'];
if (product_specific_price['reduction_type'] == 'percentage')
$('#reduction_percent_display').html(product_specific_price['specific_price'].reduction_percent);
}
if (display_specific_price)
$('#discount_reduced_price,#old_price,#not_impacted_by_discount, #old_price_display, #old_price_display_taxes').show();
if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
$('#discount_reduced_price,#old_price').show();
else
$('#discount_reduced_price,#old_price,#not_impacted_by_discount,#old_price_display,#old_price_display_taxes').hide();
$('#discount_reduced_price,#old_price').hide();
if (product_specific_price['reduction_type'] == 'percentage' || selectedCombination['specific_price'].reduction_type == 'percentage')
$('#reduction_percent').show();
else
$('#reduction_percent').hide();
if (display_specific_price)
$('#not_impacted_by_discount').show();
else
$('#not_impacted_by_discount').hide();
var taxExclPrice = (display_specific_price ? (specific_currency ? display_specific_price : display_specific_price * currencyRate) : priceTaxExclWithoutGroupReduction) + selectedCombination['price'] * currencyRate;
@@ -352,10 +345,16 @@ function updateDisplay()
}
var reduction = 0;
if (reduction_price || reduction_percent)
if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
{
reduction = productPrice * (parseFloat(reduction_percent) / 100) + reduction_price;
if (reduction_price && (displayPrice || noTaxForThisProduct))
reduction = productPrice * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + selectedCombination['specific_price'].reduction_price;
if (selectedCombination['specific_price'].reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
else if (product_specific_price.reduction_price || product_specific_price.reduction_percent)
{
reduction = productPrice * (parseFloat(product_specific_price.reduction_percent) / 100) + product_specific_price.reduction_price;
if (product_specific_price.reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
@@ -378,7 +377,10 @@ function updateDisplay()
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
if (productPriceWithoutReduction > productPrice)
$('#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" */
if (!noTaxForThisProduct)
var productPricePretaxed = productPrice / tax;
+12 -14
View File
@@ -49,13 +49,11 @@ var allowBuyWhenOutOfStock = {if $allow_oosp == 1}true{else}false{/if};
var availableNowValue = '{$product->available_now|escape:'quotes':'UTF-8'}';
var availableLaterValue = '{$product->available_later|escape:'quotes':'UTF-8'}';
var productPriceTaxExcluded = {$product->getPriceWithoutReduct(true)|default:'null'} - {$product->ecotax};
var reduction_percent = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'percentage'}{$product->specificPrice.reduction*100}{else}0{/if};
var reduction_price = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'amount'}{$product->specificPrice.reduction}{else}0{/if};
var specific_price = {if $product->specificPrice AND $product->specificPrice.price}{$product->specificPrice.price}{else}0{/if};
var product_specific_price = new Array();
{foreach from=$product->specificPrice key='key_specific_price' item='specific_price_value'}
product_specific_price['{$key_specific_price}'] = '{$specific_price_value}';
{/foreach}
product_specific_price['reduction_percent'] = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'percentage'}{$product->specificPrice.reduction*100}{else}0{/if};
product_specific_price['reduction_price'] = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'amount'}{$product->specificPrice.reduction}{else}0{/if};
product_specific_price['price'] = {if $product->specificPrice AND $product->specificPrice.price}{$product->specificPrice.price}{else}0{/if};
product_specific_price['reduction_type'] = '{if $product->specificPrice}$product->specificPrice.reduction_type{/if}';
var specific_currency = {if $product->specificPrice AND $product->specificPrice.id_currency}true{else}false{/if};
var group_reduction = '{$group_reduction}';
var default_eco_tax = {$product->ecotax};
@@ -79,7 +77,7 @@ var idDefaultImage = {if isset($cover.id_image_only)}{$cover.id_image_only}{else
{/if}
var productPriceWithoutRedution = '{$productPriceWithoutRedution}';
var product_price = '{$productPrice}';
var productPrice = '{$productPrice}';
// Customizable field
var img_ps_dir = '{$img_ps_dir}';
@@ -123,11 +121,10 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
// Combinations
{foreach from=$combinations key=idCombination item=combination}
var specific_price_combination = new Array();
{if $combination.specific_price}
{foreach from=$combination.specific_price key='specific_price_key' item='combination_specific_price'}
specific_price_combination['{$specific_price_key}'] = '{$combination_specific_price}';
{/foreach}
{/if}
specific_price_combination['reduction_percent'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'percentage'}{$combination.specific_price.reduction*100}{else}0{/if};
specific_price_combination['reduction_price'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'amount'}{$combination.specific_price.reduction}{else}0{/if};
specific_price_combination['price'] = {if $combination.specific_price AND $combination.specific_price.price}{$combination.specific_price.price}{else}0{/if};
specific_price_combination['reduction_type'] = '{if $combination.specific_price}{$combination.specific_price.reduction_type}{/if}';
addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, '{$combination.available_date}', specific_price_combination);
{/foreach}
{/if}
@@ -255,7 +252,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
<img src="{$img_dir}onsale_{$lang_iso}.gif" alt="{l s='On sale'}" class="on_sale_img"/>
<span class="on_sale">{l s='On sale!'}</span>
{/if}
<span style="{if !$product->specificPrice AND !$product->specificPrice.reduction AND $productPriceWithoutRedution < $productPrice}display:none;{/if}" id="discount_reduced_price" class="discount">{l s='Reduced price!'}</span>
<span style="{if !$product->specificPrice AND !$product->specificPrice.reduction AND $productPriceWithoutRedution <= $productPrice}display:none;{/if}" id="discount_reduced_price" class="discount">{l s='Reduced price!'}</span>
<br />
<span class="our_price_display">
{if $priceDisplay >= 0 && $priceDisplay <= 2}
@@ -282,7 +279,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{/if}
</span>
</p>
<p style="{if !$product->specificPrice AND !$product->specificPrice.reduction_type == 'percentage'}display:none;{/if}" id="reduction_percent">{l s='(price reduced by'} <span id="reduction_percent_display">{$product->specificPrice.reduction*100}</span> %{l s=')'}</p>
<p style="{if !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'}display:none;{/if}" id="reduction_percent">{l s='(price reduced by'} <span id="reduction_percent_display">{$product->specificPrice.reduction*100}</span> %{l s=')'}</p>
{if $packItems|@count}
<p class="pack_price">{l s='instead of'} <span style="text-decoration: line-through;">{convertPrice price=$product->getNoPackPrice()}</span></p>
<br class="clear" />
@@ -421,6 +418,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{else}
{l s='quantity'}
{/if}
{if $quantity_discount.attributes}{$quantity_discount.attributes}{/if}
</th>
{/foreach}
</tr>