/** * For the purposes of simplifying calculations, add the sign up fee to the price per period * so WC can do all the calculations and then we can figure out what proportion of the total * calculated by WC is for the initial payment and how much is for the recurring payment. * * @since 1.2 */ public static function set_subscription_prices_for_calculation($price, $product) { global $woocommerce; if (WC_Subscriptions_Product::is_subscription($product)) { self::$base_product_price = $price; $woocommerce->cart->base_recurring_prices[$product->id] = $price; $sign_up_fee = WC_Subscriptions_Product::get_sign_up_fee($product); // only modify the price when calculating a sign up fee or entire cart if ('sign_up_fee' == self::$recalculation_type) { $price = $sign_up_fee; } elseif ('none' == self::$recalculation_type) { $price += $sign_up_fee; } else { // do not modify price } } return $price; }