【问题标题】:Woocommerce Change "Select option" text in variable product pageWoocommerce 在可变产品页面中更改“选择选项”文本
【发布时间】:2017-06-20 11:57:50
【问题描述】:

在产品页面的“下拉菜单”上,我想修改 SELECT OPTIONS 文本,我认为这段代码可以做到这一点,但即使我清空缓存,我的页面也没有任何变化。 感谢您的帮助

add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
function custom_woocommerce_product_add_to_cart_text() {
    global $product;    
    $product_type = $product->product_type;  
    switch ( $product_type ) {
case 'variable':
            return __( 'Options', 'woocommerce' );
        break;
}
} 

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    使用以下代码--

    add_filter('woocommerce_dropdown_variation_attribute_options_args', 'custom_woocommerce_product_add_to_cart_text', 10, 2);
    
    
    function custom_woocommerce_product_add_to_cart_text($args){
     $args['show_option_none'] = __( 'Options', 'woocommerce' ); 
      return $args;
    }
    

    【讨论】:

      【解决方案2】:

      我来晚了,下面的代码也可以用。

       add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
              function custom_woocommerce_product_add_to_cart_text() {
                  global $product;    
                  $product_type = $product->product_type;  
                  switch ( $product_type ) {
                  case 'variable':
                              return __( 'Options', 'woocommerce' );
                          break;
                  }
              
                  case 'simple':
                              return __( 'Purchase', 'woocommerce' );
                          break;
                  }
              } 
      

      参考:https://www.raadeen.com/change-select-options-text-woocommerce/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-28
        • 2021-07-13
        • 1970-01-01
        • 2019-01-12
        • 2015-06-26
        • 1970-01-01
        • 2017-12-24
        相关资源
        最近更新 更多