-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fixes error on Admin Edit Subscription page when the subscription has custom billing fields. #403
Fixes error on Admin Edit Subscription page when the subscription has custom billing fields. #403
Conversation
includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php
Outdated
Show resolved
Hide resolved
Will this resolve WCS issue https://github.com/woocommerce/woocommerce-subscriptions/issues/4468? I'm attempting to test with https://github.com/woocommerce/woocommerce-eu-vat-number but I am seeing another fatal (unrelated I believe):
Update: It is unrelated:
|
@Jinksi yeah it will fix EU Vat Number which is using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @mattallan 🏆
I've tested by using snippets from the description (with WCPay standalone and WCPay + WCS).
- On
trunk
, I see the error when loading the Edit Subscription screen. - On this branch, the Edit Subscription screen loads correctly and I can edit the custom billing/shipping fields and view the stored value.
… custom billing fields. (#403) * Checks if get_billing_{key} function exists and falls back to getting meta * Update includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php * Call is_callable() when getting shipping field value, fallback to using get_meta() * changelog entry
Fixes #401
Fixes #402
Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4468
Description
When a store has set custom address fields (using
woocommerce_admin_billing_fields
orwoocommerce_admin_shipping_fields
) and these fields don't have$order->get_billing_{field}
or$order->get_shipping_{field}
functions, opening the Edit subscription page in the admin will result in:To fix this problem, we just need to make sure the function exists before we try to use it 😅 In cases where a getter function doesn't exist, we need to fallback to using
$subscription->get_meta( '_custom_meta_key' )
How to test this PR
This issue was reported by a store using our EU Vat number plugin, however it can also be replicated by using the following snippet to add custom billing and shipping fields:
trunk
, try to navigate to the Edit Subscription page. You will notice half the page loaded and a fatal error.Product impact