Forums / Templates, Stylesheets, Page Layout / Sold New Products display Sold Out instead of price on index and products_new pages

Sold New Products display Sold Out instead of price on index and products_new pages

Started by dharma on 8 Oct 2008, 8:44 PM · Views: 11,060

Results 1 to 20 of 37
8 Oct 2008, 8:44 PM
#1
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Sold New Products display Sold Out instead of price on index and products_new pages

Currently, in my admin, I have my stock set to leave product status ON when product sells out.

regardless of this setting...

Is there a way to get the product to display "Sold Out" instead of the price when it sells out? on the index and products_new page?

Changing the product price to $0 gets rid of the price, but "sold out" would be more clear to users.

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

9 Oct 2008, 8:00 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

You would have to change the display price function that if a product is sold out or products_quantity <= 0 that it should return, as the price, sold out or an image or something other than the price that is being built in the functions_prices for this display price function ...

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!

14 Oct 2008, 3:52 AM
#3
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

So would have edit each page: index, product listing, all, new, search, featured, p info etc with some sort of > if products_quantity <= 0 then <img src=> php something } somethingcode?

Or is there a way to do it globally? ZC seems to know not to display a price when the price is zero, is there a way to hook into this? and replace the blank space with a sold out image?

functions_prices.php ?

In any case how would I get started? :book:

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

15 Oct 2008, 4:13 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

All of the prices are displayed with the display price function in the functions_prices.php using a single function for everywhere except the shopping_cart and checkout ...

Look in the function file for:

////
// Display Price Retail
// Specials and Tax Included
  function zen_get_products_display_price($products_id) {

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!

16 Oct 2008, 4:45 AM
#5
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Ajeh:

You would have to change the display price function that if a product is sold out or products_quantity <= 0 that it should return, as the price, sold out or an image or something other than the price that is being built in the functions_prices for this display price function ...

Found this section, what would the code be to replace the blank space with an image of "Sold Out"?

am I even close?

////
// Display Price Retail
// Specials and Tax Included
  function zen_get_products_display_price($products_id) {
    global $db, $currencies;

    $free_tag = "";
    $call_tag = "";
    
    // replace blank price space with sold out image on all pages
     if products_quantity <= 0 {
      
        return 'BUTTON_IMAGE_SOLD_OUT';
      }
    

// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices
    // verify display of prices
      switch (true) {

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 1:59 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

You would need to check the products_quantity with the function:

  function zen_get_products_stock($products_id) {

It isn't available until you look it up ...

Then, whatever you return would change what the price displays as ...

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!

16 Oct 2008, 2:08 PM
#7
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Ajeh:

You would need to check the products_quantity with the function:

function zen_get_products_stock($products_id) {

> 
> It isn't available until you look it up ...
> 
> Then, whatever you return would change what the price displays as ...

Then this is correct?

```php
//// 
// Display Price Retail 
// Specials and Tax Included 
  function zen_get_products_display_price($products_id) { 
    global $db, $currencies; 

    $free_tag = ""; 
    $call_tag = ""; 
     
    // replace blank price space with sold out image on all pages 
     
  function zen_get_products_display_price($products_id) { 

if products_quantity <= 0 { 
       
        return 'BUTTON_IMAGE_SOLD_OUT'; 
      } 
 } 
     

// 0 = normal shopping 
// 1 = Login to shop 
// 2 = Can browse but no prices 
    // verify display of prices 
      switch (true) {  

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 2:48 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

In a word ... no ... :cry:

Try something like:

// replace blank price space with sold out image on all pages 
     
  $products_quantity = zen_get_products_display_price($products_id);
if $products_quantity <= 0 {       
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);
        return $return_button
      } 

I have not tested this but this is the basic idea ...you may need to tweak this some ...

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!

16 Oct 2008, 3:24 PM
#9
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

I tried the code and my site went away, whoops! I hate when that happens:Flush:

any obvious errors? :unsure: too many of these { thingys maybe?

////
// Display Price Retail
// Specials and Tax Included
  function zen_get_products_display_price($products_id) {
    global $db, $currencies;

    $free_tag = "";
    $call_tag = "";
//test
      
  $products_quantity = zen_get_products_display_price($products_id); 
if $products_quantity <= 0 {        
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT); 
        return $return_button 
      } 
      
// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices
    // verify display of prices
      switch (true) {
        case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
        // customer must be logged in to browse
        return '';
        break;
        case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
        // customer may browse but no prices
        return TEXT_LOGIN_FOR_PRICE_PRICE;
        break;
        case (CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != ''):
        // customer may browse but no prices
        return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
        break;
        case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customer_id'] == ''):
        // customer must be logged in to browse
        return TEXT_AUTHORIZATION_PENDING_PRICE;
        break;
        case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customers_authorization'] > '0'):
        // customer must be logged in to browse
        return TEXT_AUTHORIZATION_PENDING_PRICE;
        break;
        default:
        // proceed normally
        break;
      }

// show case only

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 4:00 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

You if needs to be changed:

if $products_quantity <= 0 {        

To read:

if ($products_quantity <= 0) {        

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!

16 Oct 2008, 4:15 PM
#11
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

I changed the code but my site went away again. maybe throw in a ! somewhere?

also I just popped your code in on line 154 under the call tag is the placement wrong or is my statement conflicting the above code?

////
// Display Price Retail
// Specials and Tax Included
  function zen_get_products_display_price($products_id) {
    global $db, $currencies;

    $free_tag = "";
    $call_tag = "";
    
//test
      
  $products_quantity = zen_get_products_display_price($products_id); 
if ($products_quantity <= 0) {        
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT); 
        return $return_button 
      } 

// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices
    // verify display of prices

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 5:54 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Missing semi-colon at the end of the line ...

        return $return_button[B];[/B]

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!

16 Oct 2008, 6:20 PM
#13
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Still no site with above code with added ; :yuck:

I moved the } down (see below) but that didn't work either.:sadwalk:

///
// Display Price Retail
// Specials and Tax Included
  function zen_get_products_display_price($products_id) {
    global $db, $currencies;

    $free_tag = "";
    $call_tag = "";
    
//test
      
  $products_quantity = zen_get_products_display_price($products_id); 
if ($products_quantity <= 0) {        
        $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT); 
        return $return_button; 
       
      
// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices
    // verify display of prices
      switch (true) {
        case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
        // customer must be logged in to browse
        return '';
        break;
        case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
        // customer may browse but no prices
        return TEXT_LOGIN_FOR_PRICE_PRICE;
        break;
        case (CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != ''):
        // customer may browse but no prices
        return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
        break;
        case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customer_id'] == ''):
        // customer must be logged in to browse
        return TEXT_AUTHORIZATION_PENDING_PRICE;
        break;
        case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customers_authorization'] > '0'):
        // customer must be logged in to browse
        return TEXT_AUTHORIZATION_PENDING_PRICE;
        break;
        default:
        // proceed normally
        break;
      }
      
          }

// show case only

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 7:16 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Just use this code to display the SOLD OUT image instead of the Price ...

// return sold out vs price
  $products_quantity = zen_get_products_stock($products_id);
  if ($products_quantity <= 0) {
    $return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT, BUTTON_SOLD_OUT_ALT);
    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!

16 Oct 2008, 7:34 PM
#15
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

That one does the trick! :clap:everything looks good so far, I will do some more testing to see if there are any issues and report back if need be.

Meanwhile, I think I owe you a cup of coffee!

Thanks Linda!
:rolleyes:

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

16 Oct 2008, 7:51 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

You are most welcome ...

I gave you 1 typo and then I appeared to have befuddled you on the other things needed ... :eek:

It was easier to just sit down, clean it up, test it ... and make sure the price vanished everywhere when the products_quantity <= 0 ...

Thanks for the support! :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!

21 Feb 2009, 8:20 AM
#17
ozpottery avatar

ozpottery

New Zenner

Join Date:
Feb 2009
Posts:
2
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Hi, I want to do the same thing only use the small image instead, I tried the code:

// return sold out vs price
$products_quantity = zen_get_products_stock($products_id);
if ($products_quantity <= 0) {
$return_button = zen_image_button(BUTTON_IMAGE_SOLD_OUT_SM, BUTTON_SOLD_OUT_ALT);
return $return_button;
}

but that just gave me the alt tag and no image.
(without the _SM the large image shows fine)

Thanks for your help :smile:

21 Feb 2009, 3:36 PM
#18
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

The constant for the small sold out is:
BUTTON_IMAGE_SOLD_OUT_SMALL

And its ALT tag constant is:
BUTTON_SOLD_OUT_SMALL_ALT

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!

21 Feb 2009, 8:42 PM
#19
ozpottery avatar

ozpottery

New Zenner

Join Date:
Feb 2009
Posts:
2
Plugin Contributions:
0

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Thank you so much Linda,
that worked

:P Anita

22 Feb 2009, 3:36 AM
#20
ajeh avatar

ajeh

Oba-san

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

Re: Sold New Products display Sold Out instead of price on index and products_new pages

Thanks for the update that the problem was just a typo ... :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!