更改 WooCommerce 订阅的订单按钮上的文本
Change text on order button for WooCommerce subscriptions
此处描述的问题正是我需要解决的问题,解决方案有效:
不过,我们接受一次"orders"的捐款和订阅形式赞助child。如果购物车中有订阅,结帐按钮显示为 "Sign up now"。我需要它来阅读 "Give Now" 不管购物车里有什么。
http://www.childhopeonline.org(上述更改未生效,目前使用默认值 "Place order",无论购物车中有什么,它都是一致的)
翻译好像不行。
我也试过:
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);
要更改结帐页面中提交按钮的文本,要使用的正确过滤器挂钩是 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+ 上测试并有效。
Or you can change it in WooCommerce > Settings > Subscriptions (tab):
此处描述的问题正是我需要解决的问题,解决方案有效:
不过,我们接受一次"orders"的捐款和订阅形式赞助child。如果购物车中有订阅,结帐按钮显示为 "Sign up now"。我需要它来阅读 "Give Now" 不管购物车里有什么。
http://www.childhopeonline.org(上述更改未生效,目前使用默认值 "Place order",无论购物车中有什么,它都是一致的)
翻译好像不行。
我也试过:
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);
要更改结帐页面中提交按钮的文本,要使用的正确过滤器挂钩是 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+ 上测试并有效。
Or you can change it in WooCommerce > Settings > Subscriptions (tab):