ngomezleal Posted October 4, 2014 Share Posted October 4, 2014 Hi all, Could you please tell me where this prestashop php in the file, which makes the reduction of a product when a purchase is made using the method of payment by check? waiting for your valuable responses. Link to comment Share on other sites More sharing options...
NemoPS Posted October 4, 2014 Share Posted October 4, 2014 You mean which snippet is responsible of decreasing product quantities? OrderHistory.php OrderHistory::changeIdOrderState() Look for StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop); And other occurrences of that method Link to comment Share on other sites More sharing options...
ngomezleal Posted October 4, 2014 Author Share Posted October 4, 2014 Nemo1 Hi thank you very much for your answer. Nemo1, just let me know the resposable of declining product by any method. Nemo1, based on your answer, I found the file in: classes / order / => OrderHistory.php Nemo1 would do the following: Instead of reducing the product, the product increases. The code to which you refer is me: StockAvailable :: updateQuantity ($ product ['product_id'], $ product ['product_attribute_id'], - (int) $ product ['product_quantity'], $ Order-> id_shop); I note that this - (int) $ product ['product_quantity'] Changing it to + (int) $ product ['product_quantity'] It can run? Link to comment Share on other sites More sharing options...
NemoPS Posted October 6, 2014 Share Posted October 6, 2014 It should increment instead of decrementing (again, I didn't test it) Link to comment Share on other sites More sharing options...
ngomezleal Posted October 7, 2014 Author Share Posted October 7, 2014 Very good Nemo1 thanks for your answer. Nemo1, In prestashop there is an option to cancel or accept orders placed by buyers, specifically php level, where I can find the code where the user (administrator) cancels the purchase they have made? I hope you understand me Link to comment Share on other sites More sharing options...
NemoPS Posted October 8, 2014 Share Posted October 8, 2014 You mean setting an order status to canceled? Link to comment Share on other sites More sharing options...
ngomezleal Posted October 8, 2014 Author Share Posted October 8, 2014 Exactly I mean, when a customer makes a purchase, the administrator has the option of: * cancel * approve * among others ... If for example the customer bought an article available there 20, when it is performed in the 19. When the administrator cancel the purchase, return again to 20. I wonder php code level, where it performs that action, that is, that php file I find that? Muchs thanks for your valuable answers Nemo1. They have been of great benefit. Link to comment Share on other sites More sharing options...
NemoPS Posted October 10, 2014 Share Posted October 10, 2014 It should be the same one I mentioned before actually, as it creates a new order state ($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) && !StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop)) StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop); Link to comment Share on other sites More sharing options...
ngomezleal Posted October 10, 2014 Author Share Posted October 10, 2014 Hi Nemo1, thanks so much for your answers. This code works when you have your prestashop site but the option of multi-shop. 1.- *********************************** OrderDetail.php ** Original State if (!StockAvailable::dependsOnStock($product['id_product'])) $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']); ** Changed State. /** * Check the order status * @param array $product * @param int $id_order_state */ protected function checkProductStock($product, $id_order_state) { if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR')) { $update_quantity = true; if (!StockAvailable::dependsOnStock($product['id_product'])) $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], +(int)$product['cart_quantity']); if ($update_quantity) $product['stock_quantity'] -= $product['cart_quantity']; if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) $this->outOfStock = true; Product::updateDefaultAttribute($product['id_product']); } } 2.- *********************************** State Error/Canceled. OrderHistory.php ** Original State: StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop); ** Changed State. // if waiting for payment => payment error/canceled elseif (!$new_os->logable && !$old_os->logable && in_array($new_os->id, $errorOrCanceledStatuses) && !in_array($old_os->id, $errorOrCanceledStatuses) && !StockAvailable::dependsOnStock($product['id_product'])) StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop); ********************************************************** With this code (adapted to my needs), do the following: 1.-When an order is being performed, rather than decrease existence, increases. 2.-When you want to cancel an order, rather than increasing, decreases. Link to comment Share on other sites More sharing options...
ngomezleal Posted October 10, 2014 Author Share Posted October 10, 2014 Nemo1, the code written above, does not work when I have the option of department stores. Where is the code to decrease when the product option multistore and advanced stock used ??? Link to comment Share on other sites More sharing options...
ngomezleal Posted October 10, 2014 Author Share Posted October 10, 2014 Hi Nemo1, You can guide me please, where is php code level to decrease when the product option and stock multistorey used advanced ??? That is, where the product remains when an order is made. Link to comment Share on other sites More sharing options...
Recommended Posts