Skip to content

Commit

Permalink
PIPRES-261: Minor improvements (#820)
Browse files Browse the repository at this point in the history
* PIPRES-261: Get carrier price to create subscription

* renamed some services and added additional conditions for carrier retrieve

* PIPRES-261: Minor improvements
  • Loading branch information
mandan2 authored Oct 2, 2023
1 parent 6c005bd commit 26e134a
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 56 deletions.
10 changes: 4 additions & 6 deletions src/Builder/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CouldNotCreateOrderPaymentFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CouldNotInstallModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CouldNotUpdateOrderTotals.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
8 changes: 4 additions & 4 deletions src/Handler/Exception/CouldNotHandleOrderPaymentFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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.',
Expand Down
4 changes: 2 additions & 2 deletions subscription/Exception/CouldNotHandleRecurringOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

class CouldNotHandleRecurringOrder extends MollieSubscriptionException
{
public static function failedToFindSelectedCarrier(): CouldNotHandleRecurringOrder
public static function failedToFindSelectedCarrier(): self
{
return new self(
'Failed to find selected carrier',
ExceptionCode::RECURRING_ORDER_FAILED_TO_FIND_SELECTED_CARRIER
);
}

public static function failedToApplySelectedCarrier(): CouldNotHandleRecurringOrder
public static function failedToApplySelectedCarrier(): self
{
return new self(
'Failed to apply selected carrier',
Expand Down
8 changes: 4 additions & 4 deletions subscription/Exception/CouldNotPresentOrderDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@

class CouldNotPresentOrderDetail extends MollieSubscriptionException
{
public static function failedToFindOrder(): CouldNotPresentOrderDetail
public static function failedToFindOrder(): self
{
return new self(
'Failed to find order',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER
);
}

public static function failedToFindOrderDetail(): CouldNotPresentOrderDetail
public static function failedToFindOrderDetail(): self
{
return new self(
'Failed to find order detail',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_DETAIL
);
}

public static function failedToFindProduct(): CouldNotPresentOrderDetail
public static function failedToFindProduct(): self
{
return new self(
'Failed to find product',
ExceptionCode::ORDER_FAILED_TO_FIND_PRODUCT
);
}

public static function failedToFindCurrency(): CouldNotPresentOrderDetail
public static function failedToFindCurrency(): self
{
return new self(
'Failed to find currency',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@

class CouldNotProvideSubscriptionCarrierDeliveryPrice extends MollieSubscriptionException
{
public static function failedToFindSelectedCarrier(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToFindSelectedCarrier(): self
{
return new self(
'Failed to find selected carrier',
ExceptionCode::ORDER_FAILED_TO_FIND_SELECTED_CARRIER
);
}

public static function failedToFindOrderCart(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToFindOrderCart(): self
{
return new self(
'Failed to find order cart',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_CART
);
}

public static function failedToFindOrderCustomer(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToFindOrderCustomer(): self
{
return new self(
'Failed to find order customer',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_CUSTOMER
);
}

public static function failedToApplySelectedCarrier(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToApplySelectedCarrier(): self
{
return new self(
'Failed to apply selected carrier',
ExceptionCode::ORDER_FAILED_TO_APPLY_SELECTED_CARRIER
);
}

public static function failedToFindOrderDeliveryAddress(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToFindOrderDeliveryAddress(): self
{
return new self(
'Failed to find order delivery address',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_DELIVERY_ADDRESS
);
}

public static function failedToFindOrderDeliveryCountry(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToFindOrderDeliveryCountry(): self
{
return new self(
'Failed to find order delivery country',
ExceptionCode::ORDER_FAILED_TO_FIND_ORDER_DELIVERY_COUNTRY
);
}

public static function failedToGetSelectedCarrierPrice(): CouldNotProvideSubscriptionCarrierDeliveryPrice
public static function failedToGetSelectedCarrierPrice(): self
{
return new self(
'Failed to get selected carrier price',
Expand Down
6 changes: 3 additions & 3 deletions subscription/Handler/RecurringOrderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
36 changes: 18 additions & 18 deletions views/templates/admin/Subscription/subscriptions-faq.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ subscriptionCreationTittle }}
<i class="material-icons">info_outline</i> {{ subscriptionCreationTittle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{subscriptionCreation}}</p>
<p>{{ subscriptionCreation|escape }}</p>
</div>
</div>
</div>
Expand All @@ -47,11 +47,11 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ importantInformationTittle }}
<i class="material-icons">info_outline</i> {{ importantInformationTittle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{importantInformation}}</p>
<p>{{ importantInformation|escape }}</p>
</div>
</div>
</div>
Expand All @@ -62,14 +62,14 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ carrierInformationTitle }}
<i class="material-icons">info_outline</i> {{ carrierInformationTitle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{carrierInformation1}}</p>
<p>{{carrierInformation2}}</p>
<p>{{carrierInformation3}}</p>
<p>{{carrierInformation4}}</p>
<p>{{ carrierInformation1|escape }}</p>
<p>{{ carrierInformation2|escape }}</p>
<p>{{ carrierInformation3|escape }}</p>
<p>{{ carrierInformation4|escape }}</p>
</div>
</div>
</div>
Expand All @@ -80,12 +80,12 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ cartRuleTitle }}
<i class="material-icons">info_outline</i> {{ cartRuleTitle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{cartRule}}</p>
<p>{{cartRule2}}</p>
<p>{{ cartRule|escape }}</p>
<p>{{ cartRule2|escape }}</p>
</div>
</div>
</div>
Expand All @@ -96,11 +96,11 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ giftWrappingTitle }}
<i class="material-icons">info_outline</i> {{ giftWrappingTitle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{giftWrapping1}}</p>
<p>{{ giftWrapping1|escape }}</p>
</div>
</div>
</div>
Expand All @@ -111,13 +111,13 @@
<div class="col-lg-12">
<div class="card">
<h3 class="card-header">
<i class="material-icons">info_outline</i> {{ subscriptionOrderLogicTitle }}
<i class="material-icons">info_outline</i> {{ subscriptionOrderLogicTitle|escape }}
</h3>
<div class="card-block">
<div class="card-text">
<p>{{recurringOrderCreation}}</p>
<p>{{recurringOrderPrice}}</p>
<p>{{recurringOrderAPIChanges}}</p>
<p>{{ recurringOrderCreation|escape }}</p>
<p>{{ recurringOrderPrice|escape }}</p>
<p>{{ recurringOrderAPIChanges|escape }}</p>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
<div class="row product-info">
<div class="col-12 col-lg-6 product-img">
<img class="img"
src="{$order.img}"
src="{$order.img|escape:'htmlall':'UTF-8'}"
itemprop="image" width="200">
</div>
<div class="col-12 col-lg-6">
<a href="{$order.link}"><p><b>{l s='Product:' mod='mollie'}</b> {$order.name}</p></a>
<p><b>{l s='Quantity:' mod='mollie'}</b> {$order.quantity}</p>
<p><b>{l s='Unit price:' mod='mollie'}</b> {$order.unit_price}</p>
<a href="{$order.link|escape:'htmlall':'UTF-8'}"><p><b>{l s='Product:' mod='mollie'}</b> {$order.name|escape:'htmlall':'UTF-8'}</p></a>
<p><b>{l s='Quantity:' mod='mollie'}</b> {$order.quantity|escape:'htmlall':'UTF-8'}</p>
<p><b>{l s='Unit price:' mod='mollie'}</b> {$order.unit_price|escape:'htmlall':'UTF-8'}</p>
</div>
</div>
</div>
<div class="col-12 col-lg-6">
<p><b>{l s='Total:' mod='mollie'}</b> {$order.total}</p>
<p><b>{l s='Subscription status:' mod='mollie'}</b> {$order.status}</p>
<p><b>{l s='Subscription start date:' mod='mollie'}</b> {$order.start_date}</p>
<p><b>{l s='Total:' mod='mollie'}</b> {$order.total|escape:'htmlall':'UTF-8'}</p>
<p><b>{l s='Subscription status:' mod='mollie'}</b> {$order.status|escape:'htmlall':'UTF-8'}</p>
<p><b>{l s='Subscription start date:' mod='mollie'}</b> {$order.start_date|escape:'htmlall':'UTF-8'}</p>

{if isset($order.next_payment_date)}
<p><b>{l s='Next payment date:' mod='mollie'}</b> {$order.next_payment_date}</p>
<p><b>{l s='Next payment date:' mod='mollie'}</b> {$order.next_payment_date|escape:'htmlall':'UTF-8'}</p>
{/if}

{if isset($order.cancelled_date)}
<p><b>{l s='Cancelled date:' mod='mollie'}</b> {$order.cancelled_date}</p>
<p><b>{l s='Cancelled date:' mod='mollie'}</b> {$order.cancelled_date|escape:'htmlall':'UTF-8'}</p>
{/if}
</div>
</div>
Expand Down

0 comments on commit 26e134a

Please sign in to comment.