product title too long for cart module

  • Posts: 19
  • Thank you received: 0
13 years 9 months ago #8735

Hi,

I am using variants with pretty long characteristic values. My products are named like "product name + characteristic name".
That is fine in general, also in the checkout process.

But I have displayed a cart module in a sidebar, that has only limited width. Therefore when I add a product to the cart, there is not enough space and e.g. the price is cut. Therefore I would need the cart to display the short product name only without the full characteristic text.

I there a way to display the "name only" of a product in the cart module, but remain the full name in the checkout cart?

Thank you,
kohypon

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #8738

Hi,

There is no option for that. However, you can go in the menu Display->Views and edit the file cart of the view product to change the display of the product name.

You could for example replace the code:
echo $row->product_name;

By:
echo substr($row->product_name,0,10).'...';

And that will display only the first 10 characters of the name followed by three dots.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
13 years 9 months ago #8742

Hi Nicolas,

well that kind of solved it, but not very clean.

Maybe I should generally disable the product name to be added with the characteristic. I think I can remember, that there was a option for disabling the characteristic to be part of the product name. Unfortunately I cant find that option in Hikashop configuration.

Can you give me a hint, where this could be configured?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #8743

In the config, under the tab display, you have the option "Append characteristics value to product name"

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
13 years 9 months ago #8744

Hi,

I found the perfect solution for me. I added this function:

"function first_words($string, $num, $tail=' ...')
{
/** words into an array **/
$words = str_word_count($string, 2);

/*** get the first $num words ***/
$firstwords = array_slice( $words, 0, $num);

/** return words in a string **/
return implode(' ', $firstwords).$tail;
}
"

and made an echo like "echo first_words( $row->product_name, 2)"

This takes only the first two words (my product names itself allways contain two words) and kills the characteristics in the string.

Thank you,
kohypon

Please Log in or Create an account to join the conversation.

  • Posts: 78
  • Thank you received: 0
13 years 8 months ago #9677

Another solution which I used for this was to edit the cart module view (cart file of product view) and change out product_name for product_code, so the cart displays my short code and I also modified the cart file of the checkout view so the checkout displays code > product name > ....everything else.

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum