Created
September 3, 2025 16:48
-
-
Save barryhughes/fe10e7a420f61b5cae6e29ca251e1655 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* For subscription products, overrides the default product price string with | |
* something custom. | |
*/ | |
add_filter( | |
'woocommerce_subscriptions_product_price_string', | |
function ( string $product_price_string, WC_Product $product ): string { | |
// Update the criteria as needed to target the correct product(s). | |
return $product->get_id() === 12345 | |
? '¥50 every quarter (but billed monthly)' | |
: $product_price_string; | |
}, | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably obvious, but this is a POC rather than a complete solution. In reality, we might want to do a better job of building the replacement string with the same (or a very similar) HTML structure we see for other products, and we may wish to pull information from product meta data, etc etc.