/ Published in: PHP
This function is a workaround for a bug of the subscription extension of WooCommerce.
If the subscription is set up as a variable product with monthly and yearly prices
the extension will show the wrong message, like '$10 - $120/month' instead of
'$10/month - $120/year'
Making the function general would have taken too long so I've simply hardcoded the product IDs
If the subscription is set up as a variable product with monthly and yearly prices
the extension will show the wrong message, like '$10 - $120/month' instead of
'$10/month - $120/year'
Making the function general would have taken too long so I've simply hardcoded the product IDs
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* This function is a workaround for a bug of the subscription extension of WooCommerce. If the subscription is set up as a variable product with monthly and yearly prices the extension will show the wrong message, like '$10 - $120/month' instead of '$10/month - $120/year' */ function replace_price_string() { $first_price = WC_Subscriptions_Product::get_price('61842'); $first_period = WC_Subscriptions_Product::get_period( '61842' ); $second_price = WC_Subscriptions_Product::get_price('61844'); $second_period = WC_Subscriptions_Product::get_period( '61844' ); $subscription_string = 'From: $'.$first_price.'/'.$first_period.' to $'.$second_price.'/'.$second_period; return $subscription_string; } add_filter('woocommerce_subscriptions_product_price_string', 'replace_price_string', '60697');