Plugin Directory

Changeset 3262118


Ignore:
Timestamp:
03/26/2025 10:59:46 AM (12 months ago)
Author:
cdekit
Message:

v4.1.6-rc

Location:
cdekdelivery/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • cdekdelivery/trunk/README.md

    r3246409 r3262118  
    7575* WP-163 Fix error if no shipping methods found
    7676* WP-159 Fix error for paid on delivery with zero price
     77* WP-156 Restore plugin settings on delivery zone page
     78* WP-159 Fix missing delivery invoice information on order page
    7779
    7880= 4.0 =
  • cdekdelivery/trunk/lang/cdekdelivery.pot

    r3246394 r3262118  
    1010"X-Generator: GlotPress/4.0.1\n"
    1111"Language: ru\n"
    12 "Project-Id-Version: CDEKDelivery 4.1.3"
     12"Project-Id-Version: CDEKDelivery 4.1.6"
    1313
    1414#. translators: 1: attempt number
  • cdekdelivery/trunk/src/Actions/GenerateBarcodeAction.php

    r3213294 r3262118  
    2525         * @throws \Cdek\Exceptions\External\ApiException
    2626         */
    27         public function __invoke(string $uuid): array
     27        public function __invoke(string $cdekNumber): array
    2828        {
    2929            $api = new CdekApi;
     
    3737
    3838            try {
    39                 $order = $api->orderGet($uuid);
     39                $order = $api->orderGetByNumber($cdekNumber);
    4040            } catch (HttpClientException $e) {
    4141                return [
     
    6161            foreach ($order->related() as $entity) {
    6262                if ($entity['type'] === 'barcode' && isset($entity['url'])) {
    63                     $barcodeInfo = $api->barcodeGet($entity['uuid']);
     63                    $barcodeInfo = $api->barcodeGet($cdekNumber);
    6464
    6565                    if ($barcodeInfo['format'] !==
     
    7676
    7777            try {
    78                 $barcode = $api->barcodeCreate($order->entity()['uuid']);
     78                $barcode = $api->barcodeCreate($cdekNumber);
    7979
    8080                if ($barcode === null) {
  • cdekdelivery/trunk/src/Actions/GenerateWaybillAction.php

    r3213294 r3262118  
    2222         * @throws \Cdek\Exceptions\External\ApiException
    2323         */
    24         public function __invoke(string $orderUuid): array
     24        public function __invoke(string $cdekNumber): array
    2525        {
    2626            $api = new CdekApi;
     
    3333            );
    3434
    35             $order = $api->orderGet($orderUuid);
     35            $order = $api->orderGetByNumber($cdekNumber);
    3636
    3737            if ($order->entity() === null) {
     
    5454            }
    5555
    56             $waybill = $api->waybillCreate($order->entity()['uuid']);
     56            $waybill = $api->waybillCreate($cdekNumber);
    5757
    5858            if ($waybill === null) {
  • cdekdelivery/trunk/src/Actions/OrderCreateAction.php

    r3246394 r3262118  
    7171                $existingOrder = $coreApi->orderGet($orderId);
    7272
    73                 $this->order->uuid   = $existingOrder['uuid'];
    7473                $this->order->number = $existingOrder['track'];
    7574                $this->order->save();
     
    156155
    157156            $this->order->number = $track;
    158             $this->order->uuid   = $uuid;
    159157            $this->order->save();
    160158
  • cdekdelivery/trunk/src/Actions/OrderDeleteAction.php

    r3234614 r3262118  
    3838            $order       = new Order($orderId);
    3939            $orderNumber = $order->number;
    40             $orderUuid   = $order->uuid;
    4140
    4241            $order->clean();
    4342
    4443            try {
    45                 $this->api->orderGet($orderUuid);
     44                $orderUuid = $this->api->orderGetByNumber($orderNumber)->entity()['uuid'];
    4645            } catch (InvalidRequestException $e) {
    4746                Note::send(
  • cdekdelivery/trunk/src/Blocks/AdminOrderBox.php

    r3209056 r3262118  
    4141            include Loader::getTemplate('common');
    4242
    43             if ($order->uuid === null) {
     43            if ($order->number === null) {
    4444                include Loader::getTemplate(
    4545                    $shipping->getMethod()->has_packages_mode ? 'create_many' : 'create',
  • cdekdelivery/trunk/src/CdekApi.php

    r3234614 r3262118  
    101101                );
    102102            }
    103         }
    104 
    105         /**
    106          * @throws LegacyAuthException
    107          * @throws ApiException
    108          */
    109         public function barcodeCreate(string $orderUuid): ?string
    110         {
    111             return HttpClient::sendJsonRequest(
    112                 "{$this->apiUrl}print/barcodes/",
    113                 'POST',
    114                 $this->tokenStorage->getToken(),
    115                 [
    116                     'orders' => ['order_uuid' => $orderUuid],
    117                     'format' => BarcodeFormat::getByIndex(
    118                         (int)$this->deliveryMethod->get_option(
    119                             'barcode_format',
    120                             0,
    121                         ),
    122                     ),
    123                 ],
    124             )->entity()['uuid'] ?? null;
    125         }
    126 
    127         /**
    128          * @throws LegacyAuthException
    129          * @throws ApiException
    130          */
    131         public function barcodeGet(string $uuid): ?array
    132         {
    133             return HttpClient::sendJsonRequest(
    134                 "{$this->apiUrl}print/barcodes/$uuid",
    135                 'GET',
    136                 $this->tokenStorage->getToken(),
    137             )->entity();
    138103        }
    139104
     
    421386         * @throws LegacyAuthException
    422387         */
    423         public function waybillCreate(string $orderUuid): ?string
     388        public function orderGetByNumber(string $cdekNumber): HttpResponse
     389        {
     390            return HttpClient::sendJsonRequest(
     391                "{$this->apiUrl}orders?" . http_build_query(["cdek_number" => $cdekNumber]),
     392                'GET',
     393                $this->tokenStorage->getToken(),
     394            );
     395        }
     396
     397        /**
     398         * @throws ApiException
     399         * @throws LegacyAuthException
     400         */
     401        public function waybillCreate(string $cdekNumber): ?string
    424402        {
    425403            return HttpClient::sendJsonRequest(
     
    427405                'POST',
    428406                $this->tokenStorage->getToken(),
    429                 ['orders' => ['order_uuid' => $orderUuid]],
     407                ['orders' => ['cdek_number' => $cdekNumber]],
    430408            )->entity()['uuid'] ?? null;
     409        }
     410
     411        /**
     412         * @throws LegacyAuthException
     413         * @throws ApiException
     414         */
     415        public function barcodeCreate(string $cdekNumber): ?string
     416        {
     417            return HttpClient::sendJsonRequest(
     418                "{$this->apiUrl}print/barcodes",
     419                'POST',
     420                $this->tokenStorage->getToken(),
     421                [
     422                    'orders' => ['cdek_number' => $cdekNumber],
     423                    'format' => BarcodeFormat::getByIndex(
     424                        (int)$this->deliveryMethod->get_option(
     425                            'barcode_format',
     426                            0,
     427                        ),
     428                    ),
     429                ],
     430            )->entity()['uuid'] ?? null;
     431        }
     432
     433        /**
     434         * @throws LegacyAuthException
     435         * @throws ApiException
     436         */
     437        public function barcodeGet(string $uuid): ?array
     438        {
     439            return HttpClient::sendJsonRequest(
     440                "{$this->apiUrl}print/barcodes/$uuid",
     441                'GET',
     442                $this->tokenStorage->getToken(),
     443            )->entity();
    431444        }
    432445
  • cdekdelivery/trunk/src/Controllers/OrderController.php

    r3209056 r3262118  
    3737
    3838            /** @noinspection GlobalVariableUsageInspection */
    39             $result = GenerateBarcodeAction::new()((new Order((int)wp_unslash($_GET['id'])))->uuid);
     39            $result = GenerateBarcodeAction::new()((new Order((int)wp_unslash($_GET['id'])))->number);
    4040
    4141            if ($result['success']) {
     
    207207            try {
    208208                /** @noinspection GlobalVariableUsageInspection */
    209                 $result = GenerateWaybillAction::new()((new Order((int)wp_unslash($_GET['id'])))->uuid);
     209                $result = GenerateWaybillAction::new()((new Order((int)wp_unslash($_GET['id'])))->number);
    210210
    211211                if ($result['success']) {
  • cdekdelivery/trunk/src/Model/Order.php

    r3226728 r3262118  
    2121
    2222    /**
    23      * @property string|null $uuid
    2423     * @property string|null $number
    2524     *
     
    124123        {
    125124            unset(
     125                //legacy uuid is clean too
    126126                $this->meta['number'], $this->meta['uuid'], $this->meta['order_uuid'], $this->meta['order_number'], $this->meta['cdek_order_uuid'], $this->meta['cdek_order_waybill'],
    127127            );
     
    203203        final public function loadLegacyStatuses(?array $statuses = null): array
    204204        {
    205             if (empty($this->uuid)) {
     205            if (empty($this->number)) {
    206206                return [];
    207207            }
    208208
    209209            if ($statuses === null) {
    210                 $orderInfo = (new CdekApi)->orderGet($this->uuid);
     210                $orderInfo = (new CdekApi)->orderGetByNumber($this->number);
    211211                if ($orderInfo->entity() === null) {
    212212                    throw new OrderNotFoundException;
     
    214214
    215215                $statuses = $orderInfo->entity()['statuses'];
    216 
    217                 if (empty($this->number)) {
    218                     $this->number = $orderInfo->entity()['cdek_number'];
    219                     $this->save();
    220                 }
    221216            }
    222217
  • cdekdelivery/trunk/src/UI/Admin.php

    r3209056 r3262118  
    1414    use Cdek\Loader;
    1515    use Cdek\Traits\CanBeCreated;
    16     use WC_Admin_Settings;
     16    use WC_Shipping_Zones;
    1717
    1818    class Admin
     
    5959            global $current_section, $current_tab;
    6060
    61             // Not on Settings page.
    62             if($current_section !== Config::DELIVERY_NAME || $current_tab !== 'shipping') {
     61            // Is not shipping settings page.
     62            if ($current_tab !== 'shipping') {
    6363                return;
     64            }
     65
     66            if ($current_section !== Config::DELIVERY_NAME) {
     67                $shippingMethodCurrent = WC_Shipping_Zones::get_shipping_method(absint(wp_unslash($_REQUEST['instance_id'])));
     68
     69                // Is not CDEK shipping page
     70                if ($shippingMethodCurrent === false || $shippingMethodCurrent->id !== Config::DELIVERY_NAME) {
     71                    return;
     72                }
    6473            }
    6574
  • cdekdelivery/trunk/templates/processing.php

    r3209056 r3262118  
    2323<div>
    2424    <p><?php esc_html_e('Waybill', 'cdekdelivery') ?> <b>
    25             <?php echo esc_html($order->uuid) ?></b></p>
     25            <?php echo esc_html($order->number) ?></b></p>
    2626</div>
    2727
Note: See TracChangeset for help on using the changeset viewer.