[英]WooCommerce - Order Status for Pending Payment Reducing Stock
I use WooCommerce to manually take orders via the telephone / email etc. I use the backend to record the orders manually adding the orders.我使用WooCommerce通过电话/email等手动接单。我使用后端记录订单手动添加订单。
At present, when generating an order as 'pending payment' as the status the stock is automatically reduced / deducted.目前,当生成状态为“待付款”的订单时,库存会自动减少/扣除。 I do not want this to happen.我不希望这种情况发生。 Ideally I only want stock to be reduced when the order is marked as in 'processing' as then payment would of then been taken.理想情况下,我只希望在订单被标记为“处理中”时减少库存,因为那时将进行付款。
I understand this is how WooCommerce works back is there a way to avoid stock being reduced until a certain status has been selected?我知道这就是 WooCommerce 的工作方式有没有办法避免库存减少,直到选择了某个状态?
I have tried the below code within functions.php and used the 'on-hold' status to test but the stock is still reduced.我在 functions.php 中尝试了以下代码,并使用“暂停”状态进行测试,但库存仍然减少。
add_filter( 'woocommerce_can_reduce_order_stock', 'wcs_do_not_reduce_onhold_stock', 10, 2 );
function wcs_do_not_reduce_onhold_stock( $reduce_stock, $order ) {
if ( $order->has_status( 'on-hold' )) {
$reduce_stock = false;
}
return $reduce_stock;
}
I wonder if it because I am adding the order as an admin?我想知道是不是因为我以管理员身份添加订单? I know this is how WooCommerce works but ideally I need a method of overriding the 'pending payment' status when creating an order both within the draft and creation stage until marked as 'processing'.我知道这就是 WooCommerce 的工作方式,但理想情况下,我需要一种在草稿和创建阶段创建订单时覆盖“待付款”状态的方法,直到标记为“处理中”。
Any help would be fantastic.任何帮助都会很棒。
Try this adding to functions.php Note: not tested.尝试将此添加到函数中。php 注意:未经测试。
function reduce_stock_processing($order_id) {
wc_reduce_stock_levels($order_id);
} }
add_action('woocommerce_order_status_processing', 'reduce_stock_processing');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.