woocommerce / woocommerce-subscriptions-custom-price-string

Customize the price displayed to your customers for subscription products (or non-subscription product).
GNU General Public License v3.0
62 stars 11 forks source link

Support custom price string on cart & checkout recurring totals sections #2

Open thenbrent opened 5 years ago

thenbrent commented 5 years ago

At the moment, the price string displayed is only for the product price. It would be possible to also apply that string to the cart & checkout recurring totals tool if:

melindahelt commented 4 years ago

3113894-zen requested

bernattorras commented 3 years ago

3332586-zen

thuautp commented 3 years ago

The customer in 3332586-zen shared their solution:

/**

* Subscription - change the FREE TRIAL pricing string in cart, checkout and elsewhere 30 sept 2020

*/

function wc_subscriptions_custom_price_string( $pricestring ) {

$pricestring = str_replace( 'free trial and', 'is pre-paid today via', $pricestring );

$pricestring = str_replace( 'with a', 'starting on the 15th of the month. Your first', $pricestring );

$pricestring = str_replace( 'sign-up fee', 'payment', $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' );

The outcome is this string appearing in the cart: Red is all the dynamic content.

$225.00 every 3 months starting on the 15th of the month. Your first 3-month is pre-paid today via a $225.00 payment
ldr2273 commented 3 years ago

Another case is 29105259-hc

dougaitken commented 3 years ago

3934883-zen