Forums / Templates, Stylesheets, Page Layout / Targeting specific products in product listing

Targeting specific products in product listing

Locked

Views: 1,443

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
27 Jul 2007, 9:38 PM
#1
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Targeting specific products in product listing

I haven't found what I'm looking for - so I don't know if it's just never been asked before (ha!) or if I'm just not putting in the right search terms (more likely).

I have a client who will be selling some limited edition items. I've placed the "Limited Edition" items in their own separate category, but because they share some of the same attributes of other products, they will show up in other categories as well.

To clarify, I'll use the example of slippers. We'll say her limited edition stuff is pink fuzzy bunny slippers. But because they are pink, then they'll also show up in the "slippers by color" category, under "pink". Or when listing all items available, then they'll show up in there, as well.

Now, when she runs out of these pink fuzzy bunny slippers - she's out, and will sell no more of them. She wants to have a "snipe" (apparently an actual term used in printing - so I guess next time I take my little brother on a "snipe hunt" he can actually look for one! LOL) go across regular items when they are sold out to say "Sold out, available soon". But if the Limited Edition stuff is sold out, she simply wants it to say "Sold Out" and nothing more.

Now, I know on the individual "product details" page, I could do this, because I can use the stylesheet to specifically target that product ID, and issue forth the correct style to do what she wants. But when it comes to the alternate listings...is there a way to target specific items in the listing pages so if a regular item is sold out, it'll say "more soon", but if a Limited Edition item is right next to it in the listing, it'll just say "sold out"?

I didn't know if I could do this, so I didn't want to say "sure I can!" and then eat my words later on. I suppose I could do something like edit the field to set a class that shows the product ID for each individual listing...

But that's me thinking out loud. Would anyone know if this is a possibility?

27 Jul 2007, 11:25 PM
#2
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Re: Targeting specific products in product listing

doodlebee:

I haven't found what I'm looking for - so I don't know if it's just never been asked before (ha!) or if I'm just not putting in the right search terms (more likely).

I have a client who will be selling some limited edition items. I've placed the "Limited Edition" items in their own separate category, but because they share some of the same attributes of other products, they will show up in other categories as well.

To clarify, I'll use the example of slippers. We'll say her limited edition stuff is pink fuzzy bunny slippers. But because they are pink, then they'll also show up in the "slippers by color" category, under "pink". Or when listing all items available, then they'll show up in there, as well.

Now, when she runs out of these pink fuzzy bunny slippers - she's out, and will sell no more of them. She wants to have a "snipe" (apparently an actual term used in printing - so I guess next time I take my little brother on a "snipe hunt" he can actually look for one! LOL) go across regular items when they are sold out to say "Sold out, available soon". But if the Limited Edition stuff is sold out, she simply wants it to say "Sold Out" and nothing more.

Now, I know on the individual "product details" page, I could do this, because I can use the stylesheet to specifically target that product ID, and issue forth the correct style to do what she wants. But when it comes to the alternate listings...is there a way to target specific items in the listing pages so if a regular item is sold out, it'll say "more soon", but if a Limited Edition item is right next to it in the listing, it'll just say "sold out"?

I didn't know if I could do this, so I didn't want to say "sure I can!" and then eat my words later on. I suppose I could do something like edit the field to set a class that shows the product ID for each individual listing...

But that's me thinking out loud. Would anyone know if this is a possibility?

It can be done... though its a bit complicated.

I recently did something similar for a client. What I did was for a certain category, when you went to that category, it listed the three products in the category, but there was no way to "link" to that actual product... so the customer would be forced to click the "buy now" on that page, without actually going to the product.

I edited includes/modules/product_listing.php, to basically say "If the master_categories_id != 16 , then show the regular code, else, show this code" (!= mean does not equal).

Assuming that you'd want the changes you want both on the categories page with the listed products (like I did above) AND on the ALL PRODUCTS page, then you'd make your changes to includes/modules/YOUR_TEMPLATE/product_listing.php, AND includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_all_listing.php

So basically, you'd edit the section where it shows the sold out button, and you'd say "If product is not in this certain category, show this sold out button, BUT if it is in this certain category, show this sold out button".

Now, since the sql code for both the all products and the category products listing does not query for the master_categories_id, you have to make a change in the sql query (I can tell you how to do this, if you still want to proceed after reading how complicated it is, LOL) so that it does ask for the products master_categories_id.

28 Jul 2007, 5:45 AM
#3
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,867
Plugin Contributions:
19

Re: Targeting specific products in product listing

If the master category for the slippers is the limited edition category, you could probably create an if statement for the sold out image to show the plain sold out when the master category = catid. In other words, if you copied from the limited edition cat as a link (versus copy) to the pink category.

Regardless of where the item shows up, it should still track its master category id.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

28 Jul 2007, 6:03 AM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,867
Plugin Contributions:
19

Re: Targeting specific products in product listing

had this sitting open and didn't realize it had been answered so well. Should have refreshed before fininishing.:blush:

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

25 Aug 2007, 3:50 PM
#5
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Targeting specific products in product listing

Now, since the sql code for both the all products and the category products listing does not query for the master_categories_id, you have to make a change in the sql query (I can tell you how to do this, if you still want to proceed after reading how complicated it is, LOL) so that it does ask for the products master_categories_id.

Here I am, trying to figure out why it's not working. I'm like halfway there, and then I read this part of your answer. That'll teach me not to read everything first ;)

Yes, I'd be interested in how to edit the SQL query. Actually, I'm not afraid of doing that, I've edited a few SQL queries in my time. But if you already have the method of doing it worked out, it would save me some time from trying to figure it out on my own. I'd really appreciate it if you could pass that long to me :)

25 Aug 2007, 10:17 PM
#6
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Re: Targeting specific products in product listing

doodlebee:

Here I am, trying to figure out why it's not working. I'm like halfway there, and then I read this part of your answer. That'll teach me not to read everything first ;)

Yes, I'd be interested in how to edit the SQL query. Actually, I'm not afraid of doing that, I've edited a few SQL queries in my time. But if you already have the method of doing it worked out, it would save me some time from trying to figure it out on my own. I'd really appreciate it if you could pass that long to me :)

IF I remember correctly, (my brains already moved on from this, lol, it can only hold so much before the old stuff is deleted), but from some research, I found out I modified the SQL query here:

includes/index_filters/default_filter.php

Approx line 73, I added p.master_categories_id after

p.products_type

so it looks like this:

$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, .........

Then in the includes/modules/product_listing.php I did the:

if (($listing->fields['master_categories_id']) != '16') {

to say "if this product is not in category 16, do this, else, do that...."

Hope that helps... it seems like you're on the right track, so I wont elaborate more, but let me know how it goes....

25 Aug 2007, 10:46 PM
#7
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Targeting specific products in product listing

OMG - I LOVE you. You have no idea how much time you just saved me. Thank you so much!

26 Aug 2007, 12:48 AM
#8
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Targeting specific products in product listing

And I thought I'd update. It worked great on the product listing pages. But I can't get it to work on the All listing (where it lists all products).

I changed the line to:

if (($products_all->fields['master_categories_id']) == '24') {

...but the SQL query is only for the $listing_sql (in default_filter.php), but the all listing sql is for $products_all_sql or $products_all_split_sql..which I can't find anywhere. (Looking for $products_sql too - I just don't know what it's named!)

But I'm halfway there...if anyone else has any suggestions on how to get this to work on the "All" listing, that'd be great.

26 Aug 2007, 1:34 PM
#9
jettrue avatar

jettrue

Totally Zenned

Join Date:
Jan 2005
Location:
USA, St. Louis
Posts:
3,651
Plugin Contributions:
5

Re: Targeting specific products in product listing

doodlebee:

And I thought I'd update. It worked great on the product listing pages. But I can't get it to work on the All listing (where it lists all products).

I changed the line to:

if (($products_all->fields['master_categories_id']) == '24') {

> 
> ...but the SQL query is only for the $listing_sql (in default_filter.php), but the all listing sql is for $products_all_sql or $products_all_split_sql..which I can't find anywhere.  (Looking for $products_sql too - I just don't know what it's named!)
> 
> But I'm halfway there...if anyone else has any suggestions on how to get this to work on the "All" listing, that'd be great.

Ah, you'll also need to adjust the SQL in includes/modules/pages/products_all/header_php.php
27 Aug 2007, 9:13 PM
#10
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Targeting specific products in product listing

perfect - thank you!

This is wroking beautifully - thanks so much!