| @@ -3,8 +3,13 @@ | ||
| 3 | 3 | namespace SpringDevs\Subscription\Admin; |
| 4 | 4 | |
| 5 | 5 | use SpringDevs\Subscription\Illuminate\Helper; |
| 6 | 6 | |
| 7 | +// HPOS: This file is compatible with WooCommerce High-Performance Order Storage (HPOS). | |
| 8 | +// All WooCommerce order data is accessed via WooCommerce CRUD methods (wc_get_order, etc.). | |
| 9 | +// All direct post meta access is for subscription data only, not WooCommerce order data. | |
| 10 | +// If you add new order data access, use WooCommerce CRUD for HPOS compatibility. | |
| 11 | + | |
| 7 | 12 | /** |
| 8 | 13 | * Order class |
| 9 | 14 | * |
| 10 | 15 | * @package SpringDevs\Subscription\Admin |
| @@ -26,12 +31,12 @@ | ||
| 26 | 31 | * |
| 27 | 32 | * @return void |
| 28 | 33 | */ |
| 29 | 34 | public function add_subscription_label( $order ) { |
| 30 | - $histories = Helper::get_subscriptions_from_order( $order->get_id() ); | |
| 35 | + $histories = Helper::get_subscriptions_from_order( $order->get_id() ); // HPOS: Safe, uses custom table for subscription relations. | |
| 31 | 36 | if ( count( $histories ) > 0 ) : |
| 32 | 37 | ?> |
| 33 | - <div class="subscrpt-order-label"><?php echo esc_html_e( 'Subscription order', 'sdevs_subscrpt' ); ?></div> | |
| 38 | + <div class="subscrpt-order-label"><?php echo esc_html_e( 'Subscription order', 'subscription' ); ?></div> | |
| 34 | 39 | <?php |
| 35 | 40 | endif; |
| 36 | 41 | } |
| 37 | 42 | |
| @@ -38,18 +43,18 @@ | ||
| 38 | 43 | /** |
| 39 | 44 | * Related Subscriptions meta box on Orders. |
| 40 | 45 | */ |
| 41 | 46 | public function add_meta_boxes() { |
| 42 | - $screen = is_wc_order_hpos_enabled() | |
| 47 | + $screen = wps_subscription_is_wc_order_hpos_enabled() | |
| 43 | 48 | ? wc_get_page_screen_id( 'shop-order' ) |
| 44 | 49 | : 'shop_order'; |
| 45 | - $order_id = is_wc_order_hpos_enabled() && isset( $_GET['id'] ) ? ( sanitize_text_field( wp_unslash( $_GET['id'] ) ) ) : get_the_ID(); | |
| 50 | + $order_id = wps_subscription_is_wc_order_hpos_enabled() && isset( $_GET['id'] ) ? ( sanitize_text_field( wp_unslash( $_GET['id'] ) ) ) : get_the_ID(); | |
| 46 | 51 | $histories = Helper::get_subscriptions_from_order( $order_id ); |
| 47 | 52 | if ( is_array( $histories ) ) { |
| 48 | - $order = wc_get_order( $order_id ); | |
| 53 | + $order = wc_get_order( $order_id ); // HPOS: Safe, uses WooCommerce CRUD. | |
| 49 | 54 | add_meta_box( |
| 50 | 55 | 'subscrpt_order_related', |
| 51 | - __( 'Related Subscriptions', 'sdevs_subscrpt' ), | |
| 56 | + __( 'Related Subscriptions', 'subscription' ), | |
| 52 | 57 | array( $this, 'subscrpt_order_related' ), |
| 53 | 58 | $screen, |
| 54 | 59 | 'normal', |
| 55 | 60 | 'default', |