Esempio n. 1
0
 function create($zf_ot_modules, $zf_mode = 2)
 {
     global $db;
     $this->notify('NOTIFY_ORDER_CART_EXTERNAL_TAX_DURING_ORDER_CREATE', array(), $zf_ot_modules);
     if ($this->info['total'] == 0) {
         if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
             $this->info['order_status'] = (int) DEFAULT_ORDERS_STATUS_ID;
         } else {
             if ($_SESSION['payment'] != 'freecharger') {
                 $this->info['order_status'] = (int) DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
             }
         }
     }
     $this->notify('NOTIFY_ORDER_CART_ORDERSTATUS');
     if ($_SESSION['shipping']['id'] == 'free_free') {
         $this->info['shipping_module_code'] = $_SESSION['shipping']['id'];
     }
     // Sanitize cc-num if present, using maximum 10 chars, with middle chars stripped out with XX
     if (strlen($this->info['cc_number']) > 10) {
         $cEnd = substr($this->info['cc_number'], -4);
         $cOffset = strlen($this->info['cc_number']) - 4;
         $cStart = substr($this->info['cc_number'], 0, $cOffset > 4 ? 4 : (int) $cOffset);
         $this->info['cc_number'] = str_pad($cStart, 6, 'X') . $cEnd;
     }
     $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'customers_name' => $this->customer['firstname'] . ' ' . $this->customer['lastname'], 'customers_company' => $this->customer['company'], 'customers_street_address' => $this->customer['street_address'], 'customers_suburb' => $this->customer['suburb'], 'customers_city' => $this->customer['city'], 'customers_postcode' => $this->customer['postcode'], 'customers_state' => $this->customer['state'], 'customers_country' => $this->customer['country']['title'], 'customers_telephone' => $this->customer['telephone'], 'customers_email_address' => $this->customer['email_address'], 'customers_address_format_id' => $this->customer['format_id'], 'delivery_name' => $this->delivery['firstname'] . ' ' . $this->delivery['lastname'], 'delivery_company' => $this->delivery['company'], 'delivery_street_address' => $this->delivery['street_address'], 'delivery_suburb' => $this->delivery['suburb'], 'delivery_city' => $this->delivery['city'], 'delivery_postcode' => $this->delivery['postcode'], 'delivery_state' => $this->delivery['state'], 'delivery_country' => $this->delivery['country']['title'], 'delivery_address_format_id' => $this->delivery['format_id'], 'billing_name' => $this->billing['firstname'] . ' ' . $this->billing['lastname'], 'billing_company' => $this->billing['company'], 'billing_street_address' => $this->billing['street_address'], 'billing_suburb' => $this->billing['suburb'], 'billing_city' => $this->billing['city'], 'billing_postcode' => $this->billing['postcode'], 'billing_state' => $this->billing['state'], 'billing_country' => $this->billing['country']['title'], 'billing_address_format_id' => $this->billing['format_id'], 'payment_method' => ($this->info['payment_module_code'] == '' and $this->info['payment_method'] == '') ? PAYMENT_METHOD_GV : $this->info['payment_method'], 'payment_module_code' => ($this->info['payment_module_code'] == '' and $this->info['payment_method'] == '') ? PAYMENT_MODULE_GV : $this->info['payment_module_code'], 'shipping_method' => $this->info['shipping_method'], 'shipping_module_code' => strpos($this->info['shipping_module_code'], '_') > 0 ? substr($this->info['shipping_module_code'], 0, strpos($this->info['shipping_module_code'], '_')) : $this->info['shipping_module_code'], 'coupon_code' => $this->info['coupon_code'], 'cc_type' => $this->info['cc_type'], 'cc_owner' => $this->info['cc_owner'], 'cc_number' => $this->info['cc_number'], 'cc_expires' => $this->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $this->info['order_status'], 'order_total' => $this->info['total'], 'order_tax' => $this->info['tax'], 'currency' => $this->info['currency'], 'currency_value' => $this->info['currency_value'], 'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']);
     // BEGIN COWOA edit
     if ($_SESSION['COWOA']) {
         $sql_data_array[COWOA_order] = 1;
     }
     // END COWOA edit
     zen_db_perform(TABLE_ORDERS, $sql_data_array);
     $insert_id = $db->Insert_ID();
     // BEGIN Super Orders edit
     // add CC data as a line item to SO payment system
     if (zen_not_null($this->info['cc_type']) || zen_not_null($this->info['cc_owner']) || zen_not_null($this->info['cc_number'])) {
         require DIR_WS_CLASSES . 'super_order.php';
         $so = new super_order($insert_id);
         $so->cc_line_item();
     }
     // END Super Orders edit
     $this->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER', array_merge(array('orders_id' => $insert_id, 'shipping_weight' => $_SESSION['cart']->weight), $sql_data_array));
     for ($i = 0, $n = sizeof($zf_ot_modules); $i < $n; $i++) {
         $sql_data_array = array('orders_id' => $insert_id, 'title' => $zf_ot_modules[$i]['title'], 'text' => $zf_ot_modules[$i]['text'], 'value' => is_numeric($zf_ot_modules[$i]['value']) ? $zf_ot_modules[$i]['value'] : '0', 'class' => $zf_ot_modules[$i]['code'], 'sort_order' => $zf_ot_modules[$i]['sort_order']);
         zen_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
         $this->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDERTOTAL_LINE_ITEM', $sql_data_array);
     }
     $customer_notification = SEND_EMAILS == 'true' ? '1' : '0';
     $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $this->info['order_status'], 'date_added' => 'now()', 'customer_notified' => $customer_notification, 'comments' => $this->info['comments']);
     zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
     $this->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_COMMENT', $sql_data_array);
     return $insert_id;
 }