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

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