Skip to content

Commit

Permalink
Fix reduced price on product list
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeigne committed Jul 24, 2013
1 parent 463c49e commit 098187d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function getProducts(){

foreach($result as $responsiveHomeFeatured)
{
$product = new Product($responsiveHomeFeatured['id_product'], true, Context::getContext()->cookie->id_lang);
$product = new Product($responsiveHomeFeatured['id_product'], false, Context::getContext()->cookie->id_lang);

if ($product->id) {
$return[] = $product;
Expand Down
23 changes: 23 additions & 0 deletions modules/responsivehomefeatured/responsivehomefeatured.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public function hookHome($params)
$i = 0;
$j = 0;

/** @var $homeFeatured ResponsiveHomeFeaturedClass */
foreach(ResponsiveHomeFeaturedClass::findAll() as $homeFeatured)
{
$categoryList[$i]['category'] = new Category($homeFeatured->id_category, $this->context->cookie->id_lang);
Expand All @@ -280,6 +281,28 @@ public function hookHome($params)
$cover = $product->getCover($product->id);
$categoryList[$i]['products'][$j]['product'] = $product;
$categoryList[$i]['products'][$j]['price_tax_inc'] = Product::getPriceStatic($product->id, true);

$categoryList[$i]['products'][$j]['reduction'] = Product::getPriceStatic(
$product->id,
(bool)Tax::excludeTaxeOption(),
null,
6,
null,
true,
true,
1,
true,
null,
null,
null
);

if (Group::getPriceDisplayMethod((int)Group::getCurrent()->id) == PS_TAX_EXC) {
$categoryList[$i]['products'][$j]['price_without_reduction'] = $product->getPrice(false, null, 6, null, false, false);
} else {
$categoryList[$i]['products'][$j]['price_without_reduction'] = $product->getPrice(true, null, 6, null, false, false);
}

$categoryList[$i]['products'][$j]['image'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover['id_image'], 'large_default');

$j++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,27 @@
{foreach from=$category.products item=product name=homeFeaturedProducts}
<li class="ajax_block_product">
<a class="product_image" href="{$link->getProductLink($product.product)}" title="{$product.product->name|escape:html:'UTF-8'}">
{if $product.product->specificPrice && isset($product.product->specificPrice.reduction)}
{if $product.product->specificPrice.reduction_type == "percentage" or $product.product->specificPrice.reduction_type == "amount"}
<span class="new">{l s='Reduced price !' mod='responsivehomefeatured'}</span>
{/if}
{if isset($product.reduction) && $product.reduction && isset($product.product->show_price) && $product.product->show_price && !$PS_CATALOG_MODE}
<span class="new">{l s='Reduced price !' mod='responsivehomefeatured'}</span>
{/if}
<img src="{$product.image}" height="205" width="205" alt="{$product.product->name|escape:html:'UTF-8'}" />
</a>
<h5 class="align_center">
<a href="{$link->getProductLink($product.product)}" title="{$product.product->name|escape:html:'UTF-8'}">{$product.product->name|truncate:30:'...'|escape:'htmlall':'UTF-8'}</a>
</h5>
<div class="product_price align_center">
{if $product.product->show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}
{if isset($product.product->show_price) && $product.product->show_price AND !$PS_CATALOG_MODE}
<span class="price">
{if !$priceDisplay}
{convertPrice price=$product.price_tax_inc}
{else}
{convertPrice price=$product.product->price}
{/if}
</span>
{if $product.product->specificPrice && isset($product.product->specificPrice.reduction)}
{if $product.product->specificPrice.reduction_type == "percentage" or $product.product->specificPrice.reduction_type == "amount"}
{if $product.reduction && isset($product.reduction)}
<span class="original_price">
{if $product.product->specificPrice.reduction_type == "percentage"}
{convertPrice price=(($product.price_tax_inc * $product.product->specificPrice.reduction) + $product.price_tax_inc)}
{/if}

{if $product.product->specificPrice.reduction_type == "amount"}
{convertPrice price=$product.price_tax_inc + $product.product->specificPrice.reduction}
{/if}
{convertPrice price=$product.price_without_reduction}
</span>
{/if}
{/if}
{/if}
</div>
Expand Down
26 changes: 9 additions & 17 deletions themes/simpleresponsivetheme/product-list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{foreach from=$products item=product name=products}
<li class="ajax_block_product">
<a class="product_image" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">
{if $product.specific_prices.reduction_type == "percentage" or $product.specific_prices.reduction_type == "amount"}
{if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
<span class="new">{l s='Reduced price!'}</span>
{/if}
<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'large_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />
Expand All @@ -43,24 +43,16 @@
<div class="product_price align_center">
{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
<span class="price">
{if !$priceDisplay}
{convertPrice price=$product.price}
{else}
{convertPrice price=$product.price_tax_exc}
{/if}
</span>
{if isset($product.reduction) && $product.reduction}
{if $product.specific_prices.reduction_type == "percentage" or $product.specific_prices.reduction_type == "amount"}
<span class="original_price">
{if $product.specific_prices.reduction_type == "percentage"}
{convertPrice price=(($product.price * $product.specific_prices.reduction) + $product.price)}
{if !$priceDisplay}
{convertPrice price=$product.price}
{else}
{convertPrice price=$product.price_tax_exc}
{/if}

{if $product.specific_prices.reduction_type == "amount"}
{convertPrice price=$product.price + $product.specific_prices.reduction}
{/if}
</span>
{/if}
{if isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}
<span class="original_price">
{convertPrice price=$product.price_without_reduction}
</span>
{/if}
{/if}
{*{if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}
Expand Down

0 comments on commit 098187d

Please sign in to comment.