Page 3 of 5

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Sat Jan 21, 2012 1:31 am
by GoGo OpenCart
Here's a mod I've created, which works on every page of OpenCart where the "Add to Cart" button is shown:

http://www.opencart.com/index.php?route ... on_id=4358

You can choose to disable button for all "Out of Stock" items, or leave it enabled for "Pre-Order", "2 - 3 Days", etc.

Here's another for the options as well:

http://www.opencart.com/index.php?route ... on_id=4468

PM if you want 20% discount for purchasing both ;)

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Fri Jan 27, 2012 1:46 am
by tropnevad
Thanks for releasing the usefull VQmod!

Has anyone used this for the shoppica theme? I tried to edit the xml file, the part that says

<!-- Clone this block and change default for additional themes -->

But after changing default to shoppica it does not seem to work.

Perhaps the theme is differant or I have another extension that is interfering with this. Any help/suggestions for shoppica theme would be appreciated

I did manage to get this to work for the default template of opencart 1.5.1.3, but not with shoppica

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Wed Feb 01, 2012 5:45 pm
by vytasm
mwshark wrote: I have modified the previous version as I too needed the mod to work for the latest products. I have updated the new version (attached)
I have modified it to work with related product tab. Now it changes buttons "Add to cart" to "Out of stock" and disables them for all products that are out of stock (quantity <= 0). Tested on OC 1.5.1.3 default theme.

UPDATE!
1.0.4 related product tab on the product page, on manufacturer, product compare and wishlist pagess Enjoy :drunk:

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Wed Feb 01, 2012 7:47 pm
by olimax
Brilliant
Thank you
Doesnt work in the wish list for me though (1.5.1.3)

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Wed Feb 01, 2012 8:25 pm
by vytasm
olimax wrote:Brilliant
Thank you
Doesnt work in the wish list for me though (1.5.1.3)
Now works on wishlist to! Updated my previous post attachment to v1.0.4 :ok:

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Wed Feb 01, 2012 8:32 pm
by olimax
good man. thanks

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Fri Feb 03, 2012 5:19 am
by vytasm
Change "Add to cart" button when product is out of stock. Created for OpenCart v1.5.1.3
Works on all standard theme places (Product, category, manufacturer, search, featured, specials, latest, wishlist, compare) where "Add to cart" button appears.

In v1.2.0 added new functionality.
  • When item quantity is 0 then "Add to cart" button is disabled and label is changed to "Out of stock".
  • When item quantity is less than 0 (ex. -1), then "Add to cart" button is enabled and label is changed to "Pre-Order". This allows add items into cart and checkout if checkout is enabled when items are not in stock (Admin -> System -> Settings -> (Select shop) -> Option -> set "YES" for "Stock Checkout"). If this is not enabled then Add to cart is disabled and label is set to "Out of stock"
So now it is customers can buy products even when they are not in stock, showing that information on "Add to cart" button anywhere.

UPDATED!
v1.2.1 2012.02.06 vytasm - (OpenCart v1.5.1.3)
- Bugfix: fixed problem in few modules when button was in Pre-Order state was not possible to add items to Cart.

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Tue Feb 07, 2012 4:46 am
by vytasm
Found a small bug when copying some lines.I have changed my previous post with the fixed version. Please update who has downloaded and using it :whistle:

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Mon Mar 19, 2012 7:01 pm
by svenman
Hi,

Thank you very much for this, it's great! However, the 'out of stock' button looks strange, the left side is square and there is grey area behind it. How do I change this? I'm very new at this...

Thanks!

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Mon Mar 19, 2012 8:18 pm
by vytasm
svenman wrote:Hi,
Thank you very much for this, it's great! However, the 'out of stock' button looks strange, the left side is square and there is grey area behind it. How do I change this? I'm very new at this...
Thanks!
Have you a picture, or better a link to your shop that I could see. Link you can post me using PM then I can say what is wrong. maybe I have left something with the styles... By the way what version of OC are you using?

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Wed Mar 21, 2012 8:52 am
by Goncharenko
vytasm, thanks very much for your mod, exactly what I was searching for.

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Thu Mar 29, 2012 2:59 pm
by ikhlief
Does it work for V1.5.2.1?
Thanks

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Tue Apr 03, 2012 5:38 pm
by TechSitement
It doesn't appear to be working for 1.5.2.1. :-\

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Mon Apr 16, 2012 7:31 pm
by msmith
TechSitement wrote:It doesn't appear to be working for 1.5.2.1. :-\
No neither of the versions work for 1.5.2.1 (not even Q's)

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Mon Apr 16, 2012 8:36 pm
by miran
I have updated the mod but t he "out of stock" button will show everywhere except the category page..
Maybe someone can do it, i am a newbie:) Here it goes:

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Thu Apr 26, 2012 2:57 am
by frisco_aw
i changed a little bit Miran's code to make it working for category. It seems to be working for me. Hopefully, it will work for you guys also. I tested with 1.5.2.1 version.

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Tue May 01, 2012 12:25 am
by msmith
Thanks to both of you, it's working great now !

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Tue May 01, 2012 2:39 am
by olimax
one small bug for that new version (1.5.2.1)
if a category is empty you get an error
Notice: Undefined variable: result in ....\vqmod\vqcache\vq2-catalog_controller_product_category.php on line 271

you need to change this

Code: Select all

	<!-- Category Controller Mod -->	
	<file name="catalog/controller/product/category.php">
		<operation error="skip"><!-- v15x -->
            <search position="before"><![CDATA[
			if ($this->config->get('config_review_status')) {
			]]></search>
            <add trim="true"><![CDATA[
	if ((float)$result['quantity']) {
					$quantity = (int)$result['quantity'];
				} else {
					$quantity = false;
				}
				]]></add>
        </operation>

to this

Code: Select all

	<!-- Category Controller Mod -->	
	<file name="catalog/controller/product/category.php">
		<operation error="skip"><!-- v15x -->
            <search position="before"><![CDATA[
			if ($this->config->get('config_review_status')) {
			]]></search>
            <add trim="true"><![CDATA[
  if(!isset($result['quantity'])) $result['quantity'] = 0;
	if ((float)$result['quantity']) {
					$quantity = (int)$result['quantity'];
				} else {
					$quantity = false;
				}
				]]></add>
        </operation>
it may need it elsewhere too but I haven't checked

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Thu May 10, 2012 1:38 pm
by arielito23
O0 O0 O0 O0 O0 O0 O0 O0 O0

Re: [vQmod] Hide AddtoCart for Out of Stock Products

Posted: Sun May 27, 2012 1:45 pm
by storm-cloud
vytasm wrote:UPDATED!
v1.2.1 2012.02.06 vytasm - (OpenCart v1.5.1.3)
- Bugfix: fixed problem in few modules when button was in Pre-Order state was not possible to add items to Cart.
Hello Vytasm,

Great Mod!

However, I have found a quirk which I hope someone may be able to resolve. Here goes, I hope it makes sense...

For Pre Order to work, this mod requires the Stock Checkout option to be enabled. This almost works perfectly. If the product stock quantity is zero the Add to Cart button will be disabled (even when Stock Checkout is enabled) and the Out of Stock button will appear. If the stock is set to a negative quantity, the Pre Order button will show up and the customer can complete Checkout... So far, so good.

However the problem is, if for example there is perhaps 2 remaining of a particular product and you do not want to sell this product when out of stock, if the customer adds 3 or more to their basket, they are still able to Checkout due to Stock Checkout being enabled.

Any ideas on how to overcome this?