Skip to content

Commit

Permalink
[framework] fix calculation of transport price (#3255)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav authored Jul 10, 2024
2 parents 3215526 + 22678ac commit fd3005a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/Model/Payment/PaymentValidationFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Cart\Cart;
use Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider;
use Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser;
use Shopsys\FrameworkBundle\Model\Payment\Payment;
use Shopsys\FrameworkBundle\Model\Payment\PaymentPriceProvider;
use Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade;
use Shopsys\FrontendApiBundle\Model\Payment\Exception\InvalidPaymentTransportCombinationException;
use Shopsys\FrontendApiBundle\Model\Payment\Exception\PaymentPriceChangedException;
Expand All @@ -19,13 +19,13 @@ class PaymentValidationFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
* @param \Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser $currentCustomerUser
* @param \Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade $cartApiFacade
* @param \Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider $cartPriceProvider
* @param \Shopsys\FrameworkBundle\Model\Payment\PaymentPriceProvider $paymentPriceProvider
*/
public function __construct(
protected readonly Domain $domain,
protected readonly CurrentCustomerUser $currentCustomerUser,
protected readonly CartApiFacade $cartApiFacade,
protected readonly CartPriceProvider $cartPriceProvider,
protected readonly PaymentPriceProvider $paymentPriceProvider,
) {
}

Expand All @@ -35,7 +35,7 @@ public function __construct(
*/
public function checkPaymentPrice(Payment $payment, Cart $cart): void
{
$calculatedPaymentPrice = $this->cartPriceProvider->getPaymentPrice(
$calculatedPaymentPrice = $this->paymentPriceProvider->getPaymentPrice(
$cart,
$payment,
$this->domain->getCurrentDomainConfig(),
Expand Down
13 changes: 8 additions & 5 deletions src/Model/Resolver/Price/PriceQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

use ArrayObject;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider;
use Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser;
use Shopsys\FrameworkBundle\Model\Payment\Payment;
use Shopsys\FrameworkBundle\Model\Payment\PaymentPriceCalculation;
use Shopsys\FrameworkBundle\Model\Payment\PaymentPriceProvider;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade;
use Shopsys\FrameworkBundle\Model\Pricing\Price;
use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPrice;
use Shopsys\FrameworkBundle\Model\Product\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductCachedAttributesFacade;
use Shopsys\FrameworkBundle\Model\Transport\Transport;
use Shopsys\FrameworkBundle\Model\Transport\TransportPriceCalculation;
use Shopsys\FrameworkBundle\Model\Transport\TransportPriceProvider;
use Shopsys\FrontendApiBundle\Component\GqlContext\GqlContextHelper;
use Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade;
use Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade;
Expand All @@ -36,7 +37,8 @@ class PriceQuery extends AbstractQuery
* @param \Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser $currentCustomerUser
* @param \Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade $cartApiFacade
* @param \Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade $orderApiFacade
* @param \Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider $cartPriceProvider
* @param \Shopsys\FrameworkBundle\Model\Transport\TransportPriceProvider $transportPriceProvider
* @param \Shopsys\FrameworkBundle\Model\Payment\PaymentPriceProvider $paymentPriceProvider
*/
public function __construct(
protected readonly ProductCachedAttributesFacade $productCachedAttributesFacade,
Expand All @@ -48,7 +50,8 @@ public function __construct(
protected readonly CurrentCustomerUser $currentCustomerUser,
protected readonly CartApiFacade $cartApiFacade,
protected readonly OrderApiFacade $orderApiFacade,
protected readonly CartPriceProvider $cartPriceProvider,
protected readonly TransportPriceProvider $transportPriceProvider,
protected readonly PaymentPriceProvider $paymentPriceProvider,
) {
}

Expand Down Expand Up @@ -108,7 +111,7 @@ public function priceByPaymentQuery(
return $this->calculateIndependentPaymentPrice($payment);
}

return $this->cartPriceProvider->getPaymentPrice($cart, $payment, $this->domain->getCurrentDomainConfig());
return $this->paymentPriceProvider->getPaymentPrice($cart, $payment, $this->domain->getCurrentDomainConfig());
}

/**
Expand Down Expand Up @@ -149,7 +152,7 @@ public function priceByTransportQuery(
return $this->calculateIndependentTransportPrice($transport);
}

return $this->cartPriceProvider->getTransportPrice($cart, $transport, $this->domain->getCurrentDomainConfig());
return $this->transportPriceProvider->getTransportPrice($cart, $transport, $this->domain->getCurrentDomainConfig());
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Transport/TransportValidationFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Cart\Cart;
use Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider;
use Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser;
use Shopsys\FrameworkBundle\Model\Store\StoreFacade;
use Shopsys\FrameworkBundle\Model\Transport\Transport;
use Shopsys\FrameworkBundle\Model\Transport\TransportPriceProvider;
use Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade;
use Shopsys\FrontendApiBundle\Model\Transport\Exception\InvalidTransportPaymentCombinationException;
use Shopsys\FrontendApiBundle\Model\Transport\Exception\MissingPickupPlaceIdentifierException;
Expand All @@ -23,14 +23,14 @@ class TransportValidationFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
* @param \Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser $currentCustomerUser
* @param \Shopsys\FrontendApiBundle\Model\Cart\CartApiFacade $cartApiFacade
* @param \Shopsys\FrameworkBundle\Model\Cart\CartPriceProvider $cartPriceProvider
* @param \Shopsys\FrameworkBundle\Model\Transport\TransportPriceProvider $transportPriceProvider
*/
public function __construct(
protected readonly StoreFacade $storeFacade,
protected readonly Domain $domain,
protected readonly CurrentCustomerUser $currentCustomerUser,
protected readonly CartApiFacade $cartApiFacade,
protected readonly CartPriceProvider $cartPriceProvider,
protected readonly TransportPriceProvider $transportPriceProvider,
) {
}

Expand Down Expand Up @@ -67,7 +67,7 @@ public function checkTransportWeightLimit(Transport $transport, Cart $cart): voi
*/
public function checkTransportPrice(Transport $transport, Cart $cart): void
{
$calculatedTransportPrice = $this->cartPriceProvider->getTransportPrice(
$calculatedTransportPrice = $this->transportPriceProvider->getTransportPrice(
$cart,
$transport,
$this->domain->getCurrentDomainConfig(),
Expand Down

0 comments on commit fd3005a

Please sign in to comment.