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