Check if 3rd parties are active before integration init.

This commit is contained in:
Narek Zakarian 2023-10-16 15:56:45 +04:00
parent e4534d64cd
commit fedcc8f79a
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
2 changed files with 15 additions and 17 deletions

View file

@ -54,18 +54,6 @@ return array(
);
},
'compat.gzd.is_supported_plugin_version_active' => function (): bool {
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.ywot.is_supported_plugin_version_active' => function (): bool {
return function_exists( 'yith_ywot_init' );
},
'compat.module.url' => static function ( ContainerInterface $container ): string {
/**
* The path cannot be false.

View file

@ -96,10 +96,20 @@ return array(
$logger = $container->get( 'woocommerce.logger.woocommerce' );
$endpoint = $container->get( 'order-tracking.endpoint.controller' );
return array(
new GermanizedShipmentIntegration( $shipment_factory, $logger, $endpoint ),
new ShipmentTrackingIntegration( $shipment_factory, $logger, $endpoint ),
new YithShipmentIntegration( $shipment_factory, $logger, $endpoint ),
);
$integrations = array();
if ( function_exists( 'wc_gzd_get_shipments_by_order' ) ) {
$integrations[] = new GermanizedShipmentIntegration( $shipment_factory, $logger, $endpoint );
}
if ( class_exists( 'WC_Shipment_Tracking' ) ) {
$integrations[] = new ShipmentTrackingIntegration( $shipment_factory, $logger, $endpoint );
}
if ( function_exists( 'yith_ywot_init' ) ) {
$integrations[] = new YithShipmentIntegration( $shipment_factory, $logger, $endpoint );
}
return $integrations;
},
);