Forums / Templates, Stylesheets, Page Layout / Can I show an item as being out of stock yet still allow add to cart?

Can I show an item as being out of stock yet still allow add to cart?

Locked

Started by patf on 3 Nov 2008, 7:47 PM · Views: 4,714

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
3 Nov 2008, 7:47 PM
#1
patf avatar

patf

Zen Follower

Join Date:
May 2008
Posts:
200
Plugin Contributions:
0

Can I show an item as being out of stock yet still allow add to cart?

Hi guys,

Looking for a small bit of guidance please....

I know you can set Zen to allow checkout of out of stock items. In this case there is a message displayed only after the customer has added to cart.

The alternative is to show a sold out button instead of the add to cart box.

What I would really like is for the produt listing page and search pages etc to show a message saying temporarily out of stock but to allow the customer to add to cart and checkout as normal.

This is the way for example play.com is set up - in that you can see it is sold out and then when clicking on the item you see a message saying will be dispatched as soon as stock has arrived.

If anyone has any ideas on if / how this can be achieved in Zen Cart I would be very grateful :smile:

3 Nov 2008, 7:52 PM
#2
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

admin>configuration>stock>allow checkout

Set to "true"

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

3 Nov 2008, 8:24 PM
#3
patf avatar

patf

Zen Follower

Join Date:
May 2008
Posts:
200
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

afo:

admin>configuration>stock>allow checkout

Set to "true"

Yes but this allows a customer to add to cart and only then are they told that the item is out of stock

( to explain a bit more - I do not show stock counts on the site so its not a case of them seeing 0 in stock before clicking on add to cart )

I wish the site to say "temporarily out of stock" on the main index page / on the listings page / on the search pages etc but then have the ability to add to cart and checkout.

4 Nov 2008, 4:10 PM
#4
patf avatar

patf

Zen Follower

Join Date:
May 2008
Posts:
200
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

I am realising that this may be trickier than thought ....

I am looking at product_listing.php and I see this:

// product is in stock or customers may add it to cart anyway
($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
$how_many++;
}
// hide quantity box

And I think that this is the starting point for what I would like to do. I need some code that will check the 'products_quantity' field in the database and if this is a value less than 1 to show a message under the price.

So over at tpl_product_info_display.php I have .........

<!--bof Product Price block -->
<h2 id="productPrices" class="productGeneral">
<?php
// base price
  if ($show_onetime_charges_description == 'true') {
    $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
  } else {
    $one_time = '';
  }
  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
?><font color="#000066"> Delivered</font></h2>
<!--eof Product Price block -->

The last line with delivered is something I added into all products descriptions as we offer free shipping.

Could anyone please point me in the direction of what code I would need to slap in under here that will check the database for stock levels and then display the relevant message ????

I am thinking something like .....

if ($listing->fields['products_quantity'] < 1 echo DEFINED_TEXT

I know that is nowhere near complete but still ;)

4 Nov 2008, 4:40 PM
#5
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

Unfortunately, my php isn't strong enough to really help you. I believe you're on the right path. I'm sure someone will jump in with a suggestion (or 2 or 3...)

It occurs to me that a solution to this may be a solution to those who want to have items that can be pre-ordered.

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

4 Nov 2008, 5:02 PM
#6
patf avatar

patf

Zen Follower

Join Date:
May 2008
Posts:
200
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

Believe it or not we take pre orders on our site already - we have just edited the " will be in stock on XXXXX " line to say " this item is available for per order and is due for release on XXXXXX and this solved the problem nicely.

Thats why we need the ability to show an item as being out of stock on the product description so that we can have a temporarily out of stock message. Otherwise it would have been a case of editing the product to put an available date in a couple of weeks time and leaving it run with the " will be in stock on xxxxxx "

In our case now it would mean all our products that go out of stock would be appearing on the future pre orders list which won't do at all :shocking:

9 Nov 2008, 7:11 PM
#7
patf avatar

patf

Zen Follower

Join Date:
May 2008
Posts:
200
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

:lamo: Gentle bump !

18 Jan 2010, 9:38 PM
#8
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

Has anyone come up with the code to place on the product listing page and product info page to show this? I would be interested in using this feature for my site.

Eric
www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!

18 Jan 2010, 9:45 PM
#9
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

Here is the code I came up with for the tpl_product_info_display.php page. :clap:

TEXT TO SHOW IF PRODUCT IN STOCK

<?php if ($products_quantity > 0) {
              // show if product in stock
?>              
PUT YOUR TEXT HERE<?php
            } 
?>

TEXT TO SHOW IF PRODUCT NOT IN STOCK

<?php if ($products_quantity == 0) {
              // show if product out of stock
?>              
PUT YOUR TEXT HERE<?php
            } 
?>

I cannot figure out how to get the same thing to work on the products_listing.php page. Can anyone help? :no:

Eric
www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!

18 Jan 2010, 10:00 PM
#10
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

I think I want to edit this code:

                &&
                // product is in stock or customers may add it to cart anyway
                ($listing->fields['products_quantity'] > 1 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 1) ) {
                    $how_many++;
                  }

Except I want it to be products_quantity == 0

I know I am close. Any help??

Eric
www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!

18 Jan 2010, 10:23 PM
#11
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Can I show an item as being out of stock yet still allow add to cart?

OK. Kind of a one man conversation here so far but that's ok.

Here is a very very rough solution. I eliminated a bunch of code that I was unable to read well but it works.

PLEASE BACK UP YOUR product_listing.php file before beginning.

Basically, this shows a link to the page and an in stock button if the product quantity is greater than 0 and it shows a link to the page and an out of stock text if the product quantity is equal to 0.

As I said before, I erased a lot of code for the other conditions in order to get this to work. Use at your own risk.

        case 'PRODUCT_LIST_PRICE':
          $lc_price = zen_get_products_display_price($listing->fields['products_id']);
          $lc_align = 'right';
          $lc_text =  $lc_price;


// in stock or not
          $lc_button = '';
          if ($listing->fields['products_quantity'] > '0') {
            $lc_button = '<br /><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><img src="LINK TO VIEW PRODUCT BUTTON"></a><br /><img src="LINK TO SOME KIND OF IN STOCK BUTTON">';
          } else {
            if ( ($listing->fields['products_quantity'] == '0' ) ) {
                    $lc_button = '<br /><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><img src="LINK TO SOME KIND OF VIEW PRODUCT BUTTON></a><br />Temporarily Out of Stock';

                  }
          }
          $the_button = $lc_button;
        $products_link = '<br /><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><img src="LINK TO SOME KIND OF VIEW PRODUCT BUTTON"></a>';
          $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
          $lc_text .= '' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? 'FREE SHIPPING!' : '') : '');


break;

That's all.

As you can tell, I am a novice but this gets done what I want. Hope I explained this correctly.

Eric
www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!