Automattic\WooCommerce\Internal\Admin\Orders
Edit::maybe_register_order_attribution()
Register order attribution meta boxes if the feature is enabled.
Method of the class: Edit{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = Edit::maybe_register_order_attribution( $screen_id, $title );
- $screen_id(string) (required)
- Screen ID.
- $title(string) (required)
- Title of the page.
Changelog
Since 8.5.0 | Introduced. |
Edit::maybe_register_order_attribution() Edit::maybe register order attribution code WC 9.5.1
private static function maybe_register_order_attribution( string $screen_id, string $title ) { /** * Features controller. * * @var FeaturesController $feature_controller */ $feature_controller = wc_get_container()->get( FeaturesController::class ); if ( ! $feature_controller->feature_is_enabled( 'order_attribution' ) ) { return; } /** * Order attribution meta box. * * @var OrderAttribution $order_attribution_meta_box */ $order_attribution_meta_box = wc_get_container()->get( OrderAttribution::class ); add_meta_box( 'woocommerce-order-source-data', /* Translators: %s order type name. */ sprintf( __( '%s attribution', 'woocommerce' ), $title ), function( $post_or_order ) use ( $order_attribution_meta_box ) { $order = $post_or_order instanceof WC_Order ? $post_or_order : wc_get_order( $post_or_order ); if ( $order instanceof WC_Order ) { $order_attribution_meta_box->output( $order ); } }, $screen_id, 'side', 'high' ); // Add customer history meta box if analytics is enabled. if ( 'yes' !== get_option( 'woocommerce_analytics_enabled' ) ) { return; } if ( ! OrderUtil::is_order_edit_screen() ) { return; } /** * Customer history meta box. * * @var CustomerHistory $customer_history_meta_box */ $customer_history_meta_box = wc_get_container()->get( CustomerHistory::class ); add_meta_box( 'woocommerce-customer-history', __( 'Customer history', 'woocommerce' ), function ( $post_or_order ) use ( $customer_history_meta_box ) { $order = $post_or_order instanceof WC_Order ? $post_or_order : wc_get_order( $post_or_order ); if ( $order instanceof WC_Order ) { $customer_history_meta_box->output( $order ); } }, $screen_id, 'side', 'high' ); }