hps / heartland-woocommerce-plugin

Secure Submit Plugin for WooCommerce
GNU General Public License v2.0
13 stars 14 forks source link

Cart with Subscriptions Incorrectly Allowing Gift Cards for Payment #198

Closed tflight closed 1 year ago

tflight commented 1 year ago

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();
    }
securesubmit-buildmaster commented 1 year ago

Hi @tflight,

Thanks for bringing this to our attention! This will be corrected for in our next release.