Skip to content

Commit 0095552

Browse files
committed
Add logic for downgrades
1 parent e0a4c78 commit 0095552

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

includes/class-wc-subscriptions-coupon.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,12 @@ public static function get_discount_amount_for_cart_item( $cart_item, $discount,
222222
// Compute the sign-up fee. If it's a switch, we need to get the signup fee less
223223
// recurring payment upgrade/downgrade costs.
224224
if ( $is_switch ) {
225-
$sign_up_fee = (int) $cart_item['data']->get_meta( '_subscription_sign_up_fee_prorated' );
225+
$sign_up_fee_prorated = (int) $cart_item['data']->get_meta( '_subscription_sign_up_fee_prorated' );
226+
$price_prorated = (int) $cart_item['data']->get_meta( '_subscription_price_prorated' );
227+
$is_downgrade = 0 === $sign_up_fee_prorated && 0 === $price_prorated;
228+
$sign_up_fee = $is_downgrade ?
229+
WC_Subscriptions_Product::get_sign_up_fee( $cart_item['data'] ) :
230+
$sign_up_fee_prorated;
226231
} else {
227232
$sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee( $cart_item['data'] );
228233
}

0 commit comments

Comments
 (0)