Prestashop - 已取消的订单产品数量未增加库存数量

时间:2015-11-13 13:09:52

标签: prestashop shopping-cart stock prestashop-1.5 cancellation

我正在使用Prestashop Advance Stock Management System来处理某些产品。当我对产品下订单(启用预先库存管理)时,数量从实际输入值(允许我们手动输入数量的输入框)中扣除而不是从库存中扣除(我可以在库存管理列表中看到相同的数量) )。将订单状态更改为“已发货/已开票”后,库存数量会减少。

当我取消该订单时,库存数量不会增加。我想在取消订单时自动增加库存数量。我是新手,我不知道该怎么做。请帮我解决这个问题。

提前致谢

2 个答案:

答案 0 :(得分:0)

您应该拨打StockAvailable::updateQuantity,然后拨打$update_quantity = StockAvailable::updateQuantity(...

if (!StockAvailable::dependsOnStock($product['id_product']))

有趣的是,在更新数量之前,存在这种情况

override/classes/stock/StockAvailable.php

我建议您https://stackoverflow.com/a/27090088/3597276并在需要时返回true。

此外,您可以在复制订单之前设置全局标志,然后检查该标志,如果是,则返回true以防止更新库存。

class StockAvailable extends StockAvailableCore { public static function dependsOnStock($id_product, $id_shop = null) { $no_quantity_update = isset($GLOBALS['no_quantity_update']) && $GLOBALS['no_quantity_update']; if ($no_quantity_update) return true; else return parent::dependsOnStock($id_product, $id_shop = null); } }

中的覆盖代码
cache/class_index.php

要使此覆盖生效,请删除文件//set to false just to be sure $GLOBALS['no_quantity_update'] = false; $this->module->validateOrder($cart->id, Configuration... 以刷新覆盖列表

您的模块代码:

<div classname="panel-heading">
    <h4 classname="panel-title headingText" style="float:left">Attributes</h4>
    <button type="button" style="float:left;padding:10px" classname="btn btn-info btn-sml pull-right" data-toggle="modal" data-target="#newListModal">New List</button>
</div>

您可以直接修改核心代码,但不建议使用

您也可以查看override this method

答案 1 :(得分:0)

$productid = $request->input('productid');
$userid = $request->input('userid');  
$quantityt= $request->input('quantity');

$data2=Cart::where('productid',$productid)->where('userid',$userid)->pluck('id');

$productq=Products::where('id',$productid)->get();

foreach($productq as $pro)
{
    $product = Products::find($pro->id);
    $product->quantity = $pro->quantity + $quantityt;
    $product->save();
}
相关问题