PluginProbe
Welcart e-Commerce / 1.3.2
Welcart e-Commerce v1.3.2
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / functions / function.php

function.php in Welcart e-Commerce 1.3.2, at functions/function.php

4,085 lines 152.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function usces_ajax_send_mail() {
4 global $wpdb, $usces;
5
6 $_POST = $usces->stripslashes_deep_post($_POST);
7 $order_para = array(
8 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), trim(urldecode($_POST['name']))),
9 'to_address' => trim($_POST['mailaddress']),
10 'from_name' => get_option('blogname'),
11 'from_address' => $usces->options['sender_mail'],
12 'return_path' => $usces->options['sender_mail'],
13 'subject' => trim(urldecode($_POST['subject'])),
14 'message' => trim(urldecode($_POST['message']))
15 );
16
17 $order_para = apply_filters( 'usces_ajax_send_mail_para_to_customer', $order_para);
18 $res = usces_send_mail( $order_para );
19 if($res){
20 $tableName = $wpdb->prefix . "usces_order";
21 $order_id = $_POST['order_id'];
22 $checked = $_POST['checked'];
23
24 $query = $wpdb->prepare("SELECT `order_check` FROM $tableName WHERE ID = %d", $order_id);
25 $res = $wpdb->get_var( $query );
26
27 $checkfield = unserialize($res);
28 if( !isset($checkfield[$checked]) ) $checkfield[$checked] = $checked;
29 //$checkfield = 'OK';
30 $query = $wpdb->prepare("UPDATE $tableName SET `order_check`=%s WHERE ID = %d", serialize($checkfield), $order_id);
31 $wpdb->query( $query );
32
33 $bcc_para = array(
34 'to_name' => 'Shop Admin',
35 'to_address' => $usces->options['order_mail'],
36 'from_name' => 'Welcart Auto BCC',
37 'from_address' => $usces->options['sender_mail'],
38 'return_path' => $usces->options['sender_mail'],
39 'subject' => trim(urldecode($_POST['subject'])) . ' to ' . sprintf(__('Mr/Mrs %s', 'usces'), trim(urldecode($_POST['name']))),
40 'message' => trim(urldecode($_POST['message']))
41 );
42
43 $bcc_para = apply_filters( 'usces_ajax_send_mail_para_to_manager', $bcc_para);
44 usces_send_mail( $bcc_para );
45
46 return 'success';
47 }else{
48 return 'error';
49 }
50 }
51
52 function usces_order_confirm_message($order_id) {
53 global $usces, $wpdb, $usces_settings;
54
55 $tableName = $wpdb->prefix . "usces_order";
56 $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id);
57 $data = $wpdb->get_row( $query, ARRAY_A );
58 $deli = unserialize($data['order_delivery']);
59 $cart = unserialize($data['order_cart']);
60 $country = $usces->get_order_meta_value('customer_country', $order_id);
61 $customer = array(
62 'name1' => $data['order_name1'],
63 'name2' => $data['order_name2'],
64 'name3' => $data['order_name3'],
65 'name4' => $data['order_name4'],
66 'zipcode' => $data['order_zip'],
67 'country' => $country,
68 'pref' => $data['order_pref'],
69 'address1' => $data['order_address1'],
70 'address2' => $data['order_address2'],
71 'address3' => $data['order_address3'],
72 'tel' => $data['order_tel'],
73 'fax' => $data['order_fax'],
74 );
75 $condition = unserialize($data['order_condition']);
76
77 $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'];
78
79
80 $mail_data = $usces->options['mail_data'];
81 $payment = $usces->getPayments( $data['order_payment_name'] );
82 $res = false;
83
84 if($_POST['mode'] == 'mitumoriConfirmMail'){
85 $msg_body = "\r\n\r\n\r\n" . __('Estimate','usces') . "\r\n";
86 $msg_body .= usces_mail_line( 1, $data['order_email'] );//********************
87 $msg_body .= apply_filters('usces_filter_order_confirm_mail_first', NULL, $data);
88 $msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id );
89 $msg_body .= __('estimate number','usces') . " : " . $order_id . "\r\n";
90 }else{
91 $msg_body = "\r\n\r\n\r\n" . __('** Article order contents **','usces') . "\r\n";
92 $msg_body .= usces_mail_line( 1, $data['order_email'] );//********************
93 $msg_body .= apply_filters('usces_filter_order_confirm_mail_first', NULL, $data);
94 $msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id );
95 $msg_body .= __('Order number','usces') . " : " . usces_get_deco_order_id( $order_id ) . "\r\n";
96 }
97
98 $meisai = __('Items','usces') . " : \r\n";
99 foreach ( (array)$cart as $cart_row ) {
100 $post_id = $cart_row['post_id'];
101 $sku = urldecode($cart_row['sku']);
102 $quantity = $cart_row['quantity'];
103 $options = $cart_row['options'];
104 $itemCode = $usces->getItemCode($post_id);
105 $itemName = $usces->getItemName($post_id);
106 $cartItemName = $usces->getCartItemName($post_id, $sku);
107 $skuPrice = $cart_row['price'];
108 // $pictids = $usces->get_pictids($itemCode);
109 if (!empty($options)) {
110 // $optstr = implode(',', $options);
111 } else {
112 $optstr = '';
113 $options = array();
114 }
115
116 $meisai .= usces_mail_line( 2, $data['order_email'] );//--------------------
117 $meisai .= "$cartItemName \r\n";
118 if( is_array($options) && count($options) > 0 ){
119 $optstr = '';
120 foreach($options as $key => $value){
121 //20110629ysk start 0000190
122 //if( !empty($key) )
123 // $meisai .= $key . ' : ' . urldecode($value) . "\r\n";
124 if( !empty($key) ) {
125 $key = urldecode($key);
126 if(is_array($value)) {
127 $c = '';
128 $optstr .= $key . ' : ';
129 foreach($value as $v) {
130 $optstr .= $c.urldecode($v);
131 $c = ', ';
132 }
133 $optstr .= "\r\n";
134 } else {
135 $optstr .= $key . ' : ' . urldecode($value) . "\r\n";
136 }
137 }
138 //20110629ysk end
139 }
140 $meisai .= apply_filters( 'usces_filter_option_adminmail', $optstr, $options);
141 }
142 $meisai .= __('Unit price','usces') . " ".usces_crform( $skuPrice, true, false, 'return' ) . __(' * ','usces') . $cart_row['quantity'] . "\r\n";
143 }
144
145 $meisai .= usces_mail_line( 3, $data['order_email'] );//====================
146 $meisai .= __('total items','usces') . " : " . usces_crform( $data['order_item_total_price'], true, false, 'return' ) . "\r\n";
147
148 if ( $data['order_usedpoint'] != 0 )
149 $meisai .= __('use of points','usces') . " : " . number_format($data['order_usedpoint']) . __('Points','usces') . "\r\n";
150 if ( $data['order_discount'] != 0 )
151 $meisai .= apply_filters('usces_confirm_discount_label', __('Campaign disnount', 'usces'), $order_id) . " : " . usces_crform( $data['order_discount'], true, false, 'return' ) . "\r\n";
152 $meisai .= __('Shipping','usces') . " : " . usces_crform( $data['order_shipping_charge'], true, false, 'return' ) . "\r\n";
153 if ( $payment['settlement'] == 'COD' )
154 $meisai .= apply_filters('usces_filter_cod_label', __('COD fee', 'usces')) . " : " . usces_crform( $data['order_cod_fee'], true, false, 'return' ) . "\r\n";
155 if ( !empty($usces->options['tax_rate']) )
156 $meisai .= __('consumption tax','usces') . " : " . usces_crform( $data['order_tax'], true, false, 'return' ) . "\r\n";
157 $meisai .= usces_mail_line( 2, $data['order_email'] );//--------------------
158 $meisai .= __('Payment amount','usces') . " : " . usces_crform( $total_full_price, true, false, 'return' ) . "\r\n";
159 $meisai .= usces_mail_line( 2, $data['order_email'] );//--------------------
160 $meisai .= "(" . __('Currency', 'usces') . ' : ' . __(usces_crcode( 'return' ), 'usces') . ")\r\n\r\n";
161
162 $msg_body .= apply_filters('usces_filter_order_confirm_mail_meisai', $meisai, $data, $cart);
163
164
165
166 $msg_shipping = __('** A shipping address **','usces') . "\r\n";
167 $msg_shipping .= usces_mail_line( 1, $data['order_email'] );//********************
168
169 $msg_shipping .= uesces_get_mail_addressform( 'admin_mail', $deli, $order_id );
170
171 //20101208ysk start
172 //$msg_shipping .= __('Delivery Time','usces') . " : " . $data['order_delivery_time'] . "\r\n";
173 if ( $data['order_delidue_date'] == NULL || $data['order_delidue_date'] == '#none#' ) {
174 $msg_shipping .= "\r\n";
175 }else{
176 $msg_shipping .= __('Shipping date', 'usces') . " : " . $data['order_delidue_date'] . "\r\n";
177 $msg_shipping .= __("* A shipment due date is a day to ship an article, and it's not the arrival day.", 'usces') . "\r\n";
178 $msg_shipping .= "\r\n";
179 }
180 $deli_meth = (int)$data['order_delivery_method'];
181 if( 0 <= $deli_meth ){
182 $deli_index = $usces->get_delivery_method_index($deli_meth);
183 $msg_shipping .= __('Delivery Method','usces') . " : " . $usces->options['delivery_method'][$deli_index]['name'] . "\r\n";
184 }
185 $msg_shipping .= __('Delivery date','usces') . " : " . $data['order_delivery_date'] . "\r\n";
186 $msg_shipping .= __('Delivery Time','usces') . " : " . $data['order_delivery_time'] . "\r\n";
187 //20101208ysk end
188 $msg_shipping .= "\r\n";
189 $msg_body .= apply_filters('usces_filter_order_confirm_mail_shipping', $msg_shipping, $data);
190
191 // $msg_body .= __('** For some region, to deliver the items in the morning is not possible.','usces') . "\r\n";
192 // $msg_body .= __('** WE may not always be able to deliver the items on time which you desire.','usces') . " \r\n";
193 // $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n";
194
195 $msg_payment = __('** Payment method **','usces') . "\r\n";
196 $msg_payment .= usces_mail_line( 1, $data['order_email'] );//********************
197 $msg_payment .= $payment['name']. "\r\n\r\n";
198 if ( $payment['settlement'] == 'transferAdvance' || $payment['settlement'] == 'transferDeferred' ) {
199 $transferee = __('Transfer','usces') . " : \r\n";
200 $transferee .= $usces->options['transferee'] . "\r\n";
201 $msg_payment .= apply_filters('usces_filter_mail_transferee', $transferee, $payment);
202 $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//--------------------
203 //20101018ysk start
204 } elseif($payment['settlement'] == 'acting_jpayment_conv') {
205 $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
206 $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
207 $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
208 $msg_payment .= __('お支払�
209 �', 'usces').' : '.usces_get_conv_name($args['cv'])."\r\n";
210 $msg_payment .= __('コンビニ受付番号','usces').' : '.$args['no']."\r\n";
211 if($args['cv'] != '030') {//ファミリーマート以外
212 $msg_payment .= __('コンビニ受付番号�
213 報URL', 'usces').' : '.$args['cu']."\r\n";
214 }
215 $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//--------------------
216 } elseif($payment['settlement'] == 'acting_jpayment_bank') {
217 $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
218 $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
219 $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
220 $bank = explode('.', $args['bank']);
221 $msg_payment .= __('銀行コード','usces').' : '.$bank[0]."\r\n";
222 $msg_payment .= __('銀行名','usces').' : '.$bank[1]."\r\n";
223 $msg_payment .= __('支店コード','usces').' : '.$bank[2]."\r\n";
224 $msg_payment .= __('支店名','usces').' : '.$bank[3]."\r\n";
225 $msg_payment .= __('口座種別','usces').' : '.$bank[4]."\r\n";
226 $msg_payment .= __('口座番号','usces').' : '.$bank[5]."\r\n";
227 $msg_payment .= __('口座名義','usces').' : '.$bank[6]."\r\n";
228 $msg_payment .= __('支払期限','usces').' : '.substr($args['exp'], 0, 4).''.substr($args['exp'], 4, 2).''.substr($args['exp'], 6, 2)."日\r\n";
229 $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//--------------------
230 //20101018ysk end
231 }
232
233 $msg_body .= apply_filters('usces_filter_order_confirm_mail_payment', $msg_payment, $order_id, $payment, $cart, $data);
234
235 //20100818ysk start
236 $msg_body .= usces_mail_custom_field_info( 'order', '', $order_id, $data['order_email'] );
237 //20100818ysk end
238
239 $msg_body .= "\r\n";
240 $msg_body .= __('** Others / a demand **','usces') . "\r\n";
241 $msg_body .= usces_mail_line( 1, $data['order_email'] );//********************
242 $msg_body .= $data['order_note'] . "\r\n\r\n";
243 // $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n";//--------------------
244 // $msg_body .= "\r\n";
245
246 // $msg_body .= __('Please inform it of any questions from [an inquiry].','usces') . "\r\n";
247 // $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n";//--------------------
248
249 $msg_body .= apply_filters('usces_filter_order_confirm_mail_body', NULL, $data);
250
251 switch ( $_POST['mode'] ) {
252 case 'completionMail':
253 $message = do_shortcode($mail_data['header']['completionmail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['completionmail']);
254 break;
255 case 'orderConfirmMail':
256 $message = do_shortcode($mail_data['header']['ordermail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['ordermail']);
257 break;
258 case 'changeConfirmMail':
259 $message = do_shortcode($mail_data['header']['changemail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['changemail']);
260 break;
261 case 'receiptConfirmMail':
262 $message = do_shortcode($mail_data['header']['receiptmail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['receiptmail']);
263 break;
264 case 'mitumoriConfirmMail':
265 $message = do_shortcode($mail_data['header']['mitumorimail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['mitumorimail']);
266 break;
267 case 'cancelConfirmMail':
268 $message = do_shortcode($mail_data['header']['cancelmail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['cancelmail']);
269 break;
270 case 'otherConfirmMail':
271 $message = do_shortcode($mail_data['header']['othermail']) . apply_filters('usces_filter_order_confirm_mail_body_after', $msg_body, $data) . do_shortcode($mail_data['footer']['othermail']);
272 break;
273 }
274 return $message;
275
276 }
277
278 function usces_send_ordermail($order_id) {
279 global $usces, $wpdb;
280
281 $tableName = $wpdb->prefix . "usces_order";
282 $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id);
283 $data = $wpdb->get_row( $query, ARRAY_A );
284
285 $cart = $usces->cart->get_cart();
286 $entry = $usces->cart->get_entry();
287 $mail_data = $usces->options['mail_data'];
288 $payment = $usces->getPayments( $entry['order']['payment_name'] );
289 $res = false;
290
291 $msg_body = "\r\n\r\n\r\n" . __('** content of ordered items **','usces') . "\r\n";
292 $msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
293 $msg_body .= apply_filters('usces_filter_send_order_mail_first', NULL, $data);
294 //20110118ysk start
295 //$msg_body .= usces_mail_custom_field_info( 'customer', 'name_pre', $order_id );
296 //20110118ysk end
297 //$msg_body .= __('Buyer','usces') . " : " . sprintf(__('Mr/Mrs %s', 'usces'), usces_localized_name( $entry['customer']['name1'], $entry['customer']['name2'], 'return' )) . "\r\n";
298 $msg_body .= uesces_get_mail_addressform( 'order_mail_customer', $entry, $order_id );
299 //20110118ysk start
300 //$msg_body .= usces_mail_custom_field_info( 'customer', 'name_after', $order_id );
301 //20110118ysk end
302 $msg_body .= __('Order number','usces') . " : " . usces_get_deco_order_id( $order_id ) . "\r\n";
303
304 $meisai = __('Items','usces') . " : \r\n";
305 foreach ( $cart as $cart_row ) {
306 $post_id = $cart_row['post_id'];
307 $sku = urldecode($cart_row['sku']);
308 $quantity = $cart_row['quantity'];
309 $options = $cart_row['options'];
310 $itemCode = $usces->getItemCode($post_id);
311 $itemName = $usces->getItemName($post_id);
312 $cartItemName = $usces->getCartItemName($post_id, $sku);
313 $skuPrice = $cart_row['price'];
314 // $pictids = $usces->get_pictids($itemCode);
315 if (!empty($options)) {
316 // $optstr = implode(',', $options);
317 } else {
318 $optstr = '';
319 $options = array();
320 }
321
322 $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
323 $meisai .= "$cartItemName \r\n";
324 if( is_array($options) && count($options) > 0 ){
325 $optstr = '';
326 foreach($options as $key => $value){
327 //20110629ysk start 0000190
328 //if( !empty($key) )
329 // $meisai .= $key . ' : ' . urldecode($value) . "\r\n";
330 if( !empty($key) ) {
331 $key = urldecode($key);
332 if(is_array($value)) {
333 $c = '';
334 $optstr .= $key. ' : ';
335 foreach($value as $v) {
336 $optstr .= $c.urldecode($v);
337 $c = ', ';
338 }
339 $optstr .= "\r\n";
340 } else {
341 $optstr .= $key . ' : ' . urldecode($value) . "\r\n";
342 }
343 }
344 //20110629ysk end
345 }
346 $meisai .= apply_filters( 'usces_filter_option_ordermail', $optstr, $options);
347 }
348 $meisai .= __('Unit price','usces') . " ".usces_crform( $skuPrice, true, false, 'return' ) . __(' * ','usces') . $cart_row['quantity'] . "\r\n";
349 }
350 $meisai .= usces_mail_line( 3, $entry['customer']['mailaddress1'] );//====================
351 $meisai .= __('total items','usces') . " : " . usces_crform( $entry['order']['total_items_price'], true, false, 'return' ) . "\r\n";
352
353 if ( $entry['order']['usedpoint'] != 0 )
354 $meisai .= __('use of points','usces') . " : " . number_format($entry['order']['usedpoint']) . __('Points','usces') . "\r\n";
355 //20120308ysk start 0000433
356 //if ( $data['order_discount'] != 0 )
357 if ( $entry['order']['discount'] != 0 )
358 //20120308ysk end
359 $meisai .= apply_filters('usces_confirm_discount_label', __('Campaign disnount', 'usces'), $order_id) . " : " . usces_crform( $entry['order']['discount'], true, false, 'return' ) . "\r\n";
360 $meisai .= __('Shipping','usces') . " : " . usces_crform( $entry['order']['shipping_charge'], true, false, 'return' ) . "\r\n";
361 if ( $payment['settlement'] == 'COD' )
362 $meisai .= apply_filters('usces_filter_cod_label', __('COD fee', 'usces')) . " : " . usces_crform( $entry['order']['cod_fee'], true, false, 'return' ) . "\r\n";
363 if ( !empty($usces->options['tax_rate']) )
364 $meisai .= __('consumption tax','usces') . " : " . usces_crform( $entry['order']['tax'], true, false, 'return' ) . "\r\n";
365 $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
366 $meisai .= __('Payment amount','usces') . " : " . usces_crform( $entry['order']['total_full_price'], true, false, 'return' ) . "\r\n";
367 $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
368 $meisai .= "(" . __('Currency', 'usces') . ' : ' . __(usces_crcode( 'return' ), 'usces') . ")\r\n\r\n";
369
370 //20120308ysk start 0000433
371 //$msg_body .= apply_filters('usces_filter_send_order_mail_meisai', $meisai, $data);
372 $msg_body .= apply_filters('usces_filter_send_order_mail_meisai', $meisai, $data, $cart, $entry);
373 //20120308ysk end
374
375
376 $msg_shipping = __('** A shipping address **','usces') . "\r\n";
377 $msg_shipping .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
378
379 $msg_shipping .= uesces_get_mail_addressform( 'order_mail', $entry, $order_id );
380
381 //20101208ysk start
382 //$msg_shipping .= __('Delivery Time','usces') . " : " . $entry['order']['delivery_time'] . "\r\n";
383 $deli_meth = (int)$entry['order']['delivery_method'];
384 if( 0 <= $deli_meth ){
385 $deli_index = $usces->get_delivery_method_index($deli_meth);
386 $msg_shipping .= __('Delivery Method','usces') . " : " . $usces->options['delivery_method'][$deli_index]['name'] . "\r\n";
387 }
388 $msg_shipping .= __('Delivery date','usces') . " : " . $entry['order']['delivery_date'] . "\r\n";
389 $msg_shipping .= __('Delivery Time','usces') . " : " . $entry['order']['delivery_time'] . "\r\n";
390 //20101208ysk end
391 // $msg_body .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
392 // $msg_body .= __('** For some region, to deliver the items in the morning is not possible.','usces') . "\r\n";
393 // $msg_body .= " " . __('** WE may not always be able to deliver the items on time which you desire.','usces') . "\r\n";
394 // $msg_body .= usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
395 $msg_shipping .= "\r\n";
396 $msg_body .= apply_filters('usces_filter_send_order_mail_shipping', $msg_shipping, $data);
397
398 $msg_payment = __('** Payment method **','usces') . "\r\n";
399 $msg_payment .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
400 $msg_payment .= $payment['name'] . usces_payment_detail($entry) . "\r\n\r\n";
401 if ( $payment['settlement'] == 'transferAdvance' || $payment['settlement'] == 'transferDeferred' ) {
402 $transferee = __('Transfer','usces') . " : \r\n";
403 $transferee .= $usces->options['transferee'] . "\r\n";
404 $msg_payment .= apply_filters('usces_filter_mail_transferee', $transferee, $payment);
405 $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
406 //20101018ysk start
407 } elseif($payment['settlement'] == 'acting_jpayment_conv') {
408 $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
409 $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
410 $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
411 $msg_payment .= __('お支払�
412 �', 'usces').' : '.usces_get_conv_name($args['cv'])."\r\n";
413 $msg_payment .= __('コンビニ受付番号','usces').' : '.$args['no']."\r\n";
414 if($args['cv'] != '030') {//ファミリーマート以外
415 $msg_payment .= __('コンビニ受付番号�
416 報URL', 'usces').' : '.$args['cu']."\r\n";
417 }
418 $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
419 } elseif($payment['settlement'] == 'acting_jpayment_bank') {
420 $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
421 $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
422 $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
423 $bank = explode('.', $args['bank']);
424 $msg_payment .= __('銀行コード','usces').' : '.$bank[0]."\r\n";
425 $msg_payment .= __('銀行名','usces').' : '.$bank[1]."\r\n";
426 $msg_payment .= __('支店コード','usces').' : '.$bank[2]."\r\n";
427 $msg_payment .= __('支店名','usces').' : '.$bank[3]."\r\n";
428 $msg_payment .= __('口座種別','usces').' : '.$bank[4]."\r\n";
429 $msg_payment .= __('口座番号','usces').' : '.$bank[5]."\r\n";
430 $msg_payment .= __('口座名義','usces').' : '.$bank[6]."\r\n";
431 $msg_payment .= __('支払期限','usces').' : '.substr($args['exp'], 0, 4).''.substr($args['exp'], 4, 2).''.substr($args['exp'], 6, 2)."日\r\n";
432 $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
433 //20101018ysk end
434 }
435
436 $msg_body .= apply_filters('usces_filter_send_order_mail_payment', $msg_payment, $order_id, $payment, $cart, $entry, $data);
437
438 //20100818ysk start
439 $msg_body .= usces_mail_custom_field_info( 'order', '', $order_id );
440 //20100818ysk end
441
442 $msg_body .= "\r\n";
443 $msg_body .= __('** Others / a demand **','usces') . "\r\n";
444 $msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
445 $msg_body .= $entry['order']['note'] . "\r\n\r\n";
446 // $msg_body .= usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
447 // $msg_body .= "\r\n";
448
449 // $msg_body .= __('I will inform it of shipment completion by an email.','usces') . "\r\n";
450 // $msg_body .= __('Please inform it of any questions from [an inquiry].','usces') . "\r\n";
451 // $msg_body .= usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
452
453 $msg_body .= apply_filters('usces_filter_send_order_mail_body', NULL, $data);
454
455 $subject = apply_filters('usces_filter_send_order_mail_subject_thankyou', $mail_data['title']['thankyou'], $data);
456 $message = do_shortcode($mail_data['header']['thankyou']) . $msg_body . do_shortcode($mail_data['footer']['thankyou']);
457 //var_dump($msg_body);exit;
458 $confirm_para = array(
459 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), ($entry["customer"]["name1"] . ' ' . $entry["customer"]["name2"])),
460 'to_address' => $entry['customer']['mailaddress1'],
461 'from_name' => get_option('blogname'),
462 'from_address' => $usces->options['sender_mail'],
463 'return_path' => $usces->options['sender_mail'],
464 'subject' => $subject,
465 'message' => $message
466 );
467 $confirm_para = apply_filters( 'usces_send_ordermail_para_to_customer', $confirm_para, $entry, $data);
468
469 //if ( usces_send_mail( $confirm_para ) ) {
470 usces_send_mail( $confirm_para );
471
472 $subject = apply_filters('usces_filter_send_order_mail_subject_order', $mail_data['title']['order'], $data);
473 $message = do_shortcode($mail_data['header']['order']) . $msg_body
474 . $mail_data['footer']['order']
475 . "\n----------------------------------------------------\n"
476 . "REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR']
477 . "\n----------------------------------------------------\n";
478
479 $order_para = array(
480 'to_name' => __('An order email','usces'),
481 'to_address' => $usces->options['order_mail'],
482 'from_name' => sprintf(__('Mr/Mrs %s', 'usces'), ($entry["customer"]["name1"] . ' ' . $entry["customer"]["name2"])),
483 'from_address' => $entry['customer']['mailaddress1'],
484 'return_path' => $usces->options['error_mail'],
485 'subject' => $subject,
486 'message' => $message
487 );
488
489 $order_para = apply_filters( 'usces_send_ordermail_para_to_manager', $order_para, $entry, $data);
490 $res = usces_send_mail( $order_para );
491
492 // }
493
494 return $res;
495
496 }
497
498
499 function usces_send_inquirymail() {
500 global $usces;
501 $_POST = $usces->stripslashes_deep_post($_POST);
502 $res = false;
503 $mail_data = $usces->options['mail_data'];
504 $inq_name = trim($_POST["inq_name"]);
505 $inq_contents = trim($_POST["inq_contents"]);
506 $inq_mailaddress = trim($_POST["inq_mailaddress"]);
507 $reserve = '';
508 if(isset($_POST['reserve'])){
509 foreach($_POST['reserve'] as $key => $value){
510 $reserve .= $key . " : " . $value . "\r\n";
511 }
512 }
513 $mats = compact($inq_name,$inq_contents,$inq_mailaddress,$reserve,$mail_data);
514 $subject = apply_filters( 'usces_filter_inquiry_subject_to_customer', $mail_data['title']['inquiry'],$mats);
515 $message = apply_filters( 'usces_filter_inquiry_header', $mail_data['header']['inquiry'], $inq_name, $inq_mailaddress ) . "\r\n\r\n";
516 $message .= apply_filters( 'usces_filter_inquiry_reserve', $reserve, $inq_name, $inq_mailaddress );
517 $message .= apply_filters( 'usces_filter_inq_contents', $inq_contents, $inq_name, $inq_mailaddress ) . "\r\n\r\n";
518 $message .= apply_filters( 'usces_filter_inq_footer', $mail_data['footer']['inquiry'], $inq_name, $inq_mailaddress );
519 do_action( 'usces_action_presend_inquiry_mail', $message, $inq_name, $inq_mailaddress );
520
521 $para1 = array(
522 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $inq_name),
523 'to_address' => $inq_mailaddress,
524 'from_name' => get_option('blogname'),
525 'from_address' => $usces->options['sender_mail'],
526 'return_path' => $usces->options['sender_mail'],
527 'subject' => $subject,
528 'message' => do_shortcode($message),
529 );
530
531 $res0 = usces_send_mail( $para1 );
532 if ( $res0 ) {
533
534 $subject = apply_filters( 'usces_filter_inquiry_subject_to_manager', __('** An inquiry **','usces').'('.$inq_name.')',$mats);
535 $message = $reserve . $_POST['inq_contents'] . "\r\n"
536 . "\n----------------------------------------------------\n"
537 . "REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR']
538 . "\n----------------------------------------------------\n";
539
540 $para2 = array(
541 'to_name' => __('An inquiry email','usces'),
542 'to_address' => $usces->options['inquiry_mail'],
543 'from_name' => sprintf(__('Mr/Mrs %s', 'usces'), $inq_name),
544 'from_address' => $inq_mailaddress,
545 'return_path' => $usces->options['error_mail'],
546 'subject' => $subject,
547 'message' => do_shortcode($message),
548 );
549 sleep(1);
550 $res = usces_send_mail( $para2 );
551
552 }
553
554 return $res;
555
556 }
557
558 function usces_send_regmembermail($user) {
559 global $usces;
560 $res = false;
561 $mail_data = $usces->options['mail_data'];
562 $newmem_admin_mail = $usces->options['newmem_admin_mail'];
563 $name = usces_localized_name(trim($user['name1']), trim($user['name2']), 'return');
564 $mailaddress1 = trim($user['mailaddress1']);
565
566 $subject = $mail_data['title']['membercomp'];
567 $message = $mail_data['header']['membercomp'];
568 $message .= __('Registration contents', 'usces')."\r\n";
569 $message .= '--------------------------------'."\r\n";
570 $message .= __('Member ID', 'usces') . ' : ' . $user['ID'] . "\r\n";
571 $message .= __('Name', 'usces') . ' : ' . sprintf(__('Mr/Mrs %s', 'usces'), $name) . "\r\n";
572 $message .= __('e-mail adress', 'usces') . ' : ' . $mailaddress1."\r\n";
573 $message .= '--------------------------------'."\r\n\r\n";
574 $message .= $mail_data['footer']['membercomp'];
575 $message = apply_filters('usces_filter_send_regmembermail_message', $message, $user);
576
577 $para1 = array(
578 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $name),
579 'to_address' => $mailaddress1,
580 'from_name' => get_option('blogname'),
581 'from_address' => $usces->options['sender_mail'],
582 'return_path' => $usces->options['sender_mail'],
583 'subject' => $subject,
584 'message' => do_shortcode($message),
585 );
586
587 $para1 = apply_filters( 'usces_filter_send_regmembermail_para1', $para1);
588 $res = usces_send_mail( $para1 );
589
590 if($newmem_admin_mail){
591
592 $subject = __('New sign-in processing was completed.', 'usces');
593 $message = __('New sign-in processing was completed.', 'usces') . "\r\n\r\n";
594 $message .= __('Registration contents', 'usces')."\r\n";
595 $message .= '--------------------------------'."\r\n";
596 $message .= __('Member ID', 'usces') . ' : ' . $user['ID'] . "\r\n";
597 $message .= __('Name', 'usces') . ' : ' . sprintf(__('Mr/Mrs %s', 'usces'), $name) . "\r\n";
598 $message .= __('e-mail adress', 'usces') . ' : ' . $mailaddress1."\r\n";
599 $message .= '--------------------------------'."\r\n\r\n";
600 $message = apply_filters('usces_filter_send_regmembermail_notice', $message, $user);
601
602 $para2 = array(
603 'to_name' => __('Notice of new sign-in', 'usces'),
604 'to_address' => $usces->options['order_mail'],
605 'from_name' => get_option('blogname'),
606 'from_address' => $usces->options['sender_mail'],
607 'return_path' => $usces->options['sender_mail'],
608 'subject' => $subject,
609 'message' => do_shortcode($message),
610 );
611 $para1 = apply_filters( 'usces_filter_send_regmembermail_para2', $para2);
612
613 usces_send_mail( $para2 );
614 }
615
616 return $res;
617
618 }
619
620 function usces_lostmail($url) {
621 global $usces;
622 $res = false;
623
624 $mail_data = $usces->options['mail_data'];
625 $subject = __('Change password','usces');
626 $message = __('Please, click the following URL, and please change a password.','usces') . "\n\r\n\r\n\r"
627 . $url . "\n\r\n\r\n\r"
628 . "-----------------------------------------------------\n\r"
629 . __('If you have not requested this email please kindly ignore and delete it.','usces') . "\n\r"
630 . "-----------------------------------------------------\n\r\n\r\n\r"
631 . apply_filters('usces_filter_lostmail_footer', $mail_data['footer']['othermail']);
632
633 $para1 = array(
634 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $_SESSION["usces_lostmail"]),
635 'to_address' => $_SESSION["usces_lostmail"],
636 'from_name' => get_option('blogname'),
637 'from_address' => $usces->options['sender_mail'],
638 'return_path' => $usces->options['sender_mail'],
639 'subject' => $subject,
640 'message' => do_shortcode($message),
641 );
642
643 $res = usces_send_mail( $para1 );
644
645 if($res === false) {
646 $usces->error_message = __('Error: I was not able to transmit an email.','usces');
647 $page = 'lostmemberpassword';
648 } else {
649 $page = 'lostcompletion';
650 }
651
652 return $page;
653
654 }
655
656 //20100818ysk start
657 //function usces_mail_custom_field_info( $custom_field, $position, $id ) {
658 function usces_mail_custom_field_info( $custom_field, $position, $id, $mailaddress = '' ) {
659 global $usces;
660
661 $msg_body = '';
662 switch($custom_field) {
663 case 'order':
664 $field = 'usces_custom_order_field';
665 $cs = 'csod_';
666 break;
667 case 'customer':
668 $field = 'usces_custom_customer_field';
669 $cs = 'cscs_';
670 break;
671 case 'delivery':
672 $field = 'usces_custom_delivery_field';
673 $cs = 'csde_';
674 break;
675 case 'member':
676 $field = 'usces_custom_member_field';
677 $cs = 'csmb_';
678 break;
679 default:
680 return $msg_body;
681 }
682
683 $meta = usces_has_custom_field_meta($custom_field);
684
685 if(!empty($meta) and is_array($meta)) {
686 $keys = array_keys($meta);
687 switch($custom_field) {
688 case 'order':
689 $msg_body .= "\r\n";
690 $msg_body .= usces_mail_line( 1, $mailaddress );
691 foreach($keys as $key) {
692 $value = maybe_unserialize($usces->get_order_meta_value($cs.$key, $id));
693 if(is_array($value)) {
694 $concatval = '';
695 $c = '';
696 foreach($value as $v) {
697 $concatval .= $c.$v;
698 $c = ', ';
699 }
700 $value = $concatval;
701 }
702 $msg_body .= $meta[$key]['name']." : ".$value."\r\n";
703 }
704 $msg_body .= usces_mail_line( 1, $mailaddress );
705 break;
706
707 case 'customer':
708 case 'delivery':
709 foreach($keys as $key) {
710 if($meta[$key]['position'] == $position) {
711 $value = maybe_unserialize($usces->get_order_meta_value($cs.$key, $id));
712 if(is_array($value)) {
713 $concatval = '';
714 $c = '';
715 foreach($value as $v) {
716 $concatval .= $c.$v;
717 $c = ', ';
718 }
719 $value = $concatval;
720 }
721 $msg_body .= $meta[$key]['name']." : ".$value."\r\n";
722 }
723 }
724 break;
725
726 case 'member':
727 foreach($keys as $key) {
728 if($meta[$key]['position'] == $position) {
729 $value = maybe_unserialize($usces->get_member_meta_value($cs.$key, $id));
730 if(is_array($value)) {
731 $concatval = '';
732 $c = '';
733 foreach($value as $v) {
734 $concatval .= $c.$v;
735 $c = ', ';
736 }
737 $value = $concatval;
738 }
739 $msg_body .= $meta[$key]['name']." : ".$value."\r\n";
740 }
741 }
742 break;
743 }
744 }
745 $msg_body = apply_filters('usces_filter_mail_custom_field_info', $msg_body, $custom_field, $position, $id, $mailaddress);
746 return $msg_body;
747 }
748 //20100818ysk end
749
750 //function usces_send_receipted_mail( $order_id, $acting ) {
751 // global $usces;
752 // $res = false;
753 //
754 // $subject = __('Change password','usces');
755 // $message = __('Please, click the following URL, and please change a password.','usces') . "\n\r\n\r\n\r"
756 // . $url . "\n\r\n\r\n\r"
757 // . "-----------------------------------------------------\n\r"
758 // . __('I seem to have you cancel it when the body does not have memorizing to this email.','usces') . "\n\r"
759 // . "-----------------------------------------------------\n\r\n\r\n\r"
760 // . $usces->options['mail_data']['footer']['footerlogo'];
761 //
762 // $para1 = array(
763 // 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $_SESSION["usces_lostmail"]),
764 // 'to_address' => $_SESSION["usces_lostmail"],
765 // 'from_name' => get_bloginfo('name'),
766 // 'from_address' => $usces->options['sender_mail'],
767 // 'return_path' => $usces->options['error_mail'],
768 // 'subject' => $subject,
769 // 'message' => $message
770 // );
771 //
772 // $res = usces_send_mail( $para1 );
773 //
774 // if($res === false) {
775 // $usces->error_message = __('Error: I was not able to transmit an email.','usces');
776 // $page = 'lostmemberpassword';
777 // } else {
778 // $page = 'lostcompletion';
779 // }
780 //
781 // return $page;
782 //
783 //}
784
785 function usces_send_mail( $para ) {
786 global $usces;
787
788 $from_name = $para['from_name'];
789 $from_address = $para['from_address'];
790 if (strpos($para['from_address'], '..') !== false || strpos($para['from_address'], '.@') !== false) {
791 $fname = str_replace(strstr($para['from_address'], '@'), '', $para['from_address']);
792 if( '"' != substr($fname, 0, 1) && '"' != substr($fname, -1) ){
793 $para['from_address'] = str_replace($fname, '"RFC_violation"', $para['from_address']);
794 $from_name = $para['from_name'] . '(' . $from_address . ')';
795 }
796 }
797 $from = htmlspecialchars(html_entity_decode($from_name, ENT_QUOTES)) . " <{$para['from_address']}>";
798 $header = "From: " . apply_filters('usces_filter_send_mail_from', $from, $para) . "\r\n";
799 $header .= "Return-Path: {$para['return_path']}\r\n";
800
801 $subject = html_entity_decode($para['subject'], ENT_QUOTES);
802 $message = $para['message'];
803
804 ini_set( "SMTP", "{$usces->options['smtp_hostname']}" );
805 if( !ini_get( "smtp_port" ) ){
806 ini_set( "smtp_port", apply_filters('usces_filter_send_mail_port', 25, $para) );
807 }
808 ini_set( "sendmail_from", "" );
809
810 $mails = explode( ',', $para['to_address'] );
811 $to_mailes = array();
812 foreach( $mails as $mail ){
813 if (strpos($mail, '..') !== false || strpos($mail, '.@') !== false) {
814 $name = str_replace(strstr($mail, '@'), '', $mail);
815 if( '"' != substr($name, 0, 1) && '"' != substr($name, -1) ){
816 $to_mailes[] = str_replace($name, '"'.$name.'"', $mail);
817 }else{
818 $to_mailes[] = $mail;
819 }
820 }elseif( is_email( trim($mail) ) ){
821 $to_mailes[] = $mail;
822 }else{
823 $to_mailes[] = NULL;
824 }
825 }
826
827 if( !empty( $to_mailes ) ){
828 $res = @wp_mail( $to_mailes , $subject , $message, $header );
829 }else{
830 $res = false;
831 }
832
833 return $res;
834
835 }
836
837 function usces_send_mail2( $para ) {
838 global $usces;
839
840 $usces->mail_para = $para;
841 add_action('phpmailer_init','usces_send_mail_init', 11);
842
843 // $from = htmlspecialchars(html_entity_decode($para['from_name'], ENT_QUOTES)) . " <{$para['from_address']}>";
844 // $header = "From: " . apply_filters('usces_filter_send_mail_from', $from, $para) . "\r\n";
845 // $header .= "Return-Path: {$para['return_path']}\r\n";
846
847 $subject = html_entity_decode($para['subject'], ENT_QUOTES);
848 $message = $para['message'];
849
850 // ini_set( "SMTP", "{$usces->options['smtp_hostname']}" );
851 // if( !ini_get( "smtp_port" ) ){
852 // ini_set( "smtp_port", apply_filters('usces_filter_send_mail_port', 25, $para) );
853 // }
854 // ini_set( "sendmail_from", "" );
855
856 $mails = explode( ',', $para['to_address'] );
857 $to_mailes = array();
858 foreach( $mails as $mail ){
859 if( is_email( trim($mail) ) ){
860 $to_mailes[] = $mail;
861 }
862 }
863 if( !empty( $to_mailes ) ){
864 $res = @wp_mail( $to_mailes , $subject , $message );
865 }else{
866 $res = false;
867 }
868 //usces_log('mail : '.print_r($res, true), 'acting_transaction.log');
869
870 remove_action('phpmailer_init','usces_send_mail_init', 11);
871 $usces->mail_para = array();
872 return $res;
873
874 }
875
876 function usces_send_mail_init($phpmailer){
877 global $usces;
878
879 $phpmailer->Mailer = 'mail';
880 $phpmailer->From = $usces->mail_para['from_address'];
881 $phpmailer->FromName = apply_filters('usces_filter_send_mail_from', $usces->mail_para['from_name'], $usces->mail_para);
882 $phpmailer->Sender = $usces->mail_para['from_address'];
883
884 // $phpmailer->Mailer = 'smtp';
885 // $phpmailer->SMTPSecure = '';
886 // $phpmailer->Host = 'sample.com';
887 // $phpmailer->Port = 25;
888 // $phpmailer->SMTPAuth = true;
889 // $phpmailer->Username = 'sample@sample.com';
890 // $phpmailer->Password = 'password';
891
892 do_action('usces_filter_phpmailer_init', array( &$phpmailer ));
893 }
894
895 function usces_reg_orderdata( $results = array() ) {
896 global $wpdb, $usces;
897 // $wpdb->show_errors();
898
899 $options = get_option('usces');
900 $cart = $usces->cart->get_cart();
901 $entry = $usces->cart->get_entry();
902 if( empty($cart) ){
903 usces_log('reg_orderdata : Session is empty.', 'database_error.log');
904 return 0;
905 }
906
907 $charging_type = $usces->getItemChargingType($cart[0]['post_id']);
908
909 $item_total_price = $usces->get_total_price( $cart );
910 $member = $usces->get_member();
911 $order_table_name = $wpdb->prefix . "usces_order";
912 $order_table_meta_name = $wpdb->prefix . "usces_order_meta";
913 $member_table_name = $wpdb->prefix . "usces_member";
914 $set = $usces->getPayments( $entry['order']['payment_name'] );
915 $status = '';
916 if( 'continue' == $charging_type ){
917 $order_modified = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
918 }else{
919 $status = ( $set['settlement'] == 'transferAdvance' || $set['settlement'] == 'transferDeferred' || $set['settlement'] == 'acting_remise_conv' || $set['settlement'] == 'acting_zeus_bank' || $set['settlement'] == 'acting_zeus_conv' || $set['settlement'] == 'acting_jpayment_conv' || $set['settlement'] == 'acting_jpayment_bank' || $set['settlement'] == 'acting_sbps_conv' || $set['settlement'] == 'acting_sbps_payeasy' || $set['settlement'] == 'acting_digitalcheck_conv' || $set['settlement'] == 'acting_mizuho_conv1' || $set['settlement'] == 'acting_mizuho_conv2' ) ? 'noreceipt' : '';
920 $order_modified = NULL;
921 }
922 $payments = $usces->getPayments($entry['order']['payment_name']);
923 if( isset($results['payment_status']) && $results['payment_status'] != 'Completed' && $payments['module'] == 'paypal.php') $status = 'pending';
924
925 if( (empty($entry['customer']['name1']) && empty($entry['customer']['name2'])) || empty($entry['customer']['mailaddress1']) || empty($entry) || empty($cart) ) return '1';
926 $status = apply_filters('usces_filter_reg_orderdata_status', $status);
927 $delidue_date = ( isset($entry['order']['delidue_date']) ) ? $entry['order']['delidue_date'] : NULL;
928 //20101208ysk start
929 $query = $wpdb->prepare(
930 "INSERT INTO $order_table_name (
931 `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`,
932 `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`,
933 `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`,
934 `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`,
935 `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` )
936 VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %f, %d, %d, %f, %f, %f, %f, %s, %s, %s, %s)",
937 $member['ID'],
938 $entry['customer']['mailaddress1'],
939 $entry['customer']['name1'],
940 $entry['customer']['name2'],
941 $entry['customer']['name3'],
942 $entry['customer']['name4'],
943 $entry['customer']['zipcode'],
944 $entry['customer']['pref'],
945 $entry['customer']['address1'],
946 $entry['customer']['address2'],
947 $entry['customer']['address3'],
948 $entry['customer']['tel'],
949 $entry['customer']['fax'],
950 serialize($entry['delivery']),
951 serialize($cart),
952 $entry['order']['note'],
953 $entry['order']['delivery_method'],
954 $entry['order']['delivery_date'],
955 $entry['order']['delivery_time'],
956 $entry['order']['payment_name'],
957 serialize($entry['condition']),
958 $item_total_price,
959 $entry['order']['getpoint'],
960 $entry['order']['usedpoint'],
961 $entry['order']['discount'],
962 $entry['order']['shipping_charge'],
963 $entry['order']['cod_fee'],
964 $entry['order']['tax'],
965 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
966 $order_modified,
967 $status,
968 $delidue_date
969 );
970 //20101208ysk end
971
972 $res = $wpdb->query( $query );
973 usces_log('reg_orderdata : ' . $wpdb->last_error, 'database_error.log');
974
975 if( $res === false){
976 $order_id = false;
977 }else{
978 $order_id = $wpdb->insert_id;
979 }
980
981 if ( !$order_id ) :
982
983 usces_log('reg_error_entry : '.print_r($entry, true), 'acting_transaction.log');
984 return false;
985
986 else :
987
988 $usces->cart->set_order_entry( array('ID' => $order_id) );
989 $usces->set_order_meta_value('customer_country', $entry['customer']['country'], $order_id);
990
991 if ( $member['ID'] && 'activate' == $options['membersystem_state'] && 'activate' == $options['membersystem_point'] ) {
992 //20120919ysk start 0000573
993 $mquery = '';
994 if( usces_is_complete_settlement( $entry['order']['payment_name'], $status ) ) {//20120306ysk 0000324
995 $mquery = $wpdb->prepare(
996 "UPDATE $member_table_name SET mem_point = (mem_point + %d - %d) WHERE ID = %d",
997 $entry['order']['getpoint'], $entry['order']['usedpoint'], $member['ID']);
998 } elseif( 0 < $entry['order']['usedpoint'] ) {
999 $mquery = $wpdb->prepare(
1000 "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d",
1001 $entry['order']['usedpoint'], $member['ID']);
1002 }
1003 if( $mquery ) {
1004 $wpdb->query( $mquery );
1005 $mquery = $wpdb->prepare("SELECT mem_point FROM $member_table_name WHERE ID = %d", $member['ID']);
1006 $point = $wpdb->get_var( $mquery );
1007 $_SESSION['usces_member']['point'] = $point;
1008 }
1009 //20120919ysk end
1010 }
1011
1012 if ( !empty($entry['reserve']) ) {
1013 foreach ( $entry['reserve'] as $key => $value ) {
1014 if ( is_array($value) )
1015 $value = serialize($value);
1016 $usces->set_order_meta_value($key, $value, $order_id);
1017 }
1018 }
1019
1020 if ( !preg_match('/pending|noreceipt/', $status) ) {
1021 $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
1022 $usces->set_order_meta_value('receipted_date', $value, $order_id);
1023 }
1024
1025 //20100818ysk start
1026 if( !empty($entry['custom_order']) ) {
1027 foreach( $entry['custom_order'] as $key => $value ) {
1028 $csod_key = 'csod_'.$key;
1029 if( is_array($value) )
1030 $value = serialize($value);
1031 $usces->set_order_meta_value($csod_key, $value, $order_id);
1032 }
1033 }
1034 if( !empty($entry['custom_customer']) ) {
1035 foreach( $entry['custom_customer'] as $key => $value ) {
1036 $cscs_key = 'cscs_'.$key;
1037 if( is_array($value) )
1038 $value = serialize($value);
1039 $usces->set_order_meta_value($cscs_key, $value, $order_id);
1040 }
1041 }
1042 if( !empty($entry['custom_delivery']) ) {
1043 foreach( $entry['custom_delivery'] as $key => $value ) {
1044 $csde_key = 'csde_'.$key;
1045 if( is_array($value) )
1046 $value = serialize($value);
1047 $usces->set_order_meta_value($csde_key, $value, $order_id);
1048 }
1049 }
1050 //20100818ysk end
1051
1052 if ( isset($_REQUEST['X-S_TORIHIKI_NO']) ) {
1053 $usces->set_order_meta_value('settlement_id', $_REQUEST['X-S_TORIHIKI_NO'], $order_id);
1054 if ( isset($_REQUEST['X-AC_MEMBERID']) ) {
1055 $usces->set_order_meta_value($_REQUEST['X-AC_MEMBERID'], 'continuation', $order_id);
1056 //$usces->set_member_meta_value('continue_memberid', $_REQUEST['X-AC_MEMBERID']);
1057 $usces->set_member_meta_value('continue_memberid_'.$order_id, $_REQUEST['X-AC_MEMBERID']);
1058 }
1059 }
1060
1061 if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
1062 $usces->set_order_meta_value('settlement_id', $_GET['cod'], $order_id);
1063 foreach($_GET as $key => $value) {
1064 if( 'purchase_jpayment' != $key)
1065 $data[$key] = mysql_real_escape_string($value);
1066 }
1067 $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
1068 }
1069 if( isset($_REQUEST['acting']) && isset($_REQUEST['acting_return']) && isset($_REQUEST['trans_code']) && 'epsilon' == $_REQUEST['acting'] ) {
1070 $usces->set_order_meta_value('settlement_id', $_GET['trans_code'], $order_id);
1071 }
1072 if( isset($_REQUEST['res_tracking_id']) ) {
1073 $usces->set_order_meta_value('res_tracking_id', $_REQUEST['res_tracking_id'], $order_id);
1074 }
1075 //20121206ysk start
1076 if( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) ) {
1077 if( substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) {
1078 $data['SID'] = mysql_real_escape_string($_REQUEST['SID']);
1079 $usces->set_order_meta_value( $_REQUEST['FUKA'], serialize($data), $order_id );
1080 }
1081 $usces->set_order_meta_value( 'SID', $_REQUEST['SID'], $order_id );
1082 }
1083 //20121206ysk end
1084 //20130225ysk start
1085 if( isset($_REQUEST['acting']) && 'mizuho_card' == $_REQUEST['acting'] ) {
1086 $data['stran'] = mysql_real_escape_string($_REQUEST['stran']);
1087 $data['mbtran'] = mysql_real_escape_string($_REQUEST['mbtran']);
1088 $usces->set_order_meta_value( 'acting_'.$_REQUEST['acting'], serialize($data), $order_id );
1089 } elseif( isset($_REQUEST['acting']) && 'mizuho_conv' == $_REQUEST['acting'] ) {
1090 $data['stran'] = mysql_real_escape_string($_REQUEST['stran']);
1091 $data['mbtran'] = mysql_real_escape_string($_REQUEST['mbtran']);
1092 $data['bktrans'] = mysql_real_escape_string($_REQUEST['bktrans']);
1093 $data['tranid'] = mysql_real_escape_string($_REQUEST['tranid']);
1094 $usces->set_order_meta_value( 'stran', $data['stran'], $order_id );
1095 $usces->set_order_meta_value( 'acting_'.$_REQUEST['acting'], serialize($data), $order_id );
1096 }
1097 //20130225ysk end
1098
1099 foreach($cart as $cartrow){
1100 $sku = urldecode($cartrow['sku']);
1101 $zaikonum = $usces->getItemZaikoNum( $cartrow['post_id'], $sku );
1102 if($zaikonum == '') continue;
1103 $zaikonum = $zaikonum - $cartrow['quantity'];
1104 $usces->updateItemZaikoNum( $cartrow['post_id'], $sku, $zaikonum );
1105 if($zaikonum <= 0) $usces->updateItemZaiko( $cartrow['post_id'], $sku, 2 );
1106 }
1107
1108 $args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member['ID'], 'payments'=>$payments, 'charging_type'=>$charging_type);
1109 do_action('usces_action_reg_orderdata', $args);
1110
1111 endif;
1112
1113 return $order_id;
1114
1115 }
1116
1117 function usces_new_orderdata() {
1118 global $wpdb, $usces;
1119 $_POST = $usces->stripslashes_deep_post($_POST);
1120
1121 $usces->cart->crear_cart();
1122 $cart = $usces->cart->get_cart();
1123 $item_total_price = $usces->get_total_price( $cart );
1124 $entry = $usces->cart->get_entry();
1125 $member_id = $usces->get_memberid_by_email($_POST['customer']['mailaddress']);
1126 $order_table_name = $wpdb->prefix . "usces_order";
1127 $order_table_meta_name = $wpdb->prefix . "usces_order_meta";
1128 $member_table_name = $wpdb->prefix . "usces_member";
1129 $set = $usces->getPayments( $_POST['offer']['payment_name'] );
1130 if( isset($_POST['offer']['receipt']) ) {
1131 $status = $_POST['offer']['receipt'].',';
1132 } else {
1133 $status = ( $set['settlement'] == 'transferAdvance' || $set['settlement'] == 'transferDeferred' || $set['settlement'] == 'acting_remise_conv' || $set['settlement'] == 'acting_zeus_bank' || $set['settlement'] == 'acting_zeus_conv' || $set['settlement'] == 'acting_jpayment_conv' || $set['settlement'] == 'acting_jpayment_bank' || $set['settlement'] == 'acting_sbps_conv' || $set['settlement'] == 'acting_sbps_payeasy' || $set['settlement'] == 'acting_digitalcheck_conv' ) ? 'noreceipt' : '';
1134 }
1135 $status .= ( !WCUtils::is_blank($_POST['offer']['taio']) && $_POST['offer']['taio'] != '#none#' ) ? $_POST['offer']['taio'].',' : '';
1136 $status .= $_POST['offer']['admin'];
1137 $status = apply_filters('usces_filter_new_orderdata_status', $status);
1138 $order_conditions = $usces->get_condition();
1139
1140 //20101208ysk start
1141 $query = $wpdb->prepare(
1142 "INSERT INTO $order_table_name (
1143 `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`,
1144 `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`,
1145 `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`,
1146 `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`,
1147 `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` )
1148 VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %f, %d, %d, %f, %f, %f, %f, %s, %s, %s, %s)",
1149 $member_id,
1150 $_POST['customer']['mailaddress'],
1151 $_POST['customer']['name1'],
1152 $_POST['customer']['name2'],
1153 $_POST['customer']['name3'],
1154 $_POST['customer']['name4'],
1155 $_POST['customer']['zipcode'],
1156 $_POST['customer']['pref'],
1157 $_POST['customer']['address1'],
1158 $_POST['customer']['address2'],
1159 $_POST['customer']['address3'],
1160 $_POST['customer']['tel'],
1161 $_POST['customer']['fax'],
1162 serialize($_POST['delivery']),
1163 serialize($cart),
1164 $_POST['offer']['note'],
1165 $_POST['offer']['delivery_method'],
1166 $_POST['offer']['delivery_date'],
1167 $_POST['offer']['delivery_time'],
1168 $_POST['offer']['payment_name'],
1169 serialize($order_conditions),
1170 $item_total_price,
1171 $_POST['offer']['getpoint'],
1172 $_POST['offer']['usedpoint'],
1173 $_POST['offer']['discount'],
1174 $_POST['offer']['shipping_charge'],
1175 $_POST['offer']['cod_fee'],
1176 $_POST['offer']['tax'],
1177 get_date_from_gmt(gmdate('Y-m-d H:i:s', time())),
1178 null,
1179 $status,
1180 $_POST['offer']['delidue_date']
1181 );
1182 //20101208ysk end
1183
1184 $res = $wpdb->query( $query );
1185 // $wpdb->print_error();
1186 // echo $query;
1187 // exit;
1188 $order_id = $wpdb->insert_id;
1189 $_REQUEST['order_id'] = $wpdb->insert_id;
1190
1191 //20100818ysk start
1192 if( !$order_id ) :
1193
1194 return false;
1195
1196 else :
1197 $usces->set_order_meta_value('customer_country', $_POST['customer']['country'], $order_id);
1198
1199 if( !empty($_POST['custom_order']) ) {
1200 foreach( $_POST['custom_order'] as $key => $value ) {
1201 $csod_key = 'csod_'.$key;
1202 if( is_array($value) )
1203 $value = serialize($value);
1204 $usces->set_order_meta_value($csod_key, $value, $order_id);
1205 }
1206 }
1207 if( !empty($_POST['custom_customer']) ) {
1208 foreach( $_POST['custom_customer'] as $key => $value ) {
1209 $cscs_key = 'cscs_'.$key;
1210 if( is_array($value) )
1211 $value = serialize($value);
1212 $usces->set_order_meta_value($cscs_key, $value, $order_id);
1213 }
1214 }
1215 if( !empty($_POST['custom_delivery']) ) {
1216 foreach( $_POST['custom_delivery'] as $key => $value ) {
1217 $csde_key = 'csde_'.$key;
1218 if( is_array($value) )
1219 $value = serialize($value);
1220 $usces->set_order_meta_value($csde_key, $value, $order_id);
1221 }
1222 }
1223 if ( !preg_match('/pending|noreceipt/', $status) ) {
1224 $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
1225 $usces->set_order_meta_value('receipted_date', $value, $order_id);
1226 }
1227 //20120314ysk start 0000435
1228 $args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member_id);
1229 do_action('usces_action_reg_orderdata', $args);
1230 //20120314ysk end
1231 endif;
1232 //20100818ysk end
1233
1234 $usces->cart->crear_cart();
1235 return $res;
1236
1237 }
1238
1239 function usces_delete_memberdata( $ID = 0 ) {
1240 global $wpdb, $usces;
1241
1242 if( 0 === $ID ){
1243 if(!isset($_REQUEST['member_id']) || WCUtils::is_blank($_REQUEST['member_id']) )
1244 return 0;
1245 $ID = $_REQUEST['member_id'];
1246 }
1247 do_action('usces_action_pre_delete_memberdata', $ID);
1248
1249 $member_table_name = $wpdb->prefix . "usces_member";
1250 //20100818ysk start
1251 $member_table_meta_name = $wpdb->prefix . "usces_member_meta";
1252 //20100818ysk end
1253
1254 $query = $wpdb->prepare("DELETE FROM $member_table_name WHERE ID = %d", $ID);
1255 $res = $wpdb->query( $query );
1256 //20100818ysk start
1257 if($res) {
1258 $query = $wpdb->prepare("DELETE FROM $member_table_meta_name WHERE member_id = %d", $ID);
1259 $wpdb->query( $query );
1260 }
1261 //20100818ysk end
1262 do_action('usces_action_post_delete_memberdata', $res, $ID);
1263
1264 return $res;
1265 }
1266
1267 function usces_update_memberdata() {
1268 global $wpdb, $usces;
1269 $_POST = $usces->stripslashes_deep_post($_POST);
1270
1271 $member_table_name = $wpdb->prefix . "usces_member";
1272 //20100818ysk start
1273 $member_table_meta_name = $wpdb->prefix . "usces_member_meta";
1274 //20100818ysk end
1275
1276 $ID = (int)$_REQUEST['member_id'];
1277
1278 //$wpdb->show_errors();
1279 $query = $wpdb->prepare(
1280 "UPDATE $member_table_name SET
1281 `mem_email`=%s, `mem_status`=%s, `mem_point`=%d, `mem_name1`=%s, `mem_name2`=%s,
1282 `mem_name3`=%s, `mem_name4`=%s, `mem_zip`=%s, `mem_pref`=%s, `mem_address1`=%s,
1283 `mem_address2`=%s, `mem_address3`=%s, `mem_tel`=%s, `mem_fax`=%s
1284 WHERE ID = %d",
1285 $_POST['member']['email'],
1286 $_POST['member']['status'],
1287 $_POST['member']['point'],
1288 $_POST['member']['name1'],
1289 $_POST['member']['name2'],
1290 $_POST['member']['name3'],
1291 $_POST['member']['name4'],
1292 $_POST['member']['zipcode'],
1293 $_POST['member']['pref'],
1294 $_POST['member']['address1'],
1295 $_POST['member']['address2'],
1296 $_POST['member']['address3'],
1297 $_POST['member']['tel'],
1298 $_POST['member']['fax'],
1299 $ID
1300 );
1301
1302 do_action('usces_action_pre_update_memberdata', $ID);
1303 //20100818ysk start
1304 //$res = $wpdb->query( $query );
1305 $res[0] = $wpdb->query( $query );
1306
1307 do_action( 'usces_action_post_update_memberdata', $ID, $res[0]);
1308
1309 if(false === $res[0])
1310 return false;
1311
1312 $usces->set_member_meta_value('customer_country', $_POST['member']['country'], $ID);
1313 $i = 1;
1314 if( !empty($_POST['custom_member']) ) {
1315 foreach( $_POST['custom_member'] as $key => $value ) {
1316 $csmb_key = 'csmb_'.$key;
1317 if( is_array($value) )
1318 $value = serialize($value);
1319 $res[$i] = $usces->set_member_meta_value($csmb_key, $value, $ID);
1320 if(false === $res[$i])
1321 return false;
1322 $i++;
1323 }
1324 }
1325
1326 $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" );
1327 $query = $wpdb->prepare("DELETE FROM $member_table_meta_name WHERE member_id = %d AND meta_key IN( $meta_keys )",
1328 $_POST['member_id']
1329 );
1330 $res[$i] = $wpdb->query( $query );
1331
1332 $result = ( 0 < array_sum($res) ) ? 1 : 0;
1333 //return $res;
1334 return $result;
1335 //20100818ysk end
1336
1337 }
1338
1339 function usces_delete_orderdata() {
1340 global $wpdb, $usces;
1341 if(!isset($_REQUEST['order_id']) || WCUtils::is_blank($_REQUEST['order_id']) ) return 0;
1342 $order_table = $wpdb->prefix . "usces_order";
1343 $order_meta_table = $wpdb->prefix . "usces_order_meta";
1344 $ID = $_REQUEST['order_id'];
1345
1346 $del = usces_delete_order_check( $ID );
1347 if( $del ) {
1348
1349 $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $ID);
1350 $order_data = $wpdb->get_row( $query, OBJECT );
1351 //20120306ysk start 0000324
1352 $order_res = $wpdb->get_row( $query, ARRAY_A );
1353 $restore_point = false;
1354 if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) {
1355 if( !empty($order_res['mem_id']) && 0 < $order_res['order_getpoint'] ) {
1356 if( $usces->is_status('completion', $order_res['order_status']) ) {
1357 $restore_point = true;
1358 } else {
1359 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) || $usces->is_status('receipted', $order_res['order_status']) )
1360 $restore_point = true;
1361 }
1362 }
1363 }
1364 //20120306ysk end
1365
1366 $query = $wpdb->prepare("DELETE FROM $order_table WHERE ID = %d", $ID);
1367 $res = $wpdb->query( $query );
1368
1369 if($res){
1370 $query = $wpdb->prepare("DELETE FROM $order_meta_table WHERE order_id = %d", $ID);
1371 $wpdb->query( $query );
1372
1373 do_action('usces_action_del_orderdata', $order_data);
1374 //20120306ysk start 0000324
1375 if( $restore_point ) usces_restore_point( $order_res['mem_id'], $order_res['order_getpoint'] );
1376 //20120306ysk end
1377 }
1378
1379 } else {
1380 $res = true;
1381 }
1382
1383 return $res;
1384 }
1385
1386 function usces_update_ordercart() {
1387 global $wpdb, $usces;
1388 if(!isset($_REQUEST['order_id']) || WCUtils::is_blank($_REQUEST['order_id']) ) return 0;
1389 $order_table_name = $wpdb->prefix . "usces_order";
1390 $ID = $_REQUEST['order_id'];
1391 $usces->cart->crear_cart();
1392 $usces->cart->upCart();
1393 $cart = $usces->cart->get_cart();
1394 //20120613ysk start 0000500
1395 $idx = count($cart)-1;
1396 $post_id = $cart[$idx]['post_id'];
1397 $sku = $cart[$idx]['sku'];
1398 $sku_code = esc_attr(urldecode($sku));
1399 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
1400 $skuPrice = $cart[$idx]['price'];
1401 //20120613ysk end
1402
1403 $query = $wpdb->prepare("UPDATE $order_table_name SET `order_cart`=%s WHERE ID = %d", serialize($cart), $ID);
1404 $res = $wpdb->query( $query );
1405
1406 $usces->cart->crear_cart();
1407 //20120613ysk start 0000500
1408 if( $res === false ) {
1409 $res = "-1#usces#";
1410 } else {
1411 $res = $skuPrice."#usces#".$cartItemName;
1412 }
1413 //20120613ysk end
1414 return $res;
1415 }
1416
1417 function usces_update_ordercheck() {
1418 global $wpdb, $usces;
1419
1420 $tableName = $wpdb->prefix . "usces_order";
1421 $order_id = $_POST['order_id'];
1422 $checked = $_POST['checked'];
1423
1424 $query = $wpdb->prepare("SELECT `order_check` FROM $tableName WHERE ID = %d", $order_id);
1425 $res = $wpdb->get_var( $query );
1426
1427 $checkfield = unserialize($res);
1428 if( !isset($checkfield[$checked]) ) $checkfield[$checked] = $checked;
1429 //$checkfield = 'OK';
1430 $query = $wpdb->prepare("UPDATE $tableName SET `order_check`=%s WHERE ID = %d", serialize($checkfield), $order_id);
1431 $res = $wpdb->query( $query );
1432
1433 if($res)
1434 return $checked;
1435 else
1436 return 'error';
1437 }
1438 function usces_update_orderdata() {
1439 global $wpdb, $usces;
1440 $_POST = $usces->stripslashes_deep_post($_POST);
1441
1442 $order_table_name = $wpdb->prefix . "usces_order";
1443 $order_table_meta_name = $wpdb->prefix . "usces_order_meta";
1444 $member_table_name = $wpdb->prefix . "usces_member";
1445
1446 $ID = $_REQUEST['order_id'];
1447
1448 $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID);
1449 $old_orderdata = $wpdb->get_row( $query );
1450 $old_status = $old_orderdata->order_status;
1451
1452 $usces->cart->crear_cart();
1453 $usces->cart->upCart();
1454 if(isset($_POST['delButton'])) {
1455 $usces->cart->del_row();
1456 $indexs = array_keys($_POST['delButton']);
1457 $index = $indexs[0];
1458 do_action('usces_admin_delete_orderrow', $ID, $index );
1459 }
1460 $cart = $usces->cart->get_cart();
1461 $usces->cart->entry();
1462 $entry = $usces->cart->get_entry();
1463
1464 $item_total_price = $usces->get_total_price( $cart );
1465 $set = $usces->getPayments( $entry['order']['payment_name'] );
1466 $taio = isset($entry['order']['taio']) ? $entry['order']['taio'] : '';
1467 $receipt = isset($entry['order']['receipt']) ? $entry['order']['receipt'] : '';
1468 $admin = isset($entry['order']['admin']) ? $entry['order']['admin'] : '';
1469 $status = $usces->make_status( $taio, $receipt, $admin );
1470 if( $taio == 'completion' || $taio == 'continuation' ){
1471 if( 'update' == $_POST['up_modified'] ){
1472 $order_modified = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
1473 }else{
1474 $order_modified = $_POST['modified'];
1475 }
1476 }else{
1477 $order_modified = '';
1478 }
1479 $ordercheck = isset($_POST['check']) ? serialize($_POST['check']) : '';
1480 $member_id = $usces->get_memberid_by_email($_POST['customer']['mailaddress']);
1481
1482 if( 'cancel' == $taio ){
1483 $query = $wpdb->prepare(
1484 "UPDATE $order_table_name SET `order_modified`=%s, `order_status`=%s WHERE ID = %d",
1485 $order_modified, $status, $ID
1486 );
1487 $res[0] = $wpdb->query( $query );
1488
1489 $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID);
1490 $new_orderdata = $wpdb->get_row( $query );
1491
1492 do_action('usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata);
1493 $usces->cart->crear_cart();
1494
1495 return 1;
1496 }
1497
1498
1499 //$wpdb->show_errors();
1500 //20101208ysk start
1501 $query = $wpdb->prepare(
1502 "UPDATE $order_table_name SET
1503 `mem_id`=%d, `order_email`=%s, `order_name1`=%s, `order_name2`=%s, `order_name3`=%s, `order_name4`=%s,
1504 `order_zip`=%s, `order_pref`=%s, `order_address1`=%s, `order_address2`=%s, `order_address3`=%s,
1505 `order_tel`=%s, `order_fax`=%s, `order_delivery`=%s, `order_cart`=%s, `order_note`=%s,
1506 `order_delivery_method`=%d, `order_delivery_date`=%s, `order_delivery_time`=%s, `order_payment_name`=%s, `order_item_total_price`=%f, `order_getpoint`=%d, `order_usedpoint`=%d,
1507 `order_discount`=%f, `order_shipping_charge`=%f, `order_cod_fee`=%f, `order_tax`=%f, `order_modified`=%s,
1508 `order_status`=%s, `order_delidue_date`=%s, `order_check`=%s
1509 WHERE ID = %d",
1510 $member_id,
1511 $_POST['customer']['mailaddress'],
1512 $_POST['customer']['name1'],
1513 $_POST['customer']['name2'],
1514 $_POST['customer']['name3'],
1515 $_POST['customer']['name4'],
1516 $_POST['customer']['zipcode'],
1517 $_POST['customer']['pref'],
1518 $_POST['customer']['address1'],
1519 $_POST['customer']['address2'],
1520 $_POST['customer']['address3'],
1521 $_POST['customer']['tel'],
1522 $_POST['customer']['fax'],
1523 serialize($_POST['delivery']),
1524 serialize($cart),
1525 $_POST['offer']['note'],
1526 $_POST['offer']['delivery_method'],
1527 $_POST['offer']['delivery_date'],
1528 $_POST['offer']['delivery_time'],
1529 $_POST['offer']['payment_name'],
1530 $item_total_price,
1531 $_POST['offer']['getpoint'],
1532 $_POST['offer']['usedpoint'],
1533 $_POST['offer']['discount'],
1534 $_POST['offer']['shipping_charge'],
1535 $_POST['offer']['cod_fee'],
1536 $_POST['offer']['tax'],
1537 $order_modified,
1538 $status,
1539 $_POST['offer']['delidue_date'],
1540 $ordercheck,
1541 $ID
1542 );
1543 //20101208ysk end
1544
1545 //20100818ysk start
1546 //$res = $wpdb->query( $query );
1547 $res[0] = $wpdb->query( $query );
1548 if(false === $res[0])
1549 return false;
1550
1551 $usces->set_order_meta_value('customer_country', $_POST['customer']['country'], $ID);
1552
1553 $i = 1;
1554 if( !empty($_POST['custom_order']) ) {
1555 foreach( $_POST['custom_order'] as $key => $value ) {
1556 $csod_key = 'csod_'.$key;
1557 if( is_array($value) )
1558 $value = serialize($value);
1559 $res[$i] = $usces->set_order_meta_value($csod_key, $value, $ID);
1560 if(false === $res[$i])
1561 return false;
1562 $i++;
1563 }
1564 }
1565 if( !empty($_POST['custom_customer']) ) {
1566 foreach( $_POST['custom_customer'] as $key => $value ) {
1567 $cscs_key = 'cscs_'.$key;
1568 if( is_array($value) )
1569 $value = serialize($value);
1570 $res[$i] = $usces->set_order_meta_value($cscs_key, $value, $ID);
1571 if(false === $res[$i])
1572 return false;
1573 $i++;
1574 }
1575 }
1576 if( !empty($_POST['custom_delivery']) ) {
1577 foreach( $_POST['custom_delivery'] as $key => $value ) {
1578 $csde_key = 'csde_'.$key;
1579 if( is_array($value) )
1580 $value = serialize($value);
1581 $res[$i] = $usces->set_order_meta_value($csde_key, $value, $ID);
1582 if(false === $res[$i])
1583 return false;
1584 $i++;
1585 }
1586 }
1587 $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
1588 if ( !preg_match('/pending|noreceipt/', $old_status) && preg_match('/pending|noreceipt/', $status) ) {
1589 $rquery = $wpdb->prepare("DELETE FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date');
1590 $wpdb->query( $rquery );
1591 }else if ( !preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) {
1592 $query = $wpdb->prepare("SELECT order_id FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date');
1593 $varres = $wpdb->get_var( $query );
1594 if( empty($varres) ){
1595 $usces->set_order_meta_value('receipted_date', $value, $ID);
1596 }
1597 }else if ( preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) {
1598 $usces->set_order_meta_value('receipted_date', $value, $ID);
1599 }
1600 //20120306ysk start 0000324
1601 if( !usces_is_complete_settlement( $_POST['offer']['payment_name'] ) ) {
1602 if( !preg_match('/pending|noreceipt/', $old_status) && preg_match('/pending|noreceipt/', $status) ) {//�
1603 �金→未�
1604 �金
1605 usces_action_acting_getpoint( $ID, false );//ポイント取消
1606 } else if( preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) {//未�
1607 �金→�
1608 �金
1609 usces_action_acting_getpoint( $ID );//ポイント追加
1610 //20120919ysk start 0000573
1611 //} else if( preg_match('/completion|continuation/', $old_status) && !preg_match('/completion|continuation/', $status) ) {//発送済み→未発送
1612 // if( !preg_match('/receipt/', $old_status) ) {
1613 // usces_action_acting_getpoint( $ID, false );//ポイント取消
1614 // }
1615 //} else if( !preg_match('/completion|continuation/', $old_status) && preg_match('/completion|continuation/', $status) ) {//未発送→発送済み
1616 // if( !preg_match('/receipt/', $old_status) ) {
1617 // usces_action_acting_getpoint( $ID );//ポイント追加
1618 // }
1619 //20120919ysk end
1620 }
1621 }
1622 //20120306ysk end
1623
1624 $result = ( 0 < array_sum($res) ) ? 1 : 0;
1625 //20100818ysk end
1626
1627 $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID);
1628 $new_orderdata = $wpdb->get_row( $query );
1629 //20120612ysk start 0000501
1630 //do_action('usces_action_update_orderdata', $new_orderdata);
1631 do_action('usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata);
1632 //20120612ysk end
1633 $usces->cart->crear_cart();
1634
1635 return $result;
1636
1637 // else :
1638 //
1639 // if ( $member['ID'] ) {
1640 //
1641 // $mquery = $wpdb->prepare(
1642 // "UPDATE $member_table_name SET mem_point = (mem_point + %d - %d) WHERE ID = %d",
1643 // $entry['order']['getpoint'], $entry['order']['usedpoint'], $member['ID']);
1644 //
1645 // $wpdb->query( $mquery );
1646 // $mquery = $wpdb->prepare("SELECT mem_point FROM $member_table_name WHERE ID = %d", $member['ID']);
1647 // $point = $wpdb->get_var( $mquery );
1648 // $_SESSION['usces_member']['point'] = $point;
1649 // }
1650 //
1651 // if ( !empty($entry['reserve']) ) {
1652 // foreach ( $entry['reserve'] as $key => $value ) {
1653 // if ( is_array($value) )
1654 // $value = serialize($value);
1655 // $mquery = $wpdb->prepare("INSERT INTO $order_table_meta_name ( order_id, meta_key, meta_value )
1656 // VALUES (%d, %s, %s, %s)", $order_id, $key, $value);
1657 // $wpdb->query( $mquery );
1658 // }
1659 // }
1660 //
1661 // endif;
1662 //
1663 // //zaiko
1664 // foreach($cart as $cartrow){
1665 // $zaikonum = $usces->getItemZaikoNum( $cartrow['post_id'], $cartrow['sku'] );
1666 // if($zaikonum == '') continue;
1667 // $zaikonum = $zaikonum - $cartrow['quantity'];
1668 // $usces->updateItemZaikoNum( $cartrow['post_id'], $cartrow['sku'], $zaikonum );
1669 // if($zaikonum <= 0) $usces->updateItemZaiko( $cartrow['post_id'], $cartrow['sku'], 2 );
1670 // }
1671 //
1672 // return $order_id;
1673
1674 }
1675
1676
1677
1678 function usces_export_xml() {
1679 $options = get_option('usces');
1680 echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . ">\n";
1681 ?>
1682 <usces><?php echo serialize($options); ?></usces>
1683 <usces_management_status><?php echo serialize(get_option('usces_management_status')); ?></usces_management_status>
1684 <usces_zaiko_status><?php echo serialize(get_option('usces_zaiko_status')); ?></usces_zaiko_status>
1685 <usces_customer_status><?php echo serialize(get_option('usces_customer_status')); ?></usces_customer_status>
1686 <usces_payment_structure><?php echo serialize(get_option('usces_payment_structure')); ?></usces_payment_structure>
1687 <usces_display_mode><?php echo serialize(get_option('usces_display_mode')); ?></usces_display_mode>
1688 <!--20110331ysk start-->
1689 <!-- <usces_pref><?php //echo serialize(get_option('usces_pref')); ?></usces_pref>-->
1690 <!--20110331ysk end-->
1691 <usces_shipping_rule><?php echo serialize(get_option('usces_shipping_rule')); ?></usces_shipping_rule>
1692
1693 <?php
1694 }
1695
1696 function usces_all_change_zaiko(&$obj) {
1697 global $wpdb, $usces;
1698
1699 $ids = $_POST['listcheck'];
1700 $status = true;
1701 foreach ( (array)$ids as $post_id ){
1702 $skus = $usces->get_skus($post_id);
1703 foreach ( (array)$skus as $sku ){
1704 $res = usces_update_sku( $post_id, $sku['code'], 'stock', (int)$_POST['change']['word']['zaiko'] );
1705 if( !$res ){
1706 $status = false;
1707 }
1708 }
1709 }
1710 if ( true === $status ) {
1711 $obj->set_action_status('success', __('I completed collective operation.','usces'));
1712 } elseif ( false === $status ) {
1713 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
1714 } else {
1715 $obj->set_action_status('none', '');
1716 }
1717 }
1718
1719 function usces_all_change_itemdisplay(&$obj){
1720 global $wpdb;
1721
1722 $ids = $_POST['listcheck'];
1723 $post_status = $_POST['change']['word']['display_status'];
1724 $status = true;
1725 foreach ( (array)$ids as $post_id ):
1726 // $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s WHERE ID = %d", $post_status, $post_id);
1727 // $res = $wpdb->query( $query );
1728 $post_data = array('ID'=>$post_id, 'post_status'=>$post_status);
1729 $res = wp_update_post( $post_data );
1730
1731 if( $res == 0 ) {
1732 $status = false;
1733 }
1734 endforeach;
1735 if ( true === $status ) {
1736 $obj->set_action_status('success', __('I completed collective operation.','usces'));
1737 } elseif ( false === $status ) {
1738 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
1739 } else {
1740 $obj->set_action_status('none', '');
1741 }
1742 }
1743
1744 function usces_all_change_order_reciept(&$obj){
1745 global $wpdb, $usces;
1746
1747 $tableName = $wpdb->prefix . "usces_order";
1748 $ids = $_POST['listcheck'];
1749 $status = true;
1750 foreach ( (array)$ids as $id ):
1751 //20120306ysk start 0000324
1752 //$query = $wpdb->prepare("SELECT order_status FROM $tableName WHERE ID = %d", $id);
1753 //$statusstr = $wpdb->get_var( $query );
1754 $query = $wpdb->prepare("SELECT order_status, mem_id, order_getpoint FROM $tableName WHERE ID = %d", $id);
1755 $order_res = $wpdb->get_row( $query, ARRAY_A );
1756 $statusstr = $order_res['order_status'];
1757 $restore_point = false;
1758 $getpoint = $order_res['order_getpoint'];
1759 //20120306ysk end
1760 if(strpos($statusstr, 'noreceipt') === false && strpos($statusstr, 'receipted') === false) continue;
1761 if($_REQUEST['change']['word']['order_reciept'] == 'receipted') {
1762 //20120306ysk start 0000324
1763 //if(strpos($statusstr, 'noreceipt') !== false)
1764 if(strpos($statusstr, 'noreceipt') !== false) {
1765 $statusstr = str_replace('noreceipt', 'receipted', $statusstr);
1766 //if( !$usces->is_status('completion', $order_res['order_status']) ) {
1767 $restore_point = true;
1768 $getpoint = $getpoint * -1;//add point
1769 //}
1770 }
1771 //20120306ysk end
1772 }elseif($_REQUEST['change']['word']['order_reciept'] == 'noreceipt') {
1773 //20120306ysk start 0000324
1774 //if(strpos($statusstr, 'receipted') !== false)
1775 if(strpos($statusstr, 'receipted') !== false) {
1776 $statusstr = str_replace('receipted', 'noreceipt', $statusstr);
1777 //if( !$usces->is_status('completion', $order_res['order_status']) )
1778 $restore_point = true;
1779 }
1780 //20120306ysk end
1781 }
1782 $query = $wpdb->prepare("UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id);
1783 $res = $wpdb->query( $query );
1784 if( $res === false ) {
1785 $status = false;
1786 }
1787 //20120306ysk start 0000324
1788 if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) {
1789 if( !empty($order_res['mem_id']) && 0 < $order_res['order_getpoint'] ) {
1790 if( $res && $restore_point ) usces_restore_point( $order_res['mem_id'], $getpoint );
1791 }
1792 }
1793 //20120306ysk end
1794 endforeach;
1795 if ( true === $status ) {
1796 $obj->set_action_status('success', __('I completed collective operation.','usces'));
1797 } elseif ( false === $status ) {
1798 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
1799 } else {
1800 $obj->set_action_status('none', '');
1801 }
1802 do_action('usces_action_collective_order_reciept', array(&$obj));
1803 }
1804
1805 function usces_all_change_order_status(&$obj){
1806 global $wpdb, $usces;
1807
1808 $tableName = $wpdb->prefix . "usces_order";
1809 $ids = $_POST['listcheck'];
1810 foreach ( (array)$ids as $id ):
1811 $status = true;
1812 //20120306ysk start 0000324
1813 //$query = $wpdb->prepare("SELECT order_status FROM $tableName WHERE ID = %d", $id);
1814 //$statusstr = $wpdb->get_var( $query );
1815 $query = $wpdb->prepare("SELECT order_status, mem_id, order_getpoint, order_payment_name FROM $tableName WHERE ID = %d", $id);
1816 $order_res = $wpdb->get_row( $query, ARRAY_A );
1817 $statusstr = $order_res['order_status'];
1818 $restore_point = false;
1819 $getpoint = $order_res['order_getpoint'];
1820 //20120306ysk end
1821 $old_status = $statusstr;//20120612ysk 0000501
1822 switch ($_REQUEST['change']['word']['order_status']) {
1823 case 'estimate':
1824 if(strpos($statusstr, 'adminorder') !== false) {
1825 $statusstr = str_replace('adminorder', 'estimate', $statusstr);
1826 }else if(strpos($statusstr, 'estimate') === false) {
1827 $statusstr .= 'estimate,';
1828 }
1829 break;
1830 case 'adminorder':
1831 if(strpos($statusstr, 'estimate') !== false) {
1832 $statusstr = str_replace('estimate', 'adminorder', $statusstr);
1833 }else if(strpos($statusstr, 'adminorder') === false) {
1834 $statusstr .= 'adminorder,';
1835 }
1836 break;
1837 case 'duringorder':
1838 if(strpos($statusstr, 'cancel') !== false) {
1839 $statusstr = str_replace('cancel', 'duringorder', $statusstr);
1840 //20120919ysk start 0000573
1841 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) {
1842 $restore_point = true;
1843 $getpoint = $getpoint * -1;//add point
1844 } elseif( $usces->is_status('receipted', $order_res['order_status']) ) {
1845 $restore_point = true;
1846 $getpoint = $getpoint * -1;//add point
1847 }
1848 //20120919ysk end
1849 }else if(strpos($statusstr, 'completion') !== false) {
1850 $statusstr = str_replace('completion', 'duringorder', $statusstr);
1851 //20120306ysk start 0000324
1852 //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) )
1853 // $restore_point = true;
1854 //20120306ysk end
1855 }else if(strpos($statusstr, 'new') !== false) {
1856 $statusstr = str_replace('new', 'duringorder', $statusstr);
1857 }else if(strpos($statusstr, 'duringorder') === false) {
1858 $statusstr .= 'duringorder,';
1859 }
1860 break;
1861 case 'cancel':
1862 if(strpos($statusstr, 'completion') !== false) {
1863 $statusstr = str_replace('completion', 'cancel', $statusstr);
1864 //20120306ysk start 0000324
1865 //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) )
1866 // $restore_point = true;
1867 //20120306ysk end
1868 }else if(strpos($statusstr, 'new') !== false) {
1869 $statusstr = str_replace('new', 'cancel', $statusstr);
1870 }else if(strpos($statusstr, 'duringorder') !== false) {
1871 $statusstr = str_replace('duringorder', 'cancel', $statusstr);
1872 }else if(strpos($statusstr, 'cancel') === false) {
1873 $statusstr .= 'cancel,';
1874 }
1875 //20120919ysk start 0000573
1876 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) {
1877 $restore_point = true;
1878 } elseif( $usces->is_status('receipted', $order_res['order_status']) ) {
1879 $restore_point = true;
1880 }
1881 //20120919ysk end
1882 break;
1883 case 'completion':
1884 if(strpos($statusstr, 'new') !== false) {
1885 $statusstr = str_replace('new', 'completion', $statusstr);
1886 }else if(strpos($statusstr, 'duringorder') !== false) {
1887 $statusstr = str_replace('duringorder', 'completion', $statusstr);
1888 }else if(strpos($statusstr, 'cancel') !== false) {
1889 $statusstr = str_replace('cancel', 'completion', $statusstr);
1890 //20120919ysk start 0000573
1891 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) {
1892 $restore_point = true;
1893 $getpoint = $getpoint * -1;//add point
1894 } elseif( $usces->is_status('receipted', $order_res['order_status']) ) {
1895 $restore_point = true;
1896 $getpoint = $getpoint * -1;//add point
1897 }
1898 //20120919ysk end
1899 }else if(strpos($statusstr, 'completion') === false) {
1900 $statusstr .= 'completion,';
1901 }
1902 //20120306ysk start 0000324
1903 //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) ) {
1904 // $restore_point = true;
1905 // $getpoint = $getpoint * -1;//add point
1906 //}
1907 //20120306ysk end
1908 break;
1909 case 'new':
1910 if(strpos($statusstr, 'duringorder') !== false) {
1911 $statusstr = str_replace('duringorder,', '', $statusstr);
1912 }else if(strpos($statusstr, 'completion') !== false) {
1913 $statusstr = str_replace('completion,', '', $statusstr);
1914 //20120306ysk start 0000324
1915 //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) )
1916 // $restore_point = true;
1917 //20120306ysk end
1918 }else if(strpos($statusstr, 'cancel') !== false) {
1919 $statusstr = str_replace('cancel,', '', $statusstr);
1920 //20120919ysk start 0000573
1921 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) {
1922 $restore_point = true;
1923 $getpoint = $getpoint * -1;//add point
1924 } elseif( $usces->is_status('receipted', $order_res['order_status']) ) {
1925 $restore_point = true;
1926 $getpoint = $getpoint * -1;//add point
1927 }
1928 //20120919ysk end
1929 }
1930 break;
1931 }
1932 $query = $wpdb->prepare("UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id);
1933 $res = $wpdb->query( $query );
1934 if( $res === false ) {
1935 $status = false;
1936 }
1937 //20120306ysk start 0000324
1938 if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) {
1939 if( !empty($order_res['mem_id']) && 0 < $order_res['order_getpoint'] ) {
1940 if( $res && $restore_point ) usces_restore_point( $order_res['mem_id'], $getpoint );
1941 }
1942 }
1943 //20120306ysk end
1944 //20120612ysk 0000501 start
1945 if( $status ) {
1946 do_action('usces_action_collective_order_status_each', $id, $statusstr, $old_status);
1947 }
1948 //20120612ysk end
1949 endforeach;
1950 if ( true === $status ) {
1951 $obj->set_action_status('success', __('I completed collective operation.','usces'));
1952 } elseif ( false === $status ) {
1953 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
1954 } else {
1955 $obj->set_action_status('none', '');
1956 }
1957 do_action('usces_action_collective_order_status', array(&$obj));
1958 }
1959
1960 function usces_all_delete_order_data(&$obj){
1961 global $wpdb, $usces;
1962
1963 $tableName = $wpdb->prefix . "usces_order";
1964 $tableMetaName = $wpdb->prefix . "usces_order_meta";
1965 $ids = $_POST['listcheck'];
1966 $status = true;
1967 foreach ( (array)$ids as $id ):
1968 $del = usces_delete_order_check( $id );
1969 if( $del === false ) continue;
1970 //20120306ysk start 0000324
1971 $restore_point = false;
1972 if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) {
1973 $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $id);
1974 $order_res = $wpdb->get_row( $query, ARRAY_A );
1975 if( !empty($order_res['mem_id']) && 0 < $order_res['order_getpoint'] ) {
1976 //if( $usces->is_status('completion', $order_res['order_status']) ) {
1977 // $restore_point = true;
1978 //} else {
1979 if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) || $usces->is_status('receipted', $order_res['order_status']) )
1980 $restore_point = true;
1981 //}
1982 }
1983 }
1984 //20120306ysk end
1985 $query = $wpdb->prepare("DELETE FROM $tableName WHERE ID = %d", $id);
1986 $res = $wpdb->query( $query );
1987 if( $res === false ) {
1988 $status = false;
1989 }else{
1990 $metaquery = $wpdb->prepare("DELETE FROM $tableMetaName WHERE order_id = %d", $id);//0000427
1991 $metares = $wpdb->query( $metaquery );
1992 //20120306ysk start 0000324
1993 if( $restore_point ) usces_restore_point( $order_res['mem_id'], $order_res['order_getpoint'] );
1994 //20120306ysk end
1995 //20120612ysk start 0000501
1996 //20130419ysk
1997 do_action('usces_action_collective_order_delete_each', $id, $order_res);
1998 //20120612ysk end
1999 }
2000 endforeach;
2001 if ( true === $status ) {
2002 $obj->set_action_status('success', __('I completed collective operation.','usces'));
2003 } elseif ( false === $status ) {
2004 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
2005 } else {
2006 $obj->set_action_status('none', '');
2007 }
2008 do_action('usces_action_collective_order_delete', array(&$obj));
2009 }
2010
2011 function usces_check_acting_return() {
2012 global $usces;
2013 $entry = $usces->cart->get_entry();
2014
2015 $acting = $_GET['acting'];
2016 $results = array();
2017 switch ( $acting ) {
2018 case 'epsilon':
2019 if(isset($_GET['duplicate']) && $_GET['duplicate'] == 1){
2020 $results[0] = 'duplicate';
2021 }else if(isset($_GET['result'])){
2022 $results[0] = (int)$_GET['result'];
2023 $results['reg_order'] = true;
2024 }else{
2025 $str = explode('?', $_GET['acting_return']);
2026 if(!isset($str[1])) {
2027 $results[0] = 0;
2028 }else{
2029 $para = parse_str($str[1]);
2030 $results[0] = isset($para['result']) ? (int)$para['result'] : 0;
2031 foreach($para as $key => $value){
2032 $results[$key] = $value;
2033 }
2034 }
2035
2036 }
2037 $results['reg_order'] = true;
2038 break;
2039
2040 case 'paypal':
2041 usces_log('paypal in ', 'acting_transaction.log');
2042 require_once($usces->options['settlement_path'] . "paypal.php");
2043 $results = paypal_check($usces_paypal_url);
2044 remove_action( 'wp_footer', array(&$usces, 'lastprocessing'));
2045 $results['reg_order'] = true;
2046 break;
2047
2048 case 'zeus_card':
2049 $results = $_REQUEST;
2050 if( $_REQUEST['acting_return'] ){
2051 $results[0] = 1;
2052 }else{
2053 $results[0] = 0;
2054 }
2055 $results['reg_order'] = true;
2056 break;
2057
2058 case 'zeus_conv':
2059 $results = $_GET;
2060 if( $_REQUEST['acting_return'] ){
2061 $results[0] = 1;
2062 }else{
2063 $results[0] = 0;
2064 }
2065 $results['reg_order'] = false;
2066 break;
2067
2068 case 'remise_card':
2069 $results = $_POST;
2070 if( $_REQUEST['acting_return'] && ' ' === $_REQUEST['X-ERRCODE'] ){
2071 usces_log('remise card entry data : '.print_r($entry, true), 'acting_transaction.log');
2072 $results[0] = 1;
2073 }else{
2074 $results[0] = 0;
2075 }
2076 if( isset($_REQUEST['dlseller_update']) ){
2077 $results['reg_order'] = false;
2078 }else{
2079 $results['reg_order'] = true;
2080 }
2081 break;
2082
2083 case 'remise_conv':
2084 $results = $_GET;
2085 if( $_REQUEST['acting_return'] && isset($_REQUEST['X-JOB_ID']) && '0:0000' === $_REQUEST['X-R_CODE']){
2086 //usces_log('remise conv entry data : '.print_r($entry, true), 'acting_transaction.log');
2087 $results[0] = 1;
2088 }else{
2089 $results[0] = 0;
2090 }
2091 $results['reg_order'] = true;
2092 break;
2093
2094 //20101018ysk start
2095 case 'jpayment_card':
2096 $results = $_GET;
2097 if($_GET['rst'] == 2) {
2098 usces_log('jpayment card error : '.print_r($entry, true), 'acting_transaction.log');
2099 }
2100 $results[0] = ($_GET['rst'] == 1) ? 1 : 0;
2101 $results['reg_order'] = true;
2102 break;
2103
2104 case 'jpayment_conv':
2105 $results = $_GET;
2106 if($_GET['rst'] == 2) {
2107 usces_log('jpayment conv error : '.print_r($entry, true), 'acting_transaction.log');
2108 }
2109 $results[0] = ($_GET['rst'] == 1 and $_GET['ap'] == 'CPL_PRE') ? 1 : 0;
2110 $results['reg_order'] = true;
2111 break;
2112
2113 case 'jpayment_bank':
2114 $results = $_GET;
2115 if($_GET['rst'] == 2) {
2116 usces_log('jpayment bank error : '.print_r($entry, true), 'acting_transaction.log');
2117 }
2118 $results[0] = ($_GET['rst'] == 1) ? 1 : 0;
2119 $results['reg_order'] = true;
2120 break;
2121 //20101018ysk end
2122 //20110208ysk start
2123 case 'paypal_ec':
2124 $results = $_GET;
2125
2126 //Build a second API request to PayPal, using the token as the ID to get the details on the payment authorization
2127 $nvpstr = "&TOKEN=".urlencode($_REQUEST['token']);
2128
2129 $usces->paypal->setMethod('GetExpressCheckoutDetails');
2130 $usces->paypal->setData($nvpstr);
2131 $res = $usces->paypal->doExpressCheckout();
2132 $resArray = $usces->paypal->getResponse();
2133 $ack = strtoupper($resArray["ACK"]);
2134 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
2135 //20121009ysk start 0000587
2136 //20121225ysk start 000634
2137 $cart = $usces->cart->get_cart();
2138 $charging_type = $usces->getItemChargingType($cart[0]['post_id'], $cart);
2139 if( 'continue' == $charging_type ) {
2140 $results[0] = 1;
2141 } else {
2142 //20121225ysk end
2143 if( (float)$resArray["AMT"] != (float)$entry['order']['total_full_price'] ) {
2144 usces_log('PayPal : AMT Error. AMT='.$resArray["AMT"].', total_full_price='.$entry['order']['total_full_price'], 'acting_transaction.log');
2145 $results[0] = 0;
2146 } else {
2147 $results[0] = 1;
2148 }
2149 }
2150 //20121009ysk end
2151
2152 } else {
2153 //Display a user friendly Error on the page using any of the following error information returned by PayPal
2154 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
2155 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
2156 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
2157 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
2158 usces_log('PayPal : GetExpressCheckoutDetails API call failed. Error Code:['.$ErrorCode.'] Error Severity Code:['.$ErrorSeverityCode.'] Short Error Message:'.$ErrorShortMsg.' Detailed Error Message:'.$ErrorLongMsg, 'acting_transaction.log');
2159 $results[0] = 0;
2160 }
2161 $results['reg_order'] = true;
2162 break;
2163 //20110208ysk end
2164 //20120413ysk start
2165 case 'sbps_card':
2166 case 'sbps_wallet':
2167 case 'sbps_mobile':
2168 /* if( isset($_REQUEST['cancel']) ) {
2169 $results[0] = 0;
2170 $results['reg_order'] = false;
2171
2172 } else {
2173 if( isset($_REQUEST['res_result']) and 'OK' == $_REQUEST['res_result'] ) {
2174 usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log');
2175 $results[0] = 1;
2176 } else {
2177 usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log');
2178 $results[0] = 0;
2179 }
2180 $results['reg_order'] = true;
2181 }
2182 break;*/
2183 case 'sbps_conv':
2184 case 'sbps_payeasy':
2185 if( isset($_REQUEST['cancel']) ) {
2186 $results[0] = 0;
2187 $results['reg_order'] = false;
2188
2189 } else {
2190 if( isset($_REQUEST['res_result']) and 'OK' == $_REQUEST['res_result'] ) {
2191 $results[0] = 1;
2192 } else {
2193 //usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log');
2194 $results[0] = 0;
2195 }
2196 $results['reg_order'] = false;
2197 }
2198 break;
2199 //20120413ysk end
2200 //20120618ysk start
2201 case 'telecom_card':
2202 $results = $_GET;
2203 if( $_REQUEST['result'] ){
2204 usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log');
2205 $results[0] = 1;
2206 }else{
2207 usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log');
2208 $results[0] = 0;
2209 }
2210 $results['reg_order'] = true;
2211 break;
2212 //20120618ysk end
2213 //20121206ysk start
2214 case 'digitalcheck_card':
2215 $results = $_REQUEST;
2216 if( isset($_REQUEST['SID']) ) {
2217 $results[0] = 1;
2218 } else {
2219 $results[0] = 0;
2220 }
2221 $results['reg_order'] = true;
2222 break;
2223 case 'digitalcheck_conv':
2224 $results = $_REQUEST;
2225 //if( isset($_REQUEST['SID']) ) {
2226 $results[0] = 1;
2227 //} else {
2228 // $results[0] = 0;
2229 //}
2230 $results['reg_order'] = false;
2231 break;
2232 //20121206ysk end
2233 //20130225ysk start
2234 case 'mizuho_card':
2235 case 'mizuho_conv':
2236 $results = $_GET;
2237 if( isset($_GET['rsltcd']) ) {
2238 if( '000' == substr($_GET['rsltcd'], 0, 3) ) {
2239 $results[0] = 1;
2240 $results['reg_order'] = true;
2241 } else {
2242 $results[0] = 0;
2243 $results['reg_order'] = false;
2244 }
2245 } else {
2246 $results[0] = 0;
2247 $results['reg_order'] = false;
2248 }
2249 break;
2250 //20130225ysk end
2251
2252 default:
2253 do_action( 'usces_action_check_acting_return_default' );
2254 $results = $_GET;
2255 if( $_REQUEST['result'] ){
2256 usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log');
2257 $results[0] = 1;
2258 }else{
2259 usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log');
2260 $results[0] = 0;
2261 }
2262 //20110310ysk start
2263 //$results['reg_order'] = false;
2264 $results['reg_order'] = true;
2265 //20110310ysk end
2266 break;
2267 }
2268
2269 return $results;
2270 }
2271 //20110203ysk start
2272 function usces_check_acting_return_duplicate( $results = array() ) {
2273 global $wpdb;
2274 $acting = isset($_GET['acting']) ? $_GET['acting'] : '';
2275 // usces_log('$_REQUEST : '.print_r($_REQUEST,true), 'acting_transaction.log');
2276 // usces_log('$results : '.print_r($results,true), 'acting_transaction.log');
2277
2278 switch($acting) {
2279 case 'epsilon':
2280 $trans_id = isset($_REQUEST['trans_code']) ? $_REQUEST['trans_code'] : '';
2281 break;
2282 //20110208ysk start
2283 case 'paypal':
2284 $trans_id = isset($results['txn_id']) ? $results['txn_id'] : '';
2285 break;
2286 //20110208ysk end
2287 case 'paypal_ipn':
2288 $trans_id = isset($_REQUEST['txn_id']) ? $_REQUEST['txn_id'] : '';
2289 break;
2290 //20110208ysk start
2291 case 'paypal_ec':
2292 $trans_id = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';
2293 break;
2294 //20110208ysk end
2295 case 'zeus_card':
2296 $trans_id = isset($_REQUEST['ordd']) ? $_REQUEST['ordd'] : '';
2297 break;
2298 case 'zeus_conv':
2299 case 'zeus_bank':
2300 $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : '';
2301 break;
2302 case 'remise_card':
2303 $trans_id = isset($_REQUEST['X-TRANID']) ? $_REQUEST['X-TRANID'] : '';
2304 break;
2305 case 'remise_conv':
2306 $trans_id = isset($_REQUEST['X-JOB_ID']) ? $_REQUEST['X-JOB_ID'] : '';
2307 break;
2308 case 'jpayment_card':
2309 case 'jpayment_conv':
2310 case 'jpayment_bank':
2311 $trans_id = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : '';
2312 break;
2313 //20120413ysk start
2314 case 'sbps_card':
2315 case 'sbps_conv':
2316 case 'sbps_payeasy':
2317 case 'sbps_wallet':
2318 case 'sbps_mobile':
2319 $trans_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : '';
2320 break;
2321 //20120413ysk end
2322 //20120618ysk start
2323 case 'telecom_card':
2324 $trans_id = isset($_REQUEST['sendid']) ? $_REQUEST['sendid'] : '';
2325 break;
2326 //20120618ysk end
2327 //20121206ysk start
2328 case 'digitalcheck_card':
2329 case 'digitalcheck_conv':
2330 $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : '';
2331 break;
2332 //20121206ysk end
2333 //20130225ysk start
2334 case 'mizuho_card':
2335 case 'mizuho_conv':
2336 $trans_id = isset($_REQUEST['stran']) ? $_REQUEST['stran'] : '';
2337 break;
2338 //20130225ysk end
2339 default:
2340 $trans_id = '';
2341 }
2342 $table_meta_name = $wpdb->prefix.'usces_order_meta';
2343 $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'trans_id', $trans_id);
2344 $order_id = $wpdb->get_var($query);
2345 return $order_id;
2346 }
2347 //20110203ysk end
2348
2349 //20111111ysk start
2350 function usces_dates_interconv( $date_str ) {
2351 $base_struc = split('[/.-]', 'd/m/Y' );
2352 $date_str_parts = split('[/.-]', $date_str );
2353 $date_elements = array();
2354
2355 $p_keys = array_keys( $base_struc );
2356 foreach( $p_keys as $p_key ) {
2357 if( !empty( $date_str_parts[$p_key] )) {
2358 $date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key];
2359 } else {
2360 return false;
2361 }
2362 }
2363 $dummy_ts = mktime( 0,0,0, $date_elements['m'],$date_elements['d'],$date_elements['Y']);
2364 return date( 'Y-m-d', $dummy_ts );
2365 }
2366 //20101111ysk end
2367
2368 function usces_register_action($handle, $type, $key, $value, $function){
2369 global $usces_action;
2370 $usces_action[$handle] = array('type'=>$type, 'key'=>$key, 'value'=>$value, 'function'=>$function);
2371 }
2372
2373 function usces_deregister_action($handle){
2374 global $usces_action;
2375 unset($usces_action[$handle]);
2376 }
2377
2378 function usces_get_wcexp($post_id, $name=''){
2379 $wcexp = get_post_meta($post_id, '_wcexp', true);
2380 if( empty($name) ){
2381 $value = ( $wcexp !== false ) ? $wcexp : '';
2382 }else{
2383 $value = ($wcexp !== false && isset($wcexp[$name])) ? $wcexp[$name] : '';
2384 }
2385 return $value;
2386 }
2387
2388 function usces_update_check_admin($result){
2389 $result = true;
2390 return $result;
2391 }
2392
2393 function usces_setup_cod_ajax(){
2394 global $usces;
2395 $usces->options = get_option('usces');
2396 $message = '';
2397 $_POST = $usces->stripslashes_deep_post($_POST);
2398
2399 $usces->options['cod_type'] = isset($_POST['cod_type']) ? $_POST['cod_type'] : 'fix';
2400 if( isset($_POST['cod_fee']) )
2401 $usces->options['cod_fee'] = (int)$_POST['cod_fee'];
2402
2403 if( 'fix' == $usces->options['cod_type'] ){
2404 if( isset($_POST['cod_limit_amount']) ){
2405 $usces->options['cod_limit_amount'] = (int)$_POST['cod_limit_amount'];
2406 if( !WCUtils::is_blank($_POST['cod_limit_amount']) && 0 === (int)$_POST['cod_limit_amount'] )
2407 $message = __('There is the item where a value is dirty.', 'usces');
2408 }
2409
2410 }elseif( 'change' == $usces->options['cod_type'] ){
2411 if( isset($_POST['cod_first_amount']) ){
2412 $usces->options['cod_first_amount'] = (int)$_POST['cod_first_amount'];
2413 if( 0 === (int)$_POST['cod_first_amount'] )
2414 $message = __('There is the item where a value is dirty.', 'usces');
2415 }
2416 if( isset($_POST['cod_limit_amount']) ){
2417 $usces->options['cod_limit_amount'] = (int)$_POST['cod_limit_amount'];
2418 if( !WCUtils::is_blank($_POST['cod_limit_amount']) && 0 === (int)$_POST['cod_limit_amount'] )
2419 $message = __('There is the item where a value is dirty.', 'usces');
2420 }
2421 if( isset($_POST['cod_first_fee']) ){
2422 $usces->options['cod_first_fee'] = (int)$_POST['cod_first_fee'];
2423 if( 0 === (int)$_POST['cod_first_fee'] && '0' !== $_POST['cod_first_fee'])
2424 $message = __('There is the item where a value is dirty.', 'usces');
2425 }
2426 if( isset($_POST['cod_end_fee']) ){
2427 $usces->options['cod_end_fee'] = (int)$_POST['cod_end_fee'];
2428 if( 0 === (int)$_POST['cod_end_fee'] && '0' !== $_POST['cod_end_fee'] )
2429 $message = __('There is the item where a value is dirty.', 'usces');
2430 }
2431
2432 unset($usces->options['cod_amounts'], $usces->options['cod_fees']);
2433 if( isset($_POST['cod_amounts']) ){
2434 for($i=0; $i<count((array)$_POST['cod_amounts']); $i++){
2435 $usces->options['cod_amounts'][$i] = (int)$_POST['cod_amounts'][$i];
2436 $usces->options['cod_fees'][$i] = (int)$_POST['cod_fees'][$i];
2437 if( 0 === (int)$_POST['cod_amounts'][$i] || (0 === (int)$_POST['cod_fees'][$i] && '0' !== $_POST['cod_fees'][$i]) )
2438 $message = __('There is the item where a value is dirty.', 'usces');
2439 }
2440 }
2441 }
2442
2443
2444 if( '' == $message ){
2445 $r = 'success';
2446 update_option('usces', $usces->options);
2447 }else{
2448 $r = '<span style="color:red;">' . $message . '</span>';
2449 }
2450 die( $r );
2451 }
2452
2453 function usces_get_order_acting_data($rand){
2454 global $wpdb;
2455
2456 $table_name = $wpdb->prefix . "usces_access";
2457 $query = $wpdb->prepare("SELECT acc_str1 AS sesid, acc_value AS order_data FROM $table_name WHERE acc_key = %s", $rand);
2458 $res = $wpdb->get_row($query, ARRAY_A);
2459 if($res == NULL){
2460 return false;
2461 }else{
2462 return $res;
2463 }
2464 }
2465
2466 function usces_get_filename( $path ){
2467 $res = array();
2468 if ( $handle = opendir($path) ) {
2469 while (false !== ($file = readdir($handle))) {
2470 if( '.' != $file && '..' != $file )
2471 $res[] = $file;
2472 }
2473 closedir($handle);
2474 }
2475 return $res;
2476 }
2477
2478 function usces_locales(){
2479 $res = array();
2480 if ( $handle = opendir(USCES_PLUGIN_DIR.'/languages/') ) {
2481 while (false !== ($file = readdir($handle))) {
2482 if( '.' != $file && '..' != $file && preg_match('/^usces-(.+)\.mo$/', $file, $matches) ){
2483 $res[] = $matches[1];
2484 }
2485 }
2486 closedir($handle);
2487 }
2488 return $res;
2489 }
2490
2491 function usces_get_local_language(){
2492 $locale = get_locale();
2493 switch( $locale ){
2494 case '':
2495 case 'en':
2496 case 'en_US':
2497 $front_lang = 'en';
2498 break;
2499 case 'ja':
2500 case 'ja_JP':
2501 $front_lang = 'ja';
2502 break;
2503 default:
2504 $front_lang = 'others';
2505 }
2506 return $front_lang;
2507 }
2508
2509 function usces_get_base_country(){
2510 global $usces_settings;
2511 // $locale = get_locale();
2512 $wplang = defined('WPLANG') ? WPLANG : '';
2513 $locale = empty( $wplang ) ? 'en' : $wplang;
2514 if( array_key_exists($locale, $usces_settings['lungage2country']) )
2515 return $usces_settings['lungage2country'][$locale];
2516 else
2517 return 'US';
2518 }
2519
2520 function usces_get_local_addressform(){
2521 global $usces_settings;
2522 $base = usces_get_base_country();
2523 if( array_key_exists($base, $usces_settings['addressform']) )
2524 return $usces_settings['addressform'][$base];
2525 else
2526 return 'US';
2527 }
2528
2529 function usces_get_local_target_market(){
2530 $base = usces_get_base_country();
2531 return (array)$base;
2532 }
2533
2534 function usces_get_apply_addressform($country){
2535 global $usces_settings;
2536 return $usces_settings['addressform'][$country];
2537 }
2538
2539 function usces_remove_filter(){
2540 global $usces, $post;
2541
2542 if( is_single() && 'item' == $post->post_mime_type ) {
2543 remove_filter('the_content', array(&$usces, 'filter_itemPage'));
2544
2545 }else if( $usces->is_cart_page($_SERVER['REQUEST_URI']) || $usces->is_inquiry_page($_SERVER['REQUEST_URI']) ){
2546 remove_action('the_post', array(&$usces, 'action_cartFilter'));
2547 remove_filter('the_title', array(&$usces, 'filter_cartTitle'),20);
2548 remove_filter('the_content', array(&$usces, 'filter_cartContent'),20);
2549
2550 }else if( $usces->is_member_page($_SERVER['REQUEST_URI']) ){
2551 remove_action('the_post', array(&$usces, 'action_memberFilter'));
2552 remove_filter('the_title', array(&$usces, 'filter_memberTitle'),20);
2553 remove_filter('the_content', array(&$usces, 'filter_memberContent'),20);
2554
2555 }else{
2556 remove_action('the_post', array(&$usces, 'goDefaultPage'));
2557 }
2558 }
2559
2560 function usces_reset_filter(){
2561 global $usces, $post;
2562
2563 if( is_single() && 'item' == $post->post_mime_type ) {
2564 add_filter('the_content', array(&$usces, 'filter_itemPage'));
2565
2566 }else if( $usces->is_cart_page($_SERVER['REQUEST_URI']) || $usces->is_inquiry_page($_SERVER['REQUEST_URI']) ){
2567 add_action('the_post', array(&$usces, 'action_cartFilter'));
2568 add_filter('the_title', array(&$usces, 'filter_cartTitle'),20);
2569 add_filter('the_content', array(&$usces, 'filter_cartContent'),20);
2570
2571 }else if( $usces->is_member_page($_SERVER['REQUEST_URI']) ){
2572 add_action('the_post', array(&$usces, 'action_memberFilter'));
2573 add_filter('the_title', array(&$usces, 'filter_memberTitle'),20);
2574 add_filter('the_content', array(&$usces, 'filter_memberContent'),20);
2575
2576 }else{
2577 add_action('the_post', array(&$usces, 'goDefaultPage'));
2578 }
2579 }
2580
2581
2582 function usces_get_wcex(){
2583 $wcex = array();
2584 if( defined('WCEX_DLSELLER_VERSION'))
2585 $wcex['DLSELLER'] = array('name'=>'Dl Seller', 'version'=>WCEX_DLSELLER_VERSION);
2586 if( defined('WCEX_ITEM_LIST_LAYOUT_VERSION'))
2587 $wcex['ITEM_LIST_LAYOUT'] = array('name'=>'Item List Layout', 'version'=>WCEX_ITEM_LIST_LAYOUT_VERSION);
2588 if( defined('WCEX_MOBILE_VERSION'))
2589 $wcex['MOBILE'] = array('name'=>'Mobile', 'version'=>WCEX_MOBILE_VERSION);
2590 if( defined('WCEX_MULTIPRICE_VERSION'))
2591 $wcex['MULTIPRICE'] = array('name'=>'Multi Price', 'version'=>WCEX_MULTIPRICE_VERSION);
2592 if( defined('WCEX_SLIDE_SHOWCASE_VERSION'))
2593 $wcex['SLIDE_SHOWCASE'] = array('name'=>'Slide Showcase', 'version'=>WCEX_SLIDE_SHOWCASE_VERSION);
2594 if( defined('WCEX_WIDGET_CART_VERSION'))
2595 $wcex['WIDGET_CART'] = array('name'=>'Widget Cart', 'version'=>WCEX_WIDGET_CART_VERSION);
2596
2597 return $wcex;
2598 }
2599
2600 function usces_trackPageview_cart($push){
2601 $push = array();
2602 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2603 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_cart'";
2604 }else{
2605 $push[] = "'_trackPageview','/wc_cart'";
2606 }
2607 return $push;
2608 }
2609
2610 function usces_trackPageview_customer($push){
2611 $push = array();
2612 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2613 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_customer'";
2614 }else{
2615 $push[] = "'_trackPageview','/wc_customer'";
2616 }
2617 return $push;
2618 }
2619
2620 function usces_trackPageview_delivery($push){
2621 $push = array();
2622 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2623 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_delivery'";
2624 }else{
2625 $push[] = "'_trackPageview','/wc_delivery'";
2626 }
2627 return $push;
2628 }
2629
2630 function usces_trackPageview_confirm($push){
2631 $push = array();
2632 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2633 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_confirm'";
2634 }else{
2635 $push[] = "'_trackPageview','/wc_confirm'";
2636 }
2637 return $push;
2638 }
2639
2640 function usces_trackPageview_ordercompletion($push){
2641 global $usces;
2642 $sesdata = $usces->cart->get_entry();
2643 $order_id = $sesdata['order']['ID'];
2644 $data = $usces->get_order_data($order_id, 'direct');
2645 $cart = unserialize($data['order_cart']);
2646 $total_price = $usces->get_total_price( $cart ) - $data['order_discount'];
2647
2648 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2649 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_ordercompletion'";
2650 }else{
2651 $push[] = "'_trackPageview','/wc_ordercompletion'";
2652 }
2653 $push[] = "'_addTrans', '" . $order_id . "', '" . get_option('blogname') . "', '" . $total_price . "', '" . $data['order_tax'] . "', '" . $data['order_shipping_charge'] . "', '" . $data['order_address1'].$data['order_address2'] . "', '" . $data['order_pref'] . "', '" . get_locale() . "'";
2654 for($i=0; $i<count($cart); $i++) {
2655 $cart_row = $cart[$i];
2656 $post_id = $cart_row['post_id'];
2657 $sku = urldecode($cart_row['sku']);
2658 $quantity = $cart_row['quantity'];
2659 // $options = $cart_row['options'];
2660 // $advance = $usces->cart->wc_serialize($cart_row['advance']);
2661 // $itemCode = $usces->getItemCode($post_id);
2662 $itemName = $usces->getItemName($post_id);
2663 // $cartItemName = $usces->getCartItemName($post_id, $sku);
2664 $skuPrice = $cart_row['price'];
2665 $cats = $usces->get_item_cat_genre_ids( $post_id );
2666 if( is_array($cats) )
2667 sort($cats);
2668 $category = get_cat_name( $cats[0] );
2669 $push[] = "'_addItem', '" . $order_id . "', '" . $sku . "', '" . $itemName . "', '" . $category . "', '" . $skuPrice . "', '" . $quantity . "'";
2670 }
2671 $push[] = "'_trackTrans'";
2672
2673 return $push;
2674 }
2675
2676 function usces_trackPageview_error($push){
2677 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2678 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_error'";
2679 }else{
2680 $push[] = "'_trackPageview','/wc_error'";
2681 }
2682 return $push;
2683 }
2684
2685 function usces_trackPageview_member($push){
2686 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2687 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_member'";
2688 }else{
2689 $push[] = "'_trackPageview','/wc_member'";
2690 }
2691 return $push;
2692 }
2693
2694 function usces_trackPageview_login($push){
2695 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2696 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_login'";
2697 }else{
2698 $push[] = "'_trackPageview','/wc_login'";
2699 }
2700 return $push;
2701 }
2702
2703 function usces_trackPageview_editmemberform($push){
2704 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2705 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_editmemberform'";
2706 }else{
2707 $push[] = "'_trackPageview','/wc_editmemberform'";
2708 }
2709 return $push;
2710 }
2711
2712 function usces_trackPageview_newcompletion($push){
2713 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2714 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newcompletion'";
2715 }else{
2716 $push[] = "'_trackPageview','/wc_newcompletion'";
2717 }
2718 return $push;
2719 }
2720
2721 function usces_trackPageview_newmemberform($push){
2722 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2723 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newmemberform'";
2724 }else{
2725 $push[] = "'_trackPageview','/wc_newmemberform'";
2726 }
2727 return $push;
2728 }
2729
2730 function usces_trackPageview_deletemember($push){
2731 if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){
2732 $push[] = "'_trackPageview','/" . USCES_KEY . "wc_deletemember'";
2733 }else{
2734 $push[] = "'_trackPageview','/wc_deletemember'";
2735 }
2736 return $push;
2737 }
2738
2739 function usces_get_essential_mark( $fielde, $data = NULL ){
2740 global $usces_essential_mark;
2741 do_action('usces_action_essential_mark', $data, $fielde);
2742 return $usces_essential_mark[$fielde];
2743 }
2744
2745 function uesces_get_admin_addressform( $type, $data, $customdata, $out = 'return' ){
2746 global $usces, $usces_settings;
2747 $options = get_option('usces');
2748 $applyform = usces_get_apply_addressform($options['system']['addressform']);
2749 $formtag = '';
2750 switch( $type ){
2751 case 'member':
2752 $values = array('name1'=>$data['mem_name1'], 'name2'=>$data['mem_name2'], 'name3'=>$data['mem_name3'], 'name4'=>$data['mem_name4'], 'zipcode'=>$data['mem_zip'], 'address1'=>$data['mem_address1'], 'address2'=>$data['mem_address2'], 'address3'=>$data['mem_address3'], 'tel'=>$data['mem_tel'], 'fax'=>$data['mem_fax'], 'pref'=>$data['mem_pref']);
2753 $country = $usces->get_member_meta_value('customer_country', $data['ID']);
2754 $values['country'] = !empty($country) ? $country : usces_get_local_addressform();
2755 break;
2756 case 'customer':
2757 $values = array('name1'=>$data['order_name1'], 'name2'=>$data['order_name2'], 'name3'=>$data['order_name3'], 'name4'=>$data['order_name4'], 'zipcode'=>$data['order_zip'], 'address1'=>$data['order_address1'], 'address2'=>$data['order_address2'], 'address3'=>$data['order_address3'], 'tel'=>$data['order_tel'], 'fax'=>$data['order_fax'], 'pref'=>$data['order_pref']);
2758 $country = $usces->get_order_meta_value('customer_country', $data['ID']);
2759 $values['country'] = !empty($country) ? $country : usces_get_local_addressform();
2760 break;
2761 case 'delivery':
2762 $values = $data;
2763 break;
2764 }
2765
2766 switch ($applyform){
2767
2768 case 'JP':
2769 //20100818ysk start
2770 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return');
2771 //20100818ysk end
2772 $formtag .= '
2773 <tr>
2774 <td class="label">' . __('name', 'usces') . '</td>
2775 <td class="col2"><input name="' . $type . '[name1]" type="text" class="text short" value="' . esc_attr($values['name1']) . '" /><input name="' . $type . '[name2]" type="text" class="text short" value="' . esc_attr($values['name2']) . '" /></td>
2776 </tr>
2777 <tr>
2778 <td class="label">' . __('furigana', 'usces') . '</td>
2779 <td class="col2"><input name="' . $type . '[name3]" type="text" class="text short" value="' . esc_attr($values['name3']) . '" /><input name="' . $type . '[name4]" type="text" class="text short" value="' . esc_attr($values['name4']) . '" /></td>
2780 </tr>';
2781 //20100818ysk start
2782 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return');
2783 //20100818ysk end
2784 $formtag .= '
2785 <tr>
2786 <td class="label">' . __('Zip/Postal Code', 'usces') . '</td>
2787 <td class="col2"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" />'.apply_filters('usces_filter_admin_addressform_zipcode', NULL, $type).'</td>
2788 </tr>
2789 <tr>
2790 <td class="label">' . __('Country', 'usces') . '</td>
2791 <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td>
2792 </tr>
2793 <tr>
2794 <td class="label">' . __('Province', 'usces') . '</td>
2795 <td class="col2">';
2796
2797 $formtag .= usces_pref_select( $type, $values );
2798
2799 $formtag .= '</td>
2800 </tr>';
2801 $formtag .= '
2802 <tr>
2803 <td class="label">' . __('city', 'usces') . '</td>
2804 <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td>
2805 </tr>
2806 <tr>
2807 <td class="label">' . __('numbers', 'usces') . '</td>
2808 <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td>
2809 </tr>
2810 <tr>
2811 <td class="label">' . __('building name', 'usces') . '</td>
2812 <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td>
2813 </tr>
2814 <tr>
2815 <td class="label">' . __('Phone number', 'usces') . '</td>
2816 <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td>
2817 </tr>
2818 <tr>
2819 <td class="label">' . __('FAX number', 'usces') . '</td>
2820 <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td>
2821 </tr>';
2822 //20100818ysk start
2823 $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return');
2824 //20100818ysk end
2825 break;
2826
2827 case 'CN':
2828 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return');
2829 $formtag .= '
2830 <tr>
2831 <td class="label">' . __('name', 'usces') . '</td>
2832 <td class="col2"><input name="' . $type . '[name1]" type="text" class="text short" value="' . esc_attr($values['name1']) . '" /><input name="' . $type . '[name2]" type="text" class="text short" value="' . esc_attr($values['name2']) . '" /></td>
2833 </tr>';
2834 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return');
2835 $formtag .= '
2836 <tr>
2837 <td class="label">' . __('Country', 'usces') . '</td>
2838 <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td>
2839 </tr>
2840 <tr>
2841 <td class="label">' . __('State', 'usces') . '</td>
2842 <td class="col2">';
2843
2844 $formtag .= usces_pref_select( $type, $values );
2845
2846 $formtag .= '</td>
2847 </tr>';
2848 $formtag .= '<tr>
2849 <td class="label">' . __('city', 'usces') . '</td>
2850 <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td>
2851 </tr>
2852 <tr>
2853 <td class="label">' . __('Address Line1', 'usces') . '</td>
2854 <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td>
2855 </tr>
2856 <tr>
2857 <td class="label">' . __('Address Line2', 'usces') . '</td>
2858 <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td>
2859 </tr>
2860 <tr>
2861 <td class="label">' . __('Zip', 'usces') . '</td>
2862 <td class="col2"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" /></td>
2863 </tr>
2864 <tr>
2865 <td class="label">' . __('Phone number', 'usces') . '</td>
2866 <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td>
2867 </tr>
2868 <tr>
2869 <td class="label">' . __('FAX number', 'usces') . '</td>
2870 <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td>
2871 </tr>';
2872 $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return');
2873 break;
2874
2875 case 'US':
2876 default:
2877 //20100818ysk start
2878 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return');
2879 //20100818ysk end
2880 $formtag .= '
2881 <tr>
2882 <td class="label">' . __('name', 'usces') . '</td>
2883 <td class="col2"><input name="' . $type . '[name2]" type="text" class="text short" value="' . esc_attr($values['name2']) . '" /><input name="' . $type . '[name1]" type="text" class="text short" value="' . esc_attr($values['name1']) . '" /></td>
2884 </tr>';
2885 //20100818ysk start
2886 $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return');
2887 //20100818ysk end
2888 $formtag .= '
2889 <tr>
2890 <td class="label">' . __('Address Line1', 'usces') . '</td>
2891 <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td>
2892 </tr>
2893 <tr>
2894 <td class="label">' . __('Address Line2', 'usces') . '</td>
2895 <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td>
2896 </tr>
2897 <tr>
2898 <td class="label">' . __('city', 'usces') . '</td>
2899 <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td>
2900 </tr>
2901 <tr>
2902 <td class="label">' . __('State', 'usces') . '</td>
2903 <td class="col2">';
2904
2905 $formtag .= usces_pref_select( $type, $values );
2906
2907 $formtag .= '</td>
2908 </tr>';
2909 $formtag .= '
2910 <tr>
2911 <td class="label">' . __('Country', 'usces') . '</td>
2912 <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td>
2913 </tr>
2914 <tr>
2915 <td class="label">' . __('Zip', 'usces') . '</td>
2916 <td class="col2"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" /></td>
2917 </tr>
2918 <tr>
2919 <td class="label">' . __('Phone number', 'usces') . '</td>
2920 <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td>
2921 </tr>
2922 <tr>
2923 <td class="label">' . __('FAX number', 'usces') . '</td>
2924 <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td>
2925 </tr>';
2926 //20100818ysk start
2927 $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return');
2928 //20100818ysk end
2929 break;
2930 }
2931 $res = apply_filters('usces_filter_apply_admin_addressform', $formtag, $type, $data, $customdata);
2932
2933
2934 if($out == 'return') {
2935 return $res;
2936 } else {
2937 echo $res;
2938 }
2939 }
2940
2941 function uesces_get_mail_addressform( $type, $data, $order_id, $out = 'return' ){
2942 global $usces, $usces_settings;
2943 $options = get_option('usces');
2944 $applyform = usces_get_apply_addressform($options['system']['addressform']);
2945 $formtag = '';
2946 switch( $type ){
2947 case 'admin_mail_customer':
2948 $values = $data;
2949 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2950 $mode = 'customer';
2951 $name_label = __('Buyer','usces');
2952 break;
2953 case 'admin_mail':
2954 $values = $data;
2955 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2956 $mode = 'delivery';
2957 $name_label = __('A destination name','usces');
2958 break;
2959 case 'order_mail_customer':
2960 $values = $data['customer'];
2961 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2962 $mode = 'customer';
2963 $name_label = __('Buyer','usces');
2964 break;
2965 case 'order_mail':
2966 $values = $data['delivery'];
2967 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2968 $mode = 'delivery';
2969 $name_label = __('A destination name','usces');
2970 break;
2971 }
2972
2973 switch ($applyform){
2974
2975 case 'JP':
2976 //20110118ysk start
2977 $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id );
2978 //20110118ysk end
2979 $formtag .= $name_label . "\t\t: " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name1'] . ' ' . $values['name2'])) . " \r\n";
2980 if( !empty($values['name3']) || !empty($values['name4']) ) {
2981 $formtag .= __('furigana','usces') . "\t\t: " . $values['name3'] . ' ' . $values['name4'] . " \r\n";
2982 }
2983 //20110118ysk start
2984 $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id );
2985 //20110118ysk end
2986 $formtag .= __('Country','usces') . "\t\t\t: " . $usces_settings['country'][$values['country']] . "\r\n";
2987 $formtag .= __('Zip/Postal Code','usces') . "\t\t: " . $values['zipcode'] . "\r\n";
2988 $formtag .= __('Address','usces') . "\t\t\t: " . $values['pref'] . $values['address1'] . $values['address2'] . " " . $values['address3'] . "\r\n";
2989 $formtag .= __('Phone number','usces') . "\t\t: " . $values['tel'] . "\r\n";
2990 $formtag .= __('FAX number','usces') . "\t\t: " . $values['fax'] . "\r\n";
2991 //20110118ysk start
2992 $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id );
2993 //20110118ysk end
2994 break;
2995
2996 case 'CN':
2997 //20110118ysk start
2998 $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id );
2999 //20110118ysk end
3000 $formtag .= $name_label . "\t\t: " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name1'] . ' ' . $values['name2'])) . " \r\n";
3001 //20110118ysk start
3002 $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id );
3003 //20110118ysk end
3004 $formtag .= __('Country','usces') . " : " . $usces_settings['country'][$values['country']] . "\r\n";
3005 $formtag .= __('State','usces') . " : " . $values['pref'] . "\r\n";
3006 $formtag .= __('City','usces') . " : " . $values['address1'] . "\r\n";
3007 $formtag .= __('Address','usces') . " : " . $values['address2'] . " " . $values['address3'] . "\r\n";
3008 $formtag .= __('Zip/Postal Code','usces') . " : " . $values['zipcode'] . "\r\n";
3009 $formtag .= __('Phone number','usces') . " : " . $values['tel'] . "\r\n";
3010 $formtag .= __('FAX number','usces') . " : " . $values['fax'] . "\r\n";
3011 //20110118ysk start
3012 $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id );
3013 //20110118ysk end
3014 break;
3015
3016 case 'US':
3017 default:
3018 //20110118ysk start
3019 $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id );
3020 //20110118ysk end
3021 $formtag .= $name_label . " : " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name2'] . ' ' . $values['name1'])) . " \r\n";
3022 //20110118ysk start
3023 $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id );
3024 //20110118ysk end
3025 $formtag .= __('Address','usces') . " : " . $values['address2'] . " " . $values['address3'] . "\r\n";
3026 $formtag .= __('City','usces') . " : " . $values['address1'] . "\r\n";
3027 $formtag .= __('State','usces') . " : " . $values['pref'] . "\r\n";
3028 $formtag .= __('Country','usces') . " : " . $usces_settings['country'][$values['country']] . "\r\n";
3029 $formtag .= __('Zip/Postal Code','usces') . " : " . $values['zipcode'] . "\r\n";
3030 $formtag .= __('Phone number','usces') . " : " . $values['tel'] . "\r\n";
3031 $formtag .= __('FAX number','usces') . " : " . $values['fax'] . "\r\n";
3032 //20110118ysk start
3033 $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id );
3034 //20110118ysk end
3035 break;
3036 }
3037 $res = apply_filters('usces_filter_apply_mail_addressform', $formtag, $type, $data, $order_id);
3038
3039
3040 if($out == 'return') {
3041 return $res;
3042 } else {
3043 echo $res;
3044 }
3045 }
3046
3047 function uesces_get_target_market_form( $type, $selected, $out = 'return' ){
3048 global $usces_settings;
3049 $options = get_option('usces');
3050 $res = '<select name="' . $type . '[country]" id="' . $type . '_country">'."\n";
3051 foreach ( $usces_settings['country'] as $key => $value ){
3052 if( in_array($key, $options['system']['target_market']) )
3053 $res .= '<option value="' . $key . '"' . ($selected == $key ? ' selected="selected"' : '') . '>' . $value . "</option>\n";
3054 }
3055 $res .= '</select>'."\n";
3056
3057 if($out == 'return') {
3058 return $res;
3059 } else {
3060 echo $res;
3061 }
3062 }
3063
3064 function usces_pref_select( $type, $values, $out = 'return' ){
3065 global $usces, $usces_states;
3066
3067 //20110513ysk start
3068 //$country = empty($values['country']) ? usces_get_local_addressform() : $values['country'];
3069 $country = empty($values['country']) ? usces_get_base_country() : $values['country'];
3070 $options = get_option('usces');
3071 if( !in_array($country, $options['system']['target_market']) )
3072 $country = $options['system']['target_market'][0];
3073 //20110513ysk end
3074 //20110331ysk start
3075 //$prefs = $usces_states[$country];
3076 $prefs = get_usces_states($country);
3077 //20110331ysk end
3078 $html = '<select name="' . esc_attr($type . '[pref]') . '" id="' . esc_attr($type) . '_pref" class="pref">';
3079 //20120123ysk start 0000386
3080 //foreach((array)$prefs as $pref)
3081 // $html .= "\t".'<option value="' . esc_attr($pref) . '"' . ($pref == $values['pref'] ? ' selected="selected"' : '') . '>' . esc_html($pref) . "</option>\n";
3082 $prefs_count = count($prefs);
3083 if($prefs_count > 0) {
3084 $select = __('-- Select --', 'usces');
3085 $html .= "\t".'<option value="' . esc_attr($select) . '">' . esc_html($select) . "</option>\n";
3086 for($i = 1; $i < $prefs_count; $i++)
3087 $html .= "\t".'<option value="' . esc_attr($prefs[$i]) . '"' . ($prefs[$i] == $values['pref'] ? ' selected="selected"' : '') . '>' . esc_html($prefs[$i]) . "</option>\n";
3088 }
3089 //20120123ysk end
3090 $html .= "</select>\n";
3091
3092 if( $out == 'return' ){
3093 return $html;
3094 }else{
3095 echo $html;
3096 }
3097 }
3098
3099 function usces_is_member_system(){
3100 global $usces;
3101 if($usces->options['membersystem_state'] == 'activate')
3102 return true;
3103 else
3104 return false;
3105 }
3106
3107 function usces_is_member_system_point(){
3108 global $usces;
3109 if($usces->options['membersystem_point'] == 'activate')
3110 return true;
3111 else
3112 return false;
3113 }
3114
3115 function usces_shipping_country_option( $selected, $out = '' ){
3116 global $usces_settings;
3117 $options = get_option('usces');
3118 $res = '';
3119 foreach ( $usces_settings['country'] as $key => $value ){
3120 if( in_array($key, $options['system']['target_market']) )
3121 $res .= '<option value="' . $key . '"' . ($selected == $key ? ' selected="selected"' : '') . '>' . $value . "</option>\n";
3122 }
3123 //20110317ysk start
3124 //$res .= '<option value="world_wide"' . ($selected == $key ? ' selected="selected"' : '') . '>World Wide' . "</option>\n";
3125 //20110317ysk end
3126 echo $res;
3127 }
3128
3129 function usces_get_cart_button( $out = '' ) {
3130 global $usces;
3131 $res = '';
3132
3133 if($usces->use_js){
3134 $res .= '<input name="previous" type="button" id="previouscart" class="continue_shopping_button" value="' . __('continue shopping','usces') . '"' . apply_filters('usces_filter_cart_prebutton', ' onclick="uscesCart.previousCart();"') . ' />&nbsp;&nbsp;';
3135 if( usces_is_cart() ) {
3136 $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __(' Next ','usces') . '"' . apply_filters('usces_filter_cart_nextbutton', ' onclick="return uscesCart.cartNext();"') . ' />';
3137 }
3138 }else{
3139 $res .= '<a href="' . get_home_url() . '" class="continue_shopping_button">' . __('continue shopping','usces') . '</a>&nbsp;&nbsp;';
3140 if( usces_is_cart() ) {
3141 $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __(' Next ','usces') . '"' . apply_filters('usces_filter_cart_nextbutton', NULL) . ' />';
3142 }
3143 }
3144 $res = apply_filters('usces_filter_get_cart_button', $res);
3145
3146 if($out == 'return'){
3147 return $res;
3148 }else{
3149 echo $res;
3150 }
3151 }
3152
3153 function usces_get_customer_button( $out = '' ) {
3154 global $usces, $member_regmode;
3155 $res = '';
3156
3157 $res = '<input name="backCart" type="submit" class="back_cart_button" value="'.__('Back', 'usces').'" />&nbsp;&nbsp;';
3158
3159 $button = '<input name="deliveryinfo" type="submit" class="to_deliveryinfo_button" value="'.__(' Next ', 'usces').'" />&nbsp;&nbsp;';
3160 $res .= apply_filters('usces_filter_customer_button', $button);
3161
3162 if(usces_is_membersystem_state() && $member_regmode != 'editmemberfromcart' && usces_is_login() == false ){
3163 $res .= '<input name="reganddeliveryinfo" type="submit" class="to_reganddeliveryinfo_button" value="'.__('To the next while enrolling', 'usces').'"' . apply_filters('usces_filter_customerinfo_prebutton', NULL) . ' />';
3164 }elseif(usces_is_membersystem_state() && $member_regmode == 'editmemberfromcart' ){
3165 $res .= '<input name="reganddeliveryinfo" type="submit" class="to_reganddeliveryinfo_button" value="'.__('Revise member information, and to next', 'usces').'"' . apply_filters('usces_filter_customerinfo_nextbutton', NULL) . ' />';
3166 }
3167
3168 $res = apply_filters('usces_filter_get_customer_button', $res);
3169
3170 if($out == 'return'){
3171 return $res;
3172 }else{
3173 echo $res;
3174 }
3175 }
3176
3177 function usces_delivery_secure_form( $out = '' ) {
3178 global $usces, $usces_entries, $usces_carts;
3179 $html = '';
3180 include( USCES_PLUGIN_DIR . "/includes/delivery_secure_form.php");
3181
3182 if($out == 'return'){
3183 return $html;
3184 }else{
3185 echo $html;
3186 }
3187 }
3188
3189 function usces_delivery_info_script( $out ='' ){
3190 global $usces, $usces_entries, $usces_carts;
3191 $html = '';
3192 include( USCES_PLUGIN_DIR . "/includes/delivery_info_script.php");
3193
3194 if($out == 'return'){
3195 return $html;
3196 }else{
3197 echo $html;
3198 }
3199 }
3200
3201 function usces_get_entries(){
3202 global $usces, $usces_entries;
3203 $usces_entries = $usces->cart->get_entry();
3204 }
3205
3206 function usces_get_carts(){
3207 global $usces, $usces_carts;
3208 $usces_carts = $usces->cart->get_cart();
3209 }
3210
3211 function usces_get_members(){
3212 global $usces, $usces_members;
3213 $usces_members = $usces->get_member();
3214 }
3215
3216 function usces_error_message( $out = ''){
3217 global $usces;
3218
3219 if($out == 'return'){
3220 return $usces->error_message;
3221 }else{
3222 echo $usces->error_message;
3223 }
3224 }
3225
3226 function usces_url( $type, $out = ''){
3227 global $usces;
3228
3229 switch ( $type ){
3230 case 'cart':
3231 $url = USCES_CART_URL;
3232 break;
3233 case 'login':
3234 $url = USCES_LOGIN_URL;
3235 break;
3236 case 'member':
3237 $url = USCES_MEMBER_URL;
3238 break;
3239 case 'newmember':
3240 $url = USCES_NEWMEMBER_URL;
3241 break;
3242 case 'lostmemberpassword':
3243 $url = USCES_LOSTMEMBERPASSWORD_URL;
3244 break;
3245 case 'cartnonsession':
3246 $url = USCES_CART_NONSESSION_URL;
3247 break;
3248 }
3249
3250 if($out == 'return'){
3251 return $url;
3252 }else{
3253 echo $url;
3254 }
3255 }
3256
3257 function usces_total_price( $out = ''){
3258 global $usces;
3259
3260 if($out == 'return'){
3261 return $usces->get_total_price();
3262 }else{
3263 echo $usces->get_total_price();
3264 }
3265 }
3266
3267 function usces_completion_settlement( $out ='' ){
3268 global $usces, $usces_entries;
3269 $html = '';
3270 require( USCES_PLUGIN_DIR . "/includes/completion_settlement.php");
3271
3272 if($out == 'return'){
3273 return $html;
3274 }else{
3275 echo $html;
3276 }
3277 }
3278
3279 function usces_purchase_button( $out ='' ){
3280 global $usces, $usces_entries;
3281 $html = '';
3282 include( USCES_PLUGIN_DIR . "/includes/purchase_button.php");
3283
3284 if($out == 'return'){
3285 return $html;
3286 }else{
3287 echo $html;
3288 }
3289 }
3290
3291 function usces_get_member_regmode(){
3292 global $member_regmode;
3293 $member_regmode = isset( $_SESSION['usces_entry']['member_regmode'] ) ? $_SESSION['usces_entry']['member_regmode'] : 'none';
3294 }
3295
3296 function uesces_get_error_settlement( $out = '' ) {
3297 $res = '';
3298 if( isset($_REQUEST['acting']) && ('zeus_conv' == $_REQUEST['acting'] || 'zeus_card' == $_REQUEST['acting'] || 'zeus_bank' == $_REQUEST['acting'] ) ){ //ZEUS
3299 $res .= '<div class="support_box">';
3300 if( isset($_GET['code']) ){
3301 $res .= ' <br />エラーコード:' . esc_html($_GET['code']);
3302 if( in_array($_GET['code'], array('02130514', '02130517', '02130619', '02130620', '02130621', '02130640')) ){
3303 $res .= '<br />カード番号が正しくないようです。';
3304 }elseif( in_array($_GET['code'], array('02130714', '02130717', '02130725', '02130814', '02130817', '02130825')) ){
3305 $res .= '<br />カードの有効期限が正しくないようです。';
3306 }elseif( in_array($_GET['code'], array('02130922')) ){
3307 $res .= '<br />カードの有効期限が切れているようです。';
3308 }elseif( in_array($_GET['code'], array('02131117', '02131123', '02131124')) ){
3309 $res .= '<br />カードの名義が正しくないようです。';
3310 }elseif( in_array($_GET['code'], array('02131414', '02131417', '02131437')) ){
3311 $res .= '<br />お客様�
3312 報の電話番号が正しくないようです。';
3313 }elseif( in_array($_GET['code'], array('02131527', '02131528', '02131529', '02131537')) ){
3314 $res .= '<br />お客様�
3315 報のEメールアドレスが正しくないようです。';
3316 }
3317 $res .= ' <br />
3318  <br />
3319 <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う>></a><br />';
3320 }else{
3321 $res .= ' <br />
3322 カード番号を再�
3323 �力する場合はこちらをクリックしてください。<br />
3324  <br />
3325 <a href="' . USCES_CUSTOMER_URL . '">カード番号の再�
3326 �力>></a><br />';
3327 }
3328 $res .= ' <br />
3329 ゼウス・カスタマーサポート(24時間365日)<br />
3330 電話番号:0570-02-3939(つながらないときは 03-4334-0500)<br />
3331 E-mail:support@cardservice.co.jp
3332 </div>'."\n";
3333 }
3334
3335 if($out == 'return'){
3336 return $res;
3337 }else{
3338 echo $res;
3339 }
3340 }
3341
3342 function usces_page_name( $out = '') {
3343 global $usces;
3344 $page = '';
3345
3346 if( empty($usces->page) ){
3347 if( $usces->is_cart_page($_SERVER['REQUEST_URI']) ){
3348 $page = 'cart';
3349 }elseif( $usces->is_member_page($_SERVER['REQUEST_URI']) ){
3350 $page = 'member';
3351 }
3352 }else{
3353 $page = $usces->page;
3354 }
3355
3356 if($out == 'return'){
3357 return $page;
3358 }else{
3359 echo $page;
3360 }
3361 }
3362
3363 function usces_post_reg_orderdata($order_id, $results){
3364 global $usces, $wpdb;
3365 //$entry = $usces->cart->get_entry();//20110621ysk 0000184
3366 $acting = isset($_GET['acting']) ? $_GET['acting'] : '';
3367 $data = array();
3368
3369 if( $order_id ){
3370
3371 switch ( $acting ) {
3372 case 'epsilon':
3373 $trans_id = isset($_REQUEST['trans_code']) ? $_REQUEST['trans_code'] : '';
3374 break;
3375 case 'paypal_ipn':
3376 $trans_id = isset($_REQUEST['txn_id']) ? $_REQUEST['txn_id'] : '';
3377 break;
3378 case 'paypal':
3379 $trans_id = isset($results['txn_id']) ? $results['txn_id'] : '';
3380 break;
3381 //20110208ysk start
3382 case 'paypal_ec':
3383 $trans_id = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';
3384 //20110621ysk start 0000184
3385 if(isset($results['settlement_id']))
3386 $usces->set_order_meta_value('settlement_id', $results['settlement_id'], $order_id);
3387 if(isset($results['profile_id']))
3388 $usces->set_order_meta_value('profile_id', $results['profile_id'], $order_id);
3389 //20110621ysk end
3390 break;
3391 //20110208ysk end
3392 case 'zeus_card':
3393 if( isset($_GET['zeussuffix']) ){
3394 $acting_opts = $usces->options['acting_settings']['zeus'];
3395 $data['acting'] = 'zeus_card Secure API';
3396 $data['order_number'] = $_GET['zeusordd'];
3397
3398 $usces->set_order_meta_value('acting_'.$acting, serialize($data), $order_id);
3399 if( $usces->is_member_logged_in() ){
3400 if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge']){
3401 $usces->set_member_meta_value('zeus_pcid', '8888888888888888');
3402 }
3403 $usces->set_member_meta_value('partofcard', $_GET['zeussuffix']);
3404 $usces->set_member_meta_value('limitofcard', ($_GET['zeusyear'].'/'.$_GET['zeusmonth']));
3405 }
3406 }else{
3407 $trans_id = isset($_REQUEST['ordd']) ? $_REQUEST['ordd'] : '';
3408 //foreach($_GET as $key => $value) {
3409 // $data[$key] = mysql_real_escape_string($value);
3410 //}
3411 //$usces->set_order_meta_value('acting_'.$acting, serialize($data), $order_id);
3412 if( !empty($_REQUEST['order_number']) ) {
3413 $usces->set_order_meta_value( 'order_number', $_REQUEST['order_number'], $order_id );
3414 }
3415 if( $usces->is_member_logged_in() )
3416 $usces->set_member_meta_value('zeus_pcid', '8888888888888888');
3417 }
3418 //usces_log(print_r($_REQUEST,true), 'acting_transaction.log');
3419 if(empty($usces)){
3420 usces_log('zeus card transaction : No Session', 'acting_transaction.log');
3421 }else{
3422 usces_log('zeus card transaction : OK', 'acting_transaction.log');
3423 }
3424 break;
3425 case 'zeus_conv':
3426 $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['sendpoint'] : '';
3427 $zeus_convs = array(
3428 'acting' => 'zeus_conv',
3429 'pay_cvs' => isset($_REQUEST['pay_cvs']) ? $_REQUEST['pay_cvs'] : '',
3430 'order_no' => isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : '',
3431 'money' => isset($_REQUEST['money']) ? $_REQUEST['money'] : '',
3432 'pay_no1' => isset($_REQUEST['pay_no1']) ? $_REQUEST['pay_no1'] : '',
3433 'pay_no2' => isset($_REQUEST['pay_no2']) ? $_REQUEST['pay_no2'] : '',
3434 'pay_limit' => isset($_REQUEST['pay_limit']) ? $_REQUEST['pay_limit'] : '',
3435 'status' => isset($_REQUEST['status']) ? $_REQUEST['status'] : '',
3436 'error_code' => isset($_REQUEST['error_code']) ? $_REQUEST['error_code'] : ''
3437 );
3438 $usces->set_order_meta_value('acting_'.(isset($_REQUEST['sendpoint']) ? $_REQUEST['sendpoint'] : ''), serialize($zeus_convs), $order_id);
3439 break;
3440 case 'zeus_bank':
3441 $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : '';
3442 break;
3443 case 'remise_card':
3444 $trans_id = isset($_REQUEST['X-TRANID']) ? $_REQUEST['X-TRANID'] : '';
3445 break;
3446 case 'remise_conv':
3447 $trans_id = isset($_REQUEST['X-JOB_ID']) ? $_REQUEST['X-JOB_ID'] : '';
3448 break;
3449 case 'jpayment_card':
3450 case 'jpayment_conv':
3451 case 'jpayment_bank':
3452 $trans_id = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : '';
3453 break;
3454 //20120413ysk start
3455 case 'sbps_card':
3456 case 'sbps_conv':
3457 case 'sbps_payeasy':
3458 case 'sbps_wallet':
3459 case 'sbps_mobile':
3460 $trans_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : '';
3461 break;
3462 //20120413ysk end
3463 //20120618ysk start
3464 case 'telecom_card':
3465 $trans_id = isset($_REQUEST['sendid']) ? $_REQUEST['sendid'] : '';
3466 break;
3467 //20120618ysk end
3468 //20121206ysk start
3469 case 'digitalcheck_card':
3470 case 'digitalcheck_conv':
3471 $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : '';
3472 break;
3473 //20121206ysk end
3474 //20130225ysk start
3475 case 'mizuho_card':
3476 case 'mizuho_conv':
3477 $trans_id = isset($_REQUEST['stran']) ? $_REQUEST['stran'] : '';
3478 break;
3479 //20130225ysk end
3480 default:
3481 if( isset($_REQUEST['FUKA']) && strstr($_REQUEST['FUKA'], "digitalcheck_card") ) {
3482 $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : '';
3483 } else {
3484 $trans_id = '';
3485 }
3486 }
3487
3488 if(!empty($trans_id)) {
3489 $usces->set_order_meta_value('trans_id', $trans_id, $order_id);
3490 }
3491 }
3492
3493 }
3494
3495 //20110621ysk start 0000184
3496 function usces_paypal_doecp( &$results ) {
3497 global $usces;
3498 $entry = $usces->cart->get_entry();
3499
3500 $cart = $usces->cart->get_cart();
3501
3502 $post_id = $cart[0]['post_id'];
3503 $charging_type = $usces->getItemChargingType( $post_id );
3504 if( 'continue' != $charging_type ) {
3505 //通常購�
3506
3507 //Format the other parameters that were stored in the session from the previous calls
3508 $paymentAmount = usces_crform($entry['order']['total_full_price'], false, false, 'return', false);
3509 $token = urlencode($_REQUEST['token']);
3510 $paymentType = urlencode("Sale");
3511 $currencyCodeType = urlencode($usces->get_currency_code());
3512 $payerID = urlencode($_REQUEST['PayerID']);
3513 $serverName = urlencode($_SERVER['SERVER_NAME']);
3514
3515 $nvpstr = '&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&IPADDRESS='.$serverName;
3516
3517 $usces->paypal->setMethod('DoExpressCheckoutPayment');
3518 $usces->paypal->setData($nvpstr);
3519 $res = $usces->paypal->doExpressCheckout();
3520 $resArray = $usces->paypal->getResponse();
3521 $ack = strtoupper($resArray["ACK"]);
3522 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
3523 $transactionId = $resArray["TRANSACTIONID"]; // ' Unique transaction ID of the payment. Note: If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs.
3524 //$usces->set_order_meta_value('settlement_id', $transactionId, $order_id);
3525 $results['settlement_id'] = $transactionId;
3526
3527 } else {
3528 //Display a user friendly Error on the page using any of the following error information returned by PayPal
3529 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
3530 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
3531 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
3532 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
3533 usces_log('PayPal : DoExpressCheckoutPayment API call failed. Error Code:['.$ErrorCode.'] Error Severity Code:['.$ErrorSeverityCode.'] Short Error Message:'.$ErrorShortMsg.' Detailed Error Message:'.$ErrorLongMsg, 'acting_transaction.log');
3534 return false;
3535 }
3536
3537 } else {
3538 //定期支払い
3539 //$paymentAmount = usces_crform($entry['order']['total_items_price'], false, false, 'return', false);
3540 $paymentAmount = usces_crform($entry['order']['total_full_price'], false, false, 'return', false);//20111129ysk 0000320
3541 $token = urlencode($_REQUEST['token']);
3542 $currencyCodeType = urlencode($usces->get_currency_code());
3543 //$nextdate = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
3544 //$profileStartDate = date('Y-m-d', mktime(0,0,0,substr($nextdate, 5, 2)+1,$usces->getItemChargingDay($post_id),substr($nextdate, 0, 4))).'T01:01:01Z';
3545 /* if( 'regular' == $charging_type ) {//定期購�
3546
3547 $profileStartDate = date('Y-m-d', current_time('timestamp')).'T01:01:01Z';
3548 $sku = urldecode( $cart[0]['sku'] );
3549 $advance = unserialize( $cart[0]['advance'] );
3550 $regular = $advance[$post_id][$sku]['regular'];
3551 $unit = $regular['unit'];
3552 $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
3553 $frequency = isset( $regular['frequency'] ) ? (int)$regular['frequency'] : 0;
3554 if( 'day' == $unit ) {
3555 $billingPeriod = "Day";
3556 } elseif( 'month' == $unit ) {
3557 $billingPeriod = "Month";
3558 }
3559 $billingFreq = $frequency;
3560 $totalBillingCycles = ( dlseller_auto_stop() ) ? '&TOTALBILLINGCYCLES='.$interval : '';
3561
3562 } else {//継続課金
3563
3564 $profileStartDate = date('Y-m-d', dlseller_first_charging($post_id, 'time')).'T01:01:01Z';
3565 $billingPeriod = "Month";// or "Day", "Week", "SemiMonth", "Year"
3566 $billingFreq = $usces->getItemFrequency($post_id);
3567 $totalBillingCycles = ( dlseller_auto_stop() ) ? '&TOTALBILLINGCYCLES='.dlseller_cycles( $post_id ) : '';
3568 }*/
3569 $profileStartDate = date('Y-m-d', dlseller_first_charging($post_id, 'time')).'T01:01:01Z';
3570 $billingPeriod = "Month";// or "Day", "Week", "SemiMonth", "Year"
3571 $billingFreq = $usces->getItemFrequency($post_id);
3572 //$desc = urlencode(usces_make_agreement_description($cart, $entry['order']['total_items_price']));
3573 $desc = urlencode(usces_make_agreement_description($cart, $entry['order']['total_full_price']));//20111125ysk 0000320
3574 $totalBillingCycles = (empty($dlitem['dlseller_interval'])) ? '' : '&TOTALBILLINGCYCLES='.urlencode($dlitem['dlseller_interval']);
3575 //$totalBillingCycles = ( dlseller_auto_stop() ) ? '&TOTALBILLINGCYCLES='.dlseller_cycles( $post_id ) : '';
3576
3577 //$nvpstr = '&TOKEN='.$token.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&PROFILESTARTDATE='.$profileStartDate.'&BILLINGPERIOD='.$billingPeriod.'&BILLINGFREQUENCY='.$billingFreq.'&DESC='.$desc;
3578 $nvpstr = '&TOKEN='.$token.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&PROFILESTARTDATE='.$profileStartDate.'&BILLINGPERIOD='.$billingPeriod.'&BILLINGFREQUENCY='.$billingFreq.'&DESC='.$desc.$totalBillingCycles;
3579
3580 $usces->paypal->setMethod('CreateRecurringPaymentsProfile');
3581 $usces->paypal->setData($nvpstr);
3582 $res = $usces->paypal->doExpressCheckout();
3583 $resArray = $usces->paypal->getResponse();
3584 $ack = strtoupper($resArray["ACK"]);
3585 if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
3586 $profileid = $resArray["PROFILEID"];
3587 //$usces->set_order_meta_value('profile_id', $profileid, $order_id);
3588 $results['settlement_id'] = $profileid;
3589 $results['profile_id'] = $profileid;
3590
3591 } else {
3592 //Display a user friendly Error on the page using any of the following error information returned by PayPal
3593 $ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
3594 $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
3595 $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
3596 $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
3597 usces_log('PayPal : CreateRecurringPaymentsProfile API call failed. Error Code:['.$ErrorCode.'] Error Severity Code:['.$ErrorSeverityCode.'] Short Error Message:'.$ErrorShortMsg.' Detailed Error Message:'.$ErrorLongMsg, 'acting_transaction.log');
3598 return false;
3599 }
3600 }
3601
3602 return true;
3603 }
3604 //20110621ysk end
3605 //20110421ysk start
3606 function usces_make_agreement_description($cart, $amt) {
3607 global $usces;
3608
3609 $cart_row = $cart[0];
3610 $quantity = $cart_row['quantity'];
3611 $itemName = $usces->getItemName($cart_row['post_id']);
3612 //if(1 < count($cart)) $itemName .= ','.__('Others', 'usces');
3613 if(50 < mb_strlen($itemName)) $itemName = mb_substr($itemName, 0, 50).'...';
3614 $amt = usces_crform($amt, true, false, 'return', true);
3615 $desc = $itemName.' '.__('Quantity','usces').':'.$quantity.' '.$amt;
3616 return($desc);
3617 }
3618 //20110421ysk end
3619
3620 function usces_get_send_out_date(){
3621 global $usces;
3622
3623 $bus_day_arr = (isset($usces->options['business_days'])) ? $usces->options['business_days'] : false;
3624 list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = split( '([^0-9])', current_time('mysql') );
3625 if( !is_array($bus_day_arr) ){
3626 $today_bus_flag = 1;
3627 }else{
3628 $today_bus_flag = isset($bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day]) ? (int)$bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day] : 1;
3629 }
3630 // get the time limit addition
3631 $limit_hour = (!empty($usces->options['delivery_time_limit']['hour'])) ? $usces->options['delivery_time_limit']['hour'] : false;
3632 $limit_min = (!empty($usces->options['delivery_time_limit']['min'])) ? $usces->options['delivery_time_limit']['min'] : false;
3633
3634 if( false === $hour || false === $minute ){
3635 $time_limit_addition = false;
3636 }elseif( ($hour.':'.$minute.':'.$second) > ($limit_hour.':'.$limit_min.':00') ){
3637 $time_limit_addition = 1;
3638 }else{
3639 $time_limit_addition = 0;
3640 }
3641 // get the shipping indication in cart
3642 $cart = $usces->cart->get_cart();
3643 $shipping_indication = apply_filters('usces_filter_shipping_indication', $usces->options['usces_shipping_indication']);
3644 $shipping = 0;
3645 $indication_flag = true;
3646 for($i = 0; $i < count($cart); $i++) {
3647 $cart_row = $cart[$i];
3648 $post_id = $cart_row['post_id'];
3649 $itemShipping = (int)$usces->getItemShipping($post_id);
3650 if($itemShipping === 0 or $itemShipping === 9) {
3651 $indication_flag = false;
3652 break;
3653 }
3654 if($shipping < $itemShipping) $shipping = $itemShipping;
3655 }
3656 $indication_incart = ( $indication_flag ) ? $shipping_indication[$shipping] : false;
3657 // get the send out date
3658 $sendout_num = 0;
3659 if( $today_bus_flag ){
3660 if( $time_limit_addition ){
3661 $sendout_num += 1;
3662 }
3663 if( false !== $indication_incart ){
3664 $sendout_num += $indication_incart;
3665 }
3666 }else{
3667 if( false !== $indication_incart ){
3668 $sendout_num += $indication_incart;
3669 }
3670 }
3671 $holiday = 0;
3672 for( $i=0; $i<=$sendout_num; $i++ ){
3673 list($yyyy, $mm, $dd) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $i),(int)$today_year)));
3674 if( isset($bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd]) && !$bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd] ){
3675 $holiday++;
3676 $sendout_num++;
3677 }
3678 if( 100 < $sendout_num ) break;
3679 }
3680 list($send_y, $send_m, $send_d) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $sendout_num),(int)$today_year)));
3681
3682 $res = array(
3683 'today_bus_flag' => $today_bus_flag,
3684 'time_limit_addition'=> $time_limit_addition,
3685 'indication_incart' => $indication_incart,
3686 'holiday' => $holiday,
3687 'sendout_num' => $sendout_num,
3688 'sendout_date' => array('year' => $send_y, 'month' => $send_m, 'day' => $send_d)
3689 );
3690 return $res;
3691 }
3692
3693 function usces_action_footer_comment(){
3694 echo "<!-- Welcart version : v".USCES_VERSION." -->\n";
3695 }
3696
3697 function usces_set_acting_notification_time( $key ){
3698 global $wpdb;
3699 $tableName = $wpdb->prefix . "usces_access";
3700 $query = $wpdb->prepare("SELECT ID FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key);
3701 $res = $wpdb->get_var( $query );
3702 if( $res )
3703 return;
3704
3705 $query = $wpdb->prepare("INSERT INTO $tableName (acc_key, acc_type, acc_num1) VALUES (%s, %s, %d)",
3706 $key, 'notification_time', time());
3707 $res = $wpdb->query( $query );
3708 }
3709
3710 function usces_check_notification_time( $key, $time ){
3711 global $wpdb;
3712 $tableName = $wpdb->prefix . "usces_access";
3713 $query = $wpdb->prepare("SELECT acc_num1 FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key);
3714 $res = $wpdb->get_var( $query );
3715 if( !$res )
3716 return false;
3717
3718 $past = time() - $res;
3719 if( $time > $past )
3720 return true;
3721 else
3722 return false;
3723 }
3724
3725 function usces_is_same_itemcode( $post_id, $item_code ){
3726 global $wpdb, $usces;
3727
3728 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE post_id <> %d AND meta_key = %s AND meta_value = %s", $post_id, '_itemCode', $item_code);
3729 $ids = $wpdb->get_col( $query );
3730 // usces_log('ids : '.print_r($query,true), 'acting_transaction.log');
3731 // usces_log('ids : '.print_r($ids,true), 'acting_transaction.log');
3732 if( !$ids ){
3733 return false;
3734 }
3735 $id_str = implode(',', $ids);
3736 $query = "SELECT ID FROM $wpdb->posts WHERE ID IN({$id_str}) AND post_status = 'publish'";
3737 $res = $wpdb->get_col( $query );
3738 // usces_log('res : '.print_r($res,true), 'acting_transaction.log');
3739 // usces_log('res : '.print_r($query,true), 'acting_transaction.log');
3740 if( !$res ){
3741 return false;
3742 }
3743
3744 return $res;
3745 }
3746
3747 function usces_update_sku( $post_id, $skucode, $fieldname, $value ){
3748 global $wpdb;
3749 $metas = usces_get_post_meta($post_id, '_isku_');
3750 if( ! $metas )
3751 return false;
3752
3753 $meta_id = '';
3754 foreach( $metas as $meta ){
3755 $sku = unserialize($meta['meta_value']);
3756 if( $skucode == $sku['code'] ){
3757 $meta_id = $meta['meta_id'];
3758 $sku[$fieldname] = $value;
3759 break;
3760 }
3761 }
3762 $serialized_values = serialize($sku);
3763 if( !empty($meta_id) ) $res = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d", $serialized_values, $meta_id) );
3764 if( !$res ){
3765 return false;
3766 }else{
3767 return true;
3768 }
3769 }
3770
3771 function usces_get_items_skus() {
3772 global $wpdb, $usces;
3773 $res = array();
3774 $item_codes = array();
3775 $item_names = array();
3776 $status = array();
3777
3778 $query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts}
3779 WHERE post_mime_type = %s AND post_status = %s", 'item', 'publish');
3780 $IDs = $wpdb->get_col($query);
3781 if( !$IDs )
3782 return $res;
3783
3784 //wp_cache_set( 'item_ids', $IDs );
3785
3786 $key = 0;
3787 foreach((array)$IDs as $post_id){
3788 $item_codes[$post_id] = $usces->getItemCode($post_id);
3789 $item_names[$post_id] = $usces->getItemName($post_id);
3790
3791 //$skus = $usces->get_skus($post_id);
3792 $metas = usces_get_post_meta($post_id, '_isku_');
3793 foreach( (array)$metas as $mkey => $rows ){
3794 $metas[$mkey]['meta_value'] = unserialize($rows['meta_value']);
3795 $allmetas[] = $metas;
3796 // $sku_post_id[] = $post_id;
3797 // $sku_code[] = $values['code'];
3798 // $sku_stocknum[] = $values['stocknum'];
3799 $status[] = $metas[$mkey]['meta_value']['stock'];
3800 $key++;
3801 }
3802 //usces_log('implode : '.strlen(explode(',', $res)), 'acting_transaction.log');
3803 }
3804 // wp_cache_set( 'item_ids', $IDs );
3805 // wp_cache_set( 'item_codes', $item_codes );
3806 // wp_cache_set( 'item_names', $item_names );
3807 // wp_cache_set( 'sku_data', $res );
3808 // wp_cache_set( 'stock_ct', array_count_values($status) );
3809
3810 }
3811 function usces_get_non_zerostoc_items() {
3812 global $wpdb, $usces;
3813
3814 $query = $wpdb->prepare("SELECT ID, code.meta_value AS code, name.meta_value AS name FROM {$wpdb->posts}
3815 LEFT JOIN {$wpdb->postmeta} AS code ON ID = code.post_id AND '_itemCode' = code.meta_key
3816 LEFT JOIN {$wpdb->postmeta} AS name ON ID = name.post_id AND '_itemName' = name.meta_key
3817 LEFT JOIN {$wpdb->postmeta} AS sku ON ID = sku.post_id AND '_isku_' = sku.meta_key
3818 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s AND (sku.meta_value LIKE %s OR sku.meta_value LIKE %s)
3819 GROUP BY ID",
3820 'item', 'post', 'trush', '%"stocknum";i:0%', '%"stocknum";s:1:"0"%');
3821 $res = $wpdb->get_results($query, ARRAY_A);
3822
3823 return $res;
3824
3825 // $key = 0;
3826 // foreach((array)$items as $item){
3827 //// $ItemCode = $usces->getItemCode($item['ID']);
3828 //// $ItemName = $usces->getItemName($item['ID']);
3829 //
3830 // //$skus = $usces->get_skus($post_id);
3831 // $metas = usces_get_post_meta($item['ID'], '_isku_');
3832 // foreach( (array)$metas as $rows ){
3833 // $meta_value = unserialize($rows['meta_value']);
3834 // if( "" != $meta_value['stocknum'] && 0 === (int)$meta_value['stocknum'] ){
3835 // $res[$key]['ID'] = $item['ID'];
3836 // $res[$key]['code'] = $item['code'];
3837 // $res[$key]['name'] = $item['name'];
3838 // $res[$key]['sku'] = $meta_value['code'];
3839 // }
3840 // $key++;
3841 // }
3842 // }
3843 // return $res;
3844 }
3845 function usces_get_stocs() {
3846 global $wpdb, $usces;
3847 $status = array();
3848
3849 $query = $wpdb->prepare("SELECT m.meta_value FROM {$wpdb->posts} AS p
3850 LEFT JOIN {$wpdb->postmeta} AS m ON p.ID = m.post_id AND m.meta_key = %s
3851 WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s"
3852 , '_isku_', 'item', 'post', 'trush');
3853 $values = $wpdb->get_col($query);
3854 if( !$values )
3855 return $status;
3856
3857 foreach((array)$values as $value){
3858 $meta_value = unserialize($value);
3859 $status[] = (string)$meta_value['stock'];
3860 }
3861 return array_count_values($status);
3862 }
3863
3864 function usces_get_deco_order_id( $order_id ) {
3865 global $usces;
3866
3867 $dec_order_id = $usces->get_order_meta_value( 'dec_order_id', $order_id);
3868 if( !$dec_order_id ){
3869 $dec_order_id = str_pad($order_id, $usces->options['system']['dec_orderID_digit'], "0", STR_PAD_LEFT);
3870 }
3871 return $dec_order_id;
3872 }
3873
3874 function usces_mail_line( $type, $email = '' ) {
3875 $line = '';
3876
3877 switch( $type ) {
3878 case 1:
3879 $line = "******************************************************************";
3880 break;
3881 case 2:
3882 $line = "------------------------------------------------------------------";
3883 break;
3884 case 3:
3885 $line = "==================================================================";
3886 break;
3887 }
3888
3889 $line = apply_filters( 'usces_filter_mail_line', $line, $type, $email );
3890
3891 return $line."\r\n";
3892 }
3893
3894 function usces_get_gp_price($post_id, $p, $quant){
3895 global $usces;
3896 $GpN1 = $usces->getItemGpNum1($post_id);
3897 $GpN2 = $usces->getItemGpNum2($post_id);
3898 $GpN3 = $usces->getItemGpNum3($post_id);
3899 $GpD1 = $usces->getItemGpDis1($post_id);
3900 $GpD2 = $usces->getItemGpDis2($post_id);
3901 $GpD3 = $usces->getItemGpDis3($post_id);
3902
3903 if( empty($GpN1) || empty($GpD1) ) {
3904
3905 $realprice = $p;
3906
3907 }else if( (!empty($GpN1) && !empty($GpD1)) && (empty($GpN2) || empty($GpD2)) ) {
3908
3909 if( $quant >= $GpN1 ) {
3910 $realprice = round($p * (100 - $GpD1) / 100);
3911 }else{
3912 $realprice = $p;
3913 }
3914
3915 }else if( (!empty($GpN1) && !empty($GpD1)) && (!empty($GpN2) && !empty($GpD2)) && (empty($GpN3) || empty($GpD3)) ) {
3916
3917 if( $quant >= $GpN2 ) {
3918 $realprice = round($p * (100 - $GpD2) / 100);
3919 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
3920 $realprice = round($p * (100 - $GpD1) / 100);
3921 }else{
3922 $realprice = $p;
3923 }
3924
3925 }else if( (!empty($GpN1) && !empty($GpD1)) && (!empty($GpN2) && !empty($GpD2)) && (!empty($GpN3) && !empty($GpD3)) ) {
3926
3927 if( $quant >= $GpN3 ) {
3928 $realprice = round($p * (100 - $GpD3) / 100);
3929 }else if( $quant >= $GpN2 && $quant < $GpN3 ) {
3930 $realprice = round($p * (100 - $GpD2) / 100);
3931 }else if( $quant >= $GpN1 && $quant < $GpN2 ) {
3932 $realprice = round($p * (100 - $GpD1) / 100);
3933 }else{
3934 $realprice = $p;
3935 }
3936
3937 }else{
3938 $realprice = $p;
3939 }
3940
3941 $realprice = apply_filters('usces_filter_get_gp_price', $realprice, $post_id, $p, $quant);
3942 return $realprice;
3943 }
3944 //20120306ysk start 0000324
3945 function usces_is_complete_settlement( $payment_name, $status = '' ) {
3946 //20120919ysk start 0000573
3947 $options = get_option('usces');
3948 if( $options['point_assign'] == 0 ) {
3949 return true;
3950 //20120919ysk end
3951 } else {
3952 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
3953 if( isset($payments[$payment_name]['settlement']) ) {
3954 switch( $payments[$payment_name]['settlement'] ) {
3955 case 'acting':
3956 if( $status == 'pending' ) break;
3957 case 'acting_zeus_card':
3958 case 'acting_remise_card':
3959 case 'acting_jpayment_card':
3960 case 'acting_paypal_ec':
3961 case 'acting_sbps_card':
3962 case 'acting_telecom_card':
3963 case 'COD':
3964 return true;
3965 }
3966 }
3967 return false;
3968 }
3969 }
3970
3971 function usces_action_acting_getpoint( $order_id, $add = true ) {
3972 global $usces, $wpdb;
3973 //20120919ysk start 0000573
3974 $options = get_option('usces');
3975 if( $options['point_assign'] != 0 ) {
3976 //20120919ysk end
3977 if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) {
3978 $table_name = $wpdb->prefix . "usces_order";
3979 $mquery = $wpdb->prepare("SELECT mem_id, order_getpoint FROM $table_name WHERE ID = %d", $order_id);
3980 $values = $wpdb->get_row( $mquery, ARRAY_A );
3981 $mem_id = $values['mem_id'];
3982 $getpoint = $values['order_getpoint'];
3983
3984 if( !empty($mem_id) && 0 < $getpoint ) {
3985 $calc = ($add) ? '+' : '-';
3986 $member_table_name = $wpdb->prefix . "usces_member";
3987 $mquery = $wpdb->prepare("UPDATE $member_table_name SET mem_point = (mem_point ".$calc." %d) WHERE ID = %d", $getpoint, $mem_id);
3988 $wpdb->query( $mquery );
3989
3990 if( !empty($_SESSION['usces_member']['point']) ) {
3991 $mquery = $wpdb->prepare("SELECT mem_point FROM $member_table_name WHERE ID = %d", $mem_id);
3992 $point = $wpdb->get_var( $mquery );
3993 $_SESSION['usces_member']['point'] = $point;
3994 }
3995 }
3996 }
3997 }
3998 do_action( 'usces_action_acting_getpoint', $order_id, $add );
3999 }
4000
4001 function usces_restore_point( $mem_id, $point ) {
4002 global $wpdb;
4003 $member_table_name = $wpdb->prefix . "usces_member";
4004 $mquery = $wpdb->prepare("UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", $point, $mem_id);
4005 $wpdb->query( $mquery );
4006 }
4007 //20120306ysk end
4008 //20120413ysk start
4009 function usces_set_free_csv( $customer ){
4010 $free_csv = "";
4011 if( !WCUtils::is_blank($customer['name1']) ) {
4012 $free_csv = "LAST_NAME=".mb_convert_encoding($customer['name1'],'SJIS','UTF-8').",FIRST_NAME=".mb_convert_encoding($customer['name2'],'SJIS','UTF-8').",TEL=".str_replace("-","",$customer['tel']).",MAIL=".$customer['mailaddress1'];
4013 $free_csv = base64_encode( $free_csv );
4014 }
4015 return $free_csv;
4016 }
4017 //20120413ysk end
4018
4019 function usces_get_itemopt_filed($post_id, $sku, $opt){
4020 global $usces;
4021 $sku = urlencode($sku);
4022 $optcode = urlencode($opt['name']);
4023 $name = $opt['name'];
4024 $means = (int)$opt['means'];
4025 $essential = (int)$opt['essential'];
4026 $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] ) ? $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] : NULL;
4027
4028 $html = '';
4029 switch($means) {
4030 case 0://Single-select
4031 case 1://Multi-select
4032 $selects = explode("\n", $opt['value']);
4033 $multiple = ($means === 0) ? '' : ' multiple';
4034 $multiple_array = ($means == 0) ? '' : '[]';
4035 $html .= "\n<select name='itemOption[{$post_id}][{$sku}][{$optcode}]{$multiple_array}' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_select'{$multiple} onKeyDown=\"if (event.keyCode == 13) {return false;}\">\n";
4036 if($essential == 1){
4037 if( '#NONE#' == $session_value || NULL == $session_value )
4038 $selected = ' selected="selected"';
4039 else
4040 $selected = '';
4041 $html .= "\t<option value='#NONE#'{$selected}>" . __('Choose','usces') . "</option>\n";
4042 }
4043 $i=0;
4044 foreach($selects as $v) {
4045 if( ($i == 0 && $essential == 0 && NULL == $session_value) || esc_attr($v) == $session_value )
4046 $selected = ' selected="selected"';
4047 else
4048 $selected = '';
4049 $html .= "\t<option value='" . esc_attr($v) . "'{$selected}>" . esc_html($v) . "</option>\n";
4050 $i++;
4051 }
4052 $html .= "</select>\n";
4053 break;
4054 case 2://Text
4055 $html .= "\n<input name='itemOption[{$post_id}][{$sku}][{$optcode}]' type='text' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_text' onKeyDown=\"if (event.keyCode == 13) {return false;}\" value=\"" . esc_attr($session_value) . "\" />\n";
4056 break;
4057 case 5://Text-area
4058 $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr($session_value) . "</textarea>\n";
4059 break;
4060 }
4061
4062 $html = apply_filters('usces_get_itemopt_filed', $html, $post_id, $sku, $opt);
4063
4064 return $html;
4065 }
4066
4067 function usces_delete_order_check( $order_id ) {
4068 $res = apply_filters( 'usces_filter_delete_order_check', true, $order_id );
4069 return $res;
4070 }
4071
4072 function usces_itempage_admin_bar() {
4073 global $wp_admin_bar, $post;
4074 if( is_single() && usces_is_item() ){
4075 $wp_admin_bar->remove_menu('edit');
4076 $ref = urlencode(site_url() . '/wp-admin/admin.php?page=usces_itemedit');
4077 $wp_admin_bar->add_menu( array(
4078 'id' => 'edit',
4079 'title' => __('Edit item', 'usces'),
4080 'href' => site_url() . '/wp-admin/admin.php?page=usces_itemedit&action=edit&post=' . $post->ID . '&usces_referer=' . $ref
4081 ) );
4082 }
4083 }
4084
4085 ?>