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:
Re: Can you show an item as being out of stock yet still allow add to cart
admin>configuration>stock>allow checkout
Set to "true"
Re: Can you show an item as being out of stock yet still allow add to cart
Quote:
Originally Posted by
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.
Re: Can you 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 .........
Code:
<!--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 ;)
Re: Can you 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.
Re: Can you 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:
Re: Can you show an item as being out of stock yet still allow add to cart
Re: Can you 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.
Re: Can you 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
Code:
<?php if ($products_quantity > 0) {
// show if product in stock
?>
PUT YOUR TEXT HERE<?php
}
?>
TEXT TO SHOW IF PRODUCT NOT IN STOCK
Code:
<?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:
Re: Can you show an item as being out of stock yet still allow add to cart
I think I want to edit this code:
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??