Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .psalm/gzd.php → .psalm/shiptastic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Vendidero\Germanized\Shipments {
namespace Vendidero\Shiptastic {

use WC_Data;
use WC_Order;
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions modules/ppcp-compat/resources/js/tracking-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ document.addEventListener( 'DOMContentLoaded', () => {
const orderTrackingContainerId = 'ppcp_order-tracking';
const orderTrackingContainerSelector =
'#ppcp_order-tracking .ppcp-tracking-column.shipments';
const gzdSaveButton = document.getElementById( 'order-shipments-save' );
const shiptasticSaveButton = document.getElementById( 'order-shipments-save' );
const loadLocation =
location.href + ' ' + orderTrackingContainerSelector + '>*';
const gzdSyncEnabled = config.gzd_sync_enabled;
const shiptasticSyncEnabled = config.shiptastic_sync_enabled;
const wcShipmentSyncEnabled = config.wc_shipment_sync_enabled;
const wcShippingTaxSyncEnabled = config.wc_shipping_tax_sync_enabled;
const wcShipmentSaveButton = document.querySelector(
Expand Down Expand Up @@ -61,11 +61,11 @@ document.addEventListener( 'DOMContentLoaded', () => {
};

if (
gzdSyncEnabled &&
typeof gzdSaveButton !== 'undefined' &&
gzdSaveButton != null
shiptasticSyncEnabled &&
typeof shiptasticSaveButton !== 'undefined' &&
shiptasticSaveButton != null
) {
gzdSaveButton.addEventListener( 'click', function ( event ) {
shiptasticSaveButton.addEventListener( 'click', function ( event ) {
toggleLoaderVisibility();
waitForTrackingUpdate( jQuery( '#order-shipments-save' ) );
} );
Expand Down
6 changes: 3 additions & 3 deletions modules/ppcp-compat/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
);
},

'compat.gzd.is_supported_plugin_version_active' => function (): bool {
return function_exists( 'wc_gzd_get_shipments_by_order' ); // 3.0+
'compat.shiptastic.is_supported_plugin_version_active' => function (): bool {
return function_exists( 'wc_stc_get_shipments' );
},

'compat.wc_shipment_tracking.is_supported_plugin_version_active' => function (): bool {
Expand Down Expand Up @@ -113,7 +113,7 @@
return new CompatAssets(
$container->get( 'compat.asset_getter' ),
$container->get( 'ppcp.asset-version' ),
$container->get( 'compat.gzd.is_supported_plugin_version_active' ),
$container->get( 'compat.shiptastic.is_supported_plugin_version_active' ),
$container->get( 'compat.wc_shipment_tracking.is_supported_plugin_version_active' ),
$container->get( 'compat.wc_shipping_tax.is_supported_plugin_version_active' ),
$container->get( 'api.bearer' )
Expand Down
12 changes: 6 additions & 6 deletions modules/ppcp-compat/src/Assets/CompatAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class CompatAssets {
private $version;

/**
* Whether Germanized plugin is active.
* Whether Shiptastic plugin is active.
*
* @var bool
*/
protected $is_gzd_active;
protected $is_shiptastic_active;

/**
* Whether WC Shipments plugin is active
Expand All @@ -60,23 +60,23 @@ class CompatAssets {
/**
* @param AssetGetter $asset_getter
* @param string $version The assets version.
* @param bool $is_gzd_active Whether Germanized plugin is active.
* @param bool $is_shiptastic_active Whether Shiptastic plugin is active.
* @param bool $is_wc_shipment_active Whether WC Shipments plugin is active.
* @param bool $is_wc_shipping_tax_active Whether WC Shipping & Tax plugin is active.
* @param Bearer $bearer The bearer.
*/
public function __construct(
AssetGetter $asset_getter,
string $version,
bool $is_gzd_active,
bool $is_shiptastic_active,
bool $is_wc_shipment_active,
bool $is_wc_shipping_tax_active,
Bearer $bearer
) {

$this->asset_getter = $asset_getter;
$this->version = $version;
$this->is_gzd_active = $is_gzd_active;
$this->is_shiptastic_active = $is_shiptastic_active;
$this->is_wc_shipment_active = $is_wc_shipment_active;
$this->is_wc_shipping_tax_active = $is_wc_shipping_tax_active;
$this->bearer = $bearer;
Expand All @@ -101,7 +101,7 @@ public function register(): void {
'ppcp-tracking-compat',
'PayPalCommerceGatewayOrderTrackingCompat',
array(
'gzd_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) && $this->is_gzd_active,
'shiptastic_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_shiptastic_tracking', true ) && $this->is_shiptastic_active,
'wc_shipment_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_wc_shipment_tracking', true ) && $this->is_wc_shipment_active,
'wc_shipping_tax_sync_enabled' => apply_filters( 'woocommerce_paypal_payments_sync_wc_shipping_tax', true ) && $this->is_wc_shipping_tax_active,
)
Expand Down
8 changes: 4 additions & 4 deletions modules/ppcp-order-tracking/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use WooCommerce\PayPalCommerce\Assets\AssetGetter;
use WooCommerce\PayPalCommerce\Assets\AssetGetterFactory;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\DhlShipmentIntegration;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\GermanizedShipmentIntegration;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\ShiptasticIntegration;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\ShipmentTrackingIntegration;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\ShipStationIntegration;
use WooCommerce\PayPalCommerce\OrderTracking\Integration\WcShippingTaxIntegration;
Expand Down Expand Up @@ -113,7 +113,7 @@
$logger = $container->get( 'woocommerce.logger.woocommerce' );
$endpoint = $container->get( 'order-tracking.endpoint.controller' );

$is_gzd_active = $container->get( 'compat.gzd.is_supported_plugin_version_active' );
$is_shiptastic_active = $container->get( 'compat.shiptastic.is_supported_plugin_version_active' );
$is_wc_shipment_active = $container->get( 'compat.wc_shipment_tracking.is_supported_plugin_version_active' );
$is_yith_ywot_active = $container->get( 'compat.ywot.is_supported_plugin_version_active' );
$is_dhl_de_active = $container->get( 'compat.dhl.is_supported_plugin_version_active' );
Expand All @@ -122,8 +122,8 @@

$integrations = array();

if ( $is_gzd_active ) {
$integrations[] = new GermanizedShipmentIntegration( $shipment_factory, $logger, $endpoint );
if ( $is_shiptastic_active ) {
$integrations[] = new ShiptasticIntegration( $shipment_factory, $logger, $endpoint );
}

if ( $is_wc_shipment_active ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* The Shipment integration for Germanized plugin.
* Shiptastic integration.
* https://wordpress.org/plugins/shiptastic-for-woocommerce/
*
* @package WooCommerce\PayPalCommerce\OrderTracking\Shipment
*/
Expand All @@ -13,17 +14,15 @@
use Psr\Log\LoggerInterface;
use WC_Order;
use WooCommerce\PayPalCommerce\Compat\Integration;
use Vendidero\Germanized\Shipments\Shipment;
use Vendidero\Germanized\Shipments\ShipmentItem;
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
use WooCommerce\PayPalCommerce\OrderTracking\Shipment\ShipmentFactoryInterface;
use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
use function WooCommerce\PayPalCommerce\Api\ppcp_get_paypal_order;

/**
* Class GermanizedShipmentIntegration.
* Class ShiptasticIntegration.
*/
class GermanizedShipmentIntegration implements Integration {
class ShiptasticIntegration implements Integration {

use TransactionIdHandlingTrait;

Expand Down Expand Up @@ -69,12 +68,11 @@ public function __construct(
* {@inheritDoc}
*/
public function integrate(): void {

add_action(
'woocommerce_gzd_shipment_status_shipped',
function ( int $shipment_id, Shipment $shipment ) {
'woocommerce_shiptastic_shipment_status_shipped',
function ( int $shipment_id, $shipment ) {
try {
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_gzd_tracking', true ) ) {
if ( ! apply_filters( 'woocommerce_paypal_payments_sync_shiptastic_tracking', true ) ) {
return;
}

Expand All @@ -91,7 +89,7 @@ function ( int $shipment_id, Shipment $shipment ) {
$carrier = $shipment->get_shipping_provider();

$items = array_map(
function ( ShipmentItem $item ): int {
function ( $item ): int {
return $item->get_order_item_id();
},
$shipment->get_items()
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<file name=".psalm/stubs.php"/>
<file name=".psalm/wcblocks.php"/>
<file name=".psalm/wcs.php"/>
<file name=".psalm/gzd.php"/>
<file name=".psalm/shiptastic.php"/>
<file name=".psalm/wc-bookings.php"/>
<file name=".psalm/wpcli.php"/>
<file name="vendor/php-stubs/wordpress-stubs/wordpress-stubs.php"/>
Expand Down
Loading