smartsendio / woocommerce

Smart Send module for WooCommerce
GNU General Public License v3.0
0 stars 2 forks source link

HPOS compatibility #41

Closed alshypilov closed 7 months ago

alshypilov commented 8 months ago

Closes #34

worked on the next one: https://docs.google.com/spreadsheets/d/1pRkiBV7oMJhUf-oW95p33zqxJ0fNFhTQE1W1s-zD3pk/edit?usp=sharing

bilfeldt commented 8 months ago

Note from @alshypilov

I checked in your plugin code and changed next functions:

Debug log with: Detecting whether HPOS tables are being used in the store Do I need to do this check for all the old functions that I will be replacing with new ones for HPOS?

@alshypilov I think we should just do the debug log for HPOS once. Is there a good place to do this logging? It could be when rendering the admin block or when rendering the settings page? Just one place is fine.

alshypilov commented 8 months ago

1)changed the receipt of order ID in the function where we add a metabox to the order admin menu global $woocommerce, $post, $theorder; $order_id = $post->ID ?? $theorder->ID; Error: Warning: Attempt to read property "ID" on null in /Users/alexshevchenko/Development/smartsendio-new/wp-content/plugins/smart-send-logistics/includes/class-ss-shipping-wc-order.php on line 114...

2)Declaring extension compatibility in class SS_Shipping_WC added action add_action('before_woocommerce_init', [$this, 'declaringExtensionCompatibility']); public function declaringExtensionCompatibility(): void { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', FILE, true ); } }

3)Do we really need the globals? It seems like we should refactor to a "render_smart_send_metabox" method as well:

4)We need to include a link and some description that this is "how to add meta boxes .... - I don’t fully understand what exactly needs to be added in this fix. As in our documentation, this metabox will be added in any case, both for HPOS and without HPOS, we have a check. $screen = wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() ? wc_get_page_screen_id( 'shop_order' ) : 'shop_order';

5)I think we should just do the debug log for HPOS once. Is there a good place to do this logging? It could be when rendering the admin block or when rendering the settings page? Just one place is fine. -Can you write in more detail what you mean? When activating the plugin, if the HPOS mode is not enabled, do I need to log as in this screenshot? image As I understand it, this check is needed so that we can use the functionality when HPOS is turned on and if it is turned off, but then we also need to leave all the old functionality and wrap all new functions in this check? use Automattic\WooCommerce\Utilities\OrderUtil; if ( OrderUtil::custom_orders_table_usage_is_enabled() ) { // HPOS usage is enabled. } else { // Traditional CPT-based orders are in use. }