1

這裏所描述的問題正是我需要做的,該解決方案的工作原理:
Woocommerce: Change text on order button [Updated]更改文本

然而,我們的捐款和訂閱的形式接受一次「訂單」贊助一個孩子。如果購物車中有訂閱,結賬按鈕顯示「立即註冊」。無論購物車中有什麼,我都需要它閱讀「Give Now」。

http://www.childhopeonline.org(上述變更不活,它目前使用默認的「下訂單」,這是一貫的,無論是什麼車)

翻譯似乎並沒有工作。

我也試過:

function woocommerce_custom_subscription_product_single_add_to_cart_text($text = '' , $post = '') { 

    global $product; 

    if ($product->is_type('subscription')) { 
     $text = get_option(WC_Subscriptions_Admin::$option_prefix . '_add_to_cart_button_text', __('Give Now', 'woocommerce-subscriptions')); 
    } else { 
     $text = $product->add_to_cart_text(); // translated "Read More" 
    } 

    return $text; 
} 
add_filter('woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_subscription_product_single_add_to_cart_text', 2, 10); 

回答

0

若要更改提交按鈕在結賬頁面中的文本正確的過濾器鉤用的是woocommerce_order_button_text。下面是該代碼:

add_filter('woocommerce_order_button_text', 'subscriptions_custom_checkout_submit_button_text'); 
function subscriptions_custom_checkout_submit_button_text($order_button_text) { 
    if (WC_Subscriptions_Cart::cart_contains_subscription()) { 
     $order_button_text = __('Give Now', 'woocommerce-subscriptions' ); 
    } else { 
     // You can change it here for other products types in cart 
     # $order_button_text = __('Something here', 'woocommerce-subscriptions' ); 
    } 
    return $order_button_text; 
} 

代碼放在您的活動子主題(或主題)的function.php文件或也以任何插件文件。

此代碼在woocommerce 3.1+上測試並正常工作。

或者,你可以改變它在WooCommerce>設置>訂閱(標籤)

enter image description here

+0

謝謝!你的第二個選項解決了我的問題 – Jifinner