Woocommerce Change"选择选项"变量产品页面中的文本

时间:2017-06-20 11:57:50

标签: woocommerce

在产品页面'下拉列表中,我想修改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;
}
} 

2 个答案:

答案 0 :(得分:0)

使用以下代码 -

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;
}

答案 1 :(得分:0)

我来晚了一点,但是下面的代码也可以使用。

 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/

相关问题