Page 1 of 1
pre-order visual enhancement for availability
Posted: Thu Aug 05, 2010 5:14 am
by FFJim
I take pre-orders on some items but do not allow "stock checkout" for out-of-stock items. Instead of having availability display as "In Stock" I want these items to show "Pre-Order".
To accomplish this, for the pre-order items I set the product's out-of-stock message to "Pre-Order" instead of the default setting. (Whatever non-default message you select will be displayed.) I also set the stock to whatever my incoming stock will be. Then I altered catalog/controller/product/product.php as follows:
Find this:
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
$this->data['stock'] = $this->language->get('text_instock');
}
}
Replace with this:
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
if ($product_info['stock_status_id'] == $this->config->get('config_stock_status_id')) {
$this->data['stock'] = $this->language->get('text_instock');
} else {
$this->data['stock'] = $product_info['stock'];
}
}
}
Now availability shows as follows:
(1) If stock is zero and out-of-stock is the default, shows the default "Out Of Stock" text
(2) If stock is zero and out-of-stock is not the default, shows product's OOS text
(3) If stock is 1 or more and out-of-stock is the default, shows "In Stock" text
(4) If stock is 1 or more and out-of-stock is not the default, shows the product's OOS text
This doesn't completely resolve pre-ordering needs, but it at least gives a better availability status. I hope its helpful to others who take pre-orders.
Re: pre-order visual enhancement for availability
Posted: Thu Aug 05, 2010 7:24 am
by FFJim
If you're using the mod to hide the add button when items reach zero, found
here, make the following change to catalog/view/theme/yourtheme/template/product/product.php:
Find this:
Code: Select all
<?php if($stock == $this->language->get('text_instock') || $stock > 0): ?>
Replace with this:
Code: Select all
<?php if($stock == $this->language->get('text_instock') || $product_info['stock_status_id'] <> $this->config->get('config_stock_status_id') || $stock > 0): ?>
Re: pre-order visual enhancement for availability
Posted: Thu Aug 05, 2010 3:58 pm
by SXGuy
Good work, i made a mod similiar to this a little while ago.
A Client basically wanted a way to have different options depending on stock qty.
So i pulled the stock qty down to the product pages, and used that as a guide to what would show depending on how much stock was left, very simple to do and not alot of editing was needed.
Rather than messing with stock at 1 or above or whether an item is "instock" or "out of stock" i decided to just use minus figures for different options.
So if all products are set to in stock, but one has a stock count of -1 the add to cart button was removed and replaced with something else, i.e Contact us for details.
Same applied to -2 or -3
Re: pre-order visual enhancement for availability
Posted: Fri Sep 10, 2010 2:08 pm
by vkaltchev
You are quite knowledgeable guys and I have a question re availability, so hope you can help me. The majority of my products are made to order with availability/delivery 3-4 weeks. I want the customer to be able to purchase the item and make the payment/checkout without the system dealing with any "stock" on hand. Can you please validate if what I did is correct:
1. In Settings/Option I set:
- "Out of Stock Warning" to "no"
- "Stock Checkout" to "yes"
- "Out of Stock Status" to "2-3 days" for default out of stock
2. In Product/Data for each product I set:
- "Quantity" to "0"
- "Subtract Stock" to "no"
It seems to be working but I am not 100% sure.
The second part of my question is how to change the text of the "Out of Stock Status"; instead of "2-3 Days" I'd like it to read "3-4 Weeks Delivery" or something in those lines. How can I do that?
Cheers,
Valentina
Re: pre-order visual enhancement for availability
Posted: Fri Sep 10, 2010 7:22 pm
by fido-x
vkaltchev wrote:... The second part of my question is how to change the text of the "Out of Stock Status"; instead of "2-3 Days" I'd like it to read "3-4 Weeks Delivery" or something in those lines. How can I do that?
Cheers,
Valentina
Log in to your administration. From the menu, select "System->Localisation->Stock Statuses", then click the "Edit" link in the "Action" column for the entry you want to edit.
Re: pre-order visual enhancement for availability
Posted: Sun Sep 12, 2010 1:20 pm
by vkaltchev
I feel like an idiot - didn't expect to have the "fix" in admin and was waiting to see a long list of codes.
Thank you Fido for opening my eyes and solving my "big" problem
Any way to change the text color to red (not a must, just want to experiment)?
Cheers,
Valentina
Re: pre-order visual enhancement for availability
Posted: Sun Sep 12, 2010 1:34 pm
by fido-x
You can change the colour in your template file (catalog/view/theme/default/template/product/product.tpl). Find the following (around lines 27 to 30):
Code: Select all
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><?php echo $stock; ?></td>
</tr>
And change to:
Code: Select all
<tr>
<td><b><?php echo $text_availability; ?></b></td>
<td><span style="color: #FF0000;"><?php echo $stock; ?></span></td>
</tr>
This will then display your stock status in red.
Re: pre-order visual enhancement for availability
Posted: Wed Sep 22, 2010 4:25 am
by vkaltchev
Thank you so much, Fido; it did the job!
Cheers,
Valentina
Re: pre-order visual enhancement for availability
Posted: Mon Feb 21, 2011 12:51 am
by schlegk
Just what I need, but it has to be compatible with PAPs (Product Image Attributes).
http://www.opencart.com/index.php?route ... order=DESC
Any ideas?
Re: pre-order visual enhancement for availability
Posted: Wed May 18, 2011 5:57 am
by funkyou86
Thank you very much for this modifications. Works perfectly on OC 1.4.9.4

Re: pre-order visual enhancement for availability
Posted: Wed May 18, 2011 8:24 pm
by funkyou86
Any idea how can I edit the color of the "Pre-Order" status? I alredy did the in stock color change, but can't find the others. Please advise. Thanks

Re: pre-order visual enhancement for availability
Posted: Fri Feb 24, 2012 5:18 am
by yiyinlah
Great work!!!

Re: pre-order visual enhancement for availability
Posted: Wed Feb 27, 2013 6:17 pm
by PlusCybernet
FFJim wrote:I take pre-orders on some items but do not allow "stock checkout" for out-of-stock items. Instead of having availability display as "In Stock" I want these items to show "Pre-Order".
To accomplish this, for the pre-order items I set the product's out-of-stock message to "Pre-Order" instead of the default setting. (Whatever non-default message you select will be displayed.) I also set the stock to whatever my incoming stock will be. Then I altered catalog/controller/product/product.php as follows:
Find this:
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
$this->data['stock'] = $this->language->get('text_instock');
}
}
Replace with this:
Code: Select all
if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock'];
} else {
if ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
if ($product_info['stock_status_id'] == $this->config->get('config_stock_status_id')) {
$this->data['stock'] = $this->language->get('text_instock');
} else {
$this->data['stock'] = $product_info['stock'];
}
}
}
Now availability shows as follows:
(1) If stock is zero and out-of-stock is the default, shows the default "Out Of Stock" text
(2) If stock is zero and out-of-stock is not the default, shows product's OOS text
(3) If stock is 1 or more and out-of-stock is the default, shows "In Stock" text
(4) If stock is 1 or more and out-of-stock is not the default, shows the product's OOS text
This doesn't completely resolve pre-ordering needs, but it at least gives a better availability status. I hope its helpful to others who take pre-orders.
It's not working with OC 1541, can you please provide code for latest version.
Re: pre-order visual enhancement for availability
Posted: Mon Jul 15, 2013 7:55 am
by modmyairsoft
Here is what I get for product pages that have product availability set to out of stock or pre order.
Notice: Undefined index: stock in /home1/modmyair/public_html/Shop/catalog/controller/product/product.php on line 282
I need some help.