Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Category listing- add text under each price

Category listing- add text under each price

Locked

Views: 3,004

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
25 Aug 2009, 2:41 PM
#1
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Category listing- add text under each price

Pretty much all my items are listed with a base price and a customer can choose larger sizes from the product's page. Problem is, many do not realize this from the Category listing page even though I have text on top explaining it. So I'd like to add "and up" under each price.

I do not use the "More info" link and thought of changing that text to suit my needs, but it wouldn't work for many other items. And I haven't been able to figure out what file to adjust for this idea.

Any ideas?

R

ZC 1.38a
alexandergifts.ca

25 Aug 2009, 3:41 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Category listing- add text under each price

giftmeister:

...many do not realize this from the Category listing page...

... do you mean the PRODUCT listing page (where products in a given category are listed... ?

25 Aug 2009, 7:49 PM
#3
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Yup, Product listing page!

25 Aug 2009, 8:02 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

You can edit the content in /includes/modules/your_template/product_listing.php. There is a "case" list, and you can insert a bit of text in the code for the "price" case. This can be quick & dirty, or done with defined constants for multi-language support.

26 Aug 2009, 3:25 AM
#5
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Okay, getting closer...you're talking about this part, right?

    case 'PRODUCT_LIST_PRICE':
    $lc_text = TABLE_HEADING_PRICE;
    $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
    $zc_col_count_description++;
    break;

20 minutes later and none of my attempts worked. As you can tell, I'm not a real programmer. Any specifics, please?

R

26 Aug 2009, 9:03 AM
#6
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

There are two sets of cases; the first one is for the headings. You want to edit the second set, where the actual price is output.

26 Aug 2009, 9:08 AM
#7
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

Around line 107:```php
case 'PRODUCT_LIST_PRICE':
$lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
$lc_align = 'right';
$lc_text = $lc_price;

    // more info in place of buy now
    $lc_button = '';

//continued...


and up<br />

after the <br />```php
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />and up<br />';
26 Aug 2009, 3:39 PM
#8
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Thanks a million!

I may actually do something slightly different as this adds the text even on General Document items without a price, but I at least can continue from here.

You Zenners are the best!

27 Aug 2009, 6:32 AM
#9
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

Adding a test for certain categories or products before inserting the "and up" text should be fairly straightforward. I didn't want to start by going into that subtlety, but now it is needed.

27 Aug 2009, 6:03 PM
#10
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

What's needed is for you to spell that out, if you'd be so kind again! Maybe I've added a test elsewhere, like for boilerplate text in tpl_product_info_display, but that was simply copying it...I don't know how to do it offhand.

R

27 Aug 2009, 7:09 PM
#11
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

You can use the function zen_get_products_category_id($product_id) to determine if the product is in a certain category or group of cats, and output the extra text in that case.

        case 'PRODUCT_LIST_PRICE':
        //check for cat(s) to add text
        $text_andup = (in_array(zen_get_products_category_id($listing->fields['products_id']), explode(',', '23,42,55')))?'and up<br />':'';

        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />' . $text_andup;
        $lc_align = 'right';
        $lc_text =  $lc_price;

explode(',', '23,42,55')
makes a comma-delimited array of numbers; substitute a list of all the categories where you want the text, separated by commas and no spaces.

$text_andup will have the text if in those cats, otherwise it will be empty.

27 Aug 2009, 8:11 PM
#12
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Brilliant! Exactly what I wanted without affecting other categories! Two million thanks!!:clap:

24 Sep 2009, 12:17 PM
#13
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Is there a limit to how many categories this works for? Or do I have to do something for Category IDs that are three digits long? Everything was fine till I added a tenth category, 111 and the first at three digits, and the 'and up' text does not show for some in that category. Same with 121 and then the latest, 142, does not show on any item in its cat.

$text_andup = (in_array(zen_get_products_category_id($listing->fields['products_id']), explode(',', '65,66,67,68,69,70,72,82,111,121,142')))?'and up<br />':'';

On my site category 111 is Bouquets (under Flowers) and 121 is Roses (under Flowers) and the text only appears on a few of them. Cat 142, Spa Baskets, is the latest and nothing appears. All the earlier ones, the first nine and two digits long, are fine.

Any ideas?

24 Sep 2009, 2:58 PM
#14
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

That's really odd... there should theoretically be no limits on either number of items in the explode or number of digits per item.

You show only eight two-digit cats.
Can you try taking some of the two-digit cats out of the list until there are only 8 cats in total?

Are the new cats filled with new products, or are they existing products linked in to the new cats? If linked, what other cats apply to a product that isn't working? What happens if you make a malfunctioning linked product have the new cat as its master? (Product editing page, "master" dropdown box at top.)

29 Sep 2009, 10:52 PM
#15
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

I'll write again soon, I've been having computer trouble.

6 Oct 2009, 1:37 AM
#16
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

I'm back...

I deleted a few to make it 8, but same issue. I double-checked and all products are in their proper Master Cats.

As for linking-

Cats 111 and 121 (Bouquets and Roses under Flowers) have some linked products and some not; the linked ones do not have the "and up" text.

Cat 142 has all linked products and none show the text.

The only places products link to are subcats of Occasion and Price.

111 and 121 are subcats. The products in 142 started in a subcat and were moved to a Master...and, again, the products have the proper Master setting.

R

6 Oct 2009, 2:40 AM
#17
gjh42 avatar

gjh42

Black Belt

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

Re: Category listing- add text under each price

Clearly the linking is involved in the problem. Let's try some debugging. Add a linephp $lc_text .= ' cat ' . zen_get_products_category_id($listing->fields['products_id']) . '<br />'; to the code above to get```php
case 'PRODUCT_LIST_PRICE':
//check for cat(s) to add text
$text_andup = (in_array(zen_get_products_category_id($listing->fields['products_id']), explode(',', '23,42,55')))?'and up<br />':'';

    $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />' . $text_andup;
    $lc_align = 'right';
    $lc_text =  $lc_price;
    $lc_text .= ' cat ' . zen_get_products_category_id($listing->fields['products_id']) . '<br />';
6 Oct 2009, 5:56 PM
#18
giftmeister avatar

giftmeister

Zen Follower

Join Date:
Jan 2009
Location:
Montreal, Canada
Posts:
230
Plugin Contributions:
0

Re: Category listing- add text under each price

Three million thanks! :clap:

I deleted the new line you provided, added the linked-to category numbers (except for a few products that were linked to many subcats) to the explode code and it worked!

Your time and attention is much appreciated.

R