Changeset 3262118
- Timestamp:
- 03/26/2025 10:59:46 AM (12 months ago)
- Location:
- cdekdelivery/trunk
- Files:
-
- 12 edited
-
README.md (modified) (1 diff)
-
lang/cdekdelivery.pot (modified) (1 diff)
-
src/Actions/GenerateBarcodeAction.php (modified) (4 diffs)
-
src/Actions/GenerateWaybillAction.php (modified) (3 diffs)
-
src/Actions/OrderCreateAction.php (modified) (2 diffs)
-
src/Actions/OrderDeleteAction.php (modified) (1 diff)
-
src/Blocks/AdminOrderBox.php (modified) (1 diff)
-
src/CdekApi.php (modified) (3 diffs)
-
src/Controllers/OrderController.php (modified) (2 diffs)
-
src/Model/Order.php (modified) (4 diffs)
-
src/UI/Admin.php (modified) (2 diffs)
-
templates/processing.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cdekdelivery/trunk/README.md
r3246409 r3262118 75 75 * WP-163 Fix error if no shipping methods found 76 76 * 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 77 79 78 80 = 4.0 = -
cdekdelivery/trunk/lang/cdekdelivery.pot
r3246394 r3262118 10 10 "X-Generator: GlotPress/4.0.1\n" 11 11 "Language: ru\n" 12 "Project-Id-Version: CDEKDelivery 4.1. 3"12 "Project-Id-Version: CDEKDelivery 4.1.6" 13 13 14 14 #. translators: 1: attempt number -
cdekdelivery/trunk/src/Actions/GenerateBarcodeAction.php
r3213294 r3262118 25 25 * @throws \Cdek\Exceptions\External\ApiException 26 26 */ 27 public function __invoke(string $ uuid): array27 public function __invoke(string $cdekNumber): array 28 28 { 29 29 $api = new CdekApi; … … 37 37 38 38 try { 39 $order = $api->orderGet ($uuid);39 $order = $api->orderGetByNumber($cdekNumber); 40 40 } catch (HttpClientException $e) { 41 41 return [ … … 61 61 foreach ($order->related() as $entity) { 62 62 if ($entity['type'] === 'barcode' && isset($entity['url'])) { 63 $barcodeInfo = $api->barcodeGet($ entity['uuid']);63 $barcodeInfo = $api->barcodeGet($cdekNumber); 64 64 65 65 if ($barcodeInfo['format'] !== … … 76 76 77 77 try { 78 $barcode = $api->barcodeCreate($ order->entity()['uuid']);78 $barcode = $api->barcodeCreate($cdekNumber); 79 79 80 80 if ($barcode === null) { -
cdekdelivery/trunk/src/Actions/GenerateWaybillAction.php
r3213294 r3262118 22 22 * @throws \Cdek\Exceptions\External\ApiException 23 23 */ 24 public function __invoke(string $ orderUuid): array24 public function __invoke(string $cdekNumber): array 25 25 { 26 26 $api = new CdekApi; … … 33 33 ); 34 34 35 $order = $api->orderGet ($orderUuid);35 $order = $api->orderGetByNumber($cdekNumber); 36 36 37 37 if ($order->entity() === null) { … … 54 54 } 55 55 56 $waybill = $api->waybillCreate($ order->entity()['uuid']);56 $waybill = $api->waybillCreate($cdekNumber); 57 57 58 58 if ($waybill === null) { -
cdekdelivery/trunk/src/Actions/OrderCreateAction.php
r3246394 r3262118 71 71 $existingOrder = $coreApi->orderGet($orderId); 72 72 73 $this->order->uuid = $existingOrder['uuid'];74 73 $this->order->number = $existingOrder['track']; 75 74 $this->order->save(); … … 156 155 157 156 $this->order->number = $track; 158 $this->order->uuid = $uuid;159 157 $this->order->save(); 160 158 -
cdekdelivery/trunk/src/Actions/OrderDeleteAction.php
r3234614 r3262118 38 38 $order = new Order($orderId); 39 39 $orderNumber = $order->number; 40 $orderUuid = $order->uuid;41 40 42 41 $order->clean(); 43 42 44 43 try { 45 $ this->api->orderGet($orderUuid);44 $orderUuid = $this->api->orderGetByNumber($orderNumber)->entity()['uuid']; 46 45 } catch (InvalidRequestException $e) { 47 46 Note::send( -
cdekdelivery/trunk/src/Blocks/AdminOrderBox.php
r3209056 r3262118 41 41 include Loader::getTemplate('common'); 42 42 43 if ($order-> uuid=== null) {43 if ($order->number === null) { 44 44 include Loader::getTemplate( 45 45 $shipping->getMethod()->has_packages_mode ? 'create_many' : 'create', -
cdekdelivery/trunk/src/CdekApi.php
r3234614 r3262118 101 101 ); 102 102 } 103 }104 105 /**106 * @throws LegacyAuthException107 * @throws ApiException108 */109 public function barcodeCreate(string $orderUuid): ?string110 {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 LegacyAuthException129 * @throws ApiException130 */131 public function barcodeGet(string $uuid): ?array132 {133 return HttpClient::sendJsonRequest(134 "{$this->apiUrl}print/barcodes/$uuid",135 'GET',136 $this->tokenStorage->getToken(),137 )->entity();138 103 } 139 104 … … 421 386 * @throws LegacyAuthException 422 387 */ 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 424 402 { 425 403 return HttpClient::sendJsonRequest( … … 427 405 'POST', 428 406 $this->tokenStorage->getToken(), 429 ['orders' => [' order_uuid' => $orderUuid]],407 ['orders' => ['cdek_number' => $cdekNumber]], 430 408 )->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(); 431 444 } 432 445 -
cdekdelivery/trunk/src/Controllers/OrderController.php
r3209056 r3262118 37 37 38 38 /** @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); 40 40 41 41 if ($result['success']) { … … 207 207 try { 208 208 /** @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); 210 210 211 211 if ($result['success']) { -
cdekdelivery/trunk/src/Model/Order.php
r3226728 r3262118 21 21 22 22 /** 23 * @property string|null $uuid24 23 * @property string|null $number 25 24 * … … 124 123 { 125 124 unset( 125 //legacy uuid is clean too 126 126 $this->meta['number'], $this->meta['uuid'], $this->meta['order_uuid'], $this->meta['order_number'], $this->meta['cdek_order_uuid'], $this->meta['cdek_order_waybill'], 127 127 ); … … 203 203 final public function loadLegacyStatuses(?array $statuses = null): array 204 204 { 205 if (empty($this-> uuid)) {205 if (empty($this->number)) { 206 206 return []; 207 207 } 208 208 209 209 if ($statuses === null) { 210 $orderInfo = (new CdekApi)->orderGet ($this->uuid);210 $orderInfo = (new CdekApi)->orderGetByNumber($this->number); 211 211 if ($orderInfo->entity() === null) { 212 212 throw new OrderNotFoundException; … … 214 214 215 215 $statuses = $orderInfo->entity()['statuses']; 216 217 if (empty($this->number)) {218 $this->number = $orderInfo->entity()['cdek_number'];219 $this->save();220 }221 216 } 222 217 -
cdekdelivery/trunk/src/UI/Admin.php
r3209056 r3262118 14 14 use Cdek\Loader; 15 15 use Cdek\Traits\CanBeCreated; 16 use WC_ Admin_Settings;16 use WC_Shipping_Zones; 17 17 18 18 class Admin … … 59 59 global $current_section, $current_tab; 60 60 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') { 63 63 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 } 64 73 } 65 74 -
cdekdelivery/trunk/templates/processing.php
r3209056 r3262118 23 23 <div> 24 24 <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> 26 26 </div> 27 27
Note: See TracChangeset
for help on using the changeset viewer.