Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only prevent Product add-ons from adjusting prices if prices are honoured #510

Merged
merged 4 commits into from
Sep 21, 2023

Conversation

james-allan
Copy link
Contributor

Part of https://github.com/woocommerce/woocommerce-subscriptions/issues/4535

Description

When using the Product Add-ons plugin and you pay for a subscription renewal, failed initial order or resubscribe, we were telling Product Add-ons to not adjust the price.

This caused issues when paying for initial parent orders because we (subscriptions) don't automatically grandfather the price and so we need Product Add-ons to actually calculate the add-on prices in that case.

This PR fixes that by making sure we only tell Product Add-ons to not adjust prices if we're going to honour the order/subscription total. To help explain, this little table explains what the cart product price source should be for the various scenarios:

Order type Price Source
Parent product price + Add-ons
Parent w' price lock * subscription/order
Renewal subscription/order

* you can lock the parent order price by editing the order and hitting this checkbox

Screenshot 2023-09-19 at 2 28 52 pm

How to test this PR

  1. Install the WooCommerce Product Add-ons plugin.
  2. Create a subscription product with at least 1 product Add-on.
  3. Go the product page on the front end, choose an add-on and then add the product to the cart.
  4. At checkout fail the payment using a failing payment method.
  5. Go to the My Account Orders page and click the "Pay" link.
    • On trunk you'll notice 2 things.
      1. The order price will be wrong. It doesn't include the add-on prices.
      2. The add-ons are doubled up (screenshot) - you can ignore this for now.
    • On this branch the total price should be correct. ie include the add-on(s) prices.
  6. Edit the order in the admin dashboard.
  7. Change the order's status to pending.
  8. Edit the line item total and increase the price.
  9. Check the "lock manual price increases" box.
  10. Save
  11. Repeat step 5 from above.
    • On trunk the price is correct (the increased price).
    • On this branch the total price should still be correct (the increased price).
  12. Create a pending renewal order for a subscription with product add-ons.
  13. Attempt to pay for it through the cart, the cart total should always match subscription/renewal order.

The add-ons are doubled up (screenshot) - you can ignore this for now.

This doubling up of the add-ons will need to be fixed in the Product Add-ons plugin. I've got some working changes that I'll submit to their repo.

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
  • Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
  • Added deprecated functions, hooks or classes to the spreadsheet

Copy link
Contributor

@mattallan mattallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix @james-allan . I've tested:

  • Paying for failed parent order with addons
  • Paying for a renewal order
  • Editing a price and locking the manual price
  • Replicated bug on trunk

LGTM

@james-allan james-allan merged commit 88cc564 into trunk Sep 21, 2023
12 checks passed
@james-allan james-allan deleted the issue/wcs-4535 branch September 21, 2023 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants