Jump to content

creating a link from a product to another one


Recommended Posts

Hi,

 

I'd like to know how to use a button or something like that to link a product to another one...

 

I'll explain:

 

I offer free e-books in my website... when the visitor opens an e-book area, one could have the opportunity of following a link (a button close to "add to cart") saying "click here if you want the printed version of this e-book" that would forward the visitor to the printed version area (another product).

 

Can you help me, please?

 

Thank you,

 

Rui

Edited by rsilvapt (see edit history)
Link to comment
Share on other sites

Have you considered adding the printable version of the product as an accessory of the main product? To do this, edit a product, go to the Associations tab, enter a product name in the "Accessories" field, click one of the search results, then save the product. You could then go to Localization > Translations > Front Office translations > product to change "Accessories" header to something else.

 

Or if you really need it as a button next to "Add to cart", you can edit product.tpl in your theme's directory and {* comment out *} the accessories code (starting on the line before <!--Accessories --> and finishing on the line after <!--end Accessories -->) and then add code like the following before the $HOOK_PRODUCT_ACTIONS line:

{if isset($accessories) && $accessories}
    {foreach from=$accessories item='accessory'}
        <a class="button" href="{$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}">{l s='Printable version'}</a>
    {/foreach}
{/if}

You will then have a "Printable version" button below the "Add to cart" button that links to the product.

Link to comment
Share on other sites

Have you considered adding the printable version of the product as an accessory of the main product? To do this, edit a product, go to the Associations tab, enter a product name in the "Accessories" field, click one of the search results, then save the product. You could then go to Localization > Translations > Front Office translations > product to change "Accessories" header to something else.

 

Or if you really need it as a button next to "Add to cart", you can {* comment out *} the accessories code (starting on the line before <!--Accessories --> and finishing on the line after <!--end Accessories -->) and then add code like the following before the $HOOK_PRODUCT_ACTIONS line:

{if isset($accessories) && $accessories}
    {foreach from=$accessories item='accessory'}
        <a class="button" href="{$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}">{l s='Printable version'}</a>
    {/foreach}
{/if}

You will then have a "Printable version" button below the "Add to cart" button that links to the product.

 

Hi!,

 

Thank you.

 

In which file should I write the code? Sorry... a Prestashop newbie ;)

 

Rui

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