Jump to content

Show Reference near to cart button (and refresh it)


AETtec

Recommended Posts

Hello.

Im so newbie at php and i want show the reference of each product on a near/visible place around button add to cart and price. So

so i did the next modification:

My version of PS is 1.7.6.1

1) File "only-reference.tpl" created on next location: /themes/newyork_home1/templates/catalog/_partials/only-reference.tpl
and writed the next code inside the file:

    {if isset($product.reference_to_display)}
      <div class="product-reference">
        <label class="label">{l s='Reference' d='Shop.Theme.Catalog'} </label>
        <span itemprop="sku">{$product.reference_to_display}</span>
      </div>
    {/if}

 

2) Modify the next file: /themes/newyork_home1/templates/catalog/product.tpl
and insert this code:
 

                    {block name='only-reference'}
                    {include file='catalog/_partials/only-reference.tpl'}
                    {/block}


The result...? yes the reference is on the correct place now, but it doesnt refresh when i change to other combination of the product, so i need help to fix it.
Please!
 

imagen.png

Edited by AETtec
edit title and adding more info (see edit history)
Link to comment
Share on other sites

  • 3 months later...

Simple solution.
Create a minimodule and use hookHeader in it.

Probably like this.

public function hookHeader($params)
{                        
   if(Tools::getValue('id_product')) {
        $product_reference= $this->context->product->reference_to_display;
     	$this->context->smarty->assign(array(
                    'my_reference_to_display' => product_reference,
     	));
   }               
}

 

tpl:

<span itemprop="sku">{$my_reference_to_display}</span>
      

 

Link to comment
Share on other sites

1 hour ago, Guest said:

Simple solution.
Create a minimodule and use hookHeader in it.

Probably like this.


public function hookHeader($params)
{                        
   if(Tools::getValue('id_product')) {
        $product_reference= $this->context->product->reference_to_display;
     	$this->context->smarty->assign(array(
                    'my_reference_to_display' => product_reference,
     	));
   }               
}

 

tpl:


<span itemprop="sku">{$my_reference_to_display}</span>
      

 

Thank you for the answer, but i dont know how to create a minimodule, i saw this tool https://validator.prestashop.com/generator
But i dont know nothing about php, i tried creating one with the tool and editing the php file with the 1º code you shared, then tried to install but it give me an error.

 

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