Jif*_*ner 3 php wordpress checkout woocommerce woocommerce-subscriptions
这里描述的问题正是我需要做的,并且解决方案有效:
Woocommerce:更改订单按钮上的文本[已更新]
然而,我们接受一次性“订单”,以捐赠和订阅的形式赞助一名儿童。如果购物车中有订阅,结账按钮会显示“立即注册”。无论购物车中有什么,我都需要它来阅读“立即给予”。
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);
Run Code Online (Sandbox Code Playgroud)
要更改结账页面中提交按钮的文本,要使用的正确过滤器挂钩是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;
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(或主题)的 function.php 文件中或任何插件文件中。
此代码在 woocommerce 3.1+ 上经过测试并且有效。
或者您可以在 WooCommerce > 设置 > 订阅(选项卡)中更改它:
| 归档时间: |
|
| 查看次数: |
4637 次 |
| 最近记录: |