We've encountered a situation where Gift Cards are being allowed as a payment method for subscriptions. Further, when the subscription renews it charges only the difference between the original order total and what was used on the gift card. Yikes!
The issue stems from the cartHasSubscriptionProducts function which doesn't have all of the logic needed to determine if a cart includes subscription products. Instead, use the cart_contains_subscription function from the WC_Subscriptions_Cart object which should be much more reliable than rolling your own logic to determine if the cart has subscription products.
Proposed fix:
protected function cartHasSubscriptionProducts()
{
if (!method_exists('WC_Subscriptions_Cart', 'cart_contains_subscription')) {
return false;
}
return WC_Subscriptions_Cart::cart_contains_subscription();
}
We've encountered a situation where Gift Cards are being allowed as a payment method for subscriptions. Further, when the subscription renews it charges only the difference between the original order total and what was used on the gift card. Yikes!
The issue stems from the cartHasSubscriptionProducts function which doesn't have all of the logic needed to determine if a cart includes subscription products. Instead, use the
cart_contains_subscription
function from theWC_Subscriptions_Cart
object which should be much more reliable than rolling your own logic to determine if the cart has subscription products.Proposed fix: