Forums / Setting Up Categories, Products, Attributes / Different "Sold Out" images for each product type

Different "Sold Out" images for each product type

Locked

Views: 11,145

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
28 Feb 2008, 7:35 PM
#1
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Different "Sold Out" images for each product type

I've been trying to figure out a way to have one "sold out" image for one product type (general), and use a different one for another product type (music). Any hints would be appreciated. thanks!

25 Apr 2008, 8:18 PM
#2
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

I take it there's no way to do this? I'm still very interested in a way if it's possible.

26 Apr 2008, 4:49 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different "Sold Out" images for each product type

If you look at:
/includes/functions/functions_general.php

Line #1148 : $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);

Line #1150 : $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL, BUTTON_SOLD_OUT_SMALL_ALT); 

You could add IF statements to manage the Sold Out image used by products_type in the products table ...

You would need to alter the function to get this field by changing the SELECT statement from:

    $button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

to include the products_type field ...

NOTE: there are no overrides on the function files ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Apr 2008, 4:46 PM
#4
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

Oh man, that's awesome. I'm glad there is a way to do it. I knew if there was, that it would have something to do with the /includes/functions/functions_general.php file, but I'm such a noob I just have no idea how to tweak it. I'm trying to read up on php and IF statements so I can take care of it myself, but it may be a few days before I can post back and let you know if I got it working. Thank you, Ajeh, for pointing me in the right direction. :)

28 Apr 2008, 5:39 PM
#5
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

Ajeh:

You could add IF statements to manage the Sold Out image used by products_type in the products table ...

You would need to alter the function to get this field by changing the SELECT statement from:

$button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

Ok, I officially don't get it. I'll keep working on it, but if anyone out there want to take a stab at showing me what this should look like, I'd probably jump for joy. 
:wink2:
28 Apr 2008, 8:36 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different "Sold Out" images for each product type

You need to know the master_categories_id for the product when using this function to change the Sold Out image ...

This line selects the data:

    $button_check = $db->Execute("select product_is_call, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

if you change it to read:

    $button_check = $db->Execute("select product_is_call, products_quantity, master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

You now can identify the categories_id to change the sold out ... where $button_check->fields['master_categories_id'] is the categories_id to identify which one the Product uses as its main Category ...

This case statement manages the Sold Out settings:

    case ($button_check->fields['products_quantity'] <= 0 and SHOW_PRODUCTS_SOLD_OUT_IMAGE == '1'):
      if ($_GET['main_page'] == zen_get_info_page($product_id)) {
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);
      } else {
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL, BUTTON_SOLD_OUT_SMALL_ALT);
      }
      break;

The IF is managing which Sold Out image to send ...

You need to customize that section based on the categories_id that you get from:
$button_check->fields['master_categories_id']

Does that help you some? :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Apr 2008, 10:29 PM
#7
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

Thank you, Ajeh. I will be working on this some more as the week progresses. I will keep you updated as to my progress.

1 May 2008, 7:57 PM
#8
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

*sniff
I still don't get it. I have decided I am just not anywhere close to proficient enough with PHP to do this on my own. I have the feeling it's really easy and once I see it, I'll kick myself.
If anyone wants to volunteer more clues, I would be forever in their debt.

1 May 2008, 8:18 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different "Sold Out" images for each product type

See if this doesn't steer you in the right direction ... it is just a quick fix but should work for your needs ... :smile:

    $button_check = $db->Execute("select product_is_call, products_quantity, master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
    switch (true) {
// cannot be added to the cart
    case (zen_get_products_allow_add_to_cart($product_id) == 'N'):
      return $additional_link;
      break;
    case ($button_check->fields['product_is_call'] == '1'):
      $return_button = '<a href="' . zen_href_link(FILENAME_CONTACT_US) . '">' . TEXT_CALL_FOR_PRICE . '</a>';
      break;
// configure to manage sold images out by categories_id via master_categories_id
    case ($button_check->fields['products_quantity'] <= 0 and SHOW_PRODUCTS_SOLD_OUT_IMAGE == '1'):
      switch ((int)$button_check->fields['master_categories_id']) {
      case (10):
        if ($_GET['main_page'] == zen_get_info_page($product_id)) {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_10, BUTTON_SOLD_OUT_ALT_10);
        } else {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL_10, BUTTON_SOLD_OUT_SMALL_ALT_10);
        }
        break;
      case (27):
        if ($_GET['main_page'] == zen_get_info_page($product_id)) {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_27, BUTTON_SOLD_OUT_ALT_27);
        } else {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL_27, BUTTON_SOLD_OUT_SMALL_ALT_27);
        }
        break;
      default:
        if ($_GET['main_page'] == zen_get_info_page($product_id)) {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);
        } else {
          $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SMALL, BUTTON_SOLD_OUT_SMALL_ALT);
        }
        break;
      }
// forgot one!
      break;
    default:
      $return_button = $link;
      break;
    }
    if ($return_button != $link and $additional_link != false) {
      return $additional_link . '<br />' . $return_button;
    } else {
      return $return_button;
    }
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 May 2008, 7:20 PM
#10
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

Wow! Thank you, Ajeh/Linda for taking the time to help me. It is appreciated more than you know!

I am using the code you gave me (with my own category numbers and image settings), and it looks like it should be the answer to my situation, but now for some reason the sold out images aren't displaying at all. The add-to-cart option is still available, despite being set to display the sold out image instead when the item is out of stock.

Here are some links to my site so you can see what I mean:
registry link
regular item link

I have special (temporary) buttons made up for the registry items, and I'm trying to get the regular sold out images to show for the regular items.

I may have just missed something, but like I said before, it's beyond me. :)

5 May 2008, 5:10 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different "Sold Out" images for each product type

I am such a goober ... :cry:

I forgot a break in the code above ... I edited it so if you re-copy that into your code it will work lots better now ... :rolleyes:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

5 May 2008, 4:49 PM
#12
starlyn avatar

starlyn

New Zenner

Join Date:
Jul 2007
Location:
Washington, MO
Posts:
50
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

:clap:

*hug Linda

Yay! That did it! Thank you so much for all of your help. I am soo buying you a coffee today. :)

5 May 2008, 4:58 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different "Sold Out" images for each product type

You are most welcome ... :smile:

Imagine my surprise when the dang code broke on me when I pasted it into some clean code ... :eek:

I sat and pondered for quite a while about what the heck had I done dumb ... :unsure:

Then I noticed this little ol' break missing ... silly, silly me ... :smartalec:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Mar 2009, 9:37 PM
#14
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Different "Sold Out" images for each product type

Hi guys,

I've been trying to figure this out for a couple of days but to no avail... This is only 'slightly' off topic so hopefully you can help.

I'm basically trying to use some sort of position: relative; top: -100px; to control the position of the BUTTON_IMAGE_SOLD_OUT_SMALL gif that displays under the image on the products list pages.

Is there any way to position this button over the image?

I tried going with CSS buttons which helps but I hate them... I much prefer the image buttons... but how do I position button_sold_out_sm.gif relative?