Jump to content

[Solved] Ajax Cart - Problem showing the whole product name when you add to cart


Recommended Posts

Hi

 

I got a little problem regarding blockcart2 and ajax-cart.js. I'm trying to show the whole product name in the cart when you add something instead of the first 10 letters. So what I have done is that I have changed this line in ajax-cart.js:

 

Line 434: var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name);

 

to

 

var name = (this.name.length > 32 ? this.name.substring(0, 30) + '...' : this.name);

 

Then I changed this line in the blockcart.tpl file:

 

Line 66: {$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>

 

to

 

{$product.name|truncate:33:'...'|escape:html:'UTF-8'}</a>

 

It works when you add a product and refresh the page, but if you dont, you'll still get the first 10 letters + the (...)

 

Force compile is on and cache is off in BO's "performance". I've also manually cleaned the cache in /tools/smarty and smarty_v2. And for good measure I've also cleaned my browsers

 

Does anyone know what I am doing wrong, or what causes this?

 

Using Prestashop 1.4.8.2 (tried several themes, including the default, with the same result)

 

 

 

Thanx in advance

 

 

I figured it out. You need to edit the blockcart-json.tpl in the "blockcart" (not blockcart2) module, even though the module isn't enabled.

 

Line 38: "name": "{$product.name|html_entity_decode:2:'UTF-8'|escape|truncate:35:'...':true}",

Edited by Izraelviz (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 5 months later...

Thanks for sharing!

I had (and still have) a similar issue but it was worse because when I added a product with name "Epístolas" it was only displayed as "Ep&..." I changed the truncation to see if that helped but no way. I had to change the "escape" in the blockcart-json.tpl from "escapeall" to "escape", then I still have the truncation problem (name always truncated) that you had, even after changing the truncation length in both blockcart.tpl and blockcart-json.tpl so that it is longer. I need to refresh the page for the new truncation (longer) to be used. I cant really understand why...

Link to comment
Share on other sites

  • 6 months later...

I'm using Prestashop 1.5.4.0. I made all the changes mentioned above in order to show longer names in the cart items instead of the initial 13, but these changes didn't do anything. Then I found another file containing the "truncate" code specifying the name length of the items in the cart. Go to your theme (I'm using default) - modules - blockcart. Open the file called blockcart.tpl and find the following code:

 

{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>

 

Just change the number 13 to any length you desire. Hope this helps.

  • Like 1
Link to comment
Share on other sites

I did the same thing on 1.5.4.1, BUT you need to change it in another file in addition to the blockcart.tpl in the themes/modules/blockcart/ for it to update IMMEDIATELY on your site when adding items otherwise the cart will continue to show the truncated value until you refresh the page or go to a new one. The second file you need to modify if you are using AJAX is blockcart-json.tpl located in /modules/blockcart/

 

@Vekia Below is a glimpse of mine. I extended my shopping cart to accommodate the extra length product names

post-595250-0-20218900-1375225753_thumb.jpg

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

Hi,

 

All your comments were very helpful. I've extened name of my products in cart to 28 but I can see another problem:

when you poin coursor on the name you can see that description which appears is also "cutted"... (see attached picture)

After web refreshing is O.K.

 

Can this description can be full all the time?  

post-727820-0-14097400-1391784149_thumb.jpg

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