Skip to content

Instantly share code, notes, and snippets.

View davidrukahu's full-sized avatar

David Rukahu davidrukahu

View GitHub Profile
@davidrukahu
davidrukahu / Make switch prorations base off the subscription's recurring price.txt
Last active October 14, 2025 11:07
Make switch prorations base off the subscription's recurring price
/**
* TEMP FIX: Make switch prorations base off the subscription's recurring price,
* not the previous switch order total (affects consecutive same-cycle upgrades).
*/
add_filter( 'wcs_switch_total_paid_for_current_period', function( $total_paid, $subscription, $existing_item ) {
// Get the product being switched from
$product = $existing_item && is_callable( [$existing_item, 'get_product'] ) ? $existing_item->get_product() : null;
if ( ! $product ) {