jd.creative Posted May 11, 2013 Share Posted May 11, 2013 (edited) Prestashop 1.5 On the default theme, there is that cart block on all pages, with the hover effect (top right). I've edited the JS so that now, when you click add to cart, if the title length is more than 11 characters, it will cut it to 9 and add '...' this.name.length > 11 ? this.name.substring(0, 9) Instead of the original 12 cut to 10 this.name.length > 12 ? this.name.substring(0, 10) That's great, that works for when you've just added it, but when you reload the page, or load a different page, it's obviously loading the title from somewhere else and is not shortened to the same settings... does anyone know where I have to change to shorten the name when page is loaded? I've looked and everywhere that I thought it might be, hasn't fixed it. Thanks in advance, JD Edited May 11, 2013 by jd.creative (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2013 Share Posted May 11, 2013 blockcart.tpl located in modules/blockcart or themes/modules/blockcart you've got there: <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}"> {$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a> {$product.name|truncate:13:'...'|escape:html:'UTF-8'} truncate it! :-) Link to comment Share on other sites More sharing options...
jd.creative Posted May 11, 2013 Author Share Posted May 11, 2013 blockcart.tpl located in modules/blockcart or themes/modules/blockcart you've got there: <a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}"> {$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a> {$product.name|truncate:13:'...'|escape:html:'UTF-8'} truncate it! :-) Thanks for your comments, I've already tried that, it doesn't seem to work, do I need to clear a cache file or something? Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2013 Share Posted May 11, 2013 where you apply changes? in file located in modules/blockcart or in theme/modules/blockcart ? If you change something in tpl files it is necessary to recompile the theme - so turn force compilation on Link to comment Share on other sites More sharing options...
jd.creative Posted May 11, 2013 Author Share Posted May 11, 2013 Oh I see, thanks I was testing it in modules/blockcart, then if it worked, I would move it theme/modules/blockcart... didn't know about the force compilation, thanks Will check it now. JD Link to comment Share on other sites More sharing options...
jd.creative Posted May 11, 2013 Author Share Posted May 11, 2013 Yep, that works, thanks! Link to comment Share on other sites More sharing options...
vekia Posted May 11, 2013 Share Posted May 11, 2013 Yep, that works, thanks! You're welcome :-) Im glad that i could help you, thanks for [solved] in the topic title regards 1 Link to comment Share on other sites More sharing options...
ALMAJ Posted November 10, 2013 Share Posted November 10, 2013 Tanks vekia i had that problem and i had truncate the wrong file "blockcart-json.tpl" in the wrong place "/modules/blockcart" insted of "themes/modules/blockcart.tpl" Link to comment Share on other sites More sharing options...
vekia Posted November 10, 2013 Share Posted November 10, 2013 Tanks vekia i had that problem and i had truncate the wrong file "blockcart-json.tpl" in the wrong place "/modules/blockcart" insted of "themes/modules/blockcart.tpl" hello majority, but now, after changing proper file, everything works as you expected? Link to comment Share on other sites More sharing options...
ALMAJ Posted November 11, 2013 Share Posted November 11, 2013 (edited) hello majority, but now, after changing proper file, everything works as you expected? yes, but only works when i reload the page, is this normal? url: www.tekcenter.pt/store tanks again Edited November 11, 2013 by majority (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 11, 2013 Share Posted November 11, 2013 ok blockcart-json is correct file in this case Link to comment Share on other sites More sharing options...
ALMAJ Posted November 11, 2013 Share Posted November 11, 2013 so i must truncate the blockcart-json file ? Link to comment Share on other sites More sharing options...
vekia Posted November 11, 2013 Share Posted November 11, 2013 for the first please check what you exactly have got in product name variable, it looks like it is empty (i suppose so) Link to comment Share on other sites More sharing options...
ALMAJ Posted November 11, 2013 Share Posted November 11, 2013 (edited) Ok I've discovered a fix for the missing characters in the Ajax cart. It seems this happens only when the prestashop 1.5.4 is updated by the "1-click Upgrade" (not 100% sure) I've 2 cleans installations of prestashop 1.5.6, one was installed manually (clean install) the other one was upgraded from 1.5.4 to 1.5.6 by the 1-click Upgrade module, the one that was installed manually (clean install) have no problems (missing characters) in the cart. So the the logic thing that cross my mind was to study the old files from prestashop 1.5.4 (clean install) and compare it with the upgraded files from prestshop 1.5.6 (1-click Upgrade) So, after analyzing the file "ajax-cart.js" I found out that the new prestashop 1.5.6 (1-click Upgrade) have this line: var min = this.name.indexOf(';', 10); that the old file "ajax-cart.js" from the prestashop 1.5.4 (clean install) doesn't have also the line: var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); is different from the prestashop 1.5.4 (clean install) The fix: Go to modules/blockcart and open the file "ajax-cart.js" around the line 465 comment out by adding // at beguining of the code line or just delete the line. var min = this.name.indexOf(';', 10); In the same file "ajax-cart.js" around the line 465 find this code: var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); and play with the values or just replace by this code (with the min values removed): var name = (this.name.length > 18 ? this.name.substring(0, 16) + '...' : this.name); Hope this helps someone with the same problem as me. this goes a little off the original topic, should i make a new topic about it? Regards. Edited November 12, 2013 by majority (see edit history) 2 Link to comment Share on other sites More sharing options...
amar.prestashop Posted November 12, 2013 Share Posted November 12, 2013 Thank you it was a big issue, now it is solved ! Link to comment Share on other sites More sharing options...
totallighting.sk Posted December 14, 2013 Share Posted December 14, 2013 THX, working on version 1.5.6... Link to comment Share on other sites More sharing options...
ilovekutchi.com Posted February 1, 2014 Share Posted February 1, 2014 Thank you @majority! I also had this problem and I also had used 1-click update before... Link to comment Share on other sites More sharing options...
JuanCu Posted May 4, 2014 Share Posted May 4, 2014 (edited) Thanks for the solution! it was exactly what I needed. One note here though: var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name); "this.name.substring(" alters "this.name", which is used right in the following line, to set the title: content += '<a href="' + this.link + '" title="' + this.name the result is that hovering over the truncated text shows the same truncated text. (easy fix: do "var title=this.name" before this line, and do "content += '<a href="' + this.link + '" title="' + title ..." after.) Edited May 4, 2014 by JuanCu (see edit history) Link to comment Share on other sites More sharing options...
MilkSheikh Posted August 14, 2015 Share Posted August 14, 2015 Fix doesn't work on 1.6. In case you are trying... Link to comment Share on other sites More sharing options...
MilkSheikh Posted August 14, 2015 Share Posted August 14, 2015 (edited) Finally got it to work in PS 1.6 (full txt when add to cart) by changing in yourtheme/js/modules/blockcart/ajax-cart.js the following with the desired length: name = (name.length > 25 ? name.substring(0, 24) + '...' : name); I precise this is if you want the product name to be displayed fully, or up to xx characters when added to cart without having to refresh Edited August 15, 2015 by MilkSheikh (see edit history) 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