Endre Posted August 25, 2015 Share Posted August 25, 2015 Hi. I have managed to show EAN13 and UPC numbers on the product page. The issue I have is that the numbers come up for every attribute group that has been assigned to the product. Is there any way to have these numbers only appear once, based on the choices customers make? Here is an example of what I mean: http://verktoy.com/bukker/90-industribukken.html NOBB equals EAN13 Strekkode equals UPC I would them to behave like the reference number that only appears after all attributes have been selected. A pint or two to anyone who can point me in the right direction :-) I haven't found a module that solves this problem either. Cheers Endre Link to comment Share on other sites More sharing options...
musicmaster Posted August 25, 2015 Share Posted August 25, 2015 (edited) If you really want to. It is quite an effort as the query doesn't ask for them. It would be much easier if you used the reference field. - in the file /classes/product.php in the function getAttributesGroups() you need to add "pa.ean13" and "pa.upc" to the list of demanded fields (I will leave the upc out of the rest of this answer). - in the file /controllers/productController.php in the function assignAttributesGroups() you need to add a line $combinations[$row['id_product_attribute']]['ean13'] = $row['ean13']; - in your file product.tpl you will find a line that starts with "addCombination({$idCombination|intval}". You need to add your fields as extra arguments to this javascript function. - in the file product.js in the header of function addCombination() you need to add the new fields(=arguments) - in the file product.js in the function addCombination() you need to add the line "combination['ean13'] = ean13;" - in the file product.js in the function findCombination() you need to add the line "selectedCombination['ean13'] = combinations[combination]['ean13'];" - In the file product.tpl you insert "<span id=ean13 name=ean13></span>" - in the file product.js in the function updateDisplay() you need to add the line $('#ean13').text(selectedCombination['ean13']); I have left out where in those functions you need to insert these texts. Just look for the reference field and do the same. Edited August 26, 2015 by musicmaster (see edit history) 1 Link to comment Share on other sites More sharing options...
Endre Posted September 15, 2015 Author Share Posted September 15, 2015 Hi, musicmaster. Sorry I haven't replied earlier, but I've been away on travel for a bit, so haven't been able to try your suggestion until now. Now I've finally tested this, and it seems to work exactly how I was looking for. As I stated in my initial post, a pint or two to whoever could help me with this. Do you have a Paypal account? :-) Thank you for your help with this issue, musicmaster! Link to comment Share on other sites More sharing options...
ukbaz Posted September 24, 2015 Share Posted September 24, 2015 Hi Endre- Can you post the code from product.tpl and product.js for EAN13 - this is exactly what I want to do Link to comment Share on other sites More sharing options...
ukbaz Posted September 24, 2015 Share Posted September 24, 2015 I cannot find that code in version 1.6.0.9 what versions are you using? Link to comment Share on other sites More sharing options...
Endre Posted September 27, 2015 Author Share Posted September 27, 2015 (edited) I'm using 1.6.1.1, and your are right, some of the code is different. I have attached product.js, Product.php and ProductController.php. Compare these to your files. product.tpl: <!-- BOF EAN13 og UPC--> <p id="product_ean13"{if empty($product->ean13) || !$product->ean13} style="display: none;"{/if}> <label>{l s='EAN13:'} </label> <span class="editable" itemprop="ean13">{if !isset($groups)}{$product->ean13|escape:'html':'UTF-8'}{/if}</span></p> <p id="product_upc" {if isset($groups) OR !$product->upc}style="display: none;"{/if}> <label>{l s='UPC : '} </label> <span class="editable">{$product->upc|escape:'html':'UTF-8'}</span> </p> <!-- EOF EAN13 og UPC--> Kind regards Endre ean-upc.zip Edited September 27, 2015 by Endre (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now