[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: order.php v5.0 07/19/2007 djmonkey1 Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 class manualOrder { 14 var $info, $totals, $products, $customer, $delivery; 15 16 function manualOrder($order_id) { 17 $this->info = array(); 18 $this->totals = array(); 19 $this->products = array(); 20 $this->customer = array(); 21 $this->delivery = array(); 22 23 $this->query($order_id); 24 } 25 26 function query($order_id) { 27 global $shipping; 28 29 $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); 30 $order = tep_db_fetch_array($order_query); 31 32 $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); 33 34 while ($totals = tep_db_fetch_array($totals_query)) { 35 $this->totals[] = array( 36 'title' => $totals['title'], 37 'text' => $totals['text'], 38 'class' => $totals['class'], 39 'value' => $totals['value'], 40 'sort_order' => $totals['sort_order'], 41 'orders_total_id' => $totals['orders_total_id']); 42 } 43 44 $this->info = array('currency' => $order['currency'], 45 'currency_value' => $order['currency_value'], 46 'payment_method' => $order['payment_method'], 47 'cc_type' => $order['cc_type'], 48 'cc_owner' => $order['cc_owner'], 49 'cc_number' => $order['cc_number'], 50 'cc_expires' => $order['cc_expires'], 51 'date_purchased' => $order['date_purchased'], 52 'orders_status' => $order['orders_status'], 53 'last_modified' => $order['last_modified'], 54 'shipping_method' => $shipping['title'], 55 'shipping_cost' => $shipping['cost'], 56 'shipping_id' => $order['shipping_module'], 57 'subtotal' => 0, 58 'tax' => 0, 59 'tax_groups' => array()); 60 61 $this->customer = array('id' => $order['customers_id'], 62 'name' => $order['customers_name'], 63 'company' => $order['customers_company'], 64 'street_address' => $order['customers_street_address'], 65 'suburb' => $order['customers_suburb'], 66 'city' => $order['customers_city'], 67 'postcode' => $order['customers_postcode'], 68 'state' => $order['customers_state'], 69 'country' => $order['customers_country'], 70 'country_id' => oe_get_country_id($order['customers_country']), 71 'zone_id' => oe_get_zone_id(oe_get_country_id($order['customers_country']), $order['customers_state']), 72 'format_id' => $order['customers_address_format_id'], 73 'telephone' => $order['customers_telephone'], 74 'email_address' => $order['customers_email_address']); 75 76 $this->delivery = array('name' => $order['delivery_name'], 77 'company' => $order['delivery_company'], 78 'street_address' => $order['delivery_street_address'], 79 'suburb' => $order['delivery_suburb'], 80 'city' => $order['delivery_city'], 81 'postcode' => $order['delivery_postcode'], 82 'state' => $order['delivery_state'], 83 'country' => $order['delivery_country'], 84 'country_id' => oe_get_country_id($order['delivery_country']), 85 'zone_id' => oe_get_zone_id(oe_get_country_id($order['delivery_country']), $order['delivery_state']), 86 'format_id' => $order['delivery_address_format_id']); 87 88 $this->billing = array('name' => $order['billing_name'], 89 'company' => $order['billing_company'], 90 'street_address' => $order['billing_street_address'], 91 'suburb' => $order['billing_suburb'], 92 'city' => $order['billing_city'], 93 'postcode' => $order['billing_postcode'], 94 'state' => $order['billing_state'], 95 'country' => $order['billing_country'], 96 'country_id' => oe_get_country_id($order['billing_country']), 97 'zone_id' => oe_get_zone_id(oe_get_country_id($order['billing_country']), $order['billing_state']), 98 'format_id' => $order['billing_address_format_id']); 99 100 101 $index = 0; 102 $orders_products_query = tep_db_query("select op.orders_products_id, op.products_id, op.products_name, op.products_model, op.products_price, op.products_tax, op.products_quantity, op.final_price, p.products_tax_class_id, p.products_weight, p.products_id from " . TABLE_ORDERS_PRODUCTS . " op INNER JOIN " . TABLE_PRODUCTS . " p on op.products_id = p.products_id where orders_id = '" . (int)$order_id . "' order by op.orders_products_id"); 103 104 while ($orders_products = tep_db_fetch_array($orders_products_query)) { 105 $orders_products_tax_query = tep_db_query("select products_tax_class_id from " .TABLE_PRODUCTS . " where products_id = " . $orders_products['products_id'] . ""); 106 $orders_products_tax = tep_db_fetch_array($orders_products_tax_query); 107 $this->products[$index] = array( 108 'qty' => $orders_products['products_quantity'], 109 'name' => $orders_products['products_name'], 110 'model' => $orders_products['products_model'], 111 'tax' => $orders_products['products_tax'], 112 'tax_description' => tep_get_tax_description($orders_products_tax['products_tax_class_id'], $this->delivery["country_id"], $this->delivery["zone_id"]), 113 'price' => $orders_products['products_price'], 114 'final_price' => $orders_products['final_price'], 115 'weight' => $orders_products['products_weight'], 116 'products_id' => $orders_products['products_id'], 117 'orders_products_id' => $orders_products['orders_products_id']); 118 119 $subindex = 0; 120 $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); 121 if (tep_db_num_rows($attributes_query)) { 122 while ($attributes = tep_db_fetch_array($attributes_query)) { 123 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 124 'value' => $attributes['products_options_values'], 125 'prefix' => $attributes['price_prefix'], 126 'price' => $attributes['options_values_price'], 127 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); 128 129 $subindex++; 130 } 131 } 132 133 $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; 134 $this->info['subtotal'] += $shown_price; 135 136 $products_tax = $this->products[$index]['tax']; 137 $products_tax_description = $this->products[$index]['tax_description']; 138 if (DISPLAY_PRICE_WITH_TAX == 'true') { 139 $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); 140 if (isset($this->info['tax_groups']["$products_tax_description"])) { 141 $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); 142 } else { 143 $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); 144 } 145 } else { 146 $this->info['tax'] += ($products_tax / 100) * $shown_price; 147 if (isset($this->info['tax_groups']["$products_tax_description"])) { 148 $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; 149 } else { 150 $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; 151 } 152 } 153 154 $index++; 155 } 156 157 if (DISPLAY_PRICE_WITH_TAX == 'true') { 158 $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; 159 } else { 160 $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; 161 } 162 } 163 164 function adjust_zones() { 165 $customer_country_id = oe_get_country_id($this->customer['country']); 166 $this->customer['country'] = array('id' => $customer_country_id, 167 'title' => $this->customer['country'], 168 'iso_code_2' => oe_get_country_iso_code_2($customer_country_id), 169 'iso_code_3' => oe_get_country_iso_code_3($customer_country_id)); 170 $this->customer['zone_id'] = oe_get_zone_id($customer_country_id, $this->customer['state']); 171 172 $billing_country_id = oe_get_country_id($this->billing['country']); 173 $this->billing['country'] = array('id' => $billing_country_id, 174 'title' => $this->billing['country'], 175 'iso_code_2' => oe_get_country_iso_code_2($billing_country_id), 176 'iso_code_3' => oe_get_country_iso_code_3($billing_country_id)); 177 $this->billing['zone_id'] = oe_get_zone_id($billing_country_id, $this->billing['state']); 178 179 $delivery_country_id = oe_get_country_id($this->delivery['country']); 180 $this->delivery['country'] = array('id' => $delivery_country_id, 181 'title' => $this->delivery['country'], 182 'iso_code_2' => oe_get_country_iso_code_2($delivery_country_id), 183 'iso_code_3' => oe_get_country_iso_code_3($delivery_country_id)); 184 $this->delivery['zone_id'] = oe_get_zone_id($delivery_country_id, $this->delivery['state']); 185 } 186 187 function adjust_totals($order_id) { 188 $totals_query = tep_db_query("select orders_total_id, title, text, class, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); 189 $this->totals = array(); 190 $i=0; 191 while ($totals = tep_db_fetch_array($totals_query)) { 192 if ($totals['class'] == 'ot_shipping') $shipping_index = $i; 193 $this->totals[] = array('title' => $totals['title'], 194 'text' => $totals['text'], 195 'class' => $totals['class'], 196 'value' => $totals['value'], 197 'orders_total_id' => $totals['orders_total_id']); 198 $this->totals[] = array('title' => '', 199 'text' => '', 200 'class' => 'ot_custom', 201 'value' => '', 202 'orders_total_id' => '0'); 203 $i=$i+2; 204 } 205 array_pop($this->totals); 206 207 return $shipping_index; 208 } 209 210 211 } 212 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |