-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Describe the bug
Within the WCPay\MultiCurrency\Compatibility\WooCommerceSubscriptions
class, the method override_selected_currency()
calls the get_post_meta
function that will not work correctly when a store has HPOS enabled.
This should be replaced with a WC_Order CRUD method to work with HPOS.
woocommerce-payments/includes/multi-currency/Compatibility/WooCommerceSubscriptions.php
Lines 156 to 158 in 2c22e38
if ( $switch_id ) { | |
return get_post_meta( $switch_id, '_order_currency', true ); | |
} |
Additional details
Note
I've initially tried a quick replacement withwc_get_order()
/get_subscription()
here, but it results in an infinite loop.
This was identified while auditing WCPay subscription-related code for HPOS incompatible functions and hooks using the following regexp:
wpdb|get_post|get_post_field|get_post_status|get_post_type|get_post_type_object|get_posts|metadata_exists|get_post_meta|get_metadata|get_metadata_raw|get_metadata_default|get_metadata_by_mid|wp_insert_post|add_metadata|add_post_meta|wp_update_post|update_post_meta|update_metadata|update_metadata_by_mid|delete_metadata|delete_post_meta|delete_metadata_by_mid|delete_post_meta_by_key|wp_delete_post|wp_trash_post|wp_untrash_post|wp_transition_post_status|clean_post_cache|update_post_caches|update_postmeta_cache|post_exists|wp_count_post|save_post
See related PR #4228 for details on other subscription-related currency overrides within this function.