ckarone Posted June 29, 2012 Share Posted June 29, 2012 (edited) Bonjour, I have in my back/front office added the concept of attributes availability. In order to display the attributes product availability in Frensh or englih or GR ... I use the JS solution to display the reference attribute and it work good but I can't find a solution to translate "available", "on order", "out of stock", "resupply", "pre order" How this works: Depending on the value of dispo_code I set the availability to "available", "on order",... and I show the availability with jquery. Here is my js inside product.js of my template to set the availability: //add a combination of attributes in the global JS sytem function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, unit_price, minimal_quantity, dispo_date, dispo_code) { globalQuantity += quantity; var combination = new Array(); combination['idCombination'] = idCombination; combination['quantity'] = quantity; combination['idsAttributes'] = arrayOfIdAttributes; combination['price'] = price; combination['ecotax'] = ecotax; combination['image'] = id_image; combination['reference'] = reference; combination['unit_price'] = unit_price; combination['minimal_quantity'] = minimal_quantity; if(quantity>0){dispo_code=1} if(dispo_code==1){combination['dispo_code'] = 'Available'} if(dispo_code==2){combination['dispo_code'] = 'on order'} if(dispo_code==3){combination['dispo_code'] = 'out of stock'} if(dispo_code==4){combination['dispo_code'] = 'resupply'} if(dispo_code==5){combination['dispo_code'] = 'pre order'} if(dispo_code==1){combination['dispo_date'] = ''} else {combination['dispo_date'] = dispo_date;} combinations.push(combination); } And here is my JS code inside product.js of my template to show the availability: if (selectedCombination['dispo_date']) { $('#product_dispo_date span').text(selectedCombination['dispo_date']); $('#product_dispo_date:hidden').show('slow'); } else $('#product_dispo_date:visible').hide('slow'); if (selectedCombination['dispo_code']) { $('#product_dispo_code span').text(selectedCombination['dispo_code']); $('#product_dispo_code:hidden').show('slow'); } else $('#product_dispo_code:visible').hide('slow'); $('#product_dispo_coda:visible').hide('slow'); Many thanks !! Ckarone Edited June 29, 2012 by ckarone (see edit history) Link to comment Share on other sites More sharing options...
ckarone Posted June 29, 2012 Author Share Posted June 29, 2012 (edited) I have the solution Just set in product.tlp some variables for each status with translation in lan/fr.php or lan/en.php : var myavailable = '{l s='Available' js=1}'; var myoutofstok = '{l s='Out of stock' js=1}'; var myononoreder = '{l s='On order' js=1}'; var myresupply = '{l s='Resupply' js=1}'; var mypreorder = '{l s='Pre order' js=1}'; and depending on the dispo_code value show the good status if (selectedCombination['dispo_code']) { if (selectedCombination['dispo_code'] ==1) $('#product_dispo_code span').text(myavailable); if (selectedCombination['dispo_code'] ==2) $('#product_dispo_code span').text(myresupply); if (selectedCombination['dispo_code'] ==3) $('#product_dispo_code span').text(myoutofstock); if (selectedCombination['dispo_code'] ==4) $('#product_dispo_code span').text(myonorder); if (selectedCombination['dispo_code'] ==5) $('#product_dispo_code span').text(mypreorder); $('#product_dispo_code:hidden').show('slow'); } else $('#product_dispo_code:visible').hide('slow'); $('#product_dispo_coda:visible').hide('slow'); Wasn't some complicated Sorry for my bad english Ckarone Edited June 29, 2012 by ckarone (see edit history) 2 Link to comment Share on other sites More sharing options...
jojohn Posted December 19, 2013 Share Posted December 19, 2013 Impeccable Link to comment Share on other sites More sharing options...
ALMAJ Posted January 24, 2014 Share Posted January 24, 2014 I have the solution Just set in product.tlp some variables for each status with translation in lan/fr.php or lan/en.php : var myavailable = '{l s='Available' js=1}'; var myoutofstok = '{l s='Out of stock' js=1}'; var myononoreder = '{l s='On order' js=1}'; var myresupply = '{l s='Resupply' js=1}'; var mypreorder = '{l s='Pre order' js=1}'; and depending on the dispo_code value show the good status if (selectedCombination['dispo_code']) { if (selectedCombination['dispo_code'] ==1) $('#product_dispo_code span').text(myavailable); if (selectedCombination['dispo_code'] ==2) $('#product_dispo_code span').text(myresupply); if (selectedCombination['dispo_code'] ==3) $('#product_dispo_code span').text(myoutofstock); if (selectedCombination['dispo_code'] ==4) $('#product_dispo_code span').text(myonorder); if (selectedCombination['dispo_code'] ==5) $('#product_dispo_code span').text(mypreorder); $('#product_dispo_code:hidden').show('slow'); } else $('#product_dispo_code:visible').hide('slow'); $('#product_dispo_coda:visible').hide('slow'); Wasn't some complicated Sorry for my bad english Ckarone I know this have little to do with your topic, but i want to translate the availability state from product list (product-list.tpl) as in this topic here I've tried to add the "js=1}" but isn't working...because I'm not a coder can you please help-me? Tanks in Advance Link to comment Share on other sites More sharing options...
vekia Posted January 24, 2014 Share Posted January 24, 2014 js=1} what is this ? just wondering where you use this and .... it looks definitely bad Link to comment Share on other sites More sharing options...
ALMAJ Posted January 24, 2014 Share Posted January 24, 2014 js=1} what is this ? just wondering where you use this and .... it looks definitely bad js=1 looks like a java script derivative, heck I don't know what a hell is that I'm just trying to translate this here Tanks Link to comment Share on other sites More sharing options...
xiparos Posted April 25, 2015 Share Posted April 25, 2015 Hi All, I've tried this method for translating terms in my separate js file, unfortunately it didn't work. Could somebody tell me it is possible to do the translation in separate js file or not, with PS1.6.0.14. After reading this post https://www.prestashop.com/forums/topic/263170-solved-translate-in-javascript/ Could I assume that the translation inside a js only works if you add <script> tags within template file? Thanks in advance for your reply. Link to comment Share on other sites More sharing options...
joseantgv Posted December 4, 2015 Share Posted December 4, 2015 js=1} what is this ? just wondering where you use this and .... it looks definitely bad I guess it's related to this: http://forge.prestashop.com/browse/PSCFV-9427 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