Jump to content

Edit History

Kelsier

Kelsier

Hello:

I am using version 1.7.8.5 of PrestaShop. I have created a CMS page, and I have created a template in the path /themes/classic/templates/cms/ to be able to display fully personalized content.

So far, so good. In a section of the page, I want to display products from a certain category.

I have achieved this without problems using the following code:

{assign var="products" value=Product::getProducts(1, 0, 6, 'id_product', 'DESC', 11, true)}
{foreach $products as $product}
  <div class="product-description">
      <h3 class="h3 product-title">
          <a href="{Context::getContext()->link->getProductLink( $product.id_product )}" content="{Context::getContext()->link->getProductLink($product.id_product )}">{$product.name}
          </a>
       </h3>
  </div>
{/foreach}

The loop works and the products are displayed. My problem is that I can't show the discounts of the products. I have tried various solutions based on other system TPLs, but I can't get the product discount.

{if $product.has_discount}
	{if $product.discount_type === 'percentage'}
		<span class="discount-percentage discount-product">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]}</span>
    {else}
    	<span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]}</span>
    {/if}
{else}
	<span class="price" aria-label="Precio">{$product.price|ceil}&nbsp;€</span>
{/if}

 

But the non-discounted price is always displayed, even on products that have it.

How can I check if a product has a discount or specific prices, and then show it if so?

Thank you very much in advance.

Kelsier

Kelsier

Hello:

I am using version 1.7.8.5 of PrestaShop. I have created a CMS page, and I have created a template in the path /themes/classic/templates/cms/ to be able to display fully personalized content.

So far, so good. In a section of the page, I want to display products from a certain category.

I have achieved this without problems using the following code:

{assign var="products" value=Product::getProducts(1, 0, 6, 'id_product', 'DESC', 11, true)}
{foreach $products as $product}
  <div class="product-description">
      <h3 class="h3 product-title">
          <a href="{Context::getContext()->link->getProductLink( $product.id_product )}" content="{Context::getContext()->link->getProductLink($product.id_product )}">{$product.name}
          </a>
       </h3>
  </div>
{/foreach}

The loop works and the products are displayed. My problem is that I can't show the discounts of the products. I have tried various solutions based on other system TPLs, but I can't get the product discount.

{if $product.has_discount}
	{if $product.discount_type === 'percentage'}
		<span class="discount-percentage discount-product">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]}</span>
    {else}
    	<span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]}</span>
    {/if}
{else}
	<span class="price" aria-label="Precio">{$product.price|ceil}&nbsp;€</span>
{/if}

 

But the non-discounted price is always displayed, even on products that have it.

How can I check if a product has a discount or specific prices, and then show it if so?

Thank you very much in advance.

Kelsier

Kelsier

Hello:

I am using version 1.7.8.5 of PrestaShop. I have created a CMS page, and I have created a template in the path /themes/classic/templates/cms/ to be able to display fully personalized content.

So far, so good. In a section of the page, I want to display products from a certain category.

I have achieved this without problems using the following code:

{assign var="products" value=Product::getProducts(1, 0, 6, 'id_product', 'DESC', 11, true)}
{foreach $products as $product}
  <div class="product-description">
      <h3 class="h3 product-title">
          <a href="{Context::getContext()->link->getProductLink( $product.id_product )}" content="{Context::getContext()->link->getProductLink($product.id_product )}">{$product.name}
          </a>
       </h3>
  </div>
{/foreach}

The loop works and the products are displayed. My problem is that I can't show the discounts of the products. I have tried various solutions based on other system TPLs, but I can't get the product discount.

{if $product.has_discount}
	{if $product.discount_type === 'percentage'}
		<span class="discount-percentage discount-product">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]}</span>
    {else}
    	<span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]}</span>
    {/if}
{else}
	<span class="price" aria-label="Precio">{$product.price|ceil}&nbsp;€</span>
{/if}

 

But the non-discounted price is always displayed, even on products that have it.

How can I check if a product has a discount or specific prices, and then show it if so?

Thank you very much in advance.

Kelsier

Kelsier

Hello:

I am using version 1.7.8.5 of PrestaShop. I have created a CMS page, and I have created a template in the path /themes/classic/templates/cms/ to be able to display fully personalized content.

So far, so good. In a section of the page, I want to display products from a certain category.

I have achieved this without problems using the following code:

{assign var="products" value=Product::getProducts(1, 0, 6, 'id_product', 'DESC', 11, true)}
{foreach $products as $product}
  <div class="product-description">
      <h3 class="h3 product-title">
          <a href="{Context::getContext()->link->getProductLink( $product.id_product )}" content="{Context::getContext()->link->getProductLink($product.id_product )}">{$product.name}
          </a>
       </h3>
  </div>
{/foreach}

The loop works and the products are displayed. My problem is that I can't show the discounts of the products. I have tried various solutions based on other system TPLs, but I can't get the product discount.

{if $product.has_discount}
	{if $product.discount_type === 'percentage'}
		<span class="discount-percentage discount-product">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]}</span>
    {else}
    	<span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]}</span>
    {/if}
{else}
	<span class="price" aria-label="Precio">{$product.price|ceil}&nbsp;€</span>
{/if}

 

But the non-discounted price is always displayed, even on products that have it.

How can I check if a product has a discount or specific prices, and then show it if so?

Thank you very much in advance.

Kelsier

Kelsier

Hello:

I am using version 1.7.8.5 of PrestaShop. I have created a CMS page, and I have created a template in the path /themes/classic/templates/cms/ to be able to display fully personalized content.

So far, so good. In a section of the page, I want to display products from a certain category.

I have achieved this without problems using the following code:

{assign var="products" value=Product::getProducts(1, 0, 6, 'id_product', 'DESC', 11, true)}
{foreach $products as $product}
  <div class="product-description">
      <h3 class="h3 product-title">
          <a href="{Context::getContext()->link->getProductLink( $product.id_product )}" content="{Context::getContext()->link->getProductLink($product.id_product )}">{$product.name}
          </a>
       </h3>
  </div>
{/foreach}

The loop works and the products are displayed. My problem is that I can't show the discounts of the products. I have tried various solutions based on other system TPLs, but I can't get the product discount.

{if $product.has_discount}
	{if $product.discount_type === 'percentage'}
		<span class="discount-percentage discount-product">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]}</span>
    {else}
    	<span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]}</span>
    {/if}
{else}
	<span class="price" aria-label="Precio">{$product.price|ceil}&nbsp;€</span>
{/if}

 

But the non-discounted price is always displayed, even on products that have it.

 

How can I check if a product has a discount, and then show it if so?

Thank you very much in advance.

×
×
  • Create New...