| @@ -1,4925 +1,5633 @@ | ||
| 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 | - $cart = usces_get_ordercartdata($order_id); | |
| 61 | - | |
| 62 | - $country = $usces->get_order_meta_value('customer_country', $order_id); | |
| 63 | - $customer = array( | |
| 64 | - 'name1' => $data['order_name1'], | |
| 65 | - 'name2' => $data['order_name2'], | |
| 66 | - 'name3' => $data['order_name3'], | |
| 67 | - 'name4' => $data['order_name4'], | |
| 68 | - 'zipcode' => $data['order_zip'], | |
| 69 | - 'country' => $country, | |
| 70 | - 'pref' => $data['order_pref'], | |
| 71 | - 'address1' => $data['order_address1'], | |
| 72 | - 'address2' => $data['order_address2'], | |
| 73 | - 'address3' => $data['order_address3'], | |
| 74 | - 'tel' => $data['order_tel'], | |
| 75 | - 'fax' => $data['order_fax'], | |
| 76 | - ); | |
| 77 | - $condition = unserialize($data['order_condition']); | |
| 78 | - | |
| 79 | - $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']; | |
| 80 | - | |
| 81 | - | |
| 82 | - $mail_data = $usces->options['mail_data']; | |
| 83 | - $payment = $usces->getPayments( $data['order_payment_name'] ); | |
| 84 | - $res = false; | |
| 85 | - | |
| 86 | - if($_POST['mode'] == 'mitumoriConfirmMail'){ | |
| 87 | - $msg_body = "\r\n\r\n\r\n" . __('Estimate','usces') . "\r\n"; | |
| 88 | - $msg_body .= usces_mail_line( 1, $data['order_email'] );//******************** | |
| 89 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_first', NULL, $data); | |
| 90 | - $msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id ); | |
| 91 | - $msg_body .= __('estimate number','usces') . " : " . $order_id . "\r\n"; | |
| 92 | - }else{ | |
| 93 | - $msg_body = "\r\n\r\n\r\n" . __('** Article order contents **','usces') . "\r\n"; | |
| 94 | - $msg_body .= usces_mail_line( 1, $data['order_email'] );//******************** | |
| 95 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_first', NULL, $data); | |
| 96 | - $msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id ); | |
| 97 | - $msg_body .= __('Order number','usces') . " : " . usces_get_deco_order_id( $order_id ) . "\r\n"; | |
| 98 | -//20131129_kitamu_start | |
| 99 | - $msg_body .= __( 'order date','usces' ) . " : " . $data['order_date'] . "\r\n"; | |
| 100 | -//20131129_kitamu end | |
| 101 | - } | |
| 102 | - | |
| 103 | - $meisai = __('Items','usces') . " : \r\n"; | |
| 104 | - foreach ( (array)$cart as $cart_row ) { | |
| 105 | - $post_id = $cart_row['post_id']; | |
| 106 | - $sku = urldecode($cart_row['sku']); | |
| 107 | - $quantity = $cart_row['quantity']; | |
| 108 | - $options = $cart_row['options']; | |
| 109 | - $itemCode = $usces->getItemCode($post_id); | |
| 110 | - $itemName = $usces->getItemName($post_id); | |
| 111 | - $cartItemName = $usces->getCartItemName($post_id, $sku); | |
| 112 | - $skuPrice = $cart_row['price']; | |
| 113 | -// $pictids = $usces->get_pictids($itemCode); | |
| 114 | - if (!empty($options)) { | |
| 115 | -// $optstr = implode(',', $options); | |
| 116 | - } else { | |
| 117 | - $optstr = ''; | |
| 118 | - $options = array(); | |
| 119 | - } | |
| 120 | - | |
| 121 | - $meisai .= usces_mail_line( 2, $data['order_email'] );//-------------------- | |
| 122 | - $meisai .= "$cartItemName \r\n"; | |
| 123 | - if( is_array($options) && count($options) > 0 ){ | |
| 124 | - $optstr = ''; | |
| 125 | - foreach($options as $key => $value){ | |
| 126 | -//20110629ysk start 0000190 | |
| 127 | - //if( !empty($key) ) | |
| 128 | - // $meisai .= $key . ' : ' . urldecode($value) . "\r\n"; | |
| 129 | - if( !empty($key) ) { | |
| 130 | - $key = urldecode($key); | |
| 131 | - if(is_array($value)) { | |
| 132 | - $c = ''; | |
| 133 | - $optstr .= $key . ' : '; | |
| 134 | - foreach($value as $v) { | |
| 135 | - $optstr .= $c.urldecode($v); | |
| 136 | - $c = ', '; | |
| 137 | - } | |
| 138 | - $optstr .= "\r\n"; | |
| 139 | - } else { | |
| 140 | - $optstr .= $key . ' : ' . urldecode($value) . "\r\n"; | |
| 141 | - } | |
| 142 | - } | |
| 143 | -//20110629ysk end | |
| 144 | - } | |
| 145 | - $meisai .= apply_filters( 'usces_filter_option_adminmail', $optstr, $options); | |
| 146 | - } | |
| 147 | - $meisai .= __('Unit price','usces') . " ".usces_crform( $skuPrice, true, false, 'return' ) . __(' * ','usces') . $cart_row['quantity'] . "\r\n"; | |
| 148 | - } | |
| 149 | - | |
| 150 | - $meisai .= usces_mail_line( 3, $data['order_email'] );//==================== | |
| 151 | - $meisai .= __('total items','usces') . " : " . usces_crform( $data['order_item_total_price'], true, false, 'return' ) . "\r\n"; | |
| 152 | - | |
| 153 | - if ( $data['order_discount'] != 0 ) | |
| 154 | - $meisai .= apply_filters('usces_confirm_discount_label', __('Campaign disnount', 'usces'), $order_id) . " : " . usces_crform( $data['order_discount'], true, false, 'return' ) . "\r\n"; | |
| 155 | - | |
| 156 | - if ( 0.00 < (float)$data['order_tax'] ) | |
| 157 | - $meisai .= usces_tax_label($data, 'return') . " : " . usces_crform( $data['order_tax'], true, false, 'return' ) . "\r\n"; | |
| 158 | - | |
| 159 | - $meisai .= __('Shipping','usces') . " : " . usces_crform( $data['order_shipping_charge'], true, false, 'return' ) . "\r\n"; | |
| 160 | - | |
| 161 | - if ( $payment['settlement'] == 'COD' ) | |
| 162 | - $meisai .= apply_filters('usces_filter_cod_label', __('COD fee', 'usces')) . " : " . usces_crform( $data['order_cod_fee'], true, false, 'return' ) . "\r\n"; | |
| 163 | - | |
| 164 | - if ( $data['order_usedpoint'] != 0 ) | |
| 165 | - $meisai .= __('use of points','usces') . " : " . number_format($data['order_usedpoint']) . __('Points','usces') . "\r\n"; | |
| 166 | - | |
| 167 | - $meisai .= usces_mail_line( 2, $data['order_email'] );//-------------------- | |
| 168 | - $meisai .= __('Payment amount','usces') . " : " . usces_crform( $total_full_price, true, false, 'return' ) . "\r\n"; | |
| 169 | - $meisai .= usces_mail_line( 2, $data['order_email'] );//-------------------- | |
| 170 | - $meisai .= "(" . __('Currency', 'usces') . ' : ' . __(usces_crcode( 'return' ), 'usces') . ")\r\n\r\n"; | |
| 171 | - | |
| 172 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_meisai', $meisai, $data, $cart); | |
| 173 | - | |
| 174 | - | |
| 175 | - | |
| 176 | - $msg_shipping = __('** A shipping address **','usces') . "\r\n"; | |
| 177 | - $msg_shipping .= usces_mail_line( 1, $data['order_email'] );//******************** | |
| 178 | - | |
| 179 | - $msg_shipping .= uesces_get_mail_addressform( 'admin_mail', $deli, $order_id ); | |
| 180 | - | |
| 181 | -//20101208ysk start | |
| 182 | - //$msg_shipping .= __('Delivery Time','usces') . " : " . $data['order_delivery_time'] . "\r\n"; | |
| 183 | - if ( $data['order_delidue_date'] == NULL || $data['order_delidue_date'] == '#none#' ) { | |
| 184 | - $msg_shipping .= "\r\n"; | |
| 185 | - }else{ | |
| 186 | - $msg_shipping .= __('Shipping date', 'usces') . " : " . $data['order_delidue_date'] . "\r\n"; | |
| 187 | - $msg_shipping .= __("* A shipment due date is a day to ship an article, and it's not the arrival day.", 'usces') . "\r\n"; | |
| 188 | - $msg_shipping .= "\r\n"; | |
| 189 | - } | |
| 190 | - $deli_meth = (int)$data['order_delivery_method']; | |
| 191 | - if( 0 <= $deli_meth ){ | |
| 192 | - $deli_index = $usces->get_delivery_method_index($deli_meth); | |
| 193 | - if( 0 <= $deli_index ) $msg_shipping .= __('Delivery Method','usces') . " : " . $usces->options['delivery_method'][$deli_index]['name'] . "\r\n"; | |
| 194 | - } | |
| 195 | - $msg_shipping .= __('Delivery date','usces') . " : " . $data['order_delivery_date'] . "\r\n"; | |
| 196 | - $msg_shipping .= __('Delivery Time','usces') . " : " . $data['order_delivery_time'] . "\r\n"; | |
| 197 | -//20101208ysk end | |
| 198 | - $msg_shipping .= "\r\n"; | |
| 199 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_shipping', $msg_shipping, $data); | |
| 200 | - | |
| 201 | -// $msg_body .= __('** For some region, to deliver the items in the morning is not possible.','usces') . "\r\n"; | |
| 202 | -// $msg_body .= __('** WE may not always be able to deliver the items on time which you desire.','usces') . " \r\n"; | |
| 203 | -// $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n"; | |
| 204 | - | |
| 205 | - $msg_payment = __('** Payment method **','usces') . "\r\n"; | |
| 206 | - $msg_payment .= usces_mail_line( 1, $data['order_email'] );//******************** | |
| 207 | - $msg_payment .= $payment['name']. "\r\n\r\n"; | |
| 208 | - if( 'orderConfirmMail' == $_POST['mode'] || 'changeConfirmMail' == $_POST['mode'] || 'mitumoriConfirmMail' == $_POST['mode'] || 'otherConfirmMail' == $_POST['mode'] ) {//20130514ysk start 0000524 | |
| 209 | - if ( $payment['settlement'] == 'transferAdvance' || $payment['settlement'] == 'transferDeferred' ) { | |
| 210 | - $transferee = __('Transfer','usces') . " : \r\n"; | |
| 211 | - $transferee .= $usces->options['transferee'] . "\r\n"; | |
| 212 | - $msg_payment .= apply_filters('usces_filter_mail_transferee', $transferee, $payment); | |
| 213 | - $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//-------------------- | |
| 214 | -//20101018ysk start | |
| 215 | - } elseif($payment['settlement'] == 'acting_jpayment_conv') { | |
| 216 | - $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id)); | |
| 217 | - $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n"; | |
| 218 | - $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n"; | |
| 219 | - $msg_payment .= __('お支払先', 'usces').' : '.usces_get_conv_name($args['cv'])."\r\n"; | |
| 220 | - $msg_payment .= __('コンビニ受付番号','usces').' : '.$args['no']."\r\n"; | |
| 221 | - if($args['cv'] != '030') {//ファミリーマート以外 | |
| 222 | - $msg_payment .= __('コンビニ受付番号情報URL', 'usces').' : '.$args['cu']."\r\n"; | |
| 223 | - } | |
| 224 | - $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//-------------------- | |
| 225 | - } elseif($payment['settlement'] == 'acting_jpayment_bank') { | |
| 226 | - $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id)); | |
| 227 | - $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n"; | |
| 228 | - $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n"; | |
| 229 | - $bank = explode('.', $args['bank']); | |
| 230 | - $msg_payment .= __('銀行コード','usces').' : '.$bank[0]."\r\n"; | |
| 231 | - $msg_payment .= __('銀行名','usces').' : '.$bank[1]."\r\n"; | |
| 232 | - $msg_payment .= __('支店コード','usces').' : '.$bank[2]."\r\n"; | |
| 233 | - $msg_payment .= __('支店名','usces').' : '.$bank[3]."\r\n"; | |
| 234 | - $msg_payment .= __('口座種別','usces').' : '.$bank[4]."\r\n"; | |
| 235 | - $msg_payment .= __('口座番号','usces').' : '.$bank[5]."\r\n"; | |
| 236 | - $msg_payment .= __('口座名義','usces').' : '.$bank[6]."\r\n"; | |
| 237 | - $msg_payment .= __('支払期限','usces').' : '.substr($args['exp'], 0, 4).'年'.substr($args['exp'], 4, 2).'月'.substr($args['exp'], 6, 2)."日\r\n"; | |
| 238 | - $msg_payment .= "\r\n".usces_mail_line( 2, $data['order_email'] )."\r\n";//-------------------- | |
| 239 | -//20101018ysk end | |
| 240 | - } | |
| 241 | - }//20130514ysk end | |
| 242 | - | |
| 243 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_payment', $msg_payment, $order_id, $payment, $cart, $data); | |
| 244 | - | |
| 245 | -//20100818ysk start | |
| 246 | - $msg_body .= usces_mail_custom_field_info( 'order', '', $order_id, $data['order_email'] ); | |
| 247 | -//20100818ysk end | |
| 248 | - | |
| 249 | - $msg_body .= "\r\n"; | |
| 250 | - $msg_body .= __('** Others / a demand **','usces') . "\r\n"; | |
| 251 | - $msg_body .= usces_mail_line( 1, $data['order_email'] );//******************** | |
| 252 | - $msg_body .= $data['order_note'] . "\r\n\r\n"; | |
| 253 | -// $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n";//-------------------- | |
| 254 | -// $msg_body .= "\r\n"; | |
| 255 | - | |
| 256 | -// $msg_body .= __('Please inform it of any questions from [an inquiry].','usces') . "\r\n"; | |
| 257 | -// $msg_body .= usces_mail_line( 2, $data['order_email'] )."\r\n";//-------------------- | |
| 258 | - | |
| 259 | - $msg_body .= apply_filters('usces_filter_order_confirm_mail_body', NULL, $data); | |
| 260 | - $msg_body = apply_filters('usces_filter_order_confirm_mail_bodyall', $msg_body, $data); | |
| 261 | - | |
| 262 | - switch ( $_POST['mode'] ) { | |
| 263 | - case 'completionMail': | |
| 264 | - $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']); | |
| 265 | - break; | |
| 266 | - case 'orderConfirmMail': | |
| 267 | - $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']); | |
| 268 | - break; | |
| 269 | - case 'changeConfirmMail': | |
| 270 | - $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']); | |
| 271 | - break; | |
| 272 | - case 'receiptConfirmMail': | |
| 273 | - $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']); | |
| 274 | - break; | |
| 275 | - case 'mitumoriConfirmMail': | |
| 276 | - $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']); | |
| 277 | - break; | |
| 278 | - case 'cancelConfirmMail': | |
| 279 | - $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']); | |
| 280 | - break; | |
| 281 | - case 'otherConfirmMail': | |
| 282 | - $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']); | |
| 283 | - break; | |
| 284 | - default: | |
| 285 | - $message = apply_filters( 'usces_filter_order_confirm_mail_body_after', $msg_body, $data ); | |
| 286 | - } | |
| 287 | - return apply_filters('usces_filter_order_confirm_mail_message', $message, $data); | |
| 288 | - | |
| 289 | -} | |
| 290 | - | |
| 291 | -function usces_send_ordermail($order_id) { | |
| 292 | - global $usces, $wpdb; | |
| 293 | - | |
| 294 | - $tableName = $wpdb->prefix . "usces_order"; | |
| 295 | - $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id); | |
| 296 | - $data = $wpdb->get_row( $query, ARRAY_A ); | |
| 297 | - | |
| 298 | - $cart = $usces->cart->get_cart(); | |
| 299 | - $entry = $usces->cart->get_entry(); | |
| 300 | - $mail_data = $usces->options['mail_data']; | |
| 301 | - $payment = $usces->getPayments( $entry['order']['payment_name'] ); | |
| 302 | - $res = false; | |
| 303 | - | |
| 304 | - $msg_body = "\r\n\r\n\r\n" . __('** content of ordered items **','usces') . "\r\n"; | |
| 305 | - $msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//******************** | |
| 306 | - $msg_body .= apply_filters('usces_filter_send_order_mail_first', NULL, $data); | |
| 307 | - $msg_body .= uesces_get_mail_addressform( 'order_mail_customer', $entry, $order_id ); | |
| 308 | - $msg_body .= __('Order number','usces') . " : " . usces_get_deco_order_id( $order_id ) . "\r\n"; | |
| 309 | - $msg_body .= __( 'order date','usces' ) . " : " . $data['order_date'] . "\r\n"; | |
| 310 | - | |
| 311 | - $meisai = __('Items','usces') . " : \r\n"; | |
| 312 | - foreach ( $cart as $cart_row ) { | |
| 313 | - $post_id = $cart_row['post_id']; | |
| 314 | - $sku = urldecode($cart_row['sku']); | |
| 315 | - $quantity = $cart_row['quantity']; | |
| 316 | - $options = $cart_row['options']; | |
| 317 | - $itemCode = $usces->getItemCode($post_id); | |
| 318 | - $itemName = $usces->getItemName($post_id); | |
| 319 | - $cartItemName = $usces->getCartItemName($post_id, $sku); | |
| 320 | - $skuPrice = $cart_row['price']; | |
| 321 | -// $pictids = $usces->get_pictids($itemCode); | |
| 322 | - if (!empty($options)) { | |
| 323 | -// $optstr = implode(',', $options); | |
| 324 | - } else { | |
| 325 | - $optstr = ''; | |
| 326 | - $options = array(); | |
| 327 | - } | |
| 328 | - | |
| 329 | - $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//-------------------- | |
| 330 | - $meisai .= "$cartItemName \r\n"; | |
| 331 | - if( is_array($options) && count($options) > 0 ){ | |
| 332 | - $optstr = ''; | |
| 333 | - foreach($options as $key => $value){ | |
| 334 | - if( !empty($key) ) { | |
| 335 | - $key = urldecode($key); | |
| 336 | - if(is_array($value)) { | |
| 337 | - $c = ''; | |
| 338 | - $optstr .= $key. ' : '; | |
| 339 | - foreach($value as $v) { | |
| 340 | - $optstr .= $c.urldecode($v); | |
| 341 | - $c = ', '; | |
| 342 | - } | |
| 343 | - $optstr .= "\r\n"; | |
| 344 | - } else { | |
| 345 | - $optstr .= $key . ' : ' . urldecode($value) . "\r\n"; | |
| 346 | - } | |
| 347 | - } | |
| 348 | - } | |
| 349 | - $meisai .= apply_filters( 'usces_filter_option_ordermail', $optstr, $options); | |
| 350 | - } | |
| 351 | - $meisai .= __('Unit price','usces') . " ".usces_crform( $skuPrice, true, false, 'return' ) . __(' * ','usces') . $cart_row['quantity'] . "\r\n"; | |
| 352 | - } | |
| 353 | - $meisai .= usces_mail_line( 3, $entry['customer']['mailaddress1'] );//==================== | |
| 354 | - $meisai .= __('total items','usces') . " : " . usces_crform( $entry['order']['total_items_price'], true, false, 'return' ) . "\r\n"; | |
| 355 | - | |
| 356 | - if ( $entry['order']['discount'] != 0 ) | |
| 357 | - $meisai .= apply_filters('usces_confirm_discount_label', __('Campaign disnount', 'usces'), $order_id) . " : " . usces_crform( $entry['order']['discount'], true, false, 'return' ) . "\r\n"; | |
| 358 | - | |
| 359 | - if ( 0.00 < (float)$entry['order']['tax'] ) | |
| 360 | - $meisai .= usces_tax_label($data, 'return') . " : " . usces_crform( $entry['order']['tax'], true, false, 'return' ) . "\r\n"; | |
| 361 | - | |
| 362 | - $meisai .= "\r\n" . __('Shipping','usces') . " : " . usces_crform( $entry['order']['shipping_charge'], true, false, 'return' ) . "\r\n"; | |
| 363 | - | |
| 364 | - if ( $payment['settlement'] == 'COD' ) | |
| 365 | - $meisai .= apply_filters('usces_filter_cod_label', __('COD fee', 'usces')) . " : " . usces_crform( $entry['order']['cod_fee'], true, false, 'return' ) . "\r\n"; | |
| 366 | - | |
| 367 | - if ( $entry['order']['usedpoint'] != 0 ) | |
| 368 | - $meisai .= __('use of points','usces') . " : " . number_format($entry['order']['usedpoint']) . __('Points','usces') . "\r\n"; | |
| 369 | - | |
| 370 | - $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//-------------------- | |
| 371 | - $meisai .= __('Payment amount','usces') . " : " . usces_crform( $entry['order']['total_full_price'], true, false, 'return' ) . "\r\n"; | |
| 372 | - $meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//-------------------- | |
| 373 | - $meisai .= "(" . __('Currency', 'usces') . ' : ' . __(usces_crcode( 'return' ), 'usces') . ")\r\n\r\n"; | |
| 374 | - | |
| 375 | - $msg_body .= apply_filters('usces_filter_send_order_mail_meisai', $meisai, $data, $cart, $entry); | |
| 376 | - | |
| 377 | - | |
| 378 | - $msg_shipping = __('** A shipping address **','usces') . "\r\n"; | |
| 379 | - $msg_shipping .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//******************** | |
| 380 | - | |
| 381 | - $msg_shipping .= uesces_get_mail_addressform( 'order_mail', $entry, $order_id ); | |
| 382 | - | |
| 383 | - $deli_meth = (int)$entry['order']['delivery_method']; | |
| 384 | - if( 0 <= $deli_meth ){ | |
| 385 | - $deli_index = $usces->get_delivery_method_index($deli_meth); | |
| 386 | - if( 0 <= $deli_index ) $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 | - $msg_shipping .= "\r\n"; | |
| 391 | - $msg_body .= apply_filters('usces_filter_send_order_mail_shipping', $msg_shipping, $data, $entry ); | |
| 392 | - | |
| 393 | - $msg_payment = __('** Payment method **','usces') . "\r\n"; | |
| 394 | - $msg_payment .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//******************** | |
| 395 | - $msg_payment .= $payment['name'] . usces_payment_detail($entry) . "\r\n\r\n"; | |
| 396 | - if ( $payment['settlement'] == 'transferAdvance' || $payment['settlement'] == 'transferDeferred' ) { | |
| 397 | - $transferee = __('Transfer','usces') . " : \r\n"; | |
| 398 | - $transferee .= $usces->options['transferee'] . "\r\n"; | |
| 399 | - $msg_payment .= apply_filters('usces_filter_mail_transferee', $transferee, $payment); | |
| 400 | - $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//-------------------- | |
| 401 | - } elseif($payment['settlement'] == 'acting_jpayment_conv') { | |
| 402 | - $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id)); | |
| 403 | - $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n"; | |
| 404 | - $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n"; | |
| 405 | - $msg_payment .= __('お支払先', 'usces').' : '.usces_get_conv_name($args['cv'])."\r\n"; | |
| 406 | - $msg_payment .= __('コンビニ受付番号','usces').' : '.$args['no']."\r\n"; | |
| 407 | - if($args['cv'] != '030') {//ファミリーマート以外 | |
| 408 | - $msg_payment .= __('コンビニ受付番号情報URL', 'usces').' : '.$args['cu']."\r\n"; | |
| 409 | - } | |
| 410 | - $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//-------------------- | |
| 411 | - } elseif($payment['settlement'] == 'acting_jpayment_bank') { | |
| 412 | - $args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id)); | |
| 413 | - $msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n"; | |
| 414 | - $msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n"; | |
| 415 | - $bank = explode('.', $args['bank']); | |
| 416 | - $msg_payment .= __('銀行コード','usces').' : '.$bank[0]."\r\n"; | |
| 417 | - $msg_payment .= __('銀行名','usces').' : '.$bank[1]."\r\n"; | |
| 418 | - $msg_payment .= __('支店コード','usces').' : '.$bank[2]."\r\n"; | |
| 419 | - $msg_payment .= __('支店名','usces').' : '.$bank[3]."\r\n"; | |
| 420 | - $msg_payment .= __('口座種別','usces').' : '.$bank[4]."\r\n"; | |
| 421 | - $msg_payment .= __('口座番号','usces').' : '.$bank[5]."\r\n"; | |
| 422 | - $msg_payment .= __('口座名義','usces').' : '.$bank[6]."\r\n"; | |
| 423 | - $msg_payment .= __('支払期限','usces').' : '.substr($args['exp'], 0, 4).'年'.substr($args['exp'], 4, 2).'月'.substr($args['exp'], 6, 2)."日\r\n"; | |
| 424 | - $msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//-------------------- | |
| 425 | - } | |
| 426 | - | |
| 427 | - $msg_body .= apply_filters('usces_filter_send_order_mail_payment', $msg_payment, $order_id, $payment, $cart, $entry, $data); | |
| 428 | - | |
| 429 | - $msg_body .= usces_mail_custom_field_info( 'order', '', $order_id ); | |
| 430 | - | |
| 431 | - $msg_body .= "\r\n"; | |
| 432 | - $msg_body .= __('** Others / a demand **','usces') . "\r\n"; | |
| 433 | - $msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//******************** | |
| 434 | - $msg_body .= $entry['order']['note'] . "\r\n\r\n"; | |
| 435 | - | |
| 436 | - $msg_body .= apply_filters('usces_filter_send_order_mail_body', NULL, $data); | |
| 437 | - $msg_body = apply_filters('usces_filter_send_order_mail_bodyall', $msg_body, $data); | |
| 438 | - | |
| 439 | - $subject = apply_filters('usces_filter_send_order_mail_subject_thankyou', $mail_data['title']['thankyou'], $data); | |
| 440 | - $message = do_shortcode($mail_data['header']['thankyou']) . $msg_body . do_shortcode($mail_data['footer']['thankyou']); | |
| 441 | - $confirm_para = array( | |
| 442 | - 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), ($entry["customer"]["name1"] . ' ' . $entry["customer"]["name2"])), | |
| 443 | - 'to_address' => $entry['customer']['mailaddress1'], | |
| 444 | - 'from_name' => get_option('blogname'), | |
| 445 | - 'from_address' => $usces->options['sender_mail'], | |
| 446 | - 'return_path' => $usces->options['sender_mail'], | |
| 447 | - 'subject' => $subject, | |
| 448 | - 'message' => $message | |
| 449 | - ); | |
| 450 | - $confirm_para = apply_filters( 'usces_send_ordermail_para_to_customer', $confirm_para, $entry, $data); | |
| 451 | - | |
| 452 | - usces_send_mail( $confirm_para ); | |
| 453 | - | |
| 454 | - $subject = apply_filters('usces_filter_send_order_mail_subject_order', $mail_data['title']['order'], $data); | |
| 455 | - $message = do_shortcode($mail_data['header']['order']) . $msg_body | |
| 456 | - . $mail_data['footer']['order'] | |
| 457 | - . "\n----------------------------------------------------\n" | |
| 458 | - . "REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR'] | |
| 459 | - . "\n----------------------------------------------------\n"; | |
| 460 | - | |
| 461 | - $order_para = array( | |
| 462 | - 'to_name' => __('An order email','usces'), | |
| 463 | - 'to_address' => $usces->options['order_mail'], | |
| 464 | - 'from_name' => sprintf(__('Mr/Mrs %s', 'usces'), ($entry["customer"]["name1"] . ' ' . $entry["customer"]["name2"])), | |
| 465 | - 'from_address' => $entry['customer']['mailaddress1'], | |
| 466 | - 'return_path' => $usces->options['error_mail'], | |
| 467 | - 'subject' => $subject, | |
| 468 | - 'message' => $message | |
| 469 | - ); | |
| 470 | - | |
| 471 | - $order_para = apply_filters( 'usces_send_ordermail_para_to_manager', $order_para, $entry, $data); | |
| 472 | - $res = usces_send_mail( $order_para ); | |
| 473 | - | |
| 474 | - return $res; | |
| 475 | -} | |
| 476 | - | |
| 477 | - | |
| 478 | -function usces_send_inquirymail() { | |
| 479 | - global $usces; | |
| 480 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 481 | - $res = false; | |
| 482 | - $mail_data = $usces->options['mail_data']; | |
| 483 | - $inq_name = trim($_POST["inq_name"]); | |
| 484 | - $inq_contents = trim($_POST["inq_contents"]); | |
| 485 | - $inq_mailaddress = trim($_POST["inq_mailaddress"]); | |
| 486 | - $reserve = ''; | |
| 487 | - if(isset($_POST['reserve'])){ | |
| 488 | - foreach($_POST['reserve'] as $key => $value){ | |
| 489 | - $reserve .= $key . " : " . $value . "\r\n"; | |
| 490 | - } | |
| 491 | - } | |
| 492 | - $mats = compact('inq_name','inq_contents','inq_mailaddress','reserve','mail_data'); | |
| 493 | - $subject = apply_filters( 'usces_filter_inquiry_subject_to_customer', $mail_data['title']['inquiry'],$mats); | |
| 494 | - $message = apply_filters( 'usces_filter_inquiry_header', $mail_data['header']['inquiry'], $inq_name, $inq_mailaddress ) . "\r\n\r\n"; | |
| 495 | - $message .= apply_filters( 'usces_filter_inquiry_reserve', $reserve, $inq_name, $inq_mailaddress ); | |
| 496 | - $message .= apply_filters( 'usces_filter_inq_contents', $inq_contents, $inq_name, $inq_mailaddress ) . "\r\n\r\n"; | |
| 497 | - $message .= apply_filters( 'usces_filter_inq_footer', $mail_data['footer']['inquiry'], $inq_name, $inq_mailaddress ); | |
| 498 | - do_action( 'usces_action_presend_inquiry_mail', $message, $inq_name, $inq_mailaddress ); | |
| 499 | - | |
| 500 | - $para1 = array( | |
| 501 | - 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $inq_name), | |
| 502 | - 'to_address' => $inq_mailaddress, | |
| 503 | - 'from_name' => get_option('blogname'), | |
| 504 | - 'from_address' => $usces->options['sender_mail'], | |
| 505 | - 'return_path' => $usces->options['sender_mail'], | |
| 506 | - 'subject' => $subject, | |
| 507 | - 'message' => do_shortcode($message), | |
| 508 | - ); | |
| 509 | - | |
| 510 | - $res0 = usces_send_mail( $para1 ); | |
| 511 | - if ( $res0 ) { | |
| 512 | - | |
| 513 | - $subject = apply_filters( 'usces_filter_inquiry_subject_to_manager', __('** An inquiry **','usces').'('.$inq_name.')',$mats); | |
| 514 | - $message = $reserve . $_POST['inq_contents'] . "\r\n" | |
| 515 | - . "\n----------------------------------------------------\n" | |
| 516 | - . "REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR'] | |
| 517 | - . "\n----------------------------------------------------\n"; | |
| 518 | - | |
| 519 | - $para2 = array( | |
| 520 | - 'to_name' => __('An inquiry email','usces'), | |
| 521 | - 'to_address' => $usces->options['inquiry_mail'], | |
| 522 | - 'from_name' => sprintf(__('Mr/Mrs %s', 'usces'), $inq_name), | |
| 523 | - 'from_address' => $inq_mailaddress, | |
| 524 | - 'return_path' => $usces->options['error_mail'], | |
| 525 | - 'subject' => $subject, | |
| 526 | - 'message' => do_shortcode($message), | |
| 527 | - ); | |
| 528 | - sleep(1); | |
| 529 | - $res = usces_send_mail( $para2 ); | |
| 530 | - | |
| 531 | - } | |
| 532 | - | |
| 533 | - return $res; | |
| 534 | - | |
| 535 | -} | |
| 536 | - | |
| 537 | -function usces_send_regmembermail($user) { | |
| 538 | - global $usces; | |
| 539 | - $res = false; | |
| 540 | - $mail_data = $usces->options['mail_data']; | |
| 541 | - $newmem_admin_mail = $usces->options['newmem_admin_mail']; | |
| 542 | - $name = usces_localized_name(trim($user['name1']), trim($user['name2']), 'return'); | |
| 543 | - $mailaddress1 = trim($user['mailaddress1']); | |
| 544 | - | |
| 545 | - $subject = $mail_data['title']['membercomp']; | |
| 546 | - $message = $mail_data['header']['membercomp']; | |
| 547 | - $message .= __('Registration contents', 'usces')."\r\n"; | |
| 548 | - $message .= '--------------------------------'."\r\n"; | |
| 549 | - $message .= __('Member ID', 'usces') . ' : ' . $user['ID'] . "\r\n"; | |
| 550 | - $message .= __('Name', 'usces') . ' : ' . sprintf(__('Mr/Mrs %s', 'usces'), $name) . "\r\n"; | |
| 551 | - $message .= __('e-mail adress', 'usces') . ' : ' . $mailaddress1."\r\n"; | |
| 552 | - $message .= '--------------------------------'."\r\n\r\n"; | |
| 553 | - $message .= $mail_data['footer']['membercomp']; | |
| 554 | - $message = apply_filters('usces_filter_send_regmembermail_message', $message, $user); | |
| 555 | - | |
| 556 | - $para1 = array( | |
| 557 | - 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $name), | |
| 558 | - 'to_address' => $mailaddress1, | |
| 559 | - 'from_name' => get_option('blogname'), | |
| 560 | - 'from_address' => $usces->options['sender_mail'], | |
| 561 | - 'return_path' => $usces->options['sender_mail'], | |
| 562 | - 'subject' => $subject, | |
| 563 | - 'message' => do_shortcode($message), | |
| 564 | - ); | |
| 565 | - $para1 = apply_filters( 'usces_filter_send_regmembermail_para1', $para1 ); | |
| 566 | - $res = usces_send_mail( $para1 ); | |
| 567 | - | |
| 568 | - if($newmem_admin_mail){ | |
| 569 | - | |
| 570 | - $subject = __('New sign-in processing was completed.', 'usces'); | |
| 571 | - $message = __('New sign-in processing was completed.', 'usces') . "\r\n\r\n"; | |
| 572 | - $message .= __('Registration contents', 'usces')."\r\n"; | |
| 573 | - $message .= '--------------------------------'."\r\n"; | |
| 574 | - $message .= __('Member ID', 'usces') . ' : ' . $user['ID'] . "\r\n"; | |
| 575 | - $message .= __('Name', 'usces') . ' : ' . sprintf(__('Mr/Mrs %s', 'usces'), $name) . "\r\n"; | |
| 576 | - $message .= __('e-mail adress', 'usces') . ' : ' . $mailaddress1."\r\n"; | |
| 577 | - $message .= '--------------------------------'."\r\n\r\n"; | |
| 578 | - $message = apply_filters('usces_filter_send_regmembermail_notice', $message, $user); | |
| 579 | - | |
| 580 | - $para2 = array( | |
| 581 | - 'to_name' => __('Notice of new sign-in', 'usces'), | |
| 582 | - 'to_address' => $usces->options['order_mail'], | |
| 583 | - 'from_name' => get_option('blogname'), | |
| 584 | - 'from_address' => $usces->options['sender_mail'], | |
| 585 | - 'return_path' => $usces->options['sender_mail'], | |
| 586 | - 'subject' => $subject, | |
| 587 | - 'message' => do_shortcode($message), | |
| 588 | - ); | |
| 589 | - $para2 = apply_filters( 'usces_filter_send_regmembermail_para2', $para2 ); | |
| 590 | - usces_send_mail( $para2 ); | |
| 591 | - } | |
| 592 | - | |
| 593 | - return $res; | |
| 594 | - | |
| 595 | -} | |
| 596 | - | |
| 597 | -function usces_send_delmembermail( $user ) { | |
| 598 | - global $usces; | |
| 599 | - $res = true; | |
| 600 | - $mail_data = $usces->options['mail_data']; | |
| 601 | - $delmem_admin_mail = $usces->options['delmem_admin_mail']; | |
| 602 | - $delmem_customer_mail = $usces->options['delmem_customer_mail']; | |
| 603 | - $name = usces_localized_name(trim($user['name1']), trim($user['name2']), 'return'); | |
| 604 | - $mailaddress1 = trim($user['mailaddress1']); | |
| 605 | - $subject = apply_filters( 'usces_filter_send_delmembermail_subject', __('Member removal processing was completed.', 'usces'), $user ); | |
| 606 | - | |
| 607 | - if( $delmem_customer_mail ) { | |
| 608 | - $message = $subject."\r\n\r\n"; | |
| 609 | - $message .= __('Registration contents', 'usces')."\r\n"; | |
| 610 | - $message .= '--------------------------------'."\r\n"; | |
| 611 | - $message .= __('Member ID', 'usces').' : '.$user['ID']."\r\n"; | |
| 612 | - $message .= __('Name', 'usces').' : '.sprintf(__('Mr/Mrs %s', 'usces'), $name)."\r\n"; | |
| 613 | - $message .= __('e-mail adress', 'usces').' : '.$mailaddress1."\r\n"; | |
| 614 | - $message .= '--------------------------------'."\r\n\r\n"; | |
| 615 | - $message .= $mail_data['footer']['membercomp']; | |
| 616 | - $message = apply_filters( 'usces_filter_send_delmembermail_message', $message, $user ); | |
| 617 | - | |
| 618 | - $para1 = array( | |
| 619 | - 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $name), | |
| 620 | - 'to_address' => $mailaddress1, | |
| 621 | - 'from_name' => get_option('blogname'), | |
| 622 | - 'from_address' => $usces->options['sender_mail'], | |
| 623 | - 'return_path' => $usces->options['sender_mail'], | |
| 624 | - 'subject' => $subject, | |
| 625 | - 'message' => do_shortcode($message), | |
| 626 | - ); | |
| 627 | - $para1 = apply_filters( 'usces_filter_send_delmembermail_para1', $para1 ); | |
| 628 | - $res = usces_send_mail( $para1 ); | |
| 629 | - } | |
| 630 | - | |
| 631 | - if( $delmem_admin_mail ) { | |
| 632 | - $message = $subject."\r\n\r\n"; | |
| 633 | - $message .= __('Registration contents', 'usces')."\r\n"; | |
| 634 | - $message .= '--------------------------------'."\r\n"; | |
| 635 | - $message .= __('Member ID', 'usces').' : '.$user['ID']."\r\n"; | |
| 636 | - $message .= __('Name', 'usces').' : '.sprintf(__('Mr/Mrs %s', 'usces'), $name)."\r\n"; | |
| 637 | - $message .= __('e-mail adress', 'usces') . ' : '.$mailaddress1."\r\n"; | |
| 638 | - $message .= '--------------------------------'."\r\n\r\n"; | |
| 639 | - $message = apply_filters( 'usces_filter_send_delmembermail_notice', $message, $user ); | |
| 640 | - | |
| 641 | - $para2 = array( | |
| 642 | - 'to_name' => __('Notice of new sign-in', 'usces'), | |
| 643 | - 'to_address' => $usces->options['order_mail'], | |
| 644 | - 'from_name' => get_option('blogname'), | |
| 645 | - 'from_address' => $usces->options['sender_mail'], | |
| 646 | - 'return_path' => $usces->options['sender_mail'], | |
| 647 | - 'subject' => $subject, | |
| 648 | - 'message' => do_shortcode($message), | |
| 649 | - ); | |
| 650 | - $para2 = apply_filters( 'usces_filter_send_delmembermail_para2', $para2 ); | |
| 651 | - $res = usces_send_mail( $para2 ); | |
| 652 | - } | |
| 653 | - return $res; | |
| 654 | -} | |
| 655 | - | |
| 656 | -function usces_lostmail($url) { | |
| 657 | - global $usces; | |
| 658 | - $res = false; | |
| 659 | - | |
| 660 | - $mail_data = $usces->options['mail_data']; | |
| 661 | - $subject = apply_filters( 'usces_filter_lostmail_subject', __('Change password','usces') ); | |
| 662 | - $message = __('Please, click the following URL, and please change a password.','usces') . "\n\r\n\r\n\r" | |
| 663 | - . $url . "\n\r\n\r\n\r" | |
| 664 | - . "-----------------------------------------------------\n\r" | |
| 665 | - . __('If you have not requested this email please kindly ignore and delete it.','usces') . "\n\r" | |
| 666 | - . "-----------------------------------------------------\n\r\n\r\n\r"; | |
| 667 | - $message = apply_filters( 'usces_filter_lostmail_message', $message, $url ); | |
| 668 | - $message .= apply_filters( 'usces_filter_lostmail_footer', $mail_data['footer']['othermail'] ); | |
| 669 | - | |
| 670 | - | |
| 671 | - $para1 = array( | |
| 672 | - 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $_SESSION["usces_lostmail"]), | |
| 673 | - 'to_address' => $_SESSION["usces_lostmail"], | |
| 674 | - 'from_name' => get_option('blogname'), | |
| 675 | - 'from_address' => $usces->options['sender_mail'], | |
| 676 | - 'return_path' => $usces->options['sender_mail'], | |
| 677 | - 'subject' => $subject, | |
| 678 | - 'message' => do_shortcode($message), | |
| 679 | - ); | |
| 680 | - | |
| 681 | - $para1 = apply_filters( 'usces_filter_send_lostmail_para1', $para1 ); | |
| 682 | - $res = usces_send_mail( $para1 ); | |
| 683 | - | |
| 684 | - if($res === false) { | |
| 685 | - $usces->error_message = __('Error: I was not able to transmit an email.','usces'); | |
| 686 | - $page = 'lostmemberpassword'; | |
| 687 | - } else { | |
| 688 | - $page = 'lostcompletion'; | |
| 689 | - } | |
| 690 | - | |
| 691 | - return $page; | |
| 692 | - | |
| 693 | -} | |
| 694 | - | |
| 695 | -//20100818ysk start | |
| 696 | -//function usces_mail_custom_field_info( $custom_field, $position, $id ) { | |
| 697 | -function usces_mail_custom_field_info( $custom_field, $position, $id, $mailaddress = '' ) { | |
| 698 | - global $usces; | |
| 699 | - | |
| 700 | - $msg_body = ''; | |
| 701 | - switch($custom_field) { | |
| 702 | - case 'order': | |
| 703 | - $field = 'usces_custom_order_field'; | |
| 704 | - $cs = 'csod_'; | |
| 705 | - break; | |
| 706 | - case 'customer': | |
| 707 | - $field = 'usces_custom_customer_field'; | |
| 708 | - $cs = 'cscs_'; | |
| 709 | - break; | |
| 710 | - case 'delivery': | |
| 711 | - $field = 'usces_custom_delivery_field'; | |
| 712 | - $cs = 'csde_'; | |
| 713 | - break; | |
| 714 | - case 'member': | |
| 715 | - $field = 'usces_custom_member_field'; | |
| 716 | - $cs = 'csmb_'; | |
| 717 | - break; | |
| 718 | - default: | |
| 719 | - return $msg_body; | |
| 720 | - } | |
| 721 | - | |
| 722 | - $meta = usces_has_custom_field_meta($custom_field); | |
| 723 | - | |
| 724 | - if(!empty($meta) and is_array($meta)) { | |
| 725 | - $keys = array_keys($meta); | |
| 726 | - switch($custom_field) { | |
| 727 | - case 'order': | |
| 728 | - $msg_body .= "\r\n"; | |
| 729 | - $msg_body .= usces_mail_line( 1, $mailaddress ); | |
| 730 | - foreach($keys as $key) { | |
| 731 | - $value = maybe_unserialize($usces->get_order_meta_value($cs.$key, $id)); | |
| 732 | - if(is_array($value)) { | |
| 733 | - $concatval = ''; | |
| 734 | - $c = ''; | |
| 735 | - foreach($value as $v) { | |
| 736 | - $concatval .= $c.$v; | |
| 737 | - $c = ', '; | |
| 738 | - } | |
| 739 | - $value = $concatval; | |
| 740 | - } | |
| 741 | - $msg_body .= $meta[$key]['name']." : ".$value."\r\n"; | |
| 742 | - } | |
| 743 | - $msg_body .= usces_mail_line( 1, $mailaddress ); | |
| 744 | - break; | |
| 745 | - | |
| 746 | - case 'customer': | |
| 747 | - case 'delivery': | |
| 748 | - foreach($keys as $key) { | |
| 749 | - if($meta[$key]['position'] == $position) { | |
| 750 | - $value = maybe_unserialize($usces->get_order_meta_value($cs.$key, $id)); | |
| 751 | - if(is_array($value)) { | |
| 752 | - $concatval = ''; | |
| 753 | - $c = ''; | |
| 754 | - foreach($value as $v) { | |
| 755 | - $concatval .= $c.$v; | |
| 756 | - $c = ', '; | |
| 757 | - } | |
| 758 | - $value = $concatval; | |
| 759 | - } | |
| 760 | - $msg_body .= $meta[$key]['name']." : ".$value."\r\n"; | |
| 761 | - } | |
| 762 | - } | |
| 763 | - break; | |
| 764 | - | |
| 765 | - case 'member': | |
| 766 | - foreach($keys as $key) { | |
| 767 | - if($meta[$key]['position'] == $position) { | |
| 768 | - $value = maybe_unserialize($usces->get_member_meta_value($cs.$key, $id)); | |
| 769 | - if(is_array($value)) { | |
| 770 | - $concatval = ''; | |
| 771 | - $c = ''; | |
| 772 | - foreach($value as $v) { | |
| 773 | - $concatval .= $c.$v; | |
| 774 | - $c = ', '; | |
| 775 | - } | |
| 776 | - $value = $concatval; | |
| 777 | - } | |
| 778 | - $msg_body .= $meta[$key]['name']." : ".$value."\r\n"; | |
| 779 | - } | |
| 780 | - } | |
| 781 | - break; | |
| 782 | - } | |
| 783 | - } | |
| 784 | - $msg_body = apply_filters('usces_filter_mail_custom_field_info', $msg_body, $custom_field, $position, $id, $mailaddress); | |
| 785 | - return $msg_body; | |
| 786 | -} | |
| 787 | -//20100818ysk end | |
| 788 | - | |
| 789 | -//function usces_send_receipted_mail( $order_id, $acting ) { | |
| 790 | -// global $usces; | |
| 791 | -// $res = false; | |
| 792 | -// | |
| 793 | -// $subject = __('Change password','usces'); | |
| 794 | -// $message = __('Please, click the following URL, and please change a password.','usces') . "\n\r\n\r\n\r" | |
| 795 | -// . $url . "\n\r\n\r\n\r" | |
| 796 | -// . "-----------------------------------------------------\n\r" | |
| 797 | -// . __('I seem to have you cancel it when the body does not have memorizing to this email.','usces') . "\n\r" | |
| 798 | -// . "-----------------------------------------------------\n\r\n\r\n\r" | |
| 799 | -// . $usces->options['mail_data']['footer']['footerlogo']; | |
| 800 | -// | |
| 801 | -// $para1 = array( | |
| 802 | -// 'to_name' => sprintf(__('Mr/Mrs %s', 'usces'), $_SESSION["usces_lostmail"]), | |
| 803 | -// 'to_address' => $_SESSION["usces_lostmail"], | |
| 804 | -// 'from_name' => get_bloginfo('name'), | |
| 805 | -// 'from_address' => $usces->options['sender_mail'], | |
| 806 | -// 'return_path' => $usces->options['error_mail'], | |
| 807 | -// 'subject' => $subject, | |
| 808 | -// 'message' => $message | |
| 809 | -// ); | |
| 810 | -// | |
| 811 | -// $res = usces_send_mail( $para1 ); | |
| 812 | -// | |
| 813 | -// if($res === false) { | |
| 814 | -// $usces->error_message = __('Error: I was not able to transmit an email.','usces'); | |
| 815 | -// $page = 'lostmemberpassword'; | |
| 816 | -// } else { | |
| 817 | -// $page = 'lostcompletion'; | |
| 818 | -// } | |
| 819 | -// | |
| 820 | -// return $page; | |
| 821 | -// | |
| 822 | -//} | |
| 823 | - | |
| 824 | -function usces_send_mail( $para ) { | |
| 825 | - global $usces; | |
| 826 | - | |
| 827 | - $from_name = $para['from_name']; | |
| 828 | - $from_address = $para['from_address']; | |
| 829 | - if (strpos($para['from_address'], '..') !== false || strpos($para['from_address'], '.@') !== false) { | |
| 830 | - $fname = str_replace(strstr($para['from_address'], '@'), '', $para['from_address']); | |
| 831 | - if( '"' != substr($fname, 0, 1) && '"' != substr($fname, -1) ){ | |
| 832 | - $para['from_address'] = str_replace($fname, '"RFC_violation"', $para['from_address']); | |
| 833 | - $from_name = $para['from_name'] . '(' . $from_address . ')'; | |
| 834 | - } | |
| 835 | - } | |
| 836 | - $from = htmlspecialchars(html_entity_decode($from_name, ENT_QUOTES)) . " <{$para['from_address']}>"; | |
| 837 | - $header = "From: " . apply_filters('usces_filter_send_mail_from', $from, $para) . "\r\n"; | |
| 838 | - $header .= "Return-Path: {$para['return_path']}\r\n"; | |
| 839 | - | |
| 840 | - $subject = html_entity_decode($para['subject'], ENT_QUOTES); | |
| 841 | - $message = $para['message']; | |
| 842 | - | |
| 843 | - ini_set( "SMTP", "{$usces->options['smtp_hostname']}" ); | |
| 844 | - if( !ini_get( "smtp_port" ) ){ | |
| 845 | - ini_set( "smtp_port", apply_filters('usces_filter_send_mail_port', 25, $para) ); | |
| 846 | - } | |
| 847 | - ini_set( "sendmail_from", "" ); | |
| 848 | - | |
| 849 | - $mails = explode( ',', $para['to_address'] ); | |
| 850 | - $to_mailes = array(); | |
| 851 | - foreach( $mails as $mail ){ | |
| 852 | - if (strpos($mail, '..') !== false || strpos($mail, '.@') !== false) { | |
| 853 | - $name = str_replace(strstr($mail, '@'), '', $mail); | |
| 854 | - if( '"' != substr($name, 0, 1) && '"' != substr($name, -1) ){ | |
| 855 | - $to_mailes[] = str_replace($name, '"'.$name.'"', $mail); | |
| 856 | - }else{ | |
| 857 | - $to_mailes[] = $mail; | |
| 858 | - } | |
| 859 | - }elseif( is_email( trim($mail) ) ){ | |
| 860 | - $to_mailes[] = $mail; | |
| 861 | - }else{ | |
| 862 | - $to_mailes[] = NULL; | |
| 863 | - } | |
| 864 | - } | |
| 865 | - | |
| 866 | - if( !empty( $to_mailes ) ){ | |
| 867 | - $res = @wp_mail( $to_mailes , $subject , $message, $header ); | |
| 868 | - }else{ | |
| 869 | - $res = false; | |
| 870 | - } | |
| 871 | - | |
| 872 | - return $res; | |
| 873 | - | |
| 874 | -} | |
| 875 | - | |
| 876 | -function usces_send_mail2( $para ) { | |
| 877 | - global $usces; | |
| 878 | - | |
| 879 | - $usces->mail_para = $para; | |
| 880 | - add_action('phpmailer_init','usces_send_mail_init', 11); | |
| 881 | - | |
| 882 | -// $from = htmlspecialchars(html_entity_decode($para['from_name'], ENT_QUOTES)) . " <{$para['from_address']}>"; | |
| 883 | -// $header = "From: " . apply_filters('usces_filter_send_mail_from', $from, $para) . "\r\n"; | |
| 884 | -// $header .= "Return-Path: {$para['return_path']}\r\n"; | |
| 885 | - | |
| 886 | - $subject = html_entity_decode($para['subject'], ENT_QUOTES); | |
| 887 | - $message = $para['message']; | |
| 888 | - | |
| 889 | -// ini_set( "SMTP", "{$usces->options['smtp_hostname']}" ); | |
| 890 | -// if( !ini_get( "smtp_port" ) ){ | |
| 891 | -// ini_set( "smtp_port", apply_filters('usces_filter_send_mail_port', 25, $para) ); | |
| 892 | -// } | |
| 893 | -// ini_set( "sendmail_from", "" ); | |
| 894 | - | |
| 895 | - $mails = explode( ',', $para['to_address'] ); | |
| 896 | - $to_mailes = array(); | |
| 897 | - foreach( $mails as $mail ){ | |
| 898 | - if( is_email( trim($mail) ) ){ | |
| 899 | - $to_mailes[] = $mail; | |
| 900 | - } | |
| 901 | - } | |
| 902 | - if( !empty( $to_mailes ) ){ | |
| 903 | - $res = @wp_mail( $to_mailes , $subject , $message ); | |
| 904 | - }else{ | |
| 905 | - $res = false; | |
| 906 | - } | |
| 907 | -//usces_log('mail : '.print_r($res, true), 'acting_transaction.log'); | |
| 908 | - | |
| 909 | - remove_action('phpmailer_init','usces_send_mail_init', 11); | |
| 910 | - $usces->mail_para = array(); | |
| 911 | - return $res; | |
| 912 | - | |
| 913 | -} | |
| 914 | - | |
| 915 | -function usces_send_mail_init($phpmailer){ | |
| 916 | - global $usces; | |
| 917 | - | |
| 918 | - $phpmailer->Mailer = 'mail'; | |
| 919 | - $phpmailer->From = $usces->mail_para['from_address']; | |
| 920 | - $phpmailer->FromName = apply_filters('usces_filter_send_mail_from', $usces->mail_para['from_name'], $usces->mail_para); | |
| 921 | - $phpmailer->Sender = $usces->mail_para['from_address']; | |
| 922 | - | |
| 923 | -// $phpmailer->Mailer = 'smtp'; | |
| 924 | -// $phpmailer->SMTPSecure = ''; | |
| 925 | -// $phpmailer->Host = 'sample.com'; | |
| 926 | -// $phpmailer->Port = 25; | |
| 927 | -// $phpmailer->SMTPAuth = true; | |
| 928 | -// $phpmailer->Username = 'sample@sample.com'; | |
| 929 | -// $phpmailer->Password = 'password'; | |
| 930 | - | |
| 931 | - do_action('usces_filter_phpmailer_init', array( &$phpmailer )); | |
| 932 | -} | |
| 933 | - | |
| 934 | -function usces_reg_orderdata( $results = array() ) { | |
| 935 | - global $wpdb, $usces; | |
| 936 | -// $wpdb->show_errors(); | |
| 937 | - | |
| 938 | - $options = get_option('usces'); | |
| 939 | - $cart = $usces->cart->get_cart(); | |
| 940 | - $entry = $usces->cart->get_entry(); | |
| 941 | - if( empty($cart) ){ | |
| 942 | - usces_log('reg_orderdata : Session is empty.', 'database_error.log'); | |
| 943 | - return 0; | |
| 944 | - } | |
| 945 | - if( (empty($entry['customer']['name1']) && empty($entry['customer']['name2'])) || empty($entry['customer']['mailaddress1']) || empty($entry) || empty($cart) ) return '1';//20131121ysk | |
| 946 | - | |
| 947 | - $charging_type = $usces->getItemChargingType($cart[0]['post_id']); | |
| 948 | - | |
| 949 | - $item_total_price = $usces->get_total_price( $cart ); | |
| 950 | - $member = $usces->get_member(); | |
| 951 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 952 | - $order_table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 953 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 954 | - $set = $usces->getPayments( $entry['order']['payment_name'] ); | |
| 955 | - $status = ''; | |
| 956 | - if( 'continue' == $charging_type ){ | |
| 957 | - $order_modified = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 958 | - }else{ | |
| 959 | -//20131121ysk start | |
| 960 | - //$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' : ''; | |
| 961 | - $noreceipt_status_table = apply_filters( 'usces_filter_noreceipt_status', array( 'transferAdvance', 'transferDeferred', 'acting_remise_conv', 'acting_zeus_bank', 'acting_zeus_conv', 'acting_jpayment_conv', 'acting_jpayment_bank', 'acting_sbps_conv', 'acting_sbps_payeasy', 'acting_digitalcheck_conv', 'acting_mizuho_conv1', 'acting_mizuho_conv2', 'acting_veritrans_conv' ) ); | |
| 962 | - $status = ( in_array( $set['settlement'], $noreceipt_status_table ) ) ? 'noreceipt' : ''; | |
| 963 | - $order_modified = NULL; | |
| 964 | - } | |
| 965 | - //$payments = $usces->getPayments($entry['order']['payment_name']); | |
| 966 | - //if( isset($results['payment_status']) && $results['payment_status'] != 'Completed' && $payments['module'] == 'paypal.php') $status = 'pending'; | |
| 967 | - if( $set['module'] == 'paypal.php' || $set['settlement'] == 'acting_paypal_ec' ) { | |
| 968 | - if( ( isset($results['payment_status']) && $results['payment_status'] != 'Completed' ) || ( isset($results['profile_status']) && $results['profile_status'] != 'ActiveProfile' ) ) { | |
| 969 | - $status = 'pending'; | |
| 970 | - } | |
| 971 | - } | |
| 972 | - //if( (empty($entry['customer']['name1']) && empty($entry['customer']['name2'])) || empty($entry['customer']['mailaddress1']) || empty($entry) || empty($cart) ) return '1'; | |
| 973 | - $status = apply_filters( 'usces_filter_reg_orderdata_status', $status, $entry ); | |
| 974 | -//20131121ysk end | |
| 975 | - $delidue_date = ( isset($entry['order']['delidue_date']) ) ? $entry['order']['delidue_date'] : NULL; | |
| 976 | -//20101208ysk start | |
| 977 | - $query = $wpdb->prepare( | |
| 978 | - "INSERT INTO $order_table_name ( | |
| 979 | - `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`, | |
| 980 | - `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`, | |
| 981 | - `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`, | |
| 982 | - `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`, | |
| 983 | - `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` ) | |
| 984 | - 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)", | |
| 985 | - $member['ID'], | |
| 986 | - $entry['customer']['mailaddress1'], | |
| 987 | - $entry['customer']['name1'], | |
| 988 | - $entry['customer']['name2'], | |
| 989 | - $entry['customer']['name3'], | |
| 990 | - $entry['customer']['name4'], | |
| 991 | - $entry['customer']['zipcode'], | |
| 992 | - $entry['customer']['pref'], | |
| 993 | - $entry['customer']['address1'], | |
| 994 | - $entry['customer']['address2'], | |
| 995 | - $entry['customer']['address3'], | |
| 996 | - $entry['customer']['tel'], | |
| 997 | - $entry['customer']['fax'], | |
| 998 | - serialize($entry['delivery']), | |
| 999 | - serialize($cart), | |
| 1000 | - $entry['order']['note'], | |
| 1001 | - $entry['order']['delivery_method'], | |
| 1002 | - $entry['order']['delivery_date'], | |
| 1003 | - $entry['order']['delivery_time'], | |
| 1004 | - $entry['order']['payment_name'], | |
| 1005 | - serialize($entry['condition']), | |
| 1006 | - $item_total_price, | |
| 1007 | - $entry['order']['getpoint'], | |
| 1008 | - $entry['order']['usedpoint'], | |
| 1009 | - $entry['order']['discount'], | |
| 1010 | - $entry['order']['shipping_charge'], | |
| 1011 | - $entry['order']['cod_fee'], | |
| 1012 | - $entry['order']['tax'], | |
| 1013 | - get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), | |
| 1014 | - $order_modified, | |
| 1015 | - $status, | |
| 1016 | - $delidue_date | |
| 1017 | - ); | |
| 1018 | -//20101208ysk end | |
| 1019 | - | |
| 1020 | - $res = $wpdb->query( $query ); | |
| 1021 | - usces_log('reg_orderdata : ' . $wpdb->last_error, 'database_error.log'); | |
| 1022 | - | |
| 1023 | - if( $res === false){ | |
| 1024 | - $order_id = false; | |
| 1025 | - }else{ | |
| 1026 | - $order_id = $wpdb->insert_id; | |
| 1027 | - } | |
| 1028 | - | |
| 1029 | - if ( !$order_id ) : | |
| 1030 | - | |
| 1031 | - usces_log('reg_error_entry : '.print_r($entry, true), 'acting_transaction.log'); | |
| 1032 | - return false; | |
| 1033 | - | |
| 1034 | - else : | |
| 1035 | - | |
| 1036 | - $usces->cart->set_order_entry( array('ID' => $order_id) ); | |
| 1037 | - $usces->set_order_meta_value('customer_country', $entry['customer']['country'], $order_id); | |
| 1038 | - | |
| 1039 | - if ( $member['ID'] && 'activate' == $options['membersystem_state'] && 'activate' == $options['membersystem_point'] ) { | |
| 1040 | - | |
| 1041 | - $mquery = ''; | |
| 1042 | - if( usces_is_complete_settlement( $entry['order']['payment_name'], $status ) ) {//20120306ysk 0000324 | |
| 1043 | - if( apply_filters( 'usces_action_acting_getpoint_switch', true, $order_id, true) ){ | |
| 1044 | - $mquery = $wpdb->prepare( | |
| 1045 | - "UPDATE $member_table_name SET mem_point = (mem_point + %d - %d) WHERE ID = %d", | |
| 1046 | - $entry['order']['getpoint'], $entry['order']['usedpoint'], $member['ID']); | |
| 1047 | - }else{ | |
| 1048 | - $mquery = $wpdb->prepare( | |
| 1049 | - "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", | |
| 1050 | - $entry['order']['usedpoint'], $member['ID']); | |
| 1051 | - } | |
| 1052 | - } elseif( 0 < $entry['order']['usedpoint'] ) { | |
| 1053 | - $mquery = $wpdb->prepare( | |
| 1054 | - "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", | |
| 1055 | - $entry['order']['usedpoint'], $member['ID']); | |
| 1056 | - } | |
| 1057 | - if( $mquery ) { | |
| 1058 | - $wpdb->query( $mquery ); | |
| 1059 | - $mquery = $wpdb->prepare("SELECT mem_point FROM $member_table_name WHERE ID = %d", $member['ID']); | |
| 1060 | - $point = $wpdb->get_var( $mquery ); | |
| 1061 | - $_SESSION['usces_member']['point'] = $point; | |
| 1062 | - } | |
| 1063 | - | |
| 1064 | - } | |
| 1065 | - | |
| 1066 | - if ( !empty($entry['reserve']) ) { | |
| 1067 | - foreach ( $entry['reserve'] as $key => $value ) { | |
| 1068 | - if ( is_array($value) ) | |
| 1069 | - $value = serialize($value); | |
| 1070 | - $usces->set_order_meta_value($key, $value, $order_id); | |
| 1071 | - } | |
| 1072 | - } | |
| 1073 | - | |
| 1074 | - if ( !preg_match('/pending|noreceipt/', $status) ) { | |
| 1075 | - $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 1076 | - $usces->set_order_meta_value('receipted_date', $value, $order_id); | |
| 1077 | - } | |
| 1078 | - | |
| 1079 | -//20100818ysk start | |
| 1080 | - if( !empty($entry['custom_order']) ) { | |
| 1081 | - foreach( $entry['custom_order'] as $key => $value ) { | |
| 1082 | - $csod_key = 'csod_'.$key; | |
| 1083 | - if( is_array($value) ) | |
| 1084 | - $value = serialize($value); | |
| 1085 | - $usces->set_order_meta_value($csod_key, $value, $order_id); | |
| 1086 | - } | |
| 1087 | - } | |
| 1088 | - if( !empty($entry['custom_customer']) ) { | |
| 1089 | - foreach( $entry['custom_customer'] as $key => $value ) { | |
| 1090 | - $cscs_key = 'cscs_'.$key; | |
| 1091 | - if( is_array($value) ) | |
| 1092 | - $value = serialize($value); | |
| 1093 | - $usces->set_order_meta_value($cscs_key, $value, $order_id); | |
| 1094 | - } | |
| 1095 | - } | |
| 1096 | - if( !empty($entry['custom_delivery']) ) { | |
| 1097 | - foreach( $entry['custom_delivery'] as $key => $value ) { | |
| 1098 | - $csde_key = 'csde_'.$key; | |
| 1099 | - if( is_array($value) ) | |
| 1100 | - $value = serialize($value); | |
| 1101 | - $usces->set_order_meta_value($csde_key, $value, $order_id); | |
| 1102 | - } | |
| 1103 | - } | |
| 1104 | -//20100818ysk end | |
| 1105 | - | |
| 1106 | - if ( isset($_REQUEST['X-S_TORIHIKI_NO']) ) { | |
| 1107 | - $usces->set_order_meta_value('settlement_id', $_REQUEST['X-S_TORIHIKI_NO'], $order_id); | |
| 1108 | - if ( isset($_REQUEST['X-AC_MEMBERID']) ) { | |
| 1109 | - $usces->set_order_meta_value($_REQUEST['X-AC_MEMBERID'], 'continuation', $order_id); | |
| 1110 | - //$usces->set_member_meta_value('continue_memberid', $_REQUEST['X-AC_MEMBERID']); | |
| 1111 | - $usces->set_member_meta_value('continue_memberid_'.$order_id, $_REQUEST['X-AC_MEMBERID']); | |
| 1112 | - } | |
| 1113 | - } | |
| 1114 | - | |
| 1115 | - if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) { | |
| 1116 | - $usces->set_order_meta_value('settlement_id', $_GET['cod'], $order_id); | |
| 1117 | - foreach($_GET as $key => $value) { | |
| 1118 | - if( 'purchase_jpayment' != $key) | |
| 1119 | - $data[$key] = esc_sql($value); | |
| 1120 | - } | |
| 1121 | - $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id); | |
| 1122 | - } | |
| 1123 | - if( isset($_REQUEST['acting']) && isset($_REQUEST['acting_return']) && isset($_REQUEST['trans_code']) && 'epsilon' == $_REQUEST['acting'] ) { | |
| 1124 | - //$usces->set_order_meta_value('settlement_id', $_GET['trans_code'], $order_id);//20130523ysk 0000711 | |
| 1125 | - $usces->set_order_meta_value('settlement_id', $_GET['order_number'], $order_id); | |
| 1126 | - } | |
| 1127 | - if( isset($_REQUEST['res_tracking_id']) ) { | |
| 1128 | - $usces->set_order_meta_value('res_tracking_id', $_REQUEST['res_tracking_id'], $order_id); | |
| 1129 | - } | |
| 1130 | -//20121206ysk start | |
| 1131 | - if( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) ) { | |
| 1132 | - if( substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) { | |
| 1133 | - $data['SID'] = esc_sql($_REQUEST['SID']); | |
| 1134 | - $usces->set_order_meta_value( $_REQUEST['FUKA'], serialize($data), $order_id ); | |
| 1135 | - } | |
| 1136 | - $usces->set_order_meta_value( 'SID', $_REQUEST['SID'], $order_id ); | |
| 1137 | - } | |
| 1138 | -//20121206ysk end | |
| 1139 | -//20130225ysk start | |
| 1140 | - if( isset($_REQUEST['acting']) && 'mizuho_card' == $_REQUEST['acting'] ) { | |
| 1141 | - $data['stran'] = esc_sql($_REQUEST['stran']); | |
| 1142 | - $data['mbtran'] = esc_sql($_REQUEST['mbtran']); | |
| 1143 | - $usces->set_order_meta_value( 'acting_'.$_REQUEST['acting'], serialize($data), $order_id ); | |
| 1144 | - } elseif( isset($_REQUEST['acting']) && 'mizuho_conv' == $_REQUEST['acting'] ) { | |
| 1145 | - $data['stran'] = esc_sql($_REQUEST['stran']); | |
| 1146 | - $data['mbtran'] = esc_sql($_REQUEST['mbtran']); | |
| 1147 | - $data['bktrans'] = esc_sql($_REQUEST['bktrans']); | |
| 1148 | - $data['tranid'] = esc_sql($_REQUEST['tranid']); | |
| 1149 | - $usces->set_order_meta_value( 'stran', $data['stran'], $order_id ); | |
| 1150 | - $usces->set_order_meta_value( 'acting_'.$_REQUEST['acting'], serialize($data), $order_id ); | |
| 1151 | - } | |
| 1152 | -//20130225ysk end | |
| 1153 | -//20131220ysk start | |
| 1154 | - if( isset($_REQUEST['SiteId']) and $usces->options['acting_settings']['anotherlane']['siteid'] == $_REQUEST['SiteId'] and isset($_REQUEST['TransactionId']) ) { | |
| 1155 | - $usces->set_order_meta_value( 'TransactionId', $_REQUEST['TransactionId'], $order_id ); | |
| 1156 | - } | |
| 1157 | -//20131220ysk end | |
| 1158 | -//20140206ysk start | |
| 1159 | - if( isset($_GET['acting']) and 'veritrans_card' == $_GET['acting'] and isset($_POST['orderId']) ) { | |
| 1160 | - $usces->set_order_meta_value( 'orderId', $_POST['orderId'], $order_id ); | |
| 1161 | - $usces->set_order_meta_value( 'acting_'.$_GET['acting'], serialize($_POST), $order_id ); | |
| 1162 | - } elseif( isset($_GET['acting']) and 'veritrans_conv' == $_GET['acting'] and isset($_POST['orderId']) ) { | |
| 1163 | - $usces->set_order_meta_value( 'orderId', $_POST['orderId'], $order_id ); | |
| 1164 | - $data['mStatus'] = mysql_real_escape_string( $_POST['mStatus'] ); | |
| 1165 | - $data['vResultCode'] = mysql_real_escape_string( $_POST['vResultCode'] ); | |
| 1166 | - $data['orderId'] = mysql_real_escape_string( $_POST['orderId'] ); | |
| 1167 | - $usces->set_order_meta_value( 'acting_'.$_GET['acting'], serialize($data), $order_id ); | |
| 1168 | - } | |
| 1169 | -//20140206ysk end | |
| 1170 | - | |
| 1171 | - //$args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member['ID'], 'payments'=>$payments, 'charging_type'=>$charging_type); | |
| 1172 | - $args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member['ID'], 'payments'=>$set, 'charging_type'=>$charging_type);//20131121ysk | |
| 1173 | - do_action('usces_action_reg_orderdata', $args); | |
| 1174 | - | |
| 1175 | - endif; | |
| 1176 | - | |
| 1177 | - return $order_id; | |
| 1178 | - | |
| 1179 | -} | |
| 1180 | - | |
| 1181 | -function usces_new_orderdata() { | |
| 1182 | - global $wpdb, $usces; | |
| 1183 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 1184 | - | |
| 1185 | - $usces->cart->crear_cart(); | |
| 1186 | - $cart = $usces->cart->get_cart(); | |
| 1187 | - $item_total_price = $usces->get_total_price( $cart ); | |
| 1188 | - $entry = $usces->cart->get_entry(); | |
| 1189 | - $member_id = $usces->get_memberid_by_email($_POST['customer']['mailaddress']); | |
| 1190 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 1191 | - $order_table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 1192 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 1193 | - $set = $usces->getPayments( $_POST['offer']['payment_name'] ); | |
| 1194 | - if( isset($_POST['offer']['receipt']) ) { | |
| 1195 | - $status = $_POST['offer']['receipt'].','; | |
| 1196 | - } else { | |
| 1197 | -//20131121ysk start | |
| 1198 | - //$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' : ''; | |
| 1199 | - $noreceipt_status_table = apply_filters( 'usces_filter_noreceipt_status', array( 'transferAdvance', 'transferDeferred', 'acting_remise_conv', 'acting_zeus_bank', 'acting_zeus_conv', 'acting_jpayment_conv', 'acting_jpayment_bank', 'acting_sbps_conv', 'acting_sbps_payeasy', 'acting_digitalcheck_conv', 'acting_mizuho_conv1', 'acting_mizuho_conv2' ) ); | |
| 1200 | - $status = ( in_array( $set['settlement'], $noreceipt_status_table ) ) ? 'noreceipt' : ''; | |
| 1201 | -//20131121ysk end | |
| 1202 | - } | |
| 1203 | - $status .= ( !WCUtils::is_blank($_POST['offer']['taio']) && $_POST['offer']['taio'] != '#none#' ) ? $_POST['offer']['taio'].',' : ''; | |
| 1204 | - $status .= $_POST['offer']['admin']; | |
| 1205 | - $status = apply_filters( 'usces_filter_new_orderdata_status', $status, $entry ); | |
| 1206 | - $order_conditions = $usces->get_condition(); | |
| 1207 | - | |
| 1208 | -//20101208ysk start | |
| 1209 | - $query = $wpdb->prepare( | |
| 1210 | - "INSERT INTO $order_table_name ( | |
| 1211 | - `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`, | |
| 1212 | - `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`, | |
| 1213 | - `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`, | |
| 1214 | - `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`, | |
| 1215 | - `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` ) | |
| 1216 | - 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)", | |
| 1217 | - $member_id, | |
| 1218 | - $_POST['customer']['mailaddress'], | |
| 1219 | - $_POST['customer']['name1'], | |
| 1220 | - $_POST['customer']['name2'], | |
| 1221 | - $_POST['customer']['name3'], | |
| 1222 | - $_POST['customer']['name4'], | |
| 1223 | - $_POST['customer']['zipcode'], | |
| 1224 | - $_POST['customer']['pref'], | |
| 1225 | - $_POST['customer']['address1'], | |
| 1226 | - $_POST['customer']['address2'], | |
| 1227 | - $_POST['customer']['address3'], | |
| 1228 | - $_POST['customer']['tel'], | |
| 1229 | - $_POST['customer']['fax'], | |
| 1230 | - serialize($_POST['delivery']), | |
| 1231 | - serialize($cart), | |
| 1232 | - $_POST['offer']['note'], | |
| 1233 | - $_POST['offer']['delivery_method'], | |
| 1234 | - $_POST['offer']['delivery_date'], | |
| 1235 | - $_POST['offer']['delivery_time'], | |
| 1236 | - $_POST['offer']['payment_name'], | |
| 1237 | - serialize($order_conditions), | |
| 1238 | - $item_total_price, | |
| 1239 | - $_POST['offer']['getpoint'], | |
| 1240 | - $_POST['offer']['usedpoint'], | |
| 1241 | - $_POST['offer']['discount'], | |
| 1242 | - $_POST['offer']['shipping_charge'], | |
| 1243 | - $_POST['offer']['cod_fee'], | |
| 1244 | - $_POST['offer']['tax'], | |
| 1245 | - get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), | |
| 1246 | - null, | |
| 1247 | - $status, | |
| 1248 | - $_POST['offer']['delidue_date'] | |
| 1249 | - ); | |
| 1250 | -//20101208ysk end | |
| 1251 | - | |
| 1252 | - $res = $wpdb->query( $query ); | |
| 1253 | -// $wpdb->print_error(); | |
| 1254 | -// echo $query; | |
| 1255 | -// exit; | |
| 1256 | - $order_id = $wpdb->insert_id; | |
| 1257 | - $_REQUEST['order_id'] = $wpdb->insert_id; | |
| 1258 | - | |
| 1259 | -//20100818ysk start | |
| 1260 | - if( !$order_id ) : | |
| 1261 | - | |
| 1262 | - return false; | |
| 1263 | - | |
| 1264 | - else : | |
| 1265 | - $usces->set_order_meta_value('customer_country', $_POST['customer']['country'], $order_id); | |
| 1266 | - | |
| 1267 | - if( !empty($_POST['custom_order']) ) { | |
| 1268 | - foreach( $_POST['custom_order'] as $key => $value ) { | |
| 1269 | - $csod_key = 'csod_'.$key; | |
| 1270 | - if( is_array($value) ) | |
| 1271 | - $value = serialize($value); | |
| 1272 | - $usces->set_order_meta_value($csod_key, $value, $order_id); | |
| 1273 | - } | |
| 1274 | - } | |
| 1275 | - if( !empty($_POST['custom_customer']) ) { | |
| 1276 | - foreach( $_POST['custom_customer'] as $key => $value ) { | |
| 1277 | - $cscs_key = 'cscs_'.$key; | |
| 1278 | - if( is_array($value) ) | |
| 1279 | - $value = serialize($value); | |
| 1280 | - $usces->set_order_meta_value($cscs_key, $value, $order_id); | |
| 1281 | - } | |
| 1282 | - } | |
| 1283 | - if( !empty($_POST['custom_delivery']) ) { | |
| 1284 | - foreach( $_POST['custom_delivery'] as $key => $value ) { | |
| 1285 | - $csde_key = 'csde_'.$key; | |
| 1286 | - if( is_array($value) ) | |
| 1287 | - $value = serialize($value); | |
| 1288 | - $usces->set_order_meta_value($csde_key, $value, $order_id); | |
| 1289 | - } | |
| 1290 | - } | |
| 1291 | - if ( !preg_match('/pending|noreceipt/', $status) ) { | |
| 1292 | - $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 1293 | - $usces->set_order_meta_value('receipted_date', $value, $order_id); | |
| 1294 | - } | |
| 1295 | -//20120314ysk start 0000435 | |
| 1296 | -//20131121ysk start | |
| 1297 | - //$args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member_id); | |
| 1298 | - $args = array('cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member_id, 'payments'=>$set); | |
| 1299 | -//20131121ysk end | |
| 1300 | - do_action('usces_action_reg_orderdata', $args); | |
| 1301 | -//20120314ysk end | |
| 1302 | - endif; | |
| 1303 | -//20100818ysk end | |
| 1304 | - | |
| 1305 | - $usces->cart->crear_cart(); | |
| 1306 | - return $res; | |
| 1307 | - | |
| 1308 | -} | |
| 1309 | - | |
| 1310 | -function usces_new_memberdata(){ | |
| 1311 | - global $wpdb, $usces; | |
| 1312 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 1313 | - $pass = md5(trim($_POST['member']['password'])); | |
| 1314 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 1315 | - $member_table_meta_name = $wpdb->prefix . "usces_member_meta"; | |
| 1316 | - $query = $wpdb->prepare("INSERT INTO $member_table_name | |
| 1317 | - (`mem_email`, `mem_pass`, `mem_status`, `mem_cookie`, `mem_point`, | |
| 1318 | - `mem_name1`, `mem_name2`, `mem_name3`, `mem_name4`, `mem_zip`, `mem_pref`, | |
| 1319 | - `mem_address1`, `mem_address2`, `mem_address3`, `mem_tel`, `mem_fax`, | |
| 1320 | - `mem_delivery_flag`, `mem_delivery`, `mem_registered`, `mem_nicename`) | |
| 1321 | - VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 1322 | - trim($_POST['member']['email']), | |
| 1323 | - $pass, | |
| 1324 | - trim($_POST['member']['status']), | |
| 1325 | - "", | |
| 1326 | - trim($_POST['member']['point']), | |
| 1327 | - trim($_POST['member']['name1']), | |
| 1328 | - trim($_POST['member']['name2']), | |
| 1329 | - trim($_POST['member']['name3']), | |
| 1330 | - trim($_POST['member']['name4']), | |
| 1331 | - trim($_POST['member']['zipcode']), | |
| 1332 | - trim($_POST['member']['pref']), | |
| 1333 | - trim($_POST['member']['address1']), | |
| 1334 | - trim($_POST['member']['address2']), | |
| 1335 | - trim($_POST['member']['address3']), | |
| 1336 | - trim($_POST['member']['tel']), | |
| 1337 | - trim($_POST['member']['fax']), | |
| 1338 | - '', | |
| 1339 | - '', | |
| 1340 | - get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), | |
| 1341 | - ''); | |
| 1342 | - $res[0] = $wpdb->query( $query ); | |
| 1343 | - | |
| 1344 | - if(false === $res[0]) | |
| 1345 | - return false; | |
| 1346 | - | |
| 1347 | - $member_id = $wpdb->insert_id; | |
| 1348 | - $_REQUEST['member_id'] = $wpdb->insert_id; | |
| 1349 | - if( !$member_id ){ | |
| 1350 | - return false; | |
| 1351 | - }else{ | |
| 1352 | - $usces->set_member_meta_value('customer_country', $_POST['member']['country'], $member_id); | |
| 1353 | - $csmb_meta = usces_has_custom_field_meta( 'member' ); | |
| 1354 | - if( is_array($csmb_meta) ) { | |
| 1355 | - foreach( $csmb_meta as $key => $entry ) { | |
| 1356 | - if( '4' == $entry['means'] ) { | |
| 1357 | - $usces->del_member_meta( 'csmb_'.$key, $member_id); | |
| 1358 | - } | |
| 1359 | - } | |
| 1360 | - } | |
| 1361 | - $i = 1; | |
| 1362 | - if( !empty($_POST['custom_member']) ) { | |
| 1363 | - foreach( $_POST['custom_member'] as $key => $value ) { | |
| 1364 | - $csmb_key = 'csmb_'.$key; | |
| 1365 | - if( is_array($value) ) | |
| 1366 | - $value = serialize($value); | |
| 1367 | - $res[$i] = $usces->set_member_meta_value($csmb_key, $value, $member_id); | |
| 1368 | - if(false === $res[$i]) | |
| 1369 | - return false; | |
| 1370 | - $i++; | |
| 1371 | - } | |
| 1372 | - } | |
| 1373 | - $result = ( 0 < array_sum($res) ) ? 1 : 0; | |
| 1374 | - return $result; | |
| 1375 | - } | |
| 1376 | -} | |
| 1377 | - | |
| 1378 | -function usces_delete_memberdata( $ID = 0 ) { | |
| 1379 | - global $wpdb, $usces; | |
| 1380 | - | |
| 1381 | - if( 0 === $ID ){ | |
| 1382 | - if(!isset($_REQUEST['member_id']) || WCUtils::is_blank($_REQUEST['member_id']) ) | |
| 1383 | - return 0; | |
| 1384 | - $ID = $_REQUEST['member_id']; | |
| 1385 | - } | |
| 1386 | - do_action('usces_action_pre_delete_memberdata', $ID); | |
| 1387 | - | |
| 1388 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 1389 | -//20100818ysk start | |
| 1390 | - $member_table_meta_name = $wpdb->prefix . "usces_member_meta"; | |
| 1391 | -//20100818ysk end | |
| 1392 | - | |
| 1393 | - $query = $wpdb->prepare("DELETE FROM $member_table_name WHERE ID = %d", $ID); | |
| 1394 | - $res = $wpdb->query( $query ); | |
| 1395 | -//20100818ysk start | |
| 1396 | - if($res) { | |
| 1397 | - $query = $wpdb->prepare("DELETE FROM $member_table_meta_name WHERE member_id = %d", $ID); | |
| 1398 | - $wpdb->query( $query ); | |
| 1399 | - } | |
| 1400 | -//20100818ysk end | |
| 1401 | - do_action('usces_action_post_delete_memberdata', $res, $ID); | |
| 1402 | - | |
| 1403 | - return $res; | |
| 1404 | -} | |
| 1405 | - | |
| 1406 | -function usces_update_memberdata() { | |
| 1407 | - global $wpdb, $usces; | |
| 1408 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 1409 | - | |
| 1410 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 1411 | -//20100818ysk start | |
| 1412 | - $member_table_meta_name = $wpdb->prefix . "usces_member_meta"; | |
| 1413 | -//20100818ysk end | |
| 1414 | - | |
| 1415 | - $ID = (int)$_REQUEST['member_id']; | |
| 1416 | - $name3 = ( isset( $_POST['member']['name3'] ) ) ? $_POST['member']['name3'] : ''; | |
| 1417 | - $name4 = ( isset( $_POST['member']['name4'] ) ) ? $_POST['member']['name4'] : ''; | |
| 1418 | - | |
| 1419 | -//$wpdb->show_errors(); | |
| 1420 | - $query = $wpdb->prepare( | |
| 1421 | - "UPDATE $member_table_name SET | |
| 1422 | - `mem_email`=%s, `mem_status`=%s, `mem_point`=%d, `mem_name1`=%s, `mem_name2`=%s, | |
| 1423 | - `mem_name3`=%s, `mem_name4`=%s, `mem_zip`=%s, `mem_pref`=%s, `mem_address1`=%s, | |
| 1424 | - `mem_address2`=%s, `mem_address3`=%s, `mem_tel`=%s, `mem_fax`=%s | |
| 1425 | - WHERE ID = %d", | |
| 1426 | - $_POST['member']['email'], | |
| 1427 | - $_POST['member']['status'], | |
| 1428 | - $_POST['member']['point'], | |
| 1429 | - $_POST['member']['name1'], | |
| 1430 | - $_POST['member']['name2'], | |
| 1431 | - $name3, | |
| 1432 | - $name4, | |
| 1433 | - $_POST['member']['zipcode'], | |
| 1434 | - $_POST['member']['pref'], | |
| 1435 | - $_POST['member']['address1'], | |
| 1436 | - $_POST['member']['address2'], | |
| 1437 | - $_POST['member']['address3'], | |
| 1438 | - $_POST['member']['tel'], | |
| 1439 | - $_POST['member']['fax'], | |
| 1440 | - $ID | |
| 1441 | - ); | |
| 1442 | - | |
| 1443 | - do_action('usces_action_pre_update_memberdata', $ID); | |
| 1444 | -//20100818ysk start | |
| 1445 | - //$res = $wpdb->query( $query ); | |
| 1446 | - $res[0] = $wpdb->query( $query ); | |
| 1447 | - | |
| 1448 | - do_action( 'usces_action_post_update_memberdata', $ID, $res[0]); | |
| 1449 | - | |
| 1450 | - if(false === $res[0]) | |
| 1451 | - return false; | |
| 1452 | - | |
| 1453 | - $usces->set_member_meta_value('customer_country', $_POST['member']['country'], $ID); | |
| 1454 | -//20130524ysk start 0000712 | |
| 1455 | - $csmb_meta = usces_has_custom_field_meta( 'member' ); | |
| 1456 | - if( is_array($csmb_meta) ) { | |
| 1457 | - foreach( $csmb_meta as $key => $entry ) { | |
| 1458 | - if( '4' == $entry['means'] ) { | |
| 1459 | - $usces->del_member_meta( 'csmb_'.$key, $ID ); | |
| 1460 | - } | |
| 1461 | - } | |
| 1462 | - } | |
| 1463 | -//20130524ysk end | |
| 1464 | - $i = 1; | |
| 1465 | - if( !empty($_POST['custom_member']) ) { | |
| 1466 | - foreach( $_POST['custom_member'] as $key => $value ) { | |
| 1467 | - $csmb_key = 'csmb_'.$key; | |
| 1468 | - if( is_array($value) ) | |
| 1469 | - $value = serialize($value); | |
| 1470 | - $res[$i] = $usces->set_member_meta_value($csmb_key, $value, $ID); | |
| 1471 | - if(false === $res[$i]) | |
| 1472 | - return false; | |
| 1473 | - $i++; | |
| 1474 | - } | |
| 1475 | - } | |
| 1476 | - | |
| 1477 | - | |
| 1478 | - $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" ); | |
| 1479 | - $query = $wpdb->prepare("DELETE FROM $member_table_meta_name WHERE member_id = %d AND meta_key IN( $meta_keys )", | |
| 1480 | - $_POST['member_id'] | |
| 1481 | - ); | |
| 1482 | - $res[$i] = $wpdb->query( $query ); | |
| 1483 | - | |
| 1484 | - $result = ( 0 < array_sum($res) ) ? 1 : 0; | |
| 1485 | - //return $res; | |
| 1486 | - return $result; | |
| 1487 | -//20100818ysk end | |
| 1488 | -} | |
| 1489 | - | |
| 1490 | -function usces_delete_orderdata() { | |
| 1491 | - global $wpdb, $usces; | |
| 1492 | - if(!isset($_REQUEST['order_id']) || WCUtils::is_blank($_REQUEST['order_id']) ) return 0; | |
| 1493 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 1494 | - $order_meta_table = $wpdb->prefix . "usces_order_meta"; | |
| 1495 | - $order_meta_table = $wpdb->prefix . "usces_order_meta"; | |
| 1496 | - $order_meta_table = $wpdb->prefix . "usces_order_meta"; | |
| 1497 | - $ID = $_REQUEST['order_id']; | |
| 1498 | - | |
| 1499 | - $del = usces_delete_order_check( $ID ); | |
| 1500 | - if( $del ) { | |
| 1501 | - | |
| 1502 | - $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $ID); | |
| 1503 | - $order_data = $wpdb->get_row( $query, OBJECT ); | |
| 1504 | - $point = 0; | |
| 1505 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] && !empty($order_data->mem_id) && !$usces->is_status('cancel', $order_data->order_status) ) { | |
| 1506 | - if( 0 < $order_data->order_getpoint ) { | |
| 1507 | - if( usces_is_complete_settlement( $order_data->order_payment_name, $order_data->order_status ) || $usces->is_status('receipted', $order_data->order_status) ) { | |
| 1508 | - //$restore_point = true; | |
| 1509 | - $point += $order_data->order_getpoint; | |
| 1510 | - } | |
| 1511 | - } | |
| 1512 | - if( 0 < $order_data->order_usedpoint ) { | |
| 1513 | - $point -= $order_data->order_usedpoint; | |
| 1514 | - } | |
| 1515 | - } | |
| 1516 | - | |
| 1517 | - $query = $wpdb->prepare("DELETE FROM $order_table WHERE ID = %d", $ID); | |
| 1518 | - $res = $wpdb->query( $query ); | |
| 1519 | - | |
| 1520 | - $args = compact( 'ID', 'point', 'res' ); | |
| 1521 | - | |
| 1522 | - if($res){ | |
| 1523 | - | |
| 1524 | - do_action('usces_action_del_orderdata', $order_data, $args); | |
| 1525 | - | |
| 1526 | - $query = $wpdb->prepare("DELETE FROM $order_meta_table WHERE order_id = %d", $ID); | |
| 1527 | - $wpdb->query( $query ); | |
| 1528 | - | |
| 1529 | - usces_delete_ordercartdata( NULL, $ID ); | |
| 1530 | - | |
| 1531 | - if( 0 != $point ) usces_restore_point( $order_data->mem_id, $point ); | |
| 1532 | - } | |
| 1533 | - | |
| 1534 | - } else { | |
| 1535 | - $res = true; | |
| 1536 | - } | |
| 1537 | - | |
| 1538 | - return $res; | |
| 1539 | -} | |
| 1540 | - | |
| 1541 | -function usces_update_serialized_cart(){ | |
| 1542 | - global $wpdb, $usces; | |
| 1543 | - if(!isset($_REQUEST['order_id']) || WCUtils::is_blank($_REQUEST['order_id']) ) return 0; | |
| 1544 | - | |
| 1545 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 1546 | - $ID = $_REQUEST['order_id']; | |
| 1547 | - $usces->cart->crear_cart(); | |
| 1548 | - $usces->cart->upCart(); | |
| 1549 | - $cart = $usces->cart->get_cart(); | |
| 1550 | - $idx = count($cart)-1; | |
| 1551 | - $post_id = $cart[$idx]['post_id']; | |
| 1552 | - $sku = $cart[$idx]['sku']; | |
| 1553 | - $sku_code = esc_attr(urldecode($sku)); | |
| 1554 | - $cartItemName = $usces->getCartItemName($post_id, $sku_code); | |
| 1555 | - $skuPrice = $cart[$idx]['price']; | |
| 1556 | - | |
| 1557 | - $query = $wpdb->prepare("UPDATE $order_table_name SET `order_cart`=%s WHERE ID = %d", serialize($cart), $ID); | |
| 1558 | - $res = $wpdb->query( $query ); | |
| 1559 | - | |
| 1560 | - $usces->cart->crear_cart(); | |
| 1561 | -} | |
| 1562 | - | |
| 1563 | -function usces_delete_serialized_cart(){ | |
| 1564 | - global $wpdb, $usces; | |
| 1565 | - if(!isset($_REQUEST['order_id']) || WCUtils::is_blank($_REQUEST['order_id']) ) return 0; | |
| 1566 | - | |
| 1567 | - $indexs = array_keys($_POST['delButton']); | |
| 1568 | - $index = $indexs[0]; | |
| 1569 | - $ids = array_keys($_POST['delButton'][$index]); | |
| 1570 | - $post_id = $ids[0]; | |
| 1571 | - $skus = array_keys($_POST['delButton'][$index][$post_id]); | |
| 1572 | - $sku = $skus[0]; | |
| 1573 | - | |
| 1574 | - $usces->up_serialize($index, $post_id, $sku); | |
| 1575 | - do_action('usces_cart_del_row', $index); | |
| 1576 | - | |
| 1577 | - if(isset($_SESSION['usces_cart'][$usces->serial])) | |
| 1578 | - unset($_SESSION['usces_cart'][$usces->serial]); | |
| 1579 | - | |
| 1580 | - unset( $_SESSION['usces_entry']['order']['usedpoint'] ); | |
| 1581 | -} | |
| 1582 | - | |
| 1583 | -function usces_get_serialized_cart($order_id){ | |
| 1584 | - global $wpdb, $usces; | |
| 1585 | - | |
| 1586 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 1587 | - $query = $wpdb->prepare("SELECT order_cart FROM $order_table_name WHERE ID = %d", $order_id); | |
| 1588 | - $order_cart = $wpdb->get_var( $query ); | |
| 1589 | - $cart = unserialize($order_cart); | |
| 1590 | - foreach( $cart as $cart_index => $cart_row ){ | |
| 1591 | - $options = array(); | |
| 1592 | - if( !empty( $cart_row['options'] ) ){ | |
| 1593 | - foreach( $cart_row['options'] as $key => $value ){ | |
| 1594 | - $key = urldecode($key); | |
| 1595 | - if( is_array($value) ){ | |
| 1596 | - foreach( $value as $vk => $vv ){ | |
| 1597 | - $value[$vk] = urldecode($vv); | |
| 1598 | - } | |
| 1599 | - $options[$key] = $value; | |
| 1600 | - }else{ | |
| 1601 | - $options[$key] = urldecode($value); | |
| 1602 | - } | |
| 1603 | - } | |
| 1604 | - $cart_row['options'] = $options; | |
| 1605 | - } | |
| 1606 | - /*$advance = array(); | |
| 1607 | - if( !empty( $cart_row['advance'] ) ){ | |
| 1608 | - foreach( $cart_row['advance'] as $key => $value ){ | |
| 1609 | - $key = urldecode($key); | |
| 1610 | - if( is_array($value) ){ | |
| 1611 | - foreach( $value as $vk => $vv ){ | |
| 1612 | - $value[$vk] = urldecode($vv); | |
| 1613 | - } | |
| 1614 | - $advance[$key] = $value; | |
| 1615 | - }else{ | |
| 1616 | - $advance[$key] = urldecode($value); | |
| 1617 | - } | |
| 1618 | - } | |
| 1619 | - $cart_row['advance'] = $advance; | |
| 1620 | - }*/ | |
| 1621 | - $cart[$cart_index] = $cart_row; | |
| 1622 | - } | |
| 1623 | - return $cart; | |
| 1624 | -} | |
| 1625 | - | |
| 1626 | -function usces_update_ordercart() { | |
| 1627 | - $ordercart_table_name = $wpdb->prefix . "usces_ordercart"; | |
| 1628 | - foreach( $_POST['skuPrice'] as $cart_id => $price ){ | |
| 1629 | - $quantity = $_POST['quant'][$cart_id]; | |
| 1630 | - $query = $wpdb->prepare(" | |
| 1631 | - UPDATE $ordercart_table_name SET price = %f, quantity = %d WHERE cart_id = %d | |
| 1632 | - ", $price, $quantity, $cart_id ); | |
| 1633 | - $wpdb->query( $query ); | |
| 1634 | - } | |
| 1635 | - | |
| 1636 | - $ordercart_meta_table_name = $wpdb->prefix . "usces_ordercart_meta"; | |
| 1637 | - foreach( $_POST['itemOption'] as $cartmeta_id => $value ){ | |
| 1638 | - if(is_array($value)) { | |
| 1639 | - foreach($value as $v){ | |
| 1640 | - $opval[$v] = $v; | |
| 1641 | - } | |
| 1642 | - $value = serialize($opval); | |
| 1643 | - } | |
| 1644 | - $query = $wpdb->prepare(" | |
| 1645 | - UPDATE $ordercart_meta_table_name SET meta_value = %s WHERE cartmeta_id = %d | |
| 1646 | - ", $value, $cartmeta_id ); | |
| 1647 | - $wpdb->query( $query ); | |
| 1648 | - } | |
| 1649 | - if( $res === false ) { | |
| 1650 | - $res = "-1#usces#"; | |
| 1651 | - } else { | |
| 1652 | - $res = $skuPrice."#usces#".$cartItemName; | |
| 1653 | - } | |
| 1654 | - //return $res; | |
| 1655 | -} | |
| 1656 | - | |
| 1657 | -function usces_update_ordercartdata( $order_id ) { | |
| 1658 | - global $wpdb, $usces; | |
| 1659 | - | |
| 1660 | - if( !isset($_POST['skuPrice']) ) | |
| 1661 | - return; | |
| 1662 | - | |
| 1663 | - $ordercart_table_name = $wpdb->prefix . "usces_ordercart"; | |
| 1664 | - foreach( (array)$_POST['skuPrice'] as $cart_id => $price ){ | |
| 1665 | - $quantity = $_POST['quant'][$cart_id]; | |
| 1666 | - $query = $wpdb->prepare(" | |
| 1667 | - UPDATE $ordercart_table_name SET price = %f, quantity = %d WHERE cart_id = %d | |
| 1668 | - ", $price, $quantity, $cart_id ); | |
| 1669 | - $wpdb->query( $query ); | |
| 1670 | - } | |
| 1671 | - | |
| 1672 | - if( !isset($_POST['itemOption']) ) | |
| 1673 | - return; | |
| 1674 | - | |
| 1675 | - $ordercart_meta_table_name = $wpdb->prefix . "usces_ordercart_meta"; | |
| 1676 | - foreach( (array)$_POST['itemOption'] as $cartmeta_id => $value ){ | |
| 1677 | - if(is_array($value)) { | |
| 1678 | - $opval =array(); | |
| 1679 | - foreach($value as $v){ | |
| 1680 | - $opval[$v] = urldecode($v); | |
| 1681 | - } | |
| 1682 | - $value = serialize($opval); | |
| 1683 | - } | |
| 1684 | - $query = $wpdb->prepare(" | |
| 1685 | - UPDATE $ordercart_meta_table_name SET meta_value = %s WHERE cartmeta_id = %d | |
| 1686 | - ", $value, $cartmeta_id ); | |
| 1687 | - $wpdb->query( $query ); | |
| 1688 | - } | |
| 1689 | -} | |
| 1690 | - | |
| 1691 | -function usces_delete_ordercartdata( $cart_id, $order_id = NULL ){ | |
| 1692 | - global $wpdb, $usces; | |
| 1693 | - | |
| 1694 | -// if( NULL == $cart_id && NULL == $order_id ) | |
| 1695 | -// return; | |
| 1696 | - | |
| 1697 | - $ordercart_table_name = $wpdb->prefix . "usces_ordercart"; | |
| 1698 | - $ordercart_meta_table_name = $wpdb->prefix . "usces_ordercart_meta"; | |
| 1699 | - | |
| 1700 | - if( NULL != $cart_id ){ | |
| 1701 | - | |
| 1702 | - $query = $wpdb->prepare("DELETE FROM $ordercart_table_name WHERE cart_id = %d", $cart_id ); | |
| 1703 | - $wpdb->query( $query ); | |
| 1704 | - | |
| 1705 | - $mquery = $wpdb->prepare(" | |
| 1706 | - DELETE FROM $ordercart_meta_table_name WHERE cart_id = %d", $cart_id ); | |
| 1707 | - $wpdb->query( $mquery ); | |
| 1708 | - | |
| 1709 | - }elseif( NULL != $order_id ){ | |
| 1710 | - | |
| 1711 | - $query = $wpdb->prepare("SELECT cart_id FROM $ordercart_table_name WHERE order_id = %d", $order_id ); | |
| 1712 | - $cat_ids = $wpdb->get_col( $query ); | |
| 1713 | - | |
| 1714 | - $query = $wpdb->prepare("DELETE FROM $ordercart_table_name WHERE order_id = %d", $order_id ); | |
| 1715 | - $wpdb->query( $query ); | |
| 1716 | - | |
| 1717 | - foreach($cat_ids as $id){ | |
| 1718 | - $mquery = $wpdb->prepare(" | |
| 1719 | - DELETE FROM $ordercart_meta_table_name WHERE cart_id = %d", $id ); | |
| 1720 | - $wpdb->query( $mquery ); | |
| 1721 | - } | |
| 1722 | - | |
| 1723 | - } | |
| 1724 | -} | |
| 1725 | - | |
| 1726 | -function usces_get_ordercartdata( $order_id ){ | |
| 1727 | - global $usces, $wpdb; | |
| 1728 | - | |
| 1729 | - $cart_table = $wpdb->prefix . "usces_ordercart"; | |
| 1730 | - $cart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; | |
| 1731 | - | |
| 1732 | - $query = $wpdb->prepare("SELECT * FROM $cart_table WHERE order_id = %d ORDER BY cart_id", $order_id ); | |
| 1733 | - $cart = $wpdb->get_results( $query, ARRAY_A ); | |
| 1734 | - | |
| 1735 | - foreach( $cart as $key => $value ){ | |
| 1736 | - $cart[$key]['sku'] = $value['sku_code']; | |
| 1737 | - $query = $wpdb->prepare("SELECT * FROM $cart_meta_table WHERE cart_id = %d", $value['cart_id'] ); | |
| 1738 | - $results = $wpdb->get_results( $query, ARRAY_A ); | |
| 1739 | - foreach((array)$results as $value ){ | |
| 1740 | - switch( $value['meta_type'] ){ | |
| 1741 | - case 'option': | |
| 1742 | - $cart[$key]['options'][$value['meta_key']] = $value['meta_value']; | |
| 1743 | - break; | |
| 1744 | - case 'advance': | |
| 1745 | - $cart[$key]['advance'][$value['meta_key']] = $value['meta_value']; | |
| 1746 | - break; | |
| 1747 | - } | |
| 1748 | - } | |
| 1749 | - if( !isset($cart[$key]['options']) ) | |
| 1750 | - $cart[$key]['options'] = array(); | |
| 1751 | - if( !isset($cart[$key]['advance']) ) | |
| 1752 | - $cart[$key]['advance'] = array(); | |
| 1753 | - } | |
| 1754 | - | |
| 1755 | - return $cart; | |
| 1756 | -} | |
| 1757 | - | |
| 1758 | - | |
| 1759 | -function usces_update_ordercheck() { | |
| 1760 | - global $wpdb, $usces; | |
| 1761 | - | |
| 1762 | - $tableName = $wpdb->prefix . "usces_order"; | |
| 1763 | - $order_id = $_POST['order_id']; | |
| 1764 | - $checked = $_POST['checked']; | |
| 1765 | - | |
| 1766 | - $query = $wpdb->prepare("SELECT `order_check` FROM $tableName WHERE ID = %d", $order_id); | |
| 1767 | - $res = $wpdb->get_var( $query ); | |
| 1768 | - | |
| 1769 | - $checkfield = unserialize($res); | |
| 1770 | - if( !isset($checkfield[$checked]) ) $checkfield[$checked] = $checked; | |
| 1771 | - //$checkfield = 'OK'; | |
| 1772 | - $query = $wpdb->prepare("UPDATE $tableName SET `order_check` = %s WHERE ID = %d", serialize($checkfield), $order_id); | |
| 1773 | - $res = $wpdb->query( $query ); | |
| 1774 | - | |
| 1775 | - if($res) | |
| 1776 | - return $checked; | |
| 1777 | - else | |
| 1778 | - return 'error'; | |
| 1779 | -} | |
| 1780 | -function usces_update_orderdata() { | |
| 1781 | - global $wpdb, $usces; | |
| 1782 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 1783 | - | |
| 1784 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 1785 | - $order_table_meta_name = $wpdb->prefix . "usces_order_meta"; | |
| 1786 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 1787 | - | |
| 1788 | - $ID = $_REQUEST['order_id']; | |
| 1789 | - | |
| 1790 | - $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID); | |
| 1791 | - $old_orderdata = $wpdb->get_row( $query ); | |
| 1792 | - $old_status = $old_orderdata->order_status; | |
| 1793 | - | |
| 1794 | - if(isset($_POST['delButtonAdmin'])) { | |
| 1795 | - foreach( $_POST['delButtonAdmin'] as $del_cart_id => $delvalue ){ | |
| 1796 | - usces_delete_ordercartdata( $del_cart_id, NULL ); | |
| 1797 | - do_action('usces_admin_delete_orderrow', $del_cart_id, $ID ); | |
| 1798 | - } | |
| 1799 | - }else{ | |
| 1800 | - usces_update_ordercartdata( $ID ); | |
| 1801 | - } | |
| 1802 | - $cart = usces_get_ordercartdata( $ID ); | |
| 1803 | - $usces->cart->entry(); | |
| 1804 | - $entry = $usces->cart->get_entry(); | |
| 1805 | - | |
| 1806 | - $item_total_price = $usces->get_total_price( $cart ); | |
| 1807 | -// $item_total_price = $usces->get_total_price_ordercart( $cart ); | |
| 1808 | - //$set = $usces->getPayments( $entry['order']['payment_name'] ); | |
| 1809 | - $taio = isset($entry['order']['taio']) ? $entry['order']['taio'] : ''; | |
| 1810 | - $receipt = isset($entry['order']['receipt']) ? $entry['order']['receipt'] : ''; | |
| 1811 | - $admin = isset($entry['order']['admin']) ? $entry['order']['admin'] : ''; | |
| 1812 | - $status = $usces->make_status( $taio, $receipt, $admin ); | |
| 1813 | - if( $taio == 'completion' || $taio == 'continuation' ){ | |
| 1814 | - if( 'update' == $_POST['up_modified'] ){ | |
| 1815 | - $order_modified = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 1816 | - }else{ | |
| 1817 | - $order_modified = $_POST['modified']; | |
| 1818 | - } | |
| 1819 | - }else{ | |
| 1820 | - $order_modified = ''; | |
| 1821 | - } | |
| 1822 | - $ordercheck = isset($_POST['check']) ? serialize($_POST['check']) : ''; | |
| 1823 | - $member_id = isset($_POST['member_id']) ? $_POST['member_id'] : 0; | |
| 1824 | - //$member_id = $usces->get_memberid_by_email($_POST['customer']['mailaddress']); | |
| 1825 | - | |
| 1826 | - if( 'cancel' == $taio ){ | |
| 1827 | - $query = $wpdb->prepare( | |
| 1828 | - "UPDATE $order_table_name SET `order_modified` = %s, `order_status` = %s WHERE ID = %d", | |
| 1829 | - $order_modified, $status, $ID | |
| 1830 | - ); | |
| 1831 | - $res[0] = $wpdb->query( $query ); | |
| 1832 | - | |
| 1833 | - $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID); | |
| 1834 | - $new_orderdata = $wpdb->get_row( $query ); | |
| 1835 | - | |
| 1836 | -//20131101ysk start 0000751 | |
| 1837 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] && !empty($member_id) && !$usces->is_status('cancel', $old_status) ) { | |
| 1838 | - $point = 0; | |
| 1839 | - if( 0 < $old_orderdata->order_getpoint ) { | |
| 1840 | - if( usces_is_complete_settlement( $old_orderdata->order_payment_name, $old_orderdata->order_status ) || $usces->is_status('receipted', $old_orderdata->order_status) ) { | |
| 1841 | - $point += $old_orderdata->order_getpoint; | |
| 1842 | - } | |
| 1843 | - } | |
| 1844 | - if( 0 < $old_orderdata->order_usedpoint ) { | |
| 1845 | - $point -= $old_orderdata->order_usedpoint; | |
| 1846 | - } | |
| 1847 | - if( 0 != $point ) usces_restore_point( $member_id, $point ); | |
| 1848 | - } | |
| 1849 | -//20131101ysk end | |
| 1850 | - | |
| 1851 | - do_action('usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata); | |
| 1852 | -// $usces->cart->crear_cart(); | |
| 1853 | - | |
| 1854 | - return 1; | |
| 1855 | - } | |
| 1856 | - | |
| 1857 | - $old_deli = unserialize($old_orderdata->order_delivery); | |
| 1858 | - foreach($_POST['delivery'] as $dk => $dv ){ | |
| 1859 | - $old_deli[$dk] = $dv; | |
| 1860 | - } | |
| 1861 | - $delivery = serialize($old_deli); | |
| 1862 | - | |
| 1863 | -//$wpdb->show_errors(); | |
| 1864 | -//20101208ysk start | |
| 1865 | - $query = $wpdb->prepare( | |
| 1866 | - "UPDATE $order_table_name SET | |
| 1867 | - `mem_id`=%d, `order_email`=%s, `order_name1`=%s, `order_name2`=%s, `order_name3`=%s, `order_name4`=%s, | |
| 1868 | - `order_zip`=%s, `order_pref`=%s, `order_address1`=%s, `order_address2`=%s, `order_address3`=%s, | |
| 1869 | - `order_tel`=%s, `order_fax`=%s, `order_delivery`=%s, `order_note`=%s, | |
| 1870 | - `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, | |
| 1871 | - `order_discount`=%f, `order_shipping_charge`=%f, `order_cod_fee`=%f, `order_tax`=%f, `order_modified`=%s, | |
| 1872 | - `order_status`=%s, `order_delidue_date`=%s, `order_check`=%s | |
| 1873 | - WHERE ID = %d", | |
| 1874 | - $member_id, | |
| 1875 | - $_POST['customer']['mailaddress'], | |
| 1876 | - $_POST['customer']['name1'], | |
| 1877 | - $_POST['customer']['name2'], | |
| 1878 | - $_POST['customer']['name3'], | |
| 1879 | - $_POST['customer']['name4'], | |
| 1880 | - $_POST['customer']['zipcode'], | |
| 1881 | - $_POST['customer']['pref'], | |
| 1882 | - $_POST['customer']['address1'], | |
| 1883 | - $_POST['customer']['address2'], | |
| 1884 | - $_POST['customer']['address3'], | |
| 1885 | - $_POST['customer']['tel'], | |
| 1886 | - $_POST['customer']['fax'], | |
| 1887 | - $delivery, | |
| 1888 | - $_POST['offer']['note'], | |
| 1889 | - $_POST['offer']['delivery_method'], | |
| 1890 | - $_POST['offer']['delivery_date'], | |
| 1891 | - $_POST['offer']['delivery_time'], | |
| 1892 | - $_POST['offer']['payment_name'], | |
| 1893 | - $item_total_price, | |
| 1894 | - $_POST['offer']['getpoint'], | |
| 1895 | - $_POST['offer']['usedpoint'], | |
| 1896 | - $_POST['offer']['discount'], | |
| 1897 | - $_POST['offer']['shipping_charge'], | |
| 1898 | - $_POST['offer']['cod_fee'], | |
| 1899 | - $_POST['offer']['tax'], | |
| 1900 | - $order_modified, | |
| 1901 | - $status, | |
| 1902 | - $_POST['offer']['delidue_date'], | |
| 1903 | - $ordercheck, | |
| 1904 | - $ID | |
| 1905 | - ); | |
| 1906 | -//20101208ysk end | |
| 1907 | - | |
| 1908 | -//20100818ysk start | |
| 1909 | - //$res = $wpdb->query( $query ); | |
| 1910 | - $res[0] = $wpdb->query( $query ); | |
| 1911 | - if(false === $res[0]) | |
| 1912 | - return false; | |
| 1913 | - | |
| 1914 | - $usces->set_order_meta_value('customer_country', $_POST['customer']['country'], $ID); | |
| 1915 | -//20130524ysk start 0000712 | |
| 1916 | - $csod_meta = usces_has_custom_field_meta( 'order' ); | |
| 1917 | - if( is_array($csod_meta) ) { | |
| 1918 | - foreach( $csod_meta as $key => $entry ) { | |
| 1919 | - if( '4' == $entry['means'] ) { | |
| 1920 | - $usces->del_order_meta( 'csod_'.$key, $ID ); | |
| 1921 | - } | |
| 1922 | - } | |
| 1923 | - } | |
| 1924 | - $cscs_meta = usces_has_custom_field_meta( 'customer' ); | |
| 1925 | - if( is_array($cscs_meta) ) { | |
| 1926 | - foreach( $cscs_meta as $key => $entry ) { | |
| 1927 | - if( '4' == $entry['means'] ) { | |
| 1928 | - $usces->del_order_meta( 'cscs_'.$key, $ID ); | |
| 1929 | - } | |
| 1930 | - } | |
| 1931 | - } | |
| 1932 | - $csde_meta = usces_has_custom_field_meta( 'delivery' ); | |
| 1933 | - if( is_array($csde_meta) ) { | |
| 1934 | - foreach( $csde_meta as $key => $entry ) { | |
| 1935 | - if( '4' == $entry['means'] ) { | |
| 1936 | - $usces->del_order_meta( 'csde_'.$key, $ID ); | |
| 1937 | - } | |
| 1938 | - } | |
| 1939 | - } | |
| 1940 | -//20130524ysk end | |
| 1941 | - $i = 1; | |
| 1942 | - if( !empty($_POST['custom_order']) ) { | |
| 1943 | - foreach( $_POST['custom_order'] as $key => $value ) { | |
| 1944 | - $csod_key = 'csod_'.$key; | |
| 1945 | - if( is_array($value) ) | |
| 1946 | - $value = serialize($value); | |
| 1947 | - $res[$i] = $usces->set_order_meta_value($csod_key, $value, $ID); | |
| 1948 | - if(false === $res[$i]) | |
| 1949 | - return false; | |
| 1950 | - $i++; | |
| 1951 | - } | |
| 1952 | - } | |
| 1953 | - if( !empty($_POST['custom_customer']) ) { | |
| 1954 | - foreach( $_POST['custom_customer'] as $key => $value ) { | |
| 1955 | - $cscs_key = 'cscs_'.$key; | |
| 1956 | - if( is_array($value) ) | |
| 1957 | - $value = serialize($value); | |
| 1958 | - $res[$i] = $usces->set_order_meta_value($cscs_key, $value, $ID); | |
| 1959 | - if(false === $res[$i]) | |
| 1960 | - return false; | |
| 1961 | - $i++; | |
| 1962 | - } | |
| 1963 | - } | |
| 1964 | - if( !empty($_POST['custom_delivery']) ) { | |
| 1965 | - foreach( $_POST['custom_delivery'] as $key => $value ) { | |
| 1966 | - $csde_key = 'csde_'.$key; | |
| 1967 | - if( is_array($value) ) | |
| 1968 | - $value = serialize($value); | |
| 1969 | - $res[$i] = $usces->set_order_meta_value($csde_key, $value, $ID); | |
| 1970 | - if(false === $res[$i]) | |
| 1971 | - return false; | |
| 1972 | - $i++; | |
| 1973 | - } | |
| 1974 | - } | |
| 1975 | - $value = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 1976 | - if ( !preg_match('/pending|noreceipt/', $old_status) && preg_match('/pending|noreceipt/', $status) ) { | |
| 1977 | - $rquery = $wpdb->prepare("DELETE FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date'); | |
| 1978 | - $wpdb->query( $rquery ); | |
| 1979 | - }else if ( !preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) { | |
| 1980 | - $query = $wpdb->prepare("SELECT order_id FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date'); | |
| 1981 | - $varres = $wpdb->get_var( $query ); | |
| 1982 | - if( empty($varres) ){ | |
| 1983 | - $usces->set_order_meta_value('receipted_date', $value, $ID); | |
| 1984 | - } | |
| 1985 | - }else if ( preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) { | |
| 1986 | - $usces->set_order_meta_value('receipted_date', $value, $ID); | |
| 1987 | - } | |
| 1988 | - | |
| 1989 | -//20131101ysk start 0000751 | |
| 1990 | - //if( !usces_is_complete_settlement( $_POST['offer']['payment_name'] ) ) { | |
| 1991 | - // if( !preg_match('/pending|noreceipt/', $old_status) && preg_match('/pending|noreceipt/', $status) ) {//入金→未入金 | |
| 1992 | - // usces_action_acting_getpoint( $ID, false );//ポイント取消 | |
| 1993 | - // } else if( preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) {//未入金→入金 | |
| 1994 | - // usces_action_acting_getpoint( $ID );//ポイント追加 | |
| 1995 | - // } | |
| 1996 | - //} | |
| 1997 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] && !empty($member_id) ) { | |
| 1998 | - $point = 0; | |
| 1999 | - $getpoint = $_POST['offer']['getpoint']; | |
| 2000 | - $usedpoint = $_POST['offer']['usedpoint']; | |
| 2001 | - if( $usces->is_status('cancel', $old_status) && !$usces->is_status('cancel', $status) ) {//キャンセル→新規受付・取り寄せ中・発送済み | |
| 2002 | - if( 0 < $getpoint ) { | |
| 2003 | - if( usces_is_complete_settlement( $_POST['offer']['payment_name'], $status ) || $usces->is_status('receipted', $status) ) { | |
| 2004 | - $point -= $getpoint; | |
| 2005 | - } | |
| 2006 | - } | |
| 2007 | - if( 0 < $usedpoint ) { | |
| 2008 | - $point += $usedpoint; | |
| 2009 | - } | |
| 2010 | - } else { | |
| 2011 | - if( !usces_is_complete_settlement( $_POST['offer']['payment_name'] ) ) { | |
| 2012 | - if( !preg_match('/pending|noreceipt/', $old_status) && preg_match('/pending|noreceipt/', $status) ) {//入金→未入金 | |
| 2013 | - $point += $getpoint;//ポイント取消 | |
| 2014 | - } else if( preg_match('/pending|noreceipt/', $old_status) && !preg_match('/pending|noreceipt/', $status) ) {//未入金→入金 | |
| 2015 | - $point -= $getpoint;//ポイント追加 | |
| 2016 | - } else { | |
| 2017 | - if( $old_orderdata->order_getpoint != $getpoint ) { | |
| 2018 | - $point += $old_orderdata->order_getpoint - $getpoint; | |
| 2019 | - } | |
| 2020 | - } | |
| 2021 | - } else { | |
| 2022 | - if( $old_orderdata->order_getpoint != $getpoint ) { | |
| 2023 | - $point += $old_orderdata->order_getpoint - $getpoint; | |
| 2024 | - } | |
| 2025 | - } | |
| 2026 | - if( $old_orderdata->order_usedpoint != $usedpoint ) { | |
| 2027 | - $point -= $old_orderdata->order_usedpoint - $usedpoint; | |
| 2028 | - } | |
| 2029 | - } | |
| 2030 | - if( 0 != $point ) usces_restore_point( $member_id, $point ); | |
| 2031 | - } | |
| 2032 | -//20131101ysk end | |
| 2033 | - | |
| 2034 | - $result = ( 0 < array_sum($res) ) ? 1 : 0; | |
| 2035 | -//20100818ysk end | |
| 2036 | - | |
| 2037 | - $query = $wpdb->prepare("SELECT * FROM $order_table_name WHERE ID = %d", $ID); | |
| 2038 | - $new_orderdata = $wpdb->get_row( $query ); | |
| 2039 | -//20120612ysk start 0000501 | |
| 2040 | - //do_action('usces_action_update_orderdata', $new_orderdata); | |
| 2041 | - do_action('usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata); | |
| 2042 | -//20120612ysk end | |
| 2043 | - $usces->cart->crear_cart(); | |
| 2044 | - | |
| 2045 | - return $result; | |
| 2046 | -} | |
| 2047 | - | |
| 2048 | - | |
| 2049 | - | |
| 2050 | -function usces_export_xml() { | |
| 2051 | - $options = get_option('usces'); | |
| 2052 | - echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . ">\n"; | |
| 2053 | -?> | |
| 2054 | - <usces><?php echo serialize($options); ?></usces> | |
| 2055 | - <usces_management_status><?php echo serialize(get_option('usces_management_status')); ?></usces_management_status> | |
| 2056 | - <usces_zaiko_status><?php echo serialize(get_option('usces_zaiko_status')); ?></usces_zaiko_status> | |
| 2057 | - <usces_customer_status><?php echo serialize(get_option('usces_customer_status')); ?></usces_customer_status> | |
| 2058 | - <usces_payment_structure><?php echo serialize(get_option('usces_payment_structure')); ?></usces_payment_structure> | |
| 2059 | - <usces_display_mode><?php echo serialize(get_option('usces_display_mode')); ?></usces_display_mode> | |
| 2060 | -<!--20110331ysk start--> | |
| 2061 | -<!-- <usces_pref><?php //echo serialize(get_option('usces_pref')); ?></usces_pref>--> | |
| 2062 | -<!--20110331ysk end--> | |
| 2063 | - <usces_shipping_rule><?php echo serialize(get_option('usces_shipping_rule')); ?></usces_shipping_rule> | |
| 2064 | - | |
| 2065 | -<?php | |
| 2066 | -} | |
| 2067 | - | |
| 2068 | -function usces_all_change_zaiko(&$obj) { | |
| 2069 | - global $wpdb, $usces; | |
| 2070 | - | |
| 2071 | - $ids = $_POST['listcheck']; | |
| 2072 | - $status = true; | |
| 2073 | - foreach ( (array)$ids as $post_id ){ | |
| 2074 | - $skus = $usces->get_skus($post_id); | |
| 2075 | - foreach ( (array)$skus as $sku ){ | |
| 2076 | - $res = usces_update_sku( $post_id, $sku['code'], 'stock', (int)$_POST['change']['word']['zaiko'] ); | |
| 2077 | - if( !$res ){ | |
| 2078 | - $status = false; | |
| 2079 | - } | |
| 2080 | - } | |
| 2081 | - } | |
| 2082 | - if ( true === $status ) { | |
| 2083 | - $obj->set_action_status('success', __('I completed collective operation.','usces')); | |
| 2084 | - } elseif ( false === $status ) { | |
| 2085 | - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces')); | |
| 2086 | - } else { | |
| 2087 | - $obj->set_action_status('none', ''); | |
| 2088 | - } | |
| 2089 | -} | |
| 2090 | - | |
| 2091 | -function usces_all_change_itemdisplay(&$obj){ | |
| 2092 | - global $wpdb; | |
| 2093 | - | |
| 2094 | - $ids = $_POST['listcheck']; | |
| 2095 | - $post_status = $_POST['change']['word']['display_status']; | |
| 2096 | - $status = true; | |
| 2097 | - foreach ( (array)$ids as $post_id ): | |
| 2098 | -// $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s WHERE ID = %d", $post_status, $post_id); | |
| 2099 | -// $res = $wpdb->query( $query ); | |
| 2100 | - $post_data = array('ID'=>$post_id, 'post_status'=>$post_status); | |
| 2101 | - $res = wp_update_post( $post_data ); | |
| 2102 | - | |
| 2103 | - if( $res == 0 ) { | |
| 2104 | - $status = false; | |
| 2105 | - } | |
| 2106 | - endforeach; | |
| 2107 | - if ( true === $status ) { | |
| 2108 | - $obj->set_action_status('success', __('I completed collective operation.','usces')); | |
| 2109 | - } elseif ( false === $status ) { | |
| 2110 | - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces')); | |
| 2111 | - } else { | |
| 2112 | - $obj->set_action_status('none', ''); | |
| 2113 | - } | |
| 2114 | -} | |
| 2115 | - | |
| 2116 | -function usces_all_change_order_reciept(&$obj){ | |
| 2117 | - global $wpdb, $usces; | |
| 2118 | - | |
| 2119 | - $tableName = $wpdb->prefix . "usces_order"; | |
| 2120 | - $ids = $_POST['listcheck']; | |
| 2121 | - $status = true; | |
| 2122 | - foreach ( (array)$ids as $id ): | |
| 2123 | -//20120306ysk start 0000324 | |
| 2124 | - //$query = $wpdb->prepare("SELECT order_status FROM $tableName WHERE ID = %d", $id); | |
| 2125 | - //$statusstr = $wpdb->get_var( $query ); | |
| 2126 | - $query = $wpdb->prepare("SELECT order_status, mem_id, order_getpoint FROM $tableName WHERE ID = %d", $id); | |
| 2127 | - $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 2128 | - $statusstr = $order_res['order_status']; | |
| 2129 | - $restore_point = false; | |
| 2130 | - $getpoint = $order_res['order_getpoint']; | |
| 2131 | - if( strpos($statusstr, 'cancel') !== false ) continue;//20131101ysk 0000751 | |
| 2132 | -//20120306ysk end | |
| 2133 | - if(strpos($statusstr, 'noreceipt') === false && strpos($statusstr, 'receipted') === false) continue; | |
| 2134 | - $old_status = $statusstr;//20120612ysk 0000501 | |
| 2135 | - if($_REQUEST['change']['word']['order_reciept'] == 'receipted') { | |
| 2136 | -//20120306ysk start 0000324 | |
| 2137 | - //if(strpos($statusstr, 'noreceipt') !== false) | |
| 2138 | - if(strpos($statusstr, 'noreceipt') !== false) { | |
| 2139 | - $statusstr = str_replace('noreceipt', 'receipted', $statusstr); | |
| 2140 | - //if( !$usces->is_status('completion', $order_res['order_status']) ) { | |
| 2141 | - $restore_point = true; | |
| 2142 | - $getpoint = $getpoint * -1;//add point | |
| 2143 | - //} | |
| 2144 | - } | |
| 2145 | -//20120306ysk end | |
| 2146 | - }elseif($_REQUEST['change']['word']['order_reciept'] == 'noreceipt') { | |
| 2147 | -//20120306ysk start 0000324 | |
| 2148 | - //if(strpos($statusstr, 'receipted') !== false) | |
| 2149 | - if(strpos($statusstr, 'receipted') !== false) { | |
| 2150 | - $statusstr = str_replace('receipted', 'noreceipt', $statusstr); | |
| 2151 | - //if( !$usces->is_status('completion', $order_res['order_status']) ) | |
| 2152 | - $restore_point = true; | |
| 2153 | - } | |
| 2154 | -//20120306ysk end | |
| 2155 | - } | |
| 2156 | - $query = $wpdb->prepare("UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id); | |
| 2157 | - $res = $wpdb->query( $query ); | |
| 2158 | - if( $res === false ) { | |
| 2159 | - $status = false; | |
| 2160 | - } | |
| 2161 | -//20120306ysk start 0000324 | |
| 2162 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) { | |
| 2163 | - if( !empty($order_res['mem_id']) && 0 < $order_res['order_getpoint'] ) { | |
| 2164 | - if( $res && $restore_point ) usces_restore_point( $order_res['mem_id'], $getpoint ); | |
| 2165 | - } | |
| 2166 | - } | |
| 2167 | -//20120306ysk end | |
| 2168 | - if( $status ) { | |
| 2169 | - do_action( 'usces_action_collective_order_reciept_each', $id, $statusstr, $old_status ); | |
| 2170 | - } | |
| 2171 | - endforeach; | |
| 2172 | - if ( true === $status ) { | |
| 2173 | - $obj->set_action_status('success', __('I completed collective operation.','usces')); | |
| 2174 | - } elseif ( false === $status ) { | |
| 2175 | - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces')); | |
| 2176 | - } else { | |
| 2177 | - $obj->set_action_status('none', ''); | |
| 2178 | - } | |
| 2179 | - do_action('usces_action_collective_order_reciept', array(&$obj)); | |
| 2180 | -} | |
| 2181 | - | |
| 2182 | -function usces_all_change_order_status(&$obj){ | |
| 2183 | - global $wpdb, $usces; | |
| 2184 | - | |
| 2185 | - $tableName = $wpdb->prefix . "usces_order"; | |
| 2186 | - $ids = $_POST['listcheck']; | |
| 2187 | - foreach ( (array)$ids as $id ): | |
| 2188 | - $status = true; | |
| 2189 | -//20120306ysk start 0000324 | |
| 2190 | - //$query = $wpdb->prepare("SELECT order_status FROM $tableName WHERE ID = %d", $id); | |
| 2191 | - //$statusstr = $wpdb->get_var( $query ); | |
| 2192 | - $query = $wpdb->prepare("SELECT order_status, mem_id, order_getpoint, order_usedpoint, order_payment_name FROM $tableName WHERE ID = %d", $id); | |
| 2193 | - $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 2194 | - $statusstr = $order_res['order_status']; | |
| 2195 | - $restore_point = false; | |
| 2196 | - $getpoint = $order_res['order_getpoint']; | |
| 2197 | - $usedpoint = $order_res['order_usedpoint']; | |
| 2198 | -//20120306ysk end | |
| 2199 | - $old_status = $statusstr;//20120612ysk 0000501 | |
| 2200 | - switch ($_REQUEST['change']['word']['order_status']) { | |
| 2201 | - case 'estimate': | |
| 2202 | - if(strpos($statusstr, 'adminorder') !== false) { | |
| 2203 | - $statusstr = str_replace('adminorder', 'estimate', $statusstr); | |
| 2204 | - }else if(strpos($statusstr, 'estimate') === false) { | |
| 2205 | - $statusstr .= 'estimate,'; | |
| 2206 | - } | |
| 2207 | - break; | |
| 2208 | - case 'adminorder': | |
| 2209 | - if(strpos($statusstr, 'estimate') !== false) { | |
| 2210 | - $statusstr = str_replace('estimate', 'adminorder', $statusstr); | |
| 2211 | - }else if(strpos($statusstr, 'adminorder') === false) { | |
| 2212 | - $statusstr .= 'adminorder,'; | |
| 2213 | - } | |
| 2214 | - break; | |
| 2215 | - case 'duringorder': | |
| 2216 | - if(strpos($statusstr, 'cancel') !== false) { | |
| 2217 | - $statusstr = str_replace('cancel', 'duringorder', $statusstr); | |
| 2218 | -//20120919ysk start 0000573 | |
| 2219 | - if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 2220 | - $restore_point = true; | |
| 2221 | - $getpoint = $getpoint * -1;//add point | |
| 2222 | - } elseif( $usces->is_status('receipted', $order_res['order_status']) ) { | |
| 2223 | - $restore_point = true; | |
| 2224 | - $getpoint = $getpoint * -1;//add point | |
| 2225 | - } | |
| 2226 | -//20120919ysk end | |
| 2227 | - }else if(strpos($statusstr, 'completion') !== false) { | |
| 2228 | - $statusstr = str_replace('completion', 'duringorder', $statusstr); | |
| 2229 | -//20120306ysk start 0000324 | |
| 2230 | - //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) ) | |
| 2231 | - // $restore_point = true; | |
| 2232 | -//20120306ysk end | |
| 2233 | - }else if(strpos($statusstr, 'new') !== false) { | |
| 2234 | - $statusstr = str_replace('new', 'duringorder', $statusstr); | |
| 2235 | - }else if(strpos($statusstr, 'duringorder') === false) { | |
| 2236 | - $statusstr .= 'duringorder,'; | |
| 2237 | - } | |
| 2238 | - break; | |
| 2239 | - case 'cancel': | |
| 2240 | - if(strpos($statusstr, 'completion') !== false) { | |
| 2241 | - $statusstr = str_replace('completion', 'cancel', $statusstr); | |
| 2242 | -//20120306ysk start 0000324 | |
| 2243 | - //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) ) | |
| 2244 | - // $restore_point = true; | |
| 2245 | -//20120306ysk end | |
| 2246 | - }else if(strpos($statusstr, 'new') !== false) { | |
| 2247 | - $statusstr = str_replace('new', 'cancel', $statusstr); | |
| 2248 | - }else if(strpos($statusstr, 'duringorder') !== false) { | |
| 2249 | - $statusstr = str_replace('duringorder', 'cancel', $statusstr); | |
| 2250 | - }else if(strpos($statusstr, 'cancel') === false) { | |
| 2251 | - $statusstr .= 'cancel,'; | |
| 2252 | - } | |
| 2253 | -//20120919ysk start 0000573 | |
| 2254 | - if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 2255 | - $restore_point = true; | |
| 2256 | - $usedpoint = $usedpoint * -1;//add point | |
| 2257 | - } elseif( $usces->is_status('receipted', $order_res['order_status']) ) { | |
| 2258 | - $restore_point = true; | |
| 2259 | - $usedpoint = $usedpoint * -1;//add point | |
| 2260 | - } | |
| 2261 | -//20120919ysk end | |
| 2262 | - break; | |
| 2263 | - case 'completion': | |
| 2264 | - if(strpos($statusstr, 'new') !== false) { | |
| 2265 | - $statusstr = str_replace('new', 'completion', $statusstr); | |
| 2266 | - }else if(strpos($statusstr, 'duringorder') !== false) { | |
| 2267 | - $statusstr = str_replace('duringorder', 'completion', $statusstr); | |
| 2268 | - }else if(strpos($statusstr, 'cancel') !== false) { | |
| 2269 | - $statusstr = str_replace('cancel', 'completion', $statusstr); | |
| 2270 | -//20120919ysk start 0000573 | |
| 2271 | - if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 2272 | - $restore_point = true; | |
| 2273 | - $getpoint = $getpoint * -1;//add point | |
| 2274 | - } elseif( $usces->is_status('receipted', $order_res['order_status']) ) { | |
| 2275 | - $restore_point = true; | |
| 2276 | - $getpoint = $getpoint * -1;//add point | |
| 2277 | - } | |
| 2278 | -//20120919ysk end | |
| 2279 | - }else if(strpos($statusstr, 'completion') === false) { | |
| 2280 | - $statusstr .= 'completion,'; | |
| 2281 | - } | |
| 2282 | -//20120306ysk start 0000324 | |
| 2283 | - //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) ) { | |
| 2284 | - // $restore_point = true; | |
| 2285 | - // $getpoint = $getpoint * -1;//add point | |
| 2286 | - //} | |
| 2287 | -//20120306ysk end | |
| 2288 | - break; | |
| 2289 | - case 'new': | |
| 2290 | - if(strpos($statusstr, 'duringorder') !== false) { | |
| 2291 | - $statusstr = str_replace('duringorder,', '', $statusstr); | |
| 2292 | - }else if(strpos($statusstr, 'completion') !== false) { | |
| 2293 | - $statusstr = str_replace('completion,', '', $statusstr); | |
| 2294 | -//20120306ysk start 0000324 | |
| 2295 | - //if( !usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) && !$usces->is_status('receipted', $order_res['order_status']) ) | |
| 2296 | - // $restore_point = true; | |
| 2297 | -//20120306ysk end | |
| 2298 | - }else if(strpos($statusstr, 'cancel') !== false) { | |
| 2299 | - $statusstr = str_replace('cancel,', '', $statusstr); | |
| 2300 | -//20120919ysk start 0000573 | |
| 2301 | - if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 2302 | - $restore_point = true; | |
| 2303 | - $getpoint = $getpoint * -1;//add point | |
| 2304 | - } elseif( $usces->is_status('receipted', $order_res['order_status']) ) { | |
| 2305 | - $restore_point = true; | |
| 2306 | - $getpoint = $getpoint * -1;//add point | |
| 2307 | - } | |
| 2308 | -//20120919ysk end | |
| 2309 | - } | |
| 2310 | - break; | |
| 2311 | - } | |
| 2312 | - $query = $wpdb->prepare("UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id); | |
| 2313 | - $res = $wpdb->query( $query ); | |
| 2314 | - if( $res === false ) { | |
| 2315 | - $status = false; | |
| 2316 | - } | |
| 2317 | -//20120306ysk start 0000324 | |
| 2318 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) { | |
| 2319 | - if( !empty($order_res['mem_id']) && ( 0 < $order_res['order_getpoint'] || 0 < $order_res['order_usedpoint'] ) ) { | |
| 2320 | - if( $res && $restore_point ) usces_restore_point( $order_res['mem_id'], $getpoint + $usedpoint ); | |
| 2321 | - } | |
| 2322 | - } | |
| 2323 | -//20120306ysk end | |
| 2324 | -//20120612ysk 0000501 start | |
| 2325 | - if( $status ) { | |
| 2326 | - do_action('usces_action_collective_order_status_each', $id, $statusstr, $old_status); | |
| 2327 | - } | |
| 2328 | -//20120612ysk end | |
| 2329 | - endforeach; | |
| 2330 | - if ( true === $status ) { | |
| 2331 | - $obj->set_action_status('success', __('I completed collective operation.','usces')); | |
| 2332 | - } elseif ( false === $status ) { | |
| 2333 | - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces')); | |
| 2334 | - } else { | |
| 2335 | - $obj->set_action_status('none', ''); | |
| 2336 | - } | |
| 2337 | - do_action('usces_action_collective_order_status', array(&$obj)); | |
| 2338 | -} | |
| 2339 | - | |
| 2340 | -function usces_all_delete_order_data(&$obj){ | |
| 2341 | - global $wpdb, $usces; | |
| 2342 | - | |
| 2343 | - $tableName = $wpdb->prefix . "usces_order"; | |
| 2344 | - $tableMetaName = $wpdb->prefix . "usces_order_meta"; | |
| 2345 | - $ids = $_POST['listcheck']; | |
| 2346 | - $status = true; | |
| 2347 | - foreach ( (array)$ids as $id ): | |
| 2348 | - $del = usces_delete_order_check( $id ); | |
| 2349 | - if( $del === false ) continue; | |
| 2350 | -//20130625ysk start 0000721 | |
| 2351 | -//20120306ysk start 0000324 | |
| 2352 | - //$restore_point = false; | |
| 2353 | - $point = 0; | |
| 2354 | - $query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $id); | |
| 2355 | - $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 2356 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] && !empty($order_res['mem_id']) && !$usces->is_status('cancel', $order_res['order_status']) ) { | |
| 2357 | - //$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $id); | |
| 2358 | - //$order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 2359 | - if( 0 < $order_res['order_getpoint'] ) { | |
| 2360 | - //if( $usces->is_status('completion', $order_res['order_status']) ) { | |
| 2361 | - // $restore_point = true; | |
| 2362 | - //} else { | |
| 2363 | - if( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) || $usces->is_status('receipted', $order_res['order_status']) ) | |
| 2364 | - //$restore_point = true; | |
| 2365 | - $point += $order_res['order_getpoint']; | |
| 2366 | - //} | |
| 2367 | - } | |
| 2368 | - if( 0 < $order_res['order_usedpoint'] ) { | |
| 2369 | - $point -= $order_res['order_usedpoint']; | |
| 2370 | - } | |
| 2371 | - } | |
| 2372 | -//20120306ysk end | |
| 2373 | - $query = $wpdb->prepare("DELETE FROM $tableName WHERE ID = %d", $id); | |
| 2374 | - $res = $wpdb->query( $query ); | |
| 2375 | - if( $res === false ) { | |
| 2376 | - $status = false; | |
| 2377 | - }else{ | |
| 2378 | - | |
| 2379 | - if( 0 != $point ) usces_restore_point( $order_res['mem_id'], $point ); | |
| 2380 | - | |
| 2381 | - do_action('usces_action_collective_order_delete_each', $id, $order_res); | |
| 2382 | - | |
| 2383 | - usces_delete_ordercartdata( NULL, $id ); | |
| 2384 | - | |
| 2385 | - $metaquery = $wpdb->prepare("DELETE FROM $tableMetaName WHERE order_id = %d", $id);//0000427 | |
| 2386 | - $metares = $wpdb->query( $metaquery ); | |
| 2387 | - } | |
| 2388 | - endforeach; | |
| 2389 | - if ( true === $status ) { | |
| 2390 | - $obj->set_action_status('success', __('I completed collective operation.','usces')); | |
| 2391 | - } elseif ( false === $status ) { | |
| 2392 | - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces')); | |
| 2393 | - } else { | |
| 2394 | - $obj->set_action_status('none', ''); | |
| 2395 | - } | |
| 2396 | - do_action('usces_action_collective_order_delete', array(&$obj)); | |
| 2397 | -} | |
| 2398 | - | |
| 2399 | -function usces_check_acting_return() { | |
| 2400 | - global $usces; | |
| 2401 | - $entry = $usces->cart->get_entry(); | |
| 2402 | - | |
| 2403 | - $acting = $_GET['acting']; | |
| 2404 | - $results = array(); | |
| 2405 | - switch ( $acting ) { | |
| 2406 | - case 'epsilon': | |
| 2407 | - if(isset($_GET['duplicate']) && $_GET['duplicate'] == 1){ | |
| 2408 | - $results[0] = 'duplicate'; | |
| 2409 | - }else if(isset($_GET['result'])){ | |
| 2410 | - $results[0] = (int)$_GET['result']; | |
| 2411 | - $results['reg_order'] = true; | |
| 2412 | - }else{ | |
| 2413 | - $str = explode('?', $_GET['acting_return']); | |
| 2414 | - if(!isset($str[1])) { | |
| 2415 | - $results[0] = 0; | |
| 2416 | - }else{ | |
| 2417 | - $para = parse_str($str[1]); | |
| 2418 | - $results[0] = isset($para['result']) ? (int)$para['result'] : 0; | |
| 2419 | - foreach($para as $key => $value){ | |
| 2420 | - $results[$key] = $value; | |
| 2421 | - } | |
| 2422 | - } | |
| 2423 | - | |
| 2424 | - } | |
| 2425 | - $results['reg_order'] = true; | |
| 2426 | - break; | |
| 2427 | - | |
| 2428 | - case 'paypal': | |
| 2429 | - usces_log('paypal in ', 'acting_transaction.log'); | |
| 2430 | - require_once($usces->options['settlement_path'] . "paypal.php"); | |
| 2431 | - $results = paypal_check($usces_paypal_url); | |
| 2432 | - remove_action( 'wp_footer', array(&$usces, 'lastprocessing')); | |
| 2433 | - $results['reg_order'] = true; | |
| 2434 | - break; | |
| 2435 | - | |
| 2436 | - case 'zeus_card': | |
| 2437 | - $results = $_REQUEST; | |
| 2438 | - if( $_REQUEST['acting_return'] && isset($_REQUEST['wctid']) && usces_is_trusted_acting_data($_REQUEST['wctid']) ){ | |
| 2439 | - $results[0] = 1; | |
| 2440 | - }else{ | |
| 2441 | - $results[0] = 0; | |
| 2442 | - } | |
| 2443 | - $results['reg_order'] = true; | |
| 2444 | - break; | |
| 2445 | - | |
| 2446 | - case 'zeus_conv': | |
| 2447 | - $results = $_GET; | |
| 2448 | - if( $_REQUEST['acting_return'] ){ | |
| 2449 | - $results[0] = 1; | |
| 2450 | - }else{ | |
| 2451 | - $results[0] = 0; | |
| 2452 | - } | |
| 2453 | - $results['reg_order'] = false; | |
| 2454 | - break; | |
| 2455 | - | |
| 2456 | - case 'remise_card': | |
| 2457 | - $results = $_POST; | |
| 2458 | - if( $_REQUEST['acting_return'] && ( isset($_REQUEST['X-ERRCODE']) && ' ' === $_REQUEST['X-ERRCODE'] ) ){ | |
| 2459 | - usces_log('remise card entry data : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2460 | - $results[0] = 1; | |
| 2461 | - }else{ | |
| 2462 | - $results[0] = 0; | |
| 2463 | - } | |
| 2464 | - if( isset($_REQUEST['dlseller_update']) ){ | |
| 2465 | - $results['reg_order'] = false; | |
| 2466 | - }else{ | |
| 2467 | - $results['reg_order'] = true; | |
| 2468 | - } | |
| 2469 | - break; | |
| 2470 | - | |
| 2471 | - case 'remise_conv': | |
| 2472 | - $results = $_GET; | |
| 2473 | - if( $_REQUEST['acting_return'] && isset($_REQUEST['X-JOB_ID']) && '0:0000' === $_REQUEST['X-R_CODE']){ | |
| 2474 | - //usces_log('remise conv entry data : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2475 | - $results[0] = 1; | |
| 2476 | - }else{ | |
| 2477 | - $results[0] = 0; | |
| 2478 | - } | |
| 2479 | - $results['reg_order'] = true; | |
| 2480 | - break; | |
| 2481 | - | |
| 2482 | -//20101018ysk start | |
| 2483 | - case 'jpayment_card': | |
| 2484 | - $results = $_GET; | |
| 2485 | - if($_GET['rst'] == 2) { | |
| 2486 | - usces_log('jpayment card error : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2487 | - } | |
| 2488 | - $results[0] = ($_GET['rst'] == 1) ? 1 : 0; | |
| 2489 | - $results['reg_order'] = true; | |
| 2490 | - break; | |
| 2491 | - | |
| 2492 | - case 'jpayment_conv': | |
| 2493 | - $results = $_GET; | |
| 2494 | - if($_GET['rst'] == 2) { | |
| 2495 | - usces_log('jpayment conv error : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2496 | - } | |
| 2497 | - $results[0] = ($_GET['rst'] == 1 and $_GET['ap'] == 'CPL_PRE') ? 1 : 0; | |
| 2498 | - $results['reg_order'] = true; | |
| 2499 | - break; | |
| 2500 | - | |
| 2501 | - case 'jpayment_bank': | |
| 2502 | - $results = $_GET; | |
| 2503 | - if($_GET['rst'] == 2) { | |
| 2504 | - usces_log('jpayment bank error : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2505 | - } | |
| 2506 | - $results[0] = ($_GET['rst'] == 1) ? 1 : 0; | |
| 2507 | - $results['reg_order'] = true; | |
| 2508 | - break; | |
| 2509 | -//20101018ysk end | |
| 2510 | -//20110208ysk start | |
| 2511 | - case 'paypal_ec': | |
| 2512 | - $results = $_GET; | |
| 2513 | - | |
| 2514 | - //Build a second API request to PayPal, using the token as the ID to get the details on the payment authorization | |
| 2515 | - $req_token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '0'; | |
| 2516 | - $nvpstr = "&TOKEN=".urlencode($req_token); | |
| 2517 | - | |
| 2518 | - $usces->paypal->setMethod('GetExpressCheckoutDetails'); | |
| 2519 | - $usces->paypal->setData($nvpstr); | |
| 2520 | - $res = $usces->paypal->doExpressCheckout(); | |
| 2521 | - $resArray = $usces->paypal->getResponse(); | |
| 2522 | - $ack = strtoupper($resArray["ACK"]); | |
| 2523 | - if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { | |
| 2524 | -//20121009ysk start 0000587 | |
| 2525 | -//20121225ysk start 000634 | |
| 2526 | - $cart = $usces->cart->get_cart(); | |
| 2527 | - $charging_type = $usces->getItemChargingType($cart[0]['post_id'], $cart); | |
| 2528 | - if( 'continue' == $charging_type ) { | |
| 2529 | - $results[0] = 1; | |
| 2530 | - } else { | |
| 2531 | -//20121225ysk end | |
| 2532 | - if( (float)$resArray["AMT"] != (float)$entry['order']['total_full_price'] ) { | |
| 2533 | - usces_log('PayPal : AMT Error. AMT='.$resArray["AMT"].', total_full_price='.$entry['order']['total_full_price'], 'acting_transaction.log'); | |
| 2534 | - $results[0] = 0; | |
| 2535 | - } else { | |
| 2536 | - $results[0] = 1; | |
| 2537 | - } | |
| 2538 | - } | |
| 2539 | -//20121009ysk end | |
| 2540 | - | |
| 2541 | - } else { | |
| 2542 | - //Display a user friendly Error on the page using any of the following error information returned by PayPal | |
| 2543 | - $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); | |
| 2544 | - $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); | |
| 2545 | - $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); | |
| 2546 | - $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); | |
| 2547 | - 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'); | |
| 2548 | - $results[0] = 0; | |
| 2549 | - } | |
| 2550 | - $results['reg_order'] = true; | |
| 2551 | - break; | |
| 2552 | -//20110208ysk end | |
| 2553 | -//20120413ysk start | |
| 2554 | - case 'sbps_card': | |
| 2555 | - case 'sbps_wallet': | |
| 2556 | - case 'sbps_mobile': | |
| 2557 | -/* if( isset($_REQUEST['cancel']) ) { | |
| 2558 | - $results[0] = 0; | |
| 2559 | - $results['reg_order'] = false; | |
| 2560 | - | |
| 2561 | - } else { | |
| 2562 | - if( isset($_REQUEST['res_result']) and 'OK' == $_REQUEST['res_result'] ) { | |
| 2563 | - usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2564 | - $results[0] = 1; | |
| 2565 | - } else { | |
| 2566 | - usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log'); | |
| 2567 | - $results[0] = 0; | |
| 2568 | - } | |
| 2569 | - $results['reg_order'] = true; | |
| 2570 | - } | |
| 2571 | - break;*/ | |
| 2572 | - case 'sbps_conv': | |
| 2573 | - case 'sbps_payeasy': | |
| 2574 | - if( isset($_REQUEST['cancel']) ) { | |
| 2575 | - $results[0] = 0; | |
| 2576 | - $results['reg_order'] = false; | |
| 2577 | - | |
| 2578 | - } else { | |
| 2579 | - if( isset($_REQUEST['res_result']) and 'OK' == $_REQUEST['res_result'] ) { | |
| 2580 | - $results[0] = 1; | |
| 2581 | - } else { | |
| 2582 | - //usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log'); | |
| 2583 | - $results[0] = 0; | |
| 2584 | - } | |
| 2585 | - $results['reg_order'] = false; | |
| 2586 | - } | |
| 2587 | - break; | |
| 2588 | -//20120413ysk end | |
| 2589 | -//20120618ysk start | |
| 2590 | - case 'telecom_card': | |
| 2591 | - $results = $_GET; | |
| 2592 | - if( $_REQUEST['result'] ){ | |
| 2593 | - usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2594 | - $results[0] = 1; | |
| 2595 | - }else{ | |
| 2596 | - usces_log($acting.' error : '.print_r($_REQUEST,true), 'acting_transaction.log'); | |
| 2597 | - $results[0] = 0; | |
| 2598 | - } | |
| 2599 | - $results['reg_order'] = true; | |
| 2600 | - break; | |
| 2601 | -//20120618ysk end | |
| 2602 | -//20121206ysk start | |
| 2603 | - case 'digitalcheck_card': | |
| 2604 | - $results = $_REQUEST; | |
| 2605 | - if( isset($_REQUEST['SID']) ) { | |
| 2606 | - $results[0] = 1; | |
| 2607 | - } else { | |
| 2608 | - $results[0] = 0; | |
| 2609 | - } | |
| 2610 | - $results['reg_order'] = true; | |
| 2611 | - break; | |
| 2612 | - case 'digitalcheck_conv': | |
| 2613 | - $results = $_REQUEST; | |
| 2614 | - //if( isset($_REQUEST['SID']) ) { | |
| 2615 | - $results[0] = 1; | |
| 2616 | - //} else { | |
| 2617 | - // $results[0] = 0; | |
| 2618 | - //} | |
| 2619 | - $results['reg_order'] = false; | |
| 2620 | - break; | |
| 2621 | -//20121206ysk end | |
| 2622 | -//20130225ysk start | |
| 2623 | - case 'mizuho_card': | |
| 2624 | - case 'mizuho_conv': | |
| 2625 | - $results = $_GET; | |
| 2626 | - if( isset($_GET['rsltcd']) ) { | |
| 2627 | - if( '000' == substr($_GET['rsltcd'], 0, 3) ) { | |
| 2628 | - $results[0] = 1; | |
| 2629 | - $results['reg_order'] = true; | |
| 2630 | - } else { | |
| 2631 | - $results[0] = 0; | |
| 2632 | - $results['reg_order'] = false; | |
| 2633 | - } | |
| 2634 | - } else { | |
| 2635 | - $results[0] = 0; | |
| 2636 | - $results['reg_order'] = false; | |
| 2637 | - } | |
| 2638 | - break; | |
| 2639 | -//20130225ysk end | |
| 2640 | -//20131220ysk start | |
| 2641 | - case 'anotherlane_card': | |
| 2642 | - $results[0] = 1; | |
| 2643 | - $results['reg_order'] = false; | |
| 2644 | - break; | |
| 2645 | -//20131220ysk end | |
| 2646 | -//20140206ysk start | |
| 2647 | - case 'veritrans_card': | |
| 2648 | - case 'veritrans_conv': | |
| 2649 | - $results[0] = ( isset($_GET['result']) ) ? $_GET['result'] : 0; | |
| 2650 | - $results['reg_order'] = false; | |
| 2651 | - break; | |
| 2652 | -//20140206ysk end | |
| 2653 | - | |
| 2654 | - default: | |
| 2655 | - do_action( 'usces_action_check_acting_return_default' ); | |
| 2656 | - $results = $_REQUEST;//20140227ysk | |
| 2657 | - if( isset($_REQUEST['result']) and true == $_REQUEST['result'] ) { | |
| 2658 | - usces_log($acting.' entry data : '.print_r($entry, true), 'acting_transaction.log'); | |
| 2659 | - $results[0] = 1; | |
| 2660 | - }else{ | |
| 2661 | - usces_log($acting.' error : '.print_r($_REQUEST, true), 'acting_transaction.log'); | |
| 2662 | - $results[0] = 0; | |
| 2663 | - } | |
| 2664 | -//20110310ysk start | |
| 2665 | - //$results['reg_order'] = false; | |
| 2666 | - $results['reg_order'] = true; | |
| 2667 | -//20110310ysk end | |
| 2668 | - $results = apply_filters( 'usces_filter_check_acting_return_results', $results );//20140227ysk | |
| 2669 | - break; | |
| 2670 | - } | |
| 2671 | - | |
| 2672 | - return $results; | |
| 2673 | -} | |
| 2674 | -//20110203ysk start | |
| 2675 | -function usces_check_acting_return_duplicate( $results = array() ) { | |
| 2676 | - global $wpdb; | |
| 2677 | - $acting = isset($_GET['acting']) ? $_GET['acting'] : ''; | |
| 2678 | -// usces_log('$_REQUEST : '.print_r($_REQUEST,true), 'acting_transaction.log'); | |
| 2679 | -// usces_log('$results : '.print_r($results,true), 'acting_transaction.log'); | |
| 2680 | - | |
| 2681 | - switch($acting) { | |
| 2682 | - case 'epsilon': | |
| 2683 | - $trans_id = isset($_REQUEST['trans_code']) ? $_REQUEST['trans_code'] : ''; | |
| 2684 | - break; | |
| 2685 | -//20110208ysk start | |
| 2686 | - case 'paypal': | |
| 2687 | - $trans_id = isset($results['txn_id']) ? $results['txn_id'] : ''; | |
| 2688 | - break; | |
| 2689 | -//20110208ysk end | |
| 2690 | - case 'paypal_ipn': | |
| 2691 | - $trans_id = isset($_REQUEST['txn_id']) ? $_REQUEST['txn_id'] : ''; | |
| 2692 | - break; | |
| 2693 | -//20110208ysk start | |
| 2694 | - case 'paypal_ec': | |
| 2695 | - $trans_id = isset($_REQUEST['token']) ? $_REQUEST['token'] : ''; | |
| 2696 | - break; | |
| 2697 | -//20110208ysk end | |
| 2698 | - case 'zeus_card': | |
| 2699 | - $trans_id = isset($_REQUEST['ordd']) ? $_REQUEST['ordd'] : ''; | |
| 2700 | - break; | |
| 2701 | - case 'zeus_conv': | |
| 2702 | - case 'zeus_bank': | |
| 2703 | - $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : ''; | |
| 2704 | - break; | |
| 2705 | - case 'remise_card': | |
| 2706 | - $trans_id = isset($_REQUEST['X-TRANID']) ? $_REQUEST['X-TRANID'] : ''; | |
| 2707 | - break; | |
| 2708 | - case 'remise_conv': | |
| 2709 | - $trans_id = isset($_REQUEST['X-JOB_ID']) ? $_REQUEST['X-JOB_ID'] : ''; | |
| 2710 | - break; | |
| 2711 | - case 'jpayment_card': | |
| 2712 | - case 'jpayment_conv': | |
| 2713 | - case 'jpayment_bank': | |
| 2714 | - $trans_id = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : ''; | |
| 2715 | - break; | |
| 2716 | -//20120413ysk start | |
| 2717 | - case 'sbps_card': | |
| 2718 | - case 'sbps_conv': | |
| 2719 | - case 'sbps_payeasy': | |
| 2720 | - case 'sbps_wallet': | |
| 2721 | - case 'sbps_mobile': | |
| 2722 | - $trans_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : ''; | |
| 2723 | - break; | |
| 2724 | -//20120413ysk end | |
| 2725 | -//20120618ysk start | |
| 2726 | - case 'telecom_card': | |
| 2727 | - $trans_id = isset($_REQUEST['sendid']) ? $_REQUEST['sendid'] : ''; | |
| 2728 | - break; | |
| 2729 | -//20120618ysk end | |
| 2730 | -//20121206ysk start | |
| 2731 | - case 'digitalcheck_card': | |
| 2732 | - case 'digitalcheck_conv': | |
| 2733 | - $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : ''; | |
| 2734 | - break; | |
| 2735 | -//20121206ysk end | |
| 2736 | -//20130225ysk start | |
| 2737 | - case 'mizuho_card': | |
| 2738 | - case 'mizuho_conv': | |
| 2739 | - $trans_id = isset($_REQUEST['stran']) ? $_REQUEST['stran'] : ''; | |
| 2740 | - break; | |
| 2741 | -//20130225ysk end | |
| 2742 | - default: | |
| 2743 | - $trans_id = ''; | |
| 2744 | - } | |
| 2745 | - $table_meta_name = $wpdb->prefix.'usces_order_meta'; | |
| 2746 | - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'trans_id', $trans_id); | |
| 2747 | - $order_id = $wpdb->get_var($query); | |
| 2748 | - return $order_id; | |
| 2749 | -} | |
| 2750 | -//20110203ysk end | |
| 2751 | - | |
| 2752 | -//20111111ysk start | |
| 2753 | -function usces_dates_interconv( $date_str ) { | |
| 2754 | - $base_struc = preg_split('[/.-]', 'd/m/Y' ); | |
| 2755 | - $date_str_parts = preg_split('[/.-]', $date_str ); | |
| 2756 | - $date_elements = array(); | |
| 2757 | - | |
| 2758 | - $p_keys = array_keys( $base_struc ); | |
| 2759 | - foreach( $p_keys as $p_key ) { | |
| 2760 | - if( !empty( $date_str_parts[$p_key] )) { | |
| 2761 | - $date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key]; | |
| 2762 | - } else { | |
| 2763 | - return false; | |
| 2764 | - } | |
| 2765 | - } | |
| 2766 | - $dummy_ts = mktime( 0,0,0, $date_elements['m'],$date_elements['d'],$date_elements['Y']); | |
| 2767 | - return date( 'Y-m-d', $dummy_ts ); | |
| 2768 | -} | |
| 2769 | -//20101111ysk end | |
| 2770 | - | |
| 2771 | -function usces_register_action($handle, $type, $key, $value, $function){ | |
| 2772 | - global $usces_action; | |
| 2773 | - $usces_action[$handle] = array('type'=>$type, 'key'=>$key, 'value'=>$value, 'function'=>$function); | |
| 2774 | -} | |
| 2775 | - | |
| 2776 | -function usces_deregister_action($handle){ | |
| 2777 | - global $usces_action; | |
| 2778 | - unset($usces_action[$handle]); | |
| 2779 | -} | |
| 2780 | - | |
| 2781 | -function usces_get_wcexp($post_id, $name=''){ | |
| 2782 | - $wcexp = get_post_meta($post_id, '_wcexp', true); | |
| 2783 | - if( empty($name) ){ | |
| 2784 | - $value = ( $wcexp !== false ) ? $wcexp : ''; | |
| 2785 | - }else{ | |
| 2786 | - $value = ($wcexp !== false && isset($wcexp[$name])) ? $wcexp[$name] : ''; | |
| 2787 | - } | |
| 2788 | - return $value; | |
| 2789 | -} | |
| 2790 | - | |
| 2791 | -function usces_update_check_admin($result){ | |
| 2792 | - $result = true; | |
| 2793 | - return $result; | |
| 2794 | -} | |
| 2795 | - | |
| 2796 | -function usces_setup_cod_ajax(){ | |
| 2797 | - global $usces; | |
| 2798 | - $usces->options = get_option('usces'); | |
| 2799 | - $message = ''; | |
| 2800 | - $_POST = $usces->stripslashes_deep_post($_POST); | |
| 2801 | - | |
| 2802 | - $usces->options['cod_type'] = isset($_POST['cod_type']) ? $_POST['cod_type'] : 'fix'; | |
| 2803 | - if( isset($_POST['cod_fee']) ) | |
| 2804 | - $usces->options['cod_fee'] = (int)$_POST['cod_fee']; | |
| 2805 | - | |
| 2806 | - if( 'fix' == $usces->options['cod_type'] ){ | |
| 2807 | - if( isset($_POST['cod_limit_amount']) ){ | |
| 2808 | - $usces->options['cod_limit_amount'] = (int)$_POST['cod_limit_amount']; | |
| 2809 | - if( !WCUtils::is_blank($_POST['cod_limit_amount']) && 0 === (int)$_POST['cod_limit_amount'] ) | |
| 2810 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2811 | - } | |
| 2812 | - | |
| 2813 | - }elseif( 'change' == $usces->options['cod_type'] ){ | |
| 2814 | - if( isset($_POST['cod_first_amount']) ){ | |
| 2815 | - $usces->options['cod_first_amount'] = (int)$_POST['cod_first_amount']; | |
| 2816 | - if( 0 === (int)$_POST['cod_first_amount'] ) | |
| 2817 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2818 | - } | |
| 2819 | - if( isset($_POST['cod_limit_amount']) ){ | |
| 2820 | - $usces->options['cod_limit_amount'] = (int)$_POST['cod_limit_amount']; | |
| 2821 | - if( !WCUtils::is_blank($_POST['cod_limit_amount']) && 0 === (int)$_POST['cod_limit_amount'] ) | |
| 2822 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2823 | - } | |
| 2824 | - if( isset($_POST['cod_first_fee']) ){ | |
| 2825 | - $usces->options['cod_first_fee'] = (int)$_POST['cod_first_fee']; | |
| 2826 | - if( 0 === (int)$_POST['cod_first_fee'] && '0' !== $_POST['cod_first_fee']) | |
| 2827 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2828 | - } | |
| 2829 | - if( isset($_POST['cod_end_fee']) ){ | |
| 2830 | - $usces->options['cod_end_fee'] = (int)$_POST['cod_end_fee']; | |
| 2831 | - if( 0 === (int)$_POST['cod_end_fee'] && '0' !== $_POST['cod_end_fee'] ) | |
| 2832 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2833 | - } | |
| 2834 | - | |
| 2835 | - unset($usces->options['cod_amounts'], $usces->options['cod_fees']); | |
| 2836 | - if( isset($_POST['cod_amounts']) ){ | |
| 2837 | - for($i=0; $i<count((array)$_POST['cod_amounts']); $i++){ | |
| 2838 | - $usces->options['cod_amounts'][$i] = (int)$_POST['cod_amounts'][$i]; | |
| 2839 | - $usces->options['cod_fees'][$i] = (int)$_POST['cod_fees'][$i]; | |
| 2840 | - if( 0 === (int)$_POST['cod_amounts'][$i] || (0 === (int)$_POST['cod_fees'][$i] && '0' !== $_POST['cod_fees'][$i]) ) | |
| 2841 | - $message = __('There is the item where a value is dirty.', 'usces'); | |
| 2842 | - } | |
| 2843 | - } | |
| 2844 | - } | |
| 2845 | - | |
| 2846 | - | |
| 2847 | - if( '' == $message ){ | |
| 2848 | - $r = 'success'; | |
| 2849 | - update_option('usces', $usces->options); | |
| 2850 | - }else{ | |
| 2851 | - $r = '<span style="color:red;">' . $message . '</span>'; | |
| 2852 | - } | |
| 2853 | - die( $r ); | |
| 2854 | -} | |
| 2855 | - | |
| 2856 | -function usces_get_order_acting_data($rand){ | |
| 2857 | - global $wpdb; | |
| 2858 | - | |
| 2859 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 2860 | - $query = $wpdb->prepare("SELECT acc_str1 AS sesid, acc_value AS order_data FROM $table_name WHERE acc_key = %s", $rand); | |
| 2861 | - $res = $wpdb->get_row($query, ARRAY_A); | |
| 2862 | - if($res == NULL){ | |
| 2863 | - return false; | |
| 2864 | - }else{ | |
| 2865 | - return $res; | |
| 2866 | - } | |
| 2867 | -} | |
| 2868 | - | |
| 2869 | -function usces_auth_order_acting_data($rand){ | |
| 2870 | - global $usces, $wpdb; | |
| 2871 | - $datas = usces_get_order_acting_data($rand); | |
| 2872 | - $data = unserialize($datas['order_data']); | |
| 2873 | - usces_log('usces_auth_order_acting_data', 'acting_transaction.log'); | |
| 2874 | - $data['propriety'] = 1; | |
| 2875 | - | |
| 2876 | - $data = serialize($data); | |
| 2877 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 2878 | - $query = $wpdb->prepare("UPDATE $table_name SET acc_value = %s WHERE acc_type = %s AND acc_key = %s", | |
| 2879 | - $data, | |
| 2880 | - 'acting_data', | |
| 2881 | - $rand | |
| 2882 | - ); | |
| 2883 | - $res = $wpdb->query($query); | |
| 2884 | -} | |
| 2885 | - | |
| 2886 | -function usces_ordered_acting_data($rand){ | |
| 2887 | - global $usces, $wpdb; | |
| 2888 | - $datas = usces_get_order_acting_data($rand); | |
| 2889 | - $data = unserialize($datas['order_data']); | |
| 2890 | - usces_log('usces_ordered_acting_data', 'acting_transaction.log'); | |
| 2891 | - $data['order_received'] = 1; | |
| 2892 | - | |
| 2893 | - $data = serialize($data); | |
| 2894 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 2895 | - $query = $wpdb->prepare("UPDATE $table_name SET acc_value = %s WHERE acc_type = %s AND acc_key = %s", | |
| 2896 | - $data, | |
| 2897 | - 'acting_data', | |
| 2898 | - $rand | |
| 2899 | - ); | |
| 2900 | - $res = $wpdb->query($query); | |
| 2901 | -} | |
| 2902 | - | |
| 2903 | -function usces_is_trusted_acting_data($rand){ | |
| 2904 | - global $usces, $wpdb; | |
| 2905 | - $datas = usces_get_order_acting_data($rand); | |
| 2906 | - $data = unserialize($datas['order_data']); | |
| 2907 | - usces_log('usces_is_trusted_acting_data', 'acting_transaction.log'); | |
| 2908 | - if( isset($data['propriety']) && $data['propriety'] && !isset($data['order_received']) ) | |
| 2909 | - return true; | |
| 2910 | - else | |
| 2911 | - return false; | |
| 2912 | -} | |
| 2913 | - | |
| 2914 | -function usces_get_filename( $path ){ | |
| 2915 | - $res = array(); | |
| 2916 | - if ( $handle = opendir($path) ) { | |
| 2917 | - while (false !== ($file = readdir($handle))) { | |
| 2918 | - if( '.' != $file && '..' != $file ) | |
| 2919 | - $res[] = $file; | |
| 2920 | - } | |
| 2921 | - closedir($handle); | |
| 2922 | - } | |
| 2923 | - return $res; | |
| 2924 | -} | |
| 2925 | - | |
| 2926 | -function usces_locales(){ | |
| 2927 | - $res = array(); | |
| 2928 | - if ( $handle = opendir(USCES_PLUGIN_DIR.'/languages/') ) { | |
| 2929 | - while (false !== ($file = readdir($handle))) { | |
| 2930 | - if( '.' != $file && '..' != $file && preg_match('/^usces-(.+)\.mo$/', $file, $matches) ){ | |
| 2931 | - $res[] = $matches[1]; | |
| 2932 | - } | |
| 2933 | - } | |
| 2934 | - closedir($handle); | |
| 2935 | - } | |
| 2936 | - return $res; | |
| 2937 | -} | |
| 2938 | - | |
| 2939 | -function usces_get_local_language(){ | |
| 2940 | - $locale = get_locale(); | |
| 2941 | - switch( $locale ){ | |
| 2942 | - case '': | |
| 2943 | - case 'en': | |
| 2944 | - case 'en_US': | |
| 2945 | - $front_lang = 'en'; | |
| 2946 | - break; | |
| 2947 | - case 'ja': | |
| 2948 | - case 'ja_JP': | |
| 2949 | - $front_lang = 'ja'; | |
| 2950 | - break; | |
| 2951 | - default: | |
| 2952 | - $front_lang = 'others'; | |
| 2953 | - } | |
| 2954 | - return $front_lang; | |
| 2955 | -} | |
| 2956 | - | |
| 2957 | -function usces_get_base_country(){ | |
| 2958 | - global $usces_settings; | |
| 2959 | -// $locale = get_locale(); | |
| 2960 | - $wplang = defined('WPLANG') ? WPLANG : ''; | |
| 2961 | - $locale = empty( $wplang ) ? 'en' : $wplang; | |
| 2962 | - if( array_key_exists($locale, $usces_settings['lungage2country']) ) | |
| 2963 | - return $usces_settings['lungage2country'][$locale]; | |
| 2964 | - else | |
| 2965 | - return 'US'; | |
| 2966 | -} | |
| 2967 | - | |
| 2968 | -function usces_get_local_addressform(){ | |
| 2969 | - global $usces_settings; | |
| 2970 | - $base = usces_get_base_country(); | |
| 2971 | - if( array_key_exists($base, $usces_settings['addressform']) ) | |
| 2972 | - return $usces_settings['addressform'][$base]; | |
| 2973 | - else | |
| 2974 | - return 'US'; | |
| 2975 | -} | |
| 2976 | - | |
| 2977 | -function usces_get_local_target_market(){ | |
| 2978 | - $base = usces_get_base_country(); | |
| 2979 | - return (array)$base; | |
| 2980 | -} | |
| 2981 | - | |
| 2982 | -function usces_get_apply_addressform($country){ | |
| 2983 | - global $usces_settings; | |
| 2984 | - return $usces_settings['addressform'][$country]; | |
| 2985 | -} | |
| 2986 | - | |
| 2987 | -function usces_remove_filter(){ | |
| 2988 | - global $usces, $post; | |
| 2989 | - | |
| 2990 | - if( is_single() && 'item' == $post->post_mime_type ) { | |
| 2991 | - remove_filter('the_content', array(&$usces, 'filter_itemPage')); | |
| 2992 | - | |
| 2993 | - }else if( $usces->is_cart_page($_SERVER['REQUEST_URI']) || $usces->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 2994 | - remove_action('the_post', array(&$usces, 'action_cartFilter')); | |
| 2995 | - remove_filter('the_title', array(&$usces, 'filter_cartTitle'),20); | |
| 2996 | - remove_filter('the_content', array(&$usces, 'filter_cartContent'),20); | |
| 2997 | - | |
| 2998 | - }else if( $usces->is_member_page($_SERVER['REQUEST_URI']) ){ | |
| 2999 | - remove_action('the_post', array(&$usces, 'action_memberFilter')); | |
| 3000 | - remove_filter('the_title', array(&$usces, 'filter_memberTitle'),20); | |
| 3001 | - remove_filter('the_content', array(&$usces, 'filter_memberContent'),20); | |
| 3002 | - | |
| 3003 | - }else{ | |
| 3004 | - remove_action('the_post', array(&$usces, 'goDefaultPage')); | |
| 3005 | - } | |
| 3006 | -} | |
| 3007 | - | |
| 3008 | -function usces_reset_filter(){ | |
| 3009 | - global $usces, $post; | |
| 3010 | - | |
| 3011 | - if( is_single() && 'item' == $post->post_mime_type ) { | |
| 3012 | - add_filter('the_content', array(&$usces, 'filter_itemPage')); | |
| 3013 | - | |
| 3014 | - }else if( $usces->is_cart_page($_SERVER['REQUEST_URI']) || $usces->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 3015 | - add_action('the_post', array(&$usces, 'action_cartFilter')); | |
| 3016 | - add_filter('the_title', array(&$usces, 'filter_cartTitle'),20); | |
| 3017 | - add_filter('the_content', array(&$usces, 'filter_cartContent'),20); | |
| 3018 | - | |
| 3019 | - }else if( $usces->is_member_page($_SERVER['REQUEST_URI']) ){ | |
| 3020 | - add_action('the_post', array(&$usces, 'action_memberFilter')); | |
| 3021 | - add_filter('the_title', array(&$usces, 'filter_memberTitle'),20); | |
| 3022 | - add_filter('the_content', array(&$usces, 'filter_memberContent'),20); | |
| 3023 | - | |
| 3024 | - }else{ | |
| 3025 | - add_action('the_post', array(&$usces, 'goDefaultPage')); | |
| 3026 | - } | |
| 3027 | -} | |
| 3028 | - | |
| 3029 | - | |
| 3030 | -function usces_get_wcex(){ | |
| 3031 | - $wcex = array(); | |
| 3032 | - if( defined('WCEX_DLSELLER_VERSION')) | |
| 3033 | - $wcex['DLSELLER'] = array('name'=>'Dl Seller', 'version'=>WCEX_DLSELLER_VERSION); | |
| 3034 | - if( defined('WCEX_ITEM_LIST_LAYOUT_VERSION')) | |
| 3035 | - $wcex['ITEM_LIST_LAYOUT'] = array('name'=>'Item List Layout', 'version'=>WCEX_ITEM_LIST_LAYOUT_VERSION); | |
| 3036 | - if( defined('WCEX_MOBILE_VERSION')) | |
| 3037 | - $wcex['MOBILE'] = array('name'=>'Mobile', 'version'=>WCEX_MOBILE_VERSION); | |
| 3038 | - if( defined('WCEX_MULTIPRICE_VERSION')) | |
| 3039 | - $wcex['MULTIPRICE'] = array('name'=>'Multi Price', 'version'=>WCEX_MULTIPRICE_VERSION); | |
| 3040 | - if( defined('WCEX_SLIDE_SHOWCASE_VERSION')) | |
| 3041 | - $wcex['SLIDE_SHOWCASE'] = array('name'=>'Slide Showcase', 'version'=>WCEX_SLIDE_SHOWCASE_VERSION); | |
| 3042 | - if( defined('WCEX_WIDGET_CART_VERSION')) | |
| 3043 | - $wcex['WIDGET_CART'] = array('name'=>'Widget Cart', 'version'=>WCEX_WIDGET_CART_VERSION); | |
| 3044 | - | |
| 3045 | - return $wcex; | |
| 3046 | -} | |
| 3047 | - | |
| 3048 | -function usces_trackPageview_cart($push){ | |
| 3049 | - $push = array(); | |
| 3050 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3051 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_cart'"; | |
| 3052 | - }else{ | |
| 3053 | - $push[] = "'_trackPageview','/wc_cart'"; | |
| 3054 | - } | |
| 3055 | - return $push; | |
| 3056 | -} | |
| 3057 | - | |
| 3058 | -function usces_trackPageview_customer($push){ | |
| 3059 | - $push = array(); | |
| 3060 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3061 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_customer'"; | |
| 3062 | - }else{ | |
| 3063 | - $push[] = "'_trackPageview','/wc_customer'"; | |
| 3064 | - } | |
| 3065 | - return $push; | |
| 3066 | -} | |
| 3067 | - | |
| 3068 | -function usces_trackPageview_delivery($push){ | |
| 3069 | - $push = array(); | |
| 3070 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3071 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_delivery'"; | |
| 3072 | - }else{ | |
| 3073 | - $push[] = "'_trackPageview','/wc_delivery'"; | |
| 3074 | - } | |
| 3075 | - return $push; | |
| 3076 | -} | |
| 3077 | - | |
| 3078 | -function usces_trackPageview_confirm($push){ | |
| 3079 | - $push = array(); | |
| 3080 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3081 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_confirm'"; | |
| 3082 | - }else{ | |
| 3083 | - $push[] = "'_trackPageview','/wc_confirm'"; | |
| 3084 | - } | |
| 3085 | - return $push; | |
| 3086 | -} | |
| 3087 | - | |
| 3088 | -function usces_trackPageview_ordercompletion($push){ | |
| 3089 | - global $usces; | |
| 3090 | - $sesdata = $usces->cart->get_entry(); | |
| 3091 | - $order_id = $sesdata['order']['ID']; | |
| 3092 | - $data = $usces->get_order_data($order_id, 'direct'); | |
| 3093 | - $cart = unserialize($data['order_cart']); | |
| 3094 | - $total_price = $usces->get_total_price( $cart ) + $data['order_discount'] - $data['order_usedpoint']; | |
| 3095 | - | |
| 3096 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3097 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_ordercompletion'"; | |
| 3098 | - }else{ | |
| 3099 | - $push[] = "'_trackPageview','/wc_ordercompletion'"; | |
| 3100 | - } | |
| 3101 | - $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() . "'"; | |
| 3102 | - for($i=0; $i<count($cart); $i++) { | |
| 3103 | - $cart_row = $cart[$i]; | |
| 3104 | - $post_id = $cart_row['post_id']; | |
| 3105 | - $sku = urldecode($cart_row['sku']); | |
| 3106 | - $quantity = $cart_row['quantity']; | |
| 3107 | -// $options = $cart_row['options']; | |
| 3108 | -// $advance = $usces->cart->wc_serialize($cart_row['advance']); | |
| 3109 | -// $itemCode = $usces->getItemCode($post_id); | |
| 3110 | - $itemName = $usces->getItemName($post_id); | |
| 3111 | -// $cartItemName = $usces->getCartItemName($post_id, $sku); | |
| 3112 | - $skuPrice = $cart_row['price']; | |
| 3113 | - $cats = $usces->get_item_cat_genre_ids( $post_id ); | |
| 3114 | - if( is_array($cats) ) | |
| 3115 | - sort($cats); | |
| 3116 | - $category = ( isset($cats[0]) ) ? get_cat_name($cats[0]): ''; | |
| 3117 | - $push[] = "'_addItem', '" . $order_id . "', '" . $sku . "', '" . $itemName . "', '" . $category . "', '" . $skuPrice . "', '" . $quantity . "'"; | |
| 3118 | - } | |
| 3119 | - $push[] = "'_trackTrans'"; | |
| 3120 | - | |
| 3121 | - return $push; | |
| 3122 | -} | |
| 3123 | - | |
| 3124 | -function usces_trackPageview_error($push){ | |
| 3125 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3126 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_error'"; | |
| 3127 | - }else{ | |
| 3128 | - $push[] = "'_trackPageview','/wc_error'"; | |
| 3129 | - } | |
| 3130 | - return $push; | |
| 3131 | -} | |
| 3132 | - | |
| 3133 | -function usces_trackPageview_member($push){ | |
| 3134 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3135 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_member'"; | |
| 3136 | - }else{ | |
| 3137 | - $push[] = "'_trackPageview','/wc_member'"; | |
| 3138 | - } | |
| 3139 | - return $push; | |
| 3140 | -} | |
| 3141 | - | |
| 3142 | -function usces_trackPageview_login($push){ | |
| 3143 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3144 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_login'"; | |
| 3145 | - }else{ | |
| 3146 | - $push[] = "'_trackPageview','/wc_login'"; | |
| 3147 | - } | |
| 3148 | - return $push; | |
| 3149 | -} | |
| 3150 | - | |
| 3151 | -function usces_trackPageview_editmemberform($push){ | |
| 3152 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3153 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_editmemberform'"; | |
| 3154 | - }else{ | |
| 3155 | - $push[] = "'_trackPageview','/wc_editmemberform'"; | |
| 3156 | - } | |
| 3157 | - return $push; | |
| 3158 | -} | |
| 3159 | - | |
| 3160 | -function usces_trackPageview_newcompletion($push){ | |
| 3161 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3162 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newcompletion'"; | |
| 3163 | - }else{ | |
| 3164 | - $push[] = "'_trackPageview','/wc_newcompletion'"; | |
| 3165 | - } | |
| 3166 | - return $push; | |
| 3167 | -} | |
| 3168 | - | |
| 3169 | -function usces_trackPageview_newmemberform($push){ | |
| 3170 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3171 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newmemberform'"; | |
| 3172 | - }else{ | |
| 3173 | - $push[] = "'_trackPageview','/wc_newmemberform'"; | |
| 3174 | - } | |
| 3175 | - return $push; | |
| 3176 | -} | |
| 3177 | - | |
| 3178 | -function usces_trackPageview_deletemember($push){ | |
| 3179 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3180 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_deletemember'"; | |
| 3181 | - }else{ | |
| 3182 | - $push[] = "'_trackPageview','/wc_deletemember'"; | |
| 3183 | - } | |
| 3184 | - return $push; | |
| 3185 | -} | |
| 3186 | - | |
| 3187 | -function usces_trackPageview_search_item($push){ | |
| 3188 | - if(defined('USCES_KEY') && defined('USCES_MULTI') && true == USCES_MULTI){ | |
| 3189 | - $push[] = "'_trackPageview','/" . USCES_KEY . "wc_search_item'"; | |
| 3190 | - }else{ | |
| 3191 | - $push[] = "'_trackPageview','/wc_search_item'"; | |
| 3192 | - } | |
| 3193 | - return $push; | |
| 3194 | -} | |
| 3195 | - | |
| 3196 | -function usces_get_essential_mark( $fielde, $data = NULL ){ | |
| 3197 | - global $usces_essential_mark; | |
| 3198 | - do_action('usces_action_essential_mark', $data, $fielde); | |
| 3199 | - return $usces_essential_mark[$fielde]; | |
| 3200 | -} | |
| 3201 | - | |
| 3202 | -function uesces_get_admin_addressform( $type, $data, $customdata, $out = 'return' ){ | |
| 3203 | - global $usces, $usces_settings; | |
| 3204 | - $options = get_option('usces'); | |
| 3205 | - $applyform = usces_get_apply_addressform($options['system']['addressform']); | |
| 3206 | - $formtag = ''; | |
| 3207 | - switch( $type ){ | |
| 3208 | - case 'member': | |
| 3209 | - $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']); | |
| 3210 | - $country = $usces->get_member_meta_value('customer_country', $data['ID']); | |
| 3211 | - $values['country'] = !empty($country) ? $country : usces_get_local_addressform(); | |
| 3212 | - break; | |
| 3213 | - case 'customer': | |
| 3214 | - $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']); | |
| 3215 | - $country = $usces->get_order_meta_value('customer_country', $data['ID']); | |
| 3216 | - $values['country'] = !empty($country) ? $country : usces_get_local_addressform(); | |
| 3217 | - break; | |
| 3218 | - case 'delivery': | |
| 3219 | - $values = $data; | |
| 3220 | - break; | |
| 3221 | - } | |
| 3222 | - | |
| 3223 | - switch ($applyform){ | |
| 3224 | - | |
| 3225 | - case 'JP': | |
| 3226 | - //20100818ysk start | |
| 3227 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return'); | |
| 3228 | - //20100818ysk end | |
| 3229 | - $formtag .= ' | |
| 3230 | - <tr> | |
| 3231 | - <td class="label">' . __('name', 'usces') . '</td> | |
| 3232 | - <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> | |
| 3233 | - </tr> | |
| 3234 | - <tr> | |
| 3235 | - <td class="label">' . __('furigana', 'usces') . '</td> | |
| 3236 | - <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> | |
| 3237 | - </tr>'; | |
| 3238 | - //20100818ysk start | |
| 3239 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return'); | |
| 3240 | - //20100818ysk end | |
| 3241 | - $formtag .= ' | |
| 3242 | - <tr> | |
| 3243 | - <td class="label">' . __('Zip/Postal Code', 'usces') . '</td> | |
| 3244 | - <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> | |
| 3245 | - </tr> | |
| 3246 | - <tr> | |
| 3247 | - <td class="label">' . __('Country', 'usces') . '</td> | |
| 3248 | - <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 3249 | - </tr> | |
| 3250 | - <tr> | |
| 3251 | - <td class="label">' . __('Province', 'usces') . '</td> | |
| 3252 | - <td class="col2">'; | |
| 3253 | - | |
| 3254 | - $formtag .= usces_pref_select( $type, $values ); | |
| 3255 | - | |
| 3256 | - $formtag .= '</td> | |
| 3257 | - </tr>'; | |
| 3258 | - $formtag .= ' | |
| 3259 | - <tr> | |
| 3260 | - <td class="label">' . __('city', 'usces') . '</td> | |
| 3261 | - <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td> | |
| 3262 | - </tr> | |
| 3263 | - <tr> | |
| 3264 | - <td class="label">' . __('numbers', 'usces') . '</td> | |
| 3265 | - <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td> | |
| 3266 | - </tr> | |
| 3267 | - <tr> | |
| 3268 | - <td class="label">' . __('building name', 'usces') . '</td> | |
| 3269 | - <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td> | |
| 3270 | - </tr> | |
| 3271 | - <tr> | |
| 3272 | - <td class="label">' . __('Phone number', 'usces') . '</td> | |
| 3273 | - <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td> | |
| 3274 | - </tr> | |
| 3275 | - <tr> | |
| 3276 | - <td class="label">' . __('FAX number', 'usces') . '</td> | |
| 3277 | - <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td> | |
| 3278 | - </tr>'; | |
| 3279 | - //20100818ysk start | |
| 3280 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return'); | |
| 3281 | - //20100818ysk end | |
| 3282 | - break; | |
| 3283 | - | |
| 3284 | - case 'CN': | |
| 3285 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return'); | |
| 3286 | - $formtag .= ' | |
| 3287 | - <tr> | |
| 3288 | - <td class="label">' . __('name', 'usces') . '</td> | |
| 3289 | - <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> | |
| 3290 | - </tr>'; | |
| 3291 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return'); | |
| 3292 | - $formtag .= ' | |
| 3293 | - <tr> | |
| 3294 | - <td class="label">' . __('Country', 'usces') . '</td> | |
| 3295 | - <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 3296 | - </tr> | |
| 3297 | - <tr> | |
| 3298 | - <td class="label">' . __('State', 'usces') . '</td> | |
| 3299 | - <td class="col2">'; | |
| 3300 | - | |
| 3301 | - $formtag .= usces_pref_select( $type, $values ); | |
| 3302 | - | |
| 3303 | - $formtag .= '</td> | |
| 3304 | - </tr>'; | |
| 3305 | - $formtag .= '<tr> | |
| 3306 | - <td class="label">' . __('city', 'usces') . '</td> | |
| 3307 | - <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td> | |
| 3308 | - </tr> | |
| 3309 | - <tr> | |
| 3310 | - <td class="label">' . __('Address Line1', 'usces') . '</td> | |
| 3311 | - <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td> | |
| 3312 | - </tr> | |
| 3313 | - <tr> | |
| 3314 | - <td class="label">' . __('Address Line2', 'usces') . '</td> | |
| 3315 | - <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td> | |
| 3316 | - </tr> | |
| 3317 | - <tr> | |
| 3318 | - <td class="label">' . __('Zip', 'usces') . '</td> | |
| 3319 | - <td class="col2"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" /></td> | |
| 3320 | - </tr> | |
| 3321 | - <tr> | |
| 3322 | - <td class="label">' . __('Phone number', 'usces') . '</td> | |
| 3323 | - <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td> | |
| 3324 | - </tr> | |
| 3325 | - <tr> | |
| 3326 | - <td class="label">' . __('FAX number', 'usces') . '</td> | |
| 3327 | - <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td> | |
| 3328 | - </tr>'; | |
| 3329 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return'); | |
| 3330 | - break; | |
| 3331 | - | |
| 3332 | - case 'US': | |
| 3333 | - default: | |
| 3334 | - //20100818ysk start | |
| 3335 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_pre', 'return'); | |
| 3336 | - //20100818ysk end | |
| 3337 | - $formtag .= ' | |
| 3338 | - <tr> | |
| 3339 | - <td class="label">' . __('name', 'usces') . '</td> | |
| 3340 | - <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> | |
| 3341 | - </tr>'; | |
| 3342 | - //20100818ysk start | |
| 3343 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'name_after', 'return'); | |
| 3344 | - //20100818ysk end | |
| 3345 | - $formtag .= ' | |
| 3346 | - <tr> | |
| 3347 | - <td class="label">' . __('Address Line1', 'usces') . '</td> | |
| 3348 | - <td class="col2"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" /></td> | |
| 3349 | - </tr> | |
| 3350 | - <tr> | |
| 3351 | - <td class="label">' . __('Address Line2', 'usces') . '</td> | |
| 3352 | - <td class="col2"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr($values['address3']) . '" /></td> | |
| 3353 | - </tr> | |
| 3354 | - <tr> | |
| 3355 | - <td class="label">' . __('city', 'usces') . '</td> | |
| 3356 | - <td class="col2"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" /></td> | |
| 3357 | - </tr> | |
| 3358 | - <tr> | |
| 3359 | - <td class="label">' . __('State', 'usces') . '</td> | |
| 3360 | - <td class="col2">'; | |
| 3361 | - | |
| 3362 | - $formtag .= usces_pref_select( $type, $values ); | |
| 3363 | - | |
| 3364 | - $formtag .= '</td> | |
| 3365 | - </tr>'; | |
| 3366 | - $formtag .= ' | |
| 3367 | - <tr> | |
| 3368 | - <td class="label">' . __('Country', 'usces') . '</td> | |
| 3369 | - <td class="col2">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 3370 | - </tr> | |
| 3371 | - <tr> | |
| 3372 | - <td class="label">' . __('Zip', 'usces') . '</td> | |
| 3373 | - <td class="col2"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" /></td> | |
| 3374 | - </tr> | |
| 3375 | - <tr> | |
| 3376 | - <td class="label">' . __('Phone number', 'usces') . '</td> | |
| 3377 | - <td class="col2"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr($values['tel']) . '" /></td> | |
| 3378 | - </tr> | |
| 3379 | - <tr> | |
| 3380 | - <td class="label">' . __('FAX number', 'usces') . '</td> | |
| 3381 | - <td class="col2"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr($values['fax']) . '" /></td> | |
| 3382 | - </tr>'; | |
| 3383 | - //20100818ysk start | |
| 3384 | - $formtag .= usces_admin_custom_field_input($customdata, $type, 'fax_after', 'return'); | |
| 3385 | - //20100818ysk end | |
| 3386 | - break; | |
| 3387 | - } | |
| 3388 | - $res = apply_filters('usces_filter_apply_admin_addressform', $formtag, $type, $data, $customdata); | |
| 3389 | - | |
| 3390 | - | |
| 3391 | - if($out == 'return') { | |
| 3392 | - return $res; | |
| 3393 | - } else { | |
| 3394 | - echo $res; | |
| 3395 | - } | |
| 3396 | -} | |
| 3397 | - | |
| 3398 | -function uesces_get_mail_addressform( $type, $data, $order_id, $out = 'return' ){ | |
| 3399 | - global $wpdb, $usces, $usces_settings; | |
| 3400 | - $options = get_option('usces'); | |
| 3401 | - $applyform = usces_get_apply_addressform($options['system']['addressform']); | |
| 3402 | - | |
| 3403 | - $formtag = ''; | |
| 3404 | - switch( $type ){ | |
| 3405 | - case 'admin_mail_customer': | |
| 3406 | - $values = $data; | |
| 3407 | - $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform(); | |
| 3408 | - $mode = 'customer'; | |
| 3409 | - $name_label = __('Buyer','usces'); | |
| 3410 | - break; | |
| 3411 | - case 'admin_mail': | |
| 3412 | - $values = $data; | |
| 3413 | - $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform(); | |
| 3414 | - $mode = 'delivery'; | |
| 3415 | - $name_label = __('A destination name','usces'); | |
| 3416 | - break; | |
| 3417 | - case 'order_mail_customer': | |
| 3418 | - $values = $data['customer']; | |
| 3419 | - $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform(); | |
| 3420 | - $mode = 'customer'; | |
| 3421 | - $name_label = __('Buyer','usces'); | |
| 3422 | - break; | |
| 3423 | - case 'order_mail': | |
| 3424 | - $values = $data['delivery']; | |
| 3425 | - $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform(); | |
| 3426 | - $mode = 'delivery'; | |
| 3427 | - $name_label = __('A destination name','usces'); | |
| 3428 | - break; | |
| 3429 | - } | |
| 3430 | - | |
| 3431 | - switch ($applyform){ | |
| 3432 | - | |
| 3433 | - case 'JP': | |
| 3434 | - //20110118ysk start | |
| 3435 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id ); | |
| 3436 | - //20110118ysk end | |
| 3437 | - //20131129_kitamu_start | |
| 3438 | - if( $type == 'order_mail_customer' or $type == 'admin_mail_customer' ){ | |
| 3439 | - $usces_order_table = $wpdb->prefix . "usces_order"; | |
| 3440 | - $order_data = $wpdb->get_results( $wpdb->prepare("SELECT mem_id,order_email FROM $usces_order_table WHERE ID = %d LIMIT 1", $order_id ) ); | |
| 3441 | - $mem_id = $order_data[0]->mem_id; | |
| 3442 | - $order_email = $order_data[0]->order_email; | |
| 3443 | - | |
| 3444 | - $formtag .= ( !empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . "\t\t: " . $mem_id . "\r\n" : ''; | |
| 3445 | - $formtag .= ( !empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . "\t\t: " . $order_email . "\r\n" : ''; | |
| 3446 | - } | |
| 3447 | - //20131129_kitamu_end | |
| 3448 | - $formtag .= $name_label . "\t\t: " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name1'] . ' ' . $values['name2'])) . " \r\n"; | |
| 3449 | - if( !empty($values['name3']) || !empty($values['name4']) ) { | |
| 3450 | - $formtag .= __('furigana','usces') . "\t\t: " . $values['name3'] . ' ' . $values['name4'] . " \r\n"; | |
| 3451 | - } | |
| 3452 | - //20110118ysk start | |
| 3453 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id ); | |
| 3454 | - //20110118ysk end | |
| 3455 | - //20131213_kitamu_start | |
| 3456 | - if( count( $options['system']['target_market'] ) != 1 ){ | |
| 3457 | - $formtag .= __('Country','usces') . "\t\t\t: " . $usces_settings['country'][$values['country']] . "\r\n"; | |
| 3458 | - } | |
| 3459 | - //20131213_kitamu_end | |
| 3460 | - $formtag .= __('Zip/Postal Code','usces') . "\t\t: " . $values['zipcode'] . "\r\n"; | |
| 3461 | - $formtag .= __('Address','usces') . "\t\t\t: " . $values['pref'] . $values['address1'] . $values['address2'] . " " . $values['address3'] . "\r\n"; | |
| 3462 | - $formtag .= __('Phone number','usces') . "\t\t: " . $values['tel'] . "\r\n"; | |
| 3463 | - $formtag .= __('FAX number','usces') . "\t\t: " . $values['fax'] . "\r\n"; | |
| 3464 | - //20110118ysk start | |
| 3465 | - $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id ); | |
| 3466 | - //20110118ysk end | |
| 3467 | - break; | |
| 3468 | - | |
| 3469 | - case 'CN': | |
| 3470 | - //20110118ysk start | |
| 3471 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id ); | |
| 3472 | - //20110118ysk end | |
| 3473 | - //20131129_kitamu_start | |
| 3474 | - if( $type == 'order_mail_customer' or $type == 'admin_mail_customer' ){ | |
| 3475 | - $usces_order_table = $wpdb->prefix . "usces_order"; | |
| 3476 | - $order_data = $wpdb->get_results( $wpdb->prepare("SELECT mem_id,order_email FROM $usces_order_table WHERE ID = %d LIMIT 1", $order_id ) ); | |
| 3477 | - $mem_id = $order_data[0]->mem_id; | |
| 3478 | - $order_email = $order_data[0]->order_email; | |
| 3479 | - | |
| 3480 | - $formtag .= ( !empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . "\t\t: " . $mem_id . "\r\n" : ''; | |
| 3481 | - $formtag .= ( !empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . "\t\t: " . $order_email . "\r\n" : ''; | |
| 3482 | - } | |
| 3483 | - //20131129_kitamu_end | |
| 3484 | - $formtag .= $name_label . "\t\t: " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name1'] . ' ' . $values['name2'])) . " \r\n"; | |
| 3485 | - //20110118ysk start | |
| 3486 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id ); | |
| 3487 | - //20110118ysk end | |
| 3488 | - //20131213_kitamu_start | |
| 3489 | - if( count( $options['system']['target_market'] ) != 1 ){ | |
| 3490 | - $formtag .= __('Country','usces') . " : " . $usces_settings['country'][$values['country']] . "\r\n"; | |
| 3491 | - } | |
| 3492 | - //20131213_kitamu_end | |
| 3493 | - $formtag .= __('State','usces') . " : " . $values['pref'] . "\r\n"; | |
| 3494 | - $formtag .= __('City','usces') . " : " . $values['address1'] . "\r\n"; | |
| 3495 | - $formtag .= __('Address','usces') . " : " . $values['address2'] . " " . $values['address3'] . "\r\n"; | |
| 3496 | - $formtag .= __('Zip/Postal Code','usces') . " : " . $values['zipcode'] . "\r\n"; | |
| 3497 | - $formtag .= __('Phone number','usces') . " : " . $values['tel'] . "\r\n"; | |
| 3498 | - $formtag .= __('FAX number','usces') . " : " . $values['fax'] . "\r\n"; | |
| 3499 | - //20110118ysk start | |
| 3500 | - $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id ); | |
| 3501 | - //20110118ysk end | |
| 3502 | - break; | |
| 3503 | - | |
| 3504 | - case 'US': | |
| 3505 | - default: | |
| 3506 | - //20110118ysk start | |
| 3507 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_pre', $order_id ); | |
| 3508 | - //20110118ysk end | |
| 3509 | - //20131129_kitamu_start | |
| 3510 | - if( $type == 'order_mail_customer' or $type == 'admin_mail_customer' ){ | |
| 3511 | - $usces_order_table = $wpdb->prefix . "usces_order"; | |
| 3512 | - $order_data = $wpdb->get_results( $wpdb->prepare("SELECT mem_id,order_email FROM $usces_order_table WHERE ID = %d LIMIT 1", $order_id ) ); | |
| 3513 | - $mem_id = $order_data[0]->mem_id; | |
| 3514 | - $order_email = $order_data[0]->order_email; | |
| 3515 | - | |
| 3516 | - $formtag .= ( !empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . "\t\t: " . $mem_id . "\r\n" : ''; | |
| 3517 | - $formtag .= ( !empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . "\t\t: " . $order_email . "\r\n" : ''; | |
| 3518 | - } | |
| 3519 | - //20131129_kitamu_end | |
| 3520 | - $formtag .= $name_label . " : " . sprintf(__('Mr/Mrs %s', 'usces'), ($values['name2'] . ' ' . $values['name1'])) . " \r\n"; | |
| 3521 | - //20110118ysk start | |
| 3522 | - $formtag .= usces_mail_custom_field_info( $mode, 'name_after', $order_id ); | |
| 3523 | - //20110118ysk end | |
| 3524 | - $formtag .= __('Address','usces') . " : " . $values['address2'] . " " . $values['address3'] . "\r\n"; | |
| 3525 | - $formtag .= __('City','usces') . " : " . $values['address1'] . "\r\n"; | |
| 3526 | - $formtag .= __('State','usces') . " : " . $values['pref'] . "\r\n"; | |
| 3527 | - | |
| 3528 | - //20131213_kitamu_start | |
| 3529 | - if( count( $options['system']['target_market'] ) != 1 ){ | |
| 3530 | - $formtag .= __('Country','usces') . " : " . $usces_settings['country'][$values['country']] . "\r\n"; | |
| 3531 | - } | |
| 3532 | - //20131213_kitamu_end | |
| 3533 | - $formtag .= __('Zip/Postal Code','usces') . " : " . $values['zipcode'] . "\r\n"; | |
| 3534 | - $formtag .= __('Phone number','usces') . " : " . $values['tel'] . "\r\n"; | |
| 3535 | - $formtag .= __('FAX number','usces') . " : " . $values['fax'] . "\r\n"; | |
| 3536 | - //20110118ysk start | |
| 3537 | - $formtag .= usces_mail_custom_field_info( $mode, 'fax_after', $order_id ); | |
| 3538 | - //20110118ysk end | |
| 3539 | - break; | |
| 3540 | - } | |
| 3541 | - $res = apply_filters('usces_filter_apply_mail_addressform', $formtag, $type, $data, $order_id); | |
| 3542 | - | |
| 3543 | - | |
| 3544 | - if($out == 'return') { | |
| 3545 | - return $res; | |
| 3546 | - } else { | |
| 3547 | - echo $res; | |
| 3548 | - } | |
| 3549 | -} | |
| 3550 | - | |
| 3551 | -function uesces_get_target_market_form( $type, $selected, $out = 'return' ){ | |
| 3552 | - global $usces_settings; | |
| 3553 | - $options = get_option('usces'); | |
| 3554 | - $res = '<select name="' . $type . '[country]" id="' . $type . '_country">'."\n"; | |
| 3555 | - foreach ( $usces_settings['country'] as $key => $value ){ | |
| 3556 | - if( in_array($key, $options['system']['target_market']) ) | |
| 3557 | - $res .= '<option value="' . $key . '"' . ($selected == $key ? ' selected="selected"' : '') . '>' . $value . "</option>\n"; | |
| 3558 | - } | |
| 3559 | - $res .= '</select>'."\n"; | |
| 3560 | - | |
| 3561 | - if($out == 'return') { | |
| 3562 | - return $res; | |
| 3563 | - } else { | |
| 3564 | - echo $res; | |
| 3565 | - } | |
| 3566 | -} | |
| 3567 | - | |
| 3568 | -function usces_pref_select( $type, $values, $out = 'return' ){ | |
| 3569 | - global $usces, $usces_states; | |
| 3570 | - | |
| 3571 | -//20110513ysk start | |
| 3572 | - //$country = empty($values['country']) ? usces_get_local_addressform() : $values['country']; | |
| 3573 | - $country = empty($values['country']) ? usces_get_base_country() : $values['country']; | |
| 3574 | - $options = get_option('usces'); | |
| 3575 | - if( !in_array($country, $options['system']['target_market']) ) | |
| 3576 | - $country = $options['system']['target_market'][0]; | |
| 3577 | -//20110513ysk end | |
| 3578 | -//20110331ysk start | |
| 3579 | - //$prefs = $usces_states[$country]; | |
| 3580 | - $prefs = get_usces_states($country); | |
| 3581 | -//20110331ysk end | |
| 3582 | - $html = '<select name="' . esc_attr($type . '[pref]') . '" id="' . esc_attr($type) . '_pref" class="pref">'; | |
| 3583 | -//20120123ysk start 0000386 | |
| 3584 | - //foreach((array)$prefs as $pref) | |
| 3585 | - // $html .= "\t".'<option value="' . esc_attr($pref) . '"' . ($pref == $values['pref'] ? ' selected="selected"' : '') . '>' . esc_html($pref) . "</option>\n"; | |
| 3586 | - $prefs_count = count($prefs); | |
| 3587 | - if($prefs_count > 0) { | |
| 3588 | - $select = __('-- Select --', 'usces'); | |
| 3589 | - $html .= "\t".'<option value="' . esc_attr($select) . '">' . esc_html($select) . "</option>\n"; | |
| 3590 | - for($i = 1; $i < $prefs_count; $i++) | |
| 3591 | - $html .= "\t".'<option value="' . esc_attr($prefs[$i]) . '"' . ($prefs[$i] == $values['pref'] ? ' selected="selected"' : '') . '>' . esc_html($prefs[$i]) . "</option>\n"; | |
| 3592 | - } | |
| 3593 | -//20120123ysk end | |
| 3594 | - $html .= "</select>\n"; | |
| 3595 | - | |
| 3596 | - if( $out == 'return' ){ | |
| 3597 | - return $html; | |
| 3598 | - }else{ | |
| 3599 | - echo $html; | |
| 3600 | - } | |
| 3601 | -} | |
| 3602 | - | |
| 3603 | -function usces_is_member_system(){ | |
| 3604 | - global $usces; | |
| 3605 | - if($usces->options['membersystem_state'] == 'activate') | |
| 3606 | - return true; | |
| 3607 | - else | |
| 3608 | - return false; | |
| 3609 | -} | |
| 3610 | - | |
| 3611 | -function usces_is_member_system_point(){ | |
| 3612 | - global $usces; | |
| 3613 | - if($usces->options['membersystem_point'] == 'activate') | |
| 3614 | - return true; | |
| 3615 | - else | |
| 3616 | - return false; | |
| 3617 | -} | |
| 3618 | - | |
| 3619 | -function usces_shipping_country_option( $selected, $out = '' ){ | |
| 3620 | - global $usces_settings; | |
| 3621 | - $options = get_option('usces'); | |
| 3622 | - $res = ''; | |
| 3623 | - foreach ( $usces_settings['country'] as $key => $value ){ | |
| 3624 | - if( in_array($key, $options['system']['target_market']) ) | |
| 3625 | - $res .= '<option value="' . $key . '"' . ($selected == $key ? ' selected="selected"' : '') . '>' . $value . "</option>\n"; | |
| 3626 | - } | |
| 3627 | -//20110317ysk start | |
| 3628 | - //$res .= '<option value="world_wide"' . ($selected == $key ? ' selected="selected"' : '') . '>World Wide' . "</option>\n"; | |
| 3629 | -//20110317ysk end | |
| 3630 | - echo $res; | |
| 3631 | -} | |
| 3632 | - | |
| 3633 | -function usces_get_cart_button( $out = '' ) { | |
| 3634 | - global $usces; | |
| 3635 | - $res = ''; | |
| 3636 | - | |
| 3637 | - if($usces->use_js){ | |
| 3638 | - $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();"') . ' /> '; | |
| 3639 | - if( usces_is_cart() ) { | |
| 3640 | - $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __(' Next ','usces') . '"' . apply_filters('usces_filter_cart_nextbutton', ' onclick="return uscesCart.cartNext();"') . ' />'; | |
| 3641 | - } | |
| 3642 | - }else{ | |
| 3643 | - $res .= '<a href="' . get_home_url() . '" class="continue_shopping_button">' . __('continue shopping','usces') . '</a> '; | |
| 3644 | - if( usces_is_cart() ) { | |
| 3645 | - $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __(' Next ','usces') . '"' . apply_filters('usces_filter_cart_nextbutton', NULL) . ' />'; | |
| 3646 | - } | |
| 3647 | - } | |
| 3648 | - $res = apply_filters('usces_filter_get_cart_button', $res); | |
| 3649 | - | |
| 3650 | - if($out == 'return'){ | |
| 3651 | - return $res; | |
| 3652 | - }else{ | |
| 3653 | - echo $res; | |
| 3654 | - } | |
| 3655 | -} | |
| 3656 | - | |
| 3657 | -function usces_get_customer_button( $out = '' ) { | |
| 3658 | - global $usces, $member_regmode; | |
| 3659 | - $res = ''; | |
| 3660 | - | |
| 3661 | - $res = '<input name="backCart" type="submit" class="back_cart_button" value="'.__('Back', 'usces').'" /> '; | |
| 3662 | - | |
| 3663 | - $button = '<input name="deliveryinfo" type="submit" class="to_deliveryinfo_button" value="'.__(' Next ', 'usces').'" /> '; | |
| 3664 | - $res .= apply_filters('usces_filter_customer_button', $button); | |
| 3665 | - | |
| 3666 | - if(usces_is_membersystem_state() && $member_regmode != 'editmemberfromcart' && usces_is_login() == false ){ | |
| 3667 | - $res .= '<input name="reganddeliveryinfo" type="submit" class="to_reganddeliveryinfo_button" value="'.__('To the next while enrolling', 'usces').'"' . apply_filters('usces_filter_customerinfo_prebutton', NULL) . ' />'; | |
| 3668 | - }elseif(usces_is_membersystem_state() && $member_regmode == 'editmemberfromcart' ){ | |
| 3669 | - $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) . ' />'; | |
| 3670 | - } | |
| 3671 | - | |
| 3672 | - $res = apply_filters('usces_filter_get_customer_button', $res); | |
| 3673 | - | |
| 3674 | - if($out == 'return'){ | |
| 3675 | - return $res; | |
| 3676 | - }else{ | |
| 3677 | - echo $res; | |
| 3678 | - } | |
| 3679 | -} | |
| 3680 | - | |
| 3681 | -function usces_delivery_secure_form( $out = '' ) { | |
| 3682 | - global $usces, $usces_entries, $usces_carts; | |
| 3683 | - $html = ''; | |
| 3684 | - include( USCES_PLUGIN_DIR . "/includes/delivery_secure_form.php"); | |
| 3685 | - | |
| 3686 | - if($out == 'return'){ | |
| 3687 | - return $html; | |
| 3688 | - }else{ | |
| 3689 | - echo $html; | |
| 3690 | - } | |
| 3691 | -} | |
| 3692 | - | |
| 3693 | -function usces_delivery_info_script( $out ='' ){ | |
| 3694 | - global $usces, $usces_entries, $usces_carts; | |
| 3695 | - $html = ''; | |
| 3696 | - include( USCES_PLUGIN_DIR . "/includes/delivery_info_script.php"); | |
| 3697 | - | |
| 3698 | - if($out == 'return'){ | |
| 3699 | - return $html; | |
| 3700 | - }else{ | |
| 3701 | - echo $html; | |
| 3702 | - } | |
| 3703 | -} | |
| 3704 | - | |
| 3705 | -function usces_get_entries(){ | |
| 3706 | - global $usces, $usces_entries; | |
| 3707 | - $usces_entries = $usces->cart->get_entry(); | |
| 3708 | -} | |
| 3709 | - | |
| 3710 | -function usces_get_carts(){ | |
| 3711 | - global $usces, $usces_carts; | |
| 3712 | - $usces_carts = $usces->cart->get_cart(); | |
| 3713 | -} | |
| 3714 | - | |
| 3715 | -function usces_get_members(){ | |
| 3716 | - global $usces, $usces_members; | |
| 3717 | - $usces_members = $usces->get_member(); | |
| 3718 | -} | |
| 3719 | - | |
| 3720 | -function usces_error_message( $out = ''){ | |
| 3721 | - global $usces; | |
| 3722 | - | |
| 3723 | - if($out == 'return'){ | |
| 3724 | - return $usces->error_message; | |
| 3725 | - }else{ | |
| 3726 | - echo $usces->error_message; | |
| 3727 | - } | |
| 3728 | -} | |
| 3729 | - | |
| 3730 | -function usces_url( $type, $out = ''){ | |
| 3731 | - global $usces; | |
| 3732 | - | |
| 3733 | - switch ( $type ){ | |
| 3734 | - case 'cart': | |
| 3735 | - $url = USCES_CART_URL; | |
| 3736 | - break; | |
| 3737 | - case 'login': | |
| 3738 | - $url = USCES_LOGIN_URL; | |
| 3739 | - break; | |
| 3740 | - case 'member': | |
| 3741 | - $url = USCES_MEMBER_URL; | |
| 3742 | - break; | |
| 3743 | - case 'newmember': | |
| 3744 | - $url = USCES_NEWMEMBER_URL; | |
| 3745 | - break; | |
| 3746 | - case 'lostmemberpassword': | |
| 3747 | - $url = USCES_LOSTMEMBERPASSWORD_URL; | |
| 3748 | - break; | |
| 3749 | - case 'cartnonsession': | |
| 3750 | - $url = USCES_CART_NONSESSION_URL; | |
| 3751 | - break; | |
| 3752 | - } | |
| 3753 | - | |
| 3754 | - if($out == 'return'){ | |
| 3755 | - return $url; | |
| 3756 | - }else{ | |
| 3757 | - echo $url; | |
| 3758 | - } | |
| 3759 | -} | |
| 3760 | - | |
| 3761 | -function usces_total_price( $out = ''){ | |
| 3762 | - global $usces; | |
| 3763 | - | |
| 3764 | - if($out == 'return'){ | |
| 3765 | - return $usces->get_total_price(); | |
| 3766 | - }else{ | |
| 3767 | - echo $usces->get_total_price(); | |
| 3768 | - } | |
| 3769 | -} | |
| 3770 | - | |
| 3771 | -function usces_completion_settlement( $out ='' ){ | |
| 3772 | - global $usces, $usces_entries; | |
| 3773 | - $html = ''; | |
| 3774 | - | |
| 3775 | - $template = apply_filters( 'usces_filter_completion_settlement', USCES_PLUGIN_DIR . "/includes/completion_settlement.php", $usces_entries ); | |
| 3776 | - require( $template ); | |
| 3777 | - | |
| 3778 | - if($out == 'return'){ | |
| 3779 | - return $html; | |
| 3780 | - }else{ | |
| 3781 | - echo $html; | |
| 3782 | - } | |
| 3783 | -} | |
| 3784 | - | |
| 3785 | -function usces_purchase_button( $out ='' ){ | |
| 3786 | - global $usces, $usces_entries; | |
| 3787 | - $html = ''; | |
| 3788 | - include( USCES_PLUGIN_DIR . "/includes/purchase_button.php"); | |
| 3789 | - | |
| 3790 | - if($out == 'return'){ | |
| 3791 | - return $html; | |
| 3792 | - }else{ | |
| 3793 | - echo $html; | |
| 3794 | - } | |
| 3795 | -} | |
| 3796 | - | |
| 3797 | -function usces_get_member_regmode(){ | |
| 3798 | - global $member_regmode; | |
| 3799 | - $member_regmode = isset( $_SESSION['usces_entry']['member_regmode'] ) ? $_SESSION['usces_entry']['member_regmode'] : 'none'; | |
| 3800 | -} | |
| 3801 | - | |
| 3802 | -function uesces_get_error_settlement( $out = '' ) { | |
| 3803 | - $res = ''; | |
| 3804 | - if( isset($_REQUEST['acting']) && ('zeus_conv' == $_REQUEST['acting'] || 'zeus_card' == $_REQUEST['acting'] || 'zeus_bank' == $_REQUEST['acting'] ) ){ //ZEUS | |
| 3805 | - $res .= '<div class="support_box">'; | |
| 3806 | - if( isset($_GET['code']) ){ | |
| 3807 | - $res .= ' <br />エラーコード:' . esc_html($_GET['code']); | |
| 3808 | - if( in_array($_GET['code'], array('02130514', '02130517', '02130619', '02130620', '02130621', '02130640')) ){ | |
| 3809 | - $res .= '<br />カード番号が正しくないようです。'; | |
| 3810 | - }elseif( in_array($_GET['code'], array('02130714', '02130717', '02130725', '02130814', '02130817', '02130825')) ){ | |
| 3811 | - $res .= '<br />カードの有効期限が正しくないようです。'; | |
| 3812 | - }elseif( in_array($_GET['code'], array('02130922')) ){ | |
| 3813 | - $res .= '<br />カードの有効期限が切れているようです。'; | |
| 3814 | - }elseif( in_array($_GET['code'], array('02131117', '02131123', '02131124')) ){ | |
| 3815 | - $res .= '<br />カードの名義が正しくないようです。'; | |
| 3816 | - }elseif( in_array($_GET['code'], array('02131414', '02131417', '02131437')) ){ | |
| 3817 | - $res .= '<br />お客様情報の電話番号が正しくないようです。'; | |
| 3818 | - }elseif( in_array($_GET['code'], array('02131527', '02131528', '02131529', '02131537')) ){ | |
| 3819 | - $res .= '<br />お客様情報のEメールアドレスが正しくないようです。'; | |
| 3820 | - } | |
| 3821 | - $res .= ' <br /> | |
| 3822 | - <br /> | |
| 3823 | - <a href="' . USCES_CUSTOMER_URL . '">もう一度決済を行う>></a><br />'; | |
| 3824 | - }else{ | |
| 3825 | - $res .= ' <br />エラーコード:' . esc_html($_GET['err_code']); | |
| 3826 | - $res .= ' <br /> | |
| 3827 | - カード番号を再入力する場合はこちらをクリックしてください。<br /> | |
| 3828 | - <br /> | |
| 3829 | - <a href="' . USCES_CUSTOMER_URL . '&re-enter=1">カード番号の再入力>></a><br />'; | |
| 3830 | - } | |
| 3831 | - $res .= ' <br /> | |
| 3832 | - ゼウス・カスタマーサポート(24時間365日)<br /> | |
| 3833 | - 電話番号:0570-02-3939(つながらないときは 03-4334-0500)<br /> | |
| 3834 | - E-mail:support@cardservice.co.jp | |
| 3835 | - </div>'."\n"; | |
| 3836 | - } | |
| 3837 | - $res = apply_filters( 'usces_filter_get_error_settlement', $res ); | |
| 3838 | - | |
| 3839 | - if($out == 'return'){ | |
| 3840 | - return $res; | |
| 3841 | - }else{ | |
| 3842 | - echo $res; | |
| 3843 | - } | |
| 3844 | -} | |
| 3845 | - | |
| 3846 | -function usces_page_name( $out = '') { | |
| 3847 | - global $usces; | |
| 3848 | - $page = ''; | |
| 3849 | - | |
| 3850 | - if( empty($usces->page) ){ | |
| 3851 | - if( $usces->is_cart_page($_SERVER['REQUEST_URI']) ){ | |
| 3852 | - $page = 'cart'; | |
| 3853 | - }elseif( $usces->is_member_page($_SERVER['REQUEST_URI']) ){ | |
| 3854 | - $page = 'member'; | |
| 3855 | - } | |
| 3856 | - }else{ | |
| 3857 | - $page = $usces->page; | |
| 3858 | - } | |
| 3859 | - | |
| 3860 | - if($out == 'return'){ | |
| 3861 | - return $page; | |
| 3862 | - }else{ | |
| 3863 | - echo $page; | |
| 3864 | - } | |
| 3865 | -} | |
| 3866 | - | |
| 3867 | -function usces_post_reg_orderdata($order_id, $results){ | |
| 3868 | - global $usces, $wpdb; | |
| 3869 | - $acting = isset($_GET['acting']) ? $_GET['acting'] : ''; | |
| 3870 | - $data = array(); | |
| 3871 | - | |
| 3872 | - if( $order_id ){ | |
| 3873 | - | |
| 3874 | - switch ( $acting ) { | |
| 3875 | - case 'epsilon': | |
| 3876 | - $trans_id = isset($_REQUEST['trans_code']) ? $_REQUEST['trans_code'] : ''; | |
| 3877 | - break; | |
| 3878 | - case 'paypal_ipn': | |
| 3879 | - $trans_id = isset($_REQUEST['txn_id']) ? $_REQUEST['txn_id'] : ''; | |
| 3880 | - break; | |
| 3881 | - case 'paypal': | |
| 3882 | - $trans_id = isset($results['txn_id']) ? $results['txn_id'] : ''; | |
| 3883 | - break; | |
| 3884 | -//20110208ysk start | |
| 3885 | - case 'paypal_ec': | |
| 3886 | - $trans_id = isset($_REQUEST['token']) ? $_REQUEST['token'] : ''; | |
| 3887 | -//20110621ysk start 0000184 | |
| 3888 | - if(isset($results['settlement_id'])) | |
| 3889 | - $usces->set_order_meta_value('settlement_id', $results['settlement_id'], $order_id); | |
| 3890 | - if(isset($results['profile_id'])) | |
| 3891 | - $usces->set_order_meta_value('profile_id', $results['profile_id'], $order_id); | |
| 3892 | -//20110621ysk end | |
| 3893 | - break; | |
| 3894 | -//20110208ysk end | |
| 3895 | - case 'zeus_card': | |
| 3896 | - $acting_opts = $usces->options['acting_settings']['zeus']; | |
| 3897 | - if( isset($_GET['zeussuffix']) ){ | |
| 3898 | - $entry = $usces->cart->get_entry();//20110621ysk 0000184 | |
| 3899 | - $data['acting'] = 'zeus_card Secure API'; | |
| 3900 | - $data['order_number'] = $_GET['zeusordd']; | |
| 3901 | - $data['howpay'] = $entry['order']['howpay']; | |
| 3902 | - | |
| 3903 | - $usces->set_order_meta_value('acting_'.$acting, serialize($data), $order_id); | |
| 3904 | - if( $usces->is_member_logged_in() ){ | |
| 3905 | - //if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge']){ | |
| 3906 | - if( 'on' == $acting_opts['quickcharge']){ | |
| 3907 | - $usces->set_member_meta_value('zeus_pcid', '8888888888888888'); | |
| 3908 | - } | |
| 3909 | - $usces->set_member_meta_value('zeus_partofcard', $_GET['zeussuffix']); | |
| 3910 | - $usces->set_member_meta_value('zeus_limitofcard', ($_GET['zeusyear'].'/'.$_GET['zeusmonth'])); | |
| 3911 | - } | |
| 3912 | - }else{ | |
| 3913 | - $trans_id = isset($_REQUEST['ordd']) ? $_REQUEST['ordd'] : ''; | |
| 3914 | - //foreach($_GET as $key => $value) { | |
| 3915 | - // $data[$key] = esc_sql($value); | |
| 3916 | - //} | |
| 3917 | - //$usces->set_order_meta_value('acting_'.$acting, serialize($data), $order_id); | |
| 3918 | - if( !empty($_REQUEST['order_number']) ) { | |
| 3919 | - $usces->set_order_meta_value( 'order_number', $_REQUEST['order_number'], $order_id ); | |
| 3920 | - } | |
| 3921 | - if( $usces->is_member_logged_in() ) { | |
| 3922 | - if( 'on' == $acting_opts['quickcharge'] ) { | |
| 3923 | - $usces->set_member_meta_value('zeus_pcid', '8888888888888888'); | |
| 3924 | - } | |
| 3925 | - } | |
| 3926 | - } | |
| 3927 | - if(empty($usces)){ | |
| 3928 | - usces_log('zeus card transaction : No Session', 'acting_transaction.log'); | |
| 3929 | - }else{ | |
| 3930 | - usces_log('zeus card transaction : OK', 'acting_transaction.log'); | |
| 3931 | - } | |
| 3932 | - break; | |
| 3933 | - case 'zeus_conv': | |
| 3934 | - $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['sendpoint'] : ''; | |
| 3935 | - $zeus_convs = array( | |
| 3936 | - 'acting' => 'zeus_conv', | |
| 3937 | - 'pay_cvs' => isset($_REQUEST['pay_cvs']) ? $_REQUEST['pay_cvs'] : '', | |
| 3938 | - 'order_no' => isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : '', | |
| 3939 | - 'money' => isset($_REQUEST['money']) ? $_REQUEST['money'] : '', | |
| 3940 | - 'pay_no1' => isset($_REQUEST['pay_no1']) ? $_REQUEST['pay_no1'] : '', | |
| 3941 | - 'pay_no2' => isset($_REQUEST['pay_no2']) ? $_REQUEST['pay_no2'] : '', | |
| 3942 | - 'pay_limit' => isset($_REQUEST['pay_limit']) ? $_REQUEST['pay_limit'] : '', | |
| 3943 | - 'status' => isset($_REQUEST['status']) ? $_REQUEST['status'] : '', | |
| 3944 | - 'error_code' => isset($_REQUEST['error_code']) ? $_REQUEST['error_code'] : '' | |
| 3945 | - ); | |
| 3946 | - $usces->set_order_meta_value('acting_'.(isset($_REQUEST['sendpoint']) ? $_REQUEST['sendpoint'] : ''), serialize($zeus_convs), $order_id); | |
| 3947 | - break; | |
| 3948 | - case 'zeus_bank': | |
| 3949 | - $trans_id = isset($_REQUEST['order_no']) ? $_REQUEST['order_no'] : ''; | |
| 3950 | - break; | |
| 3951 | - case 'remise_card': | |
| 3952 | - $trans_id = isset($_REQUEST['X-TRANID']) ? $_REQUEST['X-TRANID'] : ''; | |
| 3953 | - break; | |
| 3954 | - case 'remise_conv': | |
| 3955 | - $trans_id = isset($_REQUEST['X-JOB_ID']) ? $_REQUEST['X-JOB_ID'] : ''; | |
| 3956 | - break; | |
| 3957 | - case 'jpayment_card': | |
| 3958 | - case 'jpayment_conv': | |
| 3959 | - case 'jpayment_bank': | |
| 3960 | - $trans_id = isset($_REQUEST['gid']) ? $_REQUEST['gid'] : ''; | |
| 3961 | - break; | |
| 3962 | -//20120413ysk start | |
| 3963 | - case 'sbps_card': | |
| 3964 | - case 'sbps_conv': | |
| 3965 | - case 'sbps_payeasy': | |
| 3966 | - case 'sbps_wallet': | |
| 3967 | - case 'sbps_mobile': | |
| 3968 | - $trans_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : ''; | |
| 3969 | - break; | |
| 3970 | -//20120413ysk end | |
| 3971 | -//20120618ysk start | |
| 3972 | - case 'telecom_card': | |
| 3973 | - $trans_id = isset($_REQUEST['sendid']) ? $_REQUEST['sendid'] : ''; | |
| 3974 | - break; | |
| 3975 | -//20120618ysk end | |
| 3976 | -//20121206ysk start | |
| 3977 | - case 'digitalcheck_card': | |
| 3978 | - case 'digitalcheck_conv': | |
| 3979 | - $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : ''; | |
| 3980 | - break; | |
| 3981 | -//20121206ysk end | |
| 3982 | -//20130225ysk start | |
| 3983 | - case 'mizuho_card': | |
| 3984 | - case 'mizuho_conv': | |
| 3985 | - $trans_id = isset($_REQUEST['stran']) ? $_REQUEST['stran'] : ''; | |
| 3986 | - break; | |
| 3987 | -//20130225ysk end | |
| 3988 | - default: | |
| 3989 | - if( isset($_REQUEST['FUKA']) && strstr($_REQUEST['FUKA'], "digitalcheck_card") ) { | |
| 3990 | - $trans_id = isset($_REQUEST['SID']) ? $_REQUEST['SID'] : ''; | |
| 3991 | - } else { | |
| 3992 | - $trans_id = ''; | |
| 3993 | - } | |
| 3994 | - } | |
| 3995 | - | |
| 3996 | - if(!empty($trans_id)) { | |
| 3997 | - $usces->set_order_meta_value('trans_id', $trans_id, $order_id); | |
| 3998 | - } | |
| 3999 | - } | |
| 4000 | - | |
| 4001 | -} | |
| 4002 | - | |
| 4003 | -//20110621ysk start 0000184 | |
| 4004 | -function usces_paypal_doecp( &$results ) { | |
| 4005 | - global $usces; | |
| 4006 | - $entry = $usces->cart->get_entry(); | |
| 4007 | - $cart = $usces->cart->get_cart(); | |
| 4008 | - | |
| 4009 | - $post_id = $cart[0]['post_id']; | |
| 4010 | - $charging_type = $usces->getItemChargingType( $post_id ); | |
| 4011 | - if( 'continue' != $charging_type ) { | |
| 4012 | - //通常購入 | |
| 4013 | - //Format the other parameters that were stored in the session from the previous calls | |
| 4014 | - $paymentAmount = usces_crform($entry['order']['total_full_price'], false, false, 'return', false); | |
| 4015 | - $token = urlencode($_REQUEST['token']); | |
| 4016 | - $paymentType = urlencode("Sale"); | |
| 4017 | - $currencyCodeType = urlencode($usces->get_currency_code()); | |
| 4018 | - $payerID = urlencode($_REQUEST['PayerID']); | |
| 4019 | - $serverName = urlencode($_SERVER['SERVER_NAME']); | |
| 4020 | - | |
| 4021 | - $nvpstr = '&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&IPADDRESS='.$serverName; | |
| 4022 | - $nvpstr = apply_filters( 'usces_filter_usces_paypal_doecp', $nvpstr, $charging_type ); | |
| 4023 | -//20131121ysk start 0000771 | |
| 4024 | - if( 'shipped' == $usces->getItemDivision( $post_id ) ) { | |
| 4025 | - $country = ( !empty($entry['delivery']['country']) ) ? $entry['delivery']['country'] : usces_get_base_country(); | |
| 4026 | - if( 'US' != $country and 'CA' != $country ) {//20140207ysk 0000771 | |
| 4027 | - $nvpstr .= '&SHIPTONAME='.$entry['delivery']['name2'].' '.$entry['delivery']['name1']. | |
| 4028 | - '&SHIPTOSTREET='.$entry['delivery']['address2']. | |
| 4029 | - '&SHIPTOSTREET2='.$entry['delivery']['address3']. | |
| 4030 | - '&SHIPTOCITY='.$entry['delivery']['address1']. | |
| 4031 | - '&SHIPTOSTATE='.$entry['delivery']['pref']. | |
| 4032 | - '&SHIPTOZIP='.$entry['delivery']['zipcode']. | |
| 4033 | - '&SHIPTOCOUNTRYCODE='.$country. | |
| 4034 | - '&SHIPTOPHONENUM='.ltrim( str_replace( '-', '', $entry['delivery']['tel'] ), '0' ); | |
| 4035 | - } | |
| 4036 | - } | |
| 4037 | -//20131121ysk end | |
| 4038 | - $usces->paypal->setMethod('DoExpressCheckoutPayment'); | |
| 4039 | - $usces->paypal->setData($nvpstr); | |
| 4040 | - $res = $usces->paypal->doExpressCheckout(); | |
| 4041 | - $resArray = $usces->paypal->getResponse(); | |
| 4042 | - $ack = strtoupper($resArray["ACK"]); | |
| 4043 | - if( $ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING" ) { | |
| 4044 | - $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. | |
| 4045 | - //$usces->set_order_meta_value('settlement_id', $transactionId, $order_id); | |
| 4046 | - $results['settlement_id'] = $transactionId; | |
| 4047 | - $results['payment_status'] = isset( $resArray["PAYMENTSTATUS"] ) ? $resArray["PAYMENTSTATUS"] : ''; | |
| 4048 | - $results['pending_reason'] = isset( $resArray["PENDINGREASON"] ) ? $resArray["PENDINGREASON"] : ''; | |
| 4049 | - | |
| 4050 | - } else { | |
| 4051 | - //Display a user friendly Error on the page using any of the following error information returned by PayPal | |
| 4052 | - $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); | |
| 4053 | - $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); | |
| 4054 | - $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); | |
| 4055 | - $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); | |
| 4056 | - 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'); | |
| 4057 | - return false; | |
| 4058 | - } | |
| 4059 | - | |
| 4060 | - } else { | |
| 4061 | - if( !apply_filters( 'usces_pre_create_recurring_payments_profile', true ) ) return false; | |
| 4062 | - | |
| 4063 | - //定期支払い | |
| 4064 | - $paymentAmount = usces_crform($entry['order']['total_full_price'], false, false, 'return', false);//20111129ysk 0000320 | |
| 4065 | - $token = urlencode($_REQUEST['token']); | |
| 4066 | - $currencyCodeType = urlencode($usces->get_currency_code()); | |
| 4067 | - //$nextdate = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 4068 | - //$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'; | |
| 4069 | - $profileStartDate = date('Y-m-d', dlseller_first_charging($post_id, 'time')).'T01:01:01Z'; | |
| 4070 | - $billingPeriod = "Month";// or "Day", "Week", "SemiMonth", "Year" | |
| 4071 | - $billingFreq = $usces->getItemFrequency($post_id); | |
| 4072 | - $desc = urlencode(usces_make_agreement_description($cart, $entry['order']['total_full_price']));//20111125ysk 0000320 | |
| 4073 | - $totalBillingCycles = (empty($dlitem['dlseller_interval'])) ? '' : '&TOTALBILLINGCYCLES='.urlencode($dlitem['dlseller_interval']); | |
| 4074 | - //$totalBillingCycles = ( dlseller_auto_stop() ) ? '&TOTALBILLINGCYCLES='.dlseller_cycles( $post_id ) : ''; | |
| 4075 | - | |
| 4076 | - //$nvpstr = '&TOKEN='.$token.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&PROFILESTARTDATE='.$profileStartDate.'&BILLINGPERIOD='.$billingPeriod.'&BILLINGFREQUENCY='.$billingFreq.'&DESC='.$desc; | |
| 4077 | - $nvpstr = '&TOKEN='.$token.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currencyCodeType.'&PROFILESTARTDATE='.$profileStartDate.'&BILLINGPERIOD='.$billingPeriod.'&BILLINGFREQUENCY='.$billingFreq.'&DESC='.$desc.$totalBillingCycles; | |
| 4078 | - $nvpstr = apply_filters( 'usces_filter_usces_paypal_doecp', $nvpstr, $charging_type ); | |
| 4079 | - | |
| 4080 | - $usces->paypal->setMethod('CreateRecurringPaymentsProfile'); | |
| 4081 | - $usces->paypal->setData($nvpstr); | |
| 4082 | - $res = $usces->paypal->doExpressCheckout(); | |
| 4083 | - $resArray = $usces->paypal->getResponse(); | |
| 4084 | - $ack = strtoupper($resArray["ACK"]); | |
| 4085 | - if( $ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING" ) { | |
| 4086 | - $profileid = $resArray["PROFILEID"]; | |
| 4087 | - //$usces->set_order_meta_value('profile_id', $profileid, $order_id); | |
| 4088 | - $results['settlement_id'] = $profileid; | |
| 4089 | - $results['profile_id'] = $profileid; | |
| 4090 | - $results['profile_status'] = isset( $resArray["PROFILESTATUS"] ) ? $resArray["PROFILESTATUS"] : ''; | |
| 4091 | - | |
| 4092 | - } else { | |
| 4093 | - //Display a user friendly Error on the page using any of the following error information returned by PayPal | |
| 4094 | - $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); | |
| 4095 | - $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); | |
| 4096 | - $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); | |
| 4097 | - $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); | |
| 4098 | - 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'); | |
| 4099 | - return false; | |
| 4100 | - } | |
| 4101 | - } | |
| 4102 | - | |
| 4103 | - return true; | |
| 4104 | -} | |
| 4105 | -//20110621ysk end | |
| 4106 | -//20110421ysk start | |
| 4107 | -function usces_make_agreement_description($cart, $amt) { | |
| 4108 | - global $usces; | |
| 4109 | - | |
| 4110 | - $cart_row = $cart[0]; | |
| 4111 | - $quantity = $cart_row['quantity']; | |
| 4112 | - $itemName = $usces->getItemName($cart_row['post_id']); | |
| 4113 | - //if(1 < count($cart)) $itemName .= ','.__('Others', 'usces'); | |
| 4114 | - if(50 < mb_strlen($itemName)) $itemName = mb_substr($itemName, 0, 50).'...'; | |
| 4115 | - $amt = usces_crform($amt, true, false, 'return', true); | |
| 4116 | - $desc = $itemName.' '.__('Quantity','usces').':'.$quantity.' '.$amt; | |
| 4117 | - return($desc); | |
| 4118 | -} | |
| 4119 | -//20110421ysk end | |
| 4120 | - | |
| 4121 | -function usces_get_send_out_date(){ | |
| 4122 | - global $usces; | |
| 4123 | - | |
| 4124 | - $bus_day_arr = (isset($usces->options['business_days'])) ? $usces->options['business_days'] : false; | |
| 4125 | - list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', current_time('mysql') ); | |
| 4126 | - if( !is_array($bus_day_arr) ){ | |
| 4127 | - $today_bus_flag = 1; | |
| 4128 | - }else{ | |
| 4129 | - $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; | |
| 4130 | - } | |
| 4131 | - // get the time limit addition | |
| 4132 | - $limit_hour = (!empty($usces->options['delivery_time_limit']['hour'])) ? $usces->options['delivery_time_limit']['hour'] : false; | |
| 4133 | - $limit_min = (!empty($usces->options['delivery_time_limit']['min'])) ? $usces->options['delivery_time_limit']['min'] : false; | |
| 4134 | - | |
| 4135 | - if( false === $hour || false === $minute ){ | |
| 4136 | - $time_limit_addition = false; | |
| 4137 | - }elseif( ($hour.':'.$minute.':'.$second) > ($limit_hour.':'.$limit_min.':00') ){ | |
| 4138 | - $time_limit_addition = 1; | |
| 4139 | - }else{ | |
| 4140 | - $time_limit_addition = 0; | |
| 4141 | - } | |
| 4142 | - // get the shipping indication in cart | |
| 4143 | - $cart = $usces->cart->get_cart(); | |
| 4144 | - $shipping_indication = apply_filters('usces_filter_shipping_indication', $usces->options['usces_shipping_indication']); | |
| 4145 | - $shipping = 0; | |
| 4146 | - $indication_flag = true; | |
| 4147 | - for($i = 0; $i < count($cart); $i++) { | |
| 4148 | - $cart_row = $cart[$i]; | |
| 4149 | - $post_id = $cart_row['post_id']; | |
| 4150 | - $itemShipping = (int)$usces->getItemShipping($post_id); | |
| 4151 | - if($itemShipping === 0 or $itemShipping === 9) { | |
| 4152 | - $indication_flag = false; | |
| 4153 | - break; | |
| 4154 | - } | |
| 4155 | - if($shipping < $itemShipping) $shipping = $itemShipping; | |
| 4156 | - } | |
| 4157 | - $indication_incart = ( $indication_flag ) ? $shipping_indication[$shipping] : false; | |
| 4158 | - // get the send out date | |
| 4159 | - $sendout_num = 0; | |
| 4160 | - if( $today_bus_flag ){ | |
| 4161 | - if( $time_limit_addition ){ | |
| 4162 | - $sendout_num += 1; | |
| 4163 | - } | |
| 4164 | - if( false !== $indication_incart ){ | |
| 4165 | - $sendout_num += $indication_incart; | |
| 4166 | - } | |
| 4167 | - }else{ | |
| 4168 | - if( false !== $indication_incart ){ | |
| 4169 | - $sendout_num += $indication_incart; | |
| 4170 | - } | |
| 4171 | - } | |
| 4172 | - $holiday = 0; | |
| 4173 | - for( $i=0; $i<=$sendout_num; $i++ ){ | |
| 4174 | - list($yyyy, $mm, $dd) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $i),(int)$today_year))); | |
| 4175 | - if( isset($bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd]) && !$bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd] ){ | |
| 4176 | - $holiday++; | |
| 4177 | - $sendout_num++; | |
| 4178 | - } | |
| 4179 | - if( 100 < $sendout_num ) break; | |
| 4180 | - } | |
| 4181 | - 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))); | |
| 4182 | - | |
| 4183 | - $res = array( | |
| 4184 | - 'today_bus_flag' => $today_bus_flag, | |
| 4185 | - 'time_limit_addition'=> $time_limit_addition, | |
| 4186 | - 'indication_incart' => $indication_incart, | |
| 4187 | - 'holiday' => $holiday, | |
| 4188 | - 'sendout_num' => $sendout_num, | |
| 4189 | - 'sendout_date' => array('year' => $send_y, 'month' => $send_m, 'day' => $send_d) | |
| 4190 | - ); | |
| 4191 | - return $res; | |
| 4192 | -} | |
| 4193 | - | |
| 4194 | -function usces_action_footer_comment(){ | |
| 4195 | - echo "<!-- Welcart version : v".USCES_VERSION." -->\n"; | |
| 4196 | -} | |
| 4197 | - | |
| 4198 | -function usces_set_acting_notification_time( $key ){ | |
| 4199 | - global $wpdb; | |
| 4200 | - $tableName = $wpdb->prefix . "usces_access"; | |
| 4201 | - $query = $wpdb->prepare("SELECT ID FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key); | |
| 4202 | - $res = $wpdb->get_var( $query ); | |
| 4203 | - if( $res ) | |
| 4204 | - return; | |
| 4205 | - | |
| 4206 | - $query = $wpdb->prepare("INSERT INTO $tableName (acc_key, acc_type, acc_num1) VALUES (%s, %s, %d)", | |
| 4207 | - $key, 'notification_time', time()); | |
| 4208 | - $res = $wpdb->query( $query ); | |
| 4209 | -} | |
| 4210 | - | |
| 4211 | -function usces_check_notification_time( $key, $time ){ | |
| 4212 | - global $wpdb; | |
| 4213 | - $tableName = $wpdb->prefix . "usces_access"; | |
| 4214 | - $query = $wpdb->prepare("SELECT acc_num1 FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key); | |
| 4215 | - $res = $wpdb->get_var( $query ); | |
| 4216 | - if( !$res ) | |
| 4217 | - return false; | |
| 4218 | - | |
| 4219 | - $past = time() - $res; | |
| 4220 | - if( $time > $past ) | |
| 4221 | - return true; | |
| 4222 | - else | |
| 4223 | - return false; | |
| 4224 | -} | |
| 4225 | - | |
| 4226 | -function usces_is_same_itemcode( $post_id, $item_code ){ | |
| 4227 | - global $wpdb, $usces; | |
| 4228 | - | |
| 4229 | - $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); | |
| 4230 | - $ids = $wpdb->get_col( $query ); | |
| 4231 | -// usces_log('ids : '.print_r($query,true), 'acting_transaction.log'); | |
| 4232 | -// usces_log('ids : '.print_r($ids,true), 'acting_transaction.log'); | |
| 4233 | - if( !$ids ){ | |
| 4234 | - return false; | |
| 4235 | - } | |
| 4236 | - $id_str = implode(',', $ids); | |
| 4237 | - $query = "SELECT ID FROM $wpdb->posts WHERE ID IN({$id_str}) AND post_status = 'publish'"; | |
| 4238 | - $res = $wpdb->get_col( $query ); | |
| 4239 | -// usces_log('res : '.print_r($res,true), 'acting_transaction.log'); | |
| 4240 | -// usces_log('res : '.print_r($query,true), 'acting_transaction.log'); | |
| 4241 | - if( !$res ){ | |
| 4242 | - return false; | |
| 4243 | - } | |
| 4244 | - | |
| 4245 | - return $res; | |
| 4246 | -} | |
| 4247 | - | |
| 4248 | -function usces_update_sku( $post_id, $skucode, $fieldname, $value ){ | |
| 4249 | - global $wpdb; | |
| 4250 | - $metas = usces_get_post_meta($post_id, '_isku_'); | |
| 4251 | - if( ! $metas ) | |
| 4252 | - return false; | |
| 4253 | - | |
| 4254 | - $meta_id = ''; | |
| 4255 | - foreach( $metas as $meta ){ | |
| 4256 | - $sku = unserialize($meta['meta_value']); | |
| 4257 | - if( $skucode == $sku['code'] ){ | |
| 4258 | - $meta_id = $meta['meta_id']; | |
| 4259 | - $sku[$fieldname] = $value; | |
| 4260 | - break; | |
| 4261 | - } | |
| 4262 | - } | |
| 4263 | - $serialized_values = serialize($sku); | |
| 4264 | - if( !empty($meta_id) ) $res = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d", $serialized_values, $meta_id) ); | |
| 4265 | - if( !$res ){ | |
| 4266 | - return false; | |
| 4267 | - }else{ | |
| 4268 | - return true; | |
| 4269 | - } | |
| 4270 | -} | |
| 4271 | - | |
| 4272 | -function usces_get_items_skus() { | |
| 4273 | - global $wpdb, $usces; | |
| 4274 | - $res = array(); | |
| 4275 | - $item_codes = array(); | |
| 4276 | - $item_names = array(); | |
| 4277 | - $status = array(); | |
| 4278 | - | |
| 4279 | - $query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} | |
| 4280 | - WHERE post_mime_type = %s AND post_status = %s", 'item', 'publish'); | |
| 4281 | - $IDs = $wpdb->get_col($query); | |
| 4282 | - if( !$IDs ) | |
| 4283 | - return $res; | |
| 4284 | - | |
| 4285 | - //wp_cache_set( 'item_ids', $IDs ); | |
| 4286 | - | |
| 4287 | - $key = 0; | |
| 4288 | - foreach((array)$IDs as $post_id){ | |
| 4289 | - $item_codes[$post_id] = $usces->getItemCode($post_id); | |
| 4290 | - $item_names[$post_id] = $usces->getItemName($post_id); | |
| 4291 | - | |
| 4292 | - //$skus = $usces->get_skus($post_id); | |
| 4293 | - $metas = usces_get_post_meta($post_id, '_isku_'); | |
| 4294 | - foreach( (array)$metas as $mkey => $rows ){ | |
| 4295 | - $metas[$mkey]['meta_value'] = unserialize($rows['meta_value']); | |
| 4296 | - $allmetas[] = $metas; | |
| 4297 | -// $sku_post_id[] = $post_id; | |
| 4298 | -// $sku_code[] = $values['code']; | |
| 4299 | -// $sku_stocknum[] = $values['stocknum']; | |
| 4300 | - $status[] = $metas[$mkey]['meta_value']['stock']; | |
| 4301 | - $key++; | |
| 4302 | - } | |
| 4303 | - //usces_log('implode : '.strlen(explode(',', $res)), 'acting_transaction.log'); | |
| 4304 | - } | |
| 4305 | -// wp_cache_set( 'item_ids', $IDs ); | |
| 4306 | -// wp_cache_set( 'item_codes', $item_codes ); | |
| 4307 | -// wp_cache_set( 'item_names', $item_names ); | |
| 4308 | -// wp_cache_set( 'sku_data', $res ); | |
| 4309 | -// wp_cache_set( 'stock_ct', array_count_values($status) ); | |
| 4310 | - | |
| 4311 | -} | |
| 4312 | -function usces_get_non_zerostoc_items() { | |
| 4313 | - global $wpdb, $usces; | |
| 4314 | - | |
| 4315 | - $query = $wpdb->prepare("SELECT ID, code.meta_value AS code, name.meta_value AS name FROM {$wpdb->posts} | |
| 4316 | - LEFT JOIN {$wpdb->postmeta} AS code ON ID = code.post_id AND '_itemCode' = code.meta_key | |
| 4317 | - LEFT JOIN {$wpdb->postmeta} AS name ON ID = name.post_id AND '_itemName' = name.meta_key | |
| 4318 | - LEFT JOIN {$wpdb->postmeta} AS sku ON ID = sku.post_id AND '_isku_' = sku.meta_key | |
| 4319 | - 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) | |
| 4320 | - GROUP BY ID", | |
| 4321 | - 'item', 'post', 'trush', '%"stocknum";i:0%', '%"stocknum";s:1:"0"%'); | |
| 4322 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 4323 | - | |
| 4324 | - return $res; | |
| 4325 | - | |
| 4326 | -// $key = 0; | |
| 4327 | -// foreach((array)$items as $item){ | |
| 4328 | -//// $ItemCode = $usces->getItemCode($item['ID']); | |
| 4329 | -//// $ItemName = $usces->getItemName($item['ID']); | |
| 4330 | -// | |
| 4331 | -// //$skus = $usces->get_skus($post_id); | |
| 4332 | -// $metas = usces_get_post_meta($item['ID'], '_isku_'); | |
| 4333 | -// foreach( (array)$metas as $rows ){ | |
| 4334 | -// $meta_value = unserialize($rows['meta_value']); | |
| 4335 | -// if( "" != $meta_value['stocknum'] && 0 === (int)$meta_value['stocknum'] ){ | |
| 4336 | -// $res[$key]['ID'] = $item['ID']; | |
| 4337 | -// $res[$key]['code'] = $item['code']; | |
| 4338 | -// $res[$key]['name'] = $item['name']; | |
| 4339 | -// $res[$key]['sku'] = $meta_value['code']; | |
| 4340 | -// } | |
| 4341 | -// $key++; | |
| 4342 | -// } | |
| 4343 | -// } | |
| 4344 | -// return $res; | |
| 4345 | -} | |
| 4346 | -function usces_get_stocs() { | |
| 4347 | - global $wpdb, $usces; | |
| 4348 | - $status = array(); | |
| 4349 | - | |
| 4350 | - $query = $wpdb->prepare("SELECT m.meta_value FROM {$wpdb->posts} AS p | |
| 4351 | - LEFT JOIN {$wpdb->postmeta} AS m ON p.ID = m.post_id AND m.meta_key = %s | |
| 4352 | - WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s" | |
| 4353 | - , '_isku_', 'item', 'post', 'trush'); | |
| 4354 | - $values = $wpdb->get_col($query); | |
| 4355 | - if( !$values ) | |
| 4356 | - return $status; | |
| 4357 | - | |
| 4358 | - foreach((array)$values as $value){ | |
| 4359 | - $meta_value = unserialize($value); | |
| 4360 | - $status[] = (string)$meta_value['stock']; | |
| 4361 | - } | |
| 4362 | - return array_count_values($status); | |
| 4363 | -} | |
| 4364 | - | |
| 4365 | -function usces_get_deco_order_id( $order_id ) { | |
| 4366 | - global $usces; | |
| 4367 | - | |
| 4368 | - $dec_order_id = $usces->get_order_meta_value( 'dec_order_id', $order_id); | |
| 4369 | - if( !$dec_order_id ){ | |
| 4370 | - $dec_order_id = str_pad($order_id, $usces->options['system']['dec_orderID_digit'], "0", STR_PAD_LEFT); | |
| 4371 | - } | |
| 4372 | - return $dec_order_id; | |
| 4373 | -} | |
| 4374 | - | |
| 4375 | -function usces_mail_line( $type, $email = '' ) { | |
| 4376 | - $line = ''; | |
| 4377 | - | |
| 4378 | - switch( $type ) { | |
| 4379 | - case 1: | |
| 4380 | - $line = "******************************************************"; | |
| 4381 | - break; | |
| 4382 | - case 2: | |
| 4383 | - $line = "------------------------------------------------------------------"; | |
| 4384 | - break; | |
| 4385 | - case 3: | |
| 4386 | - $line = "============================================="; | |
| 4387 | - break; | |
| 4388 | - } | |
| 4389 | - | |
| 4390 | - $line = apply_filters( 'usces_filter_mail_line', $line, $type, $email ); | |
| 4391 | - | |
| 4392 | - return $line."\r\n"; | |
| 4393 | -} | |
| 4394 | - | |
| 4395 | -function usces_get_gp_price($post_id, $p, $quant){ | |
| 4396 | - global $usces; | |
| 4397 | - $GpN1 = $usces->getItemGpNum1($post_id); | |
| 4398 | - $GpN2 = $usces->getItemGpNum2($post_id); | |
| 4399 | - $GpN3 = $usces->getItemGpNum3($post_id); | |
| 4400 | - $GpD1 = $usces->getItemGpDis1($post_id); | |
| 4401 | - $GpD2 = $usces->getItemGpDis2($post_id); | |
| 4402 | - $GpD3 = $usces->getItemGpDis3($post_id); | |
| 4403 | - | |
| 4404 | - if( empty($GpN1) || empty($GpD1) ) { | |
| 4405 | - | |
| 4406 | - $realprice = $p; | |
| 4407 | - | |
| 4408 | - }else if( (!empty($GpN1) && !empty($GpD1)) && (empty($GpN2) || empty($GpD2)) ) { | |
| 4409 | - | |
| 4410 | - if( $quant >= $GpN1 ) { | |
| 4411 | - $realprice = round($p * (100 - $GpD1) / 100); | |
| 4412 | - }else{ | |
| 4413 | - $realprice = $p; | |
| 4414 | - } | |
| 4415 | - | |
| 4416 | - }else if( (!empty($GpN1) && !empty($GpD1)) && (!empty($GpN2) && !empty($GpD2)) && (empty($GpN3) || empty($GpD3)) ) { | |
| 4417 | - | |
| 4418 | - if( $quant >= $GpN2 ) { | |
| 4419 | - $realprice = round($p * (100 - $GpD2) / 100); | |
| 4420 | - }else if( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 4421 | - $realprice = round($p * (100 - $GpD1) / 100); | |
| 4422 | - }else{ | |
| 4423 | - $realprice = $p; | |
| 4424 | - } | |
| 4425 | - | |
| 4426 | - }else if( (!empty($GpN1) && !empty($GpD1)) && (!empty($GpN2) && !empty($GpD2)) && (!empty($GpN3) && !empty($GpD3)) ) { | |
| 4427 | - | |
| 4428 | - if( $quant >= $GpN3 ) { | |
| 4429 | - $realprice = round($p * (100 - $GpD3) / 100); | |
| 4430 | - }else if( $quant >= $GpN2 && $quant < $GpN3 ) { | |
| 4431 | - $realprice = round($p * (100 - $GpD2) / 100); | |
| 4432 | - }else if( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 4433 | - $realprice = round($p * (100 - $GpD1) / 100); | |
| 4434 | - }else{ | |
| 4435 | - $realprice = $p; | |
| 4436 | - } | |
| 4437 | - | |
| 4438 | - }else{ | |
| 4439 | - $realprice = $p; | |
| 4440 | - } | |
| 4441 | - | |
| 4442 | - $realprice = apply_filters('usces_filter_get_gp_price', $realprice, $post_id, $p, $quant); | |
| 4443 | - return $realprice; | |
| 4444 | -} | |
| 4445 | -//20120306ysk start 0000324 | |
| 4446 | -function usces_is_complete_settlement( $payment_name, $status = '' ) { | |
| 4447 | - $complete = false; | |
| 4448 | -//20120919ysk start 0000573 | |
| 4449 | - $options = get_option('usces'); | |
| 4450 | - if( $options['point_assign'] == 0 ) { | |
| 4451 | - $complete = true; | |
| 4452 | -//20120919ysk end | |
| 4453 | - } else { | |
| 4454 | - $payments = usces_get_system_option( 'usces_payment_method', 'name' ); | |
| 4455 | - if( isset($payments[$payment_name]['settlement']) ) { | |
| 4456 | - switch( $payments[$payment_name]['settlement'] ) { | |
| 4457 | - case 'acting': | |
| 4458 | - if( false !== strpos( $status, 'pending' ) ) break; | |
| 4459 | - case 'acting_zeus_card': | |
| 4460 | - case 'acting_remise_card': | |
| 4461 | - case 'acting_jpayment_card': | |
| 4462 | - case 'acting_paypal_ec': | |
| 4463 | - case 'acting_sbps_card': | |
| 4464 | - case 'acting_telecom_card': | |
| 4465 | - case 'acting_digitalcheck_card': | |
| 4466 | - case 'acting_mizuho_card': | |
| 4467 | - case 'acting_anotherlane_card': | |
| 4468 | - case 'acting_veritrans_card': | |
| 4469 | - case 'COD': | |
| 4470 | - $complete = true; | |
| 4471 | - } | |
| 4472 | - } | |
| 4473 | - } | |
| 4474 | - $complete = apply_filters( 'usces_filter_is_complete_settlement', $complete, $payment_name, $status ); | |
| 4475 | - return $complete; | |
| 4476 | -} | |
| 4477 | - | |
| 4478 | -function usces_action_acting_getpoint( $order_id, $add = true ) { | |
| 4479 | - global $usces, $wpdb; | |
| 4480 | - | |
| 4481 | - if( !apply_filters( 'usces_action_acting_getpoint_switch', true, $order_id, $add) ) | |
| 4482 | - return; | |
| 4483 | - | |
| 4484 | -//20120919ysk start 0000573 | |
| 4485 | - $options = get_option('usces'); | |
| 4486 | - if( $options['point_assign'] != 0 ) { | |
| 4487 | -//20120919ysk end | |
| 4488 | - if( 'activate' == $usces->options['membersystem_state'] && 'activate' == $usces->options['membersystem_point'] ) { | |
| 4489 | - $table_name = $wpdb->prefix . "usces_order"; | |
| 4490 | - $mquery = $wpdb->prepare("SELECT mem_id, order_getpoint FROM $table_name WHERE ID = %d", $order_id); | |
| 4491 | - $values = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 4492 | - $mem_id = $values['mem_id']; | |
| 4493 | - $getpoint = $values['order_getpoint']; | |
| 4494 | - | |
| 4495 | - if( !empty($mem_id) && 0 < $getpoint ) { | |
| 4496 | - $calc = ($add) ? '+' : '-'; | |
| 4497 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 4498 | - $mquery = $wpdb->prepare("UPDATE $member_table_name SET mem_point = (mem_point ".$calc." %d) WHERE ID = %d", $getpoint, $mem_id); | |
| 4499 | - $wpdb->query( $mquery ); | |
| 4500 | - | |
| 4501 | - if( !empty($_SESSION['usces_member']['point']) ) { | |
| 4502 | - $mquery = $wpdb->prepare("SELECT mem_point FROM $member_table_name WHERE ID = %d", $mem_id); | |
| 4503 | - $point = $wpdb->get_var( $mquery ); | |
| 4504 | - $_SESSION['usces_member']['point'] = $point; | |
| 4505 | - } | |
| 4506 | - } | |
| 4507 | - } | |
| 4508 | - } | |
| 4509 | - do_action( 'usces_action_acting_getpoint', $order_id, $add ); | |
| 4510 | -} | |
| 4511 | - | |
| 4512 | -function usces_restore_point( $mem_id, $point ) { | |
| 4513 | - global $wpdb; | |
| 4514 | - | |
| 4515 | - if( !apply_filters( 'usces_action_restore_point_switch', true, $mem_id, $point) ) | |
| 4516 | - return; | |
| 4517 | - | |
| 4518 | - $member_table_name = $wpdb->prefix . "usces_member"; | |
| 4519 | - $query = $wpdb->prepare( "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", $point, $mem_id ); | |
| 4520 | - $wpdb->query( $query ); | |
| 4521 | -} | |
| 4522 | -//20120306ysk end | |
| 4523 | -//20120413ysk start | |
| 4524 | -function usces_set_free_csv( $customer ){ | |
| 4525 | - $free_csv = ""; | |
| 4526 | - if( !WCUtils::is_blank($customer['name1']) ) { | |
| 4527 | - $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']; | |
| 4528 | - $free_csv = base64_encode( $free_csv ); | |
| 4529 | - } | |
| 4530 | - return $free_csv; | |
| 4531 | -} | |
| 4532 | -//20120413ysk end | |
| 4533 | - | |
| 4534 | -function usces_get_itemopt_filed($post_id, $sku, $opt){ | |
| 4535 | - global $usces; | |
| 4536 | - $sku = urlencode($sku); | |
| 4537 | - $optcode = urlencode($opt['name']); | |
| 4538 | - $name = $opt['name']; | |
| 4539 | - $means = (int)$opt['means']; | |
| 4540 | - $essential = (int)$opt['essential']; | |
| 4541 | - $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] ) ? $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] : NULL; | |
| 4542 | - | |
| 4543 | - $html = ''; | |
| 4544 | - switch($means) { | |
| 4545 | - case 0://Single-select | |
| 4546 | - case 1://Multi-select | |
| 4547 | - $selects = explode("\n", $opt['value']); | |
| 4548 | - $multiple = ($means === 0) ? '' : ' multiple'; | |
| 4549 | - $multiple_array = ($means == 0) ? '' : '[]'; | |
| 4550 | - $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"; | |
| 4551 | - if($essential == 1){ | |
| 4552 | - if( '#NONE#' == $session_value || NULL == $session_value ) | |
| 4553 | - $selected = ' selected="selected"'; | |
| 4554 | - else | |
| 4555 | - $selected = ''; | |
| 4556 | - $html .= "\t<option value='#NONE#'{$selected}>" . __('Choose','usces') . "</option>\n"; | |
| 4557 | - } | |
| 4558 | - $i=0; | |
| 4559 | - foreach($selects as $v) { | |
| 4560 | - if( ($i == 0 && $essential == 0 && NULL == $session_value) || esc_attr($v) == $session_value ) | |
| 4561 | - $selected = ' selected="selected"'; | |
| 4562 | - else | |
| 4563 | - $selected = ''; | |
| 4564 | - $html .= "\t<option value='" . esc_attr($v) . "'{$selected}>" . esc_html($v) . "</option>\n"; | |
| 4565 | - $i++; | |
| 4566 | - } | |
| 4567 | - $html .= "</select>\n"; | |
| 4568 | - break; | |
| 4569 | - case 2://Text | |
| 4570 | - $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"; | |
| 4571 | - break; | |
| 4572 | - case 5://Text-area | |
| 4573 | - $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr($session_value) . "</textarea>\n"; | |
| 4574 | - break; | |
| 4575 | - } | |
| 4576 | - | |
| 4577 | - $html = apply_filters('usces_get_itemopt_filed', $html, $post_id, $sku, $opt); | |
| 4578 | - | |
| 4579 | - return $html; | |
| 4580 | -} | |
| 4581 | - | |
| 4582 | -function usces_delete_order_check( $order_id ) { | |
| 4583 | - $res = apply_filters( 'usces_filter_delete_order_check', true, $order_id ); | |
| 4584 | - return $res; | |
| 4585 | -} | |
| 4586 | - | |
| 4587 | -function usces_itempage_admin_bar() { | |
| 4588 | - global $wp_admin_bar, $post; | |
| 4589 | - if( is_single() && usces_is_item() ){ | |
| 4590 | - $wp_admin_bar->remove_menu('edit'); | |
| 4591 | - $ref = urlencode(site_url() . '/wp-admin/admin.php?page=usces_itemedit'); | |
| 4592 | - $wp_admin_bar->add_menu( array( | |
| 4593 | - 'id' => 'edit', | |
| 4594 | - 'title' => __('Edit item', 'usces'), | |
| 4595 | - 'href' => site_url() . '/wp-admin/admin.php?page=usces_itemedit&action=edit&post=' . $post->ID . '&usces_referer=' . $ref | |
| 4596 | - ) ); | |
| 4597 | - } | |
| 4598 | -} | |
| 4599 | - | |
| 4600 | -function usces_rand( $digit = 10 ) { | |
| 4601 | - $num = str_repeat( "9", $digit ); | |
| 4602 | - $rand = apply_filters( 'usces_filter_rand_value', sprintf( '%0'.$digit.'d', mt_rand( 1, (int)$num ) ), $num ); | |
| 4603 | - return $rand; | |
| 4604 | -} | |
| 4605 | - | |
| 4606 | -function usces_get_cr_symbol() { | |
| 4607 | - global $usces, $usces_settings; | |
| 4608 | - $cr = $usces->options['system']['currency']; | |
| 4609 | - list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][$cr]; | |
| 4610 | - return $symbol; | |
| 4611 | -} | |
| 4612 | - | |
| 4613 | -function usces_make_option_field( $materials, $cart ){ | |
| 4614 | - //$options = usces_get_ordercart_meta( 'option', $cart_row['cart_id'] ); | |
| 4615 | - //$options = $cart_row['options']; | |
| 4616 | - //$post_id = $cart_row['post_id']; | |
| 4617 | - extract( $materials ); | |
| 4618 | - | |
| 4619 | - $field = '<div>' . "\n"; | |
| 4620 | - $field .= '<ul>' . "\n"; | |
| 4621 | - foreach((array)$options as $opt_value){ | |
| 4622 | - | |
| 4623 | - $field .= '<li>' . usces_get_itemOption( $opt_value, $post_id, $label = '#default#' ) . '</li>' . "\n"; | |
| 4624 | - } | |
| 4625 | - $field .= '</ul>' . "\n"; | |
| 4626 | - $field .= '</div>' . "\n"; | |
| 4627 | - | |
| 4628 | - //echo apply_filters( 'usces_action_make_option_field', $field, $options, $post_id ); | |
| 4629 | - echo apply_filters( 'usces_filter_order_edit_form_row', $field, $cart, $materials ); | |
| 4630 | -} | |
| 4631 | - | |
| 4632 | -function usces_get_itemOption( $opt_value, $post_id, $label = '#default#' ) { | |
| 4633 | - global $usces; | |
| 4634 | - | |
| 4635 | - $cartmeta_id = $opt_value['cartmeta_id']; | |
| 4636 | - $name = $opt_value['meta_key']; | |
| 4637 | - $value = $opt_value['meta_value']; | |
| 4638 | -//usces_p($opt_value); | |
| 4639 | - | |
| 4640 | - if($label == '#default#') | |
| 4641 | - $label = $name; | |
| 4642 | - | |
| 4643 | - $opts = usces_get_opts($post_id, 'name'); | |
| 4644 | - if(!$opts) | |
| 4645 | - return ''; | |
| 4646 | - | |
| 4647 | - $opt = $opts[$name]; | |
| 4648 | - $means = (int)$opt['means']; | |
| 4649 | - $essential = (int)$opt['essential']; | |
| 4650 | - | |
| 4651 | - $html = ''; | |
| 4652 | - $name = esc_attr($name); | |
| 4653 | - $label = esc_attr($label); | |
| 4654 | - $html .= '<label for="itemOption[' . $cartmeta_id . ']" class="iopt_label">' . $label . '</label>' . "\n"; | |
| 4655 | - switch($means) { | |
| 4656 | - case 0://Single-select | |
| 4657 | - $selects = explode("\n", $opt['value']); | |
| 4658 | - $html .= '<select name="itemOption[' . $cartmeta_id . ']" id="itemOption[' . $cartmeta_id . ']" class="iopt_select" onKeyDown="if (event.keyCode == 13) {return false;}">' . "\n"; | |
| 4659 | - if($essential == 1){ | |
| 4660 | - if( '#NONE#' == $value || NULL == $value ) | |
| 4661 | - $selected = ' selected="selected"'; | |
| 4662 | - else | |
| 4663 | - $selected = ''; | |
| 4664 | - $html .= '<option value="#NONE#"' . $selected . '>' . __('Choose','usces') . '</option>' . "\n"; | |
| 4665 | - } | |
| 4666 | - $i=0; | |
| 4667 | - foreach($selects as $v) { | |
| 4668 | - $v = trim($v); | |
| 4669 | - if( ($i == 0 && $essential == 0 && NULL == $value) || esc_attr($v) == esc_attr($value) ) | |
| 4670 | - $selected = ' selected="selected"'; | |
| 4671 | - else | |
| 4672 | - $selected = ''; | |
| 4673 | - $html .= '<option value="' . esc_attr($v) . '"' . $selected . '>' . esc_attr($v) . '</option>' . "\n"; | |
| 4674 | - $i++; | |
| 4675 | - } | |
| 4676 | - $html .= '</select>' . "\n"; | |
| 4677 | - break; | |
| 4678 | - case 1://Multi-select | |
| 4679 | - $selects = explode("\n", $opt['value']); | |
| 4680 | - $value = maybe_unserialize($value); | |
| 4681 | - $html .= '<select name="itemOption[' . $cartmeta_id . '][]" id="itemOption[' . $cartmeta_id . ']" class="iopt_select" multiple onKeyDown="if (event.keyCode == 13) {return false;}">' . "\n"; | |
| 4682 | - if($essential == 1){ | |
| 4683 | - if( '#NONE#' == $value || NULL == $value ) | |
| 4684 | - $selected = ' selected="selected"'; | |
| 4685 | - else | |
| 4686 | - $selected = ''; | |
| 4687 | - $html .= '<option value="#NONE#"' . $selected . '>' . __('Choose','usces') . '</option>' . "\n"; | |
| 4688 | - } | |
| 4689 | - $i=0; | |
| 4690 | - | |
| 4691 | - $value_arr = maybe_unserialize($value); | |
| 4692 | - | |
| 4693 | - foreach($selects as $v) { | |
| 4694 | - $v = trim($v); | |
| 4695 | - $opval = urlencode($v); | |
| 4696 | - $val_str = isset($value_arr[$opval]) ? $value_arr[$opval] : ''; | |
| 4697 | - if( $v == $val_str ) | |
| 4698 | - $selected = ' selected="selected"'; | |
| 4699 | - else | |
| 4700 | - $selected = ''; | |
| 4701 | - $html .= '<option value="' . esc_attr($opval) . '"' . $selected . '>' . esc_attr($v) . '</option>' . "\n"; | |
| 4702 | - $i++; | |
| 4703 | - } | |
| 4704 | - $html .= '</select>' . "\n"; | |
| 4705 | - break; | |
| 4706 | - case 2://Text | |
| 4707 | - $html .= '<input name="itemOption[' . $cartmeta_id . ']" type="text" id="itemOption[' . $cartmeta_id . ']" class="iopt_text" onKeyDown="if (event.keyCode == 13) {return false;}" value="' . esc_attr($value) . '" />' . "\n"; | |
| 4708 | - break; | |
| 4709 | - case 5://Text-area | |
| 4710 | - $html .= '<textarea name="itemOption[' . $cartmeta_id . ']" id="itemOption[' . $cartmeta_id . ']" class="iopt_textarea">' . esc_attr($value) . '</textarea>' . "\n"; | |
| 4711 | - break; | |
| 4712 | - } | |
| 4713 | - | |
| 4714 | - $html = apply_filters('usces_filter_get_itemOption', $html, $opt_value, $post_id ); | |
| 4715 | - | |
| 4716 | - return $html; | |
| 4717 | -} | |
| 4718 | - | |
| 4719 | -function usces_get_ordercart_meta( $type, $cart_id, $key = '' ){ | |
| 4720 | - global $wpdb; | |
| 4721 | - | |
| 4722 | - if( !$cart_id ) | |
| 4723 | - return; | |
| 4724 | - | |
| 4725 | - $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; | |
| 4726 | - | |
| 4727 | - if( '' != $key ) { | |
| 4728 | - $query = $wpdb->prepare( " | |
| 4729 | - SELECT cartmeta_id, meta_key, meta_value | |
| 4730 | - FROM $ordercart_meta_table | |
| 4731 | - WHERE cart_id = %d AND meta_type = %s AND meta_key = %s | |
| 4732 | - ", $cart_id, $type, $key ); | |
| 4733 | - } else { | |
| 4734 | - $query = $wpdb->prepare( " | |
| 4735 | - SELECT cartmeta_id, meta_key, meta_value | |
| 4736 | - FROM $ordercart_meta_table | |
| 4737 | - WHERE cart_id = %d AND meta_type = %s | |
| 4738 | - ", $cart_id, $type ); | |
| 4739 | - } | |
| 4740 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 4741 | - return $res; | |
| 4742 | -} | |
| 4743 | - | |
| 4744 | -function usces_get_ordercart_meta_value( $type, $cart_id, $key = '' ){ | |
| 4745 | - global $wpdb; | |
| 4746 | - | |
| 4747 | - if( !$cart_id ) | |
| 4748 | - return; | |
| 4749 | - | |
| 4750 | - $ordercart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; | |
| 4751 | - | |
| 4752 | - if( '' != $key ) { | |
| 4753 | - $query = $wpdb->prepare( " | |
| 4754 | - SELECT meta_value | |
| 4755 | - FROM $ordercart_meta_table | |
| 4756 | - WHERE cart_id = %d AND meta_type = %s AND meta_key = %s | |
| 4757 | - ", $cart_id, $type, $key ); | |
| 4758 | - } else { | |
| 4759 | - $query = $wpdb->prepare( " | |
| 4760 | - SELECT meta_value | |
| 4761 | - FROM $ordercart_meta_table | |
| 4762 | - WHERE cart_id = %d AND meta_type = %s | |
| 4763 | - ", $cart_id, $type ); | |
| 4764 | - } | |
| 4765 | - $res = $wpdb->get_var( $query ); | |
| 4766 | - return $res; | |
| 4767 | -} | |
| 4768 | - | |
| 4769 | -function usces_make_advance_value( $advance, $cart_row ) { | |
| 4770 | - $value = ''; | |
| 4771 | - $advance_value = array(); | |
| 4772 | - | |
| 4773 | - foreach( $advance as $row ) { | |
| 4774 | - $advance_value[] = array( $row['meta_key'] => $row['meta_value'] ); | |
| 4775 | - } | |
| 4776 | - $value = apply_filters( 'usces_filter_order_edit_form_row_advance_value', serialize($advance_value), $advance, $cart_row ); | |
| 4777 | - return $value; | |
| 4778 | -} | |
| 4779 | - | |
| 4780 | -function usces_get_ordercart_row( $order_id, $cart = array() ){ | |
| 4781 | - global $usces; | |
| 4782 | - | |
| 4783 | - if( empty( $cart ) ) | |
| 4784 | - $cart = usces_get_ordercartdata( $order_id ); | |
| 4785 | - | |
| 4786 | - ob_start(); | |
| 4787 | - foreach( $cart as $i => $cart_row ) { | |
| 4788 | - $ordercart_id = $cart_row['cart_id']; | |
| 4789 | - $post_id = $cart_row['post_id']; | |
| 4790 | - //$post = get_post($post_id); | |
| 4791 | - $sku = $cart_row['sku']; | |
| 4792 | - $sku_code = $cart_row['sku_code']; | |
| 4793 | - $quantity = $cart_row['quantity']; | |
| 4794 | - //$options = $cart_row['options']; | |
| 4795 | - $options = usces_get_ordercart_meta( 'option', $ordercart_id ); | |
| 4796 | - $advance = usces_get_ordercart_meta( 'advance', $ordercart_id ); | |
| 4797 | - $itemCode = $cart_row['item_code']; | |
| 4798 | - $itemName = $cart_row['item_name']; | |
| 4799 | - $cartItemName = $usces->getCartItemName($post_id, $sku_code); | |
| 4800 | - $skuPrice = $cart_row['price']; | |
| 4801 | - $stock = $usces->getItemZaiko($post_id, $sku_code); | |
| 4802 | - $red = (in_array($stock, array(__('sellout', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'class="signal_red"' : ''; | |
| 4803 | - $pictid = (int)$usces->get_mainpictid($itemCode); | |
| 4804 | - $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance', | |
| 4805 | - 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'stock', 'red', 'pictid', 'order_id' ); | |
| 4806 | - $advance_value = usces_make_advance_value( $advance, $cart_row ); | |
| 4807 | -?> | |
| 4808 | - <tr> | |
| 4809 | - <td><?php echo $i + 1; ?></td> | |
| 4810 | - <td><?php echo wp_get_attachment_image( $pictid, array(80, 80), true ); ?></td> | |
| 4811 | - <td class="aleft"><?php echo esc_html($cartItemName); ?><?php do_action('usces_admin_order_item_name', $order_id, $i); ?><?php usces_make_option_field( $materials, $cart ); ?></td> | |
| 4812 | - <td><input name="skuPrice[<?php echo $ordercart_id; ?>]" class="text price" type="text" value="<?php echo esc_attr( $skuPrice ); ?>" /></td> | |
| 4813 | - <td><input name="quant[<?php echo $ordercart_id; ?>]" class="text quantity" type="text" value="<?php echo esc_attr($cart_row['quantity']); ?>" /></td> | |
| 4814 | - <td id="sub_total[<?php echo $ordercart_id; ?>]" class="aright"> </td> | |
| 4815 | - <td <?php echo $red ?>><?php echo esc_html($stock); ?></td> | |
| 4816 | - <td> | |
| 4817 | - <input name="postId[<?php echo $ordercart_id; ?>]" type="hidden" value="<?php echo esc_attr($post_id); ?>" /> | |
| 4818 | - <input name="advance[<?php echo $ordercart_id; ?>]" type="hidden" value="<?php echo esc_attr($advance_value); ?>" /> | |
| 4819 | - <input name="delButtonAdmin[<?php echo $ordercart_id; ?>]" class="delCartButton" type="submit" value="<?php _e('Delete', 'usces'); ?>" /> | |
| 4820 | - <?php do_action('usces_admin_order_cart_button', $order_id, $i); ?> | |
| 4821 | - </td> | |
| 4822 | - </tr> | |
| 4823 | -<?php | |
| 4824 | - } | |
| 4825 | - $row = ob_get_contents(); | |
| 4826 | - ob_end_clean(); | |
| 4827 | - | |
| 4828 | - return apply_filters( 'usces_filter_get_ordercart_row', $row, $order_id, $cart ); | |
| 4829 | -} | |
| 4830 | - | |
| 4831 | -function usces_add_role(){ | |
| 4832 | - | |
| 4833 | - if ( ! get_role( 'wc_author' ) ) { | |
| 4834 | - $capabilities = array( | |
| 4835 | - 'moderate_comments' => 1, | |
| 4836 | - 'manage_categories' => 1, | |
| 4837 | - 'manage_links' => 1, | |
| 4838 | - 'upload_files' => 1, | |
| 4839 | - 'unfiltered_html' => 1, | |
| 4840 | - 'edit_posts' => 1, | |
| 4841 | - 'edit_others_posts' => 1, | |
| 4842 | - 'edit_published_posts' => 1, | |
| 4843 | - 'publish_posts' => 1, | |
| 4844 | - 'edit_pages' => 1, | |
| 4845 | - 'read' => 1, | |
| 4846 | - 'level_4' => 1, | |
| 4847 | - 'level_3' => 1, | |
| 4848 | - 'level_2' => 1, | |
| 4849 | - 'level_1' => 1, | |
| 4850 | - 'level_0' => 1, | |
| 4851 | - 'edit_others_pages' => 1, | |
| 4852 | - 'edit_published_pages' => 1, | |
| 4853 | - 'publish_pages' => 1, | |
| 4854 | - 'delete_pages' => 1, | |
| 4855 | - 'delete_others_pages' => 1, | |
| 4856 | - 'delete_published_pages' => 1, | |
| 4857 | - 'delete_posts' => 1, | |
| 4858 | - 'delete_others_posts' => 1, | |
| 4859 | - 'delete_published_posts' => 1, | |
| 4860 | - 'delete_private_posts' => 1, | |
| 4861 | - 'edit_private_posts' => 1, | |
| 4862 | - 'read_private_posts' => 1, | |
| 4863 | - 'delete_private_pages' => 1, | |
| 4864 | - 'edit_private_pages' => 1, | |
| 4865 | - 'read_private_pages' => 1 | |
| 4866 | - ); | |
| 4867 | - add_role( 'wc_author', '編集者(マネジメント権限無し)', $capabilities ); | |
| 4868 | - } | |
| 4869 | - | |
| 4870 | - if ( ! get_role( 'wc_management' ) ) { | |
| 4871 | - $capabilities = array( | |
| 4872 | - 'moderate_comments' => 1, | |
| 4873 | - 'manage_categories' => 1, | |
| 4874 | - 'manage_links' => 1, | |
| 4875 | - 'upload_files' => 1, | |
| 4876 | - 'unfiltered_html' => 1, | |
| 4877 | - 'edit_posts' => 1, | |
| 4878 | - 'edit_others_posts' => 1, | |
| 4879 | - 'edit_published_posts' => 1, | |
| 4880 | - 'publish_posts' => 1, | |
| 4881 | - 'edit_pages' => 1, | |
| 4882 | - 'read' => 1, | |
| 4883 | - 'level_5' => 1, | |
| 4884 | - 'level_4' => 1, | |
| 4885 | - 'level_3' => 1, | |
| 4886 | - 'level_2' => 1, | |
| 4887 | - 'level_1' => 1, | |
| 4888 | - 'level_0' => 1, | |
| 4889 | - 'edit_others_pages' => 1, | |
| 4890 | - 'edit_published_pages' => 1, | |
| 4891 | - 'publish_pages' => 1, | |
| 4892 | - 'delete_pages' => 1, | |
| 4893 | - 'delete_others_pages' => 1, | |
| 4894 | - 'delete_published_pages' => 1, | |
| 4895 | - 'delete_posts' => 1, | |
| 4896 | - 'delete_others_posts' => 1, | |
| 4897 | - 'delete_published_posts' => 1, | |
| 4898 | - 'delete_private_posts' => 1, | |
| 4899 | - 'edit_private_posts' => 1, | |
| 4900 | - 'read_private_posts' => 1, | |
| 4901 | - 'delete_private_pages' => 1, | |
| 4902 | - 'edit_private_pages' => 1, | |
| 4903 | - 'read_private_pages' => 1 | |
| 4904 | - ); | |
| 4905 | - add_role( 'wc_management', '編集者(設定権限無し)', $capabilities ); | |
| 4906 | - } | |
| 4907 | - | |
| 4908 | - remove_role( 'wpsc_anonymous' ); | |
| 4909 | -} | |
| 4910 | - | |
| 4911 | -function usces_get_admin_user_level(){ | |
| 4912 | - global $current_user; | |
| 4913 | - get_currentuserinfo(); | |
| 4914 | - $levels = array(); | |
| 4915 | - foreach($current_user->allcaps as $key => $value){ | |
| 4916 | - $parts = explode( '_', $key ); | |
| 4917 | - if( 'level' == $parts[0] ) | |
| 4918 | - $levels[] = $parts[1]; | |
| 4919 | - } | |
| 4920 | - rsort($levels); | |
| 4921 | - | |
| 4922 | - return $levels[0]; | |
| 4923 | -} | |
| 4924 | - | |
| 4925 | - | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Functions | |
| 4 | + * | |
| 5 | + * @package Welcart | |
| 6 | + */ | |
| 7 | + | |
| 8 | +function usces_recovery_session_data() { | |
| 9 | + global $usces; | |
| 10 | + | |
| 11 | + $absolute_trans_id = isset( $_REQUEST['absolute_trans_id'] ) ? $_REQUEST['absolute_trans_id'] : 0; | |
| 12 | + | |
| 13 | + if ( ! $absolute_trans_id ) { | |
| 14 | + return; | |
| 15 | + } | |
| 16 | + | |
| 17 | + $order_data = usces_get_acting_data( $absolute_trans_id ); | |
| 18 | + | |
| 19 | + if ( ! empty( $order_data['usces_entry'] ) ) { | |
| 20 | + $_SESSION['usces_member'] = $order_data['usces_member']; | |
| 21 | + $_SESSION['usces_cart'] = $order_data['usces_cart']; | |
| 22 | + $_SESSION['usces_entry'] = $order_data['usces_entry']; | |
| 23 | + } | |
| 24 | +} | |
| 25 | + | |
| 26 | +function usces_reg_orderdata( $results = array() ) { | |
| 27 | + global $wpdb, $usces; | |
| 28 | + | |
| 29 | + $options = get_option( 'usces', array() ); | |
| 30 | + $cart = $usces->cart->get_cart(); | |
| 31 | + $entry = $usces->cart->get_entry(); | |
| 32 | + | |
| 33 | + if ( empty( $cart ) ) { | |
| 34 | + | |
| 35 | + // Trying to get back the entry data. | |
| 36 | + usces_recovery_session_data(); | |
| 37 | + $cart = $usces->cart->get_cart(); | |
| 38 | + $entry = $usces->cart->get_entry(); | |
| 39 | + | |
| 40 | + if ( empty( $cart ) ) { | |
| 41 | + $linkkey = usces_get_link_key( $results ); | |
| 42 | + $log = array( | |
| 43 | + 'acting' => 'reg_orderdata', | |
| 44 | + 'key' => $linkkey, | |
| 45 | + 'result' => 'SESSION EMPTY', | |
| 46 | + 'data' => $_REQUEST, | |
| 47 | + ); | |
| 48 | + usces_save_order_acting_error( $log ); | |
| 49 | + return 0; | |
| 50 | + } else { | |
| 51 | + $log = array( | |
| 52 | + 'acting' => 'reg_orderdata', | |
| 53 | + 'key' => $_REQUEST['absolute_trans_id'], | |
| 54 | + 'result' => 'OK SESSION RECOVERY', | |
| 55 | + 'data' => $_REQUEST, | |
| 56 | + ); | |
| 57 | + usces_save_order_acting_error( $log ); | |
| 58 | + | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + // Anti-spam. | |
| 63 | + if ( ( empty( $entry['customer']['name1'] ) && empty( $entry['customer']['name2'] ) ) || empty( $entry['customer']['mailaddress1'] ) || empty( $entry ) || empty( $cart ) ) { | |
| 64 | + $anti_spam = apply_filters( 'usces_filter_reg_orderdata_anti_spam', false, $entry, $cart ); | |
| 65 | + if ( ! $anti_spam ) { | |
| 66 | + usces_log( 'reg_orderdata : Anti-spam', 'acting_transaction.log' ); | |
| 67 | + return false; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | + $charging_type = $usces->getItemChargingType( $cart[0]['post_id'] ); | |
| 72 | + | |
| 73 | + $item_total_price = $usces->get_total_price( $cart ); | |
| 74 | + $member = $usces->get_member(); | |
| 75 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 76 | + $order_table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 77 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 78 | + $set = $usces->getPayments( $entry['order']['payment_name'] ); | |
| 79 | + $status = ''; | |
| 80 | + $gmtdate = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 81 | + if ( 'continue' === $charging_type ) { | |
| 82 | + $order_modified = substr( $gmtdate, 0, 10 ); | |
| 83 | + } else { | |
| 84 | + $noreceipt_status_table = apply_filters( 'usces_filter_noreceipt_status', get_option( 'usces_noreceipt_status' ) ); | |
| 85 | + | |
| 86 | + $status = ( in_array( $set['settlement'], $noreceipt_status_table ) ) ? 'noreceipt' : ''; | |
| 87 | + $order_modified = NULL; | |
| 88 | + } | |
| 89 | + | |
| 90 | + if ( 'paypal.php' === $set['module'] || 'acting_paypal_ec' === $set['settlement'] ) { | |
| 91 | + if ( ( isset( $results['payment_status'] ) && 'Completed' !== $results['payment_status'] ) || ( isset( $results['profile_status'] ) && 'ActiveProfile' !== $results['profile_status'] ) ) { | |
| 92 | + $status = 'pending'; | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + $status = apply_filters( 'usces_filter_reg_orderdata_status', $status, $entry ); | |
| 97 | + $order_date = ( isset( $results['order_date'] ) ) ? $results['order_date'] : $gmtdate; | |
| 98 | + $delidue_date = ( isset( $entry['order']['delidue_date'] ) ) ? $entry['order']['delidue_date'] : NULL; | |
| 99 | + $query = $wpdb->prepare( | |
| 100 | + "INSERT INTO $order_table_name ( | |
| 101 | + `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`, | |
| 102 | + `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`, | |
| 103 | + `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`, | |
| 104 | + `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`, | |
| 105 | + `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` ) | |
| 106 | + 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)", | |
| 107 | + $member['ID'], | |
| 108 | + $entry['customer']['mailaddress1'], | |
| 109 | + $entry['customer']['name1'], | |
| 110 | + $entry['customer']['name2'], | |
| 111 | + $entry['customer']['name3'], | |
| 112 | + $entry['customer']['name4'], | |
| 113 | + $entry['customer']['zipcode'], | |
| 114 | + $entry['customer']['pref'], | |
| 115 | + $entry['customer']['address1'], | |
| 116 | + $entry['customer']['address2'], | |
| 117 | + $entry['customer']['address3'], | |
| 118 | + $entry['customer']['tel'], | |
| 119 | + $entry['customer']['fax'], | |
| 120 | + serialize( $entry['delivery'] ), | |
| 121 | + serialize( $cart ), | |
| 122 | + $entry['order']['note'], | |
| 123 | + $entry['order']['delivery_method'], | |
| 124 | + $entry['order']['delivery_date'], | |
| 125 | + $entry['order']['delivery_time'], | |
| 126 | + $entry['order']['payment_name'], | |
| 127 | + serialize( $entry['condition'] ), | |
| 128 | + $item_total_price, | |
| 129 | + $entry['order']['getpoint'], | |
| 130 | + $entry['order']['usedpoint'], | |
| 131 | + $entry['order']['discount'], | |
| 132 | + $entry['order']['shipping_charge'], | |
| 133 | + $entry['order']['cod_fee'], | |
| 134 | + $entry['order']['tax'], | |
| 135 | + $order_date, | |
| 136 | + $order_modified, | |
| 137 | + $status, | |
| 138 | + $delidue_date | |
| 139 | + ); | |
| 140 | + | |
| 141 | + $res = $wpdb->query( $query ); | |
| 142 | + | |
| 143 | + if ( false === $res ) { | |
| 144 | + $order_id = false; | |
| 145 | + usces_log( 'reg_orderdata : ' . $wpdb->last_error, 'database_error.log' ); | |
| 146 | + } else { | |
| 147 | + $order_id = $wpdb->insert_id; | |
| 148 | + } | |
| 149 | + | |
| 150 | + if ( ! $order_id ) { | |
| 151 | + usces_log( 'reg_error_entry : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 152 | + return false; | |
| 153 | + } | |
| 154 | + | |
| 155 | + $usces->cart->set_order_entry( array( 'ID' => $order_id ) ); | |
| 156 | + $usces->set_order_meta_value( 'customer_country', $entry['customer']['country'], $order_id ); | |
| 157 | + | |
| 158 | + if ( usces_is_tax_display() && usces_is_reduced_taxrate() ) { | |
| 159 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 160 | + $materials = array( | |
| 161 | + 'total_items_price' => $entry['order']['total_items_price'], | |
| 162 | + 'discount' => ( isset( $entry['order']['discount'] ) ) ? $entry['order']['discount'] : 0, | |
| 163 | + 'shipping_charge' => ( isset( $entry['order']['shipping_charge'] ) ) ? $entry['order']['shipping_charge'] : 0, | |
| 164 | + 'cod_fee' => ( isset( $entry['order']['cod_fee'] ) ) ? $entry['order']['cod_fee'] : 0, | |
| 165 | + 'use_point' => ( isset( $entry['order']['usedpoint'] ) ) ? $entry['order']['usedpoint'] : 0, | |
| 166 | + 'carts' => $cart, | |
| 167 | + 'condition' => $entry['condition'], | |
| 168 | + ); | |
| 169 | + $usces_tax->get_order_tax( $materials ); | |
| 170 | + $usces->set_order_meta_value( 'subtotal_standard', $usces_tax->subtotal_standard, $order_id ); | |
| 171 | + $usces->set_order_meta_value( 'subtotal_reduced', $usces_tax->subtotal_reduced, $order_id ); | |
| 172 | + $usces->set_order_meta_value( 'discount_standard', $usces_tax->discount_standard, $order_id ); | |
| 173 | + $usces->set_order_meta_value( 'discount_reduced', $usces_tax->discount_reduced, $order_id ); | |
| 174 | + if ( 'include' === $usces->options['tax_mode'] ) { | |
| 175 | + $usces->set_order_meta_value( 'tax_standard', 0, $order_id ); | |
| 176 | + $usces->set_order_meta_value( 'tax_reduced', 0, $order_id ); | |
| 177 | + } else { | |
| 178 | + $usces->set_order_meta_value( 'tax_standard', $usces_tax->tax_standard, $order_id ); | |
| 179 | + $usces->set_order_meta_value( 'tax_reduced', $usces_tax->tax_reduced, $order_id ); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + | |
| 183 | + if ( $member['ID'] && 'activate' === $options['membersystem_state'] && 'activate' === $options['membersystem_point'] ) { | |
| 184 | + | |
| 185 | + $mquery = ''; | |
| 186 | + if ( usces_is_complete_settlement( $entry['order']['payment_name'], $status ) ) { | |
| 187 | + if ( apply_filters( 'usces_action_acting_getpoint_switch', true, $order_id, true ) ) { | |
| 188 | + $mquery = $wpdb->prepare( | |
| 189 | + "UPDATE $member_table_name SET mem_point = (mem_point + %d - %d) WHERE ID = %d", | |
| 190 | + $entry['order']['getpoint'], $entry['order']['usedpoint'], $member['ID'] | |
| 191 | + ); | |
| 192 | + } else { | |
| 193 | + $mquery = $wpdb->prepare( | |
| 194 | + "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", | |
| 195 | + $entry['order']['usedpoint'], $member['ID'] | |
| 196 | + ); | |
| 197 | + } | |
| 198 | + } elseif ( 0 < $entry['order']['usedpoint'] ) { | |
| 199 | + $mquery = $wpdb->prepare( | |
| 200 | + "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", | |
| 201 | + $entry['order']['usedpoint'], $member['ID'] | |
| 202 | + ); | |
| 203 | + } | |
| 204 | + if ( $mquery ) { | |
| 205 | + $wpdb->query( $mquery ); | |
| 206 | + $mquery = $wpdb->prepare( "SELECT mem_point FROM $member_table_name WHERE ID = %d", $member['ID'] ); | |
| 207 | + $point = $wpdb->get_var( $mquery ); | |
| 208 | + $_SESSION['usces_member']['point'] = $point; | |
| 209 | + } | |
| 210 | + | |
| 211 | + } | |
| 212 | + | |
| 213 | + if ( ! empty( $entry['reserve'] ) ) { | |
| 214 | + foreach ( $entry['reserve'] as $key => $value ) { | |
| 215 | + if ( is_array( $value ) ) { | |
| 216 | + $value = serialize( $value ); | |
| 217 | + } | |
| 218 | + $usces->set_order_meta_value( $key, $value, $order_id ); | |
| 219 | + } | |
| 220 | + } | |
| 221 | + | |
| 222 | + if ( ! preg_match( '/pending|noreceipt/', $status ) ) { | |
| 223 | + $usces->set_order_meta_value( 'receipted_date', $gmtdate, $order_id ); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if ( ! empty( $entry['custom_order'] ) ) { | |
| 227 | + foreach ( $entry['custom_order'] as $key => $value ) { | |
| 228 | + $csod_key = 'csod_' . $key; | |
| 229 | + $value = wel_safe_text_serialize( $value ); | |
| 230 | + if ( is_array( $value ) ) { | |
| 231 | + $value = serialize( $value ); | |
| 232 | + } | |
| 233 | + $usces->set_order_meta_value( $csod_key, $value, $order_id ); | |
| 234 | + } | |
| 235 | + } | |
| 236 | + if ( ! empty( $entry['custom_customer'] ) ) { | |
| 237 | + foreach ( $entry['custom_customer'] as $key => $value ) { | |
| 238 | + $cscs_key = 'cscs_' . $key; | |
| 239 | + $value = wel_safe_text_serialize( $value ); | |
| 240 | + if ( is_array( $value ) ) { | |
| 241 | + $value = serialize( $value ); | |
| 242 | + } | |
| 243 | + $usces->set_order_meta_value( $cscs_key, $value, $order_id ); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + if ( ! empty( $entry['custom_delivery'] ) ) { | |
| 247 | + foreach ( $entry['custom_delivery'] as $key => $value ) { | |
| 248 | + $csde_key = 'csde_' . $key; | |
| 249 | + $value = wel_safe_text_serialize( $value ); | |
| 250 | + if ( is_array( $value ) ) { | |
| 251 | + $value = serialize( $value ); | |
| 252 | + } | |
| 253 | + $usces->set_order_meta_value( $csde_key, $value, $order_id ); | |
| 254 | + } | |
| 255 | + } | |
| 256 | + | |
| 257 | + $args = array( | |
| 258 | + 'cart' => $cart, | |
| 259 | + 'entry' => $entry, | |
| 260 | + 'order_id' => $order_id, | |
| 261 | + 'member_id' => $member['ID'], | |
| 262 | + 'payments' => $set, | |
| 263 | + 'charging_type' => $charging_type, | |
| 264 | + 'results' => $results, | |
| 265 | + ); | |
| 266 | + do_action( 'usces_action_reg_orderdata', $args ); | |
| 267 | + | |
| 268 | + return $order_id; | |
| 269 | +} | |
| 270 | + | |
| 271 | +function usces_new_orderdata() { | |
| 272 | + global $wpdb, $usces; | |
| 273 | + | |
| 274 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 275 | + $_POST['customer']['name3'] = isset( $_POST['customer']['name3'] ) ? $_POST['customer']['name3'] : ''; | |
| 276 | + $_POST['customer']['name4'] = isset( $_POST['customer']['name4'] ) ? $_POST['customer']['name4'] : ''; | |
| 277 | + $usces->cart->crear_cart(); | |
| 278 | + $cart = $usces->cart->get_cart(); | |
| 279 | + $item_total_price = $usces->get_total_price( $cart ); | |
| 280 | + $entry = $usces->cart->get_entry(); | |
| 281 | + $member_id = $usces->get_memberid_by_email( $_POST['customer']['mailaddress'] ); | |
| 282 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 283 | + $order_table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 284 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 285 | + $set = $usces->getPayments( $_POST['offer']['payment_name'] ); | |
| 286 | + if ( isset( $_POST['offer']['receipt'] ) ) { | |
| 287 | + $status = $_POST['offer']['receipt'] . ','; | |
| 288 | + } else { | |
| 289 | + $noreceipt_status_table = apply_filters( 'usces_filter_noreceipt_status', get_option( 'usces_noreceipt_status' ) ); | |
| 290 | + $status = ( in_array( $set['settlement'], $noreceipt_status_table ) ) ? 'noreceipt' : ''; | |
| 291 | + } | |
| 292 | + $status .= ( ! WCUtils::is_blank( $_POST['offer']['taio'] ) && '#none#' !== $_POST['offer']['taio'] ) ? $_POST['offer']['taio'] . ',' : ''; | |
| 293 | + $status .= $_POST['offer']['admin']; | |
| 294 | + $status = apply_filters( 'usces_filter_new_orderdata_status', $status, $entry ); | |
| 295 | + $order_conditions = $usces->get_condition(); | |
| 296 | + $gmtdate = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 297 | + | |
| 298 | + $delivery_date = $_POST['offer']['delivery_date']; | |
| 299 | + if ( ! usces_is_date( $delivery_date ) ) { | |
| 300 | + $delivery_date = apply_filters( 'usces_filter_label_delivery_date_no_preference', __( 'Non-request', 'usces_dual' ) ); | |
| 301 | + } | |
| 302 | + | |
| 303 | + $query = $wpdb->prepare( | |
| 304 | + "INSERT INTO $order_table_name ( | |
| 305 | + `mem_id`, `order_email`, `order_name1`, `order_name2`, `order_name3`, `order_name4`, | |
| 306 | + `order_zip`, `order_pref`, `order_address1`, `order_address2`, `order_address3`, | |
| 307 | + `order_tel`, `order_fax`, `order_delivery`, `order_cart`, `order_note`, `order_delivery_method`, `order_delivery_date`, `order_delivery_time`, | |
| 308 | + `order_payment_name`, `order_condition`, `order_item_total_price`, `order_getpoint`, `order_usedpoint`, `order_discount`, | |
| 309 | + `order_shipping_charge`, `order_cod_fee`, `order_tax`, `order_date`, `order_modified`, `order_status`, `order_delidue_date` ) | |
| 310 | + 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)", | |
| 311 | + $member_id, | |
| 312 | + $_POST['customer']['mailaddress'], | |
| 313 | + $_POST['customer']['name1'], | |
| 314 | + $_POST['customer']['name2'], | |
| 315 | + $_POST['customer']['name3'], | |
| 316 | + $_POST['customer']['name4'], | |
| 317 | + $_POST['customer']['zipcode'], | |
| 318 | + $_POST['customer']['pref'], | |
| 319 | + $_POST['customer']['address1'], | |
| 320 | + $_POST['customer']['address2'], | |
| 321 | + $_POST['customer']['address3'], | |
| 322 | + $_POST['customer']['tel'], | |
| 323 | + $_POST['customer']['fax'], | |
| 324 | + serialize( $_POST['delivery'] ), | |
| 325 | + serialize( $cart ), | |
| 326 | + $_POST['offer']['note'], | |
| 327 | + $_POST['offer']['delivery_method'], | |
| 328 | + $delivery_date, | |
| 329 | + $_POST['offer']['delivery_time'], | |
| 330 | + $_POST['offer']['payment_name'], | |
| 331 | + serialize( $order_conditions ), | |
| 332 | + $item_total_price, | |
| 333 | + $_POST['offer']['getpoint'], | |
| 334 | + $_POST['offer']['usedpoint'], | |
| 335 | + $_POST['offer']['discount'], | |
| 336 | + $_POST['offer']['shipping_charge'], | |
| 337 | + $_POST['offer']['cod_fee'], | |
| 338 | + $_POST['offer']['tax'], | |
| 339 | + $gmtdate, | |
| 340 | + null, | |
| 341 | + $status, | |
| 342 | + $_POST['offer']['delidue_date'] | |
| 343 | + ); | |
| 344 | + | |
| 345 | + $res = $wpdb->query( $query ); | |
| 346 | + $order_id = $wpdb->insert_id; | |
| 347 | + $_REQUEST['order_id'] = $wpdb->insert_id; | |
| 348 | + | |
| 349 | + if ( ! $order_id ) { | |
| 350 | + return false; | |
| 351 | + } | |
| 352 | + | |
| 353 | + $usces->set_order_meta_value( 'customer_country', $_POST['customer']['country'], $order_id ); | |
| 354 | + | |
| 355 | + if ( usces_is_tax_display() && usces_is_reduced_taxrate() ) { | |
| 356 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 357 | + $materials = array( | |
| 358 | + 'total_items_price' => $item_total_price, | |
| 359 | + 'discount' => $_POST['offer']['discount'], | |
| 360 | + 'shipping_charge' => $_POST['offer']['shipping_charge'], | |
| 361 | + 'cod_fee' => $_POST['offer']['cod_fee'], | |
| 362 | + 'use_point' => $_POST['offer']['usedpoint'], | |
| 363 | + 'carts' => $cart, | |
| 364 | + 'condition' => $order_conditions, | |
| 365 | + ); | |
| 366 | + $usces_tax->get_order_tax( $materials ); | |
| 367 | + $usces->set_order_meta_value( 'subtotal_standard', $usces_tax->subtotal_standard, $order_id ); | |
| 368 | + $usces->set_order_meta_value( 'subtotal_reduced', $usces_tax->subtotal_reduced, $order_id ); | |
| 369 | + $usces->set_order_meta_value( 'discount_standard', $usces_tax->discount_standard, $order_id ); | |
| 370 | + $usces->set_order_meta_value( 'discount_reduced', $usces_tax->discount_reduced, $order_id ); | |
| 371 | + if ( 'include' === $usces->options['tax_mode'] ) { | |
| 372 | + $usces->set_order_meta_value( 'tax_standard', 0, $order_id ); | |
| 373 | + $usces->set_order_meta_value( 'tax_reduced', 0, $order_id ); | |
| 374 | + } else { | |
| 375 | + $usces->set_order_meta_value( 'tax_standard', $usces_tax->tax_standard, $order_id ); | |
| 376 | + $usces->set_order_meta_value( 'tax_reduced', $usces_tax->tax_reduced, $order_id ); | |
| 377 | + } | |
| 378 | + } | |
| 379 | + | |
| 380 | + if ( ! empty( $_POST['custom_order'] ) ) { | |
| 381 | + $csod_meta = usces_has_custom_field_meta( 'order' ); | |
| 382 | + foreach ( $_POST['custom_order'] as $key => $value ) { | |
| 383 | + if ( ! is_array( $csod_meta ) || ! isset( $csod_meta[ $key ] ) ) { | |
| 384 | + continue; | |
| 385 | + } | |
| 386 | + $csod_key = 'csod_' . $key; | |
| 387 | + if ( is_array( $value ) ) { | |
| 388 | + $value = serialize( $value ); | |
| 389 | + } | |
| 390 | + $usces->set_order_meta_value( $csod_key, $value, $order_id ); | |
| 391 | + } | |
| 392 | + } | |
| 393 | + if ( ! empty( $_POST['custom_customer'] ) ) { | |
| 394 | + foreach ( $_POST['custom_customer'] as $key => $value ) { | |
| 395 | + $cscs_key = 'cscs_' . $key; | |
| 396 | + if ( is_array( $value ) ) { | |
| 397 | + $value = serialize( $value ); | |
| 398 | + } | |
| 399 | + $usces->set_order_meta_value( $cscs_key, $value, $order_id ); | |
| 400 | + } | |
| 401 | + } | |
| 402 | + if ( ! empty( $_POST['custom_delivery'] ) ) { | |
| 403 | + foreach ( $_POST['custom_delivery'] as $key => $value ) { | |
| 404 | + $csde_key = 'csde_' . $key; | |
| 405 | + if ( is_array( $value ) ) { | |
| 406 | + $value = serialize( $value ); | |
| 407 | + } | |
| 408 | + $usces->set_order_meta_value( $csde_key, $value, $order_id ); | |
| 409 | + } | |
| 410 | + } | |
| 411 | + if ( ! preg_match( '/pending|noreceipt/', $status ) ) { | |
| 412 | + $usces->set_order_meta_value( 'receipted_date', $gmtdate, $order_id ); | |
| 413 | + } | |
| 414 | + $args = array( | |
| 415 | + 'cart' => $cart, | |
| 416 | + 'entry' => $entry, | |
| 417 | + 'order_id' => $order_id, | |
| 418 | + 'member_id' => $member_id, | |
| 419 | + 'payments' => $set, | |
| 420 | + ); | |
| 421 | + do_action( 'usces_action_reg_orderdata', $args ); | |
| 422 | + | |
| 423 | + $usces->cart->crear_cart(); | |
| 424 | + return $res; | |
| 425 | +} | |
| 426 | + | |
| 427 | +function usces_new_memberdata() { | |
| 428 | + global $wpdb, $usces; | |
| 429 | + | |
| 430 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 431 | + $_POST['member']['name3'] = isset( $_POST['member']['name3'] ) ? $_POST['member']['name3'] : ''; | |
| 432 | + $_POST['member']['name4'] = isset( $_POST['member']['name4'] ) ? $_POST['member']['name4'] : ''; | |
| 433 | + $salt = usces_get_salt( '', 1 ); | |
| 434 | + $pass = usces_get_hash( trim( $_POST['member']['password'] ), $salt, 1 ); | |
| 435 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 436 | + $member_table_meta_name = usces_get_tablename( 'usces_member_meta' ); | |
| 437 | + $gmtdate = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 438 | + $query = $wpdb->prepare( | |
| 439 | + "INSERT INTO $member_table_name | |
| 440 | + (`mem_email`, `mem_pass`, `mem_status`, `mem_cookie`, `mem_point`, | |
| 441 | + `mem_name1`, `mem_name2`, `mem_name3`, `mem_name4`, `mem_zip`, `mem_pref`, | |
| 442 | + `mem_address1`, `mem_address2`, `mem_address3`, `mem_tel`, `mem_fax`, | |
| 443 | + `mem_delivery_flag`, `mem_delivery`, `mem_registered`, `mem_nicename`) | |
| 444 | + VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 445 | + trim( $_POST['member']['email'] ), | |
| 446 | + $pass, | |
| 447 | + trim( $_POST['member']['status'] ), | |
| 448 | + '', | |
| 449 | + trim( $_POST['member']['point'] ), | |
| 450 | + trim( $_POST['member']['name1'] ), | |
| 451 | + trim( $_POST['member']['name2'] ), | |
| 452 | + trim( $_POST['member']['name3'] ), | |
| 453 | + trim( $_POST['member']['name4'] ), | |
| 454 | + trim( $_POST['member']['zipcode'] ), | |
| 455 | + trim( $_POST['member']['pref'] ), | |
| 456 | + trim( $_POST['member']['address1'] ), | |
| 457 | + trim( $_POST['member']['address2'] ), | |
| 458 | + trim( $_POST['member']['address3'] ), | |
| 459 | + trim( $_POST['member']['tel'] ), | |
| 460 | + trim( $_POST['member']['fax'] ), | |
| 461 | + '', | |
| 462 | + '', | |
| 463 | + $gmtdate, | |
| 464 | + '' | |
| 465 | + ); | |
| 466 | + $res[0] = $wpdb->query( $query ); | |
| 467 | + | |
| 468 | + if ( false === $res[0] ) { | |
| 469 | + return false; | |
| 470 | + } | |
| 471 | + | |
| 472 | + $member_id = $wpdb->insert_id; | |
| 473 | + $_REQUEST['member_id'] = $wpdb->insert_id; | |
| 474 | + if ( ! $member_id ) { | |
| 475 | + return false; | |
| 476 | + } | |
| 477 | + | |
| 478 | + $usces->set_member_meta_value( 'customer_country', $_POST['member']['country'], $member_id ); | |
| 479 | + $csmb_meta = usces_has_custom_field_meta( 'member' ); | |
| 480 | + if ( is_array( $csmb_meta ) ) { | |
| 481 | + foreach ( $csmb_meta as $key => $entry ) { | |
| 482 | + if ( 4 === (int) $entry['means'] ) { | |
| 483 | + $usces->del_member_meta( 'csmb_' . $key, $member_id ); | |
| 484 | + } | |
| 485 | + } | |
| 486 | + } | |
| 487 | + $admb_meta = usces_has_custom_field_meta( 'admin_member' ); | |
| 488 | + if ( is_array( $admb_meta ) ) { | |
| 489 | + foreach ( $admb_meta as $key => $entry ) { | |
| 490 | + if ( 4 === (int) $entry['means'] ) { | |
| 491 | + $usces->del_member_meta( 'admb_' . $key, $member_id ); | |
| 492 | + } | |
| 493 | + } | |
| 494 | + } | |
| 495 | + $i = 1; | |
| 496 | + if ( ! empty( $_POST['custom_member'] ) ) { | |
| 497 | + foreach ( $_POST['custom_member'] as $key => $value ) { | |
| 498 | + $csmb_key = 'csmb_' . $key; | |
| 499 | + if ( is_array( $value ) ) { | |
| 500 | + $value = serialize( $value ); | |
| 501 | + } | |
| 502 | + $res[ $i ] = $usces->set_member_meta_value( $csmb_key, $value, $member_id ); | |
| 503 | + if ( false === $res[ $i ] ) { | |
| 504 | + return false; | |
| 505 | + } | |
| 506 | + $i++; | |
| 507 | + } | |
| 508 | + } | |
| 509 | + if ( ! empty( $_POST['admin_custom_member'] ) ) { | |
| 510 | + foreach ( $_POST['admin_custom_member'] as $key => $value ) { | |
| 511 | + $admb_key = 'admb_' . $key; | |
| 512 | + if ( is_array( $value ) ) { | |
| 513 | + $value = serialize( $value ); | |
| 514 | + } | |
| 515 | + $res[ $i ] = $usces->set_member_meta_value( $admb_key, $value, $member_id ); | |
| 516 | + if ( false === $res[ $i ] ) { | |
| 517 | + return false; | |
| 518 | + } | |
| 519 | + $i++; | |
| 520 | + } | |
| 521 | + } | |
| 522 | + if ( ! empty( $salt ) ) { | |
| 523 | + $res[ $i ] = $usces->set_member_meta_value( 'mem_salt', $salt, $member_id ); | |
| 524 | + $i++; | |
| 525 | + } | |
| 526 | + $result = ( 0 < array_sum( array_filter( $res, 'is_numeric' ) ) ) ? 1 : 0; | |
| 527 | + | |
| 528 | + do_action( 'usces_action_post_new_memberdata', $member_id, $res[0] ); | |
| 529 | + | |
| 530 | + return $result; | |
| 531 | +} | |
| 532 | + | |
| 533 | +function usces_delete_memberdata( $ID = 0 ) { | |
| 534 | + global $wpdb, $usces; | |
| 535 | + | |
| 536 | + if ( 0 === (int) $ID ) { | |
| 537 | + if ( ! isset( $_REQUEST['member_id'] ) || WCUtils::is_blank( $_REQUEST['member_id'] ) ) { | |
| 538 | + return 0; | |
| 539 | + } | |
| 540 | + $ID = $_REQUEST['member_id']; | |
| 541 | + } | |
| 542 | + do_action( 'usces_action_pre_delete_memberdata', $ID ); | |
| 543 | + | |
| 544 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 545 | + $member_table_meta_name = usces_get_tablename( 'usces_member_meta' ); | |
| 546 | + | |
| 547 | + $query = $wpdb->prepare( "DELETE FROM $member_table_name WHERE ID = %d", $ID ); | |
| 548 | + $res = $wpdb->query( $query ); | |
| 549 | + if ( $res ) { | |
| 550 | + $query = $wpdb->prepare( "DELETE FROM $member_table_meta_name WHERE member_id = %d", $ID ); | |
| 551 | + $wpdb->query( $query ); | |
| 552 | + } | |
| 553 | + do_action( 'usces_action_post_delete_memberdata', $res, $ID ); | |
| 554 | + | |
| 555 | + return $res; | |
| 556 | +} | |
| 557 | + | |
| 558 | +function usces_update_memberdata() { | |
| 559 | + global $wpdb, $usces; | |
| 560 | + | |
| 561 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 562 | + | |
| 563 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 564 | + $member_table_meta_name = usces_get_tablename( 'usces_member_meta' ); | |
| 565 | + | |
| 566 | + $ID = (int) $_REQUEST['member_id']; | |
| 567 | + $name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : ''; | |
| 568 | + $name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : ''; | |
| 569 | + | |
| 570 | + $query = $wpdb->prepare( | |
| 571 | + "UPDATE $member_table_name SET | |
| 572 | + `mem_email`=%s, `mem_status`=%s, `mem_point`=%d, `mem_name1`=%s, `mem_name2`=%s, | |
| 573 | + `mem_name3`=%s, `mem_name4`=%s, `mem_zip`=%s, `mem_pref`=%s, `mem_address1`=%s, | |
| 574 | + `mem_address2`=%s, `mem_address3`=%s, `mem_tel`=%s, `mem_fax`=%s | |
| 575 | + WHERE ID = %d", | |
| 576 | + trim( $_POST['member']['email'] ), | |
| 577 | + trim( $_POST['member']['status'] ), | |
| 578 | + trim( $_POST['member']['point'] ), | |
| 579 | + trim( $_POST['member']['name1'] ), | |
| 580 | + trim( $_POST['member']['name2'] ), | |
| 581 | + $name3, | |
| 582 | + $name4, | |
| 583 | + trim( $_POST['member']['zipcode'] ), | |
| 584 | + trim( $_POST['member']['pref'] ), | |
| 585 | + trim( $_POST['member']['address1'] ), | |
| 586 | + trim( $_POST['member']['address2'] ), | |
| 587 | + trim( $_POST['member']['address3'] ), | |
| 588 | + trim( $_POST['member']['tel'] ), | |
| 589 | + trim( $_POST['member']['fax'] ), | |
| 590 | + $ID | |
| 591 | + ); | |
| 592 | + | |
| 593 | + do_action( 'usces_action_pre_update_memberdata', $ID ); | |
| 594 | + $res[0] = $wpdb->query( $query ); | |
| 595 | + | |
| 596 | + do_action( 'usces_action_post_update_memberdata', $ID, $res[0] ); | |
| 597 | + | |
| 598 | + if ( false === $res[0] ) { | |
| 599 | + return false; | |
| 600 | + } | |
| 601 | + | |
| 602 | + $usces->set_member_meta_value( 'customer_country', $_POST['member']['country'], $ID ); | |
| 603 | + $csmb_meta = usces_has_custom_field_meta( 'member' ); | |
| 604 | + if ( is_array( $csmb_meta ) ) { | |
| 605 | + foreach ( $csmb_meta as $key => $entry ) { | |
| 606 | + if ( 4 === (int) $entry['means'] ) { | |
| 607 | + $usces->del_member_meta( 'csmb_' . $key, $ID ); | |
| 608 | + } | |
| 609 | + } | |
| 610 | + } | |
| 611 | + $admb_meta = usces_has_custom_field_meta( 'admin_member' ); | |
| 612 | + if ( is_array( $admb_meta ) ) { | |
| 613 | + foreach ( $admb_meta as $key => $entry ) { | |
| 614 | + if ( 4 === (int) $entry['means'] ) { | |
| 615 | + $usces->del_member_meta( 'admb_' . $key, $ID ); | |
| 616 | + } | |
| 617 | + } | |
| 618 | + } | |
| 619 | + $i = 1; | |
| 620 | + if ( ! empty( $_POST['custom_member'] ) ) { | |
| 621 | + foreach ( $_POST['custom_member'] as $key => $value ) { | |
| 622 | + $csmb_key = 'csmb_' . $key; | |
| 623 | + if ( is_array( $value ) ) { | |
| 624 | + $value = serialize( $value ); | |
| 625 | + } | |
| 626 | + $res[ $i ] = $usces->set_member_meta_value( $csmb_key, $value, $ID ); | |
| 627 | + if ( false === $res[ $i ] ) { | |
| 628 | + return false; | |
| 629 | + } | |
| 630 | + $i++; | |
| 631 | + } | |
| 632 | + } | |
| 633 | + if ( ! empty( $_POST['admin_custom_member'] ) ) { | |
| 634 | + foreach ( $_POST['admin_custom_member'] as $key => $value ) { | |
| 635 | + $admb_key = 'admb_' . $key; | |
| 636 | + if ( is_array( $value ) ) { | |
| 637 | + $value = serialize( $value ); | |
| 638 | + } | |
| 639 | + $res[ $i ] = $usces->set_member_meta_value( $admb_key, $value, $ID ); | |
| 640 | + if ( false === $res[ $i ] ) { | |
| 641 | + return false; | |
| 642 | + } | |
| 643 | + $i++; | |
| 644 | + } | |
| 645 | + } | |
| 646 | + | |
| 647 | + do_action( 'usces_action_post_update_after_memberdata', $ID, $res ); | |
| 648 | + | |
| 649 | + $result = ( 0 < array_sum( array_filter( $res, 'is_numeric' ) ) ) ? 1 : 0; | |
| 650 | + return $result; | |
| 651 | +} | |
| 652 | + | |
| 653 | +function usces_delete_orderdata() { | |
| 654 | + global $wpdb, $usces; | |
| 655 | + | |
| 656 | + if ( ! isset( $_REQUEST['order_id'] ) || WCUtils::is_blank( $_REQUEST['order_id'] ) ) { | |
| 657 | + return 0; | |
| 658 | + } | |
| 659 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 660 | + $order_meta_table = $wpdb->prefix . 'usces_order_meta'; | |
| 661 | + $ID = $_REQUEST['order_id']; | |
| 662 | + | |
| 663 | + $del = usces_delete_order_check( $ID ); | |
| 664 | + if ( $del ) { | |
| 665 | + | |
| 666 | + $query = $wpdb->prepare( "SELECT * FROM $order_table WHERE ID = %d", $ID ); | |
| 667 | + $order_data = $wpdb->get_row( $query, OBJECT ); | |
| 668 | + $point = 0; | |
| 669 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] && ! empty( $order_data->mem_id ) && ! $usces->is_status( 'cancel', $order_data->order_status ) ) { | |
| 670 | + if ( 0 < $order_data->order_getpoint ) { | |
| 671 | + if ( usces_is_complete_settlement( $order_data->order_payment_name, $order_data->order_status ) || $usces->is_status( 'receipted', $order_data->order_status) ) { | |
| 672 | + $point += $order_data->order_getpoint; | |
| 673 | + } | |
| 674 | + } | |
| 675 | + if ( 0 < $order_data->order_usedpoint ) { | |
| 676 | + $point -= $order_data->order_usedpoint; | |
| 677 | + } | |
| 678 | + } | |
| 679 | + | |
| 680 | + $query = $wpdb->prepare( "DELETE FROM $order_table WHERE ID = %d", $ID ); | |
| 681 | + $res = $wpdb->query( $query ); | |
| 682 | + | |
| 683 | + $args = compact( 'ID', 'point', 'res' ); | |
| 684 | + | |
| 685 | + if ( $res ) { | |
| 686 | + | |
| 687 | + do_action( 'usces_action_del_orderdata', $order_data, $args ); | |
| 688 | + | |
| 689 | + $query = $wpdb->prepare( "DELETE FROM $order_meta_table WHERE order_id = %d", $ID ); | |
| 690 | + $wpdb->query( $query ); | |
| 691 | + | |
| 692 | + usces_delete_ordercartdata( NULL, $ID ); | |
| 693 | + | |
| 694 | + if ( 0 != $point ) { | |
| 695 | + usces_restore_point( $order_data->mem_id, $point ); | |
| 696 | + } | |
| 697 | + } | |
| 698 | + | |
| 699 | + } else { | |
| 700 | + $res = true; | |
| 701 | + } | |
| 702 | + | |
| 703 | + return $res; | |
| 704 | +} | |
| 705 | + | |
| 706 | +function usces_update_serialized_cart() { | |
| 707 | + global $wpdb, $usces; | |
| 708 | + | |
| 709 | + if ( ! isset( $_REQUEST['order_id'] ) || WCUtils::is_blank( $_REQUEST['order_id'] ) ) { | |
| 710 | + return 0; | |
| 711 | + } | |
| 712 | + | |
| 713 | + $ID = $_REQUEST['order_id']; | |
| 714 | + | |
| 715 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 716 | + $usces->cart->crear_cart(); | |
| 717 | + $usces->cart->upCart(); | |
| 718 | + $cart = $usces->cart->get_cart(); | |
| 719 | + if ( $cart && is_array( $cart ) && 0 < count( $cart ) ) { | |
| 720 | + // $idx = count( $cart ) - 1; | |
| 721 | + // $post_id = $cart[ $idx ]['post_id']; | |
| 722 | + // $sku = $cart[ $idx ]['sku']; | |
| 723 | + // $sku_code = esc_attr( urldecode( $sku ) ); | |
| 724 | + // $cartItemName = $usces->getCartItemName( $post_id, $sku_code, false ); | |
| 725 | + // $skuPrice = $cart[ $idx ]['price']; | |
| 726 | + | |
| 727 | + $query = $wpdb->prepare( | |
| 728 | + "UPDATE $order_table_name SET `order_cart`=%s WHERE ID = %d", | |
| 729 | + serialize( $cart ), | |
| 730 | + $ID | |
| 731 | + ); | |
| 732 | + $res = $wpdb->query( $query ); | |
| 733 | + | |
| 734 | + $usces->cart->crear_cart(); | |
| 735 | + } | |
| 736 | +} | |
| 737 | + | |
| 738 | +function usces_delete_serialized_cart() { | |
| 739 | + global $wpdb, $usces; | |
| 740 | + | |
| 741 | + if ( ! isset( $_REQUEST['order_id'] ) || WCUtils::is_blank( $_REQUEST['order_id'] ) ) { | |
| 742 | + return 0; | |
| 743 | + } | |
| 744 | + | |
| 745 | + $indexs = array_keys( $_POST['delButton'] ); | |
| 746 | + $index = $indexs[0]; | |
| 747 | + $ids = array_keys( $_POST['delButton'][ $index ] ); | |
| 748 | + $post_id = $ids[0]; | |
| 749 | + $skus = array_keys( $_POST['delButton'][ $index ][ $post_id ] ); | |
| 750 | + $sku = $skus[0]; | |
| 751 | + | |
| 752 | + $usces->up_serialize( $index, $post_id, $sku ); | |
| 753 | + do_action( 'usces_cart_del_row', $index ); | |
| 754 | + | |
| 755 | + if ( isset( $_SESSION['usces_cart'][ $usces->serial ] ) ) { | |
| 756 | + unset( $_SESSION['usces_cart'][ $usces->serial ] ); | |
| 757 | + } | |
| 758 | + | |
| 759 | + unset( $_SESSION['usces_entry']['order']['usedpoint'] ); | |
| 760 | +} | |
| 761 | + | |
| 762 | +function usces_get_serialized_cart( $order_id ) { | |
| 763 | + global $wpdb, $usces; | |
| 764 | + | |
| 765 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 766 | + $query = $wpdb->prepare( "SELECT order_cart FROM $order_table_name WHERE ID = %d", $order_id ); | |
| 767 | + $order_cart = $wpdb->get_var( $query ); | |
| 768 | + $cart = wel_safe_unserialize( $order_cart ); | |
| 769 | + foreach ( $cart as $cart_index => $cart_row ) { | |
| 770 | + $options = array(); | |
| 771 | + if ( ! empty( $cart_row['options'] ) ) { | |
| 772 | + foreach ( $cart_row['options'] as $key => $value ) { | |
| 773 | + $key = urldecode( $key ); | |
| 774 | + if ( is_array( $value ) ) { | |
| 775 | + foreach ( $value as $vk => $vv ) { | |
| 776 | + $value[ $vk ] = urldecode( $vv ); | |
| 777 | + } | |
| 778 | + $options[ $key ] = $value; | |
| 779 | + } else { | |
| 780 | + $options[ $key ] = urldecode( $value ); | |
| 781 | + } | |
| 782 | + } | |
| 783 | + $cart_row['options'] = $options; | |
| 784 | + } | |
| 785 | + $cart[ $cart_index ] = $cart_row; | |
| 786 | + } | |
| 787 | + return $cart; | |
| 788 | +} | |
| 789 | + | |
| 790 | +function usces_update_ordercart() { | |
| 791 | + $ordercart_table_name = $wpdb->prefix . 'usces_ordercart'; | |
| 792 | + foreach ( $_POST['skuPrice'] as $cart_id => $price ) { | |
| 793 | + $quantity = $_POST['quant'][ $cart_id ]; | |
| 794 | + $query = $wpdb->prepare( | |
| 795 | + "UPDATE $ordercart_table_name SET price = %f, quantity = %f WHERE cart_id = %d", | |
| 796 | + $price, $quantity, $cart_id | |
| 797 | + ); | |
| 798 | + $wpdb->query( $query ); | |
| 799 | + } | |
| 800 | + | |
| 801 | + $ordercart_meta_table_name = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 802 | + foreach ( $_POST['itemOption'] as $cartmeta_id => $value ) { | |
| 803 | + if ( is_array( $value ) ) { | |
| 804 | + foreach ( $value as $v ) { | |
| 805 | + $opval[ $v ] = $v; | |
| 806 | + } | |
| 807 | + $value = serialize( $opval ); | |
| 808 | + } | |
| 809 | + $query = $wpdb->prepare( | |
| 810 | + "UPDATE $ordercart_meta_table_name SET meta_value = %s WHERE cartmeta_id = %d", | |
| 811 | + $value, $cartmeta_id | |
| 812 | + ); | |
| 813 | + $wpdb->query( $query ); | |
| 814 | + } | |
| 815 | + // if ( false === $res ) { | |
| 816 | + // $res = "-1#usces#"; | |
| 817 | + // } else { | |
| 818 | + // $res = $skuPrice . "#usces#" . $cartItemName; | |
| 819 | + // } | |
| 820 | + // //return $res; | |
| 821 | +} | |
| 822 | + | |
| 823 | +function usces_update_ordercartdata( $order_id ) { | |
| 824 | + global $wpdb, $usces; | |
| 825 | + | |
| 826 | + if ( ! isset( $_POST['skuPrice'] ) ) { | |
| 827 | + return; | |
| 828 | + } | |
| 829 | + | |
| 830 | + $ordercart_table_name = $wpdb->prefix . 'usces_ordercart'; | |
| 831 | + $ordercart_meta_table_name = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 832 | + foreach ( (array) $_POST['skuPrice'] as $cart_id => $price ) { | |
| 833 | + $quantity = $_POST['quant'][ $cart_id ]; | |
| 834 | + $query = $wpdb->prepare( | |
| 835 | + "UPDATE $ordercart_table_name SET price = %f, quantity = %f WHERE cart_id = %d", | |
| 836 | + $price, $quantity, $cart_id | |
| 837 | + ); | |
| 838 | + $wpdb->query( $query ); | |
| 839 | + | |
| 840 | + // itemOptionチェックボックスとラジオのチェック. | |
| 841 | + $cart = usces_get_ordercartdata_row( $cart_id ); | |
| 842 | + $item_opts = usces_get_opts( $cart['post_id'], 'name', false ); | |
| 843 | + foreach ( $item_opts as $key => $iopts ) { | |
| 844 | + if ( 3 === (int) $iopts['means'] || 4 === (int) $iopts['means'] ) { | |
| 845 | + $cart_meta = usces_get_ordercart_meta( 'option', $cart_id, $iopts['name'] ); | |
| 846 | + $cart_meta_id = isset( $cart_meta[0]['cartmeta_id'] ) ? $cart_meta[0]['cartmeta_id'] : 'notfound'; | |
| 847 | + | |
| 848 | + // POSTが無ければmeta_valueをNULLに変更. | |
| 849 | + if ( ! isset( $_POST['itemOption'][ $cart_meta_id ] ) ) { | |
| 850 | + $query = $wpdb->prepare( | |
| 851 | + "UPDATE $ordercart_meta_table_name SET meta_value = %s WHERE cartmeta_id = %d", | |
| 852 | + NULL, $cart_meta_id | |
| 853 | + ); | |
| 854 | + $wpdb->query( $query ); | |
| 855 | + } | |
| 856 | + } | |
| 857 | + } | |
| 858 | + } | |
| 859 | + | |
| 860 | + if ( ! isset( $_POST['itemOption'] ) ) { | |
| 861 | + return; | |
| 862 | + } | |
| 863 | + | |
| 864 | + $ordercart_meta_table_name = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 865 | + foreach ( (array) $_POST['itemOption'] as $cartmeta_id => $value ) { | |
| 866 | + $post_id = usces_get_post_id_by_cartmeta_id( $cartmeta_id ); | |
| 867 | + $option_fields = usces_get_opts( $post_id, 'name' ); | |
| 868 | + $ordercart_metas = usces_get_ordercart_meta_by_id( $cartmeta_id ); | |
| 869 | + $means = $option_fields[ $ordercart_metas['meta_key'] ]['means']; | |
| 870 | + if ( is_array( $value ) ) { | |
| 871 | + $opval = array(); | |
| 872 | + if ( 4 === (int) $means ) { | |
| 873 | + foreach ( $value as $v ) { | |
| 874 | + $opval[] = urldecode( $v ); | |
| 875 | + } | |
| 876 | + } else { | |
| 877 | + foreach ( $value as $v ) { | |
| 878 | + $opval[ $v ] = urldecode( $v ); | |
| 879 | + } | |
| 880 | + } | |
| 881 | + $value = serialize( $opval ); | |
| 882 | + } else { | |
| 883 | + if ( 3 === (int) $means ) { | |
| 884 | + $value = urldecode( $value ); | |
| 885 | + } | |
| 886 | + } | |
| 887 | + $query = $wpdb->prepare( | |
| 888 | + "UPDATE $ordercart_meta_table_name SET meta_value = %s WHERE cartmeta_id = %d", | |
| 889 | + $value, $cartmeta_id | |
| 890 | + ); | |
| 891 | + $wpdb->query( $query ); | |
| 892 | + } | |
| 893 | +} | |
| 894 | + | |
| 895 | +function usces_delete_ordercartdata( $cart_id, $order_id = NULL ) { | |
| 896 | + global $wpdb, $usces; | |
| 897 | + | |
| 898 | + $ordercart_table_name = $wpdb->prefix . 'usces_ordercart'; | |
| 899 | + $ordercart_meta_table_name = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 900 | + | |
| 901 | + if ( NULL != $cart_id ) { | |
| 902 | + | |
| 903 | + $query = $wpdb->prepare( "DELETE FROM $ordercart_table_name WHERE cart_id = %d", $cart_id ); | |
| 904 | + $wpdb->query( $query ); | |
| 905 | + | |
| 906 | + $mquery = $wpdb->prepare( "DELETE FROM $ordercart_meta_table_name WHERE cart_id = %d", $cart_id ); | |
| 907 | + $wpdb->query( $mquery ); | |
| 908 | + | |
| 909 | + } elseif ( NULL != $order_id ) { | |
| 910 | + | |
| 911 | + $query = $wpdb->prepare( "SELECT cart_id FROM $ordercart_table_name WHERE order_id = %d", $order_id ); | |
| 912 | + $cat_ids = $wpdb->get_col( $query ); | |
| 913 | + | |
| 914 | + $query = $wpdb->prepare( "DELETE FROM $ordercart_table_name WHERE order_id = %d", $order_id ); | |
| 915 | + $wpdb->query( $query ); | |
| 916 | + | |
| 917 | + foreach ( $cat_ids as $id ) { | |
| 918 | + $mquery = $wpdb->prepare( "DELETE FROM $ordercart_meta_table_name WHERE cart_id = %d", $id ); | |
| 919 | + $wpdb->query( $mquery ); | |
| 920 | + } | |
| 921 | + } | |
| 922 | +} | |
| 923 | + | |
| 924 | +function usces_get_ordercartdata_row( $cart_id ) { | |
| 925 | + global $usces, $wpdb; | |
| 926 | + | |
| 927 | + $cart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 928 | + | |
| 929 | + $query = $wpdb->prepare( "SELECT * FROM $cart_table WHERE cart_id = %d", $cart_id ); | |
| 930 | + $cart = $wpdb->get_row( $query, ARRAY_A ); | |
| 931 | + return $cart; | |
| 932 | +} | |
| 933 | + | |
| 934 | +function usces_get_ordercartdata( $order_id ) { | |
| 935 | + global $usces, $wpdb; | |
| 936 | + | |
| 937 | + $cart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 938 | + $cart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 939 | + | |
| 940 | + $query = $wpdb->prepare( "SELECT * FROM $cart_table WHERE order_id = %d ORDER BY cart_id", $order_id ); | |
| 941 | + $cart = $wpdb->get_results( $query, ARRAY_A ); | |
| 942 | + | |
| 943 | + foreach ( $cart as $key => $value ) { | |
| 944 | + $cart[ $key ]['sku'] = $value['sku_code']; | |
| 945 | + $query = $wpdb->prepare( "SELECT * FROM $cart_meta_table WHERE cart_id = %d ORDER BY cartmeta_id", $value['cart_id'] ); | |
| 946 | + $results = $wpdb->get_results( $query, ARRAY_A ); | |
| 947 | + foreach ( (array) $results as $value ) { | |
| 948 | + switch ( $value['meta_type'] ) { | |
| 949 | + case 'option': | |
| 950 | + $cart[ $key ]['options'][ $value['meta_key'] ] = $value['meta_value']; | |
| 951 | + break; | |
| 952 | + case 'advance': | |
| 953 | + $cart[ $key ]['advance'][ $value['meta_key'] ] = $value['meta_value']; | |
| 954 | + break; | |
| 955 | + } | |
| 956 | + } | |
| 957 | + if ( ! isset( $cart[ $key ]['options'] ) ) { | |
| 958 | + $cart[ $key ]['options'] = array(); | |
| 959 | + } | |
| 960 | + if ( ! isset( $cart[ $key ]['advance'] ) ) { | |
| 961 | + $cart[ $key ]['advance'] = array(); | |
| 962 | + } | |
| 963 | + } | |
| 964 | + | |
| 965 | + return $cart; | |
| 966 | +} | |
| 967 | + | |
| 968 | +function usces_update_ordercheck() { | |
| 969 | + global $wpdb; | |
| 970 | + | |
| 971 | + $tableName = $wpdb->prefix . 'usces_order'; | |
| 972 | + $order_id = $_POST['order_id']; | |
| 973 | + $checked = $_POST['checked']; | |
| 974 | + $logger = Logger::start( $order_id, 'orderedit', 'update' ); | |
| 975 | + | |
| 976 | + $query = $wpdb->prepare( "SELECT `order_check` FROM $tableName WHERE ID = %d", $order_id ); | |
| 977 | + $res = $wpdb->get_var( $query ); | |
| 978 | + | |
| 979 | + $checkfield = ! empty( $res ) ? wel_safe_unserialize( $res ) : array(); | |
| 980 | + if ( ! is_array( $checkfield ) ) { | |
| 981 | + $checkfield = array(); | |
| 982 | + } | |
| 983 | + if ( ! isset( $checkfield[ $checked ] ) ) { | |
| 984 | + $checkfield[ $checked ] = $checked; | |
| 985 | + } | |
| 986 | + $query = $wpdb->prepare( "UPDATE $tableName SET `order_check` = %s WHERE ID = %d", serialize( $checkfield ), $order_id ); | |
| 987 | + $res = $wpdb->query( $query ); | |
| 988 | + | |
| 989 | + if ( $res ) { | |
| 990 | + $logger->flush(); | |
| 991 | + return $checked; | |
| 992 | + } else { | |
| 993 | + return 'error'; | |
| 994 | + } | |
| 995 | +} | |
| 996 | + | |
| 997 | +function usces_update_orderdata() { | |
| 998 | + global $wpdb, $usces; | |
| 999 | + | |
| 1000 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 1001 | + | |
| 1002 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 1003 | + $order_table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 1004 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 1005 | + | |
| 1006 | + $ID = $_REQUEST['order_id']; | |
| 1007 | + $old_cart = usces_get_ordercartdata( $ID ); | |
| 1008 | + | |
| 1009 | + $query = $wpdb->prepare( "SELECT * FROM $order_table_name WHERE ID = %d", $ID ); | |
| 1010 | + $old_orderdata = $wpdb->get_row( $query ); | |
| 1011 | + $old_status = $old_orderdata->order_status; | |
| 1012 | + | |
| 1013 | + if ( isset( $_POST['delButtonAdmin'] ) ) { | |
| 1014 | + foreach ( $_POST['delButtonAdmin'] as $del_cart_id => $delvalue ) { | |
| 1015 | + do_action( 'usces_admin_delete_orderrow', $del_cart_id, $ID, $old_cart ); | |
| 1016 | + usces_delete_ordercartdata( $del_cart_id, NULL ); | |
| 1017 | + } | |
| 1018 | + } else { | |
| 1019 | + usces_update_ordercartdata( $ID ); | |
| 1020 | + } | |
| 1021 | + | |
| 1022 | + $new_cart = usces_get_ordercartdata( $ID ); | |
| 1023 | + $gmtdate = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 1024 | + | |
| 1025 | + $item_total_price = $usces->get_total_price( $new_cart ); | |
| 1026 | + $taio = isset( $_POST['offer']['taio'] ) ? $_POST['offer']['taio'] : ''; | |
| 1027 | + $receipt = isset( $_POST['offer']['receipt'] ) ? $_POST['offer']['receipt'] : ''; | |
| 1028 | + $admin = isset( $_POST['offer']['admin'] ) ? $_POST['offer']['admin'] : ''; | |
| 1029 | + $status = $usces->make_status( $taio, $receipt, $admin ); | |
| 1030 | + if ( 'completion' === $taio || 'continuation' === $taio ) { | |
| 1031 | + if ( 'update' === $_POST['up_modified'] ) { | |
| 1032 | + $order_modified = substr( $gmtdate, 0, 10 ); | |
| 1033 | + } else { | |
| 1034 | + $order_modified = $_POST['modified']; | |
| 1035 | + } | |
| 1036 | + } else { | |
| 1037 | + $order_modified = ''; | |
| 1038 | + } | |
| 1039 | + $order_modified = apply_filters( 'usces_filter_update_orderdata_modified', $order_modified, $taio, $gmtdate, $old_orderdata ); | |
| 1040 | + $ordercheck = isset( $_POST['check'] ) ? serialize( $_POST['check'] ) : ''; | |
| 1041 | + $member_id = isset( $_POST['member_id'] ) ? $_POST['member_id'] : 0; | |
| 1042 | + | |
| 1043 | + if ( 'cancel' === $taio ) { | |
| 1044 | + $query = $wpdb->prepare( | |
| 1045 | + "UPDATE $order_table_name SET `order_modified` = %s, `order_status` = %s WHERE ID = %d", | |
| 1046 | + $order_modified, $status, $ID | |
| 1047 | + ); | |
| 1048 | + $res[0] = $wpdb->query( $query ); | |
| 1049 | + | |
| 1050 | + $query = $wpdb->prepare( "SELECT * FROM $order_table_name WHERE ID = %d", $ID ); | |
| 1051 | + $new_orderdata = $wpdb->get_row( $query ); | |
| 1052 | + | |
| 1053 | + if ( 'activate' == $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] && ! empty( $member_id ) && ! $usces->is_status( 'cancel', $old_status ) ) { | |
| 1054 | + $point = 0; | |
| 1055 | + if ( 0 < $old_orderdata->order_getpoint ) { | |
| 1056 | + if ( usces_is_complete_settlement( $old_orderdata->order_payment_name, $old_orderdata->order_status ) || $usces->is_status( 'receipted', $old_orderdata->order_status ) ) { | |
| 1057 | + $point += $old_orderdata->order_getpoint; | |
| 1058 | + } | |
| 1059 | + } | |
| 1060 | + if ( 0 < $old_orderdata->order_usedpoint ) { | |
| 1061 | + $point -= $old_orderdata->order_usedpoint; | |
| 1062 | + } | |
| 1063 | + if ( 0 !== $point ) { | |
| 1064 | + usces_restore_point( $member_id, $point ); | |
| 1065 | + } | |
| 1066 | + } | |
| 1067 | + | |
| 1068 | + do_action( 'usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata, $new_cart, $old_cart ); | |
| 1069 | + | |
| 1070 | + return 1; | |
| 1071 | + } | |
| 1072 | + | |
| 1073 | + $old_deli = wel_safe_unserialize( $old_orderdata->order_delivery ); | |
| 1074 | + foreach ( (array) $_POST['delivery'] as $dk => $dv ) { | |
| 1075 | + $old_deli[ $dk ] = $dv; | |
| 1076 | + } | |
| 1077 | + $delivery = serialize( $old_deli ); | |
| 1078 | + | |
| 1079 | + $delivery_date = ( isset( $_POST['offer']['delivery_date'] ) ) ? $_POST['offer']['delivery_date'] : ''; | |
| 1080 | + if ( ! usces_is_date( $delivery_date ) ) { | |
| 1081 | + $delivery_date = apply_filters( 'usces_filter_label_delivery_date_no_preference', __( 'Non-request', 'usces_dual' ) ); | |
| 1082 | + } | |
| 1083 | + | |
| 1084 | + $query = $wpdb->prepare( | |
| 1085 | + "UPDATE $order_table_name SET | |
| 1086 | + `mem_id`=%d, `order_email`=%s, `order_name1`=%s, `order_name2`=%s, `order_name3`=%s, `order_name4`=%s, | |
| 1087 | + `order_zip`=%s, `order_pref`=%s, `order_address1`=%s, `order_address2`=%s, `order_address3`=%s, | |
| 1088 | + `order_tel`=%s, `order_fax`=%s, `order_delivery`=%s, `order_note`=%s, | |
| 1089 | + `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, | |
| 1090 | + `order_discount`=%f, `order_shipping_charge`=%f, `order_cod_fee`=%f, `order_tax`=%f, `order_modified`=%s, | |
| 1091 | + `order_status`=%s, `order_delidue_date`=%s, `order_check`=%s | |
| 1092 | + WHERE ID = %d", | |
| 1093 | + $member_id, | |
| 1094 | + $_POST['customer']['mailaddress'], | |
| 1095 | + $_POST['customer']['name1'], | |
| 1096 | + $_POST['customer']['name2'], | |
| 1097 | + ( isset( $_POST['customer']['name3'] ) ? $_POST['customer']['name3'] : '' ), | |
| 1098 | + ( isset( $_POST['customer']['name4'] ) ? $_POST['customer']['name4'] : '' ), | |
| 1099 | + $_POST['customer']['zipcode'], | |
| 1100 | + $_POST['customer']['pref'], | |
| 1101 | + $_POST['customer']['address1'], | |
| 1102 | + $_POST['customer']['address2'], | |
| 1103 | + $_POST['customer']['address3'], | |
| 1104 | + $_POST['customer']['tel'], | |
| 1105 | + $_POST['customer']['fax'], | |
| 1106 | + $delivery, | |
| 1107 | + $_POST['offer']['note'], | |
| 1108 | + $_POST['offer']['delivery_method'], | |
| 1109 | + $delivery_date, | |
| 1110 | + $_POST['offer']['delivery_time'], | |
| 1111 | + $_POST['offer']['payment_name'], | |
| 1112 | + $item_total_price, | |
| 1113 | + $_POST['offer']['getpoint'], | |
| 1114 | + $_POST['offer']['usedpoint'], | |
| 1115 | + $_POST['offer']['discount'], | |
| 1116 | + $_POST['offer']['shipping_charge'], | |
| 1117 | + $_POST['offer']['cod_fee'], | |
| 1118 | + $_POST['offer']['tax'], | |
| 1119 | + $order_modified, | |
| 1120 | + $status, | |
| 1121 | + $_POST['offer']['delidue_date'], | |
| 1122 | + $ordercheck, | |
| 1123 | + $ID | |
| 1124 | + ); | |
| 1125 | + | |
| 1126 | + $res[0] = $wpdb->query( $query ); | |
| 1127 | + if ( false === $res[0] ) { | |
| 1128 | + return false; | |
| 1129 | + } | |
| 1130 | + | |
| 1131 | + $usces->set_order_meta_value( 'customer_country', $_POST['customer']['country'], $ID ); | |
| 1132 | + | |
| 1133 | + if ( usces_is_tax_display() && usces_is_reduced_taxrate( $ID ) ) { | |
| 1134 | + $usces->del_order_meta( 'subtotal_standard', $ID ); | |
| 1135 | + $usces->del_order_meta( 'subtotal_reduced', $ID ); | |
| 1136 | + $usces->del_order_meta( 'discount_standard', $ID ); | |
| 1137 | + $usces->del_order_meta( 'discount_reduced', $ID ); | |
| 1138 | + $usces->del_order_meta( 'tax_standard', $ID ); | |
| 1139 | + $usces->del_order_meta( 'tax_reduced', $ID ); | |
| 1140 | + if ( isset( $_POST['order_subtotal_standard'] ) && isset( $_POST['order_subtotal_reduced'] ) && isset( $_POST['order_discount_standard'] ) && isset( $_POST['order_discount_reduced'] ) && isset( $_POST['order_tax_standard'] ) && isset( $_POST['order_tax_reduced'] ) ) { | |
| 1141 | + $usces->set_order_meta_value( 'subtotal_standard', $_POST['order_subtotal_standard'], $ID ); | |
| 1142 | + $usces->set_order_meta_value( 'subtotal_reduced', $_POST['order_subtotal_reduced'], $ID ); | |
| 1143 | + $usces->set_order_meta_value( 'discount_standard', $_POST['order_discount_standard'], $ID ); | |
| 1144 | + $usces->set_order_meta_value( 'discount_reduced', $_POST['order_discount_reduced'], $ID ); | |
| 1145 | + if ( 'include' === $usces->options['tax_mode'] ) { | |
| 1146 | + $usces->set_order_meta_value( 'tax_standard', 0, $ID ); | |
| 1147 | + $usces->set_order_meta_value( 'tax_reduced', 0, $ID ); | |
| 1148 | + } else { | |
| 1149 | + $usces->set_order_meta_value( 'tax_standard', $_POST['order_tax_standard'], $ID ); | |
| 1150 | + $usces->set_order_meta_value( 'tax_reduced', $_POST['order_tax_reduced'], $ID ); | |
| 1151 | + } | |
| 1152 | + } else { | |
| 1153 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 1154 | + $materials = array( | |
| 1155 | + 'total_items_price' => $item_total_price, | |
| 1156 | + 'discount' => $_POST['offer']['discount'], | |
| 1157 | + 'shipping_charge' => $_POST['offer']['shipping_charge'], | |
| 1158 | + 'cod_fee' => $_POST['offer']['cod_fee'], | |
| 1159 | + 'use_point' => $_POST['offer']['usedpoint'], | |
| 1160 | + 'carts' => $new_cart, | |
| 1161 | + 'condition' => $old_orderdata->order_condition, | |
| 1162 | + ); | |
| 1163 | + $usces_tax->get_order_tax( $materials ); | |
| 1164 | + $usces->set_order_meta_value( 'subtotal_standard', $usces_tax->subtotal_standard, $ID ); | |
| 1165 | + $usces->set_order_meta_value( 'subtotal_reduced', $usces_tax->subtotal_reduced, $ID ); | |
| 1166 | + $usces->set_order_meta_value( 'discount_standard', $usces_tax->discount_standard, $ID ); | |
| 1167 | + $usces->set_order_meta_value( 'discount_reduced', $usces_tax->discount_reduced, $ID ); | |
| 1168 | + if ( 'include' === $usces->options['tax_mode'] ) { | |
| 1169 | + $usces->set_order_meta_value( 'tax_standard', 0, $ID ); | |
| 1170 | + $usces->set_order_meta_value( 'tax_reduced', 0, $ID ); | |
| 1171 | + } else { | |
| 1172 | + $usces->set_order_meta_value( 'tax_standard', $usces_tax->tax_standard, $ID ); | |
| 1173 | + $usces->set_order_meta_value( 'tax_reduced', $usces_tax->tax_reduced, $ID ); | |
| 1174 | + } | |
| 1175 | + } | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + $csod_meta = usces_has_custom_field_meta( 'order' ); | |
| 1179 | + if ( is_array( $csod_meta ) ) { | |
| 1180 | + foreach ( $csod_meta as $key => $entry ) { | |
| 1181 | + if ( 4 === (int) $entry['means'] ) { | |
| 1182 | + $usces->del_order_meta( 'csod_' . $key, $ID ); | |
| 1183 | + } | |
| 1184 | + } | |
| 1185 | + } | |
| 1186 | + $cscs_meta = usces_has_custom_field_meta( 'customer' ); | |
| 1187 | + if ( is_array( $cscs_meta ) ) { | |
| 1188 | + foreach ( $cscs_meta as $key => $entry ) { | |
| 1189 | + if ( 4 === (int) $entry['means'] ) { | |
| 1190 | + $usces->del_order_meta( 'cscs_' . $key, $ID ); | |
| 1191 | + } | |
| 1192 | + } | |
| 1193 | + } | |
| 1194 | + $csde_meta = usces_has_custom_field_meta( 'delivery' ); | |
| 1195 | + if ( is_array( $csde_meta ) ) { | |
| 1196 | + foreach ( $csde_meta as $key => $entry ) { | |
| 1197 | + if ( 4 === (int) $entry['means'] ) { | |
| 1198 | + $usces->del_order_meta( 'csde_' . $key, $ID ); | |
| 1199 | + } | |
| 1200 | + } | |
| 1201 | + } | |
| 1202 | + $i = 1; | |
| 1203 | + if ( ! empty( $_POST['custom_order'] ) ) { | |
| 1204 | + $csod_meta = usces_has_custom_field_meta( 'order' ); | |
| 1205 | + foreach ( $_POST['custom_order'] as $key => $value ) { | |
| 1206 | + if ( ! is_array( $csod_meta ) || ! isset( $csod_meta[ $key ] ) ) { | |
| 1207 | + continue; | |
| 1208 | + } | |
| 1209 | + $csod_key = 'csod_' . $key; | |
| 1210 | + if ( is_array( $value ) ) { | |
| 1211 | + $value = serialize( $value ); | |
| 1212 | + } | |
| 1213 | + $res[ $i ] = $usces->set_order_meta_value( $csod_key, $value, $ID ); | |
| 1214 | + if ( false === $res[ $i ] ) { | |
| 1215 | + return false; | |
| 1216 | + } | |
| 1217 | + $i++; | |
| 1218 | + } | |
| 1219 | + } | |
| 1220 | + if ( ! empty ( $_POST['custom_customer'] ) ) { | |
| 1221 | + foreach ( $_POST['custom_customer'] as $key => $value ) { | |
| 1222 | + $cscs_key = 'cscs_' . $key; | |
| 1223 | + if ( is_array( $value ) ) { | |
| 1224 | + $value = serialize( $value ); | |
| 1225 | + } | |
| 1226 | + $res[ $i ] = $usces->set_order_meta_value( $cscs_key, $value, $ID ); | |
| 1227 | + if ( false === $res[ $i ] ) { | |
| 1228 | + return false; | |
| 1229 | + } | |
| 1230 | + $i++; | |
| 1231 | + } | |
| 1232 | + } | |
| 1233 | + if ( ! empty( $_POST['custom_delivery'] ) ) { | |
| 1234 | + foreach ( $_POST['custom_delivery'] as $key => $value ) { | |
| 1235 | + $csde_key = 'csde_' . $key; | |
| 1236 | + if ( is_array( $value ) ) { | |
| 1237 | + $value = serialize( $value ); | |
| 1238 | + } | |
| 1239 | + $res[ $i ] = $usces->set_order_meta_value( $csde_key, $value, $ID ); | |
| 1240 | + if ( false === $res[ $i ] ) { | |
| 1241 | + return false; | |
| 1242 | + } | |
| 1243 | + $i++; | |
| 1244 | + } | |
| 1245 | + } | |
| 1246 | + | |
| 1247 | + if ( ! preg_match( '/pending|noreceipt/', $old_status ) && preg_match( '/pending|noreceipt/', $status ) ) { | |
| 1248 | + $rquery = $wpdb->prepare( "DELETE FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date' ); | |
| 1249 | + $wpdb->query( $rquery ); | |
| 1250 | + } elseif ( ! preg_match( '/pending|noreceipt/', $old_status ) && ! preg_match( '/pending|noreceipt/', $status ) ) { | |
| 1251 | + $query = $wpdb->prepare( "SELECT order_id FROM $order_table_meta_name WHERE order_id = %d AND meta_key = %s", $ID, 'receipted_date' ); | |
| 1252 | + $varres = $wpdb->get_var( $query ); | |
| 1253 | + if ( empty( $varres ) ) { | |
| 1254 | + $usces->set_order_meta_value( 'receipted_date', $gmtdate, $ID ); | |
| 1255 | + } | |
| 1256 | + } elseif ( preg_match( '/pending|noreceipt/', $old_status ) && ! preg_match( '/pending|noreceipt/', $status ) ) { | |
| 1257 | + $usces->set_order_meta_value( 'receipted_date', $gmtdate, $ID ); | |
| 1258 | + } | |
| 1259 | + | |
| 1260 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] && ! empty( $member_id ) ) { | |
| 1261 | + $point = 0; | |
| 1262 | + $getpoint = ( ! empty( $_POST['offer']['getpoint'] ) ) ? (int) $_POST['offer']['getpoint'] : 0; | |
| 1263 | + $usedpoint = ( ! empty( $_POST['offer']['usedpoint'] ) ) ? (int) $_POST['offer']['usedpoint'] : 0; | |
| 1264 | + if ( $usces->is_status( 'cancel', $old_status ) && ! $usces->is_status( 'cancel', $status ) ) { // キャンセル→新規受付・取り寄せ中・発送済み. | |
| 1265 | + if ( 0 < $getpoint ) { | |
| 1266 | + if ( usces_is_complete_settlement( $_POST['offer']['payment_name'], $status ) || $usces->is_status( 'receipted', $status ) ) { | |
| 1267 | + $point -= $getpoint; | |
| 1268 | + } | |
| 1269 | + } | |
| 1270 | + if ( 0 < $usedpoint ) { | |
| 1271 | + $point += $usedpoint; | |
| 1272 | + } | |
| 1273 | + } else { | |
| 1274 | + if ( ! usces_is_complete_settlement( $_POST['offer']['payment_name'] ) ) { | |
| 1275 | + if ( ! preg_match( '/pending|noreceipt/', $old_status ) && preg_match( '/pending|noreceipt/', $status ) ) { // 入金→未入金. | |
| 1276 | + $point += $getpoint; // ポイント取消. | |
| 1277 | + } elseif ( preg_match( '/pending|noreceipt/', $old_status ) && !preg_match( '/pending|noreceipt/', $status ) ) { // 未入金→入金. | |
| 1278 | + $point -= $getpoint; // ポイント追加. | |
| 1279 | + } elseif ( preg_match( '/pending|noreceipt/', $old_status ) && preg_match( '/pending|noreceipt/', $status ) ) { // 未入金→未入金. | |
| 1280 | + $point = 0; // ポイント追加. | |
| 1281 | + } else { | |
| 1282 | + if ( $old_orderdata->order_getpoint != $getpoint ) { | |
| 1283 | + $point += $old_orderdata->order_getpoint - $getpoint; | |
| 1284 | + } | |
| 1285 | + } | |
| 1286 | + } else { | |
| 1287 | + if ( $old_orderdata->order_getpoint != $getpoint ) { | |
| 1288 | + $point += $old_orderdata->order_getpoint - $getpoint; | |
| 1289 | + } | |
| 1290 | + } | |
| 1291 | + if ( $old_orderdata->order_usedpoint != $usedpoint ) { | |
| 1292 | + $point -= $old_orderdata->order_usedpoint - $usedpoint; | |
| 1293 | + } | |
| 1294 | + } | |
| 1295 | + if ( 0 != $point ) { | |
| 1296 | + usces_restore_point( $member_id, $point ); | |
| 1297 | + } | |
| 1298 | + } | |
| 1299 | + | |
| 1300 | + $result = ( 0 < array_sum( array_filter( $res, 'is_numeric' ) ) ) ? 1 : 0; | |
| 1301 | + | |
| 1302 | + $query = $wpdb->prepare( "SELECT * FROM $order_table_name WHERE ID = %d", $ID ); | |
| 1303 | + $new_orderdata = $wpdb->get_row( $query ); | |
| 1304 | + do_action( 'usces_action_update_orderdata', $new_orderdata, $old_status, $old_orderdata, $new_cart, $old_cart ); | |
| 1305 | + $usces->cart->crear_cart(); | |
| 1306 | + | |
| 1307 | + return $result; | |
| 1308 | +} | |
| 1309 | + | |
| 1310 | +function usces_all_change_zaiko( &$obj ) { | |
| 1311 | + global $wpdb, $usces; | |
| 1312 | + | |
| 1313 | + $ids = filter_input( INPUT_POST, 'listcheck', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); | |
| 1314 | + $change = filter_input( INPUT_POST, 'change', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); | |
| 1315 | + $zaiko = ( null !== $change && false !== $change ) ? (int) $change['word']['zaiko'] : 0; | |
| 1316 | + $status = true; | |
| 1317 | + foreach ( (array) $ids as $post_id ) { | |
| 1318 | + $skus = wel_get_skus( $post_id, 'sort', false ); | |
| 1319 | + foreach ( (array) $skus as $sku ) { | |
| 1320 | + $res = usces_update_sku( $post_id, $sku['code'], 'stock', $zaiko ); | |
| 1321 | + if ( ! $res ) { | |
| 1322 | + $status = false; | |
| 1323 | + } | |
| 1324 | + } | |
| 1325 | + } | |
| 1326 | + | |
| 1327 | + if ( true === $status ) { | |
| 1328 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1329 | + } elseif ( false === $status ) { | |
| 1330 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1331 | + } else { | |
| 1332 | + $obj->set_action_status( 'none', '' ); | |
| 1333 | + } | |
| 1334 | +} | |
| 1335 | + | |
| 1336 | +function usces_all_change_itemdisplay( &$obj ) { | |
| 1337 | + global $wpdb; | |
| 1338 | + | |
| 1339 | + $ids = $_POST['listcheck']; | |
| 1340 | + $post_status = $_POST['change']['word']['display_status']; | |
| 1341 | + $status = true; | |
| 1342 | + foreach ( (array) $ids as $post_id ) { | |
| 1343 | + $post_data = array( 'ID' => $post_id, 'post_status' => $post_status ); | |
| 1344 | + $res = wp_update_post( $post_data ); | |
| 1345 | + if ( 0 === $res ) { | |
| 1346 | + $status = false; | |
| 1347 | + } | |
| 1348 | + } | |
| 1349 | + if ( true === $status ) { | |
| 1350 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1351 | + } elseif ( false === $status ) { | |
| 1352 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1353 | + } else { | |
| 1354 | + $obj->set_action_status( 'none', '' ); | |
| 1355 | + } | |
| 1356 | +} | |
| 1357 | + | |
| 1358 | +function usces_all_change_order_reciept( &$obj ) { | |
| 1359 | + global $wpdb, $usces; | |
| 1360 | + | |
| 1361 | + $tableName = $wpdb->prefix . 'usces_order'; | |
| 1362 | + $ids = $_POST['listcheck']; | |
| 1363 | + if ( isset( $_REQUEST['change']['word'] ) && ! is_array( $_REQUEST['change']['word'] ) ) { | |
| 1364 | + $change_word = $_REQUEST['change']['word']; | |
| 1365 | + } elseif ( isset( $_REQUEST['change']['word']['order_reciept'] ) ) { | |
| 1366 | + $change_word = $_REQUEST['change']['word']['order_reciept']; | |
| 1367 | + } else { | |
| 1368 | + $change_word = ''; | |
| 1369 | + } | |
| 1370 | + $status = true; | |
| 1371 | + foreach ( (array) $ids as $id ) { | |
| 1372 | + $logger = Logger::start( $id, 'orderlist', 'update' ); | |
| 1373 | + $query = $wpdb->prepare( "SELECT order_status, mem_id, order_getpoint, order_payment_name FROM $tableName WHERE ID = %d", $id ); | |
| 1374 | + $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 1375 | + $statusstr = $order_res['order_status']; | |
| 1376 | + $restore_point = false; | |
| 1377 | + $getpoint = $order_res['order_getpoint']; | |
| 1378 | + if ( false !== strpos( $statusstr, 'cancel' ) ) { | |
| 1379 | + continue; | |
| 1380 | + } | |
| 1381 | + if ( false === strpos( $statusstr, 'noreceipt' ) && false === strpos( $statusstr, 'receipted' ) ) { | |
| 1382 | + continue; | |
| 1383 | + } | |
| 1384 | + $old_status = $statusstr; | |
| 1385 | + if ( $change_word == 'receipted' ) { | |
| 1386 | + if ( false !== strpos( $statusstr, 'noreceipt' ) ) { // 未入金→入金. | |
| 1387 | + $statusstr = str_replace( 'noreceipt', 'receipted', $statusstr ); | |
| 1388 | + if ( ! usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1389 | + $restore_point = true; | |
| 1390 | + $getpoint = $getpoint * -1; // add point. | |
| 1391 | + } | |
| 1392 | + } | |
| 1393 | + } elseif ( $change_word == 'noreceipt' ) { | |
| 1394 | + if ( false !== strpos( $statusstr, 'receipted' ) ) { // 入金済み→未入金. | |
| 1395 | + $statusstr = str_replace( 'receipted', 'noreceipt', $statusstr ); | |
| 1396 | + if ( ! usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1397 | + $restore_point = true; | |
| 1398 | + } | |
| 1399 | + } | |
| 1400 | + } | |
| 1401 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1402 | + $res = $wpdb->query( $query ); | |
| 1403 | + if ( false === $res ) { | |
| 1404 | + $status = false; | |
| 1405 | + } | |
| 1406 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] ) { | |
| 1407 | + if ( ! empty( $order_res['mem_id'] ) && 0 < $order_res['order_getpoint'] ) { | |
| 1408 | + if ( $res && $restore_point ) { | |
| 1409 | + usces_restore_point( $order_res['mem_id'], $getpoint ); | |
| 1410 | + } | |
| 1411 | + } | |
| 1412 | + } | |
| 1413 | + if ( $status ) { | |
| 1414 | + do_action( 'usces_action_collective_order_reciept_each', $id, $statusstr, $old_status ); | |
| 1415 | + } | |
| 1416 | + if ( ! empty( $res ) ) { | |
| 1417 | + $logger->flush(); | |
| 1418 | + } | |
| 1419 | + } | |
| 1420 | + if ( true === $status ) { | |
| 1421 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1422 | + } elseif ( false === $status ) { | |
| 1423 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1424 | + } else { | |
| 1425 | + $obj->set_action_status( 'none', '' ); | |
| 1426 | + } | |
| 1427 | + do_action( 'usces_action_collective_order_reciept', array( &$obj ) ); | |
| 1428 | +} | |
| 1429 | + | |
| 1430 | +function usces_all_change_order_status( &$obj ) { | |
| 1431 | + global $wpdb, $usces; | |
| 1432 | + | |
| 1433 | + $tableName = $wpdb->prefix . 'usces_order'; | |
| 1434 | + $ids = $_POST['listcheck']; | |
| 1435 | + foreach ( (array) $ids as $id ) { | |
| 1436 | + $status = true; | |
| 1437 | + $query = $wpdb->prepare( "SELECT order_status, mem_id, order_getpoint, order_usedpoint, order_payment_name FROM $tableName WHERE ID = %d", $id ); | |
| 1438 | + $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 1439 | + $statusstr = $order_res['order_status']; | |
| 1440 | + $restore_point = false; | |
| 1441 | + $getpoint = $order_res['order_getpoint']; | |
| 1442 | + $usedpoint = $order_res['order_usedpoint']; | |
| 1443 | + $old_status = $statusstr; | |
| 1444 | + if ( isset( $_REQUEST['change']['word'] ) && ! is_array( $_REQUEST['change']['word'] ) ) { | |
| 1445 | + $change_word = $_REQUEST['change']['word']; | |
| 1446 | + } elseif ( isset( $_REQUEST['change']['word']['order_reciept'] ) ) { | |
| 1447 | + $change_word = $_REQUEST['change']['word']['order_reciept']; | |
| 1448 | + } elseif ( isset( $_REQUEST['change']['word']['order_status'] ) ) { | |
| 1449 | + $change_word = $_REQUEST['change']['word']['order_status']; | |
| 1450 | + } else { | |
| 1451 | + $change_word = ''; | |
| 1452 | + } | |
| 1453 | + $query = ''; | |
| 1454 | + switch ( $change_word ) { | |
| 1455 | + case 'estimate': | |
| 1456 | + if ( false !== strpos( $statusstr, 'adminorder' ) ) { | |
| 1457 | + $statusstr = str_replace( 'adminorder', 'estimate', $statusstr ); | |
| 1458 | + } elseif ( false === strpos( $statusstr, 'estimate' ) ) { | |
| 1459 | + if ( ',' !== substr( $statusstr, -1 ) ) { | |
| 1460 | + $statusstr .= ','; | |
| 1461 | + } | |
| 1462 | + $statusstr .= 'estimate,'; | |
| 1463 | + } | |
| 1464 | + if ( false === strpos( $statusstr, 'cancel' ) ) { | |
| 1465 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1466 | + $restore_point = true; | |
| 1467 | + $usedpoint = $usedpoint * -1; // add point. | |
| 1468 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1469 | + $restore_point = true; | |
| 1470 | + $usedpoint = $usedpoint * -1; // add point. | |
| 1471 | + } | |
| 1472 | + } | |
| 1473 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1474 | + break; | |
| 1475 | + case 'adminorder': | |
| 1476 | + if ( false !== strpos( $statusstr, 'estimate' ) ) { | |
| 1477 | + $statusstr = str_replace( 'estimate', 'adminorder', $statusstr ); | |
| 1478 | + if ( false === strpos( $statusstr, 'cancel' ) ) { | |
| 1479 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1480 | + $restore_point = true; | |
| 1481 | + $getpoint = $getpoint * -1; // add point. | |
| 1482 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1483 | + $restore_point = true; | |
| 1484 | + $getpoint = $getpoint * -1; //add point. | |
| 1485 | + } | |
| 1486 | + } | |
| 1487 | + } elseif ( false === strpos( $statusstr, 'adminorder' ) ) { | |
| 1488 | + if ( ',' !== substr( $statusstr, -1 ) ) { | |
| 1489 | + $statusstr .= ','; | |
| 1490 | + } | |
| 1491 | + $statusstr .= 'adminorder,'; | |
| 1492 | + } | |
| 1493 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1494 | + break; | |
| 1495 | + case 'frontorder': | |
| 1496 | + if ( false !== strpos( $statusstr, 'estimate' ) ) { | |
| 1497 | + $statusstr = str_replace( 'estimate,', '', $statusstr ); | |
| 1498 | + $statusstr = trim( $statusstr, ',' ); | |
| 1499 | + if ( false === strpos( $statusstr, 'cancel' ) ) { | |
| 1500 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1501 | + $restore_point = true; | |
| 1502 | + $getpoint = $getpoint * -1; // add point. | |
| 1503 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1504 | + $restore_point = true; | |
| 1505 | + $getpoint = $getpoint * -1; // add point. | |
| 1506 | + } | |
| 1507 | + } | |
| 1508 | + } elseif ( false !== strpos( $statusstr, 'adminorder' ) ) { | |
| 1509 | + $statusstr = str_replace( 'adminorder,', '', $statusstr ); | |
| 1510 | + $statusstr = trim( $statusstr, ',' ); | |
| 1511 | + } | |
| 1512 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1513 | + break; | |
| 1514 | + case 'duringorder': | |
| 1515 | + if ( false !== strpos( $statusstr, 'cancel' ) ) { | |
| 1516 | + $statusstr = str_replace( 'cancel', '', $statusstr ); | |
| 1517 | + $statusstr = trim( $statusstr, ',' ); | |
| 1518 | + if ( false === strpos( $statusstr, 'estimate' ) ) { | |
| 1519 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1520 | + $restore_point = true; | |
| 1521 | + $getpoint = $getpoint * -1; // add point. | |
| 1522 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1523 | + $restore_point = true; | |
| 1524 | + $getpoint = $getpoint * -1; // add point. | |
| 1525 | + } | |
| 1526 | + } | |
| 1527 | + } | |
| 1528 | + if ( false !== strpos( $statusstr, 'completion' ) ) { | |
| 1529 | + $statusstr = str_replace( 'completion', '', $statusstr ); | |
| 1530 | + $statusstr = trim( $statusstr, ',' ); | |
| 1531 | + } | |
| 1532 | + if ( false !== strpos( $statusstr, 'new' ) ) { | |
| 1533 | + $statusstr = str_replace( 'new', '', $statusstr ); | |
| 1534 | + $statusstr = trim( $statusstr, ',' ); | |
| 1535 | + } | |
| 1536 | + if ( false === strpos( $statusstr, 'duringorder' ) ) { | |
| 1537 | + if ( ',' !== substr( $statusstr, -1 ) ) { | |
| 1538 | + $statusstr .= ','; | |
| 1539 | + } | |
| 1540 | + $statusstr .= 'duringorder,'; | |
| 1541 | + } | |
| 1542 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1543 | + break; | |
| 1544 | + case 'cancel': | |
| 1545 | + if ( false !== strpos( $statusstr, 'completion' ) ) { | |
| 1546 | + $statusstr = str_replace( 'completion', '', $statusstr ); | |
| 1547 | + $statusstr = trim( $statusstr, ',' ); | |
| 1548 | + } | |
| 1549 | + if ( false !== strpos( $statusstr, 'new' ) ) { | |
| 1550 | + $statusstr = str_replace( 'new', '', $statusstr ); | |
| 1551 | + $statusstr = trim( $statusstr, ',' ); | |
| 1552 | + } | |
| 1553 | + if ( false !== strpos( $statusstr, 'duringorder' ) ) { | |
| 1554 | + $statusstr = str_replace( 'duringorder', '', $statusstr ); | |
| 1555 | + $statusstr = trim( $statusstr, ',' ); | |
| 1556 | + } | |
| 1557 | + if ( false === strpos( $statusstr, 'cancel' ) ) { | |
| 1558 | + if ( ',' !== substr( $statusstr, -1 ) ) { | |
| 1559 | + $statusstr .= ','; | |
| 1560 | + } | |
| 1561 | + $statusstr .= 'cancel,'; | |
| 1562 | + } | |
| 1563 | + if ( false === strpos( $statusstr, 'estimate' ) ) { | |
| 1564 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1565 | + $restore_point = true; | |
| 1566 | + $usedpoint = $usedpoint * -1; // add point. | |
| 1567 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1568 | + $restore_point = true; | |
| 1569 | + $usedpoint = $usedpoint * -1; // add point. | |
| 1570 | + } | |
| 1571 | + } | |
| 1572 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1573 | + break; | |
| 1574 | + case 'completion': | |
| 1575 | + if ( false !== strpos( $statusstr, 'new' ) ) { | |
| 1576 | + $statusstr = str_replace( 'new', '', $statusstr ); | |
| 1577 | + $statusstr = trim( $statusstr, ',' ); | |
| 1578 | + } | |
| 1579 | + if ( false !== strpos( $statusstr, 'duringorder' ) ) { | |
| 1580 | + $statusstr = str_replace( 'duringorder', '', $statusstr ); | |
| 1581 | + $statusstr = trim( $statusstr, ',' ); | |
| 1582 | + } | |
| 1583 | + if ( false !== strpos( $statusstr, 'cancel' ) ) { | |
| 1584 | + $statusstr = str_replace( 'cancel', '', $statusstr ); | |
| 1585 | + $statusstr = trim( $statusstr, ',' ); | |
| 1586 | + if ( false === strpos( $statusstr, 'estimate' ) ) { | |
| 1587 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1588 | + $restore_point = true; | |
| 1589 | + $getpoint = $getpoint * -1; // add point. | |
| 1590 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1591 | + $restore_point = true; | |
| 1592 | + $getpoint = $getpoint * -1; // add point. | |
| 1593 | + } | |
| 1594 | + } | |
| 1595 | + } | |
| 1596 | + if ( false === strpos( $statusstr, 'completion' ) ) { | |
| 1597 | + if ( ',' !== substr( $statusstr, -1 ) ) { | |
| 1598 | + $statusstr .= ','; | |
| 1599 | + } | |
| 1600 | + $statusstr .= 'completion,'; | |
| 1601 | + } | |
| 1602 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s, order_modified = %s WHERE ID = %d", $statusstr, substr( current_time( 'mysql' ), 0, 10 ), $id ); | |
| 1603 | + break; | |
| 1604 | + case 'new': | |
| 1605 | + case 'neworder': | |
| 1606 | + if ( false !== strpos( $statusstr, 'duringorder' ) ) { | |
| 1607 | + $statusstr = str_replace( 'duringorder,', '', $statusstr ); | |
| 1608 | + $statusstr = trim( $statusstr, ',' ); | |
| 1609 | + } | |
| 1610 | + if ( false !== strpos( $statusstr, 'completion' ) ) { | |
| 1611 | + $statusstr = str_replace( 'completion,', '', $statusstr ); | |
| 1612 | + $statusstr = trim( $statusstr, ',' ); | |
| 1613 | + } | |
| 1614 | + if ( false !== strpos( $statusstr, 'cancel' ) ) { | |
| 1615 | + $statusstr = str_replace( 'cancel,', '', $statusstr ); | |
| 1616 | + $statusstr = trim( $statusstr, ',' ); | |
| 1617 | + if ( false === strpos( $statusstr, 'estimate' ) ) { | |
| 1618 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) ) { | |
| 1619 | + $restore_point = true; | |
| 1620 | + $getpoint = $getpoint * -1; // add point. | |
| 1621 | + } elseif ( $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1622 | + $restore_point = true; | |
| 1623 | + $getpoint = $getpoint * -1; // add point. | |
| 1624 | + } | |
| 1625 | + } | |
| 1626 | + } | |
| 1627 | + $query = $wpdb->prepare( "UPDATE $tableName SET order_status = %s WHERE ID = %d", $statusstr, $id ); | |
| 1628 | + break; | |
| 1629 | + default: | |
| 1630 | + $query = apply_filters( 'usces_filter_collective_order_status_query', $query, $statusstr, $id ); | |
| 1631 | + } | |
| 1632 | + if ( ! empty ( $query ) ) { | |
| 1633 | + $logger = Logger::start( $id, 'orderlist', 'update' ); | |
| 1634 | + $res = $wpdb->query( $query ); | |
| 1635 | + if ( false === $res ) { | |
| 1636 | + $status = false; | |
| 1637 | + } | |
| 1638 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] ) { | |
| 1639 | + if ( ! empty( $order_res['mem_id'] ) && ( 0 < $order_res['order_getpoint'] || 0 < $order_res['order_usedpoint'] ) ) { | |
| 1640 | + if ( $res && $restore_point ) { | |
| 1641 | + usces_restore_point( $order_res['mem_id'], $getpoint + $usedpoint ); | |
| 1642 | + } | |
| 1643 | + } | |
| 1644 | + } | |
| 1645 | + if ( $status ) { | |
| 1646 | + do_action( 'usces_action_collective_order_status_each', $id, $statusstr, $old_status ); | |
| 1647 | + $logger->flush(); | |
| 1648 | + } | |
| 1649 | + } | |
| 1650 | + } | |
| 1651 | + if ( true === $status ) { | |
| 1652 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1653 | + } elseif ( false === $status ) { | |
| 1654 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1655 | + } else { | |
| 1656 | + $obj->set_action_status( 'none', '' ); | |
| 1657 | + } | |
| 1658 | + do_action( 'usces_action_collective_order_status', array( &$obj ) ); | |
| 1659 | +} | |
| 1660 | + | |
| 1661 | +function usces_all_delete_order_data( &$obj ) { | |
| 1662 | + global $wpdb, $usces; | |
| 1663 | + | |
| 1664 | + $tableName = $wpdb->prefix . 'usces_order'; | |
| 1665 | + $tableMetaName = $wpdb->prefix . 'usces_order_meta'; | |
| 1666 | + $ids = $_POST['listcheck']; | |
| 1667 | + $status = true; | |
| 1668 | + foreach ( (array) $ids as $id ) { | |
| 1669 | + $del = usces_delete_order_check( $id ); | |
| 1670 | + if ( false === $del ) { | |
| 1671 | + continue; | |
| 1672 | + } | |
| 1673 | + $logger = Logger::start( $id, 'orderlist', 'delete' ); | |
| 1674 | + $point = 0; | |
| 1675 | + $query = $wpdb->prepare( "SELECT * FROM $tableName WHERE ID = %d", $id ); | |
| 1676 | + $order_res = $wpdb->get_row( $query, ARRAY_A ); | |
| 1677 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] && ! empty( $order_res['mem_id'] ) && ! $usces->is_status( 'cancel', $order_res['order_status'] ) ) { | |
| 1678 | + if ( 0 < $order_res['order_getpoint'] ) { | |
| 1679 | + if ( usces_is_complete_settlement( $order_res['order_payment_name'], $order_res['order_status'] ) || $usces->is_status( 'receipted', $order_res['order_status'] ) ) { | |
| 1680 | + $point += $order_res['order_getpoint']; | |
| 1681 | + } | |
| 1682 | + } | |
| 1683 | + if ( 0 < $order_res['order_usedpoint'] ) { | |
| 1684 | + $point -= $order_res['order_usedpoint']; | |
| 1685 | + } | |
| 1686 | + } | |
| 1687 | + $query = $wpdb->prepare( "DELETE FROM $tableName WHERE ID = %d", $id ); | |
| 1688 | + $res = $wpdb->query( $query ); | |
| 1689 | + if ( false === $res ) { | |
| 1690 | + $status = false; | |
| 1691 | + } else { | |
| 1692 | + | |
| 1693 | + if ( 0 != $point ) { | |
| 1694 | + usces_restore_point( $order_res['mem_id'], $point ); | |
| 1695 | + } | |
| 1696 | + | |
| 1697 | + do_action( 'usces_action_collective_order_delete_each', $id, $order_res ); | |
| 1698 | + | |
| 1699 | + usces_delete_ordercartdata( NULL, $id ); | |
| 1700 | + | |
| 1701 | + $metaquery = $wpdb->prepare( "DELETE FROM $tableMetaName WHERE order_id = %d", $id ); | |
| 1702 | + $metares = $wpdb->query( $metaquery ); | |
| 1703 | + $logger->flush(); | |
| 1704 | + } | |
| 1705 | + } | |
| 1706 | + if ( true === $status ) { | |
| 1707 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1708 | + } elseif ( false === $status ) { | |
| 1709 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1710 | + } else { | |
| 1711 | + $obj->set_action_status( 'none', '' ); | |
| 1712 | + } | |
| 1713 | + do_action( 'usces_action_collective_order_delete', array( &$obj ) ); | |
| 1714 | +} | |
| 1715 | + | |
| 1716 | +function usces_all_change_member_rank( &$obj ) { | |
| 1717 | + global $wpdb, $usces; | |
| 1718 | + | |
| 1719 | + $tableName = usces_get_tablename( 'usces_member' ); | |
| 1720 | + $ids = $_POST['listcheck']; | |
| 1721 | + $status = true; | |
| 1722 | + | |
| 1723 | + foreach ( (array) $ids as $id ) { | |
| 1724 | + $logger = Logger::start( $id, 'memberlist', 'update' ); | |
| 1725 | + $value = isset( $_REQUEST['change']['word'] ) ? $_REQUEST['change']['word'] : ''; | |
| 1726 | + $query = $wpdb->prepare( "UPDATE $tableName SET mem_status = %d WHERE ID = %d", $value, $id ); | |
| 1727 | + $res = $wpdb->query( $query ); | |
| 1728 | + if ( false === $res ) { | |
| 1729 | + $status = false; | |
| 1730 | + } | |
| 1731 | + if ( $status ) { | |
| 1732 | + do_action( 'usces_action_collective_member_rank_each', $id, $value ); | |
| 1733 | + } | |
| 1734 | + $logger->flush(); | |
| 1735 | + } | |
| 1736 | + | |
| 1737 | + if ( true === $status ) { | |
| 1738 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1739 | + } elseif ( false === $status ) { | |
| 1740 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1741 | + } else { | |
| 1742 | + $obj->set_action_status( 'none', '' ); | |
| 1743 | + } | |
| 1744 | + do_action( 'usces_action_collective_member_rank', array( &$obj ) ); | |
| 1745 | +} | |
| 1746 | + | |
| 1747 | +function usces_all_change_member_point( &$obj ) { | |
| 1748 | + global $wpdb, $usces; | |
| 1749 | + | |
| 1750 | + $tableName = usces_get_tablename( 'usces_member' ); | |
| 1751 | + $ids = $_POST['listcheck']; | |
| 1752 | + $status = true; | |
| 1753 | + | |
| 1754 | + foreach ( (array) $ids as $id ) { | |
| 1755 | + $logger = Logger::start( $id, 'memberlist', 'update' ); | |
| 1756 | + $value = isset( $_REQUEST['change']['word'] ) ? $_REQUEST['change']['word'] : ''; | |
| 1757 | + $query = $wpdb->prepare( "UPDATE $tableName SET mem_point = %d WHERE ID = %d", $value, $id ); | |
| 1758 | + $res = $wpdb->query( $query ); | |
| 1759 | + if ( false === $res ) { | |
| 1760 | + $status = false; | |
| 1761 | + } | |
| 1762 | + if ( $status ) { | |
| 1763 | + do_action( 'usces_action_collective_member_point_each', $id, $value ); | |
| 1764 | + } | |
| 1765 | + $logger->flush(); | |
| 1766 | + } | |
| 1767 | + | |
| 1768 | + if ( true === $status ) { | |
| 1769 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1770 | + } elseif ( false === $status ) { | |
| 1771 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1772 | + } else { | |
| 1773 | + $obj->set_action_status( 'none', '' ); | |
| 1774 | + } | |
| 1775 | + do_action( 'usces_action_collective_member_point', array( &$obj ) ); | |
| 1776 | +} | |
| 1777 | + | |
| 1778 | +function usces_all_delete_member_data( &$obj ) { | |
| 1779 | + global $wpdb, $usces; | |
| 1780 | + | |
| 1781 | + $ids = $_POST['listcheck']; | |
| 1782 | + $status = true; | |
| 1783 | + | |
| 1784 | + foreach ( (array) $ids as $id ) { | |
| 1785 | + $del = usces_delete_member_check( $id ); | |
| 1786 | + if ( false === $del ) { | |
| 1787 | + continue; | |
| 1788 | + } | |
| 1789 | + $logger = Logger::start( $id, 'memberlist', 'delete'); | |
| 1790 | + $old_data = $usces->get_member_info( $id ); | |
| 1791 | + $res = usces_delete_memberdata( $id ); | |
| 1792 | + if ( false === $res ) { | |
| 1793 | + $status = false; | |
| 1794 | + do_action( 'usces_action_collective_member_delete_each', $id, $old_data ); | |
| 1795 | + } else { | |
| 1796 | + $logger->flush(); | |
| 1797 | + } | |
| 1798 | + } | |
| 1799 | + | |
| 1800 | + if ( true === $status ) { | |
| 1801 | + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) ); | |
| 1802 | + } elseif ( false === $status ) { | |
| 1803 | + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) ); | |
| 1804 | + } else { | |
| 1805 | + $obj->set_action_status( 'none', '' ); | |
| 1806 | + } | |
| 1807 | + do_action( 'usces_action_collective_member_delete', array( &$obj ) ); | |
| 1808 | +} | |
| 1809 | + | |
| 1810 | +function usces_check_acting_return() { | |
| 1811 | + global $usces; | |
| 1812 | + | |
| 1813 | + $entry = $usces->cart->get_entry(); | |
| 1814 | + | |
| 1815 | + $acting = ( isset( $_GET['acting'] ) ) ? $_GET['acting'] : ''; | |
| 1816 | + $results = array(); | |
| 1817 | + switch ( $acting ) { | |
| 1818 | + case 'epsilon': | |
| 1819 | + if ( isset( $_GET['duplicate'] ) && $_GET['duplicate'] == 1 ) { | |
| 1820 | + $results[0] = 'duplicate'; | |
| 1821 | + } elseif ( isset( $_GET['result'] ) ) { | |
| 1822 | + $results[0] = (int) $_GET['result']; | |
| 1823 | + $results['reg_order'] = true; | |
| 1824 | + } else { | |
| 1825 | + $str = explode( '?', $_GET['acting_return'] ); | |
| 1826 | + if ( ! isset( $str[1] ) ) { | |
| 1827 | + $results[0] = 0; | |
| 1828 | + } else { | |
| 1829 | + parse_str( $str[1], $para ); | |
| 1830 | + $results[0] = isset( $para['result'] ) ? (int) $para['result'] : 0; | |
| 1831 | + foreach ( $para as $key => $value ) { | |
| 1832 | + $results[ $key ] = $value; | |
| 1833 | + } | |
| 1834 | + } | |
| 1835 | + } | |
| 1836 | + $results['reg_order'] = true; | |
| 1837 | + break; | |
| 1838 | + | |
| 1839 | + case 'paypal': | |
| 1840 | + usces_log( 'paypal in ', 'acting_transaction.log' ); | |
| 1841 | + $paypal_file = $usces->options['settlement_path'] . 'paypal.php'; | |
| 1842 | + if ( file_exists( $paypal_file ) ) { | |
| 1843 | + require_once( $paypal_file ); | |
| 1844 | + $results = paypal_check( $usces_paypal_url ); | |
| 1845 | + remove_action( 'shutdown', array( &$usces, 'lastprocessing' ) ); | |
| 1846 | + $results['reg_order'] = true; | |
| 1847 | + } else { | |
| 1848 | + $results['reg_order'] = true; | |
| 1849 | + } | |
| 1850 | + break; | |
| 1851 | + | |
| 1852 | + case 'remise_card': | |
| 1853 | + $results = $_POST; | |
| 1854 | + if ( $_REQUEST['acting_return'] && ( isset( $_REQUEST['X-ERRCODE'] ) && ' ' === $_REQUEST['X-ERRCODE'] ) ) { | |
| 1855 | + usces_log( 'remise card entry data : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 1856 | + $results[0] = 1; | |
| 1857 | + }else{ | |
| 1858 | + $results[0] = 0; | |
| 1859 | + } | |
| 1860 | + if ( isset( $_REQUEST['dlseller_update'] ) ) { | |
| 1861 | + $results['reg_order'] = false; | |
| 1862 | + } else { | |
| 1863 | + $results['reg_order'] = true; | |
| 1864 | + } | |
| 1865 | + break; | |
| 1866 | + | |
| 1867 | + case 'remise_conv': | |
| 1868 | + $results = $_GET; | |
| 1869 | + if ( $_REQUEST['acting_return'] && isset( $_REQUEST['X-JOB_ID'] ) && '0:0000' === $_REQUEST['X-R_CODE'] ) { | |
| 1870 | + $results[0] = 1; | |
| 1871 | + } else { | |
| 1872 | + $results[0] = 0; | |
| 1873 | + } | |
| 1874 | + $results['reg_order'] = true; | |
| 1875 | + break; | |
| 1876 | + | |
| 1877 | + case 'jpayment_card': | |
| 1878 | + $results = $_GET; | |
| 1879 | + $rst = ( isset( $_GET['rst'] ) ) ? (int) $_GET['rst'] : 0; | |
| 1880 | + if ( 2 === $rst ) { | |
| 1881 | + usces_log( 'jpayment card error : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 1882 | + $cod = ( isset( $_GET['cod'] ) ) ? $_GET['cod'] : ''; | |
| 1883 | + $log = array( | |
| 1884 | + 'acting' => $acting, | |
| 1885 | + 'key' => $cod, | |
| 1886 | + 'result' => $rst, | |
| 1887 | + 'data' => $_GET, | |
| 1888 | + ); | |
| 1889 | + usces_save_order_acting_error( $log ); | |
| 1890 | + } | |
| 1891 | + $results[0] = ( 1 === $rst ) ? 1 : 0; | |
| 1892 | + $results['reg_order'] = true; | |
| 1893 | + break; | |
| 1894 | + | |
| 1895 | + case 'jpayment_conv': | |
| 1896 | + $results = $_GET; | |
| 1897 | + $rst = ( isset( $_GET['rst'] ) ) ? (int) $_GET['rst'] : 0; | |
| 1898 | + if ( 2 === $rst ) { | |
| 1899 | + usces_log( 'jpayment conv error : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 1900 | + $cod = ( isset( $_GET['cod'] ) ) ? $_GET['cod'] : ''; | |
| 1901 | + $log = array( | |
| 1902 | + 'acting' => $acting, | |
| 1903 | + 'key' => $cod, | |
| 1904 | + 'result' => $rst, | |
| 1905 | + 'data' => $_GET, | |
| 1906 | + ); | |
| 1907 | + usces_save_order_acting_error( $log ); | |
| 1908 | + } | |
| 1909 | + $results[0] = ( 1 === $rst && 'CPL_PRE' === $_GET['ap'] ) ? 1 : 0; | |
| 1910 | + $results['reg_order'] = true; | |
| 1911 | + break; | |
| 1912 | + | |
| 1913 | + case 'jpayment_bank': | |
| 1914 | + $results = $_GET; | |
| 1915 | + $rst = ( isset( $_GET['rst'] ) ) ? (int) $_GET['rst'] : 0; | |
| 1916 | + if ( 2 === $rst ) { | |
| 1917 | + usces_log( 'jpayment bank error : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 1918 | + $cod = ( isset( $_GET['cod'] ) ) ? $_GET['cod'] : ''; | |
| 1919 | + $log = array( | |
| 1920 | + 'acting' => $acting, | |
| 1921 | + 'key' => $cod, | |
| 1922 | + 'result' => $rst, | |
| 1923 | + 'data' => $_GET, | |
| 1924 | + ); | |
| 1925 | + usces_save_order_acting_error( $log ); | |
| 1926 | + } | |
| 1927 | + $results[0] = ( 1 === $rst ) ? 1 : 0; | |
| 1928 | + $results['reg_order'] = true; | |
| 1929 | + break; | |
| 1930 | + | |
| 1931 | + case 'paypal_ec': | |
| 1932 | + $results = $_GET; | |
| 1933 | + | |
| 1934 | + // Build a second API request to PayPal, using the token as the ID to get the details on the payment authorization. | |
| 1935 | + $req_token = isset( $_REQUEST['token'] ) ? $_REQUEST['token'] : '0'; | |
| 1936 | + $nvpstr = '&TOKEN=' . urlencode( $req_token ); | |
| 1937 | + | |
| 1938 | + $usces->paypal->setMethod( 'GetExpressCheckoutDetails' ); | |
| 1939 | + $usces->paypal->setData( $nvpstr ); | |
| 1940 | + $res = $usces->paypal->doExpressCheckout(); | |
| 1941 | + $resArray = $usces->paypal->getResponse(); | |
| 1942 | + $ack = strtoupper( $resArray['ACK'] ); | |
| 1943 | + if ( 'SUCCESS' === $ack || 'SUCCESSWITHWARNING' === $ack ) { | |
| 1944 | + if ( usces_have_continue_charge() ) { | |
| 1945 | + $results[0] = 1; | |
| 1946 | + } else { | |
| 1947 | + $amt = floor( $resArray['AMT'] * 100 ); | |
| 1948 | + $total_full_price = usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ); | |
| 1949 | + $total_full_price = floor( $total_full_price * 100 ); | |
| 1950 | + if ( $amt != $total_full_price ) { | |
| 1951 | + usces_log( 'PayPal : AMT Error. AMT=' . $resArray['AMT'] . ', total_full_price=' . $entry['order']['total_full_price'], 'acting_transaction.log' ); | |
| 1952 | + $results[0] = 0; | |
| 1953 | + } else { | |
| 1954 | + $results[0] = 1; | |
| 1955 | + } | |
| 1956 | + } | |
| 1957 | + | |
| 1958 | + } else { | |
| 1959 | + // Display a user friendly Error on the page using any of the following error information returned by PayPal. | |
| 1960 | + $ErrorCode = urldecode( $resArray['L_ERRORCODE0'] ); | |
| 1961 | + $ErrorShortMsg = urldecode( $resArray['L_SHORTMESSAGE0'] ); | |
| 1962 | + $ErrorLongMsg = urldecode( $resArray['L_LONGMESSAGE0'] ); | |
| 1963 | + $ErrorSeverityCode = urldecode( $resArray['L_SEVERITYCODE0'] ); | |
| 1964 | + 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' ); | |
| 1965 | + $results[0] = 0; | |
| 1966 | + } | |
| 1967 | + $results['reg_order'] = true; | |
| 1968 | + break; | |
| 1969 | + | |
| 1970 | + case 'telecom_card': | |
| 1971 | + $results = $_GET; | |
| 1972 | + if ( $_REQUEST['result'] ) { | |
| 1973 | + usces_log( $acting . ' entry data : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 1974 | + $results[0] = 1; | |
| 1975 | + } else { | |
| 1976 | + usces_log( $acting . ' error : ' . print_r( $_REQUEST, true ), 'acting_transaction.log' ); | |
| 1977 | + $results[0] = 0; | |
| 1978 | + } | |
| 1979 | + $results['reg_order'] = true; | |
| 1980 | + break; | |
| 1981 | + | |
| 1982 | + case 'digitalcheck_card': | |
| 1983 | + $results = $_REQUEST; | |
| 1984 | + if ( isset( $_REQUEST['SID'] ) ) { | |
| 1985 | + $results[0] = 1; | |
| 1986 | + } else { | |
| 1987 | + $results[0] = 0; | |
| 1988 | + } | |
| 1989 | + $results['reg_order'] = true; | |
| 1990 | + break; | |
| 1991 | + case 'digitalcheck_conv': | |
| 1992 | + $results = $_REQUEST; | |
| 1993 | + $results[0] = 1; | |
| 1994 | + $results['reg_order'] = false; | |
| 1995 | + break; | |
| 1996 | + | |
| 1997 | + case 'mizuho_card': | |
| 1998 | + case 'mizuho_conv': | |
| 1999 | + $results = $_GET; | |
| 2000 | + if ( isset( $_GET['rsltcd'] ) ) { | |
| 2001 | + if ( '000' === substr( $_GET['rsltcd'], 0, 3 ) ) { | |
| 2002 | + $results[0] = 1; | |
| 2003 | + $results['reg_order'] = true; | |
| 2004 | + } else { | |
| 2005 | + $results[0] = 0; | |
| 2006 | + $results['reg_order'] = false; | |
| 2007 | + } | |
| 2008 | + } else { | |
| 2009 | + $results[0] = 0; | |
| 2010 | + $results['reg_order'] = false; | |
| 2011 | + } | |
| 2012 | + break; | |
| 2013 | + | |
| 2014 | + case 'anotherlane_card': | |
| 2015 | + $results[0] = 1; | |
| 2016 | + $results['reg_order'] = false; | |
| 2017 | + break; | |
| 2018 | + | |
| 2019 | + case 'veritrans_card': | |
| 2020 | + case 'veritrans_conv': | |
| 2021 | + $results[0] = ( isset( $_GET['result'] ) ) ? (int) $_GET['result'] : 0; | |
| 2022 | + $results['reg_order'] = false; | |
| 2023 | + break; | |
| 2024 | + | |
| 2025 | + case 'paypal_wpp': | |
| 2026 | + $results[0] = 1; | |
| 2027 | + $results['reg_order'] = false; | |
| 2028 | + break; | |
| 2029 | + | |
| 2030 | + default: | |
| 2031 | + do_action( 'usces_action_check_acting_return_default' ); | |
| 2032 | + $results = $_REQUEST; | |
| 2033 | + if ( isset( $_REQUEST['result'] ) && true == $_REQUEST['result'] ) { | |
| 2034 | + usces_log( $acting . ' entry data : ' . print_r( $entry, true ), 'acting_transaction.log' ); | |
| 2035 | + $results[0] = 1; | |
| 2036 | + } else { | |
| 2037 | + // usces_log( $acting . ' error : ' . print_r( $_REQUEST, true ), 'acting_transaction.log' ); Not necessarily an error. | |
| 2038 | + $results[0] = 0; | |
| 2039 | + } | |
| 2040 | + $results['reg_order'] = true; | |
| 2041 | + $results = apply_filters( 'usces_filter_check_acting_return_results', $results ); | |
| 2042 | + break; | |
| 2043 | + } | |
| 2044 | + | |
| 2045 | + return $results; | |
| 2046 | +} | |
| 2047 | + | |
| 2048 | +function usces_check_acting_return_duplicate( $results = array() ) { | |
| 2049 | + global $wpdb; | |
| 2050 | + | |
| 2051 | + $acting = isset( $_GET['acting'] ) ? $_GET['acting'] : ''; | |
| 2052 | + | |
| 2053 | + switch( $acting ) { | |
| 2054 | + case 'epsilon': | |
| 2055 | + $trans_id = isset( $_REQUEST['trans_code'] ) ? $_REQUEST['trans_code'] : ''; | |
| 2056 | + $_REQUEST['absolute_trans_id'] = $_REQUEST['order_number']; | |
| 2057 | + break; | |
| 2058 | + case 'paypal': | |
| 2059 | + $trans_id = isset( $results['txn_id'] ) ? $results['txn_id'] : ''; | |
| 2060 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2061 | + break; | |
| 2062 | + case 'paypal_ipn': | |
| 2063 | + $trans_id = isset( $_REQUEST['txn_id'] ) ? $_REQUEST['txn_id'] : ''; | |
| 2064 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2065 | + break; | |
| 2066 | + case 'paypal_ec': | |
| 2067 | + $trans_id = isset( $_REQUEST['token'] ) ? $_REQUEST['token'] : ''; | |
| 2068 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2069 | + break; | |
| 2070 | + case 'remise_card': | |
| 2071 | + $trans_id = isset( $_REQUEST['X-TRANID'] ) ? $_REQUEST['X-TRANID'] : ''; | |
| 2072 | + $_REQUEST['absolute_trans_id'] = $_REQUEST['X-S_TORIHIKI_NO']; | |
| 2073 | + break; | |
| 2074 | + case 'remise_conv': | |
| 2075 | + $trans_id = isset( $_REQUEST['X-JOB_ID'] ) ? $_REQUEST['X-JOB_ID'] : ''; | |
| 2076 | + $_REQUEST['absolute_trans_id'] = $_REQUEST['X-S_TORIHIKI_NO']; | |
| 2077 | + break; | |
| 2078 | + case 'jpayment_card': | |
| 2079 | + case 'jpayment_conv': | |
| 2080 | + case 'jpayment_bank': | |
| 2081 | + $trans_id = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : ''; | |
| 2082 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2083 | + break; | |
| 2084 | + case 'telecom_card': | |
| 2085 | + $trans_id = isset( $_REQUEST['option'] ) ? $_REQUEST['option'] : ''; | |
| 2086 | + $_REQUEST['absolute_trans_id'] = isset( $_REQUEST['option'] ) ? $_REQUEST['option'] : $trans_id; | |
| 2087 | + break; | |
| 2088 | + case 'digitalcheck_card': | |
| 2089 | + case 'digitalcheck_conv': | |
| 2090 | + $trans_id = isset( $_REQUEST['SID'] ) ? $_REQUEST['SID'] : ''; | |
| 2091 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2092 | + break; | |
| 2093 | + case 'mizuho_card': | |
| 2094 | + case 'mizuho_conv': | |
| 2095 | + $trans_id = isset( $_REQUEST['stran'] ) ? $_REQUEST['stran'] : ''; | |
| 2096 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2097 | + break; | |
| 2098 | + default: | |
| 2099 | + $trans_id = apply_filters( 'usces_filter_check_acting_return_duplicate', '', $results ); | |
| 2100 | + $_REQUEST['absolute_trans_id'] = $trans_id; | |
| 2101 | + } | |
| 2102 | + $order_id = usces_get_order_id_by_trans_id( $trans_id ); | |
| 2103 | + if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { | |
| 2104 | + $_REQUEST['remote_addr'] = $_SERVER['REMOTE_ADDR']; | |
| 2105 | + } | |
| 2106 | + if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { | |
| 2107 | + $_REQUEST['user_agent'] = $_SERVER['HTTP_USER_AGENT']; | |
| 2108 | + } | |
| 2109 | + | |
| 2110 | + return $order_id; | |
| 2111 | +} | |
| 2112 | + | |
| 2113 | +function usces_get_order_id_by_trans_id( $trans_id ) { | |
| 2114 | + global $wpdb; | |
| 2115 | + | |
| 2116 | + if ( empty( $trans_id ) ) { | |
| 2117 | + return false; | |
| 2118 | + } | |
| 2119 | + | |
| 2120 | + $table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 2121 | + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'trans_id', $trans_id ); | |
| 2122 | + $order_id = $wpdb->get_var( $query ); | |
| 2123 | + return $order_id; | |
| 2124 | +} | |
| 2125 | + | |
| 2126 | +function usces_dates_interconv( $date_str ) { | |
| 2127 | + $base_struc = array( 'd', 'm', 'Y' ); | |
| 2128 | + $date_str_parts = preg_split( '[/.-]', $date_str ); | |
| 2129 | + $date_elements = array(); | |
| 2130 | + | |
| 2131 | + $p_keys = array_keys( $base_struc ); | |
| 2132 | + foreach ( $p_keys as $p_key ) { | |
| 2133 | + if ( ! empty( $date_str_parts[ $p_key ] ) ) { | |
| 2134 | + $date_elements[ $base_struc[ $p_key ] ] = $date_str_parts[ $p_key ]; | |
| 2135 | + } else { | |
| 2136 | + return false; | |
| 2137 | + } | |
| 2138 | + } | |
| 2139 | + $dummy_ts = mktime( 0, 0, 0, $date_elements['m'], $date_elements['d'], $date_elements['Y'] ); | |
| 2140 | + return date( 'Y-m-d', $dummy_ts ); | |
| 2141 | +} | |
| 2142 | + | |
| 2143 | +function usces_register_action( $handle, $type, $key, $value, $function ) { | |
| 2144 | + global $usces_action; | |
| 2145 | + $usces_action[ $handle ] = array( | |
| 2146 | + 'type' => $type, | |
| 2147 | + 'key' => $key, | |
| 2148 | + 'value' => $value, | |
| 2149 | + 'function' => $function, | |
| 2150 | + ); | |
| 2151 | +} | |
| 2152 | + | |
| 2153 | +function usces_deregister_action( $handle ) { | |
| 2154 | + global $usces_action; | |
| 2155 | + unset( $usces_action[ $handle ] ); | |
| 2156 | +} | |
| 2157 | + | |
| 2158 | +function usces_update_check_admin( $result ) { | |
| 2159 | + $result = true; | |
| 2160 | + return $result; | |
| 2161 | +} | |
| 2162 | + | |
| 2163 | +function usces_setup_cod_ajax() { | |
| 2164 | + global $usces; | |
| 2165 | + | |
| 2166 | + // Verify nonce for security. | |
| 2167 | + check_ajax_referer( 'admin_setup', 'wc_nonce' ); | |
| 2168 | + | |
| 2169 | + // Check user capability. | |
| 2170 | + if ( ! current_user_can( 'wel_manage_setting' ) ) { | |
| 2171 | + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'usces' ), 403 ); | |
| 2172 | + } | |
| 2173 | + | |
| 2174 | + $usces->options = get_option( 'usces' ); | |
| 2175 | + $message = ''; | |
| 2176 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 2177 | + | |
| 2178 | + $usces->options['cod_type'] = isset( $_POST['cod_type'] ) ? $_POST['cod_type'] : 'fix'; | |
| 2179 | + if ( isset( $_POST['cod_fee'] ) ) { | |
| 2180 | + $usces->options['cod_fee'] = (int) $_POST['cod_fee']; | |
| 2181 | + } | |
| 2182 | + if ( 'fix' == $usces->options['cod_type'] ) { | |
| 2183 | + if ( isset( $_POST['cod_limit_amount'] ) ) { | |
| 2184 | + $usces->options['cod_limit_amount'] = (int) $_POST['cod_limit_amount']; | |
| 2185 | + if ( ! WCUtils::is_blank( $_POST['cod_limit_amount'] ) && 0 === (int) $_POST['cod_limit_amount'] ) { | |
| 2186 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2187 | + } | |
| 2188 | + } // phpcs:ignore Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen | |
| 2189 | + | |
| 2190 | + } elseif ( 'change' == $usces->options['cod_type'] ) { | |
| 2191 | + if ( isset( $_POST['cod_first_amount'] ) ) { | |
| 2192 | + $usces->options['cod_first_amount'] = (int) $_POST['cod_first_amount']; | |
| 2193 | + if ( 0 === (int) $_POST['cod_first_amount'] ) { | |
| 2194 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2195 | + } | |
| 2196 | + } | |
| 2197 | + if ( isset( $_POST['cod_limit_amount'] ) ) { | |
| 2198 | + $usces->options['cod_limit_amount'] = (int) $_POST['cod_limit_amount']; | |
| 2199 | + if ( ! WCUtils::is_blank( $_POST['cod_limit_amount'] ) && 0 === (int) $_POST['cod_limit_amount'] ) { | |
| 2200 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2201 | + } | |
| 2202 | + } | |
| 2203 | + if ( isset( $_POST['cod_first_fee'] ) ) { | |
| 2204 | + $usces->options['cod_first_fee'] = (int) $_POST['cod_first_fee']; | |
| 2205 | + if ( 0 === (int) $_POST['cod_first_fee'] && '0' !== $_POST['cod_first_fee'] ) { | |
| 2206 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2207 | + } | |
| 2208 | + } | |
| 2209 | + if ( isset( $_POST['cod_end_fee'] ) ) { | |
| 2210 | + $usces->options['cod_end_fee'] = (int) $_POST['cod_end_fee']; | |
| 2211 | + if ( 0 === (int) $_POST['cod_end_fee'] && '0' !== $_POST['cod_end_fee'] ) { | |
| 2212 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2213 | + } | |
| 2214 | + } | |
| 2215 | + | |
| 2216 | + unset( $usces->options['cod_amounts'], $usces->options['cod_fees'] ); | |
| 2217 | + if ( isset( $_POST['cod_amounts'] ) ) { | |
| 2218 | + $cod_amounts_count = ( is_array( $_POST['cod_amounts'] ) ) ? count( $_POST['cod_amounts'] ) : 0; | |
| 2219 | + for ( $i = 0; $i < $cod_amounts_count; $i++ ) { | |
| 2220 | + $usces->options['cod_amounts'][ $i ] = (int) $_POST['cod_amounts'][ $i ]; | |
| 2221 | + $usces->options['cod_fees'][ $i ] = (int) $_POST['cod_fees'][ $i ]; | |
| 2222 | + if ( 0 === (int) $_POST['cod_amounts'][ $i ] || ( 0 === (int) $_POST['cod_fees'][ $i ] && '0' !== $_POST['cod_fees'][ $i ] ) ) { | |
| 2223 | + $message = __( 'There is the item where a value is dirty.', 'usces' ); | |
| 2224 | + } | |
| 2225 | + } | |
| 2226 | + } | |
| 2227 | + } | |
| 2228 | + | |
| 2229 | + if ( '' === $message ) { | |
| 2230 | + $r = 'success'; | |
| 2231 | + update_option( 'usces', $usces->options ); | |
| 2232 | + } else { | |
| 2233 | + $r = '<span style="color:red;">' . $message . '</span>'; | |
| 2234 | + } | |
| 2235 | + die( $r ); | |
| 2236 | +} | |
| 2237 | + | |
| 2238 | +function usces_get_order_acting_data( $rand ) { | |
| 2239 | + global $wpdb; | |
| 2240 | + | |
| 2241 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2242 | + $query = $wpdb->prepare( "SELECT acc_str1 AS `sesid`, acc_value AS `order_data` FROM $table_name WHERE acc_key = %s", $rand ); | |
| 2243 | + $res = $wpdb->get_row( $query, ARRAY_A ); | |
| 2244 | + if ( $res == NULL ) { | |
| 2245 | + return false; | |
| 2246 | + } else { | |
| 2247 | + return $res; | |
| 2248 | + } | |
| 2249 | +} | |
| 2250 | + | |
| 2251 | +function usces_ordered_acting_data( $rand, $key = 'order_received' ) { | |
| 2252 | + global $usces, $wpdb; | |
| 2253 | + | |
| 2254 | + $datas = usces_get_order_acting_data( $rand ); | |
| 2255 | + $data = wel_safe_unserialize( $datas['order_data'] ); | |
| 2256 | + usces_log( 'usces_ordered_acting_data', 'acting_transaction.log' ); | |
| 2257 | + $data[ $key ] = 1; | |
| 2258 | + | |
| 2259 | + $data = serialize( $data ); | |
| 2260 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2261 | + $query = $wpdb->prepare( | |
| 2262 | + "UPDATE $table_name SET acc_value = %s WHERE acc_type = %s AND acc_key = %s", | |
| 2263 | + $data, | |
| 2264 | + 'acting_data', | |
| 2265 | + $rand | |
| 2266 | + ); | |
| 2267 | + $res = $wpdb->query( $query ); | |
| 2268 | +} | |
| 2269 | + | |
| 2270 | +function usces_delete_ordered_acting_data( $rand ) { | |
| 2271 | + global $wpdb; | |
| 2272 | + | |
| 2273 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2274 | + $query = $wpdb->prepare( "DELETE FROM $table_name WHERE acc_type = %s AND acc_key = %s", 'acting_data', $rand ); | |
| 2275 | + $res = $wpdb->query( $query ); | |
| 2276 | +} | |
| 2277 | + | |
| 2278 | +function usces_is_trusted_acting_data( $rand ) { | |
| 2279 | + global $usces, $wpdb; | |
| 2280 | + | |
| 2281 | + $datas = usces_get_order_acting_data( $rand ); | |
| 2282 | + $data = wel_safe_unserialize( $datas['order_data'] ); | |
| 2283 | + usces_log( 'usces_is_trusted_acting_data', 'acting_transaction.log' ); | |
| 2284 | + if ( isset( $data['propriety'] ) && $data['propriety'] && ! isset( $data['order_received'] ) ) { | |
| 2285 | + return true; | |
| 2286 | + } else { | |
| 2287 | + return false; | |
| 2288 | + } | |
| 2289 | +} | |
| 2290 | + | |
| 2291 | +function usces_get_filename( $path ) { | |
| 2292 | + $res = array(); | |
| 2293 | + if ( $handle = opendir( $path ) ) { | |
| 2294 | + while ( false !== ( $file = readdir( $handle ) ) ) { | |
| 2295 | + if ( '.' != $file && '..' != $file ) { | |
| 2296 | + $res[] = $file; | |
| 2297 | + } | |
| 2298 | + } | |
| 2299 | + closedir( $handle ); | |
| 2300 | + } | |
| 2301 | + return $res; | |
| 2302 | +} | |
| 2303 | + | |
| 2304 | +function usces_locales() { | |
| 2305 | + $res = array(); | |
| 2306 | + if ( $handle = opendir( USCES_PLUGIN_DIR . '/languages/' ) ) { | |
| 2307 | + while ( false !== ( $file = readdir( $handle ) ) ) { | |
| 2308 | + if ( '.' != $file && '..' != $file && preg_match( '/^usces-(.+)\.mo$/', $file, $matches ) ) { | |
| 2309 | + $res[] = $matches[1]; | |
| 2310 | + } | |
| 2311 | + } | |
| 2312 | + closedir( $handle ); | |
| 2313 | + } | |
| 2314 | + return $res; | |
| 2315 | +} | |
| 2316 | + | |
| 2317 | +function usces_get_local_language() { | |
| 2318 | + $locale = get_locale(); | |
| 2319 | + switch ( $locale ) { | |
| 2320 | + case '': | |
| 2321 | + case 'en': | |
| 2322 | + case 'en_US': | |
| 2323 | + $front_lang = 'en'; | |
| 2324 | + break; | |
| 2325 | + case 'ja': | |
| 2326 | + case 'ja_JP': | |
| 2327 | + $front_lang = 'ja'; | |
| 2328 | + break; | |
| 2329 | + default: | |
| 2330 | + $front_lang = 'others'; | |
| 2331 | + } | |
| 2332 | + return $front_lang; | |
| 2333 | +} | |
| 2334 | + | |
| 2335 | +function usces_get_base_country() { | |
| 2336 | + global $usces_settings; | |
| 2337 | + | |
| 2338 | + $wplang = defined( 'WPLANG' ) ? WPLANG : get_locale(); | |
| 2339 | + $locale = empty( $wplang ) ? 'en' : $wplang; | |
| 2340 | + $base_country = ( array_key_exists( $locale, $usces_settings['lungage2country'] ) ) ? $usces_settings['lungage2country'][ $locale ] : 'US'; | |
| 2341 | + $base_country = apply_filters( 'usces_filter_base_country', $base_country ); | |
| 2342 | + return $base_country; | |
| 2343 | +} | |
| 2344 | + | |
| 2345 | +function usces_get_local_addressform() { | |
| 2346 | + global $usces_settings; | |
| 2347 | + | |
| 2348 | + $base = usces_get_base_country(); | |
| 2349 | + $addressform = ( array_key_exists( $base, $usces_settings['addressform'] ) ) ? $usces_settings['addressform'][ $base ] : 'US'; | |
| 2350 | + $addressform = apply_filters( 'usces_filter_addressform', $addressform ); | |
| 2351 | + return $addressform; | |
| 2352 | +} | |
| 2353 | + | |
| 2354 | +function usces_get_local_target_market() { | |
| 2355 | + $base = usces_get_base_country(); | |
| 2356 | + return (array) $base; | |
| 2357 | +} | |
| 2358 | + | |
| 2359 | +function usces_get_apply_addressform( $country ) { | |
| 2360 | + global $usces_settings; | |
| 2361 | + return $usces_settings['addressform'][ $country ]; | |
| 2362 | +} | |
| 2363 | + | |
| 2364 | +function usces_remove_filter() { | |
| 2365 | + global $usces, $post; | |
| 2366 | + | |
| 2367 | + if ( is_single() && 'item' == $post->post_mime_type ) { | |
| 2368 | + remove_filter( 'the_content', array( &$usces, 'filter_itemPage' ) ); | |
| 2369 | + | |
| 2370 | + } elseif ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) || $usces->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2371 | + remove_action( 'the_post', array( &$usces, 'action_cartFilter' ) ); | |
| 2372 | + remove_filter( 'the_title', array( &$usces, 'filter_cartTitle' ) ,20 ); | |
| 2373 | + remove_filter( 'the_content', array( &$usces, 'filter_cartContent' ), 20 ); | |
| 2374 | + | |
| 2375 | + } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2376 | + remove_action( 'the_post', array( &$usces, 'action_memberFilter' ) ); | |
| 2377 | + remove_filter( 'the_title', array( &$usces, 'filter_memberTitle' ), 20 ); | |
| 2378 | + remove_filter( 'the_content', array( &$usces, 'filter_memberContent' ) ,20 ); | |
| 2379 | + | |
| 2380 | + } else { | |
| 2381 | + remove_action( 'the_post', array( &$usces, 'goDefaultPage' ) ); | |
| 2382 | + } | |
| 2383 | +} | |
| 2384 | + | |
| 2385 | +function usces_reset_filter() { | |
| 2386 | + global $usces, $post; | |
| 2387 | + | |
| 2388 | + if ( is_single() && 'item' == $post->post_mime_type ) { | |
| 2389 | + add_filter( 'the_content', array( &$usces, 'filter_itemPage' ) ); | |
| 2390 | + | |
| 2391 | + } elseif ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) || $usces->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2392 | + add_action( 'the_post', array( &$usces, 'action_cartFilter' ) ); | |
| 2393 | + add_filter( 'the_title', array( &$usces, 'filter_cartTitle' ), 20 ); | |
| 2394 | + add_filter( 'the_content', array( &$usces, 'filter_cartContent' ), 20 ); | |
| 2395 | + | |
| 2396 | + } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2397 | + add_action( 'the_post', array( &$usces, 'action_memberFilter' ) ); | |
| 2398 | + add_filter( 'the_title', array( &$usces, 'filter_memberTitle' ), 20 ); | |
| 2399 | + add_filter( 'the_content', array( &$usces, 'filter_memberContent' ), 20 ); | |
| 2400 | + | |
| 2401 | + } else { | |
| 2402 | + add_action( 'the_post', array( &$usces, 'goDefaultPage' ) ); | |
| 2403 | + } | |
| 2404 | +} | |
| 2405 | + | |
| 2406 | +function usces_get_wcex() { | |
| 2407 | + $wcex = array(); | |
| 2408 | + if ( defined( 'WCEX_DLSELLER_VERSION' ) ) { | |
| 2409 | + $wcex['DLSELLER'] = array( | |
| 2410 | + 'name' => 'Dl Seller', | |
| 2411 | + 'version' => WCEX_DLSELLER_VERSION, | |
| 2412 | + ); | |
| 2413 | + } | |
| 2414 | + if ( defined( 'WCEX_ITEM_LIST_LAYOUT_VERSION' ) ) { | |
| 2415 | + $wcex['ITEM_LIST_LAYOUT'] = array( | |
| 2416 | + 'name' => 'Item List Layout', | |
| 2417 | + 'version' => WCEX_ITEM_LIST_LAYOUT_VERSION, | |
| 2418 | + ); | |
| 2419 | + } | |
| 2420 | + if ( defined( 'WCEX_MOBILE_VERSION' ) ) { | |
| 2421 | + $wcex['MOBILE'] = array( | |
| 2422 | + 'name' => 'Mobile', | |
| 2423 | + 'version' => WCEX_MOBILE_VERSION, | |
| 2424 | + ); | |
| 2425 | + } | |
| 2426 | + if ( defined( 'WCEX_MULTIPRICE_VERSION' ) ) { | |
| 2427 | + $wcex['MULTIPRICE'] = array( | |
| 2428 | + 'name' => 'Multi Price', | |
| 2429 | + 'version' => WCEX_MULTIPRICE_VERSION, | |
| 2430 | + ); | |
| 2431 | + } | |
| 2432 | + if ( defined( 'WCEX_SLIDE_SHOWCASE_VERSION' ) ) { | |
| 2433 | + $wcex['SLIDE_SHOWCASE'] = array( | |
| 2434 | + 'name' => 'Slide Showcase', | |
| 2435 | + 'version' => WCEX_SLIDE_SHOWCASE_VERSION, | |
| 2436 | + ); | |
| 2437 | + } | |
| 2438 | + if ( defined( 'WCEX_WIDGET_CART_VERSION' ) ) { | |
| 2439 | + $wcex['WIDGET_CART'] = array( | |
| 2440 | + 'name' => 'Widget Cart', | |
| 2441 | + 'version' => WCEX_WIDGET_CART_VERSION, | |
| 2442 | + ); | |
| 2443 | + } | |
| 2444 | + return $wcex; | |
| 2445 | +} | |
| 2446 | + | |
| 2447 | +function usces_trackPageview_cart( $push ) { | |
| 2448 | + $push = array(); | |
| 2449 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2450 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_cart'"; | |
| 2451 | + } else { | |
| 2452 | + $push[] = "'_trackPageview','/wc_cart'"; | |
| 2453 | + } | |
| 2454 | + return $push; | |
| 2455 | +} | |
| 2456 | + | |
| 2457 | +function usces_trackPageview_customer( $push ) { | |
| 2458 | + $push = array(); | |
| 2459 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2460 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_customer'"; | |
| 2461 | + } else { | |
| 2462 | + $push[] = "'_trackPageview','/wc_customer'"; | |
| 2463 | + } | |
| 2464 | + return $push; | |
| 2465 | +} | |
| 2466 | + | |
| 2467 | +function usces_trackPageview_delivery( $push ) { | |
| 2468 | + $push = array(); | |
| 2469 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2470 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_delivery'"; | |
| 2471 | + } else { | |
| 2472 | + $push[] = "'_trackPageview','/wc_delivery'"; | |
| 2473 | + } | |
| 2474 | + return $push; | |
| 2475 | +} | |
| 2476 | + | |
| 2477 | +function usces_trackPageview_confirm( $push ) { | |
| 2478 | + $push = array(); | |
| 2479 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2480 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_confirm'"; | |
| 2481 | + } else { | |
| 2482 | + $push[] = "'_trackPageview','/wc_confirm'"; | |
| 2483 | + } | |
| 2484 | + return $push; | |
| 2485 | +} | |
| 2486 | + | |
| 2487 | +function usces_trackPageview_ordercompletion( $push ) { | |
| 2488 | + global $usces; | |
| 2489 | + | |
| 2490 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2491 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_ordercompletion'"; | |
| 2492 | + } else { | |
| 2493 | + $push[] = "'_trackPageview','/wc_ordercompletion'"; | |
| 2494 | + } | |
| 2495 | + | |
| 2496 | + $sesdata = $usces->cart->get_entry(); | |
| 2497 | + if ( isset( $sesdata['order']['ID'] ) && ! empty( $sesdata['order']['ID'] ) ) { | |
| 2498 | + $order_id = $sesdata['order']['ID']; | |
| 2499 | + $data = $usces->get_order_data( $order_id, 'direct' ); | |
| 2500 | + $cart = wel_safe_unserialize( $data['order_cart'] ); | |
| 2501 | + $total_price = $usces->get_total_price( $cart ) + $data['order_discount'] - $data['order_usedpoint']; | |
| 2502 | + if ( $total_price < 0 ) { | |
| 2503 | + $total_price = 0; | |
| 2504 | + } | |
| 2505 | + $push[] = "'_addTrans', '" . $order_id . "', '" . esc_js( get_option( 'blogname' ) ) . "', '" . $total_price . "', '" . $data['order_tax'] . "', '" . $data['order_shipping_charge'] . "', '" . esc_js( $data['order_address1'] . $data['order_address2'] ) . "', '" . esc_js( $data['order_pref'] ) . "', '" . get_locale() . "'"; | |
| 2506 | + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0; | |
| 2507 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 2508 | + $cart_row = $cart[ $i ]; | |
| 2509 | + $post_id = $cart_row['post_id']; | |
| 2510 | + $sku = urldecode( $cart_row['sku'] ); | |
| 2511 | + $quantity = $cart_row['quantity']; | |
| 2512 | + $itemName = $usces->getItemName( $post_id ); | |
| 2513 | + $skuPrice = $cart_row['price']; | |
| 2514 | + $cats = $usces->get_item_cat_genre_ids( $post_id ); | |
| 2515 | + if ( is_array( $cats ) ) { | |
| 2516 | + sort( $cats ); | |
| 2517 | + } | |
| 2518 | + $category = ( isset( $cats[0] ) ) ? get_cat_name( $cats[0] ) : ''; | |
| 2519 | + $push[] = "'_addItem', '" . $order_id . "', '" . esc_js( $sku ) . "', '" . esc_js( $itemName ) . "', '" . esc_js( $category ) . "', '" . $skuPrice . "', '" . $quantity . "'"; | |
| 2520 | + } | |
| 2521 | + $push[] = "'_trackTrans'"; | |
| 2522 | + } | |
| 2523 | + | |
| 2524 | + return $push; | |
| 2525 | +} | |
| 2526 | + | |
| 2527 | +function usces_trackPageview_error( $push ) { | |
| 2528 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2529 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_error'"; | |
| 2530 | + } else { | |
| 2531 | + $push[] = "'_trackPageview','/wc_error'"; | |
| 2532 | + } | |
| 2533 | + return $push; | |
| 2534 | +} | |
| 2535 | + | |
| 2536 | +function usces_trackPageview_member( $push ) { | |
| 2537 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2538 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_member'"; | |
| 2539 | + } else { | |
| 2540 | + $push[] = "'_trackPageview','/wc_member'"; | |
| 2541 | + } | |
| 2542 | + return $push; | |
| 2543 | +} | |
| 2544 | + | |
| 2545 | +function usces_trackPageview_login( $push ) { | |
| 2546 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2547 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_login'"; | |
| 2548 | + } else { | |
| 2549 | + $push[] = "'_trackPageview','/wc_login'"; | |
| 2550 | + } | |
| 2551 | + return $push; | |
| 2552 | +} | |
| 2553 | + | |
| 2554 | +function usces_trackPageview_editmemberform( $push ) { | |
| 2555 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2556 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_editmemberform'"; | |
| 2557 | + } else { | |
| 2558 | + $push[] = "'_trackPageview','/wc_editmemberform'"; | |
| 2559 | + } | |
| 2560 | + return $push; | |
| 2561 | +} | |
| 2562 | + | |
| 2563 | +function usces_trackPageview_newcompletion( $push ) { | |
| 2564 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2565 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newcompletion'"; | |
| 2566 | + } else { | |
| 2567 | + $push[] = "'_trackPageview','/wc_newcompletion'"; | |
| 2568 | + } | |
| 2569 | + return $push; | |
| 2570 | +} | |
| 2571 | + | |
| 2572 | +function usces_trackPageview_newmemberform( $push ) { | |
| 2573 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2574 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_newmemberform'"; | |
| 2575 | + } else { | |
| 2576 | + $push[] = "'_trackPageview','/wc_newmemberform'"; | |
| 2577 | + } | |
| 2578 | + return $push; | |
| 2579 | +} | |
| 2580 | + | |
| 2581 | +function usces_trackPageview_deletemember( $push ) { | |
| 2582 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2583 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_deletemember'"; | |
| 2584 | + } else { | |
| 2585 | + $push[] = "'_trackPageview','/wc_deletemember'"; | |
| 2586 | + } | |
| 2587 | + return $push; | |
| 2588 | +} | |
| 2589 | + | |
| 2590 | +function usces_trackPageview_search_item( $push ) { | |
| 2591 | + if ( defined( 'USCES_KEY' ) && defined( 'USCES_MULTI' ) && true == USCES_MULTI ) { | |
| 2592 | + $push[] = "'_trackPageview','/" . USCES_KEY . "wc_search_item'"; | |
| 2593 | + } else { | |
| 2594 | + $push[] = "'_trackPageview','/wc_search_item'"; | |
| 2595 | + } | |
| 2596 | + return $push; | |
| 2597 | +} | |
| 2598 | + | |
| 2599 | +function usces_get_essential_mark( $fielde, $data = NULL ) { | |
| 2600 | + global $usces_essential_mark; | |
| 2601 | + do_action( 'usces_action_essential_mark', $data, $fielde ); | |
| 2602 | + return $usces_essential_mark[ $fielde ]; | |
| 2603 | +} | |
| 2604 | + | |
| 2605 | +function uesces_get_admin_addressform( $type, $data, $customdata, $out = 'return' ) { | |
| 2606 | + global $usces, $usces_settings; | |
| 2607 | + | |
| 2608 | + $options = get_option( 'usces', array() ); | |
| 2609 | + $applyform = usces_get_apply_addressform( $options['system']['addressform'] ); | |
| 2610 | + $formtag = ''; | |
| 2611 | + switch ( $type ) { | |
| 2612 | + case 'member': | |
| 2613 | + $values = array( | |
| 2614 | + 'name1' => $data['mem_name1'], | |
| 2615 | + 'name2' => $data['mem_name2'], | |
| 2616 | + 'name3' => $data['mem_name3'], | |
| 2617 | + 'name4' => $data['mem_name4'], | |
| 2618 | + 'zipcode' => $data['mem_zip'], | |
| 2619 | + 'address1' => $data['mem_address1'], | |
| 2620 | + 'address2' => $data['mem_address2'], | |
| 2621 | + 'address3' => $data['mem_address3'], | |
| 2622 | + 'tel' => $data['mem_tel'], | |
| 2623 | + 'fax' => $data['mem_fax'], | |
| 2624 | + 'pref' => $data['mem_pref'], | |
| 2625 | + ); | |
| 2626 | + $country = $usces->get_member_meta_value( 'customer_country', $data['ID'] ); | |
| 2627 | + $values['country'] = ! empty( $country ) ? $country : usces_get_local_addressform(); | |
| 2628 | + break; | |
| 2629 | + case 'customer': | |
| 2630 | + $values = array( | |
| 2631 | + 'name1' => $data['order_name1'], | |
| 2632 | + 'name2' => $data['order_name2'], | |
| 2633 | + 'name3' => $data['order_name3'], | |
| 2634 | + 'name4' => $data['order_name4'], | |
| 2635 | + 'zipcode' => $data['order_zip'], | |
| 2636 | + 'address1' => $data['order_address1'], | |
| 2637 | + 'address2' => $data['order_address2'], | |
| 2638 | + 'address3' => $data['order_address3'], | |
| 2639 | + 'tel' => $data['order_tel'], | |
| 2640 | + 'fax' => $data['order_fax'], | |
| 2641 | + 'pref' => $data['order_pref'], | |
| 2642 | + ); | |
| 2643 | + $country = $usces->get_order_meta_value( 'customer_country', $data['ID'] ); | |
| 2644 | + $values['country'] = ! empty( $country ) ? $country : usces_get_local_addressform(); | |
| 2645 | + break; | |
| 2646 | + case 'delivery': | |
| 2647 | + $values = $data; | |
| 2648 | + break; | |
| 2649 | + } | |
| 2650 | + | |
| 2651 | + switch ( $applyform ) { | |
| 2652 | + | |
| 2653 | + case 'JP': | |
| 2654 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_pre', 'return' ); | |
| 2655 | + $formtag .= ' | |
| 2656 | + <tr id="' . $type . '_name_row"> | |
| 2657 | + <td class="label">' . __( 'name', 'usces' ) . '</td> | |
| 2658 | + <td class="col2 datafield"><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> | |
| 2659 | + </tr> | |
| 2660 | + <tr id="' . $type . 'furikana_row"> | |
| 2661 | + <td class="label">' . __( 'furigana', 'usces' ) . '</td> | |
| 2662 | + <td class="col2 datafield"><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> | |
| 2663 | + </tr>'; | |
| 2664 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_after', 'return' ); | |
| 2665 | + $formtag .= ' | |
| 2666 | + <tr id="' . $type . 'zipcode_row"> | |
| 2667 | + <td class="label">' . __( 'Zip/Postal Code', 'usces' ) . '</td> | |
| 2668 | + <td class="col2 datafield"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr( $values['zipcode'] ) . '" />' . apply_filters( 'usces_filter_admin_addressform_zipcode', NULL, $type ) . '</td> | |
| 2669 | + </tr> | |
| 2670 | + <tr id="' . $type . '_country_row"> | |
| 2671 | + <td class="label">' . __( 'Country', 'usces' ) . '</td> | |
| 2672 | + <td class="col2 datafield">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 2673 | + </tr> | |
| 2674 | + <tr id="' . $type . '_states_row"> | |
| 2675 | + <td class="label">' . __( 'Province', 'usces' ) . '</td> | |
| 2676 | + <td class="col2 datafield">'; | |
| 2677 | + | |
| 2678 | + $formtag .= usces_pref_select( $type, $values ); | |
| 2679 | + | |
| 2680 | + $formtag .= '</td> | |
| 2681 | + </tr>'; | |
| 2682 | + $formtag .= ' | |
| 2683 | + <tr id="' . $type . '_address1_row"> | |
| 2684 | + <td class="label">' . __( 'city', 'usces' ) . '</td> | |
| 2685 | + <td class="col2 datafield"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr( $values['address1'] ) . '" /></td> | |
| 2686 | + </tr> | |
| 2687 | + <tr id="' . $type . '_address2_row"> | |
| 2688 | + <td class="label">' . __( 'numbers', 'usces' ) . '</td> | |
| 2689 | + <td class="col2 datafield"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr( $values['address2'] ) . '" /></td> | |
| 2690 | + </tr> | |
| 2691 | + <tr id="' . $type . '_address3_row"> | |
| 2692 | + <td class="label">' . __( 'building name', 'usces' ) . '</td> | |
| 2693 | + <td class="col2 datafield"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr( $values['address3'] ) . '" /></td> | |
| 2694 | + </tr> | |
| 2695 | + <tr id="' . $type . '_tel_row"> | |
| 2696 | + <td class="label">' . __( 'Phone number', 'usces' ) . '</td> | |
| 2697 | + <td class="col2 datafield"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr( $values['tel'] ) . '" /></td> | |
| 2698 | + </tr> | |
| 2699 | + <tr id="' . $type . '_fax_row"> | |
| 2700 | + <td class="label">' . __( 'FAX number', 'usces' ) . '</td> | |
| 2701 | + <td class="col2 datafield"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr( $values['fax'] ) . '" /></td> | |
| 2702 | + </tr>'; | |
| 2703 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'fax_after', 'return' ); | |
| 2704 | + break; | |
| 2705 | + | |
| 2706 | + case 'CN': | |
| 2707 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_pre', 'return' ); | |
| 2708 | + $formtag .= ' | |
| 2709 | + <tr> | |
| 2710 | + <td id="' . $type . 'name_row" class="label">' . __( 'name', 'usces' ) . '</td> | |
| 2711 | + <td class="col2 datafield"><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> | |
| 2712 | + </tr>'; | |
| 2713 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_after', 'return' ); | |
| 2714 | + $formtag .= ' | |
| 2715 | + <tr id="' . $type . '_country_row"> | |
| 2716 | + <td class="label">' . __( 'Country', 'usces' ) . '</td> | |
| 2717 | + <td class="col2 datafield">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 2718 | + </tr> | |
| 2719 | + <tr id="' . $type . '_states_row"> | |
| 2720 | + <td class="label">' . __( 'State', 'usces' ) . '</td> | |
| 2721 | + <td class="col2 datafield">'; | |
| 2722 | + | |
| 2723 | + $formtag .= usces_pref_select( $type, $values ); | |
| 2724 | + | |
| 2725 | + $formtag .= '</td> | |
| 2726 | + </tr id="' . $type . '_address1_row">'; | |
| 2727 | + $formtag .= '<tr> | |
| 2728 | + <td class="label">' . __( 'city', 'usces' ) . '</td> | |
| 2729 | + <td class="col2 datafield"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr( $values['address1'] ) . '" /></td> | |
| 2730 | + </tr> | |
| 2731 | + <tr id="' . $type . '_address2_row"> | |
| 2732 | + <td class="label">' . __( 'Address Line1', 'usces' ) . '</td> | |
| 2733 | + <td class="col2 datafield"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr( $values['address2'] ) . '" /></td> | |
| 2734 | + </tr> | |
| 2735 | + <tr id="' . $type . '_address3_row"> | |
| 2736 | + <td class="label">' . __( 'Address Line2', 'usces' ) . '</td> | |
| 2737 | + <td class="col2 datafield"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr( $values['address3'] ) . '" /></td> | |
| 2738 | + </tr> | |
| 2739 | + <tr id="' . $type . 'zipcode_row"> | |
| 2740 | + <td class="label">' . __( 'Zip', 'usces' ) . '</td> | |
| 2741 | + <td class="col2 datafield"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr( $values['zipcode'] ) . '" /></td> | |
| 2742 | + </tr> | |
| 2743 | + <tr id="' . $type . '_tel_row"> | |
| 2744 | + <td class="label">' . __( 'Phone number', 'usces' ) . '</td> | |
| 2745 | + <td class="col2 datafield"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr( $values['tel'] ) . '" /></td> | |
| 2746 | + </tr> | |
| 2747 | + <tr id="' . $type . '_fax_row"> | |
| 2748 | + <td class="label">' . __( 'FAX number', 'usces' ) . '</td> | |
| 2749 | + <td class="col2 datafield"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr( $values['fax'] ) . '" /></td> | |
| 2750 | + </tr>'; | |
| 2751 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'fax_after', 'return' ); | |
| 2752 | + break; | |
| 2753 | + | |
| 2754 | + case 'US': | |
| 2755 | + default: | |
| 2756 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_pre', 'return' ); | |
| 2757 | + $formtag .= ' | |
| 2758 | + <tr id="' . $type . 'name_row"> | |
| 2759 | + <td class="label">' . __( 'name', 'usces' ) . '</td> | |
| 2760 | + <td class="col2 datafield"><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> | |
| 2761 | + </tr>'; | |
| 2762 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'name_after', 'return' ); | |
| 2763 | + $formtag .= ' | |
| 2764 | + <tr id="' . $type . '_address2_row"> | |
| 2765 | + <td class="label">' . __( 'Address Line1', 'usces' ) . '</td> | |
| 2766 | + <td class="col2 datafield"><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr( $values['address2'] ) . '" /></td> | |
| 2767 | + </tr> | |
| 2768 | + <tr id="' . $type . '_address3_row"> | |
| 2769 | + <td class="label">' . __( 'Address Line2', 'usces' ) . '</td> | |
| 2770 | + <td class="col2 datafield"><input name="' . $type . '[address3]" type="text" class="text long" value="' . esc_attr( $values['address3'] ) . '" /></td> | |
| 2771 | + </tr> | |
| 2772 | + <tr id="' . $type . '_address1_row"> | |
| 2773 | + <td class="label">' . __( 'city', 'usces' ) . '</td> | |
| 2774 | + <td class="col2 datafield"><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr( $values['address1'] ) . '" /></td> | |
| 2775 | + </tr> | |
| 2776 | + <tr id="' . $type . '_states_row"> | |
| 2777 | + <td class="label">' . __( 'State', 'usces' ) . '</td> | |
| 2778 | + <td class="col2 datafield">'; | |
| 2779 | + | |
| 2780 | + $formtag .= usces_pref_select( $type, $values ); | |
| 2781 | + | |
| 2782 | + $formtag .= '</td> | |
| 2783 | + </tr>'; | |
| 2784 | + $formtag .= ' | |
| 2785 | + <tr id="' . $type . '_country_row"> | |
| 2786 | + <td class="label">' . __( 'Country', 'usces' ) . '</td> | |
| 2787 | + <td class="col2 datafield">' . uesces_get_target_market_form( $type, $values['country'] ) . '</td> | |
| 2788 | + </tr> | |
| 2789 | + <tr id="' . $type . 'zipcode_row"> | |
| 2790 | + <td class="label">' . __( 'Zip', 'usces' ) . '</td> | |
| 2791 | + <td class="col2 datafield"><input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr( $values['zipcode'] ) . '" /></td> | |
| 2792 | + </tr> | |
| 2793 | + <tr id="' . $type . '_tel_row"> | |
| 2794 | + <td class="label">' . __( 'Phone number', 'usces' ) . '</td> | |
| 2795 | + <td class="col2 datafield"><input name="' . $type . '[tel]" type="text" class="text long" value="' . esc_attr( $values['tel'] ) . '" /></td> | |
| 2796 | + </tr> | |
| 2797 | + <tr id="' . $type . '_fax_row"> | |
| 2798 | + <td class="label">' . __( 'FAX number', 'usces' ) . '</td> | |
| 2799 | + <td class="col2 datafield"><input name="' . $type . '[fax]" type="text" class="text long" value="' . esc_attr( $values['fax'] ) . '" /></td> | |
| 2800 | + </tr>'; | |
| 2801 | + $formtag .= usces_admin_custom_field_input( $customdata, $type, 'fax_after', 'return' ); | |
| 2802 | + break; | |
| 2803 | + } | |
| 2804 | + $res = apply_filters( 'usces_filter_apply_admin_addressform', $formtag, $type, $data, $customdata ); | |
| 2805 | + | |
| 2806 | + if ( 'return' === $out ) { | |
| 2807 | + return $res; | |
| 2808 | + } else { | |
| 2809 | + echo $res; // no escape due to filter. | |
| 2810 | + } | |
| 2811 | +} | |
| 2812 | + | |
| 2813 | +function self_filter_apply_admin_addressform( $formtag, $type, $data, $customdata ) { | |
| 2814 | + if ( ! empty( $_SESSION['admin_admb_custom_field_member'] ) ) { | |
| 2815 | + $admb = $_SESSION['admin_admb_custom_field_member']; | |
| 2816 | + $formtag .= usces_admin_custom_field_input( $admb['data'], $admb['type'], 'fax_after', 'return' ); | |
| 2817 | + unset( $_SESSION['admin_admb_custom_field_member'] ); | |
| 2818 | + } | |
| 2819 | + return $formtag; | |
| 2820 | +} | |
| 2821 | + | |
| 2822 | +function uesces_get_target_market_form( $type, $selected, $out = 'return' ) { | |
| 2823 | + global $usces_settings; | |
| 2824 | + | |
| 2825 | + $options = get_option( 'usces', array() ); | |
| 2826 | + $res = '<select name="' . $type . '[country]" id="' . $type . '_country">' . "\n"; | |
| 2827 | + foreach ( $usces_settings['country'] as $key => $value ) { | |
| 2828 | + if ( in_array( $key, $options['system']['target_market'] ) ) { | |
| 2829 | + $res .= '<option value="' . $key . '"' . selected( $selected, $key, false ) . '>' . $value . "</option>\n"; | |
| 2830 | + } | |
| 2831 | + } | |
| 2832 | + $res .= '</select>' . "\n"; | |
| 2833 | + | |
| 2834 | + if ( 'return' === $out ) { | |
| 2835 | + return wel_esc_script( $res ); | |
| 2836 | + } else { | |
| 2837 | + wel_esc_script_e( $res ); | |
| 2838 | + } | |
| 2839 | +} | |
| 2840 | + | |
| 2841 | +function usces_pref_select( $type, $values, $out = 'return' ) { | |
| 2842 | + global $usces, $usces_states; | |
| 2843 | + | |
| 2844 | + $country = empty( $values['country'] ) ? usces_get_base_country() : $values['country']; | |
| 2845 | + $options = get_option( 'usces', array() ); | |
| 2846 | + if ( ! in_array( $country, $options['system']['target_market'] ) ) { | |
| 2847 | + $country = $options['system']['target_market'][0]; | |
| 2848 | + } | |
| 2849 | + | |
| 2850 | + $pref = ( isset( $values['pref'] ) ) ? $values['pref'] : ''; | |
| 2851 | + $prefs = get_usces_states( $country ); | |
| 2852 | + $html = '<select name="' . esc_attr( $type . '[pref]' ) . '" id="' . esc_attr( $type ) . '_pref" class="pref">'; | |
| 2853 | + $prefs_count = count( $prefs ); | |
| 2854 | + if ( 0 < $prefs_count ) { | |
| 2855 | + $select = __( '-- Select --', 'usces_dual' ); | |
| 2856 | + $html .= "\t" . '<option value="' . esc_attr( $select ) . '">' . esc_html( $select ) . "</option>\n"; | |
| 2857 | + for ( $i = 1; $i < $prefs_count; $i++ ) { | |
| 2858 | + $html .= "\t" . '<option value="' . esc_attr( $prefs[ $i ] ) . '"' . selected( $prefs[ $i ], $pref, false ) . '>' . esc_html( $prefs[ $i ] ) . "</option>\n"; | |
| 2859 | + } | |
| 2860 | + } | |
| 2861 | + $html .= "</select>\n"; | |
| 2862 | + $html = apply_filters( 'usces_filter_pref_field', $html, $type, $values, $country, $prefs ); | |
| 2863 | + | |
| 2864 | + if ( 'return' === $out ) { | |
| 2865 | + return $html; | |
| 2866 | + } else { | |
| 2867 | + echo $html; // no escape due to filter. | |
| 2868 | + } | |
| 2869 | +} | |
| 2870 | + | |
| 2871 | +function usces_is_tax_display() { | |
| 2872 | + global $usces; | |
| 2873 | + if ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) { | |
| 2874 | + return false; | |
| 2875 | + } else { | |
| 2876 | + return true; | |
| 2877 | + } | |
| 2878 | +} | |
| 2879 | + | |
| 2880 | +function usces_get_tax_display() { | |
| 2881 | + global $usces; | |
| 2882 | + $tax_display = ( isset( $usces->options['tax_display'] ) ) ? $usces->options['tax_display'] : 'activate'; | |
| 2883 | + return $tax_display; | |
| 2884 | +} | |
| 2885 | + | |
| 2886 | +function usces_get_tax_mode() { | |
| 2887 | + global $usces; | |
| 2888 | + return $usces->options['tax_mode']; | |
| 2889 | +} | |
| 2890 | + | |
| 2891 | +function usces_get_tax_target() { | |
| 2892 | + global $usces; | |
| 2893 | + return $usces->options['tax_target']; | |
| 2894 | +} | |
| 2895 | + | |
| 2896 | +function usces_is_member_system() { | |
| 2897 | + global $usces; | |
| 2898 | + if ( 'activate' === $usces->options['membersystem_state'] ) { | |
| 2899 | + return true; | |
| 2900 | + } else { | |
| 2901 | + return false; | |
| 2902 | + } | |
| 2903 | +} | |
| 2904 | + | |
| 2905 | +function usces_is_member_system_point() { | |
| 2906 | + global $usces; | |
| 2907 | + if ( 'activate' === $usces->options['membersystem_point'] ) { | |
| 2908 | + return true; | |
| 2909 | + } else { | |
| 2910 | + return false; | |
| 2911 | + } | |
| 2912 | +} | |
| 2913 | + | |
| 2914 | +function usces_point_coverage() { | |
| 2915 | + global $usces; | |
| 2916 | + return $usces->options['point_coverage']; | |
| 2917 | +} | |
| 2918 | + | |
| 2919 | +function usces_shipping_country_option( $selected, $out = '' ) { | |
| 2920 | + global $usces_settings; | |
| 2921 | + | |
| 2922 | + $options = get_option( 'usces', array() ); | |
| 2923 | + $res = ''; | |
| 2924 | + foreach ( $usces_settings['country'] as $key => $value ) { | |
| 2925 | + if ( in_array( $key, $options['system']['target_market'], true ) ) { | |
| 2926 | + $res .= '<option value="' . $key . '"' . selected( $selected, $key, false ) . '>' . $value . "</option>\n"; | |
| 2927 | + } | |
| 2928 | + } | |
| 2929 | + wel_esc_script_e( $res ); | |
| 2930 | +} | |
| 2931 | + | |
| 2932 | +function usces_get_cart_button( $out = '' ) { | |
| 2933 | + global $usces; | |
| 2934 | + | |
| 2935 | + $res = ''; | |
| 2936 | + | |
| 2937 | + if ( $usces->use_js ) { | |
| 2938 | + $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();"' ) . ' /> '; | |
| 2939 | + if ( usces_is_cart() ) { | |
| 2940 | + $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __( ' Next ', 'usces' ) . '"' . apply_filters( 'usces_filter_cart_nextbutton', ' onclick="return uscesCart.cartNext();"' ) . ' />'; | |
| 2941 | + } | |
| 2942 | + } else { | |
| 2943 | + $res .= '<a href="' . get_home_url() . '" class="continue_shopping_button">' . __( 'continue shopping', 'usces' ) . '</a> '; | |
| 2944 | + if ( usces_is_cart() ) { | |
| 2945 | + $res .= '<input name="customerinfo" type="submit" class="to_customerinfo_button" value="' . __( ' Next ', 'usces' ) . '"' . apply_filters( 'usces_filter_cart_nextbutton', NULL ) . ' />'; | |
| 2946 | + } | |
| 2947 | + } | |
| 2948 | + $res = apply_filters( 'usces_filter_get_cart_button', $res ); | |
| 2949 | + | |
| 2950 | + if ( 'return' === $out ) { | |
| 2951 | + return $res; | |
| 2952 | + } else { | |
| 2953 | + echo $res; // no escape due to filter. | |
| 2954 | + } | |
| 2955 | +} | |
| 2956 | + | |
| 2957 | +function usces_get_customer_button( $out = '' ) { | |
| 2958 | + global $usces, $member_regmode; | |
| 2959 | + | |
| 2960 | + $res = '<input name="backCart" type="submit" class="back_cart_button" value="' . __( 'Back', 'usces' ) . '"' . apply_filters( 'usces_filter_customerinfo_pre', NULL ) . ' " /> '; | |
| 2961 | + | |
| 2962 | + $button = '<input name="deliveryinfo" type="submit" class="to_deliveryinfo_button" value="' . __( ' Next ', 'usces' ) . '"' . apply_filters( 'usces_filter_customerinfo_next', NULL ) . ' " /> '; | |
| 2963 | + $res .= apply_filters( 'usces_filter_customer_button', $button ); | |
| 2964 | + | |
| 2965 | + if ( usces_is_membersystem_state() && 'editmemberfromcart' !== $member_regmode && false === usces_is_login() ) { | |
| 2966 | + $res .= '<input name="reganddeliveryinfo" type="submit" class="to_reganddeliveryinfo_button" value="' . __( 'To the next while enrolling', 'usces' ) . '"' . apply_filters( 'usces_filter_customerinfo_prebutton', NULL ) . ' />'; | |
| 2967 | + } elseif ( usces_is_membersystem_state() && 'editmemberfromcart' === $member_regmode ) { | |
| 2968 | + $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 ) . ' />'; | |
| 2969 | + } | |
| 2970 | + | |
| 2971 | + $res = apply_filters( 'usces_filter_get_customer_button', $res ); | |
| 2972 | + | |
| 2973 | + if ( 'return' === $out ) { | |
| 2974 | + return $res; | |
| 2975 | + } else { | |
| 2976 | + echo $res; // no escape due to filter. | |
| 2977 | + } | |
| 2978 | +} | |
| 2979 | + | |
| 2980 | +function usces_delivery_secure_form( $out = '' ) { | |
| 2981 | + global $usces, $usces_entries, $usces_carts; | |
| 2982 | + | |
| 2983 | + $html = ''; | |
| 2984 | + include USCES_PLUGIN_DIR . '/includes/delivery_secure_form.php'; | |
| 2985 | + | |
| 2986 | + if ( 'return' === $out ) { | |
| 2987 | + return $html; | |
| 2988 | + } else { | |
| 2989 | + echo $html; // no escape due to filter. | |
| 2990 | + } | |
| 2991 | +} | |
| 2992 | + | |
| 2993 | +function usces_delivery_info_script( $out ='' ) { | |
| 2994 | + return; | |
| 2995 | +} | |
| 2996 | + | |
| 2997 | +function usces_delivery_info_scripts() { | |
| 2998 | + global $usces, $usces_entries, $usces_carts; | |
| 2999 | + | |
| 3000 | + $html = ''; | |
| 3001 | + if ( 'delivery' === $usces->page ) { | |
| 3002 | + include USCES_PLUGIN_DIR . '/includes/delivery_info_script.php'; | |
| 3003 | + } elseif ( usces_is_cart_page() && usces_is_login() ) { | |
| 3004 | + $paypal_ec = false; | |
| 3005 | + $payments = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 3006 | + foreach ( (array) $payments as $id => $payment ) { | |
| 3007 | + if ( 'acting_paypal_ec' === $payment['settlement'] && 'activate' === $payment['use'] ) { | |
| 3008 | + $paypal_ec = true; | |
| 3009 | + break; | |
| 3010 | + } | |
| 3011 | + } | |
| 3012 | + if ( $paypal_ec ) { | |
| 3013 | + include USCES_PLUGIN_DIR . '/includes/delivery_info_script.php'; | |
| 3014 | + } | |
| 3015 | + } | |
| 3016 | + echo $html; // no escape due to filter. | |
| 3017 | +} | |
| 3018 | + | |
| 3019 | +function usces_get_entries() { | |
| 3020 | + global $usces, $usces_entries; | |
| 3021 | + | |
| 3022 | + $usces_entries = $usces->cart->get_entry(); | |
| 3023 | + if ( empty( $usces_entries['order']['ID'] ) && ! empty( $usces_entries['reserve']['pre_order_id'] ) ) { | |
| 3024 | + $usces_entries['order']['ID'] = $usces->get_order_id_by_pre_order_id( $usces_entries['reserve']['pre_order_id'] ); | |
| 3025 | + $usces->cart->set_order_entry( array( 'ID' => $usces_entries['order']['ID'] ) ); | |
| 3026 | + } | |
| 3027 | +} | |
| 3028 | + | |
| 3029 | +function usces_get_carts() { | |
| 3030 | + global $usces, $usces_carts; | |
| 3031 | + $usces_carts = $usces->cart->get_cart(); | |
| 3032 | +} | |
| 3033 | + | |
| 3034 | +function usces_get_members() { | |
| 3035 | + global $usces, $usces_members; | |
| 3036 | + $usces_members = $usces->get_member(); | |
| 3037 | +} | |
| 3038 | + | |
| 3039 | +function usces_error_message( $out = '' ) { | |
| 3040 | + global $usces; | |
| 3041 | + | |
| 3042 | + if ( 'return' === $out ) { | |
| 3043 | + return wel_esc_script( $usces->error_message ); | |
| 3044 | + } else { | |
| 3045 | + wel_esc_script_e( $usces->error_message ); | |
| 3046 | + } | |
| 3047 | +} | |
| 3048 | + | |
| 3049 | +function usces_url( $type, $out = '' ) { | |
| 3050 | + global $usces; | |
| 3051 | + | |
| 3052 | + switch ( $type ) { | |
| 3053 | + case 'cart': | |
| 3054 | + $url = USCES_CART_URL; | |
| 3055 | + break; | |
| 3056 | + case 'login': | |
| 3057 | + $url = USCES_LOGIN_URL; | |
| 3058 | + break; | |
| 3059 | + case 'member': | |
| 3060 | + $url = USCES_MEMBER_URL; | |
| 3061 | + break; | |
| 3062 | + case 'newmember': | |
| 3063 | + $url = USCES_NEWMEMBER_URL; | |
| 3064 | + break; | |
| 3065 | + case 'lostmemberpassword': | |
| 3066 | + $url = USCES_LOSTMEMBERPASSWORD_URL; | |
| 3067 | + break; | |
| 3068 | + case 'cartnonsession': | |
| 3069 | + $url = USCES_CART_NONSESSION_URL; | |
| 3070 | + break; | |
| 3071 | + } | |
| 3072 | + | |
| 3073 | + if ( 'return' === $out ) { | |
| 3074 | + return $url; | |
| 3075 | + } else { | |
| 3076 | + echo esc_url( $url ); | |
| 3077 | + } | |
| 3078 | +} | |
| 3079 | + | |
| 3080 | +function usces_total_price( $out = '' ) { | |
| 3081 | + global $usces; | |
| 3082 | + | |
| 3083 | + if ( 'return' === $out ) { | |
| 3084 | + return wel_esc_script( $usces->get_total_price() ); | |
| 3085 | + } else { | |
| 3086 | + wel_esc_script_e( $usces->get_total_price() ); | |
| 3087 | + } | |
| 3088 | +} | |
| 3089 | + | |
| 3090 | +function usces_completion_settlement( $out ='' ) { | |
| 3091 | + global $usces, $usces_entries; | |
| 3092 | + | |
| 3093 | + $html = ''; | |
| 3094 | + | |
| 3095 | + $template = apply_filters( 'usces_filter_completion_settlement', USCES_PLUGIN_DIR . '/includes/completion_settlement.php', $usces_entries ); | |
| 3096 | + require( $template ); | |
| 3097 | + | |
| 3098 | + if ( 'return' === $out ) { | |
| 3099 | + return $html; | |
| 3100 | + } else { | |
| 3101 | + echo $html; // no escape due to filter. | |
| 3102 | + } | |
| 3103 | +} | |
| 3104 | + | |
| 3105 | +function usces_purchase_button( $out ='' ) { | |
| 3106 | + global $usces, $usces_entries; | |
| 3107 | + | |
| 3108 | + $html = ''; | |
| 3109 | + include USCES_PLUGIN_DIR . '/includes/purchase_button.php'; | |
| 3110 | + | |
| 3111 | + if ( 'return' === $out ) { | |
| 3112 | + return $html; | |
| 3113 | + } else { | |
| 3114 | + echo $html; // no escape due to filter. | |
| 3115 | + } | |
| 3116 | +} | |
| 3117 | + | |
| 3118 | +function usces_get_member_regmode() { | |
| 3119 | + global $member_regmode; | |
| 3120 | + $member_regmode = isset( $_SESSION['usces_entry']['member_regmode'] ) ? $_SESSION['usces_entry']['member_regmode'] : 'none'; | |
| 3121 | +} | |
| 3122 | + | |
| 3123 | +function uesces_get_error_settlement( $out = '' ) { | |
| 3124 | + $res = ''; | |
| 3125 | + $res = apply_filters( 'usces_filter_get_error_settlement', $res ); | |
| 3126 | + if ( empty( $res ) ) { | |
| 3127 | + $res = __( 'Sorry, If you have any questions, please contact the administrator of the site.', 'usces' ); | |
| 3128 | + } | |
| 3129 | + | |
| 3130 | + if ( 'return' === $out ) { | |
| 3131 | + return $res; | |
| 3132 | + } else { | |
| 3133 | + echo $res; // no escape due to filter. | |
| 3134 | + } | |
| 3135 | +} | |
| 3136 | + | |
| 3137 | +function usces_page_name( $out = '' ) { | |
| 3138 | + global $usces; | |
| 3139 | + | |
| 3140 | + $page = ''; | |
| 3141 | + | |
| 3142 | + if ( empty( $usces->page ) ) { | |
| 3143 | + if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 3144 | + $page = 'cart'; | |
| 3145 | + } elseif ( $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 3146 | + $page = 'member'; | |
| 3147 | + } | |
| 3148 | + } else { | |
| 3149 | + $page = $usces->page; | |
| 3150 | + } | |
| 3151 | + $page = apply_filters( 'usces_filter_usces_page_name', $page ); | |
| 3152 | + | |
| 3153 | + if ( 'return' === $out ) { | |
| 3154 | + return esc_js( $page ); | |
| 3155 | + } else { | |
| 3156 | + echo esc_html( $page ); | |
| 3157 | + } | |
| 3158 | +} | |
| 3159 | + | |
| 3160 | +function usces_post_reg_orderdata( $order_id, $results ) { | |
| 3161 | + global $usces, $wpdb; | |
| 3162 | + | |
| 3163 | + $acting = isset( $_GET['acting'] ) ? $_GET['acting'] : ''; | |
| 3164 | + $data = array(); | |
| 3165 | + | |
| 3166 | + if ( $order_id ) { | |
| 3167 | + | |
| 3168 | + switch ( $acting ) { | |
| 3169 | + case 'epsilon': | |
| 3170 | + $trans_id = isset( $_REQUEST['trans_code'] ) ? $_REQUEST['trans_code'] : ''; | |
| 3171 | + break; | |
| 3172 | + case 'paypal_ipn': | |
| 3173 | + $trans_id = isset( $_REQUEST['txn_id'] ) ? $_REQUEST['txn_id'] : ''; | |
| 3174 | + break; | |
| 3175 | + case 'paypal': | |
| 3176 | + $trans_id = isset( $results['txn_id'] ) ? $results['txn_id'] : ''; | |
| 3177 | + break; | |
| 3178 | + case 'paypal_ec': | |
| 3179 | + $trans_id = isset( $_REQUEST['token'] ) ? $_REQUEST['token'] : ''; | |
| 3180 | + if ( isset( $results['settlement_id'] ) ) { | |
| 3181 | + $usces->set_order_meta_value( 'settlement_id', $results['settlement_id'], $order_id ); | |
| 3182 | + } | |
| 3183 | + if ( isset( $results['profile_id'] ) ) { | |
| 3184 | + $usces->set_order_meta_value( 'profile_id', $results['profile_id'], $order_id ); | |
| 3185 | + } | |
| 3186 | + break; | |
| 3187 | + case 'remise_card': | |
| 3188 | + $trans_id = isset( $_REQUEST['X-TRANID'] ) ? $_REQUEST['X-TRANID'] : ''; | |
| 3189 | + break; | |
| 3190 | + case 'remise_conv': | |
| 3191 | + $trans_id = isset( $_REQUEST['X-JOB_ID'] ) ? $_REQUEST['X-JOB_ID'] : ''; | |
| 3192 | + break; | |
| 3193 | + case 'jpayment_card': | |
| 3194 | + case 'jpayment_conv': | |
| 3195 | + case 'jpayment_bank': | |
| 3196 | + $trans_id = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : ''; | |
| 3197 | + break; | |
| 3198 | + case 'telecom_card': | |
| 3199 | + $trans_id = isset( $_REQUEST['sendid'] ) ? $_REQUEST['sendid'] : ''; | |
| 3200 | + break; | |
| 3201 | + case 'digitalcheck_card': | |
| 3202 | + case 'digitalcheck_conv': | |
| 3203 | + $trans_id = isset( $_REQUEST['SID'] ) ? $_REQUEST['SID'] : ''; | |
| 3204 | + break; | |
| 3205 | + case 'mizuho_card': | |
| 3206 | + case 'mizuho_conv': | |
| 3207 | + $trans_id = isset( $_REQUEST['stran'] ) ? $_REQUEST['stran'] : ''; | |
| 3208 | + break; | |
| 3209 | + default: | |
| 3210 | + if ( isset( $_REQUEST['FUKA'] ) && strstr( $_REQUEST['FUKA'], 'digitalcheck_card' ) ) { | |
| 3211 | + $trans_id = isset( $_REQUEST['SID'] ) ? $_REQUEST['SID'] : ''; | |
| 3212 | + } else { | |
| 3213 | + $trans_id = ''; | |
| 3214 | + } | |
| 3215 | + } | |
| 3216 | + | |
| 3217 | + if ( ! empty( $trans_id ) ) { | |
| 3218 | + $usces->set_order_meta_value( 'trans_id', $trans_id, $order_id ); | |
| 3219 | + } | |
| 3220 | + } | |
| 3221 | +} | |
| 3222 | + | |
| 3223 | +function usces_paypal_doecp( &$results ) { | |
| 3224 | + global $usces; | |
| 3225 | + | |
| 3226 | + $entry = $usces->cart->get_entry(); | |
| 3227 | + $cart = $usces->cart->get_cart(); | |
| 3228 | + | |
| 3229 | + $post_id = $cart[0]['post_id']; | |
| 3230 | + $charging_type = $usces->getItemChargingType( $post_id ); | |
| 3231 | + if ( 'continue' !== $charging_type ) { | |
| 3232 | + //通常購入. | |
| 3233 | + //Format the other parameters that were stored in the session from the previous calls. | |
| 3234 | + $token = urlencode( $_REQUEST['token'] ); | |
| 3235 | + $paymentType = apply_filters( 'usces_filter_paypal_ec_paymentaction', 'Sale' ); | |
| 3236 | + $currencyCodeType = urlencode( $usces->get_currency_code() ); | |
| 3237 | + $payerID = urlencode( $_REQUEST['PayerID'] ); | |
| 3238 | + $serverName = urlencode( $_SERVER['SERVER_NAME'] ); | |
| 3239 | + $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; | |
| 3240 | + $item_total_price = 0; | |
| 3241 | + $i = 0; | |
| 3242 | + foreach ( $cart as $cart_row ) { | |
| 3243 | + $nvpstr .= | |
| 3244 | + '&L_PAYMENTREQUEST_0_NAME' . $i . '=' . urlencode( $usces->getItemName( $cart_row['post_id'] ) ) . | |
| 3245 | + '&L_PAYMENTREQUEST_0_AMT' . $i . '=' . usces_crform( $cart_row['price'], false, false, 'return', false ) . | |
| 3246 | + '&L_PAYMENTREQUEST_0_NUMBER' . $i . '=' . urlencode( $usces->getItemCode( $cart_row['post_id'] ) ) . ' ' . $cart_row['sku'] . | |
| 3247 | + '&L_PAYMENTREQUEST_0_QTY' . $i . '=' . $cart_row['quantity']; | |
| 3248 | + $options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array(); | |
| 3249 | + if ( is_array( $options ) && count( $options ) > 0 ) { | |
| 3250 | + $optstr = ''; | |
| 3251 | + foreach ( $options as $key => $value ) { | |
| 3252 | + if ( ! empty( $key ) ) { | |
| 3253 | + $key = urldecode( $key ); | |
| 3254 | + $value = wel_safe_maybe_unserialize( $value ); | |
| 3255 | + if ( is_array( $value ) ) { | |
| 3256 | + $c = ''; | |
| 3257 | + $optstr .= $key . ' : '; | |
| 3258 | + foreach ( $value as $v ) { | |
| 3259 | + $optstr .= $c.urldecode( $v ); | |
| 3260 | + $c = ', '; | |
| 3261 | + } | |
| 3262 | + $optstr .= "\r\n"; | |
| 3263 | + } else { | |
| 3264 | + $optstr .= $key . ' : ' . urldecode( $value ) . "\r\n"; | |
| 3265 | + } | |
| 3266 | + } | |
| 3267 | + } | |
| 3268 | + if ( '' !== $optstr ) { | |
| 3269 | + if ( 60 < mb_strlen( $optstr, 'UTF-8' ) ) { | |
| 3270 | + $optstr = mb_substr( $optstr, 0, 60, 'UTF-8' ) . '...'; | |
| 3271 | + } | |
| 3272 | + $nvpstr .= '&L_PAYMENTREQUEST_0_DESC' . $i . '=' . urlencode( $optstr ); | |
| 3273 | + } | |
| 3274 | + } | |
| 3275 | + $item_total_price += ( $cart_row['price'] * $cart_row['quantity'] ); | |
| 3276 | + $i++; | |
| 3277 | + } | |
| 3278 | + if ( ! empty( $entry['order']['discount'] ) ) { | |
| 3279 | + $nvpstr .= | |
| 3280 | + '&L_PAYMENTREQUEST_0_NAME' . $i . '=' . urlencode( __( 'Campaign discount', 'usces' ) ) . | |
| 3281 | + '&L_PAYMENTREQUEST_0_AMT' . $i . '=' . usces_crform( $entry['order']['discount'], false, false, 'return', false ); | |
| 3282 | + $item_total_price += $entry['order']['discount']; | |
| 3283 | + $i++; | |
| 3284 | + } | |
| 3285 | + if ( ! empty( $entry['order']['usedpoint'] ) ) { | |
| 3286 | + $nvpstr .= | |
| 3287 | + '&L_PAYMENTREQUEST_0_NAME' . $i . '=' . urlencode( __( 'Used points', 'usces' ) ) . | |
| 3288 | + '&L_PAYMENTREQUEST_0_AMT' . $i . '=' . usces_crform( $entry['order']['usedpoint'] * (-1), false, false, 'return', false ); | |
| 3289 | + $item_total_price -= $entry['order']['usedpoint']; | |
| 3290 | + $i++; | |
| 3291 | + } | |
| 3292 | + $nvpstr .= | |
| 3293 | + '&PAYMENTREQUEST_0_ITEMAMT=' . usces_crform( $item_total_price, false, false, 'return', false ) . | |
| 3294 | + '&PAYMENTREQUEST_0_SHIPPINGAMT=' . usces_crform( $entry['order']['shipping_charge'], false, false, 'return', false ) . | |
| 3295 | + '&PAYMENTREQUEST_0_AMT=' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ) ; | |
| 3296 | + if ( ! empty( $entry['order']['cod_fee'] ) ) { | |
| 3297 | + $nvpstr .= '&PAYMENTREQUEST_0_HANDLINGAMT=' . usces_crform( $entry['order']['cod_fee'], false, false, 'return', false ); | |
| 3298 | + } | |
| 3299 | + if ( ! empty( $entry['order']['tax'] ) ) { | |
| 3300 | + $nvpstr .= '&PAYMENTREQUEST_0_TAXAMT=' . usces_crform( $entry['order']['tax'], false, false, 'return', false ); | |
| 3301 | + } | |
| 3302 | + $nvpstr .= '&PAYMENTREQUEST_0_AMT=' . usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ); | |
| 3303 | + $nvpstr = apply_filters( 'usces_filter_usces_paypal_doecp', $nvpstr, $charging_type ); | |
| 3304 | + if ( 'shipped' === $usces->getItemDivision( $post_id ) ) { | |
| 3305 | + $name = urlencode( $entry['delivery']['name2'] . ' ' . $entry['delivery']['name1'] ); | |
| 3306 | + $address2 = urlencode( $entry['delivery']['address2'] ); | |
| 3307 | + $address3 = urlencode( $entry['delivery']['address3'] ); | |
| 3308 | + $address1 = urlencode( $entry['delivery']['address1'] ); | |
| 3309 | + $pref = urlencode( $entry['delivery']['pref'] ); | |
| 3310 | + $country = ( ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : usces_get_base_country(); | |
| 3311 | + $country_code = apply_filters( 'usces_filter_paypalec_shiptocountrycode', $country ); | |
| 3312 | + if ( 'TW' === $country_code ) { | |
| 3313 | + $city = $address1; | |
| 3314 | + $address1 = $pref; | |
| 3315 | + $pref = $city; | |
| 3316 | + } | |
| 3317 | + $zip = $entry['delivery']['zipcode']; | |
| 3318 | + $tel = ltrim( str_replace( '-', '', $entry['delivery']['tel'] ), '0' ); | |
| 3319 | + if ( 'US' !== $country_code && 'CA' !== $country_code ) { | |
| 3320 | + $nvpstr .= | |
| 3321 | + '&PAYMENTREQUEST_0_SHIPTONAME=' . $name . | |
| 3322 | + '&PAYMENTREQUEST_0_SHIPTOSTREET=' . $address2 . | |
| 3323 | + '&PAYMENTREQUEST_0_SHIPTOSTREET2=' . $address3 . | |
| 3324 | + '&PAYMENTREQUEST_0_SHIPTOCITY=' . $address1 . | |
| 3325 | + '&PAYMENTREQUEST_0_SHIPTOSTATE=' . $pref . | |
| 3326 | + '&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=' . $country_code . | |
| 3327 | + '&PAYMENTREQUEST_0_SHIPTOZIP=' . $zip . | |
| 3328 | + '&PAYMENTREQUEST_0_SHIPTOPHONENUM=' . $tel; | |
| 3329 | + } | |
| 3330 | + } | |
| 3331 | + $usces->paypal->setMethod( 'DoExpressCheckoutPayment' ); | |
| 3332 | + $usces->paypal->setData( $nvpstr ); | |
| 3333 | + $res = $usces->paypal->doExpressCheckout(); | |
| 3334 | + $resArray = $usces->paypal->getResponse(); | |
| 3335 | + $ack = strtoupper( $resArray['ACK'] ); | |
| 3336 | + if ( 'SUCCESS' === $ack || 'SUCCESSWITHWARNING' === $ack ) { | |
| 3337 | + $transactionId = $resArray['PAYMENTINFO_0_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. | |
| 3338 | + $results['settlement_id'] = $transactionId; | |
| 3339 | + $results['payment_status'] = isset( $resArray['PAYMENTINFO_0_PAYMENTSTATUS'] ) ? $resArray['PAYMENTINFO_0_PAYMENTSTATUS'] : ''; | |
| 3340 | + $results['pending_reason'] = isset( $resArray['PAYMENTINFO_0_PENDINGREASON'] ) ? $resArray['PAYMENTINFO_0_PENDINGREASON'] : ''; | |
| 3341 | + | |
| 3342 | + } else { | |
| 3343 | + //Display a user friendly Error on the page using any of the following error information returned by PayPal. | |
| 3344 | + $ErrorCode = urldecode( $resArray['L_ERRORCODE0'] ); | |
| 3345 | + $ErrorShortMsg = urldecode( $resArray['L_SHORTMESSAGE0'] ); | |
| 3346 | + $ErrorLongMsg = urldecode( $resArray['L_LONGMESSAGE0'] ); | |
| 3347 | + $ErrorSeverityCode = urldecode( $resArray['L_SEVERITYCODE0'] ); | |
| 3348 | + 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' ); | |
| 3349 | + if ( '10486' === $ErrorCode ) { | |
| 3350 | + $options = get_option( 'usces', array() ); | |
| 3351 | + $acting_opts = $options['acting_settings']['paypal']; | |
| 3352 | + $query = http_build_query( $_REQUEST ); | |
| 3353 | + $payPalURL = $acting_opts['paypal_url'] . '?cmd=_express-checkout&' . $query; | |
| 3354 | + header( 'Location: ' . $payPalURL ); | |
| 3355 | + exit; | |
| 3356 | + } | |
| 3357 | + $log = array( | |
| 3358 | + 'acting' => 'paypal_ec', | |
| 3359 | + 'key' => '(empty key)', | |
| 3360 | + 'result' => $ack, | |
| 3361 | + 'data' => $resArray, | |
| 3362 | + ); | |
| 3363 | + usces_save_order_acting_error( $log ); | |
| 3364 | + return false; | |
| 3365 | + } | |
| 3366 | + | |
| 3367 | + } else { | |
| 3368 | + if ( ! apply_filters( 'usces_pre_create_recurring_payments_profile', true ) ) { | |
| 3369 | + return false; | |
| 3370 | + } | |
| 3371 | + | |
| 3372 | + //定期支払い. | |
| 3373 | + $paymentAmount = usces_crform( $entry['order']['total_full_price'], false, false, 'return', false ); | |
| 3374 | + $token = urlencode( $_REQUEST['token'] ); | |
| 3375 | + $currencyCodeType = urlencode( $usces->get_currency_code() ); | |
| 3376 | + $profileStartDate = date( 'Y-m-d', dlseller_first_charging( $post_id, 'time' ) ) . 'T01:01:01Z'; | |
| 3377 | + $billingPeriod = 'Month';// or "Day", "Week", "SemiMonth", "Year". | |
| 3378 | + $billingFreq = $usces->getItemFrequency( $post_id ); | |
| 3379 | + $desc = urlencode( usces_make_agreement_description( $cart, $entry['order']['total_full_price'] ) ); | |
| 3380 | + $totalBillingCycles = ( empty( $dlitem['dlseller_interval'] ) ) ? '' : '&TOTALBILLINGCYCLES=' . urlencode( $dlitem['dlseller_interval'] ); | |
| 3381 | + | |
| 3382 | + $nvpstr = '&TOKEN=' . $token . '&AMT=' . $paymentAmount . '&CURRENCYCODE=' . $currencyCodeType . '&PROFILESTARTDATE=' . $profileStartDate . '&BILLINGPERIOD=' . $billingPeriod . '&BILLINGFREQUENCY=' . $billingFreq . '&DESC=' . $desc . $totalBillingCycles; | |
| 3383 | + $nvpstr = apply_filters( 'usces_filter_usces_paypal_doecp', $nvpstr, $charging_type ); | |
| 3384 | + | |
| 3385 | + $usces->paypal->setMethod( 'CreateRecurringPaymentsProfile' ); | |
| 3386 | + $usces->paypal->setData( $nvpstr ); | |
| 3387 | + $res = $usces->paypal->doExpressCheckout(); | |
| 3388 | + $resArray = $usces->paypal->getResponse(); | |
| 3389 | + $ack = strtoupper( $resArray['ACK'] ); | |
| 3390 | + if ( 'SUCCESS' === $ack || 'SUCCESSWITHWARNING' === $ack ) { | |
| 3391 | + $profileid = $resArray['PROFILEID']; | |
| 3392 | + $results['settlement_id'] = $profileid; | |
| 3393 | + $results['profile_id'] = $profileid; | |
| 3394 | + $results['profile_status'] = isset( $resArray['PROFILESTATUS'] ) ? $resArray['PROFILESTATUS'] : ''; | |
| 3395 | + | |
| 3396 | + } else { | |
| 3397 | + //Display a user friendly Error on the page using any of the following error information returned by PayPal. | |
| 3398 | + $ErrorCode = urldecode( $resArray['L_ERRORCODE0'] ); | |
| 3399 | + $ErrorShortMsg = urldecode( $resArray['L_SHORTMESSAGE0'] ); | |
| 3400 | + $ErrorLongMsg = urldecode( $resArray['L_LONGMESSAGE0'] ); | |
| 3401 | + $ErrorSeverityCode = urldecode( $resArray['L_SEVERITYCODE0'] ); | |
| 3402 | + 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' ); | |
| 3403 | + $log = array( | |
| 3404 | + 'acting' => 'paypal_ec', | |
| 3405 | + 'key' => '(empty key)', | |
| 3406 | + 'result' => $ack, | |
| 3407 | + 'data' => $resArray, | |
| 3408 | + ); | |
| 3409 | + usces_save_order_acting_error( $log ); | |
| 3410 | + return false; | |
| 3411 | + } | |
| 3412 | + } | |
| 3413 | + | |
| 3414 | + return true; | |
| 3415 | +} | |
| 3416 | + | |
| 3417 | +function usces_make_agreement_description( $cart, $amt ) { | |
| 3418 | + global $usces; | |
| 3419 | + | |
| 3420 | + $cart_row = $cart[0]; | |
| 3421 | + $quantity = $cart_row['quantity']; | |
| 3422 | + $itemName = $usces->getItemName( $cart_row['post_id'] ); | |
| 3423 | + if ( 50 < mb_strlen( $itemName, 'UTF-8' ) ) { | |
| 3424 | + $itemName = mb_substr( $itemName, 0, 50, 'UTF-8' ) . '...'; | |
| 3425 | + } | |
| 3426 | + $amt = usces_crform( $amt, true, false, 'return', true ); | |
| 3427 | + $desc = $itemName . ' ' . __( 'Quantity', 'usces' ) . ':' . $quantity . ' ' . $amt; | |
| 3428 | + return( $desc ); | |
| 3429 | +} | |
| 3430 | + | |
| 3431 | +function usces_get_send_out_date() { | |
| 3432 | + global $usces; | |
| 3433 | + | |
| 3434 | + $bus_day_arr = ( isset( $usces->options['business_days'] ) ) ? $usces->options['business_days'] : false; | |
| 3435 | + $bus_day_arr = apply_filters( 'usces_filter_business_days_bus_day_arr', $bus_day_arr ); | |
| 3436 | + | |
| 3437 | + list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', current_time( 'mysql' ) ); | |
| 3438 | + if ( ! is_array( $bus_day_arr ) ) { | |
| 3439 | + $today_bus_flag = 1; | |
| 3440 | + } else { | |
| 3441 | + $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; | |
| 3442 | + } | |
| 3443 | + // get the time limit addition. | |
| 3444 | + $limit_hour = ( ! empty( $usces->options['delivery_time_limit']['hour'] ) ) ? $usces->options['delivery_time_limit']['hour'] : false; | |
| 3445 | + $limit_min = ( ! empty( $usces->options['delivery_time_limit']['min'] ) ) ? $usces->options['delivery_time_limit']['min'] : false; | |
| 3446 | + | |
| 3447 | + if ( false === $hour || false === $minute ) { | |
| 3448 | + $time_limit_addition = false; | |
| 3449 | + } elseif ( ( $hour . ':' . $minute . ':' . $second ) > ( $limit_hour . ':' . $limit_min . ':00' ) ) { | |
| 3450 | + $time_limit_addition = 1; | |
| 3451 | + } else { | |
| 3452 | + $time_limit_addition = 0; | |
| 3453 | + } | |
| 3454 | + // get the shipping indication in cart. | |
| 3455 | + $cart = $usces->cart->get_cart(); | |
| 3456 | + $shipping_indication = apply_filters( 'usces_filter_shipping_indication', $usces->options['usces_shipping_indication'] ); | |
| 3457 | + $shipping = 0; | |
| 3458 | + $indication_flag = true; | |
| 3459 | + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0; | |
| 3460 | + $shipping_rule_ex = apply_filters( 'usces_filter_item_shipping_rule_ex', 9 ); | |
| 3461 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 3462 | + $cart_row = $cart[ $i ]; | |
| 3463 | + $post_id = $cart_row['post_id']; | |
| 3464 | + $itemShipping = (int) $usces->getItemShipping( $post_id ); | |
| 3465 | + if ( 0 === $itemShipping || $shipping_rule_ex === $itemShipping ) { | |
| 3466 | + $indication_flag = false; | |
| 3467 | + break; | |
| 3468 | + } | |
| 3469 | + if ( $shipping < $itemShipping ) { | |
| 3470 | + $shipping = $itemShipping; | |
| 3471 | + } | |
| 3472 | + } | |
| 3473 | + $indication_incart = ( $indication_flag ) ? $shipping_indication[ $shipping ] : false; | |
| 3474 | + $indication_incart = apply_filters( 'usces_filter_indication_incart', $indication_incart, $shipping_indication, $shipping, $cart ); | |
| 3475 | + // get the send out date. | |
| 3476 | + $sendout_num = 0; | |
| 3477 | + if ( $today_bus_flag ) { | |
| 3478 | + if ( $time_limit_addition ) { | |
| 3479 | + $sendout_num += 1; | |
| 3480 | + } | |
| 3481 | + if ( false !== $indication_incart ) { | |
| 3482 | + $sendout_num += $indication_incart; | |
| 3483 | + } | |
| 3484 | + } else { | |
| 3485 | + if ( false !== $indication_incart ) { | |
| 3486 | + $sendout_num += $indication_incart; | |
| 3487 | + } | |
| 3488 | + } | |
| 3489 | + $holiday = 0; | |
| 3490 | + for ( $i = 0; $i <= $sendout_num; $i++ ) { | |
| 3491 | + list( $yyyy, $mm, $dd ) = explode( '-', date( 'Y-m-d', mktime( 0, 0, 0, (int) $today_month, ( $today_day + $i ), (int) $today_year ) ) ); | |
| 3492 | + if ( isset( $bus_day_arr[ (int) $yyyy ][ (int) $mm ][ (int) $dd ] ) && ! $bus_day_arr[ (int) $yyyy ][ (int) $mm ][ (int) $dd ] ) { | |
| 3493 | + $holiday++; | |
| 3494 | + $sendout_num++; | |
| 3495 | + } | |
| 3496 | + if ( 100 < $sendout_num ) { | |
| 3497 | + break; | |
| 3498 | + } | |
| 3499 | + } | |
| 3500 | + 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 ) ) ); | |
| 3501 | + | |
| 3502 | + $res = array( | |
| 3503 | + 'today_bus_flag' => $today_bus_flag, | |
| 3504 | + 'time_limit_addition' => $time_limit_addition, | |
| 3505 | + 'indication_incart' => $indication_incart, | |
| 3506 | + 'holiday' => $holiday, | |
| 3507 | + 'sendout_num' => $sendout_num, | |
| 3508 | + 'sendout_date' => array( | |
| 3509 | + 'year' => $send_y, | |
| 3510 | + 'month' => $send_m, | |
| 3511 | + 'day' => $send_d, | |
| 3512 | + ), | |
| 3513 | + ); | |
| 3514 | + return $res; | |
| 3515 | +} | |
| 3516 | + | |
| 3517 | +function usces_action_footer_comment() { | |
| 3518 | + echo "<!-- Welcart version : v" . USCES_VERSION . " -->\n"; | |
| 3519 | +} | |
| 3520 | + | |
| 3521 | +function usces_set_acting_notification_time( $key ) { | |
| 3522 | + global $wpdb; | |
| 3523 | + | |
| 3524 | + $tableName = $wpdb->prefix . 'usces_access'; | |
| 3525 | + $query = $wpdb->prepare( "SELECT ID FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key ); | |
| 3526 | + $res = $wpdb->get_var( $query ); | |
| 3527 | + if ( $res ) { | |
| 3528 | + return; | |
| 3529 | + } | |
| 3530 | + | |
| 3531 | + $query = $wpdb->prepare( "INSERT INTO $tableName (acc_key, acc_type, acc_num1) VALUES (%s, %s, %d)", | |
| 3532 | + $key, 'notification_time', time() | |
| 3533 | + ); | |
| 3534 | + $res = $wpdb->query( $query ); | |
| 3535 | +} | |
| 3536 | + | |
| 3537 | +function usces_check_notification_time( $key, $time ) { | |
| 3538 | + global $wpdb; | |
| 3539 | + | |
| 3540 | + $tableName = $wpdb->prefix . 'usces_access'; | |
| 3541 | + $query = $wpdb->prepare( "SELECT acc_num1 FROM $tableName WHERE acc_type = %s AND acc_key = %s", 'notification_time', $key ); | |
| 3542 | + $res = $wpdb->get_var( $query ); | |
| 3543 | + if ( ! $res ) { | |
| 3544 | + return false; | |
| 3545 | + } | |
| 3546 | + | |
| 3547 | + $past = time() - $res; | |
| 3548 | + if ( $time > $past ) { | |
| 3549 | + return true; | |
| 3550 | + } else { | |
| 3551 | + return false; | |
| 3552 | + } | |
| 3553 | +} | |
| 3554 | + | |
| 3555 | +function usces_is_same_itemcode( $post_id, $item_code ) { | |
| 3556 | + global $wpdb, $usces; | |
| 3557 | + | |
| 3558 | + $item_table = usces_get_tablename( 'usces_item' ); | |
| 3559 | + | |
| 3560 | + $res = $wpdb->get_col( | |
| 3561 | + $wpdb->prepare( | |
| 3562 | + "SELECT `post_id` FROM {$item_table} | |
| 3563 | + LEFT JOIN {$wpdb->posts} ON `ID` = `post_id` | |
| 3564 | + WHERE `itemCode` = %s AND `post_id` <> %d | |
| 3565 | + AND `post_status` IN ('pending', 'publish', 'draft', 'private', 'future')", | |
| 3566 | + $item_code, | |
| 3567 | + $post_id | |
| 3568 | + ) | |
| 3569 | + ); | |
| 3570 | + | |
| 3571 | + if ( ! $res ) { | |
| 3572 | + return false; | |
| 3573 | + } else { | |
| 3574 | + return $res; | |
| 3575 | + } | |
| 3576 | +} | |
| 3577 | + | |
| 3578 | +function usces_update_sku( $post_id, $sku_code, $fieldname, $value ) { | |
| 3579 | + | |
| 3580 | + $sku = wel_get_sku( $post_id, $sku_code, false ); | |
| 3581 | + | |
| 3582 | + $sku[ $fieldname ] = $value; | |
| 3583 | + $meta_id = $sku['meta_id']; | |
| 3584 | + | |
| 3585 | + $res = wel_update_sku_data_by_id( $meta_id, $post_id, $sku ); | |
| 3586 | + | |
| 3587 | + if ( ! $res ) { | |
| 3588 | + return false; | |
| 3589 | + } else { | |
| 3590 | + return true; | |
| 3591 | + } | |
| 3592 | +} | |
| 3593 | + | |
| 3594 | +function usces_get_non_zerostoc_items() { | |
| 3595 | + global $wpdb, $usces; | |
| 3596 | + | |
| 3597 | + $item_table = usces_get_tablename( 'usces_item' ); | |
| 3598 | + $skus_table = usces_get_tablename( 'usces_skus' ); | |
| 3599 | + | |
| 3600 | + $res = $wpdb->get_results( | |
| 3601 | + $wpdb->prepare( | |
| 3602 | + "SELECT `ID`, `itemCode` AS `code`, `itemName` AS `name` FROM {$wpdb->posts} AS `post` | |
| 3603 | + LEFT JOIN {$item_table} AS `item` ON `ID` = item.post_id | |
| 3604 | + LEFT JOIN {$skus_table} AS `sku` ON `ID` = sku.post_id | |
| 3605 | + WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s AND sku.stocknum = %s | |
| 3606 | + GROUP BY ID", | |
| 3607 | + 'item', | |
| 3608 | + 'post', | |
| 3609 | + 'trash', | |
| 3610 | + '0' | |
| 3611 | + ), | |
| 3612 | + ARRAY_A | |
| 3613 | + ); | |
| 3614 | + | |
| 3615 | + return $res; | |
| 3616 | +} | |
| 3617 | + | |
| 3618 | +function usces_get_stocs() { | |
| 3619 | + global $wpdb, $usces; | |
| 3620 | + | |
| 3621 | + $status = array(); | |
| 3622 | + $sku_table = $wpdb->prefix . 'usces_skus'; | |
| 3623 | + | |
| 3624 | + $stocks = $wpdb->get_col( | |
| 3625 | + $wpdb->prepare( | |
| 3626 | + "SELECT stock FROM {$wpdb->posts} LEFT JOIN {$sku_table} ON ID = post_id | |
| 3627 | + WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s", | |
| 3628 | + 'item', | |
| 3629 | + 'post', | |
| 3630 | + 'trash' | |
| 3631 | + ) | |
| 3632 | + ); | |
| 3633 | + | |
| 3634 | + if ( ! $stocks ) { | |
| 3635 | + return $status; | |
| 3636 | + } | |
| 3637 | + | |
| 3638 | + foreach ( (array) $stocks as $value ) { | |
| 3639 | + $status[] = (string) $value; | |
| 3640 | + } | |
| 3641 | + | |
| 3642 | + return array_count_values( $status ); | |
| 3643 | +} | |
| 3644 | + | |
| 3645 | +function usces_get_deco_order_id( $order_id ) { | |
| 3646 | + global $usces; | |
| 3647 | + | |
| 3648 | + $dec_order_id = $usces->get_order_meta_value( 'dec_order_id', $order_id ); | |
| 3649 | + if ( ! $dec_order_id ) { | |
| 3650 | + | |
| 3651 | + $options = get_option( 'usces', array() ); | |
| 3652 | + $prefix = $options['system']['dec_orderID_prefix']; | |
| 3653 | + $prefix = apply_filters( 'usces_filter_get_deco_order_id_prefix', $prefix ); | |
| 3654 | + | |
| 3655 | + $dec_order_id = $prefix . usces_make_deco_order_id( $order_id ); | |
| 3656 | + } | |
| 3657 | + | |
| 3658 | + return $dec_order_id; | |
| 3659 | +} | |
| 3660 | + | |
| 3661 | +function usces_make_deco_order_id( $order_id = null ) { | |
| 3662 | + global $wpdb; | |
| 3663 | + | |
| 3664 | + $options = get_option( 'usces', array() ); | |
| 3665 | + | |
| 3666 | + if ( 0 === (int) $options['system']['dec_orderID_flag'] ) { | |
| 3667 | + | |
| 3668 | + if ( ! $order_id ) { | |
| 3669 | + $dec_order_id = str_pad( 0, $options['system']['dec_orderID_digit'], '0', STR_PAD_LEFT ); | |
| 3670 | + } else { | |
| 3671 | + $dec_order_id = str_pad( $order_id, $options['system']['dec_orderID_digit'], '0', STR_PAD_LEFT ); | |
| 3672 | + } | |
| 3673 | + | |
| 3674 | + } else { | |
| 3675 | + | |
| 3676 | + $order_meta = usces_get_tablename( 'usces_order_meta' ); | |
| 3677 | + $verify_time = apply_filters( 'usces_filter_deco_order_id_verify_time', 100 ); | |
| 3678 | + | |
| 3679 | + for ( $olimit = 0; $olimit <= $verify_time; $olimit++ ) { | |
| 3680 | + | |
| 3681 | + $ukey = usces_get_key( $options['system']['dec_orderID_digit'] ); | |
| 3682 | + $ores = $wpdb->get_var( | |
| 3683 | + $wpdb->prepare( | |
| 3684 | + "SELECT meta_key FROM {$order_meta} WHERE meta_key = %s AND meta_value = %s LIMIT 1", | |
| 3685 | + 'dec_order_id', | |
| 3686 | + $ukey | |
| 3687 | + ) | |
| 3688 | + ); | |
| 3689 | + | |
| 3690 | + if ( ! $ores ) { | |
| 3691 | + break; | |
| 3692 | + } | |
| 3693 | + } | |
| 3694 | + | |
| 3695 | + $dec_order_id = $ukey; | |
| 3696 | + } | |
| 3697 | + | |
| 3698 | + $dec_order_id = apply_filters( 'usces_filter_make_deco_order_id', $dec_order_id ); | |
| 3699 | + | |
| 3700 | + return $dec_order_id; | |
| 3701 | +} | |
| 3702 | + | |
| 3703 | +function usces_get_gp_price( $post_id, $p, $quant ) { | |
| 3704 | + global $usces; | |
| 3705 | + | |
| 3706 | + $GpN1 = $usces->getItemGpNum1( $post_id ); | |
| 3707 | + $GpN2 = $usces->getItemGpNum2( $post_id ); | |
| 3708 | + $GpN3 = $usces->getItemGpNum3( $post_id ); | |
| 3709 | + $GpD1 = $usces->getItemGpDis1( $post_id ); | |
| 3710 | + $GpD2 = $usces->getItemGpDis2( $post_id ); | |
| 3711 | + $GpD3 = $usces->getItemGpDis3( $post_id ); | |
| 3712 | + | |
| 3713 | + if ( empty( $GpN1 ) || empty( $GpD1 ) ) { | |
| 3714 | + | |
| 3715 | + $realprice = $p; | |
| 3716 | + | |
| 3717 | + } elseif ( ( ! empty( $GpN1 ) && ! empty( $GpD1 ) ) && ( empty( $GpN2 ) || empty( $GpD2 ) ) ) { | |
| 3718 | + | |
| 3719 | + if ( $quant >= $GpN1 ) { | |
| 3720 | + $realprice = wel_gp_price_discount( $p, $GpD1 ); | |
| 3721 | + } else { | |
| 3722 | + $realprice = $p; | |
| 3723 | + } | |
| 3724 | + | |
| 3725 | + } elseif ( ( ! empty( $GpN1 ) && ! empty( $GpD1 ) ) && ( ! empty( $GpN2 ) && ! empty( $GpD2 ) ) && ( empty( $GpN3 ) || empty( $GpD3 ) ) ) { | |
| 3726 | + | |
| 3727 | + if ( $quant >= $GpN2 ) { | |
| 3728 | + $realprice = wel_gp_price_discount( $p, $GpD2 ); | |
| 3729 | + } elseif ( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 3730 | + $realprice = wel_gp_price_discount( $p, $GpD1 ); | |
| 3731 | + } else { | |
| 3732 | + $realprice = $p; | |
| 3733 | + } | |
| 3734 | + | |
| 3735 | + } elseif ( ( ! empty( $GpN1 ) && ! empty( $GpD1 ) ) && ( ! empty( $GpN2 ) && ! empty( $GpD2 ) ) && ( ! empty( $GpN3 ) && ! empty( $GpD3 ) ) ) { | |
| 3736 | + | |
| 3737 | + if ( $quant >= $GpN3 ) { | |
| 3738 | + $realprice = wel_gp_price_discount( $p, $GpD3 ); | |
| 3739 | + } elseif ( $quant >= $GpN2 && $quant < $GpN3 ) { | |
| 3740 | + $realprice = wel_gp_price_discount( $p, $GpD2 ); | |
| 3741 | + } elseif ( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 3742 | + $realprice = wel_gp_price_discount( $p, $GpD1 ); | |
| 3743 | + } else { | |
| 3744 | + $realprice = $p; | |
| 3745 | + } | |
| 3746 | + | |
| 3747 | + } else { | |
| 3748 | + $realprice = $p; | |
| 3749 | + } | |
| 3750 | + | |
| 3751 | + $realprice = apply_filters( 'usces_filter_get_gp_price', $realprice, $post_id, $p, $quant ); | |
| 3752 | + return $realprice; | |
| 3753 | +} | |
| 3754 | + | |
| 3755 | +function usces_is_complete_settlement( $payment_name, $status = '' ) { | |
| 3756 | + $complete = false; | |
| 3757 | + $options = get_option( 'usces', array() ); | |
| 3758 | + if ( 0 === (int) $options['point_assign'] ) { | |
| 3759 | + $complete = true; | |
| 3760 | + } else { | |
| 3761 | + $payments = usces_get_system_option( 'usces_payment_method', 'name' ); | |
| 3762 | + if ( isset( $payments[ $payment_name ]['settlement'] ) ) { | |
| 3763 | + switch( $payments[ $payment_name ]['settlement'] ) { | |
| 3764 | + case 'acting': | |
| 3765 | + if ( false !== strpos( $status, 'pending' ) ) { | |
| 3766 | + break; | |
| 3767 | + } | |
| 3768 | + case 'acting_remise_card': | |
| 3769 | + case 'acting_jpayment_card': | |
| 3770 | + case 'acting_paypal_ec': | |
| 3771 | + case 'acting_telecom_card': | |
| 3772 | + case 'acting_digitalcheck_card': | |
| 3773 | + case 'acting_mizuho_card': | |
| 3774 | + case 'acting_anotherlane_card': | |
| 3775 | + case 'acting_veritrans_card': | |
| 3776 | + case 'COD': | |
| 3777 | + $complete = true; | |
| 3778 | + } | |
| 3779 | + } | |
| 3780 | + } | |
| 3781 | + $complete = apply_filters( 'usces_filter_is_complete_settlement', $complete, $payment_name, $status ); | |
| 3782 | + return $complete; | |
| 3783 | +} | |
| 3784 | + | |
| 3785 | +function usces_action_acting_getpoint( $order_id, $add = true ) { | |
| 3786 | + global $usces, $wpdb; | |
| 3787 | + | |
| 3788 | + if ( ! apply_filters( 'usces_action_acting_getpoint_switch', true, $order_id, $add ) ) { | |
| 3789 | + return; | |
| 3790 | + } | |
| 3791 | + | |
| 3792 | + $options = get_option( 'usces', array() ); | |
| 3793 | + if ( 0 !== (int) $options['point_assign'] ) { | |
| 3794 | + if ( 'activate' === $usces->options['membersystem_state'] && 'activate' === $usces->options['membersystem_point'] ) { | |
| 3795 | + $table_name = $wpdb->prefix . 'usces_order'; | |
| 3796 | + $mquery = $wpdb->prepare( "SELECT mem_id, order_getpoint FROM $table_name WHERE ID = %d", $order_id ); | |
| 3797 | + $values = $wpdb->get_row( $mquery, ARRAY_A ); | |
| 3798 | + $mem_id = $values['mem_id']; | |
| 3799 | + $getpoint = $values['order_getpoint']; | |
| 3800 | + | |
| 3801 | + if ( ! empty( $mem_id ) && 0 < $getpoint ) { | |
| 3802 | + $calc = ( $add ) ? '+' : '-'; | |
| 3803 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 3804 | + $mquery = $wpdb->prepare( "UPDATE $member_table_name SET mem_point = (mem_point ".$calc." %d) WHERE ID = %d", $getpoint, $mem_id ); | |
| 3805 | + $wpdb->query( $mquery ); | |
| 3806 | + | |
| 3807 | + if ( ! empty( $_SESSION['usces_member']['point'] ) ) { | |
| 3808 | + $mquery = $wpdb->prepare( "SELECT mem_point FROM $member_table_name WHERE ID = %d", $mem_id ); | |
| 3809 | + $point = $wpdb->get_var( $mquery ); | |
| 3810 | + $_SESSION['usces_member']['point'] = $point; | |
| 3811 | + } | |
| 3812 | + } | |
| 3813 | + } | |
| 3814 | + } | |
| 3815 | + do_action( 'usces_action_acting_getpoint', $order_id, $add ); | |
| 3816 | +} | |
| 3817 | + | |
| 3818 | +function usces_restore_point( $mem_id, $point ) { | |
| 3819 | + global $wpdb; | |
| 3820 | + | |
| 3821 | + if ( ! apply_filters( 'usces_action_restore_point_switch', true, $mem_id, $point ) ) { | |
| 3822 | + return; | |
| 3823 | + } | |
| 3824 | + | |
| 3825 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 3826 | + $query = $wpdb->prepare( "UPDATE $member_table_name SET mem_point = (mem_point - %d) WHERE ID = %d", $point, $mem_id ); | |
| 3827 | + $wpdb->query( $query ); | |
| 3828 | +} | |
| 3829 | + | |
| 3830 | +function usces_set_free_csv( $customer ) { | |
| 3831 | + $free_csv = ""; | |
| 3832 | + if ( ! WCUtils::is_blank( $customer['name1'] ) ) { | |
| 3833 | + $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']; | |
| 3834 | + $free_csv = base64_encode( $free_csv ); | |
| 3835 | + } | |
| 3836 | + return $free_csv; | |
| 3837 | +} | |
| 3838 | + | |
| 3839 | +function usces_get_itemopt_filed( $post_id, $sku, $opt ) { | |
| 3840 | + global $usces; | |
| 3841 | + | |
| 3842 | + $sku = urlencode( $sku ); | |
| 3843 | + $optcode = urlencode( $opt['name'] ); | |
| 3844 | + $name = $opt['name']; | |
| 3845 | + $means = (int) $opt['means']; | |
| 3846 | + $essential = (int) $opt['essential']; | |
| 3847 | + $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][ $post_id ][ $sku ][ $optcode ] ) ? $_SESSION['usces_singleitem']['itemOption'][ $post_id ][ $sku ][ $optcode ] : NULL; | |
| 3848 | + $opt['value'] = usces_change_line_break( $opt['value'] ); | |
| 3849 | + | |
| 3850 | + $html = ''; | |
| 3851 | + switch ( $means ) { | |
| 3852 | + case 0: //Single-select. | |
| 3853 | + case 1: //Multi-select. | |
| 3854 | + $selects = explode( "\n", $opt['value'] ); | |
| 3855 | + $multiple = ( 0 === $means ) ? '' : ' multiple'; | |
| 3856 | + $multiple_array = ( 0 === $means ) ? '' : '[]'; | |
| 3857 | + $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"; | |
| 3858 | + if ( 1 === $essential ) { | |
| 3859 | + if ( '#NONE#' === $session_value || NULL === $session_value ) { | |
| 3860 | + $selected = ' selected="selected"'; | |
| 3861 | + } else { | |
| 3862 | + $selected = ''; | |
| 3863 | + } | |
| 3864 | + $html .= "\t<option value='#NONE#'{$selected}>" . __( 'Choose', 'usces' ) . "</option>\n"; | |
| 3865 | + } | |
| 3866 | + $i = 0; | |
| 3867 | + foreach ( $selects as $v ) { | |
| 3868 | + if ( ( 0 === $i && 0 === $essential && NULL === $session_value ) || esc_attr( $v ) == $session_value ) { | |
| 3869 | + $selected = ' selected="selected"'; | |
| 3870 | + } else { | |
| 3871 | + $selected = ''; | |
| 3872 | + } | |
| 3873 | + $html .= "\t<option value='" . esc_attr( $v ) . "'{$selected}>" . esc_html( $v ) . "</option>\n"; | |
| 3874 | + $i++; | |
| 3875 | + } | |
| 3876 | + $html .= "</select>\n"; | |
| 3877 | + break; | |
| 3878 | + case 2: //Text. | |
| 3879 | + $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"; | |
| 3880 | + break; | |
| 3881 | + case 3: //Radio-button. | |
| 3882 | + $selects = explode( "\n", $opt['value'] ); | |
| 3883 | + $i = 0; | |
| 3884 | + foreach ( (array) $selects as $v ) { | |
| 3885 | + $v = trim( $v ); | |
| 3886 | + if ( $v === $session_value ) { | |
| 3887 | + $checked = ' checked="checked"'; | |
| 3888 | + } else { | |
| 3889 | + $checked = ''; | |
| 3890 | + } | |
| 3891 | + $html .= "\t<label for='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_radio_label'><input name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_radio' type='radio' value='" . urlencode( $v ) . "'{$checked} onKeyDown=\"if (event.keyCode == 13) {return false;}\">" . esc_html( $v ) . "</label>\n"; | |
| 3892 | + $i++; | |
| 3893 | + } | |
| 3894 | + break; | |
| 3895 | + case 4: //Check-box. | |
| 3896 | + $selects = explode( "\n", $opt['value'] ); | |
| 3897 | + $session_arr = is_array( $session_value ) ? $session_value : array(); | |
| 3898 | + $i = 0; | |
| 3899 | + foreach ( (array) $selects as $v ) { | |
| 3900 | + $v = trim( $v ); | |
| 3901 | + if ( in_array( $v, $session_arr, true ) ) { | |
| 3902 | + $checked = ' checked="checked"'; | |
| 3903 | + } else { | |
| 3904 | + $checked = ''; | |
| 3905 | + } | |
| 3906 | + $html .= "\t<label for='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_checkbox_label'><input name='itemOption[{$post_id}][{$sku}][{$optcode}][]' id='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_checkbox' type='checkbox' value='" . urlencode( $v ) . "'{$checked} onKeyDown=\"if (event.keyCode == 13) {return false;}\">" . esc_html( $v ) . "</label>\n"; | |
| 3907 | + $i++; | |
| 3908 | + } | |
| 3909 | + break; | |
| 3910 | + case 5: //Text-area. | |
| 3911 | + $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr( $session_value ) . "</textarea>\n"; | |
| 3912 | + break; | |
| 3913 | + } | |
| 3914 | + | |
| 3915 | + $html = apply_filters( 'usces_get_itemopt_filed', $html, $post_id, $sku, $opt ); | |
| 3916 | + | |
| 3917 | + return $html; | |
| 3918 | +} | |
| 3919 | + | |
| 3920 | +function usces_delete_order_check( $order_id ) { | |
| 3921 | + $res = apply_filters( 'usces_filter_delete_order_check', true, $order_id ); | |
| 3922 | + return $res; | |
| 3923 | +} | |
| 3924 | + | |
| 3925 | +function usces_delete_member_check( $member_id ) { | |
| 3926 | + $res = apply_filters( 'usces_filter_delete_member_check', true, $member_id ); | |
| 3927 | + return $res; | |
| 3928 | +} | |
| 3929 | + | |
| 3930 | +function usces_delete_member_check_front( $member_id ) { | |
| 3931 | + $res = apply_filters( 'usces_filter_delete_member_check_front', true, $member_id ); | |
| 3932 | + return $res; | |
| 3933 | +} | |
| 3934 | + | |
| 3935 | +function usces_itempage_admin_bar() { | |
| 3936 | + global $wp_admin_bar, $post; | |
| 3937 | + | |
| 3938 | + if ( is_single() && usces_is_item() ) { | |
| 3939 | + $wp_admin_bar->remove_menu( 'edit' ); | |
| 3940 | + $ref = urlencode( site_url() . '/wp-admin/admin.php?page=usces_itemedit' ); | |
| 3941 | + $wp_admin_bar->add_menu( array( | |
| 3942 | + 'id' => 'edit', | |
| 3943 | + 'title' => __( 'Edit item', 'usces' ), | |
| 3944 | + 'href' => site_url() . '/wp-admin/admin.php?page=usces_itemedit&action=edit&post=' . $post->ID . '&usces_referer=' . $ref | |
| 3945 | + ) ); | |
| 3946 | + } | |
| 3947 | +} | |
| 3948 | + | |
| 3949 | +function usces_rand( $digit = 10 ) { | |
| 3950 | + $num = str_repeat( '9', $digit ); | |
| 3951 | + $rand = apply_filters( 'usces_filter_rand_value', sprintf( '%0' . $digit . 'd', mt_rand( 1, (int) $num ) ), $num ); | |
| 3952 | + return $rand; | |
| 3953 | +} | |
| 3954 | + | |
| 3955 | +function usces_get_cr_symbol() { | |
| 3956 | + global $usces, $usces_settings; | |
| 3957 | + $cr = $usces->options['system']['currency']; | |
| 3958 | + list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ]; | |
| 3959 | + return $symbol; | |
| 3960 | +} | |
| 3961 | + | |
| 3962 | +function usces_make_option_field( $materials, $cart ) { | |
| 3963 | + extract( $materials ); | |
| 3964 | + /* $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', | |
| 3965 | + 'options', 'advance', 'itemCode', 'itemName', 'cartItemName', | |
| 3966 | + 'skuPrice', 'stock', 'red', 'pictid', 'order_id' ); | |
| 3967 | + */ | |
| 3968 | + $option_fields = usces_get_opts( $post_id, 'sort' ); | |
| 3969 | + $field = '<div>' . "\n"; | |
| 3970 | + $field .= '<ul>' . "\n"; | |
| 3971 | + | |
| 3972 | + foreach ( (array) $option_fields as $field_data ) { | |
| 3973 | + $field .= '<li>' . usces_get_itemOption( $field_data, $materials, $label = '#default#' ) . '</li>' . "\n"; | |
| 3974 | + foreach ( (array) $options as $op_key => $option ) { | |
| 3975 | + if ( $option['meta_key'] === $field_data['name'] ) { | |
| 3976 | + $options[ $op_key ]['flag'] = 1; | |
| 3977 | + } | |
| 3978 | + } | |
| 3979 | + } | |
| 3980 | + | |
| 3981 | + foreach ( (array) $options as $option ) { | |
| 3982 | + if ( ! isset( $option['flag'] ) ) { | |
| 3983 | + $meta_value = wel_safe_maybe_unserialize( $option['meta_value'] ); | |
| 3984 | + if ( ! is_array( $meta_value ) ) { | |
| 3985 | + $meta_value = (array) $meta_value; | |
| 3986 | + } | |
| 3987 | + $value_str = ''; | |
| 3988 | + foreach ( $meta_value as $mv ) { | |
| 3989 | + $value_str .= $mv . ' & '; | |
| 3990 | + } | |
| 3991 | + $value_str = trim( $value_str, ' & ' ); | |
| 3992 | + $field .= '<li>' . esc_html( $option['meta_key'] ) . ' : ' . esc_html( $value_str ) . '</li>' . "\n"; | |
| 3993 | + } | |
| 3994 | + } | |
| 3995 | + | |
| 3996 | + $field .= '</ul>' . "\n"; | |
| 3997 | + $field .= '</div>' . "\n"; | |
| 3998 | + | |
| 3999 | + echo apply_filters( 'usces_filter_order_edit_form_row', $field, $cart, $materials ); | |
| 4000 | +} | |
| 4001 | + | |
| 4002 | +function usces_get_itemOption( $field_data, $materials, $label = '#default#' ) { | |
| 4003 | + global $usces; | |
| 4004 | + | |
| 4005 | + extract( $materials ); | |
| 4006 | + /* $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', | |
| 4007 | + 'options', 'advance', 'itemCode', 'itemName', 'cartItemName', | |
| 4008 | + 'skuPrice', 'stock', 'red', 'pictid', 'order_id' ); | |
| 4009 | + */ | |
| 4010 | + $opt_value = array(); | |
| 4011 | + foreach ( $options as $opt_value ) { | |
| 4012 | + if ( $field_data['name'] === $opt_value['meta_key'] ) { | |
| 4013 | + $cartmeta_id = $opt_value['cartmeta_id']; | |
| 4014 | + $name = $opt_value['meta_key']; | |
| 4015 | + $value = $opt_value['meta_value']; | |
| 4016 | + $means = (int) $field_data['means']; | |
| 4017 | + $essential = (int) $field_data['essential']; | |
| 4018 | + break; | |
| 4019 | + } | |
| 4020 | + } | |
| 4021 | + if ( ! $opt_value ) { | |
| 4022 | + return ''; | |
| 4023 | + } | |
| 4024 | + if ( empty( $name ) ) { | |
| 4025 | + return ''; | |
| 4026 | + } | |
| 4027 | + | |
| 4028 | + if ( '#default#' === $label ) { | |
| 4029 | + $label = $name; | |
| 4030 | + } | |
| 4031 | + | |
| 4032 | + $field_data['value'] = usces_change_line_break( $field_data['value'] ); | |
| 4033 | + | |
| 4034 | + $html = ''; | |
| 4035 | + $name = esc_attr( $name ); | |
| 4036 | + $label = esc_attr( $label ); | |
| 4037 | + $html .= '<label for="itemOption[' . $cartmeta_id . ']" class="iopt_label">' . $label . '</label>' . "\n"; | |
| 4038 | + switch ( $means ) { | |
| 4039 | + case 0: //Single-select. | |
| 4040 | + $selects = explode( "\n", $field_data['value'] ); | |
| 4041 | + $value = wel_safe_maybe_unserialize( $value ); | |
| 4042 | + $check_value = array(); | |
| 4043 | + if ( ! is_array( $value ) ) { | |
| 4044 | + $check_value = (array) $value; | |
| 4045 | + } | |
| 4046 | + $diff = array_diff( $check_value, $selects ); | |
| 4047 | + | |
| 4048 | + if ( ! empty( $diff ) ) { | |
| 4049 | + | |
| 4050 | + $value_str = ''; | |
| 4051 | + foreach ( $check_value as $mv ) { | |
| 4052 | + $value_str .= $mv . ' & '; | |
| 4053 | + } | |
| 4054 | + $value_str = trim( $value_str, ' & ' ); | |
| 4055 | + $html .= '<span>:' . esc_html( $value_str ) . '</span>' . "\n"; | |
| 4056 | + | |
| 4057 | + } else { | |
| 4058 | + $html .= '<select name="itemOption[' . $cartmeta_id . ']" id="itemOption[' . $cartmeta_id . ']" class="iopt_select" onKeyDown="if (event.keyCode == 13) {return false;}">' . "\n"; | |
| 4059 | + if ( 1 === $essential ) { | |
| 4060 | + if ( '#NONE#' === $value || NULL === $value ) { | |
| 4061 | + $selected = ' selected="selected"'; | |
| 4062 | + } else { | |
| 4063 | + $selected = ''; | |
| 4064 | + } | |
| 4065 | + $html .= '<option value="#NONE#"' . $selected . '>' . __( 'Choose', 'usces' ) . '</option>' . "\n"; | |
| 4066 | + } | |
| 4067 | + $i = 0; | |
| 4068 | + foreach ( $selects as $v ) { | |
| 4069 | + $v = trim( $v ); | |
| 4070 | + if ( ( 0 === $i && 0 === $essential && NULL === $value ) || esc_attr( $v ) == esc_attr( $value ) ) { | |
| 4071 | + $selected = ' selected="selected"'; | |
| 4072 | + } else { | |
| 4073 | + $selected = ''; | |
| 4074 | + } | |
| 4075 | + $html .= '<option value="' . esc_attr( $v ) . '"' . $selected . '>' . esc_attr( $v ) . '</option>' . "\n"; | |
| 4076 | + $i++; | |
| 4077 | + } | |
| 4078 | + $html .= '</select>' . "\n"; | |
| 4079 | + } | |
| 4080 | + break; | |
| 4081 | + case 1: //Multi-select. | |
| 4082 | + $selects = explode( "\n", $field_data['value'] ); | |
| 4083 | + $value = wel_safe_maybe_unserialize( $value ); | |
| 4084 | + if ( ! is_array( $value ) ) { | |
| 4085 | + $value = (array) $value; | |
| 4086 | + } | |
| 4087 | + $diff = array_diff( (array) $value, $selects ); | |
| 4088 | + | |
| 4089 | + if ( ! empty( $diff ) ) { | |
| 4090 | + | |
| 4091 | + $value_str = ''; | |
| 4092 | + foreach ( $value as $mv ) { | |
| 4093 | + $value_str .= $mv . ' & '; | |
| 4094 | + } | |
| 4095 | + $value_str = trim( $value_str, ' & ' ); | |
| 4096 | + $html .= '<span>:' . esc_html( $value_str ) . '</span>' . "\n"; | |
| 4097 | + | |
| 4098 | + } else { | |
| 4099 | + $html .= '<select name="itemOption[' . $cartmeta_id . '][]" id="itemOption[' . $cartmeta_id . ']" class="iopt_select" multiple onKeyDown="if (event.keyCode == 13) {return false;}">' . "\n"; | |
| 4100 | + if ( 1 === $essential ) { | |
| 4101 | + if ( '#NONE#' === $value || NULL === $value ) { | |
| 4102 | + $selected = ' selected="selected"'; | |
| 4103 | + } else { | |
| 4104 | + $selected = ''; | |
| 4105 | + } | |
| 4106 | + $html .= '<option value="#NONE#"' . $selected . '>' . __( 'Choose', 'usces' ) . '</option>' . "\n"; | |
| 4107 | + } | |
| 4108 | + $i = 0; | |
| 4109 | + | |
| 4110 | + $value_arr = wel_safe_maybe_unserialize( $value ); | |
| 4111 | + | |
| 4112 | + foreach ( $selects as $v ) { | |
| 4113 | + $v = trim( $v ); | |
| 4114 | + $opval = urlencode( $v ); | |
| 4115 | + $val_str = isset( $value_arr[ $opval ] ) ? $value_arr[ $opval ] : ''; | |
| 4116 | + if ( $v == $val_str ) { | |
| 4117 | + $selected = ' selected="selected"'; | |
| 4118 | + } else { | |
| 4119 | + $selected = ''; | |
| 4120 | + } | |
| 4121 | + $html .= '<option value="' . esc_attr( $opval ) . '"' . $selected . '>' . esc_attr( $v ) . '</option>' . "\n"; | |
| 4122 | + $i++; | |
| 4123 | + } | |
| 4124 | + $html .= '</select>' . "\n"; | |
| 4125 | + } | |
| 4126 | + break; | |
| 4127 | + case 2: //Text. | |
| 4128 | + $html .= '<input name="itemOption[' . $cartmeta_id . ']" type="text" id="itemOption[' . $cartmeta_id . ']" class="iopt_text" onKeyDown="if (event.keyCode == 13) {return false;}" value="' . esc_attr( $value ) . '" />' . "\n"; | |
| 4129 | + break; | |
| 4130 | + case 3: //Radio-button. | |
| 4131 | + $selects = explode( "\n", $field_data['value'] ); | |
| 4132 | + $value = wel_safe_maybe_unserialize( $value ); | |
| 4133 | + if ( ! is_array( $value ) ) { | |
| 4134 | + $value = (array) $value; | |
| 4135 | + } | |
| 4136 | + $diff = array_diff( $value, $selects ); | |
| 4137 | + | |
| 4138 | + if ( ! empty( $diff ) && ! empty( $diff[0] ) ) { | |
| 4139 | + | |
| 4140 | + $value_str = ''; | |
| 4141 | + foreach ( $value as $mv ) { | |
| 4142 | + $value_str .= $mv . ' & '; | |
| 4143 | + } | |
| 4144 | + $value_str = trim( $value_str, ' & ' ); | |
| 4145 | + $html .= '<span>:' . esc_html( $value_str ) . '</span>' . "\n"; | |
| 4146 | + | |
| 4147 | + } else { | |
| 4148 | + $i = 0; | |
| 4149 | + foreach ( $selects as $v ) { | |
| 4150 | + $v = trim( $v ); | |
| 4151 | + $checked = ''; | |
| 4152 | + foreach ( $value as $ov ) { | |
| 4153 | + if ( $v == $ov ) { | |
| 4154 | + $checked = ' checked="checked"'; | |
| 4155 | + break; | |
| 4156 | + } | |
| 4157 | + } | |
| 4158 | + $html .= '<label for="itemOption[' . $cartmeta_id . ']' . $i . '" class="iopt_radio_label"><input name="itemOption[' . $cartmeta_id . ']" id="itemOption[' . $cartmeta_id . ']' . $i . '" class="iopt_radio" type="radio" value="' . urlencode( $v ) . '"' . $checked . ' onKeyDown="if (event.keyCode == 13) {return false;}">' . esc_html( $v ) . "</label>\n"; | |
| 4159 | + $i++; | |
| 4160 | + } | |
| 4161 | + } | |
| 4162 | + break; | |
| 4163 | + case 4: //Check-box. | |
| 4164 | + $selects = explode( "\n", $field_data['value'] ); | |
| 4165 | + $value = wel_safe_maybe_unserialize( $value ); | |
| 4166 | + if ( ! is_array( $value ) ) { | |
| 4167 | + $value = (array) $value; | |
| 4168 | + } | |
| 4169 | + $diff = array_diff( (array) $value, $selects ); | |
| 4170 | + | |
| 4171 | + if ( isset( $diff[0] ) && ! empty( $diff[0] ) ) { | |
| 4172 | + | |
| 4173 | + $value_str = ''; | |
| 4174 | + foreach ( $value as $mv ) { | |
| 4175 | + $value_str .= $mv . ' & '; | |
| 4176 | + } | |
| 4177 | + $value_str = trim( $value_str, ' & ' ); | |
| 4178 | + $html .= '<span>:' . esc_html( $value_str ) . '</span>' . "\n"; | |
| 4179 | + | |
| 4180 | + } else { | |
| 4181 | + $i = 0; | |
| 4182 | + foreach ( $selects as $v ) { | |
| 4183 | + $v = trim( $v ); | |
| 4184 | + $opval = urlencode( $v ); | |
| 4185 | + $val_str = isset( $value_arr[ $opval ] ) ? $value_arr[ $opval ] : ''; | |
| 4186 | + if ( in_array( $v, (array) $value ) ) { | |
| 4187 | + $checked = ' checked="checked"'; | |
| 4188 | + } else { | |
| 4189 | + $checked = ''; | |
| 4190 | + } | |
| 4191 | + $html .= '<label for="itemOption[' . $cartmeta_id . ']' . $i . '" class="iopt_checkbox_label"><input name="itemOption[' . $cartmeta_id . '][]" id="itemOption[' . $cartmeta_id . ']' . $i . '" class="iopt_checkbox" type="checkbox" value="' . urlencode( $v ) . '"' . $checked . ' onKeyDown="if (event.keyCode == 13) {return false;}">' . esc_html( $v ) . "</label>\n"; | |
| 4192 | + $i++; | |
| 4193 | + } | |
| 4194 | + } | |
| 4195 | + break; | |
| 4196 | + case 5: //Text-area. | |
| 4197 | + $html .= '<textarea name="itemOption[' . $cartmeta_id . ']" id="itemOption[' . $cartmeta_id . ']" class="iopt_textarea">' . esc_attr( $value ) . '</textarea>' . "\n"; | |
| 4198 | + break; | |
| 4199 | + } | |
| 4200 | + | |
| 4201 | + $html = apply_filters( 'usces_filter_get_itemOption', $html, $opt_value, $post_id ); | |
| 4202 | + | |
| 4203 | + return $html; | |
| 4204 | +} | |
| 4205 | + | |
| 4206 | +function usces_update_ordercart_meta_value( $cartmeta_id, $value ) { | |
| 4207 | + global $wpdb; | |
| 4208 | + | |
| 4209 | + if ( ! $cartmeta_id ) { | |
| 4210 | + return; | |
| 4211 | + } | |
| 4212 | + | |
| 4213 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4214 | + | |
| 4215 | + $query = $wpdb->prepare( "UPDATE $ordercart_meta_table SET meta_value = %s WHERE cartmeta_id = %d", $value, $cartmeta_id ); | |
| 4216 | + $res = $wpdb->query( $query ); | |
| 4217 | + return $res; | |
| 4218 | +} | |
| 4219 | + | |
| 4220 | +function usces_set_ordercart_meta_value( $type, $cart_id, $key, $value ) { | |
| 4221 | + global $wpdb; | |
| 4222 | + | |
| 4223 | + if ( ! $type || ! $cart_id || ! $key || ! $value ) { | |
| 4224 | + return; | |
| 4225 | + } | |
| 4226 | + | |
| 4227 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4228 | + | |
| 4229 | + $query = $wpdb->prepare( | |
| 4230 | + "SELECT cartmeta_id FROM $ordercart_meta_table | |
| 4231 | + WHERE cart_id = %d AND meta_type = %s AND meta_key = %s ", | |
| 4232 | + $cart_id, $type, $key | |
| 4233 | + ); | |
| 4234 | + $res1 = $wpdb->get_var( $query ); | |
| 4235 | + | |
| 4236 | + if ( $res1 ) { | |
| 4237 | + $query = $wpdb->prepare( | |
| 4238 | + "UPDATE $ordercart_meta_table SET meta_value = %s | |
| 4239 | + WHERE cart_id = %d AND meta_type = %s AND meta_key = %s", | |
| 4240 | + $value, $cart_id, $type, $key | |
| 4241 | + ); | |
| 4242 | + $res2 = $wpdb->query( $query ); | |
| 4243 | + } else { | |
| 4244 | + $query = $wpdb->prepare( | |
| 4245 | + "INSERT INTO $ordercart_meta_table ( cart_id, meta_type, meta_key, meta_value ) VALUES ( %d, %s, %s, %s )", | |
| 4246 | + $cart_id, $type, $key, $value | |
| 4247 | + ); | |
| 4248 | + $res2 = $wpdb->query( $query ); | |
| 4249 | + } | |
| 4250 | + return $res2; | |
| 4251 | +} | |
| 4252 | + | |
| 4253 | +function usces_get_ordercart_meta( $type, $cart_id, $key = '' ) { | |
| 4254 | + global $wpdb; | |
| 4255 | + | |
| 4256 | + if ( ! $cart_id ) { | |
| 4257 | + return; | |
| 4258 | + } | |
| 4259 | + | |
| 4260 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4261 | + | |
| 4262 | + if ( '' !== $key ) { | |
| 4263 | + $query = $wpdb->prepare( | |
| 4264 | + "SELECT cartmeta_id, meta_key, meta_value | |
| 4265 | + FROM $ordercart_meta_table | |
| 4266 | + WHERE cart_id = %d AND meta_type = %s AND meta_key = %s | |
| 4267 | + ORDER BY cartmeta_id", | |
| 4268 | + $cart_id, $type, $key | |
| 4269 | + ); | |
| 4270 | + } else { | |
| 4271 | + $query = $wpdb->prepare( | |
| 4272 | + "SELECT cartmeta_id, meta_key, meta_value | |
| 4273 | + FROM $ordercart_meta_table | |
| 4274 | + WHERE cart_id = %d AND meta_type = %s | |
| 4275 | + ORDER BY cartmeta_id", | |
| 4276 | + $cart_id, $type | |
| 4277 | + ); | |
| 4278 | + } | |
| 4279 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 4280 | + return $res; | |
| 4281 | +} | |
| 4282 | + | |
| 4283 | +function usces_add_ordercart_meta_value( $type, $cart_id, $key, $value ) { | |
| 4284 | + global $wpdb; | |
| 4285 | + | |
| 4286 | + if ( ! $type || ! $cart_id || ! $key || ! $value ) { | |
| 4287 | + return; | |
| 4288 | + } | |
| 4289 | + | |
| 4290 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4291 | + | |
| 4292 | + $query = $wpdb->prepare( | |
| 4293 | + "INSERT INTO $ordercart_meta_table | |
| 4294 | + ( cart_id, meta_type, meta_key, meta_value ) VALUES ( %d, %s, %s, %s )", | |
| 4295 | + $cart_id, $type, $key, $value | |
| 4296 | + ); | |
| 4297 | + $res = $wpdb->query( $query ); | |
| 4298 | + return $res; | |
| 4299 | +} | |
| 4300 | + | |
| 4301 | +function usces_get_ordercart_meta_value( $type, $cart_id, $key = '' ) { | |
| 4302 | + global $wpdb; | |
| 4303 | + | |
| 4304 | + if ( ! $cart_id ) { | |
| 4305 | + return; | |
| 4306 | + } | |
| 4307 | + | |
| 4308 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4309 | + | |
| 4310 | + if ( '' !== $key ) { | |
| 4311 | + $query = $wpdb->prepare( | |
| 4312 | + "SELECT meta_value | |
| 4313 | + FROM $ordercart_meta_table | |
| 4314 | + WHERE cart_id = %d AND meta_type = %s AND meta_key = %s | |
| 4315 | + ORDER BY cartmeta_id", | |
| 4316 | + $cart_id, $type, $key | |
| 4317 | + ); | |
| 4318 | + } else { | |
| 4319 | + $query = $wpdb->prepare( | |
| 4320 | + "SELECT meta_value | |
| 4321 | + FROM $ordercart_meta_table | |
| 4322 | + WHERE cart_id = %d AND meta_type = %s | |
| 4323 | + ORDER BY cartmeta_id", | |
| 4324 | + $cart_id, $type | |
| 4325 | + ); | |
| 4326 | + } | |
| 4327 | + $res = $wpdb->get_var( $query ); | |
| 4328 | + return $res; | |
| 4329 | +} | |
| 4330 | + | |
| 4331 | +function usces_get_ordercart_meta_by_id( $cartmeta_id ) { | |
| 4332 | + global $wpdb; | |
| 4333 | + | |
| 4334 | + if ( ! $cartmeta_id ) { | |
| 4335 | + return; | |
| 4336 | + } | |
| 4337 | + | |
| 4338 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4339 | + | |
| 4340 | + $query = $wpdb->prepare( "SELECT * FROM $ordercart_meta_table WHERE cartmeta_id = %d", $cartmeta_id ); | |
| 4341 | + $res = $wpdb->get_row( $query, ARRAY_A ); | |
| 4342 | + return $res; | |
| 4343 | +} | |
| 4344 | + | |
| 4345 | +function usces_get_post_id_by_cartmeta_id( $cartmeta_id ) { | |
| 4346 | + global $wpdb; | |
| 4347 | + | |
| 4348 | + if ( ! $cartmeta_id ) { | |
| 4349 | + return 0; | |
| 4350 | + } | |
| 4351 | + | |
| 4352 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4353 | + $ordercart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 4354 | + | |
| 4355 | + $query = $wpdb->prepare( "SELECT cart_id FROM $ordercart_meta_table WHERE cartmeta_id = %d", $cartmeta_id ); | |
| 4356 | + $cart_id = $wpdb->get_var( $query ); | |
| 4357 | + if ( ! $cartmeta_id ) { | |
| 4358 | + return 0; | |
| 4359 | + } | |
| 4360 | + | |
| 4361 | + $query = $wpdb->prepare( "SELECT post_id FROM $ordercart_table WHERE cart_id = %d", $cart_id ); | |
| 4362 | + $post_id = $wpdb->get_var( $query ); | |
| 4363 | + | |
| 4364 | + return $post_id; | |
| 4365 | +} | |
| 4366 | + | |
| 4367 | +function usces_delete_ordercart_meta_by_id( $cartmeta_id ) { | |
| 4368 | + global $wpdb; | |
| 4369 | + | |
| 4370 | + if ( ! $cartmeta_id ) { | |
| 4371 | + return; | |
| 4372 | + } | |
| 4373 | + | |
| 4374 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 4375 | + | |
| 4376 | + $query = $wpdb->prepare( "DELETE FROM $ordercart_meta_table WHERE cartmeta_id = %d", $cartmeta_id ); | |
| 4377 | + $res = $wpdb->query( $query ); | |
| 4378 | + return $res; | |
| 4379 | +} | |
| 4380 | + | |
| 4381 | +function usces_make_advance_value( $advance, $cart_row ) { | |
| 4382 | + $value = ''; | |
| 4383 | + $advance_value = array(); | |
| 4384 | + | |
| 4385 | + foreach ( $advance as $row ) { | |
| 4386 | + $advance_value[] = array( $row['meta_key'] => $row['meta_value'] ); | |
| 4387 | + } | |
| 4388 | + $value = apply_filters( 'usces_filter_order_edit_form_row_advance_value', serialize( $advance_value ), $advance, $cart_row ); | |
| 4389 | + return $value; | |
| 4390 | +} | |
| 4391 | + | |
| 4392 | +function usces_get_ordercart_row( $order_id, $cart = array() ) { | |
| 4393 | + global $usces; | |
| 4394 | + | |
| 4395 | + if ( empty( $cart ) ) { | |
| 4396 | + $cart = usces_get_ordercartdata( $order_id ); | |
| 4397 | + } | |
| 4398 | + $reduced_taxrate = usces_is_reduced_taxrate( $order_id ); | |
| 4399 | + if ( $reduced_taxrate ) { | |
| 4400 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 4401 | + } | |
| 4402 | + | |
| 4403 | + ob_start(); | |
| 4404 | + foreach ( $cart as $i => $cart_row ) { | |
| 4405 | + $ordercart_id = $cart_row['cart_id']; | |
| 4406 | + $post_id = $cart_row['post_id']; | |
| 4407 | + $sku = $cart_row['sku']; | |
| 4408 | + $sku_code = $cart_row['sku_code']; | |
| 4409 | + $quantity = $cart_row['quantity']; | |
| 4410 | + $options = usces_get_ordercart_meta( 'option', $ordercart_id ); | |
| 4411 | + $advance = usces_get_ordercart_meta( 'advance', $ordercart_id ); | |
| 4412 | + $applicable_taxrate = ( $reduced_taxrate ) ? $usces_tax->get_ordercart_applicable_taxrate( $ordercart_id, $post_id, $sku_code ) : ''; | |
| 4413 | + if ( 'reduced' === $applicable_taxrate ) { | |
| 4414 | + $reduced_taxrate_mark = '<span class="reduced_taxrate_mark">' . $usces_tax->reduced_taxrate_mark.'</span>'; | |
| 4415 | + } else { | |
| 4416 | + $reduced_taxrate_mark = ''; | |
| 4417 | + } | |
| 4418 | + $itemCode = $cart_row['item_code']; | |
| 4419 | + $itemName = $cart_row['item_name']; | |
| 4420 | + $cartItemName = $usces->getCartItemName_byOrder( $cart_row ); | |
| 4421 | + $skuPrice = $cart_row['price']; | |
| 4422 | + $stock = $usces->getItemZaiko( $post_id, $sku_code ); | |
| 4423 | + $stockid = $usces->getItemZaikoStatusId( $post_id, $sku_code ); | |
| 4424 | + $red = ( 1 < $stockid ) ? 'class="signal_red"' : ''; | |
| 4425 | + $pictid = (int) $usces->get_mainpictid( $itemCode ); | |
| 4426 | + $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance', | |
| 4427 | + 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'stock', 'red', 'pictid', 'order_id' ); | |
| 4428 | + $advance_value = usces_make_advance_value( $advance, $cart_row ); | |
| 4429 | + $cart_thumbnail = ( ! empty( $pictid ) ) ? wp_get_attachment_image( $pictid, array( 80, 80 ), true ) : usces_get_attachment_noimage( array( 80, 80 ), $itemCode ); | |
| 4430 | + $cart_thumbnail = apply_filters( 'usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row ); | |
| 4431 | + $index_column = apply_filters( 'usces_filter_admin_cart_index', ( $i + 1 ), $materials ); | |
| 4432 | + $post_status = get_post_status( $post_id ); | |
| 4433 | + if ( $post_status && in_array( $post_status, array( 'publish', 'draft', 'private' ), true ) ) { | |
| 4434 | + $item_editpage = admin_url( 'admin.php?page=usces_itemedit&action=edit&post=' . $post_id . '&usces_referer=' . urlencode( site_url() . '/wp-admin/admin.php?page=usces_orderlist&order_action=edit&order_id=' . $order_id ) ); | |
| 4435 | + } else { | |
| 4436 | + $item_editpage = ''; | |
| 4437 | + } | |
| 4438 | + ?> | |
| 4439 | + <tr> | |
| 4440 | + <td><?php wel_esc_script_e( $index_column ); ?></td> | |
| 4441 | + <td><?php wel_esc_script_e( $cart_thumbnail ); ?></td> | |
| 4442 | + <td class="aleft"> | |
| 4443 | + <?php if ( ! empty( $item_editpage ) ) : ?><a href="<?php echo esc_url( $item_editpage ); ?>" title="<?php esc_attr_e( 'To the edit screen for this product.', 'usces' ); ?>" ><?php endif; ?> | |
| 4444 | + <?php echo apply_filters( 'usces_filter_admin_cart_item_name', esc_html( $cartItemName ), $materials ); ?> | |
| 4445 | + <?php if ( ! empty( $item_editpage ) ) : ?></a><?php endif; ?> | |
| 4446 | + <?php wel_esc_script_e( $reduced_taxrate_mark ); ?><?php do_action( 'usces_admin_order_item_name', $order_id, $i ); ?><?php usces_make_option_field( $materials, $cart ); ?></td> | |
| 4447 | + <td><input name="skuPrice[<?php echo esc_attr( $ordercart_id ); ?>]" class="text price" type="text" value="<?php echo esc_attr( usces_crform( $skuPrice, false, false, 'return', false ) ); ?>" /><?php do_action( 'usces_admin_order_cart_after_price', $materials ); ?></td> | |
| 4448 | + <td><input name="quant[<?php echo esc_attr( $ordercart_id ); ?>]" class="text quantity" type="text" value="<?php echo esc_attr( $cart_row['quantity'] ); ?>" /></td> | |
| 4449 | + <td><p id="sub_total[<?php echo esc_attr( $ordercart_id ); ?>]" class="aright"> </p><?php do_action( 'usces_admin_order_cart_after_sub_total', $materials ); ?></td> | |
| 4450 | + <td <?php wel_esc_script_e( $red ); ?>><?php echo esc_html( $stock ); ?></td> | |
| 4451 | + <td> | |
| 4452 | + <input name="postId[<?php echo esc_attr( $ordercart_id ); ?>]" type="hidden" value="<?php echo esc_attr( $post_id ); ?>" /> | |
| 4453 | + <input name="advance[<?php echo esc_attr( $ordercart_id ); ?>]" type="hidden" value="<?php echo esc_attr( $advance_value ); ?>" /> | |
| 4454 | + <?php if ( $reduced_taxrate ) : ?> | |
| 4455 | + <input name="applicable_taxrate[<?php echo esc_attr( $ordercart_id ); ?>]" type="hidden" value="<?php echo esc_attr( $applicable_taxrate ); ?>" /> | |
| 4456 | + <?php endif; ?> | |
| 4457 | + <input name="delButtonAdmin[<?php echo esc_attr( $ordercart_id ); ?>]" class="button delCartButton" type="submit" value="<?php esc_html_e( 'Delete', 'usces' ); ?>" /> | |
| 4458 | + <?php do_action( 'usces_admin_order_cart_button', $order_id, $i ); ?> | |
| 4459 | + </td> | |
| 4460 | + </tr> | |
| 4461 | + <?php | |
| 4462 | + } | |
| 4463 | + $row = ob_get_contents(); | |
| 4464 | + ob_end_clean(); | |
| 4465 | + | |
| 4466 | + return apply_filters( 'usces_filter_get_ordercart_row', $row, $order_id, $cart ); | |
| 4467 | +} | |
| 4468 | + | |
| 4469 | +/** | |
| 4470 | + * Add capabilities to the roles. | |
| 4471 | + * | |
| 4472 | + * return void | |
| 4473 | + */ | |
| 4474 | +function usces_add_capabilites() { | |
| 4475 | + $admin_role = get_role( 'administrator' ); | |
| 4476 | + $admin_role->add_cap( 'wel_publish_products' ); | |
| 4477 | + $admin_role->add_cap( 'wel_others_products' ); | |
| 4478 | + $admin_role->add_cap( 'wel_manage_order' ); | |
| 4479 | + $admin_role->add_cap( 'wel_manage_setting' ); | |
| 4480 | + | |
| 4481 | + $editor_role = get_role( 'editor' ); | |
| 4482 | + $editor_role->add_cap( 'wel_publish_products' ); | |
| 4483 | + $editor_role->add_cap( 'wel_others_products' ); | |
| 4484 | + $editor_role->add_cap( 'wel_manage_order' ); | |
| 4485 | + $editor_role->add_cap( 'wel_manage_setting' ); | |
| 4486 | + | |
| 4487 | + $wc_management_role = get_role( 'wc_management' ); | |
| 4488 | + $wc_management_role->add_cap( 'wel_publish_products' ); | |
| 4489 | + $wc_management_role->add_cap( 'wel_others_products' ); | |
| 4490 | + $wc_management_role->add_cap( 'wel_manage_order' ); | |
| 4491 | + | |
| 4492 | + $wc_author_role = get_role( 'wc_author' ); | |
| 4493 | + $wc_author_role->add_cap( 'wel_publish_products' ); | |
| 4494 | + $wc_author_role->add_cap( 'wel_others_products' ); | |
| 4495 | + | |
| 4496 | + $author_role = get_role( 'author' ); | |
| 4497 | + $author_role->add_cap( 'wel_publish_products' ); | |
| 4498 | +} | |
| 4499 | + | |
| 4500 | +function usces_add_role() { | |
| 4501 | + | |
| 4502 | + if ( ! get_role( 'wc_author' ) ) { | |
| 4503 | + $capabilities = array( | |
| 4504 | + 'moderate_comments' => 1, | |
| 4505 | + 'manage_categories' => 1, | |
| 4506 | + 'manage_links' => 1, | |
| 4507 | + 'upload_files' => 1, | |
| 4508 | + 'unfiltered_html' => 1, | |
| 4509 | + 'edit_posts' => 1, | |
| 4510 | + 'edit_others_posts' => 1, | |
| 4511 | + 'edit_published_posts' => 1, | |
| 4512 | + 'publish_posts' => 1, | |
| 4513 | + 'edit_pages' => 1, | |
| 4514 | + 'read' => 1, | |
| 4515 | + 'level_4' => 1, | |
| 4516 | + 'level_3' => 1, | |
| 4517 | + 'level_2' => 1, | |
| 4518 | + 'level_1' => 1, | |
| 4519 | + 'level_0' => 1, | |
| 4520 | + 'edit_others_pages' => 1, | |
| 4521 | + 'edit_published_pages' => 1, | |
| 4522 | + 'publish_pages' => 1, | |
| 4523 | + 'delete_pages' => 1, | |
| 4524 | + 'delete_others_pages' => 1, | |
| 4525 | + 'delete_published_pages' => 1, | |
| 4526 | + 'delete_posts' => 1, | |
| 4527 | + 'delete_others_posts' => 1, | |
| 4528 | + 'delete_published_posts' => 1, | |
| 4529 | + 'delete_private_posts' => 1, | |
| 4530 | + 'edit_private_posts' => 1, | |
| 4531 | + 'read_private_posts' => 1, | |
| 4532 | + 'delete_private_pages' => 1, | |
| 4533 | + 'edit_private_pages' => 1, | |
| 4534 | + 'read_private_pages' => 1, | |
| 4535 | + ); | |
| 4536 | + add_role( 'wc_author', __( 'Editor (no management authority)', 'usces' ), $capabilities ); | |
| 4537 | + } | |
| 4538 | + | |
| 4539 | + if ( ! get_role( 'wc_management' ) ) { | |
| 4540 | + $capabilities = array( | |
| 4541 | + 'moderate_comments' => 1, | |
| 4542 | + 'manage_categories' => 1, | |
| 4543 | + 'manage_links' => 1, | |
| 4544 | + 'upload_files' => 1, | |
| 4545 | + 'unfiltered_html' => 1, | |
| 4546 | + 'edit_posts' => 1, | |
| 4547 | + 'edit_others_posts' => 1, | |
| 4548 | + 'edit_published_posts' => 1, | |
| 4549 | + 'publish_posts' => 1, | |
| 4550 | + 'edit_pages' => 1, | |
| 4551 | + 'read' => 1, | |
| 4552 | + 'level_5' => 1, | |
| 4553 | + 'level_4' => 1, | |
| 4554 | + 'level_3' => 1, | |
| 4555 | + 'level_2' => 1, | |
| 4556 | + 'level_1' => 1, | |
| 4557 | + 'level_0' => 1, | |
| 4558 | + 'edit_others_pages' => 1, | |
| 4559 | + 'edit_published_pages' => 1, | |
| 4560 | + 'publish_pages' => 1, | |
| 4561 | + 'delete_pages' => 1, | |
| 4562 | + 'delete_others_pages' => 1, | |
| 4563 | + 'delete_published_pages' => 1, | |
| 4564 | + 'delete_posts' => 1, | |
| 4565 | + 'delete_others_posts' => 1, | |
| 4566 | + 'delete_published_posts' => 1, | |
| 4567 | + 'delete_private_posts' => 1, | |
| 4568 | + 'edit_private_posts' => 1, | |
| 4569 | + 'read_private_posts' => 1, | |
| 4570 | + 'delete_private_pages' => 1, | |
| 4571 | + 'edit_private_pages' => 1, | |
| 4572 | + 'read_private_pages' => 1, | |
| 4573 | + ); | |
| 4574 | + add_role( 'wc_management', __( 'Editor (no setting authority)', 'usces' ), $capabilities ); | |
| 4575 | + } | |
| 4576 | + | |
| 4577 | + remove_role( 'wpsc_anonymous' ); | |
| 4578 | +} | |
| 4579 | + | |
| 4580 | +function usces_get_admin_user_level() { | |
| 4581 | + global $current_user; | |
| 4582 | + | |
| 4583 | + wp_get_current_user(); | |
| 4584 | + $levels = array(); | |
| 4585 | + foreach ( $current_user->allcaps as $key => $value ) { | |
| 4586 | + $parts = explode( '_', $key ); | |
| 4587 | + if ( 'level' == $parts[0] ) { | |
| 4588 | + $levels[] = $parts[1]; | |
| 4589 | + } | |
| 4590 | + } | |
| 4591 | + if ( empty( $levels ) ) { | |
| 4592 | + return 0; | |
| 4593 | + } else { | |
| 4594 | + rsort( $levels ); | |
| 4595 | + return $levels[0]; | |
| 4596 | + } | |
| 4597 | +} | |
| 4598 | + | |
| 4599 | +function usces_make_lost_key() { | |
| 4600 | + return uniqid( 'wc' , true ); | |
| 4601 | +} | |
| 4602 | + | |
| 4603 | +function usces_store_lostmail_key( $lost_mail, $lost_key ) { | |
| 4604 | + global $wpdb; | |
| 4605 | + | |
| 4606 | + $date = substr( current_time( 'mysql' ), 0, 10 ); | |
| 4607 | + $table = $wpdb->prefix . 'usces_access'; | |
| 4608 | + $query = $wpdb->prepare( "INSERT INTO {$table} (acc_key, acc_type, acc_value, acc_date) VALUES (%s, %s, %s, %s)", $lost_mail, 'lostkey', $lost_key, $date ); | |
| 4609 | + $res = $wpdb->query( $query ); | |
| 4610 | + return $res; | |
| 4611 | +} | |
| 4612 | + | |
| 4613 | +function usces_remove_lostmail_key( $lost_mail, $lost_key ) { | |
| 4614 | + global $wpdb; | |
| 4615 | + | |
| 4616 | + $table = $wpdb->prefix . 'usces_access'; | |
| 4617 | + $query = $wpdb->prepare( "DELETE FROM {$table} WHERE acc_key = %s AND acc_type = %s AND acc_value = %s", $lost_mail, 'lostkey', $lost_key ); | |
| 4618 | + $res = $wpdb->query( $query ); | |
| 4619 | + return $res; | |
| 4620 | +} | |
| 4621 | + | |
| 4622 | +function usces_check_lostkey( $lost_mail, $lost_key ) { | |
| 4623 | + global $wpdb; | |
| 4624 | + | |
| 4625 | + $table = $wpdb->prefix . 'usces_access'; | |
| 4626 | + $query = $wpdb->prepare( "SELECT ID FROM {$table} WHERE acc_key = %s AND acc_type = %s AND acc_value = %s", $lost_mail, 'lostkey', $lost_key ); | |
| 4627 | + $res = $wpdb->get_col( $query ); | |
| 4628 | + return $res; | |
| 4629 | +} | |
| 4630 | + | |
| 4631 | +function usces_clearup_lostkey() { | |
| 4632 | + global $wpdb; | |
| 4633 | + | |
| 4634 | + $table = $wpdb->prefix . 'usces_access'; | |
| 4635 | + $date = date( 'Y-m-d', current_time( 'timestamp' ) ); | |
| 4636 | + $query = $wpdb->prepare( "DELETE FROM {$table} WHERE acc_type = %s AND acc_date < %s", 'lostkey', $date ); | |
| 4637 | + $res = $wpdb->query( $query ); | |
| 4638 | + do_action( 'usces_clearup_lostkey', $res ); | |
| 4639 | + return $res; | |
| 4640 | +} | |
| 4641 | + | |
| 4642 | +function usces_clearup_acting_data() { | |
| 4643 | + global $wpdb; | |
| 4644 | + | |
| 4645 | + $table = $wpdb->prefix . 'usces_access'; | |
| 4646 | + $date = date( 'Y-m-d', ( current_time( 'timestamp' ) - 86400 * 30 ) ); | |
| 4647 | + $query = $wpdb->prepare( "DELETE FROM {$table} WHERE acc_type = %s AND acc_date < %s", 'acting_data', $date ); | |
| 4648 | + $res = $wpdb->query( $query ); | |
| 4649 | + do_action( 'usces_clearup_acting_data', $res ); | |
| 4650 | + return $res; | |
| 4651 | +} | |
| 4652 | + | |
| 4653 | +function usces_clearup_acting_log() { | |
| 4654 | + global $usces, $wpdb; | |
| 4655 | + | |
| 4656 | + $table = $wpdb->prefix . 'usces_log'; | |
| 4657 | + $date = date( 'Y-m-d 00:00:00', ( current_time( 'timestamp' ) - 86400 * 30 ) ); | |
| 4658 | + $query = $wpdb->prepare( "DELETE FROM {$table} WHERE ( log_type = %s OR log_type = %s ) AND datetime < %s", 'acting_data', 'acting_error', $date ); | |
| 4659 | + $res = $wpdb->query( $query ); | |
| 4660 | + do_action( 'usces_clearup_acting_log', $res ); | |
| 4661 | +} | |
| 4662 | + | |
| 4663 | +function usces_acting_key() { | |
| 4664 | + global $usces; | |
| 4665 | + $acting_key = usces_rand(); | |
| 4666 | + return $acting_key; | |
| 4667 | +} | |
| 4668 | + | |
| 4669 | +function usces_change_order_receipt( $order_id, $flag ) { | |
| 4670 | + global $wpdb, $usces; | |
| 4671 | + | |
| 4672 | + $table_name = $wpdb->prefix . 'usces_order'; | |
| 4673 | + | |
| 4674 | + if ( 'receipted' === $flag ) { | |
| 4675 | + | |
| 4676 | + $mquery = $wpdb->prepare( | |
| 4677 | + "UPDATE $table_name SET order_status = | |
| 4678 | + CASE | |
| 4679 | + WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted') | |
| 4680 | + WHEN LOCATE('receipted', order_status) > 0 THEN order_status | |
| 4681 | + ELSE CONCAT('receipted,', order_status ) | |
| 4682 | + END | |
| 4683 | + WHERE ID = %d", | |
| 4684 | + $order_id | |
| 4685 | + ); | |
| 4686 | + $res = $wpdb->query( $mquery ); | |
| 4687 | + | |
| 4688 | + $gmtdate = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 4689 | + $usces->set_order_meta_value( 'receipted_date', $gmtdate, $order_id ); | |
| 4690 | + | |
| 4691 | + } elseif ( 'noreceipt' === $flag ) { | |
| 4692 | + | |
| 4693 | + $mquery = $wpdb->prepare( | |
| 4694 | + "UPDATE $table_name SET order_status = | |
| 4695 | + CASE | |
| 4696 | + WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt') | |
| 4697 | + WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status | |
| 4698 | + ELSE CONCAT('noreceipt,', order_status ) | |
| 4699 | + END | |
| 4700 | + WHERE ID = %d", | |
| 4701 | + $order_id | |
| 4702 | + ); | |
| 4703 | + $res = $wpdb->query( $mquery ); | |
| 4704 | + | |
| 4705 | + $usces->del_order_meta( 'receipted_date', $order_id ); | |
| 4706 | + } | |
| 4707 | + return $res; | |
| 4708 | +} | |
| 4709 | + | |
| 4710 | +function usces_localized_name( $familly_name, $given_name, $out = '' ) { | |
| 4711 | + global $usces_settings, $usces; | |
| 4712 | + | |
| 4713 | + $familly_name = preg_replace( '/[\r\n]/', '', $familly_name ); | |
| 4714 | + $given_name = preg_replace( '/[\r\n]/', '', $given_name ); | |
| 4715 | + | |
| 4716 | + $options = get_option( 'usces', array() ); | |
| 4717 | + $form = $options['system']['addressform']; | |
| 4718 | + if ( $usces_settings['nameform'][ $form ] ) { | |
| 4719 | + $res = $given_name . ' ' . $familly_name; | |
| 4720 | + } else { | |
| 4721 | + $res = $familly_name . ' ' . $given_name; | |
| 4722 | + } | |
| 4723 | + | |
| 4724 | + if ( 'return' === $out ) { | |
| 4725 | + return esc_html( $res ); | |
| 4726 | + } else { | |
| 4727 | + echo esc_html( $res ); | |
| 4728 | + } | |
| 4729 | +} | |
| 4730 | + | |
| 4731 | +function usces_get_hash( $str, $salt = NULL, $type = 0 ) { | |
| 4732 | + //$hash = md5( trim( $str ) ); | |
| 4733 | + $hash_algos = ( defined( 'USCES_HASH_ALGOS' ) ) ? USCES_HASH_ALGOS : 'md5'; | |
| 4734 | + $secret_key = ( defined( 'USCES_SECRET_KEY' ) ) ? USCES_SECRET_KEY : ''; | |
| 4735 | + if ( $secret_key ) { | |
| 4736 | + $hash = hash_hmac( $hash_algos, $str.$salt, $secret_key ); | |
| 4737 | + } else { | |
| 4738 | + $hash = hash( $hash_algos, $str.$salt ); | |
| 4739 | + } | |
| 4740 | + $args = compact( 'str', 'salt', 'type' ); | |
| 4741 | + return apply_filters( 'usces_filter_get_hash', $hash, $args ); | |
| 4742 | +} | |
| 4743 | + | |
| 4744 | +function usces_get_salt( $mem_key, $type = 0 ) { | |
| 4745 | + global $wpdb; | |
| 4746 | + | |
| 4747 | + $salt = ''; | |
| 4748 | + if ( defined( 'USCES_SALT' ) && '1' === USCES_SALT ) { | |
| 4749 | + if ( 1 === $type ) { | |
| 4750 | + $salt = uniqid(); | |
| 4751 | + } else { | |
| 4752 | + if ( ! empty( $mem_key ) ) { | |
| 4753 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4754 | + $member_meta_table = usces_get_tablename( 'usces_member_meta' ); | |
| 4755 | + if ( is_numeric( $mem_key ) ) { | |
| 4756 | + $salt = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $member_meta_table WHERE member_id = %d AND meta_key = %s", $mem_key, 'mem_salt' ) ); | |
| 4757 | + } else { | |
| 4758 | + $salt = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $member_table AS `member` INNER JOIN $member_meta_table AS `meta` ON member.ID = meta.member_id AND meta.meta_key = %s WHERE mem_email = %s", 'mem_salt', $mem_key ) ); | |
| 4759 | + } | |
| 4760 | + } | |
| 4761 | + } | |
| 4762 | + } | |
| 4763 | + $args = compact( 'mem_key', 'type' ); | |
| 4764 | + return apply_filters( 'usces_filter_get_salt', $salt, $args ); | |
| 4765 | +} | |
| 4766 | + | |
| 4767 | +function usces_get_member_reinforcement() { | |
| 4768 | + if ( defined( 'WCEX_DLSELLER' ) ) { | |
| 4769 | + $dlseller_options = get_option( 'dlseller' ); | |
| 4770 | + if ( isset( $dlseller_options['dlseller_member_reinforcement'] ) && 'on' === $dlseller_options['dlseller_member_reinforcement'] ) { | |
| 4771 | + return true; | |
| 4772 | + } | |
| 4773 | + } | |
| 4774 | + return false; | |
| 4775 | +} | |
| 4776 | + | |
| 4777 | +function usces_have_shipped( $cart = NULL ) { | |
| 4778 | + global $usces; | |
| 4779 | + | |
| 4780 | + if ( empty( $cart ) ) { | |
| 4781 | + $cart = $usces->cart->get_cart(); | |
| 4782 | + } | |
| 4783 | + | |
| 4784 | + $division = ''; | |
| 4785 | + foreach ( (array) $cart as $cart_row ) { | |
| 4786 | + if ( 'shipped' === $usces->getItemDivision( $cart_row['post_id'] ) ) { | |
| 4787 | + $division = 'shipped'; | |
| 4788 | + break; | |
| 4789 | + } | |
| 4790 | + } | |
| 4791 | + if ( 'shipped' === $division ) { | |
| 4792 | + return true; | |
| 4793 | + } else { | |
| 4794 | + return false; | |
| 4795 | + } | |
| 4796 | +} | |
| 4797 | + | |
| 4798 | +function usces_have_continue_charge( $cart = NULL ) { | |
| 4799 | + global $usces; | |
| 4800 | + | |
| 4801 | + if ( empty( $cart ) ) { | |
| 4802 | + $cart = $usces->cart->get_cart(); | |
| 4803 | + } | |
| 4804 | + | |
| 4805 | + $charging_type = 'once'; | |
| 4806 | + foreach ( (array) $cart as $cart_row ) { | |
| 4807 | + if ( 'continue' === $usces->getItemChargingType( $cart_row['post_id'] ) ) { | |
| 4808 | + $charging_type = 'continue'; | |
| 4809 | + break; | |
| 4810 | + } | |
| 4811 | + } | |
| 4812 | + if ( 'continue' === $charging_type ) { | |
| 4813 | + return true; | |
| 4814 | + } else { | |
| 4815 | + return false; | |
| 4816 | + } | |
| 4817 | +} | |
| 4818 | + | |
| 4819 | +function usces_have_regular_order() { | |
| 4820 | + if ( defined( 'WCEX_AUTO_DELIVERY' ) ) { | |
| 4821 | + return wcad_have_regular_order(); | |
| 4822 | + } | |
| 4823 | + return false; | |
| 4824 | +} | |
| 4825 | + | |
| 4826 | +function usces_have_member_regular_order( $member_id ) { | |
| 4827 | + if ( defined( 'WCEX_AUTO_DELIVERY' ) ) { | |
| 4828 | + return wcad_have_member_regular_order( $member_id ); | |
| 4829 | + } | |
| 4830 | + return false; | |
| 4831 | +} | |
| 4832 | + | |
| 4833 | +function usces_have_member_continue_order( $member_id ) { | |
| 4834 | + if ( defined( 'WCEX_DLSELLER' ) && function_exists( 'dlseller_have_member_continue_order' ) ) { | |
| 4835 | + return dlseller_have_member_continue_order( $member_id ); | |
| 4836 | + } | |
| 4837 | + return false; | |
| 4838 | +} | |
| 4839 | + | |
| 4840 | +function usces_is_available_point() { | |
| 4841 | + global $usces; | |
| 4842 | + | |
| 4843 | + $res = true; | |
| 4844 | + | |
| 4845 | + if ( defined( 'WCEX_DLSELLER' ) && function_exists( 'dlseller_have_continue_charge' ) ) { | |
| 4846 | + if ( dlseller_have_continue_charge() ) { | |
| 4847 | + $res = false; | |
| 4848 | + } | |
| 4849 | + } | |
| 4850 | + | |
| 4851 | + return $res; | |
| 4852 | +} | |
| 4853 | + | |
| 4854 | +function usces_get_link_key( $results ) { | |
| 4855 | + global $usces; | |
| 4856 | + | |
| 4857 | + $linkkey = '(empty key)'; | |
| 4858 | + if ( isset( $_REQUEST['X-S_TORIHIKI_NO'] ) ) { | |
| 4859 | + $linkkey = $_REQUEST['S_TORIHIKI_NO']; //remise. | |
| 4860 | + } elseif ( isset( $_REQUEST['acting'] ) && ( 'jpayment_card' === $_REQUEST['acting'] || 'jpayment_conv' === $_REQUEST['acting'] || 'jpayment_bank' === $_REQUEST['acting'] ) && isset( $_REQUEST['cod'] ) ) { | |
| 4861 | + $linkkey = $_REQUEST['cod']; //ROBOT PAYMENT (Cloud Payment,J-Payment). | |
| 4862 | + } elseif ( isset( $_REQUEST['txn_type'] ) && 'pro_hosted' === $_REQUEST['txn_type'] && isset( $_REQUEST['custom'] ) ) { | |
| 4863 | + $linkkey = $_REQUEST['custom']; //PayPal Webpayment Plus. | |
| 4864 | + } elseif ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) ) { | |
| 4865 | + $linkkey = $_REQUEST['SID']; //Payment for (MetapsPayment,paydesign,digitalcheck). | |
| 4866 | + } elseif ( isset( $_REQUEST['acting'] ) && ( 'mizuho_card' === $_REQUEST['acting'] || 'mizuho_conv' === $_REQUEST['acting'] ) && isset( $_REQUEST['stran'] ) ) { | |
| 4867 | + $linkkey = $_REQUEST['stran']; //mizuho. | |
| 4868 | + } elseif ( isset( $_REQUEST['SiteId'] ) && $usces->options['acting_settings']['anotherlane']['siteid'] === $_REQUEST['SiteId'] && isset( $_REQUEST['TransactionId'] ) ) { | |
| 4869 | + $linkkey = $_REQUEST['TransactionId']; //AnotherLane. | |
| 4870 | + } elseif ( isset( $_REQUEST['acting'] ) && ( 'veritrans_card' === $_REQUEST['acting'] || 'veritrans_conv' === $_REQUEST['acting'] ) && isset( $_REQUEST['orderId'] ) ) { | |
| 4871 | + $linkkey = $_REQUEST['orderId']; //Veritrans. | |
| 4872 | + } elseif ( isset( $_REQUEST['acting'] ) && 'telecom_card' === $_REQUEST['acting'] && isset( $_REQUEST['acting_return'] ) && isset( $_REQUEST['option'] ) ) { | |
| 4873 | + $linkkey = $_REQUEST['option']; //telecom credit. | |
| 4874 | + } elseif ( isset( $_REQUEST['acting'] ) && 'epsilon' === $_REQUEST['acting'] && isset( $_REQUEST['acting_return'] ) && isset( $_REQUEST['order_number'] ) ) { | |
| 4875 | + $linkkey = $_REQUEST['order_number']; //epsilon. | |
| 4876 | + } | |
| 4877 | + $linkkey = apply_filters( 'usces_filter_get_link_key', $linkkey, $results ); | |
| 4878 | + return $linkkey; | |
| 4879 | +} | |
| 4880 | + | |
| 4881 | +function usces_erase_emoji( $str ) { | |
| 4882 | + if ( $str ) { | |
| 4883 | + $newstr = preg_replace( '/[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF]/', '', $str ); | |
| 4884 | + $str = apply_filters( 'usces_filter_erase_emoji', $newstr, $str ); | |
| 4885 | + } | |
| 4886 | + return $str; | |
| 4887 | +} | |
| 4888 | + | |
| 4889 | +function usces_is_reduced_taxrate( $order_id = '' ) { | |
| 4890 | + global $usces; | |
| 4891 | + | |
| 4892 | + if ( empty( $order_id ) ) { | |
| 4893 | + $reduced = $usces->is_reduced_taxrate(); | |
| 4894 | + } else { | |
| 4895 | + $condition = usces_get_order_condition( $order_id ); | |
| 4896 | + $reduced = ( isset( $condition['applicable_taxrate'] ) && 'reduced' === $condition['applicable_taxrate'] ) ? true : false; | |
| 4897 | + } | |
| 4898 | + return $reduced; | |
| 4899 | +} | |
| 4900 | + | |
| 4901 | +function usces_get_order_condition( $order_id ) { | |
| 4902 | + global $wpdb; | |
| 4903 | + $order_condition = $wpdb->get_var( $wpdb->prepare( "SELECT order_condition FROM {$wpdb->prefix}usces_order WHERE ID = %d", $order_id ) ); | |
| 4904 | + return wel_safe_maybe_unserialize( $order_condition ); | |
| 4905 | +} | |
| 4906 | + | |
| 4907 | +function usces_tax_rounding_off( $tax, $tax_method = '' ) { | |
| 4908 | + global $usces; | |
| 4909 | + | |
| 4910 | + if ( empty( $tax_method ) ) { | |
| 4911 | + $tax_method = $usces->options['tax_method']; | |
| 4912 | + } | |
| 4913 | + $decimal = $usces->get_currency_decimal(); | |
| 4914 | + $decipad = (int) str_pad( '1', $decimal + 1, '0', STR_PAD_RIGHT ); | |
| 4915 | + switch ( $tax_method ) { | |
| 4916 | + case 'cutting': | |
| 4917 | + if ( 0 < $tax ) { | |
| 4918 | + $tax = floor( (float) $tax * $decipad ) / $decipad; | |
| 4919 | + } | |
| 4920 | + break; | |
| 4921 | + case 'bring': | |
| 4922 | + if ( 0 < $tax ) { | |
| 4923 | + $tax = ceil( floatval( ( $tax . '' ) ) * $decipad ) / $decipad; | |
| 4924 | + } | |
| 4925 | + break; | |
| 4926 | + case 'rounding': | |
| 4927 | + if ( 0 < $decimal ) { | |
| 4928 | + if ( 0 < $tax ) { | |
| 4929 | + $tax = round( (float) $tax, $decimal ); | |
| 4930 | + } | |
| 4931 | + } else { | |
| 4932 | + if ( 0 < $tax ) { | |
| 4933 | + $tax = round( (float) $tax ); | |
| 4934 | + } | |
| 4935 | + } | |
| 4936 | + break; | |
| 4937 | + } | |
| 4938 | + return $tax; | |
| 4939 | +} | |
| 4940 | + | |
| 4941 | +function usces_is_required_field( $name ) { | |
| 4942 | + global $usces_essential_mark; | |
| 4943 | + | |
| 4944 | + $usces_essential_mark = apply_filters( 'usces_filter_essential_mark', $usces_essential_mark ); | |
| 4945 | + if ( empty( $usces_essential_mark[ $name ] ) ) { | |
| 4946 | + return false; | |
| 4947 | + } else { | |
| 4948 | + return true; | |
| 4949 | + } | |
| 4950 | +} | |
| 4951 | + | |
| 4952 | +function usces_get_tablename( $target ) { | |
| 4953 | + global $wpdb; | |
| 4954 | + | |
| 4955 | + $prefix = ''; | |
| 4956 | + if ( defined( 'WELCART_DB_PREFIX' ) ) { | |
| 4957 | + $prefix = WELCART_DB_PREFIX; | |
| 4958 | + } | |
| 4959 | + if ( ! $prefix ) { | |
| 4960 | + $prefix = $wpdb->prefix; | |
| 4961 | + } | |
| 4962 | + $tablename = $prefix . $target; | |
| 4963 | + | |
| 4964 | + $tablename = apply_filters( 'usces_filter_get_tablename', $tablename, $target ); | |
| 4965 | + | |
| 4966 | + return $tablename; | |
| 4967 | +} | |
| 4968 | + | |
| 4969 | +function usces_convert_zipcode( $zipcode ) { | |
| 4970 | + $zipcode = mb_convert_kana( $zipcode, 'a' ); | |
| 4971 | + $zipcode = str_replace( 'ー', '-', $zipcode ); | |
| 4972 | + $zipcode = str_replace( '―', '-', $zipcode ); | |
| 4973 | + $zipcode = str_replace( '-', '-', $zipcode ); | |
| 4974 | + return $zipcode; | |
| 4975 | +} | |
| 4976 | + | |
| 4977 | +function usces_get_sku( $post_id, $sku_code ) { | |
| 4978 | + global $usces; | |
| 4979 | + $skus = $usces->get_skus( $post_id, 'code' ); | |
| 4980 | + $sku = isset( $skus[ $sku_code ] ) ? $skus[ $sku_code ] : array(); | |
| 4981 | + return $sku; | |
| 4982 | +} | |
| 4983 | + | |
| 4984 | +function usces_get_wp_environment() { | |
| 4985 | + global $wp_version, $wpdb; | |
| 4986 | + | |
| 4987 | + $permalink_structure = get_option( 'permalink_structure' ); | |
| 4988 | + // WP memory limit. | |
| 4989 | + $wp_memory_limit = usces_let_to_num( WP_MEMORY_LIMIT ); | |
| 4990 | + if ( function_exists( 'memory_get_usage' ) ) { | |
| 4991 | + $wp_memory_limit = max( $wp_memory_limit, usces_let_to_num( @ini_get( 'memory_limit' ) ) ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged | |
| 4992 | + } | |
| 4993 | + return array( | |
| 4994 | + 'environment' => array( | |
| 4995 | + 'wp_version' => $wp_version, | |
| 4996 | + 'home_url' => get_option( 'home' ), | |
| 4997 | + 'site_url' => get_option( 'siteurl' ), | |
| 4998 | + 'site_language' => get_bloginfo( 'language' ), | |
| 4999 | + 'timezone' => get_option( 'timezone_string' ), | |
| 5000 | + 'number_of_media' => array_sum( (array) wp_count_attachments( array( 'image/jpeg', 'image/gif', 'image/png' ) ) ), | |
| 5001 | + 'number_of_post' => get_option( 'posts_per_page' ), | |
| 5002 | + 'blog_public' => get_option( 'blog_public' ), | |
| 5003 | + 'thumbnail_size' => array( | |
| 5004 | + 'width' => get_option( 'thumbnail_size_w' ), | |
| 5005 | + 'height' => get_option( 'thumbnail_size_h' ), | |
| 5006 | + ), | |
| 5007 | + 'medium_size' => array( | |
| 5008 | + 'width' => get_option( 'medium_size_w' ), | |
| 5009 | + 'height' => get_option( 'medium_size_h' ), | |
| 5010 | + ), | |
| 5011 | + 'large_size' => array( | |
| 5012 | + 'width' => get_option( 'large_size_w' ), | |
| 5013 | + 'height' => get_option( 'large_size_h' ), | |
| 5014 | + ), | |
| 5015 | + 'permalinks' => ( empty( $permalink_structure ) ) ? __( 'Plain', 'usces' ) : __( 'Custom structure', 'usces' ) . " ( {$permalink_structure} )", | |
| 5016 | + 'wp_multisite' => is_multisite(), | |
| 5017 | + 'wp_memory_limit' => $wp_memory_limit, | |
| 5018 | + 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), | |
| 5019 | + 'server' => $_SERVER['SERVER_SOFTWARE'], | |
| 5020 | + 'php_version' => phpversion(), | |
| 5021 | + 'php_post_max_size' => ini_get( 'post_max_size' ), | |
| 5022 | + 'php_max_execution_time' => ini_get( 'max_execution_time' ), | |
| 5023 | + 'php_max_input_vars' => ini_get( 'max_input_vars' ), | |
| 5024 | + 'curl_version' => curl_version(), | |
| 5025 | + 'mysql_version' => $wpdb->dbh->server_info, | |
| 5026 | + 'upload_max_filesize' => ini_get( 'upload_max_filesize' ), | |
| 5027 | + ), | |
| 5028 | + 'theme' => usces_get_theme_info(), | |
| 5029 | + 'active_plugins' => usces_get_active_plugins(), | |
| 5030 | + 'inactive_plugins' => usces_get_inactive_plugins(), | |
| 5031 | + ); | |
| 5032 | +} | |
| 5033 | + | |
| 5034 | +/** | |
| 5035 | + * Get a list of plugins active on the site. | |
| 5036 | + * | |
| 5037 | + * @return array | |
| 5038 | + */ | |
| 5039 | +function usces_get_active_plugins() { | |
| 5040 | + if ( ! function_exists( 'get_plugin_data' ) ) { | |
| 5041 | + return array(); | |
| 5042 | + } | |
| 5043 | + | |
| 5044 | + $active_plugins = (array) get_option( 'active_plugins', array() ); | |
| 5045 | + if ( is_multisite() ) { | |
| 5046 | + $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); | |
| 5047 | + $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); | |
| 5048 | + } | |
| 5049 | + | |
| 5050 | + $active_plugins_data = array(); | |
| 5051 | + | |
| 5052 | + foreach ( $active_plugins as $plugin ) { | |
| 5053 | + $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); | |
| 5054 | + $active_plugins_data[] = usces_format_plugin_data( $plugin, $data ); | |
| 5055 | + } | |
| 5056 | + | |
| 5057 | + return $active_plugins_data; | |
| 5058 | +} | |
| 5059 | + | |
| 5060 | +/** | |
| 5061 | + * Get a list of inplugins active on the site. | |
| 5062 | + * | |
| 5063 | + * @return array | |
| 5064 | + */ | |
| 5065 | +function usces_get_inactive_plugins() { | |
| 5066 | + if ( ! function_exists( 'get_plugins' ) ) { | |
| 5067 | + return array(); | |
| 5068 | + } | |
| 5069 | + | |
| 5070 | + $plugins = get_plugins(); | |
| 5071 | + $active_plugins = (array) get_option( 'active_plugins', array() ); | |
| 5072 | + | |
| 5073 | + if ( is_multisite() ) { | |
| 5074 | + $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); | |
| 5075 | + $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); | |
| 5076 | + } | |
| 5077 | + | |
| 5078 | + $plugins_data = array(); | |
| 5079 | + | |
| 5080 | + foreach ( $plugins as $plugin => $data ) { | |
| 5081 | + if ( in_array( $plugin, $active_plugins, true ) ) { | |
| 5082 | + continue; | |
| 5083 | + } | |
| 5084 | + $plugins_data[] = usces_format_plugin_data( $plugin, $data ); | |
| 5085 | + } | |
| 5086 | + | |
| 5087 | + return $plugins_data; | |
| 5088 | +} | |
| 5089 | + | |
| 5090 | +/** | |
| 5091 | + * Format plugin data, including data on updates, into a standard format. | |
| 5092 | + * | |
| 5093 | + * @since 3.6.0 | |
| 5094 | + * @param string $plugin Plugin directory/file. | |
| 5095 | + * @param array $data Plugin data from WP. | |
| 5096 | + * @return array Formatted data. | |
| 5097 | + */ | |
| 5098 | +function usces_format_plugin_data( $plugin, $data ) { | |
| 5099 | + if ( ! function_exists( 'get_plugin_updates' ) ) { | |
| 5100 | + return array(); | |
| 5101 | + } | |
| 5102 | + $available_updates = get_plugin_updates(); | |
| 5103 | + | |
| 5104 | + $version_latest = $data['Version']; | |
| 5105 | + | |
| 5106 | + // Find latest version. | |
| 5107 | + if ( isset( $available_updates[ $plugin ]->update->new_version ) ) { | |
| 5108 | + $version_latest = $available_updates[ $plugin ]->update->new_version; | |
| 5109 | + } | |
| 5110 | + | |
| 5111 | + return array( | |
| 5112 | + 'plugin' => $plugin, | |
| 5113 | + 'name' => $data['Name'], | |
| 5114 | + 'version' => $data['Version'], | |
| 5115 | + 'version_latest' => $version_latest, | |
| 5116 | + 'url' => $data['PluginURI'], | |
| 5117 | + 'author_name' => $data['AuthorName'], | |
| 5118 | + 'author_url' => esc_url_raw( $data['AuthorURI'] ), | |
| 5119 | + 'network_activated' => $data['Network'], | |
| 5120 | + ); | |
| 5121 | +} | |
| 5122 | + | |
| 5123 | +/** | |
| 5124 | + * Get info on the current active theme, info on parent theme (if presnet) | |
| 5125 | + * and a list of template overrides. | |
| 5126 | + * | |
| 5127 | + * @return array | |
| 5128 | + */ | |
| 5129 | +function usces_get_theme_info() { | |
| 5130 | + $active_theme = wp_get_theme(); | |
| 5131 | + | |
| 5132 | + $themes_update = get_site_transient( 'update_themes' ); | |
| 5133 | + | |
| 5134 | + if ( is_child_theme() ) { | |
| 5135 | + $parent_theme = wp_get_theme( $active_theme->template ); | |
| 5136 | + $parent_theme_info = array( | |
| 5137 | + 'parent_name' => $parent_theme->name, | |
| 5138 | + 'parent_version' => $parent_theme->version, | |
| 5139 | + 'parent_version_latest' => ( isset( $themes_update->response[ $parent_theme->get_stylesheet() ]['new_version'] ) ) ? $themes_update->response[ $parent_theme->get_stylesheet() ]['new_version'] : false, | |
| 5140 | + 'parent_author_url' => $parent_theme->{'Author URI'}, | |
| 5141 | + ); | |
| 5142 | + } else { | |
| 5143 | + $parent_theme_info = array( | |
| 5144 | + 'parent_name' => '', | |
| 5145 | + 'parent_version' => '', | |
| 5146 | + 'parent_version_latest' => '', | |
| 5147 | + 'parent_author_url' => '', | |
| 5148 | + ); | |
| 5149 | + } | |
| 5150 | + | |
| 5151 | + $active_theme_info = array( | |
| 5152 | + 'name' => $active_theme->name, | |
| 5153 | + 'version' => $active_theme->version, | |
| 5154 | + 'version_latest' => ( isset( $themes_update->response[ $active_theme->get_stylesheet() ]['new_version'] ) ) ? $themes_update->response[ $active_theme->get_stylesheet() ]['new_version'] : false, | |
| 5155 | + 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), | |
| 5156 | + 'is_child_theme' => is_child_theme(), | |
| 5157 | + ); | |
| 5158 | + | |
| 5159 | + return array_merge( $active_theme_info, $parent_theme_info ); | |
| 5160 | +} | |
| 5161 | + | |
| 5162 | +/** | |
| 5163 | + * Notation to numbers. | |
| 5164 | + * | |
| 5165 | + * This function transforms the php.ini notation for numbers (like '2M') to an integer. | |
| 5166 | + * | |
| 5167 | + * @param string $size Size value. | |
| 5168 | + * @return int | |
| 5169 | + */ | |
| 5170 | +function usces_let_to_num( $size ) { | |
| 5171 | + $l = substr( $size, -1 ); | |
| 5172 | + $ret = (int) substr( $size, 0, -1 ); | |
| 5173 | + switch ( strtoupper( $l ) ) { | |
| 5174 | + case 'P': | |
| 5175 | + $ret *= 1024; | |
| 5176 | + // No break. | |
| 5177 | + case 'T': | |
| 5178 | + $ret *= 1024; | |
| 5179 | + // No break. | |
| 5180 | + case 'G': | |
| 5181 | + $ret *= 1024; | |
| 5182 | + // No break. | |
| 5183 | + case 'M': | |
| 5184 | + $ret *= 1024; | |
| 5185 | + // No break. | |
| 5186 | + case 'K': | |
| 5187 | + $ret *= 1024; | |
| 5188 | + // No break. | |
| 5189 | + } | |
| 5190 | + return $ret; | |
| 5191 | +} | |
| 5192 | + | |
| 5193 | +function usces_get_total_orders() { | |
| 5194 | + global $wpdb; | |
| 5195 | + | |
| 5196 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 5197 | + $sql = "SELECT COUNT(*) AS total FROM $order_table_name"; | |
| 5198 | + $result = $wpdb->get_row( $sql ); | |
| 5199 | + return $result->total; | |
| 5200 | +} | |
| 5201 | + | |
| 5202 | +function usces_get_total_members() { | |
| 5203 | + global $wpdb; | |
| 5204 | + | |
| 5205 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 5206 | + $sql = "SELECT COUNT(*) AS total FROM $member_table_name"; | |
| 5207 | + $result = $wpdb->get_row( $sql ); | |
| 5208 | + return $result->total; | |
| 5209 | +} | |
| 5210 | + | |
| 5211 | +function get_welcart_system_information() { | |
| 5212 | + global $usces, $usces_settings; | |
| 5213 | + | |
| 5214 | + $options = get_option( 'usces', array() ); | |
| 5215 | + $options_ex = get_option( 'usces_ex', array() ); | |
| 5216 | + $indi_item_name_text = array( | |
| 5217 | + 'item_name' => 'item name', | |
| 5218 | + 'item_code' => 'item code', | |
| 5219 | + 'sku_name' => 'SKU name', | |
| 5220 | + 'sku_code' => 'SKU code', | |
| 5221 | + ); | |
| 5222 | + return array( | |
| 5223 | + 'version' => USCES_VERSION, | |
| 5224 | + 'total_items' => $usces->get_items_num(), | |
| 5225 | + 'total_sku' => array_sum( usces_get_stocs() ), | |
| 5226 | + 'maintenance_mode' => ( isset( $options['display_mode'] ) && $options['display_mode'] == 'Maintenancemode' ) ? true : false, | |
| 5227 | + 'campaign_schedule' => $options['campaign_schedule'], | |
| 5228 | + 'order_mail' => $options['order_mail'], | |
| 5229 | + 'sender_mail' => $options['sender_mail'], | |
| 5230 | + 'postage_privilege' => $options['postage_privilege'], // free ship condition. | |
| 5231 | + 'purchase_limit' => $options['purchase_limit'], | |
| 5232 | + 'shipping_rule' => $options['shipping_rule'], | |
| 5233 | + 'shipping_rule_text' => get_option( 'usces_shipping_rule' ), | |
| 5234 | + 'tax_mode' => $options['tax_mode'], | |
| 5235 | + 'tax_target' => $options['tax_target'], | |
| 5236 | + 'applicable_taxrate' => $options['applicable_taxrate'], | |
| 5237 | + 'tax_rate' => $options['tax_rate'], | |
| 5238 | + 'reduced_tax_rate' => $options['tax_rate_reduced'], | |
| 5239 | + 'tax_method' => $options['tax_method'], | |
| 5240 | + 'membership_system' => $options['membersystem_state'], | |
| 5241 | + 'membership_point' => $options['membersystem_point'], | |
| 5242 | + 'point_coverage' => $options['point_coverage'], | |
| 5243 | + 'point_assign' => $options['point_assign'], | |
| 5244 | + 'payment_methods' => usces_get_system_option( 'usces_payment_method', 'sort' ), | |
| 5245 | + 'payment_structure' => $usces->payment_structure, | |
| 5246 | + 'common_options' => usces_get_opts( USCES_CART_NUMBER ), | |
| 5247 | + 'common_options_type' => get_option( 'usces_item_option_select' ), | |
| 5248 | + 'shipping_methods' => $options['delivery_method'], | |
| 5249 | + 'shipping_charge' => $options['shipping_charge'], | |
| 5250 | + 'delivery_days' => $options['delivery_days'], | |
| 5251 | + 'delivery_method' => $options['delivery_method'], | |
| 5252 | + 'delivery_time_limit' => $options['delivery_time_limit'], | |
| 5253 | + 'shortest_delivery_time' => $options['shortest_delivery_time'], | |
| 5254 | + 'delivery_after_days' => $options['delivery_after_days'], | |
| 5255 | + 'newmem_admin_mail' => $options['newmem_admin_mail'], | |
| 5256 | + 'updmem_admin_mail' => $options['updmem_admin_mail'], | |
| 5257 | + 'updmem_customer_mail' => $options['updmem_customer_mail'], | |
| 5258 | + 'delmem_admin_mail' => $options['delmem_admin_mail'], | |
| 5259 | + 'delmem_customer_mail' => $options['delmem_customer_mail'], | |
| 5260 | + 'put_customer_name' => $options['put_customer_name'], | |
| 5261 | + 'email_attach_feature' => $options['email_attach_feature'], | |
| 5262 | + 'email_attach_file_extension' => $options['email_attach_file_extension'], | |
| 5263 | + 'email_attach_file_size' => $options['email_attach_file_size'], | |
| 5264 | + 'add_html_email_option' => $options['add_html_email_option'], | |
| 5265 | + 'indi_item_name' => $options['indi_item_name'], | |
| 5266 | + 'indi_item_name_text' => $indi_item_name_text, | |
| 5267 | + 'pos_item_name' => $options['pos_item_name'], | |
| 5268 | + 'divide_item' => $options['divide_item'], | |
| 5269 | + 'itemimg_anchor_rel' => $options['itemimg_anchor_rel'], | |
| 5270 | + 'fukugo_category_orderby' => $options['fukugo_category_orderby'], | |
| 5271 | + 'fukugo_category_order' => $options['fukugo_category_order'], | |
| 5272 | + 'use_ssl' => $options['use_ssl'], | |
| 5273 | + 'inquiry_id' => $options['inquiry_id'], | |
| 5274 | + 'no_cart_css' => $options['system']['no_cart_css'], | |
| 5275 | + 'subimage_rule' => $options['system']['subimage_rule'], | |
| 5276 | + 'pdf_delivery' => $options['system']['pdf_delivery'], | |
| 5277 | + 'csv_encode_type' => $options['system']['csv_encode_type'], | |
| 5278 | + 'csv_category_format' => $options['system']['csv_category_format'], | |
| 5279 | + 'settlement_backup' => $options['system']['settlement_backup'], | |
| 5280 | + 'settlement_notice' => $options['system']['settlement_notice'], | |
| 5281 | + 'country' => $usces_settings['country'], | |
| 5282 | + 'front_lang' => $options['system']['front_lang'], | |
| 5283 | + 'currency' => $options['system']['currency'], | |
| 5284 | + 'addressform' => $options['system']['addressform'], | |
| 5285 | + 'target_market' => $options['system']['target_market'], | |
| 5286 | + 'ganbare_activate_flag' => $options_ex['system']['ganbare']['activate_flag'], | |
| 5287 | + 'stocklink_orderedit_flag' => $options_ex['system']['stocklink']['orderedit_flag'], | |
| 5288 | + 'stocklink_collective_flag' => $options_ex['system']['stocklink']['collective_flag'], | |
| 5289 | + 'datalistup_orderlist_flag' => $options_ex['system']['datalistup']['orderlist_flag'], | |
| 5290 | + 'datalistup_memberlist_flag' => $options_ex['system']['datalistup']['memberlist_flag'], | |
| 5291 | + 'verifyemail_switch_flag' => $options_ex['system']['verifyemail']['switch_flag'], | |
| 5292 | + 'verifyemail_edit_flag' => $options_ex['system']['verifyemail']['edit_flag'], | |
| 5293 | + 'verifyemail_login_notify' => $options_ex['system']['verifyemail']['login_notify'], | |
| 5294 | + 'number_of_orders' => usces_get_total_orders(), | |
| 5295 | + 'number_of_members' => usces_get_total_members(), | |
| 5296 | + 'settlement_selected' => get_option( 'usces_settlement_selected', array() ), | |
| 5297 | + 'available_settlement' => get_option( 'usces_available_settlement', array() ), | |
| 5298 | + 'brute_force_status' => $options_ex['system']['brute_force']['status'], | |
| 5299 | + 'google_recaptcha_status' => $options_ex['system']['google_recaptcha']['status'], | |
| 5300 | + 'structured_data_product_status' => $options_ex['system']['structured_data_product']['status'], | |
| 5301 | + 'fee_subject' => $usces->options['fee_subject'], | |
| 5302 | + 'newproductimage_switch_flag' => $options_ex['system']['newproductimage']['switch_flag'], | |
| 5303 | + 'operation_log_switch_flag' => $options_ex['system']['operation_log']['status'], | |
| 5304 | + 'credit_security' => $options_ex['system']['credit_security']['active'], | |
| 5305 | + ); | |
| 5306 | +} | |
| 5307 | + | |
| 5308 | +function usces_generate_system_information_text( $environment, $theme, $active_plugins, $inactive_plugins, $welcart_information, $loaded_extensions, $ini_confs ) { | |
| 5309 | + $data = '### ' . __( 'WordPress Settings', 'usces' ) . " ###\r\n\r\n"; | |
| 5310 | + | |
| 5311 | + $data .= __( 'WordPress Address (URL)', 'usces' ) . ' : ' . esc_html( $environment['site_url'] ) . "\r\n"; | |
| 5312 | + $data .= __( 'Site Address (URL)', 'usces' ) . ' : ' . esc_html( $environment['home_url'] ) . "\r\n"; | |
| 5313 | + $data .= __( 'WordPress Version', 'usces' ) . ' : ' . esc_html( $environment['wp_version'] ) . "\r\n"; | |
| 5314 | + $data .= __( 'Site Language', 'usces' ) . ' : ' . esc_html( $environment['site_language'] ) . "\r\n"; | |
| 5315 | + $data .= __( 'Timezone', 'usces' ) . ' : ' . esc_html( $environment['timezone'] ) . "\r\n"; | |
| 5316 | + $data .= __( 'Number of media files', 'usces' ) . ' : ' . esc_html( $environment['number_of_media'] ) . "\r\n"; | |
| 5317 | + $data .= __( 'Blog pages show at most', 'usces' ) . ' : ' . esc_html( $environment['number_of_post'] ) . "\r\n"; | |
| 5318 | + $data .= __( 'Search engine visibility', 'usces' ) . ' : ' . ( ( $environment['blog_public'] ) ? '' : __( 'Discourage search engines from indexing this site', 'usces' ) ) . "\r\n"; | |
| 5319 | + $data .= __( 'Thumbnail size', 'usces' ) . ' : ' . __( 'Width', 'usces' ) . ' ' . esc_html( $environment['thumbnail_size']['width'] ) . ' ' . __( 'Height', 'usces' ) . ' ' . esc_html( $environment['thumbnail_size']['height'] ) . "\r\n"; | |
| 5320 | + $data .= __( 'Image medium size', 'usces' ) . ' : ' . __( 'Width', 'usces' ) . ' ' . esc_html( $environment['medium_size']['width'] ) . ' ' . __( 'Height', 'usces' ) . ' ' . esc_html( $environment['medium_size']['height'] ) . "\r\n"; | |
| 5321 | + $data .= __( 'Image large size', 'usces' ) . ' : ' . __( 'Width', 'usces' ) . ' ' . esc_html( $environment['large_size']['width'] ) . ' ' . __( 'Height', 'usces' ) . ' ' . esc_html( $environment['large_size']['height'] ) . "\r\n"; | |
| 5322 | + $data .= __( 'Permalink Settings', 'usces' ) . ' : ' . esc_html( $environment['permalinks'] ) . "\r\n"; | |
| 5323 | + $data .= __( 'WordPress Multisite', 'usces' ) . ' : ' . ( ( $environment['wp_multisite'] ) ? __( 'ON', 'usces' ) : '' ) . "\r\n"; | |
| 5324 | + $data .= __( 'WordPress Memory Limit', 'usces' ) . ' : ' . esc_html( $environment['wp_memory_limit'] ) . "\r\n"; | |
| 5325 | + $data .= __( 'WordPress Debug Mode', 'usces' ) . ' : ' . ( ( $environment['wp_debug_mode'] ) ? __( 'ON', 'usces' ) : __( 'OFF', 'usces' ) ) . "\r\n"; | |
| 5326 | + | |
| 5327 | + $data .= "\r\n" . '### ' . __( 'Theme', 'usces' ) . " ###\r\n\r\n"; | |
| 5328 | + $data .= __( 'Theme name', 'usces' ) . ' : ' . esc_html( $theme['name'] ) . "\r\n"; | |
| 5329 | + $data .= __( 'Theme version', 'usces' ) . ' : ' . esc_html( $theme['version'] ) . "\r\n"; | |
| 5330 | + $data .= __( 'Author URL', 'usces' ) . ' : ' . esc_html( $theme['author_url'] ) . "\r\n"; | |
| 5331 | + if ( isset( $theme['is_child_theme'] ) && $theme['is_child_theme'] ) { | |
| 5332 | + $data .= __( 'Parent theme name', 'usces' ) . ' : ' . esc_html( $theme['parent_name'] ) . "\r\n"; | |
| 5333 | + $data .= __( 'Parent theme version', 'usces' ) . ' : ' . esc_html( $theme['parent_version'] ) . "\r\n"; | |
| 5334 | + $data .= __( 'Parent author URL', 'usces' ) . ' : ' . esc_html( $theme['parent_author_url'] ) . "\r\n"; | |
| 5335 | + } | |
| 5336 | + | |
| 5337 | + $data .= "\r\n" . '### ' . __( 'Active Plugins', 'usces' ) . " ###\r\n\r\n"; | |
| 5338 | + foreach ( $active_plugins as $plugin ) { | |
| 5339 | + $data .= esc_html( $plugin['name'] ) . ' : ' . __( 'by', 'usces' ) . ' ' . esc_html( $plugin['author_name'] ) . ' - ' . esc_html( $plugin['version'] ) . | |
| 5340 | + esc_html( ( $plugin['version'] != $plugin['version_latest'] ) ? sprintf( __( '( Update to version %1$s is available. )', 'usces' ), $plugin['version_latest'] ) : '' ) . "\r\n"; | |
| 5341 | + } | |
| 5342 | + | |
| 5343 | + $data .= "\r\n" . '### ' . __( 'Inactive Plugins', 'usces' ) . " ###\r\n\r\n"; | |
| 5344 | + foreach ( $inactive_plugins as $plugin ) { | |
| 5345 | + $data .= esc_html( $plugin['name'] ) . ' : ' . __( 'by', 'usces' ) . ' ' . esc_html( $plugin['author_name'] ) . ' - ' . esc_html( $plugin['version'] ) . | |
| 5346 | + esc_html( ( $plugin['version'] != $plugin['version_latest'] ) ? sprintf( __( '( Update to version %1$s is available. )', 'usces' ), $plugin['version_latest'] ) : '' ) . "\r\n"; | |
| 5347 | + } | |
| 5348 | + $data .= "\r\n" . '### ' . __( 'General Setting', 'usces' ) . " ###\r\n\r\n"; | |
| 5349 | + $data .= __( 'Welcart Version', 'usces' ) . ' : ' . esc_html( $welcart_information['version'] ) . "\r\n"; | |
| 5350 | + $data .= __( 'number of item', 'usces' ) . ' : ' . esc_html( $welcart_information['total_items'] ) . "\r\n"; | |
| 5351 | + $data .= __( 'SKU total number', 'usces' ) . ' : ' . esc_html( $welcart_information['total_sku'] ) . "\r\n"; | |
| 5352 | + $data .= __( 'Display mode', 'usces' ) . ' : ' . ( ( $welcart_information['maintenance_mode'] ) ? __( 'Under Maintenance', 'usces' ) : __( 'Normal business', 'usces' ) ) . "\r\n"; | |
| 5353 | + $data .= __( 'Campaign Schedule', 'usces' ) . ' : ' . __( 'starting time', 'usces' ) . ': '; | |
| 5354 | + foreach ( $welcart_information['campaign_schedule']['start'] as $key => $value ) { | |
| 5355 | + $data .= esc_html( $value ) . ' ' . __( $key, 'usces' ); | |
| 5356 | + } | |
| 5357 | + $data .= '. ' . __( 'date and time of termination', 'usces' ) . ': '; | |
| 5358 | + foreach ( $welcart_information['campaign_schedule']['end'] as $key => $value ) { | |
| 5359 | + $data .= esc_html( $value ) . ' ' . __( $key, 'usces' ) . ' '; | |
| 5360 | + } | |
| 5361 | + $data .= "\r\n"; | |
| 5362 | + | |
| 5363 | + $data .= __( 'E-mail address for ordering', 'usces' ) . ' : ' . esc_html( $welcart_information['order_mail'] ) . "\r\n"; | |
| 5364 | + $data .= __( 'Sender\'s e-mail address', 'usces' ) . ' : ' . esc_html( $welcart_information['sender_mail'] ) . "\r\n"; | |
| 5365 | + $data .= __( 'Conditions for free shipping', 'usces' ) . ' : ' . ( ( ! empty( $welcart_information['postage_privilege'] ) ) ? esc_html( $welcart_information['postage_privilege'] ) . __( 'Above', 'usces' ) : '' ) . "\r\n"; | |
| 5366 | + $data .= __( 'default limitation number of purchase', 'usces' ) . ' : ' . ( ( ! empty( $welcart_information['purchase_limit'] ) ) ? esc_html( $welcart_information['purchase_limit'] ) . __( 'maximum amount', 'usces' ) : '' ) . "\r\n"; | |
| 5367 | + $data .= __( 'initial value of date of sending out.', 'usces' ) . ' : ' . ( ( isset( $welcart_information['shipping_rule_text'][ $welcart_information['shipping_rule'] ] ) ) ? esc_html( $welcart_information['shipping_rule_text'][ $welcart_information['shipping_rule'] ] ) : '' ) . "\r\n"; | |
| 5368 | + $data .= __( 'Tax treatment', 'usces' ) . ' : ' . ( ( $welcart_information['tax_mode'] == 'include' ) ? __( 'Included', 'usces' ) : __( 'Excluded', 'usces' ) ) . "\r\n"; | |
| 5369 | + $data .= __( 'Tax target', 'usces' ) . ' : ' . ( ( $welcart_information['tax_target'] == 'products' ) ? __( 'Only Products', 'usces' ) : __( 'All Amount', 'usces' ) ) . "\r\n"; | |
| 5370 | + $data .= __( 'Applicable tax rate', 'usces' ) . ' : ' . ( ( $welcart_information['applicable_taxrate'] == 'standard' ) ? __( 'Standard tax rate', 'usces' ) : __( 'Reduced tax rate', 'usces' ) ) . "\r\n"; | |
| 5371 | + $data .= __( 'Percentage of Consumption tax', 'usces' ) . ' : ' . esc_html( ucfirst( $welcart_information['tax_rate'] ) ) . ' %' . "\r\n"; | |
| 5372 | + $data .= __( 'Reduced tax rate', 'usces' ) . ' : ' . esc_html( $welcart_information['reduced_tax_rate'] ) . ' %' . "\r\n"; | |
| 5373 | + $data .= __( 'method of Calculation of the tax', 'usces' ) . ' : '; | |
| 5374 | + switch ( $welcart_information['tax_method'] ) { | |
| 5375 | + case 'cutting': | |
| 5376 | + $data .= __( 'drop fractions', 'usces' ) . "\r\n"; | |
| 5377 | + break; | |
| 5378 | + case 'bring': | |
| 5379 | + $data .= __( 'raise to a unit', 'usces' ) . "\r\n"; | |
| 5380 | + break; | |
| 5381 | + case 'rounding': | |
| 5382 | + $data .= __( 'round up numbers of five and above and round down anything under', 'usces' ) . "\r\n"; | |
| 5383 | + break; | |
| 5384 | + default: | |
| 5385 | + break; | |
| 5386 | + } | |
| 5387 | + | |
| 5388 | + $data .= __( 'Subject to fees', 'usces' ) . ' : ' . ( ( $welcart_information['fee_subject'] == 'products' ) ? __( 'Only Products', 'usces' ) : __( 'All Amount', 'usces' ) ) . "\r\n"; | |
| 5389 | + $data .= __( 'membership syetem', 'usces' ) . ' : ' . ( ( $welcart_information['membership_system'] == 'activate' ) ? __( 'to use', 'usces' ) : __( 'not to use', 'usces' ) ) . "\r\n"; | |
| 5390 | + $data .= __( 'membership points', 'usces' ) . ' : ' . ( ( $welcart_information['membership_point'] == 'activate' ) ? __( 'to grant', 'usces' ) : __( 'not to grant', 'usces' ) ) . "\r\n"; | |
| 5391 | + $data .= __( 'Areas of Point Redemption', 'usces' ) . ' : ' . ( ( $welcart_information['point_coverage'] ) ? __( 'Applicable to Total Merchandise Price and Handling Fee', 'usces' ) : __( 'Limited Only to Total Merchandise Price', 'usces' ) ) . "\r\n"; | |
| 5392 | + $data .= __( 'Timing point of grant', 'usces' ) . ' : ' . ( ( $welcart_information['point_assign'] ) ? __( 'Payment at the time', 'usces' ) : __( 'Immediately', 'usces' ) ) . "\r\n"; | |
| 5393 | + | |
| 5394 | + $data .= "\r\n" . '### ' . __( 'payment method', 'usces' ) . " ###\r\n\r\n"; | |
| 5395 | + foreach ( $welcart_information['payment_methods'] as $payment ) { | |
| 5396 | + $data .= esc_html( $payment['name'] ) . ' - ' . ( ( isset( $welcart_information['payment_structure'][ $payment['settlement'] ] ) ) ? ( esc_html( $welcart_information['payment_structure'][ $payment['settlement'] ] ) ) : '' ) . ' - ' . ( ( $payment['use'] == 'activate' ) ? __( 'Activate', 'usces' ) : __( 'Deactivate', 'usces' ) ) . "\r\n"; | |
| 5397 | + } | |
| 5398 | + | |
| 5399 | + $data .= "\r\n" . '### ' . __( 'Common Options', 'usces' ) . " ###\r\n\r\n"; | |
| 5400 | + foreach ( $welcart_information['common_options'] as $common_options ) { | |
| 5401 | + $data .= __( 'option name', 'usces' ) . ' : ' . esc_html( $common_options['name'] ) . "\r\n"; | |
| 5402 | + $data .= __( 'selected amount', 'usces' ) . ' : ' . ( str_replace( "\n", ' ', $common_options['value'] ) ) . "\r\n"; | |
| 5403 | + $data .= __( 'Type of option', 'usces' ) . ' : ' . esc_html( ( isset( $welcart_information['common_options_type'][ $common_options['means'] ] ) ) ? ( esc_html( $welcart_information['common_options_type'][ $common_options['means'] ] ) ) : '' ) . "\r\n"; | |
| 5404 | + $data .= __( 'Required', 'usces' ) . ' : ' . ( ( 1 === (int) $common_options['essential'] ) ? __( 'Essential', 'usces' ) : '' ) . "\r\n\r\n"; | |
| 5405 | + } | |
| 5406 | + | |
| 5407 | + $data .= "\r\n" . '### ' . __( 'shipping option', 'usces' ) . " ###\r\n\r\n"; | |
| 5408 | + foreach ( $welcart_information['shipping_methods'] as $shipping ) { | |
| 5409 | + $charge = ''; | |
| 5410 | + $delivery_day = ''; | |
| 5411 | + if ( -1 === $shipping['charge'] ) { | |
| 5412 | + $charge = esc_html__( 'Not fixing shipping.', 'usces' ); | |
| 5413 | + } else { | |
| 5414 | + foreach ( $welcart_information['shipping_charge'] as $shipping_charge ) { | |
| 5415 | + if ( $shipping['charge'] == $shipping_charge['id'] ) { | |
| 5416 | + $charge = $shipping_charge['name']; | |
| 5417 | + break; | |
| 5418 | + } | |
| 5419 | + } | |
| 5420 | + } | |
| 5421 | + if ( -1 === $shipping['days'] ) { | |
| 5422 | + $delivery_day = esc_html__( 'Delivery Date Not Specified', 'usces' ); | |
| 5423 | + } else { | |
| 5424 | + foreach ( $welcart_information['delivery_days'] as $day ) { | |
| 5425 | + if ( $shipping['days'] == $day['id'] ) { | |
| 5426 | + $delivery_day = $day['name']; | |
| 5427 | + break; | |
| 5428 | + } | |
| 5429 | + } | |
| 5430 | + } | |
| 5431 | + $data .= esc_html( $shipping['name'] ) . ' - ' . ( str_replace( "\n", ' ', $shipping['time'] ) ) . ' - ' . ( ( $shipping['intl'] ) ? __( 'International Shipment', 'usces' ) : __( 'Domestic Shipment', 'usces' ) ) . ' - '; | |
| 5432 | + $data .= esc_html( $charge ) . ' - ' . esc_html( $delivery_day ) . ( ( $shipping['nocod'] ) ? ' - ' . __( 'No COD', 'usces' ) : '' ) . "\r\n"; | |
| 5433 | + } | |
| 5434 | + | |
| 5435 | + $data .= "\r\n" . '### ' . __( 'Shipping', 'usces' ) . " ###\r\n\r\n"; | |
| 5436 | + foreach ( $welcart_information['shipping_charge'] as $shipping_charge ) { | |
| 5437 | + $data .= esc_html( $shipping_charge['name'] ) . "\r\n"; | |
| 5438 | + } | |
| 5439 | + | |
| 5440 | + $data .= "\r\n" . '### ' . __( 'Mail Options', 'usces' ) . " ###\r\n\r\n"; | |
| 5441 | + $data .= __( 'New sign-in completion email', 'usces' ) . ' : ' . ( ( $welcart_information['newmem_admin_mail'] ) ? __( 'Send', 'usces' ) : __( 'Don\'t send', 'usces' ) ) . "\r\n"; | |
| 5442 | + $data .= __( 'Member update completion email to admin', 'usces' ) . ' : ' . ( ( $welcart_information['updmem_admin_mail'] ) ? __( 'Send', 'usces' ) : __( 'Don\'t send', 'usces' ) ) . "\r\n"; | |
| 5443 | + $data .= __( 'Member update completion email to customer', 'usces' ) . ' : ' . ( ( $welcart_information['updmem_customer_mail'] ) ? __( 'Send', 'usces' ) : __( 'Don\'t send', 'usces' ) ) . "\r\n"; | |
| 5444 | + $data .= __( 'Member removal completion email to admin', 'usces' ) . ' : ' . ( ( $welcart_information['delmem_admin_mail'] ) ? __( 'Send', 'usces' ) : __( 'Don\'t send', 'usces' ) ) . "\r\n"; | |
| 5445 | + $data .= __( 'Member removal completion email to customer', 'usces' ) . ' : ' . ( ( $welcart_information['delmem_customer_mail'] ) ? __( 'Send', 'usces' ) : __( 'Don\'t send', 'usces' ) ) . "\r\n"; | |
| 5446 | + $data .= __( 'Customer name', 'usces' ) . ' : ' . ( ( $welcart_information['put_customer_name'] ) ? __( 'Indication', 'usces' ) : __( 'Non-indication', 'usces' ) ) . "\r\n"; | |
| 5447 | + $data .= __( 'Attachment file for administrator email', 'usces' ) . ' : ' . ( ( $welcart_information['email_attach_feature'] ) ? __( 'Use', 'usces' ) : __( 'Do not Use', 'usces' ) ) . "\r\n"; | |
| 5448 | + if ( $welcart_information['email_attach_feature'] ) { | |
| 5449 | + $data .= __( 'Extensions of attachments', 'usces' ) . ' : ' . esc_html( $welcart_information['email_attach_file_extension'] ) . "\r\n"; | |
| 5450 | + $data .= __( 'Maximum size of email attachment', 'usces' ) . ' : ' . esc_html( $welcart_information['email_attach_file_size'] ) . " Mb\r\n"; | |
| 5451 | + } | |
| 5452 | + $data .= __( 'HTML mail format', 'usces' ) . ' : ' . ( ( $welcart_information['add_html_email_option'] ) ? __( 'Use', 'usces' ) : __( 'Do not Use', 'usces' ) ) . "\r\n"; | |
| 5453 | + | |
| 5454 | + $data .= "\r\n" . '### ' . __( 'Rule of the column for a item name', 'usces' ) . " ###\r\n\r\n"; | |
| 5455 | + foreach ( $welcart_information['indi_item_name'] as $key => $value ) { | |
| 5456 | + $data .= __( "Indication of {$welcart_information['indi_item_name_text'][ $key ]}", 'usces' ) . ' : ' . ( ( $value ) ? __( 'Show', 'usces' ) : '' ) . "\r\n"; | |
| 5457 | + $data .= __( "Position of {$welcart_information['indi_item_name_text'][ $key ]}", 'usces' ) . ' : ' . esc_html( $welcart_information['pos_item_name'][ $key ] ) . "\r\n"; | |
| 5458 | + } | |
| 5459 | + $data .= "\r\n" . '### ' . __( 'System Setting', 'usces' ) . " ###\r\n\r\n"; | |
| 5460 | + $data .= __( 'Display Modes', 'usces' ) . ' : ' . ( ( $welcart_information['divide_item'] ) ? __( 'Not display an article in blog', 'usces' ) : '' ) . "\r\n"; | |
| 5461 | + $data .= __( 'rel attribute', 'usces' ) . ' : ' . ( ( $welcart_information['itemimg_anchor_rel'] ) ? $welcart_information['itemimg_anchor_rel'] : '' ) . "\r\n"; | |
| 5462 | + $data .= __( 'compound category sort item', 'usces' ) . ' : ' . ( ( 'name' == $welcart_information['fukugo_category_orderby'] ) ? __( 'category name', 'usces' ) : __( 'category ID', 'usces' ) ) . "\r\n"; | |
| 5463 | + $data .= __( 'compound category sort order', 'usces' ) . ' : ' . ( ( 'DESC' == $welcart_information['fukugo_category_order'] ) ? __( 'Descendin', 'usces' ) : __( 'Ascending', 'usces' ) ) . "\r\n"; | |
| 5464 | + $data .= __( 'Switching SSL', 'usces' ) . ' : ' . ( ( $welcart_information['use_ssl'] ) ? __( 'Switching', 'usces' ) : '' ) . "\r\n"; | |
| 5465 | + $data .= __( 'The page_id of the inquiry-form', 'usces' ) . ' : ' . esc_html( $welcart_information['inquiry_id'] ) . "\r\n"; | |
| 5466 | + $data .= __( 'To disable usces_cart.css', 'usces' ) . ' : ' . ( ( $welcart_information['no_cart_css'] ) ? __( 'To disable', 'usces' ) : '' ) . "\r\n"; | |
| 5467 | + $data .= __( 'Product sub-image rule', 'usces' ) . ' : ' . ( ( $welcart_information['subimage_rule'] ) ? __( 'Put two _ (underscores) between the product code and the sequential number', 'usces' ) : __( 'Product Code Forward Matching', 'usces' ) ) . "\r\n"; | |
| 5468 | + $data .= __( 'Described method of invoice', 'usces' ) . ' : ' . ( ( $welcart_information['pdf_delivery'] ) ? __( 'To address the shipping information', 'usces' ) : __( 'To address the purchaser information', 'usces' ) ) . "\r\n"; | |
| 5469 | + $data .= __( 'Character code in the CSV file', 'usces' ) . ' : ' . ( ( $welcart_information['csv_encode_type'] ) ? __( 'UTF-8', 'usces' ) : __( 'Shift_JIS', 'usces' ) ) . "\r\n"; | |
| 5470 | + $data .= __( "'Category' of CSV product data file", 'usces' ) . ' : ' . ( ( $welcart_information['csv_category_format'] ) ? __( 'slug (slug)', 'usces' ) : __( 'ID (tag_ID)', 'usces' ) ) . "\r\n"; | |
| 5471 | + $data .= __( 'Order data re-created from the settlement log', 'usces' ) . ' : ' . ( ( $welcart_information['settlement_backup'] ) ? __( 'Use', 'usces' ) : __( 'Do not Use', 'usces' ) ) . "\r\n"; | |
| 5472 | + $data .= __( 'Settlement error message', 'usces' ) . ' : ' . ( ( $welcart_information['settlement_notice'] ) ? __( 'Display', 'usces' ) : __( 'Do not display', 'usces' ) ) . "\r\n"; | |
| 5473 | + $data .= __( 'The language of the front-end', 'usces' ) . ' : ' . esc_html( $welcart_information['front_lang'] ) . "\r\n"; | |
| 5474 | + $data .= __( 'Currencies', 'usces' ) . ' : ' . ( ( isset( $welcart_information['country'][ $welcart_information['currency'] ] ) ) ? esc_html( $welcart_information['country'][ $welcart_information['currency'] ] ) : esc_html( $welcart_information['currency'] ) ) . "\r\n"; | |
| 5475 | + $data .= __( 'The name and address form', 'usces' ) . ' : ' . ( ( isset( $welcart_information['country'][ $welcart_information['addressform'] ] ) ) ? esc_html( $welcart_information['country'][ $welcart_information['addressform'] ] ) : esc_html( $welcart_information['currency'] ) ) . "\r\n"; | |
| 5476 | + | |
| 5477 | + $target_market_country = array(); | |
| 5478 | + foreach ( $welcart_information['target_market'] as $key => $value ) { | |
| 5479 | + if ( isset( $welcart_information['country'][ $value ] ) ) { | |
| 5480 | + $target_market_country[] = $welcart_information['country'][ $value ]; | |
| 5481 | + } | |
| 5482 | + } | |
| 5483 | + $data .= __( 'Target Market', 'usces' ) . ' : ' . esc_html( implode( ', ', $target_market_country ) ) . "\r\n"; | |
| 5484 | + | |
| 5485 | + $data .= "\r\n" . '### ' . __( 'System extension', 'usces' ) . " ###\r\n\r\n"; | |
| 5486 | + $data .= __( 'Ganbare Tencho', 'usces' ) . ' : ' . ( ( $welcart_information['ganbare_activate_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5487 | + $data .= __( 'Linkage Order Upadate', 'usces' ) . ' : ' . ( ( $welcart_information['stocklink_orderedit_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5488 | + $data .= __( 'Linkage Order Collective Upadate', 'usces' ) . ' : ' . ( ( $welcart_information['stocklink_collective_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5489 | + $data .= __( '[New] Order List', 'usces' ) . ' : ' . ( ( $welcart_information['datalistup_orderlist_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5490 | + $data .= __( '[New] Member List', 'usces' ) . ' : ' . ( ( $welcart_information['datalistup_memberlist_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5491 | + $data .= __( 'Email verification for new registration', 'usces' ) . ' : ' . ( ( $welcart_information['verifyemail_switch_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5492 | + $data .= __( 'Email verification for editing information', 'usces' ) . ' : ' . ( ( $welcart_information['verifyemail_edit_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5493 | + $data .= __( 'Login Notification', 'usces' ) . ' : ' . ( ( $welcart_information['verifyemail_login_notify'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5494 | + $data .= __( 'Google reCAPTCHA v3', 'usces' ) . ' : ' . ( ( $welcart_information['google_recaptcha_status'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5495 | + $data .= __( 'Brute-force attack countermeasures', 'usces' ) . ' : ' . ( ( $welcart_information['brute_force_status'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5496 | + $data .= __( 'Structured data measures', 'usces' ) . ' : ' . ( ( $welcart_information['structured_data_product_status'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5497 | + $data .= __( 'New product image registration', 'usces' ) . ' : ' . ( ( $welcart_information['newproductimage_switch_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5498 | + $data .= __( 'Operation Log', 'usces' ) . ' : ' . ( ( $welcart_information['operation_log_switch_flag'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5499 | + $data .= __( 'Credit Card Security Measures', 'usces' ) . ' : ' . ( ( $welcart_information['credit_security'] ) ? __( 'Enabled', 'usces' ) : __( 'Disabled', 'usces' ) ) . "\r\n"; | |
| 5500 | + | |
| 5501 | + $data .= "\r\n" . '### ' . __( 'Settlement Setting', 'usces' ) . " ###\r\n\r\n"; | |
| 5502 | + $settlement_selected_text = array(); | |
| 5503 | + if ( is_array( $welcart_information['settlement_selected'] ) ) { | |
| 5504 | + foreach ( $welcart_information['settlement_selected'] as $key => $value ) { | |
| 5505 | + if ( isset( $welcart_information['available_settlement'][ $value ] ) ) { | |
| 5506 | + $settlement_selected_text[] = esc_html__( $welcart_information['available_settlement'][ $value ], 'usces' ); | |
| 5507 | + } | |
| 5508 | + } | |
| 5509 | + } | |
| 5510 | + $data .= __( 'Settlement modules in use', 'usces' ) . ' : ' . esc_html( implode( ', ', $settlement_selected_text ) ) . "\r\n"; | |
| 5511 | + | |
| 5512 | + $data .= "\r\n" . '### ' . __( 'Management Information', 'usces' ) . " ###\r\n\r\n"; | |
| 5513 | + $data .= __( 'Number of orders', 'usces' ) . ' : ' . esc_html( $welcart_information['number_of_orders'] ) . "\r\n"; | |
| 5514 | + $data .= __( 'Number of members', 'usces' ) . ' : ' . esc_html( $welcart_information['number_of_members'] ) . "\r\n"; | |
| 5515 | + | |
| 5516 | + $data .= "\r\n" . '### ' . __( 'Server environment', 'usces' ) . " ###\r\n\r\n"; | |
| 5517 | + $data .= __( 'Server', 'usces' ) . ' : ' . esc_html( $environment['server'] ) . "\r\n"; | |
| 5518 | + $data .= __( 'PHP version', 'usces' ) . ' : ' . esc_html( $environment['php_version'] ) . "\r\n"; | |
| 5519 | + $data .= __( 'PHP global memory', 'usces' ) . ' : ' . esc_html( $ini_confs['memory_limit']['global_value'] ) . "\r\n"; | |
| 5520 | + $data .= __( 'PHP locale memory', 'usces' ) . ' : ' . esc_html( $ini_confs['memory_limit']['local_value'] ) . "\r\n"; | |
| 5521 | + $data .= __( 'PHP post max size', 'usces' ) . ' : ' . esc_html( $environment['php_post_max_size'] ) . "\r\n"; | |
| 5522 | + $data .= __( 'PHP time limit', 'usces' ) . ' : ' . esc_html( $environment['php_max_execution_time'] ) . "\r\n"; | |
| 5523 | + $data .= __( 'PHP Max Input Vars', 'usces' ) . ' : ' . esc_html( $environment['php_max_input_vars'] ) . "\r\n"; | |
| 5524 | + $data .= __( 'cURL', 'usces' ) . ' : ' . ( in_array( 'curl', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5525 | + $data .= __( 'cURL version', 'usces' ) . ' : ' . ( esc_html( $environment['curl_version']['version'] . ' ' . $environment['curl_version']['host'] ) ) . "\r\n"; | |
| 5526 | + $data .= __( 'MySQL version', 'usces' ) . ' : ' . esc_html( $environment['mysql_version'] ) . "\r\n"; | |
| 5527 | + $data .= __( 'Maximum upload size', 'usces' ) . ' : ' . esc_html( $environment['upload_max_filesize'] ) . "\r\n"; | |
| 5528 | + $data .= __( 'SimpleXML', 'usces' ) . ' : ' . ( in_array( 'SimpleXML', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5529 | + $data .= __( 'gd', 'usces' ) . ' : ' . ( in_array( 'gd', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5530 | + $data .= __( 'json', 'usces' ) . ' : ' . ( in_array( 'json', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5531 | + $data .= __( 'mbstring', 'usces' ) . ' : ' . ( in_array( 'mbstring', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5532 | + $data .= __( 'openssl', 'usces' ) . ' : ' . ( in_array( 'openssl', $loaded_extensions ) ? 'ON' : '-' ) . "\r\n"; | |
| 5533 | + | |
| 5534 | + return $data; | |
| 5535 | +} | |
| 5536 | + | |
| 5537 | +function usces_download_system_information() { | |
| 5538 | + | |
| 5539 | + check_ajax_referer( 'admin_system' ); | |
| 5540 | + if ( ! current_user_can( 'wel_manage_setting' ) ) { | |
| 5541 | + wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
| 5542 | + } | |
| 5543 | + | |
| 5544 | + $filename = 'welcart_information_' . date_i18n( 'YmdHis' ) . '.txt'; | |
| 5545 | + $wp_environment = usces_get_wp_environment(); | |
| 5546 | + $environment = $wp_environment['environment']; | |
| 5547 | + $theme = $wp_environment['theme']; | |
| 5548 | + $active_plugins = $wp_environment['active_plugins']; | |
| 5549 | + $inactive_plugins = $wp_environment['inactive_plugins']; | |
| 5550 | + $welcart_information = get_welcart_system_information(); | |
| 5551 | + $loaded_extensions = get_loaded_extensions(); | |
| 5552 | + $ini_confs = ini_get_all(); | |
| 5553 | + $data = usces_generate_system_information_text( $environment, $theme, $active_plugins, $inactive_plugins, $welcart_information, $loaded_extensions, $ini_confs ); | |
| 5554 | + $result = array( | |
| 5555 | + 'status' => true, | |
| 5556 | + 'data' => $data, | |
| 5557 | + 'filename' => $filename, | |
| 5558 | + ); | |
| 5559 | + echo json_encode( $result ); | |
| 5560 | + wp_die(); | |
| 5561 | +} | |
| 5562 | + | |
| 5563 | +/** | |
| 5564 | + * List Download Authority. | |
| 5565 | + * | |
| 5566 | + * @return boolean | |
| 5567 | + */ | |
| 5568 | +function usces_admin_user_can_download_list() { | |
| 5569 | + $admin_user = array( 'administrator', 'wc_management' ); | |
| 5570 | + $custom_user = apply_filters( 'usces_filter_admin_user_can_download_list', array() ); | |
| 5571 | + if ( is_array( $custom_user ) && ! empty( $custom_user ) ) { | |
| 5572 | + $admin_user = array_merge( $admin_user, $custom_user ); | |
| 5573 | + } | |
| 5574 | + $can_dl = false; | |
| 5575 | + foreach ( $admin_user as $user ) { | |
| 5576 | + if ( current_user_can( $user ) ) { | |
| 5577 | + $can_dl = true; | |
| 5578 | + break; | |
| 5579 | + } | |
| 5580 | + } | |
| 5581 | + return $can_dl; | |
| 5582 | +} | |
| 5583 | + | |
| 5584 | +/** | |
| 5585 | + * Filter content wp_editor preview. | |
| 5586 | + */ | |
| 5587 | +function usces_filter_content_wp_editor_preview() { | |
| 5588 | + global $usces; | |
| 5589 | + | |
| 5590 | + $_POST = $usces->stripslashes_deep_post( $_POST ); | |
| 5591 | + | |
| 5592 | + if ( ! current_user_can( 'wel_manage_order' ) ) { // This preview is also used in order_edit_form. | |
| 5593 | + wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
| 5594 | + } | |
| 5595 | + | |
| 5596 | + $nonce = isset( $_POST['wc_nonce'] ) ? wp_unslash( $_POST['wc_nonce'] ) : ''; | |
| 5597 | + if ( ! wp_verify_nonce( $nonce, 'wc_preview_editor_nonce' ) ) { | |
| 5598 | + $error_msg = array( 'message' => 'Your request is not valid.' ); | |
| 5599 | + wp_send_json_error( $error_msg, 403 ); | |
| 5600 | + } | |
| 5601 | + $mode = $_POST['mode']; | |
| 5602 | + $res = array( | |
| 5603 | + 'status' => false, | |
| 5604 | + ); | |
| 5605 | + switch ( $mode ) { | |
| 5606 | + case 'preview_email': | |
| 5607 | + $content_header = isset( $_POST['content_header'] ) ? $_POST['content_header'] : ''; | |
| 5608 | + $content_footer = isset( $_POST['content_footer'] ) ? $_POST['content_footer'] : ''; | |
| 5609 | + $res['status'] = true; | |
| 5610 | + $res['content_header'] = wpautop( $content_header ); | |
| 5611 | + $res['content_footer'] = wpautop( $content_footer ); | |
| 5612 | + break; | |
| 5613 | + case 'preview_email_order_detail': | |
| 5614 | + $content = isset( $_POST['content'] ) ? $_POST['content'] : ''; | |
| 5615 | + $res['status'] = true; | |
| 5616 | + $res['content'] = wpautop( wp_kses_post( $content ) ); | |
| 5617 | + break; | |
| 5618 | + } | |
| 5619 | + wp_send_json( $res ); | |
| 5620 | +} | |
| 5621 | + | |
| 5622 | +/** | |
| 5623 | + * 手数料対象金額 | |
| 5624 | + * -'all' 送料を含む全額 | |
| 5625 | + * -'products' 商品代金のみ | |
| 5626 | + * | |
| 5627 | + * @return string | |
| 5628 | + */ | |
| 5629 | +function usces_is_fee_subject() { | |
| 5630 | + global $usces; | |
| 5631 | + $fee_subject = ( ! empty( $usces->options['fee_subject'] ) ) ? $usces->options['fee_subject'] : 'all'; | |
| 5632 | + return $fee_subject; | |
| 5633 | +} | |