Author Topic: Disabled stock tracking  (Read 2613 times)

Offline junkyard

  • Full Member
  • ***
  • Posts: 127
  • Karma: +24/-0
    • View Profile
Disabled stock tracking
« on: July 10, 2014, 07:17:43 AM »
Are you familiar with situation when some of your orders are never paid?  Reasons vary (afterall, it's up to a customer), and in reality it may happen quite often.
By default in the cart, the ordered amounts are automatically subtracted from stock, so you will have to add the stock manually for each such product.

We do have the related Stock Tracking feature in AbanteCart, but :
- it can be managed per product only (at least in 1.1.7),
- it is ignored by the system whatever value you choose (Yes or No), the amount is always subtracted (at least in 1.1.7), so if you thought you would do a quick database update like
   mysql> update ab_products set subtract=0;
to disable Stock Tracking for all your products, it will not help  (at least in 1.1.7).

The cart does have a seemingly related global configuration parameter in the Settings->All,  called 'config_stock_subtract' for the Checkout group, but it cannot be changed in the Admin. Anyways, it is set to Off by default, and changing its value to 1(On) in the database doesn't make any difference  (at least in 1.1.7).

Soo... :)  The Tip & Trick is to add exclamation mark into the file  /public_html/storefront/model/checkout/order.php   line 247

[~/public_html/storefront]# diff model/checkout/order.php ~/tmp/order.php.saved
247c247
<             if (!$product['subtract']) {
---
>             if ($product['subtract']) {

This line is in the following section:
---
foreach ($order_product_query->rows as $product) {
                                if ($product['subtract']) {
                                        $this->db->query("UPDATE " . $this->db->table("products") . "
                                                                          SET quantity = (quantity - " . (int)$product['quantity'] . ")
                                                                          WHERE product_id = '" . (int)$product['product_id'] . "'");
---

As a result, you will have the "stock tracking" really disabled for all products at once.  To enable it back, revert the change.

The hack is related to how often your orders are really paid, and your inventory/stock control at the same time.
It is based on the issues discussed earlier in these threads:
 http://forum.abantecart.com/index.php/topic,198
 http://forum.abantecart.com/index.php/topic,1257

We found it's more appropriate to subtract the actual stock manually after the order was really paid,  instead of monitoring and manually adding the stock for the unpaid orders. Especially when you have to keep low amounts of 1-2 in the stock for each product, while a good chunk of your orders will never be paid. 
We haven't seen anything relevant mentioned in the release notes for 1.1.8 and 1.1.9, so it might be the same in these versions too. Hope it helps

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 3825
  • Karma: +185/-0
    • View Profile
Re: Disabled stock tracking
« Reply #1 on: July 11, 2014, 05:49:56 AM »
Are you familiar with situation when some of your orders are never paid?  Reasons vary (afterall, it's up to a customer), and in reality it may happen quite often.
By default in the cart, the ordered amounts are automatically subtracted from stock, so you will have to add the stock manually for each such product.

We do have the related Stock Tracking feature in AbanteCart, but :
- it can be managed per product only (at least in 1.1.7),
- it is ignored by the system whatever value you choose (Yes or No), the amount is always subtracted (at least in 1.1.7), so if you thought you would do a quick database update like
   mysql> update ab_products set subtract=0;
to disable Stock Tracking for all your products, it will not help  (at least in 1.1.7).
.........
We haven't seen anything relevant mentioned in the release notes for 1.1.8 and 1.1.9, so it might be the same in these versions too. Hope it helps

Hello we recommended to update cart to latest version (1.1.9)
Also please read short manual about Stock processing configurations

In the latest AbanteCart version go to Admin-System-Settings-Checkout Tab search for Stock Checkout setting. If set it to ON this will allow customers to still checkout if the products they are ordering are not in stock.
“Chuck Norris is so amazing.”
― Mother Teresa