2017-06-20 50 views
1

在產品頁面的下拉列表中,我想要修改SELECT OPTIONS文本,並且我認爲此代碼可以對此進行更改,但即使我爲空緩存,我的頁面也沒有任何更改。 感謝您的幫助Woocommerce在變量產品頁面中更改「Select option」文本

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

回答

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; 
} 
相關問題