简体   繁体   English

WooCommerce - 待付款减少库存的订单状态

[英]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.

相关问题 允许在 WooCommerce 订单处于待处理状态时减少库存 - Allow reducing stock while WooCommerce order in pending status WooCommerce 预订 - 24 小时后将订单状态从“待付款”更改为“已取消” - WooCommerce Bookings - Change Order status from “Pending Payment” to “Cancelled” after 24 hours WooCommerce中特定订单状态如何减少库存 - How to reduce the stock for specific order status in WooCommerce 在 WooCommerce 我的帐户页面上隐藏状态为(待付款)的订单 - Hide orders with status (Pending Payment) on WooCommerce My Account page 创建重定向链接/发布到具有待处理状态的 woocommerce 付款页面 - create redirect link/post to woocommerce payment page with pending status 支付网关的 WooCommerce 订单状态更改 - WooCommerce order status change from payment gateway WooCommerce:基于付款方式的订单状态 - WooCommerce: Order status based on Payment methods Woocommerce-woocommerce_order_status_pending挂钩未调用 - Woocommerce - woocommerce_order_status_pending hook not calling 在订单待付款时自定义Woocommerce电子邮件通知 - Customizing Woocommerce email notification when order is pending payment 仅针对 Woocommerce 中的特定订单状态和付款方式减少库存 - Reduce stock only for specific order statuses and payment method in Woocommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM