|
ZenCart_Documentation
1.5.0
http://www.collinsharper.com
|
00001 <?php 00010 class order { 00011 var $info, $totals, $products, $customer, $delivery; 00012 00013 function order($order_id) { 00014 $this->info = array(); 00015 $this->totals = array(); 00016 $this->products = array(); 00017 $this->customer = array(); 00018 $this->delivery = array(); 00019 00020 $this->query($order_id); 00021 } 00022 00023 function query($order_id) { 00024 global $db; 00025 $order = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address, 00026 customers_suburb, customers_city, customers_postcode, customers_id, 00027 customers_state, customers_country, customers_telephone, 00028 customers_email_address, customers_address_format_id, delivery_name, 00029 delivery_company, delivery_street_address, delivery_suburb, 00030 delivery_city, delivery_postcode, delivery_state, delivery_country, 00031 delivery_address_format_id, billing_name, billing_company, 00032 billing_street_address, billing_suburb, billing_city, billing_postcode, 00033 billing_state, billing_country, billing_address_format_id, 00034 coupon_code, payment_method, payment_module_code, shipping_method, shipping_module_code, 00035 cc_type, cc_owner, cc_number, cc_expires, currency, 00036 currency_value, date_purchased, orders_status, last_modified, 00037 order_total, order_tax, ip_address 00038 from " . TABLE_ORDERS . " 00039 where orders_id = '" . (int)$order_id . "'"); 00040 00041 00042 $totals = $db->Execute("select title, text, class, value 00043 from " . TABLE_ORDERS_TOTAL . " 00044 where orders_id = '" . (int)$order_id . "' 00045 order by sort_order"); 00046 00047 while (!$totals->EOF) { 00048 if ($totals->fields['class'] == 'ot_coupon') { 00049 $coupon_link_query = "SELECT coupon_id 00050 from " . TABLE_COUPONS . " 00051 where coupon_code ='" . zen_db_input($order->fields['coupon_code']) . "'"; 00052 $coupon_link = $db->Execute($coupon_link_query); 00053 $zc_coupon_link = '<a href="javascript:couponpopupWindow(\'' . zen_catalog_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $coupon_link->fields['coupon_id']) . '\')">'; 00054 } 00055 $this->totals[] = array('title' => ($totals->fields['class'] == 'ot_coupon' ? $zc_coupon_link . $totals->fields['title'] . '</a>' : $totals->fields['title']), 00056 'text' => $totals->fields['text'], 00057 'value' => $totals->fields['value'], 00058 'class' => $totals->fields['class']); 00059 $totals->MoveNext(); 00060 } 00061 00062 $this->info = array('currency' => $order->fields['currency'], 00063 'currency_value' => $order->fields['currency_value'], 00064 'payment_method' => $order->fields['payment_method'], 00065 'payment_module_code' => $order->fields['payment_module_code'], 00066 'shipping_method' => $order->fields['shipping_method'], 00067 'shipping_module_code' => $order->fields['shipping_module_code'], 00068 'coupon_code' => $order->fields['coupon_code'], 00069 'cc_type' => $order->fields['cc_type'], 00070 'cc_owner' => $order->fields['cc_owner'], 00071 'cc_number' => $order->fields['cc_number'], 00072 'cc_cvv' => $order->fields['cc_cvv'], 00073 'cc_expires' => $order->fields['cc_expires'], 00074 'date_purchased' => $order->fields['date_purchased'], 00075 'orders_status' => $order->fields['orders_status'], 00076 'total' => $order->fields['order_total'], 00077 'tax' => $order->fields['order_tax'], 00078 'last_modified' => $order->fields['last_modified'], 00079 'ip_address' => $order->fields['ip_address'] 00080 ); 00081 00082 $this->customer = array('name' => $order->fields['customers_name'], 00083 'id' => $order->fields['customers_id'], 00084 'company' => $order->fields['customers_company'], 00085 'street_address' => $order->fields['customers_street_address'], 00086 'suburb' => $order->fields['customers_suburb'], 00087 'city' => $order->fields['customers_city'], 00088 'postcode' => $order->fields['customers_postcode'], 00089 'state' => $order->fields['customers_state'], 00090 'country' => $order->fields['customers_country'], 00091 'format_id' => $order->fields['customers_address_format_id'], 00092 'telephone' => $order->fields['customers_telephone'], 00093 'email_address' => $order->fields['customers_email_address']); 00094 00095 $this->delivery = array('name' => $order->fields['delivery_name'], 00096 'company' => $order->fields['delivery_company'], 00097 'street_address' => $order->fields['delivery_street_address'], 00098 'suburb' => $order->fields['delivery_suburb'], 00099 'city' => $order->fields['delivery_city'], 00100 'postcode' => $order->fields['delivery_postcode'], 00101 'state' => $order->fields['delivery_state'], 00102 'country' => $order->fields['delivery_country'], 00103 'format_id' => $order->fields['delivery_address_format_id']); 00104 00105 $this->billing = array('name' => $order->fields['billing_name'], 00106 'company' => $order->fields['billing_company'], 00107 'street_address' => $order->fields['billing_street_address'], 00108 'suburb' => $order->fields['billing_suburb'], 00109 'city' => $order->fields['billing_city'], 00110 'postcode' => $order->fields['billing_postcode'], 00111 'state' => $order->fields['billing_state'], 00112 'country' => $order->fields['billing_country'], 00113 'format_id' => $order->fields['billing_address_format_id']); 00114 00115 $index = 0; 00116 $orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model, 00117 products_price, products_tax, products_quantity, 00118 final_price, onetime_charges, 00119 product_is_free 00120 from " . TABLE_ORDERS_PRODUCTS . " 00121 where orders_id = '" . (int)$order_id . "' 00122 order by orders_products_id"); 00123 00124 while (!$orders_products->EOF) { 00125 // convert quantity to proper decimals - account history 00126 if (QUANTITY_DECIMALS != 0) { 00127 $fix_qty = $orders_products->fields['products_quantity']; 00128 switch (true) { 00129 case (!strstr($fix_qty, '.')): 00130 $new_qty = $fix_qty; 00131 break; 00132 default: 00133 $new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']); 00134 break; 00135 } 00136 } else { 00137 $new_qty = $orders_products->fields['products_quantity']; 00138 } 00139 00140 $new_qty = round($new_qty, QUANTITY_DECIMALS); 00141 00142 if ($new_qty == (int)$new_qty) { 00143 $new_qty = (int)$new_qty; 00144 } 00145 00146 $this->products[$index] = array('qty' => $new_qty, 00147 'id' => $orders_products->fields['products_id'], 00148 'name' => $orders_products->fields['products_name'], 00149 'model' => $orders_products->fields['products_model'], 00150 'tax' => $orders_products->fields['products_tax'], 00151 'price' => $orders_products->fields['products_price'], 00152 'onetime_charges' => $orders_products->fields['onetime_charges'], 00153 'final_price' => $orders_products->fields['final_price'], 00154 'product_is_free' => $orders_products->fields['product_is_free']); 00155 00156 $subindex = 0; 00157 $attributes = $db->Execute("select products_options, products_options_values, options_values_price, 00158 price_prefix, 00159 product_attribute_is_free 00160 from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " 00161 where orders_id = '" . (int)$order_id . "' 00162 and orders_products_id = '" . (int)$orders_products->fields['orders_products_id'] . "'"); 00163 if ($attributes->RecordCount()>0) { 00164 while (!$attributes->EOF) { 00165 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options'], 00166 'value' => $attributes->fields['products_options_values'], 00167 'prefix' => $attributes->fields['price_prefix'], 00168 'price' => $attributes->fields['options_values_price'], 00169 'product_attribute_is_free' =>$attributes->fields['product_attribute_is_free']); 00170 00171 $subindex++; 00172 $attributes->MoveNext(); 00173 } 00174 } 00175 $index++; 00176 $orders_products->MoveNext(); 00177 } 00178 } 00179 }