public function hookActionObjectOrderAddAfter($params)
 {
     $SalesOrderMapper = new SalesOrderMapper();
     $SalesOrderMapper->processLocalUpdate($params['object'], true, false);
 }
 protected function mapModelToConnecResource($order)
 {
     $order_hash = array();
     // Missing transaction lines are considered as deleted by Connec!
     $order_hash['opts'] = array('sparse' => false);
     // Get customer mno_id_map
     $customerMnoIdMap = MnoIdMap::findMnoIdMapByLocalIdAndEntityName($order->id_customer, 'CUSTOMERS');
     $customerInfo = $this->loadCustomerByID($order->id_customer);
     $order_hash['code'] = $order->reference;
     $order_hash['title'] = 'Prestashop order #' . $order->id_cart . " (" . $customerInfo['firstname'] . " " . $customerInfo['lastname'] . ")";
     $order_hash['transaction_number'] = $order->id_cart;
     $order_hash['transaction_date'] = $order->date_add;
     $order_hash['due_date'] = $order->date_add;
     // Order Status Default set "SUBMITTED"
     $order_hash['status'] = 'SUBMITTED';
     $order_hash['private_note'] = "Generated by Prestashop\n" . $order_hash['title'];
     $order_hash['person_id'] = $customerMnoIdMap['mno_entity_guid'];
     // Total Amount of cart
     $order_hash['amount'] = $order->total_paid;
     // Shipping and Billing Address
     $billingAddress = $this->getAddress($order->id_address_invoice);
     $shippingAddress = $this->getAddress($order->id_address_delivery);
     $billing = array('attention_first_name' => $billingAddress['firstname'], 'attention_last_name' => $billingAddress['lastname'], 'line1' => $billingAddress['address1'], 'line2' => $billingAddress['address2'], 'city' => $billingAddress['city'], 'postal_code' => $billingAddress['postcode'], 'region' => $billingAddress['state_code'], 'country' => $billingAddress['country_code']);
     $shipping = array('attention_first_name' => $shippingAddress['firstname'], 'attention_last_name' => $shippingAddress['lastname'], 'line1' => $shippingAddress['address1'], 'line2' => $shippingAddress['address2'], 'city' => $shippingAddress['city'], 'postal_code' => $shippingAddress['postcode'], 'region' => $shippingAddress['state_code'], 'country' => $shippingAddress['country_code']);
     $order_hash['billing_address'] = $billing;
     $order_hash['shipping_address'] = $shipping;
     // Products In cart
     $items = $order->product_list;
     if (count($items) > 0) {
         $order_hash['lines'] = array();
         $line_number = 1;
         foreach ($items as $item) {
             $line_hash = array();
             $line_hash['status'] = 'ACTIVE';
             $line_hash['line_number'] = $line_number;
             //get the Product MnoID Map
             $productMnoIdMap = MnoIdMap::findMnoIdMapByLocalIdAndEntityName($item['id_product'], 'Products');
             $line_hash['item_id'] = $productMnoIdMap['mno_entity_guid'];
             $line_hash['description'] = $item['description_short'];
             $line_hash['quantity'] = $item['cart_quantity'];
             $line_hash['unit_price'] = array();
             $line_hash['unit_price']['total_amount'] = $item['price_wt'];
             //Unit Price including Tax
             $line_hash['unit_price']['tax_rate'] = $item['rate'];
             $line_hash['total_price'] = array();
             $line_hash['total_price']['total_amount'] = $item['total_wt'];
             //Total Price including Tax
             $line_hash['total_price']['tax_rate'] = $item['rate'];
             $line_hash['total_price']['tax_amount'] = $item['rate'];
             $tax_code_id = SalesOrderMapper::mapTaxToConnecResource($item['id_product']);
             if ($tax_code_id != "") {
                 $line_hash['tax_code_id'] = $tax_code_id;
             }
             $order_hash['lines'][] = $line_hash;
             $line_number++;
         }
     }
     // Add Shipping if applicable
     if ($order->total_shipping > 0) {
         $line_hash = array();
         $line_hash['description'] = "Prestashop Shipping";
         $line_hash['is_shipping'] = true;
         $line_hash['quantity'] = 1;
         $line_hash['unit_price'] = array();
         $line_hash['unit_price']['total_amount'] = $order->total_shipping_tax_incl;
         $line_hash['total_price']['total_amount'] = $order->total_shipping_tax_incl;
         $order_hash['lines'][] = $line_hash;
     }
     //echo '<pre>'; print_R($order_hash); echo '</pre>'; die();
     return $order_hash;
 }