Page 1 of 6

@tik Remove Add to Cart button for Out of Stock items

Posted: Sat Jun 30, 2012 5:52 am
by OC2PS
Go to Extension page

There are several ways of dealing with Out of Stock products. Some of us don't want customers to be able to buy products that are out of stock.

OpenCart has an option AP > System > Settings > {Edit store} > Option > Stock, mark Stock Checkout as No) that disallows customers to check out if they have an out of stock item in their shopping cart. This is a start, but for many of us it's just not consequential!

Hence this mod. This extension removes the Add to Cart button and replaces it with an "Out of stock" message for out-of-stock products. This way, customers can't even place an out-of-stock product into their shopping carts.

Because this is a vQmod, no core files are touched, and the changes should carry over to the next version.

Requirements
  1. This is a vQmod for Opencart. Hence you need OpenCart and vQmod preinstalled.
  2. This vQmod is made for the default theme. Hence you should have the default theme as the active theme for this to work. While you can very easily modify this for other themes, the out-of-the-box support is only for default theme. If you don't know how, and need me to do paid customization, please PM me.
  3. Please note that this mod applies to all pages and modules shipped in Opencart core. But if you have an additional module or page containing an Add to Cart button, then unfortunately this mod will not affect it. You can modify the mod to affect that module/page, but the out-of-the-box support is only for OC default package. If you don't know how to make changes, and need me to do paid customization, please PM me.
Installation
Upload the contents of the uploads folder to your shop's root folder.

How do I change the color/size/font of the out of stock message?
Use CSS to style the class outofstock
(e.g. by using http://www.opencart.com/index.php?route ... on_id=6241 )
Sample css

Code: Select all

.outofstock {
color: red;
font-size: 12px;
}
How do I change the text of the out of stock message?
AP > System > Localisation > Stock Statuses > {Edit Out of Stock}

Advertising
This free mod adds my link to your English site's footer (next to the Opencart link). It would be nice if you don't remove it.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 12:36 am
by darbebe
Hi,

i have installed the extension however unsure how to go about using it. Can you elaborate on how things go about after the installation?

This will be a helpful extension for my webbie.

Thanks in advance

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 1:18 am
by OC2PS
darbebe wrote:how things go about after the installation?
I've kept it simple. If the quantity (in stock) of an item goes below zero, then Add to Cart button is replaced by "Out of Stock" message. If Opencart is not doing the inventory for you (you have not selected "Subtract Stock:"), then you will need to manually set the Quantity of out of stock products to zero manually. That's pretty much all there's to it.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 9:08 am
by darbebe
Thanks for your reply.

Please dont laugh at me as I'm new to opencart.

i have just installed the vQMod for this extension. Do i place the 'disable add to cart' file in the vqmod/xml folder?

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 11:03 am
by OC2PS
Yes. As a general principle for most extensions, and definitely for my extensions, if you upload the contents of upload folder to your shop root, files go to their correct places.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 12:27 pm
by darbebe
Tried but it's not working.

The product is still able to be added into cart. Anything else that is required but not done by me?

Really thanks for your assistance.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 12:30 pm
by OC2PS
Do you have OC 1.5.3.1? Do you have vQmod 1.2.6? Are you using Default theme?

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 12:40 pm
by darbebe
oh..my opencart version is 1.5.2.1. other than that, the vqmod and the theme is as per what you stated.

the extension does not work with my 1.5.2.1?

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Jul 03, 2012 12:49 pm
by OC2PS
I have tested only with 1.5.3.1

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Sun Jul 08, 2012 12:23 pm
by jurpro
I'm using 1.5.3.1 but nothing happen. product still available even 0.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Sun Jul 08, 2012 2:27 pm
by OC2PS
Default theme? vQmod 1.2.6?

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Sun Jul 08, 2012 3:20 pm
by jurpro
OC2PS wrote:Default theme? vQmod 1.2.6?
Yup... any broken code?

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Sun Jul 08, 2012 4:03 pm
by OC2PS
Can you provide a link to a product with quantity 0? Also, any other relevant details like mods etc.

Haven't seen this issue before.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Mon Jul 09, 2012 11:42 am
by hbg
Hi, just a quick note to let you know I have tested it with 1.5.1.3. with Default Theme. I have just upgraded to VQMod 2.1.6.
Great Idea, but it didn't work.
This is an out of stock product:-
http://opencart.homebrewinn.com.au/shop ... eese-press
This was the error:-
--------- Date: 2012-07-09 03:37:21 ~ IP : 58.108.164.115 ----------
REQUEST URI : /shop/cheese-making/hardwaremoulds/mad-millie-cheese-press
MOD DETAILS:
modFile : /home/homebrew/public_html/opencart/shop/vqmod/xml/remove-add-to-cart-if-out-of-stock.xml
id : Remove Add to Cart button for Out of Stock items
version : 1.0.1
vqmver : 2.1.6
author : OC2PS
SEARCH NOT FOUND (ABORTING MOD): <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />

I thought that you maybe interested, for future development.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Mon Jul 09, 2012 12:27 pm
by OC2PS
hbg wrote:I have tested it with 1.5.1.3. with Default Theme.
Not supposed to work on 1.5.1.3

Developed for and tested with 1.5.3.1 as it says on documentation as well as in download compatibility.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Mon Jul 09, 2012 12:49 pm
by hbg
OC2PS wrote:
hbg wrote:I have tested it with 1.5.1.3. with Default Theme.
Not supposed to work on 1.5.1.3

Developed for and tested with 1.5.3.1 as it says on documentation as well as in download compatibility.
Hi, some modules do work on other versions (even though they only state a particular version), but I just wanted to let you (& others) know that it won't work with 1.5.1.3. :-)

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Mon Jul 09, 2012 12:54 pm
by OC2PS
I appreciate it.

All I meant is I won't go back to work on creating compatibility with older versions. If it works with 1.5.2.1 or 1.5.1.3, that's great, but I won't put additional effort to make it work with the versions that I have not intended it to work with.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Thu Aug 09, 2012 1:33 am
by loki52
I've tried installing this extension on a fresh install of opencart 1.5.3.1 with vqmod 2.1.6 and nothing happens to the product page when the quantity reaches 0. The "Add to Cart" button is still visible and active. Please advise.

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Thu Aug 09, 2012 2:57 am
by OC2PS
loki52 wrote:The "Add to Cart" button is still visible and active. Please advise.
Please post a sample URL

Re: @tik Remove Add to Cart button for Out of Stock items

Posted: Tue Aug 21, 2012 1:25 am
by estateP
I have installed this and it works great. Many thanks! :)

One request though. The items I sell in my store are on off's, so when sold they are gone for good. I still want to keep them in the store as a showcase of products sold, and for SEO.

Because they are one off's, they are never going to come back into stock so the "out of stock" message is slightly misleading. Is there any way to change the message displayed to "SOLD" rather than "OUT OF STOCK"?

Also, is it possible to make the message text smaller.

Thanks for a great mod. Having the add to cart button on sold out items always seemed strange to me.