Multiselect在instance-settings-modal中无法正确显示 - Woocommerce

时间:2018-04-16 12:09:45

标签: php wordpress woocommerce multi-select

我为Woocommerce创建了一种自定义送货方式,支持shipping-zonesinstance-settingsinstance-settings-modal。实例设置的表单字段是使用Woocommerce的Settings API创建的,如下所示:

$settings = array(
    'title' => array(
        'title'         => __( 'Method title', 'woocommerce' ),
        'type'          => 'text',
        'description'   => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
        'default'       => __( 'Flat rate', 'woocommerce' ),
        'desc_tip'      => true,
    ),
    'tax_status' => array(
        'title'         => __( 'Tax status', 'woocommerce' ),
        'type'          => 'select',
        'class'         => 'wc-enhanced-select',
        'default'       => 'taxable',
        'options'       => array(
            'taxable'   => __( 'Taxable', 'woocommerce' ),
            'none'      => _x( 'None', 'Tax status', 'woocommerce' ),
        ),
    ),
    'cities' => array(
        'title'         => __( 'Cities', 'woocommerce' ),
        'type'          => 'multiselect',
        'description'   => __( 'Select all cities within current zone to which this shipping method applies.', 'woocommerce' ),
        'desc_tip'      => true,
        'class'         => 'wc-enhanced-select',
        'options'       => $zone_cities,
    ),
    'cost' => array(
        'title'         => __( 'Cost', 'woocommerce' ),
        'type'          => 'text',
        'placeholder'   => '',
        'description'   => $cost_desc,
        'default'       => '0',
        'desc_tip'      => true,
    ),
);

cities无法正常工作的多选字段外,一切正常。它显示为具有多个属性的普通选择。这是一个截图:

wc-settings-modal

然而,当我只使用instance-settings时,multiselect也能正常工作。这是另一个截图:

enter image description here

同样的问题在GitHub here上已经关闭。任何寻找潜在问题的帮助都表示赞赏。

更新:如果您将tax_status字段类型从multiselect更改为select,则可以使用Woocommerce核心的统一费率运费方式重现此问题。

更改woocommerce/includes/shipping/flat-rate/includes/settings-flat-rate.php的第22行,如下所示:

$settings = array(
    'title' => array(
        'title'         => __( 'Method title', 'woocommerce' ),
        'type'          => 'text',
        'description'   => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
        'default'       => __( 'Flat rate', 'woocommerce' ),
        'desc_tip'      => true,
    ),
    'tax_status' => array(
        'title'         => __( 'Tax status', 'woocommerce' ),
        'type'          => 'multiselect', // *** Change here ***
        'class'         => 'wc-enhanced-select',
        'default'       => 'taxable',
        'options'       => array(
            'taxable'   => __( 'Taxable', 'woocommerce' ),
            'none'      => _x( 'None', 'Tax status', 'woocommerce' ),
        ),
    ),
    'cost' => array(
        'title'         => __( 'Cost', 'woocommerce' ),
        'type'          => 'text',
        'placeholder'   => '',
        'description'   => $cost_desc,
        'default'       => '0',
        'desc_tip'      => true,
    ),
);

0 个答案:

没有答案