custom/plugins/ProcLivePrice/src/Subscriber/LivePriceSubscriber.php line 140

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Proc\ProcLivePrice\Subscriber;
  3. use Proc\ProcOrderSimulate\Subscriber\OrderSimulateSubscriber;
  4. use Shopware\Core\Checkout\Customer\CustomerEntity;
  5. use Shopware\Core\Content\Product\DataAbstractionLayer\CheapestPrice\CheapestPriceContainer;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Pricing\Price;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Pricing\PriceCollection;
  8. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Shopware\Core\Checkout\Cart\Price\Struct\ListPrice;
  11. use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice;
  12. use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection;
  13. use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRule;
  14. use Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection;
  15. use Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTax;
  16. use Shopware\Core\Content\Product\ProductEntity;
  17. use Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity;
  18. use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
  19. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  20. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  21. use Shopware\Core\Framework\DataAbstractionLayer\Pricing\CalculatedListingPrice;
  22. use Shopware\Core\Content\Product\DataAbstractionLayer\CheapestPrice\CalculatedCheapestPrice;
  23. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  24. use Shopware\Core\Content\Product\Events\ProductListingResultEvent;
  25. use Shopware\Core\Framework\Event\NestedEvent;
  26. use Swag\EnterpriseSearch\Search\Page\SearchPageLoadedEvent;
  27. use Proc\ProcLivePrice\Helper\BuildRequestHelper;
  28. use Proc\ProcFoundation\Helper\ErrorHandler;
  29. use Proc\ProcFoundation\Helper\RequestHandler;
  30. use Proc\ProcFoundation\Service\ProcFoundationService;
  31. use Symfony\Component\HttpFoundation\RedirectResponse;
  32. use Symfony\Component\Routing\RouterInterface;
  33. /**
  34.  * Class LivePriceSubscriber
  35.  * @package Proc\ProcLivePrice\Subscriber
  36.  */
  37. class LivePriceSubscriber implements EventSubscriberInterface
  38. {
  39.     private const PATH '/iman/live-price';
  40.     private const CUSTOM_ZLOTY 'PLN';
  41.     /**
  42.      * @var RequestHandler
  43.      */
  44.     private $requestHandler;
  45.     /**
  46.      * @var ErrorHandler
  47.      */
  48.     private $errorHandler;
  49.     /**
  50.      * @var string
  51.      */
  52.     private
  53.         $host,
  54.         $port,
  55.         $customerNumber;
  56.     private $error null;
  57.     /**
  58.      * @var ProcFoundationService
  59.      */
  60.     private $foundationService;
  61.     /**
  62.      * @var EntityRepositoryInterface
  63.      */
  64.     private $productRepository;
  65.     /**
  66.      * @var ProductPageLoadedEvent | ProductListingResultEvent | SearchPageLoadedEvent
  67.      */
  68.     private $event;
  69.     /**
  70.      * @var array
  71.      */
  72.     private $result;
  73.     /**
  74.      * @var CalculatedTaxCollection
  75.      */
  76.     private $calculatedTaxCollection;
  77.     /**
  78.      * @var TaxRuleCollection
  79.      */
  80.     private $taxRuleCollection;
  81.     /**
  82.      * @var RouterInterface
  83.      */
  84.     private RouterInterface $router;
  85.     /**
  86.      * @inheritDoc
  87.      */
  88.     public static function getSubscribedEvents(): array
  89.     {
  90.         return [
  91.             ProductPageLoadedEvent::class => ['onProductPageLoaded'1],
  92.             ProductListingResultEvent::class => ['onListingResultLoaded'1],
  93.             SearchPageLoadedEvent::class => ['onListingResultLoaded']
  94.         ];
  95.     }
  96.     /**
  97.      * LivePriceSubscriber constructor.
  98.      * @param ProcFoundationService $foundationService
  99.      * @param RequestHandler $requestHandler
  100.      * @param ErrorHandler $errorHandler
  101.      * @param EntityRepositoryInterface $repositoryInterface
  102.      */
  103.     function __construct(
  104.         ProcFoundationService $foundationService,
  105.         RequestHandler $requestHandler,
  106.         ErrorHandler $errorHandler,
  107.         EntityRepositoryInterface $repositoryInterface,
  108.         RouterInterface $router
  109.     ) {
  110.         $this->foundationService $foundationService;
  111.         $this->requestHandler $requestHandler;
  112.         $this->errorHandler $errorHandler;
  113.         $this->productRepository $repositoryInterface;
  114.         $this->router $router;
  115.     }
  116.     /**
  117.      * @param NestedEvent $event
  118.      * @throws \Exception
  119.      */
  120.     public function onListingResultLoaded(NestedEvent $event)
  121.     {
  122.         $this->event $event;
  123.         /**
  124.          * Prüfung ob Benutzer angemeldet ist, sonst keine Live-Abfrage.
  125.          */
  126.         if (!($this->customerNumber $this->foundationService->checkLogin($this->event->getSalesChannelContext(),
  127.             get_class($this)))) {
  128.             return;
  129.         }
  130.         /**
  131.          * Prüfen ob der Benutzer eine Artikel-Whitelist hat.
  132.          */
  133.         $customFields $this->event->getSalesChannelContext()->getCustomer()->getCustomFields();
  134.         if (array_key_exists('custom_product_listing_numbers'$customFields) &&
  135.             $customFields['custom_product_listing_numbers'] != null &&
  136.             $customFields['custom_product_listing_numbers'] != &&
  137.             $customFields['custom_product_listing_numbers'] != '') {
  138.             $allowedArticles explode(','$customFields['custom_product_listing_numbers']);
  139.         } else {
  140.             return;
  141.         }
  142.         /**
  143.          * Configeinstellungen prüfen und setzen.
  144.          */
  145.         if (!$this->checkConfig()) {
  146.             return;
  147.         }
  148.         $productArray = array();
  149.         if ($this->event instanceof ProductListingResultEvent) {
  150.             $resultItems $this->event->getResult()->getIterator();
  151.         } else {
  152.             $resultItems $this->event->getPage()->getListing()->getIterator();
  153.         }
  154.         $articles = [];
  155.         $counter 0;
  156.         while ($resultItems->current() !== null) {
  157.             /**
  158.              * @var SalesChannelProductEntity $product
  159.              */
  160.             $product $resultItems->current();
  161.             // benutzer holen. -> custom field holen.(siehe oben) String in array umwandeln. Prüfen ob artikelnummer vorhanden. Wenn ja dann durchlaufen, wenn nein, continue.
  162.             if (!in_array($product->getProductNumber(), $allowedArticles)) {
  163.                 $resultItems->next();
  164.                 continue;
  165.             }
  166.             $counter++;
  167.             if ($product->getParentId()) {
  168.                 /**
  169.                  * @var ProductEntity $parentProduct
  170.                  */
  171.                 $parentProduct $this->getProduct($product->getParentId(), ['children']);
  172.                 $childArticles = array();
  173.                 foreach ($parentProduct->getChildren()->getElements() as $children) {
  174.                     $childArticle['position-id'] = $counter;
  175.                     $childArticle['article-number'] = $children->getProductNumber();
  176.                     $childArticle['quantity'] = 1;
  177.                     $childArticle['quantity-unit'] = $children->getPackUnit();
  178.                     $childArticles[] = $childArticle;
  179.                 }
  180.                 $childResult $this->getArticleInfo($childArticles);
  181.                 if ($childResult['head']['status'] == 'NOK') {
  182.                     return;
  183.                 }
  184. //                 $this->error = $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUEST, get_class($this), print_r($childResult, true));
  185. //                 $this->errorHandler->writeErrorLog($this->error);
  186.                 $countProductItems sizeof($childResult);
  187.                 $from 0;
  188.                 $to 0;
  189.                 $x 0;
  190.                 foreach ($childResult['articles']['article'] as $childArticle) {
  191.                     // $unitPrice = (float)$childArticle['conditions']['condition'][0]['condition-value'];
  192.                     // $mwstValue = (float)$childArticle['conditions']['condition'][2]['condition-value'];
  193.                     // $unitPrice = $unitPrice + $mwstValue;
  194.                     $unitPrice = (float)$childArticle['price'] / (float)$childArticle['quantity'];
  195.                     if ($x === 0) {
  196.                         $from $unitPrice;
  197.                         $to $unitPrice;
  198.                     } elseif ($unitPrice $from) {
  199.                         $from $unitPrice;
  200.                     } elseif ($unitPrice $to) {
  201.                         $to $unitPrice;
  202.                     }
  203.                     $x++;
  204.                 }
  205.                 /**
  206.                  * @var CalculatedCheapestPrice $productListingPrice
  207.                  */
  208.                 $productListingPrice $product->getCalculatedCheapestPrice();
  209.                 /**
  210.                  * @var CalculatedPrice $fromPrice , $toPrice
  211.                  */
  212.                 $fromPrice = new CalculatedPrice(
  213.                     $from,
  214.                     $from,
  215.                     $productListingPrice->getCalculatedTaxes(),
  216.                     $productListingPrice->getTaxRules(),
  217.                     1);
  218.                 $toPrice = new CalculatedPrice(
  219.                     $to,
  220.                     $to,
  221.                     $productListingPrice->getCalculatedTaxes(),
  222.                     $productListingPrice->getTaxRules(),
  223.                     1);
  224.                 /**
  225.                  * @var CalculatedCheapestPrice $newListingPrice
  226.                  */
  227.                 $newListingPrice = new CalculatedCheapestPrice($from$to$productListingPrice->getCalculatedTaxes(),
  228.                     $productListingPrice->getTaxRules());
  229.                 $product->setCalculatedCheapestPrice($newListingPrice);
  230.                 $product->getCheapestPrice()->getPrice()->first()->setGross($to);
  231.                 $product->getCheapestPrice()->getPrice()->first()->setNet($to);
  232.             }
  233.             $productArray[] = $product;
  234.             $article['position-id'] = $counter;
  235.             $article['article-number'] = $product->getProductNumber();
  236.             $article['quantity'] = 1;
  237.             $article['quantity-unit'] = $product->getPackUnit();
  238.             $articles[] = $article;
  239.             $resultItems->next();
  240.         }
  241.         if (count($articles) <= 0) {
  242.             return;
  243.         }
  244.         $this->result $this->getArticleInfo($articles);
  245.         if ($this->result['head']['status'] == 'NOK') {
  246.             return;
  247.         }
  248.         $countProductItems sizeof($productArray);
  249.         $x 0;
  250.         foreach ($productArray as $productItem) {
  251.             if ($countProductItems 1) {
  252.                 // $unitPrice = (float)$this->result['articles']['article'][$x]['conditions']['condition'][0]['condition-value'];
  253.                 $totalPrice = (float)$this->result['articles']['article'][$x]['price'];
  254.                 $unitPrice = (float)$totalPrice / (float)$this->result['articles']['article'][$x]['quantity'];
  255.                 $mwstRate 0.0// (float)$this->result['articles']['article'][$x]['conditions']['condition'][2]['condition-rate'];
  256.                 $mwstValue 0.0// (float)$this->result['articles']['article'][$x]['conditions']['condition'][2]['condition-value'];
  257.             } else {
  258.                 // $unitPrice = (float)$this->result['articles']['article']['conditions']['condition'][0]['condition-value'];
  259.                 $totalPrice = (float)$this->result['articles']['article']['price'];
  260.                 $unitPrice = (float)$totalPrice / (float)$this->result['articles']['article']['quantity'];
  261.                 $mwstRate 0.0// (float)$this->result['articles']['article']['conditions']['condition'][2]['condition-rate'];
  262.                 $mwstValue 0.0// (float)$this->result['articles']['article']['conditions']['condition'][2]['condition-value'];
  263.             }
  264.             /**
  265.              * @var CalculatedPrice $price
  266.              */
  267.             $price $product->getCalculatedPrice();
  268.             /**
  269.              * @var TaxRule $newTaxRule
  270.              */
  271.             $newTaxRule = new TaxRule($mwstRate);
  272.             /**
  273.              * @var TaxRuleCollection $newTaxRuleCollection
  274.              */
  275.             $newTaxRuleCollection = new TaxRuleCollection();
  276.             $newTaxRuleCollection->add($newTaxRule);
  277.             /**
  278.              * @var CalculatedTax $newCalculateTax
  279.              */
  280.             $newCalculateTax = new CalculatedTax($mwstValue$mwstRate$totalPrice);
  281.             /**
  282.              * @var CalculatedTaxCollection $newCalculatedTaxCollection
  283.              */
  284.             $newCalculatedTaxCollection = new CalculatedTaxCollection();
  285.             $newCalculatedTaxCollection->add($newCalculateTax);
  286.             /**
  287.              * @var CalculatedPrice $newPrice
  288.              */
  289.             $newPrice = new CalculatedPrice(
  290.                 ($unitPrice $mwstValue),
  291.                 $totalPrice,
  292.                 $newCalculatedTaxCollection,
  293.                 $newTaxRuleCollection,
  294.                 $price->getQuantity(),
  295.                 $price->getReferencePrice(),
  296.                 $price->getListPrice()
  297.             );
  298.             $productItem->setCalculatedPrice($newPrice);
  299.             $x++;
  300.         }
  301.     }
  302.     /**
  303.      * @param ProductPageLoadedEvent $event
  304.      */
  305.     public function onProductPageLoaded(ProductPageLoadedEvent $event)
  306.     {
  307.         $this->event $event;
  308.         /**
  309.          * Prüfung ob Benutzer angemeldet ist, sonst keine Live-Abfrage.
  310.          */
  311.         if (!($this->customerNumber $this->foundationService->checkLogin($this->event->getSalesChannelContext(),
  312.             get_class($this)))) {
  313.             return;
  314.         } else {
  315.             if (array_key_exists('custom_product_listing_numbers',
  316.                 $this->event->getSalesChannelContext()->getCustomer()->getCustomFields())) {
  317.                 $articles explode(',',
  318.                     $this->event->getSalesChannelContext()->getCustomer()->getCustomFields()['custom_product_listing_numbers']);
  319.                 if (!in_array($this->event->getPage()->getProduct()->getProductNumber(), $articles)) {
  320.                     $redirectResponse = new RedirectResponse($this->router->generate('frontend.home.page'));
  321.                     return $redirectResponse->send();
  322.                 }
  323.             }
  324.         }
  325.         /**
  326.          * Configeinstellungen prüfen und setzen.
  327.          */
  328.         if (!$this->checkConfig()) {
  329.             return;
  330.         }
  331.         /**
  332.          * @var SalesChannelProductEntity $product
  333.          */
  334.         $product $this->event->getPage()->getProduct();
  335.         /**
  336.          * @todo Die position-id noch richtig machen
  337.          * @var array $article
  338.          */
  339.         $article['position-id'] = 1;
  340.         $article['article-number'] = $product->getProductNumber();
  341.         $article['quantity'] = 1;
  342.         $article['quantity-unit'] = $product->getPackUnit();
  343.         $this->result $this->getArticleInfo([$article]);
  344. //         $this->error = $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUEST, get_class($this), 'Nach getAticleInfo()');
  345. //         $this->errorHandler->writeErrorLog($this->error);
  346.         if ($this->result['head']['status'] == 'NOK') {
  347.             return;
  348.         }
  349.         // $unitPrice = (float)$this->result['articles']['article']['conditions']['condition'][0]['condition-value'];
  350.         $totalPrice = (float)$this->result['articles']['article']['price'];
  351.         $unitPrice $totalPrice / (float)$this->result['articles']['article']['quantity'];
  352.         $mwstRate 0.0// (float)$this->result['articles']['article']['conditions']['condition'][2]['condition-rate'];
  353.         $mwstValue 0.0// (float)$this->result['articles']['article']['conditions']['condition'][2]['condition-value'];
  354.         /**
  355.          * @var CalculatedPrice $price
  356.          */
  357.         $price $product->getCalculatedPrice();
  358.         /**
  359.          * @var TaxRule $newTaxRule
  360.          */
  361.         $newTaxRule = new TaxRule($mwstRate);
  362.         /** a
  363.          * @var TaxRuleCollection $newTaxRuleCollection
  364.          */
  365.         $newTaxRuleCollection = new TaxRuleCollection();
  366.         $newTaxRuleCollection->add($newTaxRule);
  367.         /**
  368.          * @var CalculatedTax $newCalculateTax
  369.          */
  370.         $newCalculateTax = new CalculatedTax($mwstValue$mwstRate$unitPrice);
  371.         /**
  372.          * @var CalculatedTaxCollection $newCalculatedTaxCollection
  373.          */
  374.         $newCalculatedTaxCollection = new CalculatedTaxCollection();
  375.         $newCalculatedTaxCollection->add($newCalculateTax);
  376.         /**
  377.          * @var TaxRule $newTaxRule
  378.          */
  379.         $newTaxRule = new TaxRule(0.0); // (float)$this->result['articles']['article']['conditions']['condition'][2]['condition-value']);
  380.         $price->getTaxRules()->add($newTaxRule);
  381.         // Get from request or pick default
  382.         if (array_key_exists('free-shipping-threshold'$this->result['shipping-cost'])) {
  383.             $freeShippingThreshold = ['freeShippingThreshold' => $this->result['shipping-cost']['free-shipping-threshold']];
  384.         } else {
  385.             $freeShippingThreshold = ['freeShippingThreshold' => $this->calculateShippingThreshold($event->getSalesChannelContext())];
  386.         }
  387.         $this->event->getContext()->addArrayExtension('deliveryInformations'$freeShippingThreshold);
  388. //        $newReferencePrice = new ReferencePrice(
  389. //            $totalPrice, 1.0, 1.0, $price->getReferencePrice()->getUnitName()
  390. //        );
  391.         /**
  392.          * @var CalculatedPrice $newPrice
  393.          */
  394.         $newPrice = new CalculatedPrice(
  395.         //(float)$this->result['articles']['article']['price'],
  396.             $totalPrice,
  397.             $totalPrice,
  398.             $newCalculatedTaxCollection,
  399.             $newTaxRuleCollection,
  400.             1,
  401.             null,
  402.             // $price->getReferencePrice(),
  403.             // $newReferencePrice,
  404.             ListPrice::createFromUnitPrice($totalPrice$totalPrice)
  405.         );
  406.         $newCalculatedCheapestPrice = new CalculatedCheapestPrice($totalPrice$totalPrice$newCalculatedTaxCollection,
  407.             $newTaxRuleCollection1);
  408. //         $this->error = $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUEST, get_class($this), 'totalPrice - ' . $totalPrice);
  409. //         $this->errorHandler->writeErrorLog($this->error);
  410. //         $this->error = $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUEST, get_class($this), 'unitPrice - ' . $unitPrice);
  411. //         $this->errorHandler->writeErrorLog($this->error);
  412. //        $this->error = $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUEST, get_class($this), 'Price - ' . $newPrice->getPrice());
  413. //        $this->errorHandler->writeErrorLog($this->error);
  414.         $product->setCalculatedCheapestPrice($newCalculatedCheapestPrice);
  415.         $product->setCalculatedPrice($newPrice);
  416.         $product->getPrice()->first()->setNet($totalPrice);
  417.         $product->getPrice()->first()->setGross($totalPrice);
  418.         $product->getCheapestPrice()->getPrice()->first()->setGross($totalPrice);
  419.         $product->getCheapestPrice()->getPrice()->first()->setNet($totalPrice);
  420.         $product->getCalculatedPrices()->clear();
  421.         $product->setCheapestPrice(null);
  422.         $newCPContainer = new CheapestPriceContainer([]);
  423.         $product->setCheapestPriceContainer($newCPContainer);
  424.     }
  425.     /**
  426.      * @param array $articles
  427.      * @param int $shopInstance
  428.      * @param string $currency
  429.      * @param string $language
  430.      * @return
  431.      */
  432.     private function getArticleInfo(
  433.         array $articles,
  434.         int $shopInstance 1,
  435.         string $language 'DE'
  436.     ) {
  437.         $params = [
  438.             'customer' => $this->customerNumber,
  439.             'shop-instance' => $shopInstance,
  440.             'currency' => $this->getCurrencyISO()
  441.         ];
  442.         $buildRequestHelper = new BuildRequestHelper($params$articles$this->errorHandler);
  443.         /**
  444.          * @var string $request
  445.          */
  446.         $request $this->requestHandler->buildRequest($buildRequestHelperget_class($this));
  447.         $this->error $this->errorHandler->error($this->errorHandler::GENERAL_ERRORget_class($this),
  448.             "Request: " print_r($requesttrue));
  449.         $this->errorHandler->writeErrorLog($this->error);
  450.         if ($request !== '') {
  451.             /**
  452.              * @var string $result
  453.              */
  454.             $result $this->requestHandler->sendRequest($this->host$this->portself::PATH$request);
  455.         } else {
  456.             $this->error $this->errorHandler->error($this->errorHandler::UNKNOWN_REQUESTget_class($this),
  457.                 'Fehler im Aufbau des Request');
  458.             $this->errorHandler->writeErrorLog($this->error);
  459.             return;
  460.         }
  461.         /**
  462.          * @var array $resultArray
  463.          */
  464.         $resultArray $this->requestHandler->parseResult($result);
  465.         if ($resultArray['head']['status'] == 'NOK') {
  466.             $this->error $this->errorHandler->error($this->errorHandler::SAP_RESPONSE_ERRORget_class($this),
  467.                 'SAP Status Fehler. - ' print_r($resultArraytrue));
  468.             $this->errorHandler->writeErrorLog($this->error);
  469.             // } else {
  470.             //  $this->error = $this->errorHandler->error($this->errorHandler::WRONG_ARTICLE_ERROR, get_class($this), 'LivePrice-Response after success. - ' . print_r($resultArray, true));
  471.             //  $this->errorHandler->writeErrorLog($this->error);
  472.         }
  473.         return $resultArray;
  474.     }
  475.     /**
  476.      * @return bool
  477.      */
  478.     private function checkConfig(): bool
  479.     {
  480.         if ($this->foundationService->getConfigStatus()) {
  481.             $this->host $this->foundationService->getHost();
  482.             $this->port $this->foundationService->getPort();
  483.             return true;
  484.         }
  485.         $this->error $this->errorHandler->error($this->errorHandler::CONFIG_NOT_VALIDget_class($this),
  486.             'Konnte die Konfiguration nicht ermitteln');
  487.         $this->errorHandler->writeErrorLog($this->error);
  488.         return false;
  489.     }
  490.     /**
  491.      * @param string $productID
  492.      * @return ProductEntity
  493.      */
  494.     public function getProduct(string $productID, array $associations null): ProductEntity
  495.     {
  496.         /**
  497.          * @var Criteria $criteria
  498.          */
  499.         $criteria = new Criteria([$productID]);
  500.         if ($associations !== null) {
  501.             foreach ($associations as $association) {
  502.                 $criteria->addAssociation($association);
  503.             }
  504.         }
  505.         /**
  506.          * @var EntityCollection $products
  507.          */
  508.         $products $this->productRepository->search($criteria,
  509.             \Shopware\Core\Framework\Context::createDefaultContext());
  510.         /**
  511.          * @var array $productList
  512.          */
  513.         $productList $products->getElements();
  514.         /**
  515.          * @var ProductEntity $product
  516.          */
  517.         $product $productList[$productID];
  518.         return $product;
  519.     }
  520.     /**
  521.      * fts - Retrieve currency iso code from saleschannel context
  522.      * @return string
  523.      */
  524.     function getCurrencyISO(): string
  525.     {
  526.         return $this->event?->getSalesChannelContext()?->getCurrency()->getIsoCode() ?? "EUR";
  527.     }
  528.     /**
  529.      * If the current currency is not EUR, then the default threshold (250€)
  530.      * will be converted to the appropriate currency using the currency factor.
  531.      * @return int
  532.      */
  533.     private function calculateShippingThreshold(SalesChannelContext $context): int
  534.     {
  535.         if($context->getCurrency()->getIsoCode() === "PLN") {
  536.             return OrderSimulateSubscriber::ZLOTY_THRESHOLD;
  537.         } else if($context->getCurrency()->getIsoCode() === "GBP") {
  538.             return OrderSimulateSubscriber::POUND_THRESHOLD;
  539.         } else {
  540.             return OrderSimulateSubscriber::EUR_THRESHOLD;
  541.         }
  542.     }
  543. }