♥raiwa Posted February 5, 2018 Share Posted February 5, 2018 Not sure if this has been discussed before, I didn't find anything. Scenario: Check stock level and Subtract stock is set to true An order is placed which reduces product stock to zero and turns product status to false This order is deleted in admin with the checkbox " Restock product quantity " ticked Products stock is correct restocked to the quantity before this order Product status is still in false Shouldn't the product status also be resetted to "true" in that case or at least a checkbox and condition added "switch product status to true" The code modification (without additional checkbox and condition) would be: in: admin/includes/functions/general.php within the "tep_remove_order" function: change: tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'"); to: tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . ", products_status = (IF(products_quantity + " . $order['products_quantity'] . " > 0, 1, 0)) where products_id = '" . (int)$order['products_id'] . "'"); About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥Moxamint Posted February 6, 2018 Share Posted February 6, 2018 For my shop I prefer not to even turn product status to false when the product has been bought out. It confuses the customer. Thanks, Eddy Link to comment Share on other sites More sharing options...
mcmannehan Posted February 9, 2018 Share Posted February 9, 2018 Hmmmm... I dont have any problem at all with that. Everything works fine on osC 2.3.4 BS. Without the recommanded changes from @raiwa The clever one learn from everything and from everybody The normal one learn from his experience The silly one knows everything better [socrates, 412 before Christ] Computers help us with the problems we wouldn't have without them! 99.9% of the bugs sit in front of the computer! My programmed add-ons: WDW EasyTabs 1.0.3, WDW Facebook Like 1.0.0 if(isset($this) || !isset($this)){ // that's the question... Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 9, 2018 Share Posted February 9, 2018 @raiwa In which version of osC is this happening to you? Is it a loaded shop or vanilla osC? I just quickly installed the latest Edge version on my local server and tested it. I set quantity to 1 and bought the item. In the admin area even with quantity 0 status is set to "true" and not "false". So the product still shows inside the shop even with stock quantity 0. Not ideal if you ask me. In the Configuration settings "Stock" I set Allow checkout to "false" and it does prevent checkout since item has 0 quantity. I am not sure if osC was handling products statuses always like that though. I can set the status to false manually but it won't go back to true if I restock the quantity. Hope what I just explained made sense. Link to comment Share on other sites More sharing options...
♥raiwa Posted February 9, 2018 Author Share Posted February 9, 2018 @mcmannehan, @Tsimi, Sorry, my described scenario was uncomplete. It must say: Scenario: Allow Checkout is set to false Check stock level and Subtract stock is set to true ..... Like this when the stock reaches zero after an order is completed, the status is set to false (zero). The relevant code is in checkout_process.php ( and paypal_standard.php and other external payment modules): line 174-177: tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . (int)$stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'"); } @Tsimi, I discovered it on a real store, but checked now in a vanilla test installation of the latest 2.3.4.1 EDGE and it is just the same like described. @mcmannehan, please try it with exact the described scenario and settings. If you have Allow Checkout set to true, the described problem does not appear. See the above code. Could you also explain what exact you mean by "Everything works fine ". Does the products status stay in "true" when reaching zero stock or does it get switched back to "true" on restocking? rgds Rainer About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 9, 2018 Share Posted February 9, 2018 @raiwa Had another go at it and this time I could recreate the situation. Your code fix inside the first post works like a charm. It is only logical to have the status switch back to green when the quantity is larger than 0. I would like to see the same if you update the product quantity inside the categories.php case update_product? You can switch it manually after you updated the quantity but a more automated approach would be cool. Link to comment Share on other sites More sharing options...
♥raiwa Posted February 9, 2018 Author Share Posted February 9, 2018 @Tsimi, my scenarion is a specific case when an order is deleted (cancelled) and the products are therefore available again. On the categories page there may be good reasons to keep stock and status as separate concepts. A store owner may wish to update products stock without changing the status of a product. I believe at least there should be a checkbox to make the update optional. And for an add-on or core inclusion of my suggested modification in orders.php there should be also a check-box be added to make the status update optional. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.