mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
refactor tracking integration
This commit is contained in:
parent
1dffac6378
commit
c8e87120d4
24 changed files with 2915 additions and 964 deletions
|
@ -11,7 +11,6 @@ namespace WooCommerce\PayPalCommerce\Compat;
|
|||
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\Compat\Assets\CompatAssets;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
return array(
|
||||
|
||||
|
@ -50,7 +49,7 @@ return array(
|
|||
'ppcp-webhooks-status-page',
|
||||
'ppcp-tracking',
|
||||
'ppcp-fraudnet',
|
||||
'ppcp-gzd-compat',
|
||||
'ppcp-tracking-compat',
|
||||
'ppcp-clear-db',
|
||||
);
|
||||
},
|
||||
|
@ -59,6 +58,10 @@ return array(
|
|||
return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+
|
||||
},
|
||||
|
||||
'compat.wc_shipment_tracking.is_supported_plugin_version_active' => function (): bool {
|
||||
return class_exists( 'WC_Shipment_Tracking' );
|
||||
},
|
||||
|
||||
'compat.module.url' => static function ( ContainerInterface $container ): string {
|
||||
/**
|
||||
* The path cannot be false.
|
||||
|
@ -75,18 +78,9 @@ return array(
|
|||
return new CompatAssets(
|
||||
$container->get( 'compat.module.url' ),
|
||||
$container->get( 'ppcp.asset-version' ),
|
||||
$container->get( 'order-tracking.is-paypal-order-edit-page' ) && $container->get( 'compat.should-initialize-gzd-compat-layer' )
|
||||
$container->get( 'order-tracking.is-module-enabled' ),
|
||||
$container->get( 'compat.gzd.is_supported_plugin_version_active' ),
|
||||
$container->get( 'compat.wc_shipment_tracking.is_supported_plugin_version_active' )
|
||||
);
|
||||
},
|
||||
|
||||
'compat.should-initialize-gzd-compat-layer' => function( ContainerInterface $container ) : bool {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$tracking_enabled = $settings->has( 'tracking_enabled' ) && $settings->get( 'tracking_enabled' );
|
||||
$is_gzd_active = $container->get( 'compat.gzd.is_supported_plugin_version_active' );
|
||||
|
||||
return $tracking_enabled && $is_gzd_active;
|
||||
},
|
||||
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue