wordpress - 订单状态为待付款时如何减少 WooCommerce 可变产品库存?
问题描述
当订单状态为待付款时,我一直在尝试减少 WooCommerce 可变产品的库存数量。默认情况下,当订单状态为待付款时,WooCommerce 不会减少库存。所以我在下面使用了这些代码片段,但它不起作用。根据 WooCommerce 的钩子,它应该可以工作,但不幸的是,事实并非如此。
add_action('init', function() {
remove_action( 'woocommerce_order_status_pending', 'wc_maybe_increase_stock_levels' );
add_action( 'woocommerce_order_status_pending', 'wc_maybe_reduce_stock_levels' );
});
或者,
add_action( 'init', 'custom_stock_reduce' );
function custom_stock_reduce() {
remove_action( 'woocommerce_order_status_pending', 'wc_maybe_increase_stock_levels' );
add_action( 'woocommerce_order_status_pending', 'wc_maybe_reduce_stock_levels' );
}
你能帮我看看我哪里做错了吗?谢谢你。
解决方案
推荐阅读
- r - 使用 dplyr 将所有行保持在 R 中的特定值
- ios - iOS 应用程序在升级正在运行的应用程序时会发生什么
- mysql - Laravel 迁移耗时过长
- database - 让 osddm 启动的问题
- python - 如何从开始数到最大值然后重新开始
- android - admob 不显示广告
- kubernetes - K8s 和 Helm:绑定失败时如何找到 PersistentVolumeClaim 要求?
- mongodb - 无法将数据从 kafka 主题发送到 elasticsearch
- python - 将凭据传递给 Dash 的基本身份验证,因此用户无需再次输入
- reactjs - 部署到 heroku 并运行 npm build 后对应用程序进行更改