From 26e134ab07bc11e16f63f74749e0f9b43fb50c7c Mon Sep 17 00:00:00 2001 From: mandan2 <61560082+mandan2@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:17:50 +0300 Subject: [PATCH] PIPRES-261: Minor improvements (#820) * PIPRES-261: Get carrier price to create subscription * renamed some services and added additional conditions for carrier retrieve * PIPRES-261: Minor improvements --- src/Builder/FormBuilder.php | 10 +++--- .../CouldNotCreateOrderPaymentFee.php | 2 +- src/Exception/CouldNotInstallModule.php | 2 +- src/Exception/CouldNotUpdateOrderTotals.php | 2 +- .../CouldNotHandleOrderPaymentFee.php | 8 ++--- .../CouldNotHandleRecurringOrder.php | 4 +-- .../Exception/CouldNotPresentOrderDetail.php | 8 ++--- ...rovideSubscriptionCarrierDeliveryPrice.php | 14 ++++---- .../Handler/RecurringOrderHandler.php | 6 ++-- .../Subscription/subscriptions-faq.html.twig | 36 +++++++++---------- .../customerRecurringOrderDetailProduct.tpl | 18 +++++----- 11 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 5f77b946b..111c9f83f 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -845,12 +845,10 @@ private function getShippingOptions(string $tab): array ]; foreach ($carriers as $carrier) { - $mappedCarrier = []; - - $mappedCarrier['id'] = $carrier->id; - $mappedCarrier['name'] = $carrier->name; - - $mappedCarriers[] = $mappedCarrier; + $mappedCarriers[] = [ + 'id' => $carrier->id, + 'name' => $carrier->name, + ]; } $header = [ diff --git a/src/Exception/CouldNotCreateOrderPaymentFee.php b/src/Exception/CouldNotCreateOrderPaymentFee.php index dd7919550..0ac620f71 100644 --- a/src/Exception/CouldNotCreateOrderPaymentFee.php +++ b/src/Exception/CouldNotCreateOrderPaymentFee.php @@ -7,7 +7,7 @@ class CouldNotCreateOrderPaymentFee extends MollieException { - public static function failedToInsertOrderPaymentFee(Exception $exception): CouldNotCreateOrderPaymentFee + public static function failedToInsertOrderPaymentFee(Exception $exception): self { return new self( 'Failed to insert order payment fee.', diff --git a/src/Exception/CouldNotInstallModule.php b/src/Exception/CouldNotInstallModule.php index 9ff488ae8..c9fd4b06c 100644 --- a/src/Exception/CouldNotInstallModule.php +++ b/src/Exception/CouldNotInstallModule.php @@ -6,7 +6,7 @@ class CouldNotInstallModule extends MollieException { - public static function failedToInstallOrderState(string $orderStateName, \Exception $exception): CouldNotInstallModule + public static function failedToInstallOrderState(string $orderStateName, \Exception $exception): self { return new self( sprintf('Failed to install order state (%s).', $orderStateName), diff --git a/src/Exception/CouldNotUpdateOrderTotals.php b/src/Exception/CouldNotUpdateOrderTotals.php index 6c8625bbc..69bda3404 100644 --- a/src/Exception/CouldNotUpdateOrderTotals.php +++ b/src/Exception/CouldNotUpdateOrderTotals.php @@ -7,7 +7,7 @@ class CouldNotUpdateOrderTotals extends MollieException { - public static function failedToUpdateOrderTotals(Exception $exception): CouldNotUpdateOrderTotals + public static function failedToUpdateOrderTotals(Exception $exception): self { return new self( 'Failed to update order totals.', diff --git a/src/Handler/Exception/CouldNotHandleOrderPaymentFee.php b/src/Handler/Exception/CouldNotHandleOrderPaymentFee.php index cab968358..077c1f55a 100644 --- a/src/Handler/Exception/CouldNotHandleOrderPaymentFee.php +++ b/src/Handler/Exception/CouldNotHandleOrderPaymentFee.php @@ -8,7 +8,7 @@ class CouldNotHandleOrderPaymentFee extends MollieException { - public static function failedToRetrievePaymentMethod(Throwable $exception): CouldNotHandleOrderPaymentFee + public static function failedToRetrievePaymentMethod(Throwable $exception): self { return new self( 'Failed to retrieve payment method', @@ -17,7 +17,7 @@ public static function failedToRetrievePaymentMethod(Throwable $exception): Coul ); } - public static function failedToRetrievePaymentFee(Throwable $exception): CouldNotHandleOrderPaymentFee + public static function failedToRetrievePaymentFee(Throwable $exception): self { return new self( 'Failed to retrieve payment fee', @@ -26,7 +26,7 @@ public static function failedToRetrievePaymentFee(Throwable $exception): CouldNo ); } - public static function failedToCreateOrderPaymentFee(Throwable $exception): CouldNotHandleOrderPaymentFee + public static function failedToCreateOrderPaymentFee(Throwable $exception): self { return new self( 'Failed to create order payment fee', @@ -35,7 +35,7 @@ public static function failedToCreateOrderPaymentFee(Throwable $exception): Coul ); } - public static function failedToUpdateOrderTotalWithPaymentFee(Throwable $exception): CouldNotHandleOrderPaymentFee + public static function failedToUpdateOrderTotalWithPaymentFee(Throwable $exception): self { return new self( 'Failed to update order total with payment fee.', diff --git a/subscription/Exception/CouldNotHandleRecurringOrder.php b/subscription/Exception/CouldNotHandleRecurringOrder.php index e1dbc95e1..88c00de19 100644 --- a/subscription/Exception/CouldNotHandleRecurringOrder.php +++ b/subscription/Exception/CouldNotHandleRecurringOrder.php @@ -4,7 +4,7 @@ class CouldNotHandleRecurringOrder extends MollieSubscriptionException { - public static function failedToFindSelectedCarrier(): CouldNotHandleRecurringOrder + public static function failedToFindSelectedCarrier(): self { return new self( 'Failed to find selected carrier', @@ -12,7 +12,7 @@ public static function failedToFindSelectedCarrier(): CouldNotHandleRecurringOrd ); } - public static function failedToApplySelectedCarrier(): CouldNotHandleRecurringOrder + public static function failedToApplySelectedCarrier(): self { return new self( 'Failed to apply selected carrier', diff --git a/subscription/Exception/CouldNotPresentOrderDetail.php b/subscription/Exception/CouldNotPresentOrderDetail.php index 2b07862b9..8ed1c4c34 100644 --- a/subscription/Exception/CouldNotPresentOrderDetail.php +++ b/subscription/Exception/CouldNotPresentOrderDetail.php @@ -4,7 +4,7 @@ class CouldNotPresentOrderDetail extends MollieSubscriptionException { - public static function failedToFindOrder(): CouldNotPresentOrderDetail + public static function failedToFindOrder(): self { return new self( 'Failed to find order', @@ -12,7 +12,7 @@ public static function failedToFindOrder(): CouldNotPresentOrderDetail ); } - public static function failedToFindOrderDetail(): CouldNotPresentOrderDetail + public static function failedToFindOrderDetail(): self { return new self( 'Failed to find order detail', @@ -20,7 +20,7 @@ public static function failedToFindOrderDetail(): CouldNotPresentOrderDetail ); } - public static function failedToFindProduct(): CouldNotPresentOrderDetail + public static function failedToFindProduct(): self { return new self( 'Failed to find product', @@ -28,7 +28,7 @@ public static function failedToFindProduct(): CouldNotPresentOrderDetail ); } - public static function failedToFindCurrency(): CouldNotPresentOrderDetail + public static function failedToFindCurrency(): self { return new self( 'Failed to find currency', diff --git a/subscription/Exception/CouldNotProvideSubscriptionCarrierDeliveryPrice.php b/subscription/Exception/CouldNotProvideSubscriptionCarrierDeliveryPrice.php index 6c9709b7f..9d2f5fafb 100644 --- a/subscription/Exception/CouldNotProvideSubscriptionCarrierDeliveryPrice.php +++ b/subscription/Exception/CouldNotProvideSubscriptionCarrierDeliveryPrice.php @@ -4,7 +4,7 @@ class CouldNotProvideSubscriptionCarrierDeliveryPrice extends MollieSubscriptionException { - public static function failedToFindSelectedCarrier(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToFindSelectedCarrier(): self { return new self( 'Failed to find selected carrier', @@ -12,7 +12,7 @@ public static function failedToFindSelectedCarrier(): CouldNotProvideSubscriptio ); } - public static function failedToFindOrderCart(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToFindOrderCart(): self { return new self( 'Failed to find order cart', @@ -20,7 +20,7 @@ public static function failedToFindOrderCart(): CouldNotProvideSubscriptionCarri ); } - public static function failedToFindOrderCustomer(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToFindOrderCustomer(): self { return new self( 'Failed to find order customer', @@ -28,7 +28,7 @@ public static function failedToFindOrderCustomer(): CouldNotProvideSubscriptionC ); } - public static function failedToApplySelectedCarrier(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToApplySelectedCarrier(): self { return new self( 'Failed to apply selected carrier', @@ -36,7 +36,7 @@ public static function failedToApplySelectedCarrier(): CouldNotProvideSubscripti ); } - public static function failedToFindOrderDeliveryAddress(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToFindOrderDeliveryAddress(): self { return new self( 'Failed to find order delivery address', @@ -44,7 +44,7 @@ public static function failedToFindOrderDeliveryAddress(): CouldNotProvideSubscr ); } - public static function failedToFindOrderDeliveryCountry(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToFindOrderDeliveryCountry(): self { return new self( 'Failed to find order delivery country', @@ -52,7 +52,7 @@ public static function failedToFindOrderDeliveryCountry(): CouldNotProvideSubscr ); } - public static function failedToGetSelectedCarrierPrice(): CouldNotProvideSubscriptionCarrierDeliveryPrice + public static function failedToGetSelectedCarrierPrice(): self { return new self( 'Failed to get selected carrier price', diff --git a/subscription/Handler/RecurringOrderHandler.php b/subscription/Handler/RecurringOrderHandler.php index 60d919792..c7cfb4b0e 100644 --- a/subscription/Handler/RecurringOrderHandler.php +++ b/subscription/Handler/RecurringOrderHandler.php @@ -203,9 +203,9 @@ private function createSubscription(Payment $transaction, MolRecurringOrder $rec $newCart->update(); - if (sprintf('%d,', (int) $carrier->id) !== - $newCart->getDeliveryOption(null, false, false)[$newCart->id_address_delivery] - ) { + $cartCarrier = (int) ($newCart->getDeliveryOption(null, false, false)[$newCart->id_address_delivery] ?? 0); + + if ((int) $carrier->id !== $cartCarrier) { throw CouldNotHandleRecurringOrder::failedToApplySelectedCarrier(); } diff --git a/views/templates/admin/Subscription/subscriptions-faq.html.twig b/views/templates/admin/Subscription/subscriptions-faq.html.twig index 07bcc9659..45db6380e 100644 --- a/views/templates/admin/Subscription/subscriptions-faq.html.twig +++ b/views/templates/admin/Subscription/subscriptions-faq.html.twig @@ -32,11 +32,11 @@

- info_outline {{ subscriptionCreationTittle }} + info_outline {{ subscriptionCreationTittle|escape }}

-

{{subscriptionCreation}}

+

{{ subscriptionCreation|escape }}

@@ -47,11 +47,11 @@

- info_outline {{ importantInformationTittle }} + info_outline {{ importantInformationTittle|escape }}

-

{{importantInformation}}

+

{{ importantInformation|escape }}

@@ -62,14 +62,14 @@

- info_outline {{ carrierInformationTitle }} + info_outline {{ carrierInformationTitle|escape }}

-

{{carrierInformation1}}

-

{{carrierInformation2}}

-

{{carrierInformation3}}

-

{{carrierInformation4}}

+

{{ carrierInformation1|escape }}

+

{{ carrierInformation2|escape }}

+

{{ carrierInformation3|escape }}

+

{{ carrierInformation4|escape }}

@@ -80,12 +80,12 @@

- info_outline {{ cartRuleTitle }} + info_outline {{ cartRuleTitle|escape }}

-

{{cartRule}}

-

{{cartRule2}}

+

{{ cartRule|escape }}

+

{{ cartRule2|escape }}

@@ -96,11 +96,11 @@

- info_outline {{ giftWrappingTitle }} + info_outline {{ giftWrappingTitle|escape }}

-

{{giftWrapping1}}

+

{{ giftWrapping1|escape }}

@@ -111,13 +111,13 @@

- info_outline {{ subscriptionOrderLogicTitle }} + info_outline {{ subscriptionOrderLogicTitle|escape }}

-

{{recurringOrderCreation}}

-

{{recurringOrderPrice}}

-

{{recurringOrderAPIChanges}}

+

{{ recurringOrderCreation|escape }}

+

{{ recurringOrderPrice|escape }}

+

{{ recurringOrderAPIChanges|escape }}

diff --git a/views/templates/front/subscription/customerRecurringOrderDetailProduct.tpl b/views/templates/front/subscription/customerRecurringOrderDetailProduct.tpl index 1d071ee68..73a902eb7 100644 --- a/views/templates/front/subscription/customerRecurringOrderDetailProduct.tpl +++ b/views/templates/front/subscription/customerRecurringOrderDetailProduct.tpl @@ -4,27 +4,27 @@
-

{l s='Product:' mod='mollie'} {$order.name}

-

{l s='Quantity:' mod='mollie'} {$order.quantity}

-

{l s='Unit price:' mod='mollie'} {$order.unit_price}

+

{l s='Product:' mod='mollie'} {$order.name|escape:'htmlall':'UTF-8'}

+

{l s='Quantity:' mod='mollie'} {$order.quantity|escape:'htmlall':'UTF-8'}

+

{l s='Unit price:' mod='mollie'} {$order.unit_price|escape:'htmlall':'UTF-8'}

-

{l s='Total:' mod='mollie'} {$order.total}

-

{l s='Subscription status:' mod='mollie'} {$order.status}

-

{l s='Subscription start date:' mod='mollie'} {$order.start_date}

+

{l s='Total:' mod='mollie'} {$order.total|escape:'htmlall':'UTF-8'}

+

{l s='Subscription status:' mod='mollie'} {$order.status|escape:'htmlall':'UTF-8'}

+

{l s='Subscription start date:' mod='mollie'} {$order.start_date|escape:'htmlall':'UTF-8'}

{if isset($order.next_payment_date)} -

{l s='Next payment date:' mod='mollie'} {$order.next_payment_date}

+

{l s='Next payment date:' mod='mollie'} {$order.next_payment_date|escape:'htmlall':'UTF-8'}

{/if} {if isset($order.cancelled_date)} -

{l s='Cancelled date:' mod='mollie'} {$order.cancelled_date}

+

{l s='Cancelled date:' mod='mollie'} {$order.cancelled_date|escape:'htmlall':'UTF-8'}

{/if}