private function getDejalaCart($cartId) { return DejalaCart::getInstance($cartId); }
public function placeOrder($mOrder) { $orderID = $mOrder->id; $this->myLog("placeOrder()"); $this->myLog("mOrder->id_carrier=" . $mOrder->id_carrier); $mCarrier = new Carrier($mOrder->id_carrier); $this->myLog("mCarrier->name=" . $mCarrier->name); if ($mCarrier->name != $this->name) { return; } $this->myLog("placeOrder()"); $id_cart = $mOrder->id_cart; $djlCart = new DejalaCart($id_cart); $this->myLog("djlCart->id_delivery=" . $djlCart->id_delivery); if (!$djlCart->id_delivery) { $this->myLog("id_delivery is not filled"); $delivery = array(); $this->getInfoFromOrder($orderID, $delivery); $this->mylog("Sending delivery=" . $this->logValue($delivery)); $djlUtil = new DejalaUtils(); $response = $djlUtil->orderDelivery($this->dejalaConfig, $delivery, $djlCart->mode); $statusCode = $response['status']; $this->mylog("send orderID=" . $orderID); $this->mylog("sendOrder status_code=" . $statusCode); $this->mylog("sendOrder response=" . $response['response']); $this->mylog("sendOrder delivery=" . $this->logValue($delivery, 1)); // update status after sending... if ("201" === $statusCode) { $this->mylog("updating dejala cart cart_id=" . $id_cart); if (Validate::isUnsignedId($delivery['id'])) { $this->mylog("updating dejala cart id_delivery=" . $delivery['id']); $djlCart->id_delivery = $delivery['id']; $djlCart->update(); } if (is_null($mOrder->shipping_number) || 0 === strlen($mOrder->shipping_number)) { $this->myLog('setting Order->shipping_number to ' . $delivery['tracking_number']); $mOrder->shipping_number = $delivery['tracking_number']; $mOrder->save(); } $this->myLog("OK - Order sent to dejala.fr"); } else { // Do nothing : Keep previous status $this->myLog("NOK - Problem sending Order to dejala.fr"); } } }