更改价格字符串订单 - WooCommerce订阅

时间:2018-03-21 18:20:47

标签: wordpress string woocommerce woocommerce-subscriptions

我正在使用WooCommerce订阅,我发现如何使用我的functions.php更改价格字符串中的文本

代码:

// WC Subscriptions - Custom Price String
function wc_subscriptions_custom_price_string( $pricestring ) {
    $pricestring = str_replace( 'sign-up fee', 'down payment', $pricestring );
    $pricestring = str_replace( 'with 1 month free trial', '', $pricestring );

    return $pricestring;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wc_subscriptions_custom_price_string' );
add_filter( 'woocommerce_subscription_price_string', 'wc_subscriptions_custom_price_string' );

现在我收到这条消息:

$ 450.00 /月3个月和$ 1,250.00首付

这很好,但我真正想要的是反过来:

首付$ 1,250.00和3个月$ 450.00

在functions.php中有一种简单的方法吗?

1 个答案:

答案 0 :(得分:0)

将此添加到您的functions.php

add_filter('woocommerce_subscriptions_product_price_string', 'woo_change_subscriptions_product_price_string' );
    function woo_change_subscriptions_product_price_string( $subscription_string ) {
    
            $subscription_string = "A $1,250.00 down payment and $450.00 / month for 3 months";
    
            return $subscription_string;
    }