【问题标题】:Regular Price Drop down常规价格下降
【发布时间】:2015-06-30 04:14:06
【问题描述】:

我想知道是否可以在 WooCommerce 产品数据部分的“正常价格”字段中添加下拉菜单。

我想创建一个包含 3 个选项的下拉菜单,并防止用户在常规价格字段中输入(相反,他会选择其中一个下拉选项)。

因此,产品数据部分的“常规价格”字段中基本上有 3 个价格选项(在下拉菜单中)。

任何帮助将不胜感激。

【问题讨论】:

    标签: php wordpress input woocommerce product


    【解决方案1】:

    我认为您不能直接修改该常规价格字段。一种技巧是创建新的自定义字段,但名称相同。

    add_action( 'woocommerce_product_options_pricing', 'theme_slug_custom_product_field' );
    
    function theme_slug_custom_product_field() {
      woocommerce_wp_select(array( 'id' => '_regular_price', 'label' => __( 'Regular Price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price', 'options' =>     array( '5'=>5, '10'=>10, '15'=>15 ) )
    );
    }   
    

    这将添加新字段,但名称相同 _regular_price。要隐藏默认文本字段,您可以在管理端添加一些 CSS。

    【讨论】:

    • 谢谢大哥,效果很好,非常感谢您的帮助。
    猜你喜欢
    • 2012-01-22
    • 2015-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-29
    • 2018-07-29
    • 2020-08-21
    • 1970-01-01
    相关资源
    最近更新 更多