Jump to content

ISBN/EAN-13/UPC references show up ONLY if product has combinations - PrestaShop 1.7.5.1


finnenhawke

Recommended Posts

I either do not understand the intent behind the way it works or there is a bug with displaying specific references. As you know, in PrestaShop you can set up ISBN,  EAN-13 and UPC codes (references) for each product. It is done in "Options" tab when editing the product ("Condition & References" section). As I understand, these codes should show up in the product details section called "Specific References". Except they don't, because that section doesn't show up, even though there is a code for it in product-details.tpl:

    {* if product have specific references, a table will be added to product details section *}
    {block name='product_specific_references'}
      {if !empty($product.specific_references)}
        <section class="product-features">
          <p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
            <dl class="data-sheet">
              {foreach from=$product.specific_references item=reference key=key}
                <dt class="name">{$key}</dt>
                <dd class="value">{$reference}</dd>
              {/foreach}
            </dl>
        </section>
      {/if}
    {/block}

However, when I change the product type from "Simple product" to "Product with combinations" and add a single combination (without adding any specific references to that individual combination), these references from "OPTIONS > Conditions & References" tab immediately show up! What's more, when I even go one step further and set individual ISBN/EAN-13/UPC codes for each combination, they also show up and switch correctly. So it's working fine, but for some reason it's not working on product without combinations. Is this intended? Why can't it work the same for simple product and show the ISBN/EAN13/UPC?

If it's not intended then it must be a bug in PrestaShop that prevents showing Specific References in "Simple products". Is there any way I could fix this? I know that I can manually force showing EAN-13/ISBN/UPC codes by adding it directly to product.tpl file. However, it's not a good fix. It will work for simple products, but on "products with combinations" it will be a mess since the specific references will show up twice (from my forced code AND from the above code that works only on products with combinations). 

Is there any way that I could fix this? Or is there any way I could create code similar to the above that is limited only to simple products? Something that would work like that "IF Product Type = Simple Product SHOW [ EAN13 / ISBN / UPC ]". Sadly, I don't know Smarty and PHP so it's very hard for me to put this logic into actual code. I know how to call for EAN/ISBN/UPC code but I don't know how to limit that "call" only to "simple products".

 

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

  • 3 months later...
  • 8 months later...
  • 5 weeks later...
  • 1 month later...
  • 1 year later...

Hi,
I have a partial solution for EAN codes.
In the public_html / themes / (template-name) /templates/catalog/_partials/product-details.tpl file, the following code should be added to the condition around line 80, between {/if} and {/block}

 

{if isset($product.ean13) && $product.ean13 neq ''}
	<section class="product-features">
		<p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
			<dl class="data-sheet">
				<dt class="name">{l s='EAN' d='Shop.Theme.Catalog'}</dt>
				<dd class="value">{$product.ean13}</dd>
			</dl>
	</section>
{/if}

This is the second (additional) condition to the existing one.

In total, this code snippet should look like this:

{* if product have specific references, a table will be added to product details section *}
{block name='product_specific_references'}
    {if !empty($product.specific_references)}
        <div class="specific-references">
            {foreach from=$product.specific_references item=reference key=key}
                <div>
                    <label class="label">{$key}</label>
                    <span>{$reference}</span>
                </div>
            {/foreach}
        </div>
    {/if}
    {if isset($product.ean13) && $product.ean13 neq ''}
		<section class="product-features">
			<p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
			<dl class="data-sheet">
				<dt class="name">{l s='EAN' d='Shop.Theme.Catalog'}</dt>
				<dd class="value">{$product.ean13}</dd>
			</dl>
		</section>
	{/if}
{/block}

 

Presta 1.7.7.4

Remember to make a copy of this file before modifying!

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...
On 9/6/2021 at 2:21 PM, cedrowa said:

Hi,
I have a partial solution for EAN codes.
In the public_html / themes / (template-name) /templates/catalog/_partials/product-details.tpl file, the following code should be added to the condition around line 80, between {/if} and {/block}

 

{if isset($product.ean13) && $product.ean13 neq ''}
	<section class="product-features">
		<p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
			<dl class="data-sheet">
				<dt class="name">{l s='EAN' d='Shop.Theme.Catalog'}</dt>
				<dd class="value">{$product.ean13}</dd>
			</dl>
	</section>
{/if}

This is the second (additional) condition to the existing one.

In total, this code snippet should look like this:

{* if product have specific references, a table will be added to product details section *}
{block name='product_specific_references'}
    {if !empty($product.specific_references)}
        <div class="specific-references">
            {foreach from=$product.specific_references item=reference key=key}
                <div>
                    <label class="label">{$key}</label>
                    <span>{$reference}</span>
                </div>
            {/foreach}
        </div>
    {/if}
    {if isset($product.ean13) && $product.ean13 neq ''}
		<section class="product-features">
			<p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
			<dl class="data-sheet">
				<dt class="name">{l s='EAN' d='Shop.Theme.Catalog'}</dt>
				<dd class="value">{$product.ean13}</dd>
			</dl>
		</section>
	{/if}
{/block}

 

Presta 1.7.7.4

Remember to make a copy of this file before modifying!

 

I enhanced this solution, since in my Theme (Warehouse) it lead to EANs beeing output twice on products with Variants.

 

This solution prevents that:
 

{block name='product_specific_references'}
    {if !empty($product.specific_references)}
        <div class="specific-references">
            {foreach from=$product.specific_references item=reference key=key}
                <div>
                    <label class="label">{$key}</label>
                    <span>{$reference}</span>
                </div>
            {/foreach}
        </div>
    {elseif isset($product.ean13) && $product.ean13 neq ''}
        <div class="specific-references">
            <div>
                <label class="label">{l s='ean13' d='Shop.Theme.Catalog'}</label>
                <span>{$product.ean13}</span>
            </div>
        </div>
    {/if}
{/block}

Hope it helps somebody else.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 8 months later...

my solution code for classic theme: /themes/classic/templates/catalog/_partials/product-details.tpl file

- added lines 82-89

      {elseif isset($product.ean13) && $product.ean13 neq ''}
      <section class="product-features">
        <p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
          <dl class="data-sheet">
              <dt class="name">{l s='ean13' d='Shop.Theme.Catalog'}</dt>
              <dd class="value">{$product.ean13}</dd>
          </dl>
      </section>

 

- final view of lines 70-91:

  {* if product have specific references, a table will be added to product details section *}
  {block name='product_specific_references'}
    {if !empty($product.specific_references)}
      <section class="product-features">
        <p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
          <dl class="data-sheet">
            {foreach from=$product.specific_references item=reference key=key}
              <dt class="name">{$key}</dt>
              <dd class="value">{$reference}</dd>
            {/foreach}
          </dl>
      </section>
      {elseif isset($product.ean13) && $product.ean13 neq ''}
      <section class="product-features">
        <p class="h6">{l s='Specific References' d='Shop.Theme.Catalog'}</p>
          <dl class="data-sheet">
              <dt class="name">{l s='ean13' d='Shop.Theme.Catalog'}</dt>
              <dd class="value">{$product.ean13}</dd>
          </dl>
      </section>
    {/if}
  {/block}

- example attached:

Screenshot 2022-08-08 at 18.26.32.png

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