| 1 |
<?php |
| 2 |
/* order data class */ |
| 3 |
|
| 4 |
class orderDataObject |
| 5 |
{ |
| 6 |
var $customer; |
| 7 |
var $deliveri; |
| 8 |
var $cart; |
| 9 |
var $condition; |
| 10 |
var $order; |
| 11 |
var $reserve; |
| 12 |
|
| 13 |
function __construct($order_id) { |
| 14 |
global $usces, $wpdb, $usces_settings; |
| 15 |
|
| 16 |
$order_table = $wpdb->prefix . "usces_order"; |
| 17 |
$meta_table = $wpdb->prefix . "usces_order_meta"; |
| 18 |
$query = $wpdb->prepare("SELECT o.*, om.meta_value AS `order_country` |
| 19 |
FROM {$order_table} AS `o` |
| 20 |
LEFT JOIN {$meta_table} AS `om` ON o.ID = om.order_id AND om.meta_key = 'customer_country' |
| 21 |
WHERE o.ID = %d", $order_id); |
| 22 |
|
| 23 |
$data = $wpdb->get_row( $query, ARRAY_A ); |
| 24 |
|
| 25 |
$this->customer['mem_id'] = ( isset( $data['mem_id'] ) ) ? $data['mem_id'] : null; |
| 26 |
$this->customer['email'] = ( isset( $data['order_email'] ) ) ? $data['order_email'] : ''; |
| 27 |
$this->customer['name1'] = ( isset( $data['order_name1'] ) ) ? $data['order_name1'] : ''; |
| 28 |
$this->customer['name2'] = ( isset( $data['order_name2'] ) ) ? $data['order_name2'] : null; |
| 29 |
$this->customer['name3'] = ( isset( $data['order_name3'] ) ) ? $data['order_name3'] : null; |
| 30 |
$this->customer['name4'] = ( isset( $data['order_name4'] ) ) ? $data['order_name4'] : null; |
| 31 |
$this->customer['zip'] = ( isset( $data['order_zip'] ) ) ? $data['order_zip'] : null; |
| 32 |
$this->customer['pref'] = ( isset( $data['order_pref'] ) ) ? $data['order_pref'] : ''; |
| 33 |
$this->customer['address1'] = ( isset( $data['order_address1'] ) ) ? $data['order_address1'] : ''; |
| 34 |
$this->customer['address2'] = ( isset( $data['order_address2'] ) ) ? $data['order_address2'] : null; |
| 35 |
$this->customer['address3'] = ( isset( $data['order_address3'] ) ) ? $data['order_address3'] : null; |
| 36 |
$this->customer['tel'] = ( isset( $data['order_tel'] ) ) ? $data['order_tel'] : ''; |
| 37 |
$this->customer['fax'] = ( isset( $data['order_fax'] ) ) ? $data['order_fax'] : null; |
| 38 |
$this->customer['country_code'] = ( isset( $data['order_country'] ) ) ? $data['order_country'] : null; |
| 39 |
$this->customer['country'] = ( isset( $usces_settings['country'][$data['order_country']] ) ) ? $usces_settings['country'][$data['order_country']] : ''; |
| 40 |
|
| 41 |
$this->deliveri = (array) wel_safe_unserialize( $data['order_delivery'] ); |
| 42 |
|
| 43 |
$this->cart = usces_get_ordercartdata( $order_id ); |
| 44 |
|
| 45 |
$this->condition = (array) wel_safe_unserialize( $data['order_condition'] ); |
| 46 |
|
| 47 |
$this->order['ID'] = $order_id; |
| 48 |
$this->order['note'] = ( isset( $data['order_note'] ) ) ? $data['order_note'] : null; |
| 49 |
$this->order['delidue_date'] = ( isset( $data['order_delidue_date'] ) ) ? $data['order_delidue_date'] : null; |
| 50 |
$this->order['delivery_date'] = ( isset( $data['order_delivery_date'] ) ) ? $data['order_delivery_date'] : null; |
| 51 |
$this->order['delivery_time'] = ( isset( $data['order_delivery_time'] ) ) ? $data['order_delivery_time'] : ''; |
| 52 |
$this->order['delivery_method'] = ( isset( $data['order_delivery_method'] ) ) ? $data['order_delivery_method'] : -1; |
| 53 |
$this->order['payment_name'] = ( isset( $data['order_payment_name'] ) ) ? $data['order_payment_name'] : ''; |
| 54 |
$this->order['item_total_price'] = ( isset( $data['order_item_total_price'] ) ) ? $data['order_item_total_price'] : 0.00; |
| 55 |
$this->order['getpoint'] = ( isset( $data['order_getpoint'] ) ) ? $data['order_getpoint'] : 0; |
| 56 |
$this->order['usedpoint'] = ( isset( $data['order_usedpoint'] ) ) ? $data['order_usedpoint'] : 0; |
| 57 |
$this->order['discount'] = ( isset( $data['order_discount'] ) ) ? $data['order_discount'] : 0.00; |
| 58 |
$this->order['shipping_charge'] = ( isset( $data['order_shipping_charge'] ) ) ? $data['order_shipping_charge'] : 0.00; |
| 59 |
$this->order['cod_fee'] = ( isset( $data['order_cod_fee'] ) ) ? $data['order_cod_fee'] : 0.00; |
| 60 |
$this->order['tax'] = ( isset( $data['order_tax'] ) ) ? $data['order_tax'] : 0.00; |
| 61 |
$this->order['date'] = ( isset( $data['order_date'] ) ) ? $data['order_date'] : '0000-00-00 00:00:00'; |
| 62 |
$this->order['modified'] = ( isset( $data['order_modified'] ) ) ? $data['order_modified'] : null; |
| 63 |
$this->order['status'] = ( isset( $data['order_status'] ) ) ? $data['order_status'] : null; |
| 64 |
$this->order['check'] = ( isset( $data['order_check'] ) ) ? $data['order_check'] : null; |
| 65 |
$this->order['total_full_price'] = $data['order_item_total_price'] - $data['order_usedpoint'] + $data['order_discount'] + $data['order_shipping_charge'] + $data['order_cod_fee'] + $data['order_tax']; |
| 66 |
if( $this->order['total_full_price'] < 0 ) $this->order['total_full_price'] = 0; |
| 67 |
$this->order['order_memo'] = $usces->get_order_meta_value( 'order_memo', $order_id ); |
| 68 |
|
| 69 |
$this->reserve = array(); |
| 70 |
} |
| 71 |
} |
| 72 |
|