WPprodigy / woocommerce-product-fees

Add additional fees at checkout based on products that are in the cart.
https://wordpress.org/plugins/woocommerce-product-fees/
Other
25 stars 19 forks source link

Issue with subscription #22

Closed stickypages closed 7 years ago

stickypages commented 7 years ago

It looks like in the code that subscriptions will work, from what I can see. But I get ZERO fee added to the subscription total.

It is in the "meta" for the subscription. But I cannot see any fee applied to the actual total.

Any thoughts on this?

WPprodigy commented 7 years ago

What Subscriptions plugin are you using? What types of products are in the cart, and is this happening on the first purchase of the subs product, or on subsequent renewals?

stickypages commented 7 years ago

I'm using WooCommerce Subscriptions (by woo themes). I'm using a variable subscription, which is a renewal.

You can see it works for a 'product', but not the recurring totals.

stickypages commented 7 years ago

Here is a screenshot 2017-02-23 23_45_45-cart

WPprodigy commented 7 years ago

Right, it isn't currently set up to add fees onto recurring totals. Will only add fees to the order one time.

Adding support for recurring costs may require a bit of work.

stickypages commented 7 years ago

Oh really eh. Thought I saw it was setup for some Subscription stuff in the code. Possible to get that implemented? I am desperate. I can't seem to quite grasp what is needed to do it myself yet. Still doing research...

WPprodigy commented 7 years ago

I don't have time to implement this right now, but I can maybe help point you in the right direction.

For Subscriptions, a one-time fee is already supported with the "sign up fee" option. So you only need to handle the recurring fee part. In woocommerce-subscriptions/includes/class-wc-subscriptions-checkout.php, there is a woocommerce_add_order_fee_meta hook that looks to be what you should use for this.

stickypages commented 7 years ago

Great thanks, will look into this some more. It would be a great addition when you have time !

WPprodigy commented 7 years ago

Oh hey, fixed this while fixing https://github.com/WPprodigy/woocommerce-product-fees/issues/23 :). Fees are now applied to recurring totals as well.

At first I thought about an extra setting on Subscription product to enable/disable this, but changed my mind. If somebody doesn't want recurring fees, they can just use the "sign up fee" option.

stickypages commented 7 years ago

Awesome, thanks!