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

Order wrapper class proposal #3654

Open
wants to merge 58 commits into
base: develop
Choose a base branch
from
Open

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Dec 12, 2024

Changes proposed in this Pull Request:

This PR is a proposal for introducing a new children class (WC_Stripe_Order, extended from WC_Order) that wraps all our custom metadata and extension-specific business logic. This should make it easier to reference and change metas.

Testing instructions

  • Take a look at the code. Do you think it makes sense to move forward?
  • Check if the tests are still passing
  • Perform some smoke tests:
    -- Connect your Stripe account
    -- Enable some payment methods
    -- As a shopper, make some purchases

* Unit tests for the new class will be added if this proposal gets approved


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@wjrosa wjrosa self-assigned this Dec 12, 2024
@wjrosa
Copy link
Contributor Author

wjrosa commented Dec 13, 2024

Hey team! I would like to have your opinion on this proposal (@Mayisha , @diegocurbelo , @mattallan , @annemirasol ). What do you think?

@annemirasol
Copy link
Contributor

I love that we're consolidating order metadata getters and setters, and abstracting specifics, like the actual key names.

I haven't looked at all the changes closely, but I think it's a refactor worth pursuing, @wjrosa. Thanks for making the effort.

@wjrosa
Copy link
Contributor Author

wjrosa commented Dec 26, 2024

I love that we're consolidating order metadata getters and setters, and abstracting specifics, like the actual key names.

I haven't looked at all the changes closely, but I think it's a refactor worth pursuing, @wjrosa. Thanks for making the effort.

Nice, Anne! I will update this PR and properly move this to review so everyone can have a better look at the idea.

@wjrosa
Copy link
Contributor Author

wjrosa commented Dec 27, 2024

Hey @woocommerce/quark! I have finished polishing my idea here. I'd appreciate it if you could at least tell me if it is OK to move this forward. I believe it is a great quality of life improvement. All possible meta keys, getters, setters, and retrieval methods are in one place. This also makes our WC_Stripe_Helper class smaller.

@wjrosa wjrosa marked this pull request as ready for review January 2, 2025 12:02
@wjrosa wjrosa requested a review from mattallan January 2, 2025 12:02
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

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

Smoke test results

Account connection
✅ Connect to Stripe account
✅ Reconfigure webhook

Simple product
✅ Card
✅ WeChat
✅ Multibanco
✅ klarna
✅ iDeal
⚠️ Sepa - The status remained on-hold forever. (check if you can reproduce it or it could be my local issue)

Subscription
✅ Card
✅ Cash App
⚠️ Sepa - The status remained on-hold (check if you can reproduce it or it could be my local issue)
🔴 Renewal - subscription renewal from subs edit page results in a fatal error
Screenshot 2025-02-25 at 4 07 31 PM

Refund
✅ Tested refund with a couple of payment methods for simple and subscription product.

Capture Later
✅ Tested with card.

Additional note

Changes needed

  • Need to update the deprecation version from 9.1.0 to the latest one.
  • Added a few comments.

Post merge action item

  • Create a follow-up issue to remove deprecated functions in the future.
  • Inform Quark and Fractal members to use this wrapper going forward.
  • Include rigorous testing instructions for order related features for GS before the release.

@wjrosa
Copy link
Contributor Author

wjrosa commented Feb 25, 2025

Thanks @Mayisha for the additional review and notes!

⚠️ Sepa - The status remained on-hold forever. (check if you can reproduce it or it could be my local issue)

Fixed this issue in 8be7874

🔴 Renewal - subscription renewal from subs edit page results in a fatal error

Fixed in d64f154

if ( is_null( $order ) ) {
return false;
}

$order->delete_meta_data( self::META_NAME_FEE );
$order->delete_meta_data( self::LEGACY_META_NAME_FEE );
$order->delete_fee();
Copy link
Contributor

@Mayisha Mayisha Feb 27, 2025

Choose a reason for hiding this comment

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

Suggested change
$order->delete_fee();
$order->delete_meta_data( self::META_NAME_FEE );
$order->delete_meta_data( self::LEGACY_META_NAME_FEE );

@wjrosa I am still getting the fatal error when I try to renew a subscription from the subscription edit page. The reason is , though it's calling this helper method now, the helper method itself tries to call the function from the new order wrapper class.

Screenshot 2025-02-27 at 6 05 04 PM

This helps to realize another problem, if any third party plugins are using these helper methods, they would send an instance of WC_Order here, not WC_Stripe_Order. So we should keep the previous code in these functions.

Similar changes (reverts) should be made for other functions here as well to avoid breaking plugin compaatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, sorry about that! I reverted the changes on the deprecated methods and added extra checks for the object class type on the latest commits.

@wjrosa wjrosa requested a review from Mayisha February 27, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants