juanjico Posted September 24, 2016 Share Posted September 24, 2016 Hi! I'm developing a simple module that hooks to hookActionUpdateQuantity and update the stock of other products. But, I'm using StockAvailable::getQuantityAvailableByProduct() to get current available stock and this still have the old value. For example: I buy one unit for a p roduct which current stock is 11. Inside hookActionUpdateQuantity(), the $params value passed have the correct new stock value for the product (10). But, if I call the StockAvailable::getQuantityAvailableByProduct() for the same product, I got the old stock value (11). So, it's seems that the hook is called BEFORE the stock value is recorded on database. Is this true or I'm missing something ? Thanks! Link to comment Share on other sites More sharing options...
rocky Posted September 25, 2016 Share Posted September 25, 2016 That's right, the hook is called before the data is saved. You should use the $params['quantity'] only, not any function calls to get the current quantity. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now