-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: WooCommerce HPOS compatibility (beta) (#9)
- Loading branch information
Showing
3 changed files
with
132 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly | ||
} | ||
|
||
class WPO_WCIEP_Order_Util { | ||
|
||
protected static $_instance = null; | ||
public $wc_order_util_class_object; | ||
|
||
/** | ||
* Construct. | ||
*/ | ||
public function __construct() { | ||
$this->wc_order_util_class_object = $this->get_wc_order_util_class(); | ||
} | ||
|
||
/** | ||
* Instance. | ||
*/ | ||
public static function instance() { | ||
if ( is_null( self::$_instance ) ) { | ||
self::$_instance = new self(); | ||
} | ||
return self::$_instance; | ||
} | ||
|
||
/** | ||
* Function to check woocommerce OrderUtil class is exists or not. | ||
*/ | ||
public function get_wc_order_util_class() { | ||
if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) { | ||
return \Automattic\WooCommerce\Utilities\OrderUtil::class; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Function to get order type. | ||
*/ | ||
public function get_order_type( $order_id ) { | ||
if ( $this->wc_order_util_class_object && is_callable( [ $this->wc_order_util_class_object, 'get_order_type' ] ) ) { | ||
return $this->wc_order_util_class_object::get_order_type( intval( $order_id ) ); | ||
} else { | ||
return get_post_type( intval( $order_id ) ); | ||
} | ||
} | ||
|
||
/** | ||
* Function to check id HPOS functionality is enabled or not. | ||
*/ | ||
public function custom_orders_table_usage_is_enabled() { | ||
if ( $this->wc_order_util_class_object && is_callable( [ $this->wc_order_util_class_object, 'custom_orders_table_usage_is_enabled' ] ) ) { | ||
return $this->wc_order_util_class_object::custom_orders_table_usage_is_enabled(); | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Function to check screen. | ||
*/ | ||
public function custom_order_table_screen() { | ||
$screen = $this->custom_orders_table_usage_is_enabled() ? wc_get_page_screen_id( 'shop-order' ) : 'shop_order'; | ||
|
||
return $screen; | ||
} | ||
|
||
} // end class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters