Jump to content

Multiple Reference Number Linking


brad-w

Recommended Posts

Hi everyone,

For each product I have a link to a downloadable pdf:

reference|escape}.pdf" target="_blank">{l s='Printable PDF'}

This works great, all my PDF's are named according to their product reference number, except one problem.

Some of my products use the "attributes and groups" feature. This means there are multiple reference numbers, one for each combination of attributes. It seems the link that I was using for the product reference numbers doesn't work for reference numbers applied to attribute combinations. These products don't have a "product wide" reference number.

Is there a code I could use to replace the above link that would use the $product->reference variable when there is a product reference number, but if one doesn't exist, use the reference number from the attribute?

Let me know if this doesn't make sense lol..

Thanks =)

Link to comment
Share on other sites

It is the following code on line 222 of js/product.js in your theme's directory (in PrestaShop v1.3.1) that dynamically changes the product reference based on the currently selected combination:

if (selectedCombination['reference'] || productReference)
{
   if (selectedCombination['reference'])
       $('#product_reference span').text(selectedCombination['reference']);
   else if (productReference)
       $('#product_reference span').text(productReference);
   $('#product_reference:hidden').show('slow');
}
else
   $('#product_reference:visible').hide('slow');



You need to put an id like "pdf" on the link you want to dynamically change, then add code like the following to replace the reference in the link:

$('a#pdf').attr('href', baseDir + 'pdfs/' + selectedCombination['reference'] + '.pdf');



I hope it helps.

Link to comment
Share on other sites

  • 1 year later...

Hello Rocky

 

it is quite old post but I need similar on 1.4.6.2

 

But in my case I change add to cart button to the link to external application button, where every link is special and unique and needs dynamic reference code for every product combination.

 

For standard products everything works perfect, but problem again with combination references

 

For standard products I have link as follows:

 



	         <a href="http://externalapp&pccode={$product->reference|escape:'htmlall':'UTF-8'}&parameters" class="exclusive">Create now</a>

 

I was trying to follow your instructions for dynamic link but it does not function.

 

The js/product.js line 264

 

I changed

 

   	 if (selectedCombination['reference'])
           $('#product_reference span').text(selectedCombination['reference']);
           $('a#special_link').attr('href').text(selectedCombination['reference']);

 

and in product.tpl

 

I changed as follows:

 

{if isset($groups)}

<a id="special_link "href="http://externalapp&pccode={$product->reference|escape:'htmlall':'UTF-8'}&parameters" class="exclusive">Create now</a>

{else}

<a href="http://externalapp&pccode={$product->reference|escape:'htmlall':'UTF-8'}&parameters" class="exclusive">Create now</a>

{/if}

 

 

But it still gets only main product reference.

 

Could you tell how to fix it.

 

Thank you

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