Forums / Templates, Stylesheets, Page Layout / Reduce Product Name in Shopping Cart Side Box

Reduce Product Name in Shopping Cart Side Box

Locked

Views: 1,927

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
26 Sep 2008, 11:04 PM
#1
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Reduce Product Name in Shopping Cart Side Box

I have successfully increased the allowed length of my product names using phpMyAdmin. I have a shopping cart side box appear if an item is added to the shopping cart.

What I would like to do is to have the length of the product name reduced when it appears in the Shopping Cart side box. Can this be done? (I don't necessarily want the name to be reduced when it appears in the actual shopping cart...just in the shopping cart side box.)

Thanks for any help.

27 Sep 2008, 12:42 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Reduce Product Name in Shopping Cart Side Box

The shopping cart sidebox output can be edited in
/includes/templates/your_template/sideboxes/tpl_shopping_cart.php, near line 34:```php
$content .= $products[$i]['name'] . '</span></a></li>' . "\n";

27 Sep 2008, 1:34 PM
#3
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

Thanks for pointing that out...while I have tried to come up with a way to change the length of the 'name' allowed here...I have not been able to do that. Any suggestions?

27 Sep 2008, 9:16 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Reduce Product Name in Shopping Cart Side Box

The product listing page uses this to truncate the description, around line 95:```php
case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
} else {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
}

zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) 

This can be simplified considerably to apply to the name; the essential parts are
zen_trunc_string('string', length) 
where 'string' can be
$products[$i]['name']

zen_trunc_string($products[$i]['name'], 42) 

Change 42 to the max number of characters you want. zen_trunc_string() will cut the string to the largest number of whole words that fit in the length.

Note that I haven't used this in this way myself, so there might be some tweak needed for full functionality. Let me know how it works.
27 Sep 2008, 10:55 PM
#5
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

Thanks a lot.....I have been trying to use the truncate function myself but so far have not gotten anywhere. I will try your ideas tomorrow and let you know how it goes. I really appreciate the effort your made.

27 Sep 2008, 11:05 PM
#6
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

Well of course I could not wait to try it till tomorrow...so I just did it using 35 in my case...and it works like a charm....many thanks again!!

13 Oct 2008, 4:04 AM
#7
coolcarpartsonline avatar

coolcarpartsonline

Totally Zenned

Join Date:
Feb 2008
Posts:
1,386
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

Can you post the solution in steps, Iam trying to change the poduct name length in a few different places.

13 Oct 2008, 2:23 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Reduce Product Name in Shopping Cart Side Box

There is really only one "step" (post 4); but we have to know where you want to make the change before advising on the correct variables to use and the correct file/location to apply it.

13 Oct 2008, 3:46 PM
#9
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

I also received an email suggesting an alternative approach...I have not yet tried it but am posting it here in case it may be useful to others:

replace:
$content .= $products[$i]['name'] . " . "\n";

with

$content .= zen_trunc_string($products[$i]['name'] , 35 , 'true')."."\n";

This would set the replacement to 35 characters max for each product.

13 Oct 2008, 4:29 PM
#10
coolcarpartsonline avatar

coolcarpartsonline

Totally Zenned

Join Date:
Feb 2008
Posts:
1,386
Plugin Contributions:
0

Re: Reduce Product Name in Shopping Cart Side Box

Is there a way to display the product in the product pages such as Featured products or when displayed on the main page so the order is Title Image then Price instead of Image Title then price. Iam using the colum display and it would look better that way.

13 Oct 2008, 5:20 PM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Reduce Product Name in Shopping Cart Side Box

The 'true' is the default, so doesn't need to be specified (it adds ... after the truncated string.)

The
."."\n";
looks erroneous. In PHP, it means to concatenate a . after the
zen_trunc_string($products[$i]['name'] , 35 , 'true'), and then has a \n" at the end of the statement, which is incorrect syntax and will cause an error.
If the first " (double quote) was intended as '' (two single quotes), it would be correct PHP syntax but cause an error as the closing tags </span></a></li> would be missing in the HTML output.

13 Oct 2008, 5:27 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Reduce Product Name in Shopping Cart Side Box

In admin > Configuration > Product Listing, you can set the output order of elements:
Display Product Image 1
Display Product Manufacturer Name 0
Display Product Model 3
Display Product Name 2
Display Product Price/Add to Cart 0
Display Product Quantity 0
Display Product Weight 0

0 is don't display, a number is the order.