public function getDeliveryOptionList(Country $default_country = null, $flush = false) { $r = parent::getDeliveryOptionList($default_country, $flush); if ($this->id_carrier == Configuration::get('SHOPGATE_CARRIER_ID')) { require_once _PS_MODULE_DIR_ . 'shopgate/classes/PSShopgateOrder.php'; $shopgateOrder = PSShopgateOrder::instanceByCartId($this->id); $r[$this->id_address_delivery][$this->id_carrier . ',']['carrier_list'][$this->id_carrier] = array('price_with_tax' => $shopgateOrder->shipping_cost, 'price_without_tax' => 0, 'package_list' => array(0), 'product_list' => array(), 'instance' => new Carrier($this->id_carrier)); $r[$this->id_address_delivery][$this->id_carrier . ',']['is_best_price'] = 1; $r[$this->id_address_delivery][$this->id_carrier . ',']['is_best_grade'] = 1; $r[$this->id_address_delivery][$this->id_carrier . ',']['unique_carrier'] = 1; $r[$this->id_address_delivery][$this->id_carrier . ',']['total_price_with_tax'] = $shopgateOrder->shipping_cost; $r[$this->id_address_delivery][$this->id_carrier . ',']['total_price_without_tax'] = 0; $r[$this->id_address_delivery][$this->id_carrier . ',']['position'] = 0; } return $r; }
public function updateOrder(ShopgateOrder $order) { $shopgateOrder = PSShopgateOrder::instanceByOrderNumber($order->getOrderNumber()); if (!Validate::isLoadedObject($shopgateOrder)) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_ORDER_NOT_FOUND, 'Order not found', true); } $order_states = array(); if ($order->getUpdatePayment() && $order->getIsPaid()) { array_push($order_states, $this->getOrderStateId('PS_OS_PAYMENT')); } if ($order->getUpdateShipping() && !$order->getIsShippingBlocked()) { array_push($order_states, $this->getOrderStateId('PS_OS_PREPARATION')); } if (count($order_states)) { $ps_order = new Order($shopgateOrder->id_order); foreach ($order_states as $id_order_state) { if (version_compare(_PS_VERSION_, '1.4.1.0', '<')) { $history = new OrderHistory(); $history->id_order = (int) $shopgateOrder->id_order; $history->changeIdOrderState((int) $id_order_state, (int) $shopgateOrder->id_order); } else { $ps_order->setCurrentState($id_order_state); } } } return array('external_order_id' => $shopgateOrder->id_order, 'external_order_number' => $shopgateOrder->id_order); }
public function hookAdminOrder($params) { include_once dirname(__FILE__) . '/backward_compatibility/backward.php'; $id_order = $params['id_order']; $shopgateOrder = PSShopgateOrder::instanceByOrderId($id_order); if (Tools::isSubmit('updateShopgateOrder')) { $shopgate_order = Tools::getValue('shopgateOrder'); $shippingService = $shopgate_order['shipping_service']; $trackingNumber = $shopgate_order['tracking_number']; if (isset($shippingService)) { try { $shopgateConfig = new ShopgateConfigPresta(); $shopgateBuilder = new ShopgateBuilder($shopgateConfig); $shopgateMerchantApi = $shopgateBuilder->buildMerchantApi(); $shopgateMerchantApi->addOrderDeliveryNote($shopgateOrder->order_number, $shippingService, $trackingNumber, true, false); } catch (ShopgateMerchantApiException $e) { $error = $e->getMessage(); } $shopgateOrder->shipping_service = $shippingService; $shopgateOrder->tracking_number = $trackingNumber; $shopgateOrder->update(); } } if (!Validate::isLoadedObject($shopgateOrder)) { return ''; } $sOrder = null; $error = null; try { $shopgateConfig = new ShopgateConfigPresta(); $shopgateBuilder = new ShopgateBuilder($shopgateConfig); $shopgateMerchantApi = $shopgateBuilder->buildMerchantApi(); $orders = $shopgateMerchantApi->getOrders(array('order_numbers[0]' => $shopgateOrder->order_number)); foreach ($orders->getData() as $o) { /* @var $o ShopgateOrder */ if ($o->getOrderNumber() == $shopgateOrder->order_number) { $sOrder = $o; } } } catch (ShopgateMerchantApiException $e) { $error = $e->getMessage(); } $paymentInfoStrings = array('shopgate_payment_name' => $this->l('Payment name'), 'upp_transaction_id' => $this->l('Transaction ID'), 'authorization' => $this->l('Authorization'), 'settlement' => $this->l('Settlement'), 'purpose' => $this->l('Purpose'), 'billsafe_transaction_id' => $this->l('Transaction ID'), 'reservation_number' => $this->l('Reservation number'), 'activation_invoice_number' => $this->l('Invoice activation number'), 'bank_account_holder' => $this->l('Account holder'), 'bank_account_number' => $this->l('Account number'), 'bank_code' => $this->l('Bank code'), 'bank_name' => $this->l('Bank name'), 'iban' => $this->l('IBAN'), 'bic' => $this->l('BIC'), 'transaction_id' => $this->l('Transaction ID'), 'payer_id' => $this->l('Payer ID'), 'payer_email' => $this->l('Payer email')); $sOrderDeliveryNotes = array(); foreach ($sOrder->getDeliveryNotes() as $notes) { $sOrderDeliveryNotes[] = array('shipping_service_id' => $notes->getShippingServiceId(), 'tracking_number' => $notes->getTrackingNumber(), 'shipping_time' => $notes->getShippingTime()); } // build comments $comments = array(); foreach ($sOrder->jsonDecode($shopgateOrder->comments) as $text => $information) { $comments[] = sprintf($this->l($text), $information); } $this->context->smarty->assign('sOrder', $sOrder); $this->context->smarty->assign('sOrderComments', $comments); $this->context->smarty->assign('sOrderPaymentInfos', $sOrder->getPaymentInfos()); $this->context->smarty->assign('sOrderDeliveryNotes', $sOrderDeliveryNotes); $this->context->smarty->assign('sShopNumber', $shopgateOrder->shop_number); $this->context->smarty->assign('shopgate_error', $error); $this->context->smarty->assign('paymentInfoStrings', $paymentInfoStrings); $this->context->smarty->assign('shopgateOrder', $shopgateOrder); $this->context->smarty->assign('shippingInfos', $sOrder->getShippingInfos()); $this->context->smarty->assign('shipping_service_list', $this->shipping_service_list); $this->context->smarty->assign('sModDir', $this->_path); $this->context->smarty->assign('api_url', Tools::getHttpHost(true, true) . $this->_path . 'api.php'); return $this->display(__FILE__, 'views/templates/admin/admin_order.tpl'); }