Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barryhughes/fe10e7a420f61b5cae6e29ca251e1655 to your computer and use it in GitHub Desktop.
Save barryhughes/fe10e7a420f61b5cae6e29ca251e1655 to your computer and use it in GitHub Desktop.
<?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
);
@barryhughes
Copy link
Author

barryhughes commented Sep 3, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment