Plugin Directory

Changeset 3265740


Ignore:
Timestamp:
04/02/2025 02:58:17 PM (11 months ago)
Author:
packlink
Message:

Release version 3.5.0

Location:
packlink-pro-shipping
Files:
1011 added
35 edited

Legend:

Unmodified
Added
Removed
  • packlink-pro-shipping/trunk/Components/class-bootstrap-component.php

    r3048950 r3265740  
    2424use Packlink\BusinessLogic\BootstrapComponent;
    2525use Packlink\BusinessLogic\Brand\BrandConfigurationService;
     26use Packlink\BusinessLogic\Country\WarehouseCountryService;
    2627use Packlink\BusinessLogic\FileResolver\FileResolverService;
    2728use Packlink\BusinessLogic\Order\Interfaces\ShopOrderService;
     
    4344use Packlink\WooCommerce\Components\Services\Registration_Info_Service;
    4445use Packlink\WooCommerce\Components\Services\System_Info_Service;
     46use Packlink\WooCommerce\Components\Services\Warehouse_Country_Service;
    4547use Packlink\WooCommerce\Components\ShippingMethod\Shipping_Method_Map;
    4648use Packlink\WooCommerce\Components\ShippingMethod\Shop_Shipping_Method_Service;
     
    138140            }
    139141        );
     142
     143        ServiceRegister::registerService(
     144            WarehouseCountryService::CLASS_NAME,
     145            static function () {
     146                return Warehouse_Country_Service::getInstance();
     147            }
     148        );
    140149    }
    141150
  • packlink-pro-shipping/trunk/Controllers/class-packlink-index.php

    r3048950 r3265740  
    7373            'Shipping_Zones',
    7474            'Support',
    75             'Manual_Sync'
     75            'Manual_Sync',
     76            'Manual_Refresh_Service'
    7677        );
    7778
  • packlink-pro-shipping/trunk/changelog.txt

    r3048950 r3265740  
    11*** Packlink PRO Changelog ***
     22025-03-27 - version 3.5.0
     3* Add - Manual refresh button for updating shipping services.
     4* Add - Support for special services
    25
    362023-10-11 - version 3.3.1
  • packlink-pro-shipping/trunk/composer.json

    r3254819 r3265740  
    22  "name": "packlink/woocommerce",
    33  "description": "Packlink WooCommerce Integration",
    4   "version": "3.4.16",
     4  "version": "3.5.0",
    55  "type": "library",
    66  "repositories": [
     
    1313  "require": {
    1414    "php": ">=5.6",
    15     "packlink/integration-core": "3.4.12",
     15    "packlink/integration-core": "3.5.0",
    1616    "ext-json": "*",
    1717    "ext-curl": "*",
  • packlink-pro-shipping/trunk/composer.lock

    r3254819 r3265740  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "5ba751b7c9263ee45633a5debb5dabe8",
     7    "content-hash": "b7603b71f6f55997cce8c1b35a9dad4b",
    88    "packages": [
    99        {
     
    6363        {
    6464            "name": "packlink/integration-core",
    65             "version": "v3.4.12",
     65            "version": "v3.5.0",
    6666            "source": {
    6767                "type": "git",
    6868                "url": "git@github.com:packlink-dev/ecommerce_module_core.git",
    69                 "reference": "af5269c11c5182b503167aa6e700b59c77418af5"
    70             },
    71             "dist": {
    72                 "type": "zip",
    73                 "url": "https://api.github.com/repos/packlink-dev/ecommerce_module_core/zipball/af5269c11c5182b503167aa6e700b59c77418af5",
    74                 "reference": "af5269c11c5182b503167aa6e700b59c77418af5",
     69                "reference": "89be76fec554f0f7cf00df6ffcff5d8b1bd05acd"
     70            },
     71            "dist": {
     72                "type": "zip",
     73                "url": "https://api.github.com/repos/packlink-dev/ecommerce_module_core/zipball/89be76fec554f0f7cf00df6ffcff5d8b1bd05acd",
     74                "reference": "89be76fec554f0f7cf00df6ffcff5d8b1bd05acd",
    7575                "shasum": ""
    7676            },
     
    111111            ],
    112112            "description": "Packlink integrations core library",
    113             "time": "2025-03-11T11:34:19+00:00"
     113            "time": "2025-03-25T16:09:23+00:00"
    114114        },
    115115        {
  • packlink-pro-shipping/trunk/packlink-pro-shipping.php

    r3258568 r3265740  
    1010 * Plugin URI: https://en.wordpress.org/plugins/packlink-pro-shipping/
    1111 * Description: Save up to 70% on your shipping costs. No fixed fees, no minimum shipping volume required. Manage all your shipments in a single platform.
    12  * Version: 3.4.16
     12 * Version: 3.5.0
    1313 * Author: Packlink Shipping S.L.
    1414 * Author URI: https://pro.packlink.es/
  • packlink-pro-shipping/trunk/readme.txt

    r3258568 r3265740  
    55Requires PHP: 5.5
    66Tested up to: 6.7.2
    7 Stable tag: 3.4.16
     7Stable tag: 3.5.0
    88License: LICENSE-2.0
    99License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    6868
    6969== Changelog ==
     70
     71#### 3.5.0 - March 27th, 2025
     72**Updates**
     73Add support for special services and manual refresh of shipping services
    7074
    7175#### 3.4.16 - March 12th, 2025
  • packlink-pro-shipping/trunk/resources/packlink/countries/en.json

    r3118361 r3265740  
    489489    "discardChangesQuestion": "There are unsaved changes.<br>Are you sure you want to go back and discard them?",
    490490    "atLeastOneCountry": "At least one country must be selected.",
    491     "misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service."
     491    "misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service.",
     492    "refreshServiceList" : "Refresh service list",
     493    "refreshError": "An error occurred while refreshing the service list"
    492494  },
    493495  "orderListAndDetails": {
  • packlink-pro-shipping/trunk/resources/packlink/css/app.css

    r3118361 r3265740  
    367367  color: #fff;
    368368}
     369#pl-page button.pl-button-primary.pl-normal, #pl-page .pl-button.pl-button-primary.pl-normal {
     370  text-transform: none;
     371  margin: 0;
     372}
     373#pl-page button.pl-button-primary.pl-normal .pl-spinner, #pl-page .pl-button.pl-button-primary.pl-normal .pl-spinner {
     374  position: absolute;
     375  z-index: 500;
     376  background-color: unset;
     377  display: flex;
     378  justify-content: center;
     379  align-items: center;
     380  top: unset;
     381  left: unset;
     382  right: unset;
     383  bottom: unset;
     384}
     385#pl-page button.pl-button-primary.pl-normal .pl-spinner div, #pl-page .pl-button.pl-button-primary.pl-normal .pl-spinner div {
     386  width: 80px;
     387  height: 80px;
     388  border: 3px solid transparent;
     389  border-right-color: #2095f2;
     390  border-left-color: #2095f2;
     391  border-radius: 50%;
     392  animation: pl-rotate 1s linear 0s infinite;
     393}
    369394#pl-page button.pl-button-secondary, #pl-page .pl-button.pl-button-secondary {
    370395  border: 1px solid #2095f2;
     
    939964  height: 90px;
    940965}
     966#pl-page #pl-error {
     967  position: sticky;
     968  bottom: 20px;
     969  left: 50%;
     970  gap: 10px;
     971  width: 100%;
     972  display: flex;
     973  align-items: center;
     974}
     975#pl-page #pl-error #error-message-btn {
     976  padding-right: 30px;
     977  color: #f5f5f5;
     978  background-color: #ca2929;
     979  text-transform: none;
     980}
     981#pl-page #pl-error #pl-error-message {
     982  color: #f5f5f5;
     983}
     984#pl-page #pl-error #close-error {
     985  font-size: 22px;
     986  color: #f5f5f5;
     987  position: absolute;
     988  right: 8px;
     989  cursor: pointer;
     990  margin-left: 10px;
     991}
     992#pl-page .pl-button-danger {
     993  background-color: #ca2929;
     994}
    941995#pl-page .pl-onboarding-list {
    942996  width: 100%;
  • packlink-pro-shipping/trunk/resources/packlink/js/PickShippingServiceController.js

    r3048950 r3265740  
    1414     * @property {string} systemId
    1515     * @property {boolean} newService
     16     * @property {string} enqueue
     17     * @property {string} getTaskStatus
    1618     */
    1719
     
    6466            });
    6567
     68            const button = mainPage.querySelector('#refresh-service-list-btn');
     69            const errorButton = mainPage.querySelector('#error-message-btn');
     70            const errorMessageText = mainPage.querySelector('#pl-error-message');
     71
     72            checkTaskStatus(button,errorButton,errorMessageText);
     73
    6674            mainPage.querySelectorAll('.pl-filter-option').forEach((optionBtn) => {
    6775                optionBtn.addEventListener('click', () => {
     
    7280
    7381            mainPage.querySelector('#pl-open-filter-button').addEventListener('click', showFilterModal);
    74         };
     82
     83            mainPage.querySelector('#refresh-service-list-btn').addEventListener('click', () => {
     84                ajaxService.get(configuration.enqueue, (response) => {
     85                    if (response.status === 'success') {
     86
     87                        button.disabled = true;
     88                        utilityService.showSpinner('pl-refresh-spinner');
     89
     90                        checkTaskStatus(button, errorButton, errorMessageText,false);
     91                    } else {
     92                        showError(errorButton,errorMessageText,response.message, false);
     93                    }
     94                });
     95            });
     96
     97            const closeErrorButton = document.getElementById('close-error');
     98
     99            closeErrorButton.addEventListener('click', () => {
     100                errorButton.classList.add('pl-hidden');
     101            });
     102        };
     103
     104        function showError(button, messageButton, message) {
     105            button.classList.remove('pl-hidden');
     106
     107            if(message) {
     108                messageButton.textContent = message;
     109            }
     110
     111            setTimeout(() => {
     112               button.classList.add('pl-hidden');
     113            }, 5000);
     114        }
     115
     116        /**
     117         * @param button
     118         * @param errorButton
     119         * @param errorMessage
     120         * @param initial
     121         */
     122        function checkTaskStatus(button, errorButton, errorMessage, initial = true) {
     123            ajaxService.get(configuration.getTaskStatus, (response) => {
     124                const taskStatus = response.status;
     125                const message = response.message;
     126
     127                if (taskStatus === 'queued' || taskStatus === 'in_progress' || taskStatus === 'created') {
     128                    utilityService.showSpinner('pl-refresh-spinner');
     129                    button.disabled = true;
     130                    setTimeout(() => checkTaskStatus(button, errorButton, errorMessage,initial), 3000);
     131                } else if (taskStatus === 'completed') {
     132                    utilityService.hideSpinner('pl-refresh-spinner');
     133                    button.disabled = false;
     134
     135                    ajaxService.get(configuration.getTaskStatusUrl, checkServicesStatus);
     136                } else if (taskStatus === 'failed' && !initial) {
     137                    utilityService.hideSpinner('pl-refresh-spinner');
     138                    button.disabled = false;
     139                    showError(errorButton,errorMessage, message);
     140
     141                } else if (!initial) {
     142                    showError(errorButton,errorMessage, message);
     143                }
     144            });
     145        }
    75146
    76147        /**
     
    135206         */
    136207        const hideNoServicesModal = () => {
    137             noServicesModal.close();
     208            if (noServicesModal) {
     209                noServicesModal.close();
     210            }
    138211        };
    139212
     
    142215         */
    143216        const startAutoConfigure = () => {
     217            const mainPage = templateService.getMainPage();
     218
     219            const button = mainPage.querySelector('#refresh-service-list-btn');
     220            const errorMessage = mainPage.querySelector('#pl-error');
     221            const errorMessageText = mainPage.querySelector('#pl-error-message');
     222
     223            checkTaskStatus(button, errorMessage,errorMessageText, true);
     224
     225            loadServices();
     226        };
     227
     228        const loadServices = () => {
    144229            hideNoServicesModal();
    145230            utilityService.showSpinner();
     
    156241                showNoServicesModal
    157242            );
    158         };
     243        }
    159244
    160245        /**
  • packlink-pro-shipping/trunk/resources/packlink/js/UtilityService.js

    r3048950 r3265740  
    2626         * Enables loading spinner.
    2727         */
    28         this.showSpinner = () => {
    29             this.showElement(document.getElementById('pl-spinner'));
     28        this.showSpinner = (spinnerClass = null) => {
     29            if (spinnerClass) {
     30                this.showElement(document.getElementById(spinnerClass));
     31            } else {
     32                this.showElement(document.getElementById('pl-spinner'));
     33            }
    3034        };
    3135
     
    3337         * Hides loading spinner.
    3438         */
    35         this.hideSpinner = () => {
    36             this.hideElement(document.getElementById('pl-spinner'));
     39        this.hideSpinner = (spinnerClass = null) => {
     40            if (spinnerClass) {
     41                this.hideElement(document.getElementById(spinnerClass));
     42            } else {
     43                this.hideElement(document.getElementById('pl-spinner'));
     44            }
    3745        };
    3846
  • packlink-pro-shipping/trunk/resources/packlink/templates/pick-shipping-services.html

    r3048950 r3265740  
    6868                <div class="pl-filter-options"></div>
    6969            </div>
     70            <div class="pl-filter" style="margin-left: auto">
     71                <button id="refresh-service-list-btn" class="pl-button pl-button-primary pl-normal">
     72                    <div class="pl-spinner pl-hidden" id="pl-refresh-spinner">
     73                        <div></div>
     74                    </div>{$shippingServices.refreshServiceList}</button>
     75            </div>
    7076        </div>
    7177        <div id="pl-shipping-services-table" class="pl-full-width">
     
    7379        <div id="pl-shipping-services-list" class="pl-full-width">
    7480        </div>
     81        <div class="pl-error" id="pl-error">
     82            <button id="error-message-btn" class="pl-button pl-button-danger pl-hidden">
     83                <span id="pl-error-message">{$shippingServices.refreshError}.</span>
     84                <span id="close-error" class="pl-error-close">&times;</span>
     85            </button>
     86        </div>
    7587    </div>
    7688</div>
  • packlink-pro-shipping/trunk/resources/views/index.php

    r3048950 r3265740  
    131131                    disableCarriersUrl: "<?php echo Shop_Helper::get_controller_url( 'Shop_Shipping_Methods', 'disable_shop_shipping_methods' ); //phpcs:ignore ?>",
    132132                    getCurrencyDetailsUrl: "<?php echo Shop_Helper::get_controller_url( 'System_Info', 'get' ); //phpcs:ignore ?>",
    133                     systemId: "<?php echo System_Info_Service::SYSTEM_ID; ?>"
     133                    systemId: "<?php echo System_Info_Service::SYSTEM_ID; ?>",
     134                    enqueue: "<?php echo Shop_Helper::get_controller_url('Manual_Refresh_Service', 'refresh'); //phpcs:ignore ?>",
     135                    getTaskStatus: "<?php echo Shop_Helper::get_controller_url('Manual_Refresh_Service', 'get_task_status'); //phpcs:ignore ?>"
    134136                },
    135137                'edit-service': {
  • packlink-pro-shipping/trunk/vendor/autoload.php

    r3258568 r3265740  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit8cc8e28b45681d97044e5d49b5d35c95::getLoader();
     7return ComposerAutoloaderInit465a7228740afca527e9e10d4e5e33aa::getLoader();
  • packlink-pro-shipping/trunk/vendor/composer/autoload_real.php

    r3258568 r3265740  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit8cc8e28b45681d97044e5d49b5d35c95
     5class ComposerAutoloaderInit465a7228740afca527e9e10d4e5e33aa
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit8cc8e28b45681d97044e5d49b5d35c95', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit465a7228740afca527e9e10d4e5e33aa', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit8cc8e28b45681d97044e5d49b5d35c95', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit465a7228740afca527e9e10d4e5e33aa', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit8cc8e28b45681d97044e5d49b5d35c95::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit465a7228740afca527e9e10d4e5e33aa::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • packlink-pro-shipping/trunk/vendor/composer/autoload_static.php

    r3258568 r3265740  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit8cc8e28b45681d97044e5d49b5d35c95
     7class ComposerStaticInit465a7228740afca527e9e10d4e5e33aa
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    6363    {
    6464        return \Closure::bind(function () use ($loader) {
    65             $loader->prefixLengthsPsr4 = ComposerStaticInit8cc8e28b45681d97044e5d49b5d35c95::$prefixLengthsPsr4;
    66             $loader->prefixDirsPsr4 = ComposerStaticInit8cc8e28b45681d97044e5d49b5d35c95::$prefixDirsPsr4;
    67             $loader->classMap = ComposerStaticInit8cc8e28b45681d97044e5d49b5d35c95::$classMap;
     65            $loader->prefixLengthsPsr4 = ComposerStaticInit465a7228740afca527e9e10d4e5e33aa::$prefixLengthsPsr4;
     66            $loader->prefixDirsPsr4 = ComposerStaticInit465a7228740afca527e9e10d4e5e33aa::$prefixDirsPsr4;
     67            $loader->classMap = ComposerStaticInit465a7228740afca527e9e10d4e5e33aa::$classMap;
    6868
    6969        }, null, ClassLoader::class);
  • packlink-pro-shipping/trunk/vendor/composer/installed.json

    r3254819 r3265740  
    6060        {
    6161            "name": "packlink/integration-core",
    62             "version": "v3.4.12",
    63             "version_normalized": "3.4.12.0",
     62            "version": "v3.5.0",
     63            "version_normalized": "3.5.0.0",
    6464            "source": {
    6565                "type": "git",
    6666                "url": "git@github.com:packlink-dev/ecommerce_module_core.git",
    67                 "reference": "af5269c11c5182b503167aa6e700b59c77418af5"
    68             },
    69             "dist": {
    70                 "type": "zip",
    71                 "url": "https://api.github.com/repos/packlink-dev/ecommerce_module_core/zipball/af5269c11c5182b503167aa6e700b59c77418af5",
    72                 "reference": "af5269c11c5182b503167aa6e700b59c77418af5",
     67                "reference": "89be76fec554f0f7cf00df6ffcff5d8b1bd05acd"
     68            },
     69            "dist": {
     70                "type": "zip",
     71                "url": "https://api.github.com/repos/packlink-dev/ecommerce_module_core/zipball/89be76fec554f0f7cf00df6ffcff5d8b1bd05acd",
     72                "reference": "89be76fec554f0f7cf00df6ffcff5d8b1bd05acd",
    7373                "shasum": ""
    7474            },
     
    8282                "phpunit/phpunit": "^4.8"
    8383            },
    84             "time": "2025-03-11T11:34:19+00:00",
     84            "time": "2025-03-25T16:09:23+00:00",
    8585            "type": "library",
    8686            "installation-source": "dist",
  • packlink-pro-shipping/trunk/vendor/composer/installed.php

    r3254819 r3265740  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '3.4.16',
    4         'version' => '3.4.16.0',
     3        'pretty_version' => '3.5.0',
     4        'version' => '3.5.0.0',
    55        'type' => 'library',
    66        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'packlink/integration-core' => array(
    23             'pretty_version' => 'v3.4.12',
    24             'version' => '3.4.12.0',
     23            'pretty_version' => 'v3.5.0',
     24            'version' => '3.5.0.0',
    2525            'type' => 'library',
    2626            'install_path' => __DIR__ . '/../packlink/integration-core',
    2727            'aliases' => array(),
    28             'reference' => 'af5269c11c5182b503167aa6e700b59c77418af5',
     28            'reference' => '89be76fec554f0f7cf00df6ffcff5d8b1bd05acd',
    2929            'dev_requirement' => false,
    3030        ),
    3131        'packlink/woocommerce' => array(
    32             'pretty_version' => '3.4.16',
    33             'version' => '3.4.16.0',
     32            'pretty_version' => '3.5.0',
     33            'version' => '3.5.0.0',
    3434            'type' => 'library',
    3535            'install_path' => __DIR__ . '/../../',
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/CHANGELOG.md

    r3254819 r3265740  
    33
    44The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
     5
     6## [3.5.0](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.4.11...v3.5.0) - 2025-03-17
     7**BREAKING CHANGES**
     8### Added
     9- Add manual refresh button for updating shipping services
     10- Add additional data to Shipment
     11### Changed
     12- `UpdateShippingServicesTask` - update to fetch special services
    513
    614## [3.4.11](https://github.com/packlink-dev/ecommerce_module_core/compare/v3.4.10...v3.4.11) - 2025-03-10
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Controllers/DTO/ShippingMethodResponse.php

    r3048950 r3265740  
    7878                'logoUrl' => $this->logoUrl,
    7979                'currency' => $this->currency,
     80                'activated' => $this->activated,
    8081            )
    8182        );
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Http/DTO/Shipment.php

    r3048950 r3265740  
    44
    55use Logeecom\Infrastructure\Data\DataTransferObject;
     6use Packlink\BusinessLogic\Http\DTO\Shipment\AdditionalData;
    67
    78/**
     
    8485     */
    8586    public $currency;
     87    /**
     88     * @var AdditionalData
     89     */
     90    public $additionalData;
    8691
    8792    /**
     
    107112            'service_id' => $this->serviceId,
    108113            'currency' => $this->currency,
     114            'additional_data' => $this->additionalData->toArray(),
    109115        );
    110116    }
     
    142148
    143149        $shipment->carrierTrackingUrl = static::getDataValue($raw, 'tracking_url');
     150        $shipment->additionalData = AdditionalData::fromArray(static::getDataValue($raw, 'additional_data', array()));
    144151
    145152        return $shipment;
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Http/DTO/ShippingServiceDetails.php

    r3048950 r3265740  
    142142     */
    143143    public $availableDates;
     144
     145    /**
     146     * @var array
     147     */
     148    public $tags = array();
    144149
    145150    /**
     
    168173            'service_info' => $this->serviceInfo,
    169174            'available_dates' => $this->availableDates,
     175            'tags' => $this->tags,
    170176        );
    171177    }
     
    180186        $instance->id = self::getDataValue($raw, 'id');
    181187        $instance->carrierName = self::getDataValue($raw, 'carrier_name');
    182         $instance->serviceName = self::getDataValue($raw, 'service_name');
     188        $instance->serviceName = self::getDataValue($raw, 'name');
    183189        $instance->currency = self::getDataValue($raw, 'currency');
    184190        $instance->country = self::getDataValue($raw, 'country');
     
    205211        $instance->availableDates = self::getDataValue($raw, 'available_dates', array());
    206212        $instance->national = self::getDataValue($raw, 'national', null);
     213        $instance->tags = self::getDataValue($raw, 'tags', array());
    207214
    208215        return $instance;
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Order/OrderService.php

    r3254819 r3265740  
    5454     * @var ShopOrderService
    5555     */
    56     private $shopOrderService;
     56    protected $shopOrderService;
    5757    /**
    5858     * @var OrderShipmentDetailsService
    5959     */
    60     private $orderShipmentDetailsService;
     60    protected $orderShipmentDetailsService;
    6161
    6262    /**
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/countries/en.json

    r3118361 r3265740  
    489489    "discardChangesQuestion": "There are unsaved changes.<br>Are you sure you want to go back and discard them?",
    490490    "atLeastOneCountry": "At least one country must be selected.",
    491     "misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service."
     491    "misconfiguration": "Due to store currency change, you must set a Fixed Price value by clicking \"edit\" on the shipping service.",
     492    "refreshServiceList" : "Refresh service list",
     493    "refreshError": "An error occurred while refreshing the service list"
    492494  },
    493495  "orderListAndDetails": {
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/css/app.css

    r3118361 r3265740  
    367367  color: #fff;
    368368}
     369#pl-page button.pl-button-primary.pl-normal, #pl-page .pl-button.pl-button-primary.pl-normal {
     370  text-transform: none;
     371  margin: 0;
     372}
     373#pl-page button.pl-button-primary.pl-normal .pl-spinner, #pl-page .pl-button.pl-button-primary.pl-normal .pl-spinner {
     374  position: absolute;
     375  z-index: 500;
     376  background-color: unset;
     377  display: flex;
     378  justify-content: center;
     379  align-items: center;
     380  top: unset;
     381  left: unset;
     382  right: unset;
     383  bottom: unset;
     384}
     385#pl-page button.pl-button-primary.pl-normal .pl-spinner div, #pl-page .pl-button.pl-button-primary.pl-normal .pl-spinner div {
     386  width: 80px;
     387  height: 80px;
     388  border: 3px solid transparent;
     389  border-right-color: #2095f2;
     390  border-left-color: #2095f2;
     391  border-radius: 50%;
     392  animation: pl-rotate 1s linear 0s infinite;
     393}
    369394#pl-page button.pl-button-secondary, #pl-page .pl-button.pl-button-secondary {
    370395  border: 1px solid #2095f2;
     
    939964  height: 90px;
    940965}
     966#pl-page #pl-error {
     967  position: sticky;
     968  bottom: 20px;
     969  left: 50%;
     970  gap: 10px;
     971  width: 100%;
     972  display: flex;
     973  align-items: center;
     974}
     975#pl-page #pl-error #error-message-btn {
     976  padding-right: 30px;
     977  color: #f5f5f5;
     978  background-color: #ca2929;
     979  text-transform: none;
     980}
     981#pl-page #pl-error #pl-error-message {
     982  color: #f5f5f5;
     983}
     984#pl-page #pl-error #close-error {
     985  font-size: 22px;
     986  color: #f5f5f5;
     987  position: absolute;
     988  right: 8px;
     989  cursor: pointer;
     990  margin-left: 10px;
     991}
     992#pl-page .pl-button-danger {
     993  background-color: #ca2929;
     994}
    941995#pl-page .pl-onboarding-list {
    942996  width: 100%;
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/js/PickShippingServiceController.js

    r3048950 r3265740  
    1414     * @property {string} systemId
    1515     * @property {boolean} newService
     16     * @property {string} enqueue
     17     * @property {string} getTaskStatus
    1618     */
    1719
     
    6466            });
    6567
     68            const button = mainPage.querySelector('#refresh-service-list-btn');
     69            const errorButton = mainPage.querySelector('#error-message-btn');
     70            const errorMessageText = mainPage.querySelector('#pl-error-message');
     71
     72            checkTaskStatus(button,errorButton,errorMessageText);
     73
    6674            mainPage.querySelectorAll('.pl-filter-option').forEach((optionBtn) => {
    6775                optionBtn.addEventListener('click', () => {
     
    7280
    7381            mainPage.querySelector('#pl-open-filter-button').addEventListener('click', showFilterModal);
    74         };
     82
     83            mainPage.querySelector('#refresh-service-list-btn').addEventListener('click', () => {
     84                ajaxService.get(configuration.enqueue, (response) => {
     85                    if (response.status === 'success') {
     86
     87                        button.disabled = true;
     88                        utilityService.showSpinner('pl-refresh-spinner');
     89
     90                        checkTaskStatus(button, errorButton, errorMessageText,false);
     91                    } else {
     92                        showError(errorButton,errorMessageText,response.message, false);
     93                    }
     94                });
     95            });
     96
     97            const closeErrorButton = document.getElementById('close-error');
     98
     99            closeErrorButton.addEventListener('click', () => {
     100                errorButton.classList.add('pl-hidden');
     101            });
     102        };
     103
     104        function showError(button, messageButton, message) {
     105            button.classList.remove('pl-hidden');
     106
     107            if(message) {
     108                messageButton.textContent = message;
     109            }
     110
     111            setTimeout(() => {
     112               button.classList.add('pl-hidden');
     113            }, 5000);
     114        }
     115
     116        /**
     117         * @param button
     118         * @param errorButton
     119         * @param errorMessage
     120         * @param initial
     121         */
     122        function checkTaskStatus(button, errorButton, errorMessage, initial = true) {
     123            ajaxService.get(configuration.getTaskStatus, (response) => {
     124                const taskStatus = response.status;
     125                const message = response.message;
     126
     127                if (taskStatus === 'queued' || taskStatus === 'in_progress' || taskStatus === 'created') {
     128                    utilityService.showSpinner('pl-refresh-spinner');
     129                    button.disabled = true;
     130                    setTimeout(() => checkTaskStatus(button, errorButton, errorMessage,initial), 3000);
     131                } else if (taskStatus === 'completed') {
     132                    utilityService.hideSpinner('pl-refresh-spinner');
     133                    button.disabled = false;
     134
     135                    ajaxService.get(configuration.getTaskStatusUrl, checkServicesStatus);
     136                } else if (taskStatus === 'failed' && !initial) {
     137                    utilityService.hideSpinner('pl-refresh-spinner');
     138                    button.disabled = false;
     139                    showError(errorButton,errorMessage, message);
     140
     141                } else if (!initial) {
     142                    showError(errorButton,errorMessage, message);
     143                }
     144            });
     145        }
    75146
    76147        /**
     
    135206         */
    136207        const hideNoServicesModal = () => {
    137             noServicesModal.close();
     208            if (noServicesModal) {
     209                noServicesModal.close();
     210            }
    138211        };
    139212
     
    142215         */
    143216        const startAutoConfigure = () => {
     217            const mainPage = templateService.getMainPage();
     218
     219            const button = mainPage.querySelector('#refresh-service-list-btn');
     220            const errorMessage = mainPage.querySelector('#pl-error');
     221            const errorMessageText = mainPage.querySelector('#pl-error-message');
     222
     223            checkTaskStatus(button, errorMessage,errorMessageText, true);
     224
     225            loadServices();
     226        };
     227
     228        const loadServices = () => {
    144229            hideNoServicesModal();
    145230            utilityService.showSpinner();
     
    156241                showNoServicesModal
    157242            );
    158         };
     243        }
    159244
    160245        /**
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/js/UtilityService.js

    r3048950 r3265740  
    2626         * Enables loading spinner.
    2727         */
    28         this.showSpinner = () => {
    29             this.showElement(document.getElementById('pl-spinner'));
     28        this.showSpinner = (spinnerClass = null) => {
     29            if (spinnerClass) {
     30                this.showElement(document.getElementById(spinnerClass));
     31            } else {
     32                this.showElement(document.getElementById('pl-spinner'));
     33            }
    3034        };
    3135
     
    3337         * Hides loading spinner.
    3438         */
    35         this.hideSpinner = () => {
    36             this.hideElement(document.getElementById('pl-spinner'));
     39        this.hideSpinner = (spinnerClass = null) => {
     40            if (spinnerClass) {
     41                this.hideElement(document.getElementById(spinnerClass));
     42            } else {
     43                this.hideElement(document.getElementById('pl-spinner'));
     44            }
    3745        };
    3846
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/scss/app.scss

    r3048950 r3265740  
    99  #pl-main-header {
    1010    height: 90px;
     11  }
     12
     13  #pl-error{
     14    position: sticky;
     15    bottom: 20px;
     16    left: 50%;
     17    gap: 10px;
     18    width: 100%;
     19    display: flex;
     20    align-items: center;
     21
     22    #error-message-btn {
     23      padding-right: 30px;
     24      color: #F5F5F5;
     25      background-color: #ca2929;
     26      text-transform: none;
     27    }
     28
     29    #pl-error-message {
     30      color: #F5F5F5;
     31    }
     32
     33    #close-error {
     34      font-size: 22px;
     35      color: #F5F5F5;
     36      position: absolute;
     37      right: 8px;
     38      cursor: pointer;
     39      margin-left: 10px;
     40    }
     41  }
     42
     43  .pl-button-danger {
     44    background-color: #ca2929;
    1145  }
    1246
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/scss/ui-controls.scss

    r3118361 r3265740  
    6969      background-color: $color-blue;
    7070      color: $color-white;
     71
     72      &.pl-normal {
     73        text-transform: none;
     74        margin: 0;
     75
     76        .pl-spinner {
     77          position: absolute;
     78          z-index: 500;
     79          background-color: unset;
     80          display: flex;
     81          justify-content: center;
     82          align-items: center;
     83          top: unset;
     84          left: unset;
     85          right: unset;
     86          bottom: unset;
     87
     88          div {
     89            width: 80px;
     90            height: 80px;
     91            border: 3px solid transparent;
     92            border-right-color: $color-blue;
     93            border-left-color: $color-blue;
     94            border-radius: 50%;
     95            animation: pl-rotate 1s linear 0s infinite;
     96          }
     97        }
     98      }
    7199    }
    72100
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Resources/templates/pick-shipping-services.html

    r3048950 r3265740  
    6868                <div class="pl-filter-options"></div>
    6969            </div>
     70            <div class="pl-filter" style="margin-left: auto">
     71                <button id="refresh-service-list-btn" class="pl-button pl-button-primary pl-normal">
     72                    <div class="pl-spinner pl-hidden" id="pl-refresh-spinner">
     73                        <div></div>
     74                    </div>{$shippingServices.refreshServiceList}</button>
     75            </div>
    7076        </div>
    7177        <div id="pl-shipping-services-table" class="pl-full-width">
     
    7379        <div id="pl-shipping-services-list" class="pl-full-width">
    7480        </div>
     81        <div class="pl-error" id="pl-error">
     82            <button id="error-message-btn" class="pl-button pl-button-danger pl-hidden">
     83                <span id="pl-error-message">{$shippingServices.refreshError}.</span>
     84                <span id="close-error" class="pl-error-close">&times;</span>
     85            </button>
     86        </div>
    7587    </div>
    7688</div>
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/ShippingMethod/Models/ShippingMethod.php

    r3048950 r3265740  
    4444        'fixedPrices',
    4545        'systemDefaults',
     46        'tags',
    4647    );
    4748    /**
     
    168169     */
    169170    public $systemDefaults;
     171
     172    /**
     173     * @var array
     174     */
     175    public $tags = array();
    170176
    171177    /**
     
    209215                $this->shippingServices[] = ShippingService::fromArray($service);
    210216            }
     217        }
     218
     219        if (isset($data['tags']) && is_array($data['tags'])) {
     220            $this->shippingCountries = $data['tags'];
     221        } else {
     222            $this->shippingCountries = array();
    211223        }
    212224    }
     
    312324
    313325    /**
     326     * @return array
     327     */
     328    public function getTags()
     329    {
     330        return $this->tags;
     331    }
     332
     333    /**
    314334     * Sets whether this shipping method is enabled for user.
    315335     *
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/ShippingMethod/ShippingMethodService.php

    r3048950 r3265740  
    122122     *
    123123     */
    124     public function add(ShippingServiceDetails $serviceDetails)
    125     {
    126         return $this->update($serviceDetails);
     124    public function add($serviceDetails, $isSpecialService = false)
     125    {
     126        return $this->update($serviceDetails, $isSpecialService);
    127127    }
    128128
     
    131131     *
    132132     * @param ShippingServiceDetails $serviceDetails
     133     * @param bool $isSpecialService
    133134     *
    134135     * @return ShippingMethod Created or updated shipping method.
    135136     */
    136     public function update(ShippingServiceDetails $serviceDetails)
    137     {
    138         $method = $this->getShippingMethodForService($serviceDetails);
     137    public function update(ShippingServiceDetails $serviceDetails, $isSpecialService = false)
     138    {
     139        $method = $this->getShippingMethodForService($serviceDetails, $isSpecialService);
    139140        if ($method === null) {
    140141            $method = new ShippingMethod();
    141142        }
    142143
    143         $this->setShippingMethodDetails($method, $serviceDetails);
     144        $this->setShippingMethodDetails($method, $serviceDetails, $isSpecialService);
    144145
    145146        $this->save($method);
     
    321322     * @return ShippingMethod|null Shipping method if found; otherwise, NULL.
    322323     */
    323     public function getShippingMethodForService($service)
     324    public function getShippingMethodForService($service, $isSpecialService = false)
    324325    {
    325326        $filter = new QueryFilter();
     
    329330                ->where('destinationDropOff', Operators::EQUALS, $service->destinationDropOff)
    330331                ->where('national', Operators::EQUALS, $service->national)
    331                 ->where('expressDelivery', Operators::EQUALS, $service->expressDelivery)
    332                 ->where('carrierName', Operators::EQUALS, $service->carrierName);
     332                ->where('expressDelivery', Operators::EQUALS, $service->expressDelivery);
     333
     334            if (!$isSpecialService) {
     335                $filter->where('carrierName', Operators::EQUALS, $service->carrierName);
     336            }
     337
     338            if($isSpecialService) {
     339                $filter->where('carrierName', Operators::EQUALS, $service->carrierName . ' ' . $service->serviceName);
     340            }
    333341        } catch (QueryFilterInvalidParamException $e) {
    334342            return null;
     
    541549    protected function setShippingMethodDetails(
    542550        ShippingMethod $shippingMethod,
    543         ShippingServiceDetails $serviceDetails
     551        ShippingServiceDetails $serviceDetails,
     552        $isSpecialService = false
    544553    ) {
    545         $shippingMethod->setCarrierName($serviceDetails->carrierName);
     554        if(!$isSpecialService) {
     555            $shippingMethod->setCarrierName($serviceDetails->carrierName);
     556        }
     557
     558        if($isSpecialService) {
     559            $shippingMethod->setCarrierName($serviceDetails->carrierName . ' ' . $serviceDetails->serviceName);
     560            $shippingMethod->tags = $serviceDetails->tags;
     561        }
     562
    546563        $shippingMethod->setDepartureDropOff($serviceDetails->departureDropOff);
    547564        $shippingMethod->setDestinationDropOff($serviceDetails->destinationDropOff);
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/BusinessLogic/Tasks/UpdateShippingServicesTask.php

    r3048950 r3265740  
    2323class UpdateShippingServicesTask extends Task
    2424{
     25    const SPECIAL_SERVICE_TAG = 'EXCLUSIVE_FOR_PLUS';
     26
    2527    /**
    2628     * @var WarehouseCountryService
     
    8082        if ($this->shouldExecute()) {
    8183            $apiServices = $this->getRemoteServices();
     84            $apiSpecialServices = $this->getSpecialServices($apiServices);
     85
    8286            $currentMethods = $this->getShippingMethodService()->getAllMethods();
     87            $currentSpecialMethods = $this->getSpecialServices($currentMethods);
    8388
    8489            $this->reportProgress(20);
    8590            $this->syncServices($currentMethods, $apiServices);
     91            $this->syncServicesSpecial($currentSpecialMethods, $apiSpecialServices);
    8692        }
    8793
     
    112118
    113119        $supportedCountries = $this->getCountryService()->getSupportedCountries();
    114         $sourceCountry = $supportedCountries[$sourceCountryCode];
     120        $sourceCountry = array_key_exists($sourceCountryCode, $supportedCountries) ? $supportedCountries[$sourceCountryCode] : null;
     121        if (!$sourceCountry) {
     122            return array();
     123        }
    115124
    116125        $parcel = $config->getDefaultParcel() ?: ParcelInfo::defaultParcel();
     
    163172    {
    164173        $progress = 20;
    165         $progressStep = count($currentMethods) > 0 ? (60 / count($currentMethods)) : 60;
     174        $progressStep = count($currentMethods) > 0 ? (40 / count($currentMethods)) : 40;
    166175
    167176        foreach ($currentMethods as $shippingMethod) {
     
    172181        }
    173182       
     183        $this->reportProgress(60);
     184        $batch = 0;
     185        foreach ($apiServices as $service) {
     186            $batch++;
     187            if ($batch === 20) {
     188                $this->reportAlive();
     189                $batch = 0;
     190            }
     191            $this->getShippingMethodService()->add($service);
     192        }
     193    }
     194
     195    /**
     196     * Creates, updates or deletes local shipping methods based on state on Packlink API.
     197     *
     198     * @param array $currentMethods Current shipping methods in shop.
     199     * @param array $apiServices Services retrieved from API.
     200     */
     201    protected function syncServicesSpecial(array $currentMethods, array $apiServices)
     202    {
     203        $progress = 60;
     204        $progressStep = count($currentMethods) > 0 ? (20 / count($currentMethods)) : 20;
     205
     206        foreach ($currentMethods as $shippingMethod) {
     207            $this->updateShippingMethod($shippingMethod, $apiServices, true);
     208
     209            $progress += $progressStep;
     210            $this->reportProgress($progress);
     211        }
     212
    174213        $this->reportProgress(80);
    175214        $batch = 0;
     
    180219                $batch = 0;
    181220            }
    182             $this->getShippingMethodService()->add($service);
     221            $this->getShippingMethodService()->add($service, true);
    183222        }
    184223    }
     
    190229     * @param ShippingServiceDetails[] $apiServices Shipping services returned from API.
    191230     */
    192     protected function updateShippingMethod(ShippingMethod $shippingMethod, array &$apiServices)
     231    protected function updateShippingMethod(ShippingMethod $shippingMethod, array &$apiServices, $special = false)
    193232    {
    194233        $shippingServices = array();
    195234        foreach ($apiServices as $service) {
    196             if ($this->serviceBelongsToMethod($service, $shippingMethod)) {
     235            if ($this->serviceBelongsToMethod($service, $shippingMethod, $special)) {
    197236                $shippingServices[] = ShippingService::fromServiceDetails($service);
    198237            }
     
    215254
    216255    /**
     256     * Returns all special services from an API, and removes it from an array
     257     *
     258     * @param array $apiServices
     259     *
     260     * @return array
     261     */
     262    protected function getSpecialServices(array &$apiServices)
     263    {
     264        $specialServices = array();
     265
     266        foreach ($apiServices as $key => $service) {
     267            if (in_array(array('id' => self::SPECIAL_SERVICE_TAG), $service->tags, true)) {
     268                $specialServices[] = $service;
     269                unset($apiServices[$key]);
     270            }
     271        }
     272
     273        return $specialServices;
     274    }
     275
     276    /**
    217277     * Checks if task should be executed.
    218278     *
     
    271331     * @return bool TRUE if given shipping service belongs to given shipping method; otherwise, FALSE.
    272332     */
    273     protected function serviceBelongsToMethod(ShippingServiceDetails $service, ShippingMethod $shippingMethod)
    274     {
    275         return $service->carrierName === $shippingMethod->getCarrierName()
     333    protected function serviceBelongsToMethod(ShippingServiceDetails $service, ShippingMethod $shippingMethod, $special = false)
     334    {
     335        $carrierName = $special ? $service->carrierName . ' ' . $service->serviceName : $service->carrierName;
     336
     337        return $carrierName === $shippingMethod->getCarrierName()
    276338            && $service->national === $shippingMethod->isNational()
    277339            && $service->expressDelivery === $shippingMethod->isExpressDelivery()
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/DemoUI/src/Views/ACME/index.php

    r3118361 r3265740  
    226226                    disableCarriersUrl: "<?php getUrl('ShippingMethods', 'deactivate') ?>",
    227227                    getCurrencyDetailsUrl: "<?php getUrl('SystemInfo', 'get') ?>",
    228                     systemId: null
     228                    systemId: null,
     229                    enqueue: "<?php getUrl('ManualRefresh', 'enqueueUpdateTask'); ?>",
     230                    getTaskStatus: "<?php getUrl('ManualRefresh', 'getTaskStatus'); ?>"
    229231                },
    230232                'edit-service': {
  • packlink-pro-shipping/trunk/vendor/packlink/integration-core/src/DemoUI/src/Views/PRO/index.php

    r3118361 r3265740  
    227227                    disableCarriersUrl: "<?php getUrl('ShippingMethods', 'deactivate') ?>",
    228228                    getCurrencyDetailsUrl: "<?php getUrl('SystemInfo', 'get') ?>",
    229                     systemId: null
     229                    systemId: null,
     230                    enqueue: "<?php getUrl('ManualRefresh', 'enqueueUpdateTask'); ?>",
     231                    getTaskStatus: "<?php getUrl('ManualRefresh', 'getTaskStatus'); ?>"
    230232                },
    231233                'edit-service': {
Note: See TracChangeset for help on using the changeset viewer.