Forums / General Questions / Problem with products not switching off when out of stock..

Problem with products not switching off when out of stock..

Locked

Started by philip937 on 12 Oct 2009, 9:12 PM · Views: 1,554

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
12 Oct 2009, 9:12 PM
#1
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Problem with products not switching off when out of stock..

Hi Everyone

Im hoping you can help. For some strange reason whether my

Configuration/Stock/Products status in Catalog when out of stock should be set to

is set to 0 or 1, neither is turning my products off when out of stock???

Is this a known issue, it is only recently I am trying to use this feature and do not know if it has occurred since installing other mods or customizing my zen??

is there any specific code I can check??

Any Help or Direction would be very much appreciated..

Regards
Phil

:no:

Phil Rogers
A problem shared is a problem solved.

12 Oct 2009, 9:25 PM
#2
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: Problem with products not switching off when out of stock..

philip937:

Hi Everyone

Im hoping you can help. For some strange reason whether my

Configuration/Stock/Products status in Catalog when out of stock should be set to

is set to 0 or 1, neither is turning my products off when out of stock???

Is this a known issue, it is only recently I am trying to use this feature and do not know if it has occurred since installing other mods or customizing my zen??

is there any specific code I can check??

Any Help or Direction would be very much appreciated..

Regards
Phil

:no:

This fix might help

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

12 Oct 2009, 9:30 PM
#3
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

clydejones:

This fix might help

I might need more guidance on this. My standard product listings are showing out of stock products even when change status to 0 is selected. I'm not sure how to use the suggested fix for the New and upcoming products to fix my problem.

Thanks
Phil

Phil Rogers
A problem shared is a problem solved.

12 Oct 2009, 10:23 PM
#4
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

philip937:

I might need more guidance on this. My standard product listings are showing out of stock products even when change status to 0 is selected. I'm not sure how to use the suggested fix for the New and upcoming products to fix my problem.

Thanks
Phil

I looked in /includes/modules/products_listing.php and there doesn't seem to be any similar code to the suggested support thread? im lost, no idea where to begin looking.

Phil Rogers
A problem shared is a problem solved.

13 Oct 2009, 3:51 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Problem with products not switching off when out of stock..

Your problem could be related to many things, including:
a) manually injecting product and attribute records instead of using the built-in UI designed for that purpose: http://www.zen-cart.com/forum/showthread.php?t=138644
b) using an addon that replaces the normal stock-handling logic http://www.zen-cart.com/forum/showthread.php?p=790881#post790881

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Oct 2009, 5:39 AM
#6
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

DrByte:

Your problem could be related to many things, including:
a) manually injecting product and attribute records instead of using the built-in UI designed for that purpose: http://www.zen-cart.com/forum/showthread.php?t=138644
b) using an addon that replaces the normal stock-handling logic http://www.zen-cart.com/forum/showthread.php?p=790881#post790881

Assuming it's one of these 2, I'm going to for now assume it's not b as no one else using stock by attributes seems to have this problem. So if it's a, please help me understand the normal logic, if I manually inject stock levels, which yes I am, I would have thought this to be no different than setting a stock level to 0 through the admin UI? Ontop of which surely all the change status of product when stock is zero, just checks the value of the product_id's stock?

When I set an out of stock image to be placed next to a product listing when out of stock, this works fine, so zen must be recognising these levels regardless of manually setting stock levels no?

If you can explain to me the zen functions when calculating whether or not a products status should be on or not perhaps I can either check mines not corrupt or maybe adapt for the way I'm using zen?

Many Thanks
Phil
Posted via Mobile Device

Phil Rogers
A problem shared is a problem solved.

13 Oct 2009, 6:20 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Problem with products not switching off when out of stock..

I'm not convinced that it's not your addon.

But if you've not set the out-of-stock product-status to 0 then it's not going to work either.

You can see that the code in a clean install of Zen Cart properly sets the product status to 0 by looking for this in the order.php class file:```
if (SHOW_PRODUCTS_SOLD_OUT == '0') {

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Oct 2009, 6:37 AM
#8
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

I have set the out of stock status to 0, and it didn't work that's the point I figured there was something up.

I haven't however looked in order.php class file, so I shall check that this code is there I guess? So that is the code that the setting in configuration/stock looks at right?

Phil
Posted via Mobile Device

Phil Rogers
A problem shared is a problem solved.

13 Oct 2009, 5:20 PM
#9
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

DrByte:

I'm not convinced that it's not your addon.

But if you've not set the out-of-stock product-status to 0 then it's not going to work either.

You can see that the code in a clean install of Zen Cart properly sets the product status to 0 by looking for this in the order.php class file:```
if (SHOW_PRODUCTS_SOLD_OUT == '0') {


I am just looking at the code you said about, I have the follwoing:

```php
        if ($stock_left <= 0) {
            // only set status to off when not displaying sold out
            if (SHOW_PRODUCTS_SOLD_OUT == '0') {
              $db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");

So does this database queery only take place when a product is checked out and stock then reaches 0? If so the option works differently to how i imagined, I thought that if you set the option to turn product status to 0 if out of stock it would just not show any products with stock less that 0 in the prduct listings???

Is there a way to do what I need it to do? so effectively hide all product_id's where their stock level is less than 0???

I really really dont want out of stock products showing :lookaroun

Phil Rogers
A problem shared is a problem solved.

13 Oct 2009, 7:52 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Problem with products not switching off when out of stock..

The simplest way to do that is to go and set the products_status to 0 for all your products whose stock is less than 1.

Or, you can go through every query in the core code and adjust it to suit your own needs.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Oct 2009, 7:57 PM
#11
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

DrByte:

The simplest way to do that is to go and set the products_status to 0 for all your products whose stock is less than 1.

Or, you can go through every query in the core code and adjust it to suit your own needs.

Do mean to manually set them to 0? or is there a way to automate it? and if it can be done, when the product which has had status set to 0, when stock is added will it re-enable it?

Phil Rogers
A problem shared is a problem solved.

13 Oct 2009, 8:04 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Problem with products not switching off when out of stock..

The only part currently automated is when a customer places an order that drops the inventory to 0 or less, then the product's status is disabled ... if the admin setting is set to have it do that.

Managing your inventory levels including replenishing inventory counts as well as enabling or disabling products when they're available or not ... are all tasks left to you to handle.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Oct 2009, 8:07 PM
#13
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Problem with products not switching off when out of stock..

Ok Cheers,

Im pretty sure know what I need to do now :o)

thanks

phil

Phil Rogers
A problem shared is a problem solved.