小编Nic*_*ner的帖子

通过 WooCommerce 中的自定义库存数量减少,使“缺货”产品变体变灰

我使用了https://jeroensormani.com/custom-stock-quantity-reduction/的精彩片段为变体添加了一个额外的设置,将主要库存库存减少了变体中的设定数量。

我现在面临的问题是它不检查这些变体是否缺货(例如,主要库存为 10,捆绑设置设置为 12 瓶)。

我用来添加总库存减少乘数的代码是:

// For implementation instructions see: https://aceplugins.com/how-to-add-a-code-snippet/

/**
 * Simple product setting.
 */
function ace_add_stock_inventory_multiplier_setting() {

    ?><div class='options_group'><?php

        woocommerce_wp_text_input( array(
            'id'                => '_stock_multiplier',
            'label'             => __( 'Inventory reduction per quantity sold', 'woocommerce' ),
            'desc_tip'          => 'true',
            'description'       => __( 'Enter the quantity multiplier used for reducing stock levels when purchased.', 'woocommerce' ),
            'type'              => 'number',
            'custom_attributes' => array(
                'min'   => '1',
                'step'  => '1',
            ),
        ) );

    ?></div><?php

}
add_action( 'woocommerce_product_options_inventory_product_data', 'ace_add_stock_inventory_multiplier_setting' ); …
Run Code Online (Sandbox Code Playgroud)

php wordpress product stock woocommerce

4
推荐指数
1
解决办法
361
查看次数

标签 统计

php ×1

product ×1

stock ×1

woocommerce ×1

wordpress ×1