Woocommerce 如何在woocomerce中仅为缺货产品(简单和变化)启用存款
如何添加仅针对woocommerce中的缺货产品计算的保证金。 我有一个商业存款插件。但它适用于所有时间的存款。我只需要在产品库存<0时启用此功能。它也需要申请产品变更 在文档中,他们说wc\u存款\购物车\项目\存款\数据过滤器可以禁用存款计算。如何将其添加到function.php 我现在正在尝试为varion添加Woocommerce 如何在woocomerce中仅为缺货产品(简单和变化)启用存款,woocommerce,Woocommerce,如何添加仅针对woocommerce中的缺货产品计算的保证金。 我有一个商业存款插件。但它适用于所有时间的存款。我只需要在产品库存
add_action( 'woocommerce_cart_calculate_fees', 'calculated_deposit_discount_on_backorders' );
function calculated_deposit_discount_on_backorders( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
foreach( $cart->get_cart() as $cart_item ) {
$variation_id=$cart_item['variation_id'];
if($variation_id)
{
$variation_obj = new WC_Product_variation($variation_id);
$stock = $variation_obj->get_stock_quantity();
$backordered = get_post_meta( $variation_id, '_backorders', true );
if(($backordered=="notify" || $backordered=="yes") && $stock > 0)
{
// here we need to add the hook so that if stock is greater than 0 need to disable deposit calculation.
/*wc_deposits_cart_item_deposit_data : this filter controls the total deposit amount for cart item,or it can be set to disable deposit for cart item if value returned is 0 . variable passed through this filter are $deposit_data , $cart_item */
}
}
}
我需要的是如何在这里获取存款数据