Forums / Templates, Stylesheets, Page Layout / Need help urgently - can't figure out how something was done in the past

Need help urgently - can't figure out how something was done in the past

Started by matchlock on 25 Jan 2013, 5:16 AM · Views: 1,293

Results 1 to 11 of 11
25 Jan 2013, 5:16 AM
#1
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Need help urgently - can't figure out how something was done in the past

At some point in the past I made a change based on a thread on the forum. This change made the cart disable the add to cart button and display out of stock when inventory was less than X amount. I have absolutely no idea where I did this and I'm having no luck finding the thread. Any help on how to reverse this would be GREATLY appreciated.

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

25 Jan 2013, 6:30 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Need help urgently - can't figure out how something was done in the past

stock should be settings in
admin > config > stock

Zen-Venom Get Bitten

25 Jan 2013, 6:33 AM
#3
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

kobra:

stock should be settings in
admin > config > stock

Kobra,

Thanks for the reply, I could be wrong so please forgive me if I am but I'm 99% sure this was done on the code level. Something is telling zen cart that if inventory is less than 4 show out of stock.

Take a look at this for an example https://www.matchlockarms.com/shotguns/mossberg/mossberg-500-12-28-vr-24-rs-rfl-combo

if this is fixable in the admin I just don't see it.

Thanks again for your reply!

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

25 Jan 2013, 6:37 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Need help urgently - can't figure out how something was done in the past

I could be wrong so please forgive me if I am but I'm 99% sure this was done on the code level.
Since you can not recall...your best bet is to download your files and grab a fresh distribution of the version you are using and run a file compare....

Prior to this can you switch to the classic template and see if the issue persists
If not then you only need look to your template override files

Zen-Venom Get Bitten

25 Jan 2013, 7:03 AM
#5
drbyte avatar

drbyte

Sensei

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

Re: Need help urgently - can't figure out how something was done in the past

Might be in this section of includes/classes/order.php ```
if ([B]$stock_left <= 0[/B]) {
// 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']) . "'");
}
}

.
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.

26 Jan 2013, 12:40 AM
#6
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

DrByte:

Might be in this section of includes/classes/order.php ```
if ([B]$stock_left <= 0[/B]) {
// 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']) . "'");
}
}


I just got super excited when i saw your post and thought this was it for sure.  Unfortunately it was not.  I have a dev store (dev(dot)matchlockarms.com) setup that doesn't have this issues/change made to it and i did a diff on the files.  They match exactly so the change wasn't made here.  This has to be something very simple it's just buried somewhere.  anyone know how to do a diff in linux that would compare all the files between the dev site and the production site?  Thank you all for your help btw.

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

26 Jan 2013, 12:44 AM
#7
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

kobra:

Since you can not recall...your best bet is to download your files and grab a fresh distribution of the version you are using and run a file compare....

Prior to this can you switch to the classic template and see if the issue persists
If not then you only need look to your template override files

I just used your suggestion of switching to classic and the change was made somewhere which causes it to exist in that template as well. Would this be a DB change perhaps? I can't believe i would change a core file and not use an override (BUT that's not to say i wasn't tired and did so :))

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

26 Jan 2013, 12:55 AM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

It's most likely a MODULE, CLASS or a FUNCTION file.

Unlikely to be a database issue - unless the value that determines the behaviour is adjustable somewhere in admin (but this would have been part of the code change as well.

20 years a Zencart User

26 Jan 2013, 5:22 AM
#9
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

schoolboy:

It's most likely a MODULE, CLASS or a FUNCTION file.

Unlikely to be a database issue - unless the value that determines the behaviour is adjustable somewhere in admin (but this would have been part of the code change as well.

I'm familiar with the location of the modules and the functions, but where are the CLASS? Thanks!

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

26 Jan 2013, 5:55 AM
#10
matchlock avatar

matchlock

New Zenner

Join Date:
Jun 2011
Posts:
92
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

matchlock:

I'm familiar with the location of the modules and the functions, but where are the CLASS? Thanks!

Disregard! You let this horse to water and I was able to drink and find exactly where this was done! Schoolboy, thank you so much! Also thank you to the others who contributed as well.

for reference:
in includes/functions file functions_general.php

Original line
case ($button_check->fields['products_quantity'] <= 0 and SHOW_PRODUCTS_SOLD_OUT_IMAGE == '1'):

My line
case ($button_check->fields['products_quantity'] <= 3 and SHOW_PRODUCTS_SOLD_OUT_IMAGE == '1'):\

note the greater than equal to 3

For anyone wonder or needing this function and finding this thread in the future here is the back story.

My site is fed inventory counts from multiple wholesalers. Because of this fact if the inventory is low at a wholesaler I may not be able to secure an item before they sell out therefore leaving my customer without the product they ordered. The setting above solves this problem (sort of). What the setting does is sets a product to out of stock if the quantity is less than 3 available. This is great as a blanket setting, but occasionally i have inventory on hand (which is the case now). It would be nice and I'm sure it is possible (not a php guru) to exclude certain products from the setting but should you need to do something similar this is how it is done.

All the best,

Owner - MatchLock Arms, LLC and M&M Toys (Yes I sell toys and guns, but not toy guns)
http://www.matchlockarms.com
http://www.mandmtoys.com

26 Jan 2013, 6:39 AM
#11
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Need help urgently - can't figure out how something was done in the past

matchlock:

My site is fed inventory counts from multiple wholesalers. Because of this fact if the inventory is low at a wholesaler I may not be able to secure an item before they sell out therefore leaving my customer without the product they ordered.

My turn to thank YOU...

I have many clients who use dropshippers and this may be some way to resolving their stock issues as well...

20 years a Zencart User