Skip to content

Commit

Permalink
Merge branch 'CMS-912' into 'main'
Browse files Browse the repository at this point in the history
Resolve CMS-912

Closes CMS-912

See merge request ecommerce_modules/wordpress/plugin!5
  • Loading branch information
vermorag committed May 15, 2024
2 parents a3fcd72 + 96cd591 commit d84159a
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 214 deletions.
52 changes: 44 additions & 8 deletions lang/cdekdelivery-ru_RU.po
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,33 @@ msgstr "Ошибка автоматизации заказа: %s"
msgid "Order automation failed with error"
msgstr "Ошибка автоматизации заказа"

#: src/Checkout/InternationalOrderFields.php:18 src/CdekShippingMethod.php.php:159
#: src/Checkout/InternationalOrderFields.php:20
#: src/CdekShippingMethod.php.php:159
msgid "Passport Series"
msgstr "Серия паспорта"

#: src/Checkout/InternationalOrderFields.php:25 src/CdekShippingMethod.php.php:163
#: src/Checkout/InternationalOrderFields.php:29
#: src/CdekShippingMethod.php.php:163
msgid "Passport number"
msgstr "Номер паспорта"

#: src/Checkout/InternationalOrderFields.php:33 src/CdekShippingMethod.php.php:170
#: src/Checkout/InternationalOrderFields.php:39
#: src/CdekShippingMethod.php.php:170
msgid "Passport date of issue"
msgstr "Дата выдачи паспорта"

#: src/Checkout/InternationalOrderFields.php:37 src/CdekShippingMethod.php.php:170
#: src/Checkout/InternationalOrderFields.php:45
#: src/CdekShippingMethod.php.php:170
msgid "Passport organization"
msgstr "Орган выдачи паспорта"

#: src/Checkout/InternationalOrderFields.php:41 src/CdekShippingMethod.php.php:170
#: src/Checkout/InternationalOrderFields.php:51
#: src/CdekShippingMethod.php.php:170
msgid "TIN"
msgstr "ИНН"

#: src/Checkout/InternationalOrderFields.php:49 src/CdekShippingMethod.php.php:170
#: src/Checkout/InternationalOrderFields.php:61
#: src/CdekShippingMethod.php.php:170
msgid "Birthday"
msgstr "Дата рождения"

Expand Down Expand Up @@ -115,14 +121,43 @@ msgstr "Правила для доставки курьером"
msgid "Rules for delivery to pick-up"
msgstr "Правила для доставки до ПВЗ/Постаматов"

#: src/CdekShippingMethod:18 src/CdekShippingMethod:31
#: src/CdekShippingMethod:18
#: src/CdekShippingMethod:31
msgid "Cdek Shipping"
msgstr "Доставка СДЭК"

#: src/CdekShippingMethod:19
msgid "Official Shipping Method for Cdek"
msgstr "Официальный метод доставки компанией СДЭК"

#: src/Fieldsets/GeneralOrderFields.php:20
msgid "Street address"
msgstr "Адрес"

#: src/Fieldsets/GeneralOrderFields.php:21
msgid "House number and street name"
msgstr "Улица и номер дома"

#: src/Fieldsets/GeneralOrderFields.php:28
msgid "Apartment, suite, unit, etc."
msgstr "Квартира, корпус, строение и тп."

#: src/Fieldsets/GeneralOrderFields.php:30
msgid "Apartment, suite, unit, etc. (optional)"
msgstr "Квартира, корпус, строение и тп. (опционально)"

#: src/Fieldsets/GeneralOrderFields.php:37
msgid "Phone"
msgstr "Телефон"

#: src/Fieldsets/GeneralOrderFields.php:46
msgid "Town / City"
msgstr "Город"

#: src/Fieldsets/GeneralOrderFields.php:53
msgid "First name"
msgstr "Имя"

#: src/Actions/GenerateBarcodeAction.php:35
msgid ""
"Failed to retrieve order information.\n"
Expand Down Expand Up @@ -281,7 +316,8 @@ msgstr ""
"При включенном режиме международных заказов, на странице чекаута появятся дополнительные поля:\n"
"\r серия паспорта, номер паспорта, дата выдачи, отдел, ИНН, дата рождения."

#: src/CdekShippingMethod.php.php:140 src/CdekShippingMethod.php.php:147
#: src/CdekShippingMethod.php.php:140
#: src/CdekShippingMethod.php.php:147
msgid "True seller address"
msgstr "Адрес истинного продавца"

Expand Down
40 changes: 34 additions & 6 deletions lang/cdekdelivery.pot
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ msgstr ""
msgid "Order automation failed with error"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:18
#: src/Fieldsets/InternationalOrderFields.php:20
msgid "Passport Series"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:25
#: src/Fieldsets/InternationalOrderFields.php:29
msgid "Passport number"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:33
#: src/Fieldsets/InternationalOrderFields.php:39
msgid "Passport date of issue"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:37
#: src/Fieldsets/InternationalOrderFields.php:45
msgid "Passport organization"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:41
#: src/Fieldsets/InternationalOrderFields.php:51
msgid "TIN"
msgstr ""

#: src/Checkout/InternationalOrderFields.php:49
#: src/Fieldsets/InternationalOrderFields.php:61
msgid "Birthday"
msgstr ""

Expand Down Expand Up @@ -122,6 +122,34 @@ msgstr ""
msgid "Official Shipping Method for Cdek"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:20
msgid "Street address"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:21
msgid "House number and street name"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:28
msgid "Apartment, suite, unit, etc."
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:30
msgid "Apartment, suite, unit, etc. (optional)"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:37
msgid "Phone"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:46
msgid "Town / City"
msgstr ""

#: src/Fieldsets/GeneralOrderFields.php:53
msgid "First name"
msgstr ""

#: src/Actions/GenerateBarcodeAction.php:35
msgid ""
"Failed to retrieve order information.\n"
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
"prettier": "^3.2.5",
"webpack": "^5.91.0"
},
"packageManager": "yarn@4.2.1"
"volta": {
"node": "21.7.3",
"yarn": "4.2.2"
}
}
6 changes: 3 additions & 3 deletions src/CdekApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cdek;

use Cdek\Contracts\TokenStorage;
use Cdek\Contracts\TokenStorageContract;
use Cdek\Enums\BarcodeFormat;
use Cdek\Exceptions\CdekApiException;
use Cdek\Exceptions\RestApiInvalidRequestException;
Expand All @@ -28,10 +28,10 @@ class CdekApi
private string $clientSecret;
private WC_Shipping_Method $deliveryMethod;

private TokenStorage $tokenStorage;
private TokenStorageContract $tokenStorage;


public function __construct(?int $shippingInstanceId = null, ?TokenStorage $tokenStorage = null)
public function __construct(?int $shippingInstanceId = null, ?TokenStorageContract $tokenStorage = null)
{
$this->deliveryMethod = Helper::getActualShippingMethod($shippingInstanceId);
$this->apiUrl = $this->getApiUrl();
Expand Down
26 changes: 0 additions & 26 deletions src/Checkout/GeneralOrderFields.php

This file was deleted.

86 changes: 0 additions & 86 deletions src/Checkout/InternationalOrderFields.php

This file was deleted.

30 changes: 0 additions & 30 deletions src/Checkout/VirtualOrderFields.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Contracts/FieldConstructorInterface.php

This file was deleted.

39 changes: 39 additions & 0 deletions src/Contracts/FieldsetContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Cdek\Contracts;

use InvalidArgumentException;

abstract class FieldsetContract
{
protected const FIELDS = [];

final public function getFieldsNames(): array
{
return array_keys($this->getFields());
}

abstract protected function getFields(): array;

final public function isRequiredField(string $fieldName): bool
{
$fieldList = $this->getFields();
if (!isset($fieldList[$fieldName])) {
throw new InvalidArgumentException('Field not found');
}

return $fieldList[$fieldName]['required'] ?? false;
}

abstract public function isApplicable(): bool;

final public function getFieldDefinition(string $fieldName): array
{
$fieldList = $this->getFields();
if (!isset($fieldList[$fieldName])) {
throw new InvalidArgumentException('Field not found');
}

return $fieldList[$fieldName];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cdek\Contracts;

abstract class TokenStorage
abstract class TokenStorageContract
{
private const CIPHER = 'AES-256-CBC';

Expand Down
Loading

0 comments on commit d84159a

Please sign in to comment.