From bdc0999d1e4659ca5058886ec81e023b7214e104 Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Tue, 10 Dec 2024 15:24:00 +0100 Subject: [PATCH] FE API: Cart now contains information about the promo code type --- src/Model/Cart/CartWithModificationsResult.php | 9 ++++++--- src/Model/Cart/PromoCodeData.php | 18 ++++++++++++++++++ .../PromoCodeTypeEnumDecorator.types.yaml | 15 +++++++++++++++ .../ModelType/Cart/CartDecorator.types.yaml | 2 +- .../Cart/PromoCodeDecorator.types.yaml | 11 +++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/Model/Cart/PromoCodeData.php create mode 100644 src/Resources/config/graphql-types/EnumType/PromoCodeTypeEnumDecorator.types.yaml create mode 100644 src/Resources/config/graphql-types/ModelType/Cart/PromoCodeDecorator.types.yaml diff --git a/src/Model/Cart/CartWithModificationsResult.php b/src/Model/Cart/CartWithModificationsResult.php index fe5592b68..ab90c72bb 100644 --- a/src/Model/Cart/CartWithModificationsResult.php +++ b/src/Model/Cart/CartWithModificationsResult.php @@ -270,15 +270,18 @@ public function getPayment(): ?Payment } /** - * @return string|null + * @return \Shopsys\FrontendApiBundle\Model\Cart\PromoCodeData|null */ - public function getPromoCode(): ?string + public function getPromoCode(): ?PromoCodeData { if ($this->cart->getFirstAppliedPromoCode() === null) { return null; } - return $this->cart->getFirstAppliedPromoCode()->getCode(); + return new PromoCodeData( + $this->cart->getFirstAppliedPromoCode()->getCode(), + $this->cart->getFirstAppliedPromoCode()->getDiscountType(), + ); } /** diff --git a/src/Model/Cart/PromoCodeData.php b/src/Model/Cart/PromoCodeData.php new file mode 100644 index 000000000..586e2f82f --- /dev/null +++ b/src/Model/Cart/PromoCodeData.php @@ -0,0 +1,18 @@ +