return false; } /** @var array $moduleCurrencies */ $moduleCurrencies = $this->getCurrency($cart->id_currency); if (empty($moduleCurrencies)) { static::$currencyIsAllowed[$cart->id_currency] = false; return false; } foreach ($moduleCurrencies as $moduleCurrency) { if ($cartCurrency->id == $moduleCurrency['id_currency']) { static::$currencyIsAllowed[$cart->id_currency] = true; return true; } } static::$currencyIsAllowed[$cart->id_currency] = false; return false; } /** * Check if PayPal and ps account are valid * * @return bool */ private function merchantIsValid() { if (static::$merchantIsValid === null) { /** @var MerchantValidator $merchantValidator */ $merchantValidator = $this->getService(MerchantValidator::class); static::$merchantIsValid = $merchantValidator->isValid(); } return static::$merchantIsValid; } public function hookActionObjectOrderCarrierUpdateAfter(array $params) { $orderCarrier = $params['object'] ?? null; if (!Validate::isLoadedObject($orderCarrier)) { return; } $order = new Order((int) $orderCarrier->id_order); $carrier = new Carrier((int) $orderCarrier->id_carrier); $this->processTrackingNumberUpdate($order, $carrier); } public function hookActionGetOrderShipments(array $params) { foreach ($params as $shipment) { // External shipment data comes in $params $order = $shipment['order'] ?? new \Order($shipment['id_order']); if (!Validate::isLoadedObject($order)) { return; } try { /** @var ProcessExternalShipmentAction $processExternalShipmentAction */ $processExternalShipmentAction = $this->getService(ProcessExternalShipmentAction::class); // Process external shipment data (stop on error as requested) $processExternalShipmentAction->execute($order, $shipment); } catch (\Exception $exception) { /** @var LoggerInterface $logger */ $logger = $this->getService(LoggerInterface::class); $logger->error('Failed to process external shipment data', [ 'order_id' => $order->id ?? 'unknown', 'exception' => $exception->getMessage() ]); } } } /** * @param array{cookie: Cookie, cart: Cart, altern: int, id_order: int, newOrderStatus: OrderState, oldOrderStatus: OrderState} $params * * @return void */ public function hookActionOrderStatusPostUpdate(array $params) { $order = new Order((int) $params['id_order']); if (!Validate::isLoadedObject($order) || $order->module !== $this->name) { return; } /** @var OrderCaptureAuthorizationStatusPostUpdateHookHandler $handler */ $handler = $this->getService(OrderCaptureAuthorizationStatusPostUpdateHookHandler::class); $result = $handler->handle(new OrderCaptureAuthorizationStatusPostUpdateHookParams( $params['newOrderStatus'], (int) $params['id_order'] )); if ($result instanceof HookHandlerResult) { if ($result->isError()) { $this->context->controller->errors[] = $this->trans($result->getMessage(), [], 'Modules.Checkout.Pscheckout'); } else { $this->context->controller->confirmations[] = $this->trans($result->getMessage(), [], 'Modules.Checkout.Pscheckout'); } } } /** * Common logic to process tracking number update. * * @param Order|null $order * @param Carrier|null $carrier * * @return void */ private function processTrackingNumberUpdate($order, $carrier) { try { if (!Validate::isLoadedObject($order) || $order->module !== $this->name) { return; } if ($carrier->external_module_name) { $carrierModule = Module::getInstanceByName($carrier->external_module_name); if ($carrierModule && HookCore::isModuleRegisteredOnHook($carrierModule, 'actionGetOrderShipments', $order->id_shop)) { // Wait for external module to execute that hook return; } } /** @var AddTrackingAction $addTrackingAction */ $addTrackingAction = $this->getService(AddTrackingAction::class); $addTrackingAction->execute($order, $carrier); } catch (\Exception $exception) { /** @var LoggerInterface $logger */ $logger = $this->getService(LoggerInterface::class); $logger->error('Failed to process tracking number update', [ 'order_id' => $order->id ?? 'unknown', 'carrier_id' => $carrier->id ?? 'unknown', 'exception' => $exception->getMessage() ]); } } } Home

Nuovi Prodotti

new product
Tutti i nuovi prodotti
Passa a trovarci

Home

Filtri attivi

  • Marca: ASTRALPOOL
  • Marca: CPA
  • Marca: GLOOBE
  • Marca: NEW PLAST
  • Marca: OSIP
  • Marca: POOL'S