Woocommerce订阅字符串

My site:

https://www.fytso.com/lifestyle

I have 3 subscription options:

  1. Monthly - Charged at $49.95 per month until customer cancels
  2. 3-Month - Charged $138.85 at signup and then $49.95 per month after those first 3 months have passed.
  3. 6-Month - Charged $274.70 at signup and then $49.95 per month after those first 6 months have passed.

Settings for (1) are straightforward. Simple $49.95 per month for all time.

Setting for (2 & 3) are:

$138.85 Signup Fee with a Free 3-month trial and then $49.95 monthly. For the 6-Month, it's $274.70 Signup Fee with a 6-month free trial and then $49.95 monthly.

It's the only way I could configure those settings for them to work the way I need them to.

Now, the 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string' display info by default that's just downright confusing for my customers. So this need to be modified.

I managed to eliminate the displayed prices and strings on the Home Page with a filter (and I can live with that) but my problem is, that if a customer adds the item to their cart, those prices also don't display on the Cart Page.

Screencap: https://imgur.com/bS7HIGf

So, even though this seems like a simple problem to solve, I can't get it done and need a bit of help.

The other alternative is to just display the subscription price on the Home Page. That however causes our Monthly option to display $0 since the settings that allow just the subscription price to display, is applied globally through the simple filter I'm using.

Targeting that by product (if possible) might solve it. But again, it's something that I'm having trouble with implementing.

The filter I'm using, I found here and it looks like this right now:

add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string', 10, 3 );

function my_subs_price_string( $subscription_string, $product, $include ) {

    /****
    var_dump($product); Various variables are available to us
    ****/

    return ' Renews at ' . wc_price( $product->subscription_price );
}

Obviously wrong as it stands. Help appreciated.

Ideally, these option would display:

  1. $49.95
  2. $138.85
  3. $274.70

The solution was actually simple. Staring me right in the face.

I simply changed the Monthly option settings to:

$49.95 Signup Fee with a 30-day free trial. So it's similar to the 3-month and 6-month options. Now my little filter looks like this:

add_filter( 'woocommerce_subscriptions_product_price_string', 'my_subs_price_string', 10, 3 );

function my_subs_price_string( $subscription_string, $product, $include ) {

    /****
    var_dump($product); Various variables are available to us
    ****/

    return '' . wc_price( $product->subscription_sign_up_fee );
}

My prices on the Home Page and in the cart are displaying correctly. I.e. the signup fee that they will be charged upon signup and my recurring charges will begin 30, 60 and 180 days after that first signup.

Voila!