vippsas / vipps-recurring-woocommerce

Vipps Recurring payments for WooCommerce
GNU Affero General Public License v3.0
6 stars 4 forks source link

Support for All Products for Woocommerce Subscriptions #58

Closed danielcherubini closed 2 years ago

danielcherubini commented 2 years ago

https://woocommerce.com/document/all-products-for-woocommerce-subscriptions/

Hi

It would seem that this payment option doesn't work for one of the official woocommerce subscription plugins. This plugin enables products to be added to subscription plans easier than doing variable subscriptions. Attached is an example of one of our products.

image

When taking this product through to the checkout, it would seem that this payment option ignores it, probably because it is a "simple-product" and not a "subscription" type product, either simple or variable...

We need to use this method for ease of use, and easy price calculations.. since we have a bot that changes the prices on the website..

Here's how it looks during the checkout

image

If there's anymore info you need please let me know.

danielcherubini commented 2 years ago

So you know what the structure of a product looks like i've attached one of the exports wc-product-export-8-4-2022-1649414420014.csv

you can see there is a metadata field Meta: _wcsatt_schemes that contains data if it is a WooCommerce All product Subscription scheme.

I think I have found the code on line 411 of woo-vipps-recurring.php and line 1453 of wc-gateway-vipps-recurring.php

danielcherubini commented 2 years ago

There's a kind of issue with the fix for wc-gateway-vipps-recurring.php

Essentially, you're using WC_Subscriptions_Product::is_subscription() to check if it is a subscription type product, which that SHOULD return a true, since this type of product IS a subscription product.. .but it seems that Woo hasn't added a check in that function for if its a Wcsatt type of subscription...

So the two changes should be to add a check to see IF its a simple type product that has the _wcsatt metadata.

Marcuzz commented 2 years ago

Hi Daniel,

I had never even heard of this plugin before, but it does seem like it isn't integrating with WooCommerce Subscriptions in the way one would expect, causing us to need additional logic to support it.

I will look into this after the Easter break, as I currently have holiday.

If you are able to fix it in the meantime feel free to submit a pull request and I'll verify that everything works once I'm back 🙂

danielcherubini commented 2 years ago

I was able to temporarily bypass it. Those two lines I just changed it so that single products were ok which isn't optimal, there would need to be an additional check. And on the other line I just changed it to return true every time. Which again isn't optimal. But since all our products are exactly the same it's fine for now.

Will this have any knock on effects with cancelling or refunding?

On Mon, 11 Apr 2022, 17:02 Marcus, @.***> wrote:

Hi Daniel,

I had never even heard of this plugin before, but it does seem like it isn't integrating with WooCommerce Subscriptions in the way one would expect, causing us to need additional logic to support it.

I will look into this after the Easter break, as I currently have holiday.

If you are able to fix it in the meantime feel free to submit a pull request and I'll verify that everything works once I'm back 🙂

— Reply to this email directly, view it on GitHub https://github.com/vippsas/vipps-recurring-woocommerce/issues/58#issuecomment-1095164501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBQ4M7PMXRG2E5JDMCWTTVEQ5GNANCNFSM5TA3BV7A . You are receiving this because you authored the thread.Message ID: @.***>

Marcuzz commented 2 years ago

I think refunding should still work fine as that logic is the same for WooCommerce and WooCommerce Subscriptions. I'm not completely sure about cancellation though, but seeing as All Products for WooCommerce Subscriptions is supposed to be compatible with WooCommerce Subscriptions I assume it should work with your changes.

There would definitely have to be a more permanent fix for this however, as the lines you modified are in place to prevent this payment gateway from showing up at the same time as the Vipps Checkout plugin in certain scenarios, like if manual renewals are enabled (this enables the use of single payment gateways for subscriptions) or when using Klarna Checkout.

danielcherubini commented 2 years ago

OK that's good to know, i had a quick poke around in the source of the plugin.. and it seems like it has functions that are overrides to the standard ones..

that said, go enjoy PÃ¥skeferie...

Marcuzz commented 2 years ago

Added in 1.14.0 (not released yet, will have to do some more testing first).