Skip to content

Commit

Permalink
Merge pull request #95 from IrinaZhadzinets/issue-3763
Browse files Browse the repository at this point in the history
#3763 - Get the minimum order amount for a purchase
  • Loading branch information
carinadues authored May 13, 2022
2 parents c86e960 + 778ad8e commit d0a3bf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Model/Resolver/GetCartForCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Magento\Downloadable\Model\LinkRepository;
use Magento\Downloadable\Model\Link;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage;

class GetCartForCustomer extends CartResolver
{
Expand Down Expand Up @@ -71,6 +72,9 @@ class GetCartForCustomer extends CartResolver
/** @var IsInStorePickupDeliveryAvailableForCartInterface */
protected $inStorePickupDeliveryAvailableForCart;

/** @var ValidationMessage */
protected $amountValidationMessage;

/**
* GetCartForCustomer constructor.
* @param ParamOverriderCustomerId $overriderCustomerId
Expand All @@ -85,6 +89,7 @@ class GetCartForCustomer extends CartResolver
* @param LinkRepository $linkRepository
* @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
* @param IsInStorePickupDeliveryAvailableForCartInterface $inStorePickupDeliveryAvailableForCart
* @param ValidationResultFactory $validationResultFactory
*/
public function __construct(
ParamOverriderCustomerId $overriderCustomerId,
Expand All @@ -98,7 +103,8 @@ public function __construct(
Json $serializer,
LinkRepository $linkRepository,
QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId,
IsInStorePickupDeliveryAvailableForCartInterface $inStorePickupDeliveryAvailableForCart
IsInStorePickupDeliveryAvailableForCartInterface $inStorePickupDeliveryAvailableForCart,
ValidationMessage $amountValidationMessage
) {
parent::__construct(
$guestCartRepository,
Expand All @@ -115,6 +121,7 @@ public function __construct(
$this->linkRepository = $linkRepository;
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId;
$this->inStorePickupDeliveryAvailableForCart = $inStorePickupDeliveryAvailableForCart;
$this->amountValidationMessage = $amountValidationMessage;
}

/**
Expand Down Expand Up @@ -266,6 +273,8 @@ public function resolve(
$shipping_method = $address->getShippingMethod();
$masked_id = $this->quoteIdToMaskedQuoteId->execute(intval($cart->getId()));
$isInStorePickupAvailable = $this->inStorePickupDeliveryAvailableForCart->execute((int) $cart->getId());
$minimumOrderAmountReached = $cart->validateMinimumAmount();
$minimumOrderDescription = $this->amountValidationMessage->getMessage();

return array_merge(
$cartData,
Expand All @@ -283,7 +292,11 @@ public function resolve(
'shipping_incl_tax' => $shipping_incl_tax,
'shipping_method' => $shipping_method,
'shipping_address' => $cart->getShippingAddress(),
'is_in_store_pickup_available' => $isInStorePickupAvailable
'is_in_store_pickup_available' => $isInStorePickupAvailable,
'minimum_order_amount' => [
'minimum_order_amount_reached' => $minimumOrderAmountReached,
'minimum_order_description' => $minimumOrderDescription
]
]
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ interface TotalsObject @typeResolver(class: "\\ScandiPWA\\QuoteGraphQl\\Model\\R
quote_currency_code: String
items: [TotalsItem]
is_in_store_pickup_available: Boolean
minimum_order_amount: MinimumOrderAmount
}

type TotalsItem {
Expand Down Expand Up @@ -241,6 +242,11 @@ type SelectedDownloadableLinks {
id: Int
}

type MinimumOrderAmount {
minimum_order_amount_reached: Boolean
minimum_order_description: String
}

type TotalsSegment {
code: String
title: String
Expand Down

0 comments on commit d0a3bf3

Please sign in to comment.