| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Welcart Main Class
|
| 4 |
*
|
| 5 |
* @package Welcart
|
| 6 |
*/
|
| 7 |
class usc_e_shop {
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Page action.
|
| 11 |
*
|
| 12 |
* @var string
|
| 13 |
*/
|
| 14 |
public $page;
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Cart object.
|
| 18 |
*
|
| 19 |
* @var array
|
| 20 |
*/
|
| 21 |
public $cart;
|
| 22 |
|
| 23 |
/**
|
| 24 |
* SSL flag.
|
| 25 |
*
|
| 26 |
* @var int
|
| 27 |
*/
|
| 28 |
public $use_ssl;
|
| 29 |
|
| 30 |
public $action;
|
| 31 |
public $action_status;
|
| 32 |
public $error_status;
|
| 33 |
public $action_message;
|
| 34 |
public $error_message;
|
| 35 |
public $itemskus;
|
| 36 |
public $itemsku;
|
| 37 |
public $current_itemsku;
|
| 38 |
public $itemopts;
|
| 39 |
public $itemopt;
|
| 40 |
public $current_itemopt;
|
| 41 |
public $item;
|
| 42 |
public $zaiko_status;
|
| 43 |
public $payment_structure;
|
| 44 |
public $display_mode;
|
| 45 |
public $shipping_rule;
|
| 46 |
public $nonacting_settlements;
|
| 47 |
public $member_status;
|
| 48 |
public $options;
|
| 49 |
public $mail_para;
|
| 50 |
public $login_mail;
|
| 51 |
public $current_member;
|
| 52 |
public $member_form;
|
| 53 |
public $payment_results;
|
| 54 |
public $log_flg;
|
| 55 |
public $delim;
|
| 56 |
public $use_js;
|
| 57 |
public $user_level;
|
| 58 |
public $previous_url;
|
| 59 |
|
| 60 |
/**
|
| 61 |
* PayPal object.
|
| 62 |
*
|
| 63 |
* @var object
|
| 64 |
*/
|
| 65 |
public $paypal;
|
| 66 |
|
| 67 |
/**
|
| 68 |
* Settlement object.
|
| 69 |
*
|
| 70 |
* @var array
|
| 71 |
*/
|
| 72 |
public $settlement;
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Settlement notice.
|
| 76 |
*
|
| 77 |
* @var string
|
| 78 |
*/
|
| 79 |
public $settlement_notice;
|
| 80 |
|
| 81 |
/**
|
| 82 |
* Cart object for Multiple Shipping.
|
| 83 |
*
|
| 84 |
* @var array
|
| 85 |
*/
|
| 86 |
public $msacart;
|
| 87 |
|
| 88 |
/**
|
| 89 |
* Constructor.
|
| 90 |
*/
|
| 91 |
public function __construct() {
|
| 92 |
global $wpdb, $post, $usces_settings, $usces_states;
|
| 93 |
|
| 94 |
usces_add_role();
|
| 95 |
usces_add_capabilites();
|
| 96 |
|
| 97 |
do_action( 'usces_construct' );
|
| 98 |
|
| 99 |
add_action( 'init', array( $this, 'init' ), 1 );
|
| 100 |
|
| 101 |
$locales = usces_locales();
|
| 102 |
foreach ( $locales as $l ) {
|
| 103 |
$usces_settings['language'][ $l ] = $l;
|
| 104 |
}
|
| 105 |
|
| 106 |
$this->options = get_option( 'usces', array() );
|
| 107 |
if ( ! isset( $this->options['smtp_hostname'] ) || empty( $this->options['smtp_hostname'] ) ) {
|
| 108 |
$this->options['smtp_hostname'] = 'localhost';
|
| 109 |
}
|
| 110 |
if ( ! isset( $this->options['delivery_method'] ) || ! is_array( $this->options['delivery_method'] ) ) {
|
| 111 |
$this->options['delivery_method'] = array();
|
| 112 |
}
|
| 113 |
if ( ! isset( $this->options['shipping_charge'] ) || ! is_array( $this->options['shipping_charge'] ) ) {
|
| 114 |
$this->options['shipping_charge'] = array();
|
| 115 |
}
|
| 116 |
if ( ! isset( $this->options['membersystem_state'] ) ) {
|
| 117 |
$this->options['membersystem_state'] = 'activate';
|
| 118 |
}
|
| 119 |
if ( ! isset( $this->options['membersystem_point'] ) ) {
|
| 120 |
$this->options['membersystem_point'] = 'activate';
|
| 121 |
}
|
| 122 |
if ( ! isset( $this->options['use_ssl'] ) ) {
|
| 123 |
$this->options['use_ssl'] = 0;
|
| 124 |
}
|
| 125 |
if ( ! isset( $this->options['point_coverage'] ) ) {
|
| 126 |
$this->options['point_coverage'] = 0;
|
| 127 |
}
|
| 128 |
if ( ! isset( $this->options['use_javascript'] ) ) {
|
| 129 |
$this->options['use_javascript'] = 1;
|
| 130 |
}
|
| 131 |
if ( ! isset( $this->options['privilege_discount'] ) ) {
|
| 132 |
$this->options['privilege_discount'] = '';
|
| 133 |
}
|
| 134 |
if ( ! isset( $this->options['privilege_point'] ) ) {
|
| 135 |
$this->options['privilege_point'] = '';
|
| 136 |
}
|
| 137 |
if ( ! isset( $this->options['campaign_privilege'] ) ) {
|
| 138 |
$this->options['campaign_privilege'] = '';
|
| 139 |
}
|
| 140 |
if ( ! isset( $this->options['campaign_category'] ) ) {
|
| 141 |
$this->options['campaign_category'] = 0;
|
| 142 |
}
|
| 143 |
if ( ! isset( $this->options['campaign_schedule']['start'] ) ) {
|
| 144 |
$this->options['campaign_schedule']['start'] = array();
|
| 145 |
}
|
| 146 |
if ( ! isset( $this->options['campaign_schedule']['end'] ) ) {
|
| 147 |
$this->options['campaign_schedule']['end'] = array();
|
| 148 |
}
|
| 149 |
if ( ! isset( $this->options['purchase_limit'] ) ) {
|
| 150 |
$this->options['purchase_limit'] = '';
|
| 151 |
}
|
| 152 |
if ( ! isset( $this->options['point_rate'] ) ) {
|
| 153 |
$this->options['point_rate'] = '';
|
| 154 |
}
|
| 155 |
if ( ! isset( $this->options['shipping_rule'] ) ) {
|
| 156 |
$this->options['shipping_rule'] = '';
|
| 157 |
}
|
| 158 |
if ( ! isset( $this->options['company_name'] ) ) {
|
| 159 |
$this->options['company_name'] = '';
|
| 160 |
}
|
| 161 |
if ( ! isset( $this->options['address1'] ) ) {
|
| 162 |
$this->options['address1'] = '';
|
| 163 |
}
|
| 164 |
if ( ! isset( $this->options['address2'] ) ) {
|
| 165 |
$this->options['address2'] = '';
|
| 166 |
}
|
| 167 |
if ( ! isset( $this->options['zip_code'] ) ) {
|
| 168 |
$this->options['zip_code'] = '';
|
| 169 |
}
|
| 170 |
if ( ! isset( $this->options['tel_number'] ) ) {
|
| 171 |
$this->options['tel_number'] = '';
|
| 172 |
}
|
| 173 |
if ( ! isset( $this->options['fax_number'] ) ) {
|
| 174 |
$this->options['fax_number'] = '';
|
| 175 |
}
|
| 176 |
if ( ! isset( $this->options['order_mail'] ) ) {
|
| 177 |
$this->options['order_mail'] = '';
|
| 178 |
}
|
| 179 |
if ( ! isset( $this->options['inquiry_mail'] ) ) {
|
| 180 |
$this->options['inquiry_mail'] = '';
|
| 181 |
}
|
| 182 |
if ( ! isset( $this->options['sender_mail'] ) ) {
|
| 183 |
$this->options['sender_mail'] = '';
|
| 184 |
}
|
| 185 |
if ( ! isset( $this->options['error_mail'] ) ) {
|
| 186 |
$this->options['error_mail'] = '';
|
| 187 |
}
|
| 188 |
if ( ! isset( $this->options['copyright'] ) ) {
|
| 189 |
$this->options['copyright'] = '';
|
| 190 |
}
|
| 191 |
if ( ! isset( $this->options['business_registration_number'] ) ) {
|
| 192 |
$this->options['business_registration_number'] = '';
|
| 193 |
}
|
| 194 |
if ( ! isset( $this->options['postage_privilege'] ) ) {
|
| 195 |
$this->options['postage_privilege'] = '';
|
| 196 |
}
|
| 197 |
if ( ! isset( $this->options['shipping_rule'] ) ) {
|
| 198 |
$this->options['shipping_rule'] = '';
|
| 199 |
}
|
| 200 |
if ( ! isset( $this->options['tax_display'] ) ) {
|
| 201 |
$this->options['tax_display'] = 'activate';
|
| 202 |
}
|
| 203 |
if ( ! isset( $this->options['applicable_taxrate'] ) || empty( $this->options['applicable_taxrate'] ) ) {
|
| 204 |
$this->options['applicable_taxrate'] = 'standard';
|
| 205 |
}
|
| 206 |
if ( ! isset( $this->options['tax_rate'] ) ) {
|
| 207 |
$this->options['tax_rate'] = '';
|
| 208 |
$this->options['tax_method'] = 'cutting';
|
| 209 |
$this->options['tax_mode'] = 'include';
|
| 210 |
$this->options['tax_target'] = 'products';
|
| 211 |
} else {
|
| 212 |
if ( ! isset( $this->options['tax_mode'] ) ) {
|
| 213 |
$this->options['tax_mode'] = empty( $this->options['tax_rate'] ) ? 'include' : 'exclude';
|
| 214 |
}
|
| 215 |
if ( ! isset( $this->options['tax_target'] ) ) {
|
| 216 |
$this->options['tax_target'] = 'all';
|
| 217 |
}
|
| 218 |
}
|
| 219 |
if ( ! isset( $this->options['tax_rate_reduced'] ) ) {
|
| 220 |
$this->options['tax_rate_reduced'] = '';
|
| 221 |
}
|
| 222 |
if ( ! isset( $this->options['transferee'] ) ) {
|
| 223 |
$this->options['transferee'] = '';
|
| 224 |
}
|
| 225 |
if ( ! isset( $this->options['tatransfer_limit'] ) ) {
|
| 226 |
$this->options['tatransfer_limit'] = '';
|
| 227 |
}
|
| 228 |
if ( ! isset( $this->options['membersystem_state'] ) ) {
|
| 229 |
$this->options['membersystem_state'] = 'activate';
|
| 230 |
}
|
| 231 |
if ( ! isset( $this->options['membersystem_point'] ) ) {
|
| 232 |
$this->options['membersystem_point'] = '';
|
| 233 |
}
|
| 234 |
if ( ! isset( $this->options['point_rate'] ) ) {
|
| 235 |
$this->options['point_rate'] = '';
|
| 236 |
}
|
| 237 |
if ( ! isset( $this->options['start_point'] ) ) {
|
| 238 |
$this->options['start_point'] = '';
|
| 239 |
}
|
| 240 |
if ( ! isset( $this->options['point_coverage'] ) ) {
|
| 241 |
$this->options['point_coverage'] = 1;
|
| 242 |
}
|
| 243 |
if ( ! isset( $this->options['point_assign'] ) ) {
|
| 244 |
$this->options['point_assign'] = 1;
|
| 245 |
}
|
| 246 |
if ( ! isset( $this->options['cod_type'] ) ) {
|
| 247 |
$this->options['cod_type'] = 'fix';
|
| 248 |
}
|
| 249 |
if ( ! isset( $this->options['fee_subject'] ) ) {
|
| 250 |
$this->options['fee_subject'] = 'all';
|
| 251 |
}
|
| 252 |
if ( ! isset( $this->options['address_search'] ) ) {
|
| 253 |
$this->options['address_search'] = 'deactivate';
|
| 254 |
}
|
| 255 |
if ( ! isset( $this->options['newmem_admin_mail'] ) ) {
|
| 256 |
$this->options['newmem_admin_mail'] = 0;
|
| 257 |
}
|
| 258 |
if ( ! isset( $this->options['updmem_admin_mail'] ) ) {
|
| 259 |
$this->options['updmem_admin_mail'] = 0;
|
| 260 |
}
|
| 261 |
if ( ! isset( $this->options['updmem_customer_mail'] ) ) {
|
| 262 |
$this->options['updmem_customer_mail'] = 0;
|
| 263 |
}
|
| 264 |
if ( ! isset( $this->options['delmem_admin_mail'] ) ) {
|
| 265 |
$this->options['delmem_admin_mail'] = 1;
|
| 266 |
}
|
| 267 |
if ( ! isset( $this->options['delmem_customer_mail'] ) ) {
|
| 268 |
$this->options['delmem_customer_mail'] = 1;
|
| 269 |
}
|
| 270 |
if ( ! isset( $this->options['put_customer_name'] ) ) {
|
| 271 |
$this->options['put_customer_name'] = '0';
|
| 272 |
}
|
| 273 |
if ( ! isset( $this->options['email_attach_feature'] ) ) {
|
| 274 |
$this->options['email_attach_feature'] = '0';
|
| 275 |
}
|
| 276 |
if ( ! isset( $this->options['email_attach_file_extension'] ) ) {
|
| 277 |
$this->options['email_attach_file_extension'] = 'jpg,png,pdf';
|
| 278 |
}
|
| 279 |
if ( ! isset( $this->options['email_attach_file_size'] ) ) {
|
| 280 |
$this->options['email_attach_file_size'] = 3;
|
| 281 |
}
|
| 282 |
if ( ! isset( $this->options['add_html_email_option'] ) ) {
|
| 283 |
$this->options['add_html_email_option'] = 0;
|
| 284 |
}
|
| 285 |
if ( ! isset( $this->options['mail_data']['title'] ) ) {
|
| 286 |
$this->options['mail_data']['title'] = array(
|
| 287 |
'thankyou' => '',
|
| 288 |
'order' => '',
|
| 289 |
'inquiry' => '',
|
| 290 |
'returninq' => '',
|
| 291 |
'membercomp' => '',
|
| 292 |
'completionmail' => '',
|
| 293 |
'ordermail' => '',
|
| 294 |
'changemail' => '',
|
| 295 |
'receiptmail' => '',
|
| 296 |
'mitumorimail' => '',
|
| 297 |
'cancelmail' => '',
|
| 298 |
'othermail' => '',
|
| 299 |
);
|
| 300 |
}
|
| 301 |
if ( ! isset( $this->options['mail_data']['header'] ) ) {
|
| 302 |
$this->options['mail_data']['header'] = array(
|
| 303 |
'thankyou' => '',
|
| 304 |
'order' => '',
|
| 305 |
'inquiry' => '',
|
| 306 |
'returninq' => '',
|
| 307 |
'membercomp' => '',
|
| 308 |
'completionmail' => '',
|
| 309 |
'ordermail' => '',
|
| 310 |
'changemail' => '',
|
| 311 |
'receiptmail' => '',
|
| 312 |
'mitumorimail' => '',
|
| 313 |
'cancelmail' => '',
|
| 314 |
'othermail' => '',
|
| 315 |
);
|
| 316 |
}
|
| 317 |
if ( ! isset( $this->options['mail_data']['footer'] ) ) {
|
| 318 |
$this->options['mail_data']['footer'] = array(
|
| 319 |
'thankyou' => '',
|
| 320 |
'order' => '',
|
| 321 |
'inquiry' => '',
|
| 322 |
'returninq' => '',
|
| 323 |
'membercomp' => '',
|
| 324 |
'completionmail' => '',
|
| 325 |
'ordermail' => '',
|
| 326 |
'changemail' => '',
|
| 327 |
'receiptmail' => '',
|
| 328 |
'mitumorimail' => '',
|
| 329 |
'cancelmail' => '',
|
| 330 |
'othermail' => '',
|
| 331 |
);
|
| 332 |
}
|
| 333 |
if ( ! isset( $this->options['cart_page_data']['header'] ) ) {
|
| 334 |
$this->options['cart_page_data']['header'] = array(
|
| 335 |
'cart' => '',
|
| 336 |
'customer' => '',
|
| 337 |
'delivery' => '',
|
| 338 |
'confirm' => '',
|
| 339 |
'completion' => '',
|
| 340 |
);
|
| 341 |
}
|
| 342 |
if ( ! isset( $this->options['cart_page_data']['footer'] ) ) {
|
| 343 |
$this->options['cart_page_data']['footer'] = array(
|
| 344 |
'cart' => '',
|
| 345 |
'customer' => '',
|
| 346 |
'delivery' => '',
|
| 347 |
'confirm' => '',
|
| 348 |
'completion' => '',
|
| 349 |
);
|
| 350 |
}
|
| 351 |
if ( ! isset( $this->options['cart_page_data']['confirm_notes'] ) ) {
|
| 352 |
$this->options['cart_page_data']['confirm_notes'] = '';
|
| 353 |
}
|
| 354 |
if ( ! isset( $this->options['member_page_data']['header'] ) ) {
|
| 355 |
$this->options['member_page_data']['header'] = array(
|
| 356 |
'login' => '',
|
| 357 |
'newmember' => '',
|
| 358 |
'newpass' => '',
|
| 359 |
'changepass' => '',
|
| 360 |
'memberinfo' => '',
|
| 361 |
'completion' => '',
|
| 362 |
);
|
| 363 |
}
|
| 364 |
if ( ! isset( $this->options['member_page_data']['footer'] ) ) {
|
| 365 |
$this->options['member_page_data']['footer'] = array(
|
| 366 |
'login' => '',
|
| 367 |
'newmember' => '',
|
| 368 |
'newpass' => '',
|
| 369 |
'changepass' => '',
|
| 370 |
'memberinfo' => '',
|
| 371 |
'completion' => '',
|
| 372 |
);
|
| 373 |
}
|
| 374 |
if ( ! isset( $this->options['member_page_data']['agree_member_exp'] ) ) {
|
| 375 |
$this->options['member_page_data']['agree_member_exp'] = '';
|
| 376 |
}
|
| 377 |
if ( ! isset( $this->options['member_page_data']['agree_member_cont'] ) ) {
|
| 378 |
$this->options['member_page_data']['agree_member_cont'] = '';
|
| 379 |
}
|
| 380 |
if ( ! isset( $this->options['agree_member'] ) ) {
|
| 381 |
$this->options['agree_member'] = '';
|
| 382 |
}
|
| 383 |
if ( ! isset( $this->options['shortest_delivery_time'] ) ) {
|
| 384 |
$this->options['shortest_delivery_time'] = '0';
|
| 385 |
}
|
| 386 |
if ( ! isset( $this->options['delivery_after_days'] ) ) {
|
| 387 |
$this->options['delivery_after_days'] = 15;
|
| 388 |
}
|
| 389 |
if ( ! isset( $this->options['delivery_days'] ) ) {
|
| 390 |
$this->options['delivery_days'] = array();
|
| 391 |
}
|
| 392 |
if ( ! isset( $this->options['delivery_time_limit']['hour'] ) ) {
|
| 393 |
$this->options['delivery_time_limit']['hour'] = '00';
|
| 394 |
}
|
| 395 |
if ( ! isset( $this->options['delivery_time_limit']['min'] ) ) {
|
| 396 |
$this->options['delivery_time_limit']['min'] = '00';
|
| 397 |
}
|
| 398 |
|
| 399 |
if ( ! isset( $this->options['divide_item'] ) ) {
|
| 400 |
$this->options['divide_item'] = 0;
|
| 401 |
}
|
| 402 |
if ( ! isset( $this->options['itemimg_anchor_rel'] ) ) {
|
| 403 |
$this->options['itemimg_anchor_rel'] = '';
|
| 404 |
}
|
| 405 |
if ( ! isset( $this->options['fukugo_category_orderby'] ) ) {
|
| 406 |
$this->options['fukugo_category_orderby'] = 'ID';
|
| 407 |
}
|
| 408 |
if ( ! isset( $this->options['fukugo_category_order'] ) ) {
|
| 409 |
$this->options['fukugo_category_order'] = 'ASC';
|
| 410 |
}
|
| 411 |
if ( ! isset( $this->options['settlement_path'] ) ) {
|
| 412 |
$this->options['settlement_path'] = USCES_PLUGIN_DIR . 'settlement/';
|
| 413 |
}
|
| 414 |
if ( ! isset( $this->options['logs_path'] ) ) {
|
| 415 |
$this->options['logs_path'] = '';
|
| 416 |
}
|
| 417 |
if ( ! isset( $this->options['use_ssl'] ) ) {
|
| 418 |
$this->options['use_ssl'] = 0;
|
| 419 |
}
|
| 420 |
if ( ! isset( $this->options['ssl_url'] ) ) {
|
| 421 |
$this->options['ssl_url'] = '';
|
| 422 |
}
|
| 423 |
if ( ! isset( $this->options['ssl_url_admin'] ) ) {
|
| 424 |
$this->options['ssl_url_admin'] = '';
|
| 425 |
}
|
| 426 |
if ( ! isset( $this->options['inquiry_id'] ) ) {
|
| 427 |
$this->options['inquiry_id'] = '';
|
| 428 |
}
|
| 429 |
if ( ! isset( $this->options['system']['orderby_itemsku'] ) ) {
|
| 430 |
$this->options['system']['orderby_itemsku'] = 0;
|
| 431 |
}
|
| 432 |
if ( ! isset( $this->options['system']['orderby_itemopt'] ) ) {
|
| 433 |
$this->options['system']['orderby_itemopt'] = 0;
|
| 434 |
}
|
| 435 |
if ( ! isset( $this->options['system']['front_lang'] ) ) {
|
| 436 |
$this->options['system']['front_lang'] = usces_get_local_language();
|
| 437 |
}
|
| 438 |
if ( ! isset( $this->options['system']['currency'] ) ) {
|
| 439 |
$this->options['system']['currency'] = usces_get_base_country();
|
| 440 |
}
|
| 441 |
if ( ! isset( $this->options['system']['addressform'] ) ) {
|
| 442 |
$this->options['system']['addressform'] = usces_get_local_addressform();
|
| 443 |
}
|
| 444 |
if ( ! isset( $this->options['system']['target_market'] ) ) {
|
| 445 |
$this->options['system']['target_market'] = usces_get_local_target_market();
|
| 446 |
}
|
| 447 |
if ( ! isset( $this->options['system']['no_cart_css'] ) ) {
|
| 448 |
$this->options['system']['no_cart_css'] = 0;
|
| 449 |
}
|
| 450 |
if ( ! isset( $this->options['system']['dec_orderID_flag'] ) ) {
|
| 451 |
$this->options['system']['dec_orderID_flag'] = 0;
|
| 452 |
}
|
| 453 |
if ( ! isset( $this->options['system']['dec_orderID_prefix'] ) ) {
|
| 454 |
$this->options['system']['dec_orderID_prefix'] = '';
|
| 455 |
}
|
| 456 |
if ( ! isset( $this->options['system']['dec_orderID_digit'] ) ) {
|
| 457 |
$this->options['system']['dec_orderID_digit'] = 8;
|
| 458 |
}
|
| 459 |
if ( ! isset( $this->options['system']['subimage_rule'] ) ) {
|
| 460 |
$this->options['system']['subimage_rule'] = 1;
|
| 461 |
}
|
| 462 |
if ( ! isset( $this->options['system']['pdf_delivery'] ) ) {
|
| 463 |
$this->options['system']['pdf_delivery'] = 0;
|
| 464 |
}
|
| 465 |
if ( ! isset( $this->options['system']['member_pass_rule_min'] ) || empty( $this->options['system']['member_pass_rule_min'] ) ) {
|
| 466 |
$this->options['system']['member_pass_rule_min'] = 6;
|
| 467 |
}
|
| 468 |
if ( ! isset( $this->options['system']['member_pass_rule_max'] ) || empty( $this->options['system']['member_pass_rule_max'] ) ) {
|
| 469 |
$this->options['system']['member_pass_rule_max'] = 30;
|
| 470 |
}
|
| 471 |
if ( ! isset( $this->options['system']['member_pass_rule_upercase'] ) || empty( $this->options['system']['member_pass_rule_upercase'] ) ) {
|
| 472 |
$this->options['system']['member_pass_rule_upercase'] = false;
|
| 473 |
}
|
| 474 |
if ( ! isset( $this->options['system']['csv_encode_type'] ) ) {
|
| 475 |
$this->options['system']['csv_encode_type'] = 0;
|
| 476 |
}
|
| 477 |
if ( ! isset( $this->options['system']['csv_category_format'] ) ) {
|
| 478 |
$this->options['system']['csv_category_format'] = 0;
|
| 479 |
}
|
| 480 |
if ( ! isset( $this->options['system']['settlement_backup'] ) ) {
|
| 481 |
$this->options['system']['settlement_backup'] = 0;
|
| 482 |
}
|
| 483 |
if ( ! isset( $this->options['system']['settlement_notice'] ) ) {
|
| 484 |
$this->options['system']['settlement_notice'] = 0;
|
| 485 |
}
|
| 486 |
if ( ! isset( $this->options['system']['order_list_delete_link'] ) ) {
|
| 487 |
$this->options['system']['order_list_delete_link'] = 0;
|
| 488 |
}
|
| 489 |
if ( ! isset( $this->options['system']['member_list_delete_link'] ) ) {
|
| 490 |
$this->options['system']['member_list_delete_link'] = 0;
|
| 491 |
}
|
| 492 |
|
| 493 |
$this->options['system']['base_country'] = usces_get_base_country();
|
| 494 |
if ( ! isset( $this->options['province'] ) ) {
|
| 495 |
$this->options['province'][ $this->options['system']['base_country'] ] = $usces_states[ $this->options['system']['base_country'] ];
|
| 496 |
}
|
| 497 |
if ( ! isset( $this->options['system']['pointreduction'] ) ) {
|
| 498 |
$this->options['system']['pointreduction'] = usces_get_pointreduction( $this->options['system']['currency'] );
|
| 499 |
}
|
| 500 |
if ( ! isset( $this->options['indi_item_name'] ) ) {
|
| 501 |
$this->options['indi_item_name']['item_name'] = 1;
|
| 502 |
$this->options['indi_item_name']['item_code'] = 1;
|
| 503 |
$this->options['indi_item_name']['sku_name'] = 1;
|
| 504 |
$this->options['indi_item_name']['sku_code'] = 1;
|
| 505 |
$this->options['pos_item_name']['item_name'] = 1;
|
| 506 |
$this->options['pos_item_name']['item_code'] = 2;
|
| 507 |
$this->options['pos_item_name']['sku_name'] = 3;
|
| 508 |
$this->options['pos_item_name']['sku_code'] = 4;
|
| 509 |
}
|
| 510 |
update_option( 'usces', $this->options );
|
| 511 |
|
| 512 |
$this->check_display_mode();
|
| 513 |
$this->error_message = '';
|
| 514 |
$this->login_mail = '';
|
| 515 |
// $this->get_current_member();
|
| 516 |
$this->page = '';
|
| 517 |
$this->payment_results = array();
|
| 518 |
$this->use_js = $this->options['use_javascript'];
|
| 519 |
|
| 520 |
// admin_ssl options.
|
| 521 |
$this->use_ssl = $this->options['use_ssl'];
|
| 522 |
|
| 523 |
define( 'USCES_CART_NUMBER', get_option( 'usces_cart_number' ) );
|
| 524 |
define( 'USCES_MEMBER_NUMBER', get_option( 'usces_member_number' ) );
|
| 525 |
|
| 526 |
if ( $this->use_ssl ) {
|
| 527 |
$ssl_url = $this->options['ssl_url'];
|
| 528 |
$ssl_url_admin = $this->options['ssl_url_admin'];
|
| 529 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 530 |
define( 'USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER );
|
| 531 |
define( 'USCES_COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', $ssl_url . '/' ) );
|
| 532 |
} else {
|
| 533 |
define( 'USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER );
|
| 534 |
define( 'USCES_COOKIEPATH', COOKIEPATH );
|
| 535 |
}
|
| 536 |
define( 'USCES_SSL_URL', $ssl_url );
|
| 537 |
define( 'USCES_SSL_URL_ADMIN', $ssl_url_admin );
|
| 538 |
} else {
|
| 539 |
define( 'USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER );
|
| 540 |
define( 'USCES_SSL_URL', home_url() );
|
| 541 |
define( 'USCES_SSL_URL_ADMIN', site_url() );
|
| 542 |
define( 'USCES_COOKIEPATH', COOKIEPATH );
|
| 543 |
}
|
| 544 |
define( 'USCES_ITEM_CAT_PARENT_ID', get_option( 'usces_item_cat_parent_id' ) );
|
| 545 |
|
| 546 |
$this->nonacting_settlements = array( 'COD', 'installment', 'transferAdvance', 'transferDeferred' );
|
| 547 |
$this->zaiko_status = get_option( 'usces_zaiko_status' );
|
| 548 |
$this->member_status = get_option( 'usces_customer_status' );
|
| 549 |
$this->payment_structure = get_option( 'usces_payment_structure' );
|
| 550 |
$this->display_mode = get_option( 'usces_display_mode' );
|
| 551 |
define( 'USCES_MYSQL_VERSION', $wpdb->db_version() );
|
| 552 |
define( 'USCES_JP', ( 'ja' === get_locale() ? true : false ) );
|
| 553 |
|
| 554 |
$this->settlement = new usces_settlement();
|
| 555 |
|
| 556 |
$this->settlement_notice = get_option( 'usces_settlement_notice' );
|
| 557 |
|
| 558 |
$this->usces_session_start();
|
| 559 |
}
|
| 560 |
|
| 561 |
/**
|
| 562 |
* Init.
|
| 563 |
*/
|
| 564 |
public function init() {
|
| 565 |
global $usces_settings;
|
| 566 |
|
| 567 |
if ( ! isset( $usces_settings['language']['others'] ) ) {
|
| 568 |
$usces_settings['language']['others'] = __( 'Follow config.php', 'usces' );
|
| 569 |
}
|
| 570 |
if ( ! isset( $this->options['order_acceptable_label'] ) ) {
|
| 571 |
$this->options['order_acceptable_label'] = __( 'Order acceptable', 'usces' );
|
| 572 |
update_option( 'usces', $this->options );
|
| 573 |
}
|
| 574 |
$this->get_current_member();
|
| 575 |
}
|
| 576 |
|
| 577 |
public function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) {
|
| 578 |
global $wpdb;
|
| 579 |
|
| 580 |
$post_title = '';
|
| 581 |
if ( ! empty( $_REQUEST['post_title'] ) ) {
|
| 582 |
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ) );
|
| 583 |
}
|
| 584 |
$post_content = '';
|
| 585 |
if ( ! empty( $_REQUEST['content'] ) ) {
|
| 586 |
$post_content = esc_html( stripslashes( $_REQUEST['content'] ) );
|
| 587 |
}
|
| 588 |
$post_excerpt = '';
|
| 589 |
if ( ! empty( $_REQUEST['excerpt'] ) ) {
|
| 590 |
$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ) );
|
| 591 |
}
|
| 592 |
if ( $create_in_db ) {
|
| 593 |
// Cleanup old auto-drafts more than 7 days old.
|
| 594 |
$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
|
| 595 |
foreach ( (array) $old_posts as $delete ) {
|
| 596 |
wp_delete_post( $delete, true ); // Force delete.
|
| 597 |
}
|
| 598 |
$post = get_post(
|
| 599 |
wp_insert_post(
|
| 600 |
array(
|
| 601 |
'post_title' => __( 'Auto Draft' ),
|
| 602 |
'post_type' => $post_type,
|
| 603 |
'post_status' => 'auto-draft',
|
| 604 |
)
|
| 605 |
)
|
| 606 |
);
|
| 607 |
} else {
|
| 608 |
$post->ID = 0;
|
| 609 |
$post->post_author = '';
|
| 610 |
$post->post_date = '';
|
| 611 |
$post->post_date_gmt = '';
|
| 612 |
$post->post_password = '';
|
| 613 |
$post->post_type = $post_type;
|
| 614 |
$post->post_status = 'draft';
|
| 615 |
$post->to_ping = '';
|
| 616 |
$post->pinged = '';
|
| 617 |
$post->comment_status = get_option( 'default_comment_status' );
|
| 618 |
$post->ping_status = get_option( 'default_ping_status' );
|
| 619 |
$post->post_pingback = get_option( 'default_pingback_flag' );
|
| 620 |
$post->post_category = get_option( 'default_category' );
|
| 621 |
$post->page_template = 'default';
|
| 622 |
$post->post_parent = 0;
|
| 623 |
$post->menu_order = 0;
|
| 624 |
}
|
| 625 |
|
| 626 |
$post->post_content = apply_filters( 'default_content', $post_content, $post );
|
| 627 |
$post->post_title = apply_filters( 'default_title', $post_title, $post );
|
| 628 |
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
|
| 629 |
$post->post_name = '';
|
| 630 |
|
| 631 |
return $post;
|
| 632 |
}
|
| 633 |
|
| 634 |
public function get_default_post_to_edit() {
|
| 635 |
global $post;
|
| 636 |
|
| 637 |
$post_title = '';
|
| 638 |
if ( ! empty( $_REQUEST['post_title'] ) ) {
|
| 639 |
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ) );
|
| 640 |
}
|
| 641 |
$post_content = '';
|
| 642 |
if ( ! empty( $_REQUEST['content'] ) ) {
|
| 643 |
$post_content = esc_html( stripslashes( $_REQUEST['content'] ) );
|
| 644 |
}
|
| 645 |
$post_excerpt = '';
|
| 646 |
if ( ! empty( $_REQUEST['excerpt'] ) ) {
|
| 647 |
$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ) );
|
| 648 |
}
|
| 649 |
$post->ID = 0;
|
| 650 |
$post->post_name = '';
|
| 651 |
$post->post_author = '';
|
| 652 |
$post->post_date = '';
|
| 653 |
$post->post_date_gmt = '';
|
| 654 |
$post->post_password = '';
|
| 655 |
$post->post_status = 'draft';
|
| 656 |
$post->post_type = 'post';
|
| 657 |
$post->to_ping = '';
|
| 658 |
$post->pinged = '';
|
| 659 |
$post->comment_status = get_option( 'default_comment_status' );
|
| 660 |
$post->ping_status = get_option( 'default_ping_status' );
|
| 661 |
$post->post_pingback = get_option( 'default_pingback_flag' );
|
| 662 |
$post->post_category = get_option( 'default_category' );
|
| 663 |
$post->post_content = apply_filters( 'default_content', $post_content );
|
| 664 |
$post->post_title = apply_filters( 'default_title', $post_title );
|
| 665 |
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt );
|
| 666 |
$post->page_template = 'default';
|
| 667 |
$post->post_parent = 0;
|
| 668 |
$post->menu_order = 0;
|
| 669 |
|
| 670 |
return $post;
|
| 671 |
}
|
| 672 |
|
| 673 |
public function is_cart_or_member_page( $link ) {
|
| 674 |
$search = array(
|
| 675 |
( 'page_id=' . USCES_CART_NUMBER ),
|
| 676 |
'/usces-cart',
|
| 677 |
( 'page_id=' . USCES_MEMBER_NUMBER ),
|
| 678 |
'/usces-member',
|
| 679 |
);
|
| 680 |
$flag = false;
|
| 681 |
foreach ( $search as $value ) {
|
| 682 |
$parts = array();
|
| 683 |
if ( false !== strpos( $link, $value ) ) {
|
| 684 |
if ( $value == ( 'page_id=' . USCES_CART_NUMBER ) || $value == ( 'page_id=' . USCES_MEMBER_NUMBER ) ) {
|
| 685 |
$parts = parse_url( $link );
|
| 686 |
parse_str( $parts['query'], $query );
|
| 687 |
if ( isset( $query['page_id'] ) && ( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ) ) {
|
| 688 |
$flag = true;
|
| 689 |
}
|
| 690 |
} else {
|
| 691 |
$flag = true;
|
| 692 |
}
|
| 693 |
}
|
| 694 |
}
|
| 695 |
return $flag;
|
| 696 |
}
|
| 697 |
|
| 698 |
public function is_cart_page( $link ) {
|
| 699 |
$search = array(
|
| 700 |
( 'page_id=' . USCES_CART_NUMBER ),
|
| 701 |
'/usces-cart',
|
| 702 |
);
|
| 703 |
$flag = false;
|
| 704 |
foreach ( $search as $value ) {
|
| 705 |
if ( false !== strpos( $link, $value ) ) {
|
| 706 |
if ( $value == ( 'page_id=' . USCES_CART_NUMBER ) ) {
|
| 707 |
$parts = parse_url( $link );
|
| 708 |
parse_str( $parts['query'], $query );
|
| 709 |
if ( isset( $query['page_id'] ) && $query['page_id'] == USCES_CART_NUMBER ) {
|
| 710 |
$flag = true;
|
| 711 |
}
|
| 712 |
} else {
|
| 713 |
$flag = true;
|
| 714 |
}
|
| 715 |
}
|
| 716 |
}
|
| 717 |
return $flag;
|
| 718 |
}
|
| 719 |
|
| 720 |
public function is_member_page( $link ) {
|
| 721 |
$search = array(
|
| 722 |
( 'page_id=' . USCES_MEMBER_NUMBER ),
|
| 723 |
'/usces-member',
|
| 724 |
);
|
| 725 |
$flag = false;
|
| 726 |
foreach ( $search as $value ) {
|
| 727 |
if ( false !== strpos( $link, $value ) ) {
|
| 728 |
if ( $value == ( 'page_id=' . USCES_MEMBER_NUMBER ) ) {
|
| 729 |
$parts = parse_url( $link );
|
| 730 |
parse_str( $parts['query'], $query );
|
| 731 |
if ( $query['page_id'] == USCES_MEMBER_NUMBER ) {
|
| 732 |
$flag = true;
|
| 733 |
}
|
| 734 |
} else {
|
| 735 |
$flag = true;
|
| 736 |
}
|
| 737 |
}
|
| 738 |
}
|
| 739 |
return $flag;
|
| 740 |
}
|
| 741 |
|
| 742 |
public function is_inquiry_page( $link ) {
|
| 743 |
if ( empty( $this->options['inquiry_id'] ) ) {
|
| 744 |
return false;
|
| 745 |
}
|
| 746 |
$search = array(
|
| 747 |
( 'page_id=' . $this->options['inquiry_id'] ),
|
| 748 |
'/usces-inquiry',
|
| 749 |
);
|
| 750 |
$flag = false;
|
| 751 |
foreach ( $search as $value ) {
|
| 752 |
if ( false !== strpos( $link, $value ) ) {
|
| 753 |
if ( $value == ( 'page_id=' . $this->options['inquiry_id'] ) ) {
|
| 754 |
$parts = parse_url( $link );
|
| 755 |
parse_str( $parts['query'], $query );
|
| 756 |
if ( $query['page_id'] == $this->options['inquiry_id'] ) {
|
| 757 |
$flag = true;
|
| 758 |
}
|
| 759 |
} else {
|
| 760 |
$flag = true;
|
| 761 |
}
|
| 762 |
}
|
| 763 |
}
|
| 764 |
return $flag;
|
| 765 |
}
|
| 766 |
|
| 767 |
public function usces_ssl_page_link( $link ) {
|
| 768 |
$parts = parse_url( $link );
|
| 769 |
|
| 770 |
if ( isset( $parts['query'] ) ) {
|
| 771 |
parse_str( $parts['query'], $query );
|
| 772 |
}
|
| 773 |
|
| 774 |
if ( false !== strpos( $link, '/usces-cart' ) || ( isset( $query['page_id'] ) && $query['page_id'] == USCES_CART_NUMBER ) ) {
|
| 775 |
$link = USCES_CART_URL;
|
| 776 |
|
| 777 |
} elseif ( false !== strpos( $link, '/usces-member' ) || ( isset( $query['page_id'] ) && $query['page_id'] == USCES_MEMBER_NUMBER ) ) {
|
| 778 |
$link = USCES_MEMBER_URL;
|
| 779 |
|
| 780 |
} elseif ( ! empty( $this->options['inquiry_id'] ) && ( false !== strpos( $link, '/usces-inquiry' ) || ( isset( $query['page_id'] ) && $query['page_id'] == $this->options['inquiry_id'] ) ) ) {
|
| 781 |
$link = USCES_INQUIRY_URL;
|
| 782 |
|
| 783 |
} else {
|
| 784 |
$link = str_replace( 'https://', 'http://', $link );
|
| 785 |
$link = apply_filters( 'usces_ssl_page_link', $link );
|
| 786 |
}
|
| 787 |
|
| 788 |
return $link;
|
| 789 |
}
|
| 790 |
|
| 791 |
public function usces_ssl_contents_link( $link ) {
|
| 792 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 793 |
$req = explode( '/wp-content/', $link );
|
| 794 |
$link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
|
| 795 |
} else {
|
| 796 |
$link = apply_filters( 'usces_ssl_contents_link', $link );
|
| 797 |
}
|
| 798 |
return $link;
|
| 799 |
}
|
| 800 |
|
| 801 |
public function ssl_admin_ajax_url() {
|
| 802 |
$path = '/wp-admin/admin-ajax.php';
|
| 803 |
if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) {
|
| 804 |
$link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php';
|
| 805 |
} else {
|
| 806 |
$link = site_url( $path );
|
| 807 |
}
|
| 808 |
$link = apply_filters( 'ssl_admin_ajax_url', $link );
|
| 809 |
return $link;
|
| 810 |
}
|
| 811 |
|
| 812 |
public function usces_ssl_attachment_link( $link ) {
|
| 813 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 814 |
$link = str_replace( site_url(), USCES_SSL_URL_ADMIN, $link );
|
| 815 |
} else {
|
| 816 |
$link = apply_filters( 'usces_ssl_attachment_link', $link );
|
| 817 |
}
|
| 818 |
return $link;
|
| 819 |
}
|
| 820 |
|
| 821 |
public function usces_ssl_icon_dir_uri( $uri ) {
|
| 822 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 823 |
$uri = USCES_SSL_URL_ADMIN . '/' . WPINC . '/images/crystal';
|
| 824 |
} else {
|
| 825 |
$uri = apply_filters( 'usces_ssl_icon_dir_uri', $uri );
|
| 826 |
}
|
| 827 |
return $uri;
|
| 828 |
}
|
| 829 |
|
| 830 |
public function usces_ssl_script_link( $link ) {
|
| 831 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 832 |
if ( strpos( $link, '/wp-content/' ) !== false ) {
|
| 833 |
$req = explode( '/wp-content/', $link, 2 );
|
| 834 |
$link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1];
|
| 835 |
} elseif ( strpos( $link, '/wp-includes/' ) !== false ) {
|
| 836 |
$req = explode( '/wp-includes/', $link, 2 );
|
| 837 |
$link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1];
|
| 838 |
} elseif ( strpos( $link, '/wp-admin/') !== false ) {
|
| 839 |
$req = explode( '/wp-admin/', $link, 2 );
|
| 840 |
$link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1];
|
| 841 |
}
|
| 842 |
} else {
|
| 843 |
$link = apply_filters( 'usces_ssl_script_link', $link );
|
| 844 |
}
|
| 845 |
return $link;
|
| 846 |
}
|
| 847 |
|
| 848 |
public function set_action_status( $status, $message ) {
|
| 849 |
$this->action_status = $status;
|
| 850 |
$this->action_message = $message;
|
| 851 |
}
|
| 852 |
|
| 853 |
public function add_pages() {
|
| 854 |
add_menu_page( 'Welcart Shop', 'Welcart Shop', 'wel_publish_products', USCES_PLUGIN_BASENAME, array( $this, 'admin_top_page' ), 'dashicons-cart', '3.0011060' );
|
| 855 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Home', 'usces' ), __( 'Home', 'usces' ), 'wel_publish_products', USCES_PLUGIN_BASENAME, array( $this, 'admin_top_page' ) );
|
| 856 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Master Items', 'usces' ), __( 'Master Items', 'usces' ), 'wel_publish_products', 'usces_itemedit', array( $this, 'item_master_page' ) );
|
| 857 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Add New Item', 'usces' ), __( 'Add New Item', 'usces' ), 'wel_publish_products', 'usces_itemnew', array( $this, 'item_master_page' ) );
|
| 858 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'General Setting', 'usces' ), __( 'General Setting', 'usces' ), 'wel_manage_setting', 'usces_initial', array( $this, 'admin_setup_page' ) );
|
| 859 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Business Days Setting', 'usces' ), __( 'Business Days Setting', 'usces' ), 'wel_manage_setting', 'usces_schedule', array( $this, 'admin_schedule_page' ) );
|
| 860 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Shipping Setting', 'usces' ), __( 'Shipping Setting', 'usces' ), 'wel_manage_setting', 'usces_delivery', array( $this, 'admin_delivery_page' ) );
|
| 861 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'E-mail Setting', 'usces' ), __( 'E-mail Setting', 'usces' ), 'wel_manage_setting', 'usces_mail', array( $this, 'admin_mail_page' ) );
|
| 862 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Cart Page Setting', 'usces' ), __( 'Cart Page Setting', 'usces' ), 'wel_manage_setting', 'usces_cart', array( $this, 'admin_cart_page' ) );
|
| 863 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Member Page Setting', 'usces' ), __( 'Member Page Setting', 'usces' ), 'wel_manage_setting', 'usces_member', array( $this, 'admin_member_page' ) );
|
| 864 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'System Setting', 'usces' ), __( 'System Setting', 'usces' ), 'wel_manage_setting', 'usces_system', array( $this, 'admin_system_page' ) );
|
| 865 |
add_submenu_page( USCES_PLUGIN_BASENAME, __( 'Settlement Setting', 'usces' ), __( 'Settlement Setting', 'usces' ), 'wel_manage_setting', 'usces_settlement', array( $this, 'admin_settlement_page' ) );
|
| 866 |
do_action( 'usces_action_shop_admin_menue' );
|
| 867 |
|
| 868 |
add_menu_page( 'Welcart Management', 'Welcart Management', 'wel_manage_order', 'usces_orderlist', array( $this, 'order_list_page' ), 'dashicons-cart', '3.0011070' );
|
| 869 |
add_submenu_page( 'usces_orderlist', __( 'Order List', 'usces' ), __( 'Order List', 'usces' ), 'wel_manage_order', 'usces_orderlist', array( $this, 'order_list_page' ) );
|
| 870 |
add_submenu_page( 'usces_orderlist', __( 'New Order or Estimate', 'usces' ), __( 'New Order or Estimate', 'usces' ), 'wel_manage_order', 'usces_ordernew', array( $this, 'order_list_page' ) );
|
| 871 |
add_submenu_page( 'usces_orderlist', __( 'List of Members', 'usces' ), __( 'List of Members', 'usces' ), 'wel_manage_order', 'usces_memberlist', array( $this, 'member_list_page' ) );
|
| 872 |
add_submenu_page( 'usces_orderlist', __( 'New Membership Registration', 'usces' ), __( 'New Membership Registration', 'usces' ), 'wel_manage_order', 'usces_membernew', array( $this, 'member_list_page' ) );
|
| 873 |
Log_List_Table::add_submenu_page();
|
| 874 |
do_action( 'usces_action_management_admin_menue' );
|
| 875 |
}
|
| 876 |
|
| 877 |
/**
|
| 878 |
* Item Master Page.
|
| 879 |
*/
|
| 880 |
public function item_master_page() {
|
| 881 |
global $wpdb, $wp_locale;
|
| 882 |
global $wp_query;
|
| 883 |
|
| 884 |
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
|
| 885 |
$this->action_status = 'none';
|
| 886 |
$this->action_message = '';
|
| 887 |
}
|
| 888 |
|
| 889 |
if ( 'usces_itemnew' == $_REQUEST['page'] ) {
|
| 890 |
$action = 'new';
|
| 891 |
} else {
|
| 892 |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
| 893 |
}
|
| 894 |
do_action( 'usces_action_item_master_page', $action );
|
| 895 |
switch ( $action ) {
|
| 896 |
case 'dlitemlist':
|
| 897 |
usces_download_item_list();
|
| 898 |
break;
|
| 899 |
case 'upload_register':
|
| 900 |
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php';
|
| 901 |
break;
|
| 902 |
case 'delete':
|
| 903 |
case 'new':
|
| 904 |
case 'editpost':
|
| 905 |
case 'edit':
|
| 906 |
global $current_user;
|
| 907 |
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php';
|
| 908 |
break;
|
| 909 |
default:
|
| 910 |
require_once USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php';
|
| 911 |
break;
|
| 912 |
}
|
| 913 |
}
|
| 914 |
|
| 915 |
/**
|
| 916 |
* Order list page.
|
| 917 |
*/
|
| 918 |
public function order_list_page() {
|
| 919 |
$order_edit_form = apply_filters( 'usces_admin_order_edit_form', USCES_PLUGIN_DIR . '/includes/order_edit_form.php' );
|
| 920 |
$order_list = apply_filters( 'usces_admin_order_list', USCES_PLUGIN_DIR . '/includes/order_list.php' );
|
| 921 |
|
| 922 |
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
|
| 923 |
$this->action_status = 'none';
|
| 924 |
$this->action_message = '';
|
| 925 |
}
|
| 926 |
if ( 'usces_ordernew' == $_REQUEST['page'] ) {
|
| 927 |
$order_action = 'new';
|
| 928 |
} else {
|
| 929 |
$order_action = isset( $_REQUEST['order_action'] ) ? $_REQUEST['order_action'] : '';
|
| 930 |
}
|
| 931 |
do_action( 'usces_action_order_list_page', $order_action );
|
| 932 |
Log_List_Table::add_order_meta_box( $order_action );
|
| 933 |
switch ( $order_action ) {
|
| 934 |
case 'dlproductlist':
|
| 935 |
check_admin_referer( 'order_list', 'wc_nonce' );
|
| 936 |
usces_download_product_list();
|
| 937 |
break;
|
| 938 |
case 'dlorderlist':
|
| 939 |
check_admin_referer( 'order_list', 'wc_nonce' );
|
| 940 |
usces_download_order_list();
|
| 941 |
break;
|
| 942 |
case 'dlsettlementerrorlog':
|
| 943 |
check_admin_referer( 'order_list', 'wc_nonce' );
|
| 944 |
usces_download_settlement_error_log();
|
| 945 |
break;
|
| 946 |
case 'editpost':
|
| 947 |
check_admin_referer( 'order_edit', 'wc_nonce' );
|
| 948 |
$logger = Logger::start( $_REQUEST['order_id'], 'orderedit', 'update' );
|
| 949 |
do_action( 'usces_pre_update_orderdata', $_REQUEST['order_id'] );
|
| 950 |
$res = usces_update_orderdata();
|
| 951 |
if ( 1 === $res ) {
|
| 952 |
$backtolist = ( empty( $_POST['usces_referer'] ) || false !== strpos( $_POST['usces_referer'], 'order_action=editpost' ) ) ? admin_url( 'admin.php?page=usces_orderlist&returnList=1&wc_nonce=' . wp_create_nonce( 'order_list' ) ) : esc_url( stripslashes( $_POST['usces_referer'] ) );
|
| 953 |
$this->set_action_status( 'success', __( 'order date is updated', 'usces' ) . ' <a href="' . $backtolist . '">' . __( 'back to the summary', 'usces' ) . '</a>' );
|
| 954 |
} elseif ( 0 === $res ) {
|
| 955 |
$this->set_action_status( 'none', '' );
|
| 956 |
} else {
|
| 957 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in update', 'usces' ) );
|
| 958 |
}
|
| 959 |
$logger->flush();
|
| 960 |
do_action( 'usces_after_update_orderdata', $_REQUEST['order_id'], $res );
|
| 961 |
require_once $order_edit_form;
|
| 962 |
break;
|
| 963 |
case 'newpost':
|
| 964 |
check_admin_referer( 'order_edit', 'wc_nonce' );
|
| 965 |
do_action( 'usces_pre_new_orderdata' );
|
| 966 |
$res = usces_new_orderdata();
|
| 967 |
if ( 1 === $res ) {
|
| 968 |
$this->set_action_status( 'success', __( 'New date is add', 'usces' ) );
|
| 969 |
Logger::start( $_REQUEST['order_id'], 'ordernew', 'create' )->flush();
|
| 970 |
} elseif ( 0 === $res ) {
|
| 971 |
$this->set_action_status( 'none', '' );
|
| 972 |
} else {
|
| 973 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in addition', 'usces' ) );
|
| 974 |
}
|
| 975 |
do_action( 'usces_after_new_orderdata', $res );
|
| 976 |
$_REQUEST['order_action'] = 'edit';
|
| 977 |
$order_action = $_REQUEST['order_action'];
|
| 978 |
require_once $order_edit_form;
|
| 979 |
break;
|
| 980 |
case 'new':
|
| 981 |
case 'edit':
|
| 982 |
require_once $order_edit_form;
|
| 983 |
break;
|
| 984 |
case 'load_rich_editor':
|
| 985 |
wp_enqueue_style( 'colors' );
|
| 986 |
require_once USCES_PLUGIN_DIR . '/includes/order_detail_rich_editor.php';
|
| 987 |
break;
|
| 988 |
case 'delete':
|
| 989 |
check_admin_referer( 'order_list', 'wc_nonce' );
|
| 990 |
do_action( 'usces_pre_delete_orderdata', $_REQUEST['order_id'] );
|
| 991 |
$logger = Logger::start( $_REQUEST['order_id'], 'orderlist', 'delete' );
|
| 992 |
$res = usces_delete_orderdata();
|
| 993 |
if ( 1 === $res ) {
|
| 994 |
$this->set_action_status( 'success', __( 'the order date is deleted', 'usces' ) );
|
| 995 |
$logger->flush();
|
| 996 |
} elseif ( 0 === $res ) {
|
| 997 |
$this->set_action_status( 'none', '' );
|
| 998 |
} else {
|
| 999 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
|
| 1000 |
}
|
| 1001 |
do_action( 'usces_after_delete_orderdata', $_REQUEST['order_id'], $res );
|
| 1002 |
default:
|
| 1003 |
require_once $order_list;
|
| 1004 |
}
|
| 1005 |
}
|
| 1006 |
|
| 1007 |
/**
|
| 1008 |
* Member list page.
|
| 1009 |
*/
|
| 1010 |
public function member_list_page() {
|
| 1011 |
$member_edit_form = apply_filters( 'usces_admin_member_edit_form', USCES_PLUGIN_DIR . '/includes/member_edit_form.php' );
|
| 1012 |
$member_list = apply_filters( 'usces_admin_member_list', USCES_PLUGIN_DIR . '/includes/member_list.php' );
|
| 1013 |
if ( empty( $this->action_message ) || WCUtils::is_blank( $this->action_message ) ) {
|
| 1014 |
$this->action_status = 'none';
|
| 1015 |
$this->action_message = '';
|
| 1016 |
}
|
| 1017 |
if ( 'usces_membernew' == $_REQUEST['page'] ) {
|
| 1018 |
$member_action = isset( $_REQUEST['member_action'] ) ? $_REQUEST['member_action'] : 'new';
|
| 1019 |
} else {
|
| 1020 |
$member_action = isset( $_REQUEST['member_action'] ) ? $_REQUEST['member_action'] : '';
|
| 1021 |
}
|
| 1022 |
do_action( 'usces_action_member_list_page', $member_action );
|
| 1023 |
Log_List_Table::add_member_meta_box( $member_action );
|
| 1024 |
switch ( $member_action ) {
|
| 1025 |
case 'dlmemberlist':
|
| 1026 |
check_admin_referer( 'post_member', 'wc_nonce' );
|
| 1027 |
usces_download_member_list();
|
| 1028 |
break;
|
| 1029 |
case 'editpost':
|
| 1030 |
check_admin_referer( 'post_member', 'wc_nonce' );
|
| 1031 |
$logger = Logger::start( $_REQUEST['member_id'], 'memberedit', 'update' );
|
| 1032 |
$this->error_message = $this->admin_member_check();
|
| 1033 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 1034 |
$res = usces_update_memberdata();
|
| 1035 |
if ( 1 === $res ) {
|
| 1036 |
$this->set_action_status( 'success', __( 'Membership information is updated', 'usces' ) );
|
| 1037 |
$logger->flush();
|
| 1038 |
} elseif ( 0 === $res ) {
|
| 1039 |
$this->set_action_status( 'none', '' );
|
| 1040 |
} else {
|
| 1041 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in update', 'usces' ) );
|
| 1042 |
}
|
| 1043 |
} else {
|
| 1044 |
$this->set_action_status( 'error', 'ERROR : ' . $this->error_message );
|
| 1045 |
}
|
| 1046 |
require_once $member_edit_form;
|
| 1047 |
break;
|
| 1048 |
case 'newpost':
|
| 1049 |
check_admin_referer( 'post_member', 'wc_nonce' );
|
| 1050 |
$this->error_message = $this->admin_new_member_check();
|
| 1051 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 1052 |
$res = usces_new_memberdata();
|
| 1053 |
if ( 1 === $res ) {
|
| 1054 |
$this->set_action_status( 'success', __( 'New member registration is complete.', 'usces' ) );
|
| 1055 |
$_REQUEST['member_action'] = 'edit';
|
| 1056 |
$member_action = $_REQUEST['member_action'];
|
| 1057 |
Logger::start( $_REQUEST['member_id'], 'membernew', 'create' )->flush();
|
| 1058 |
} elseif ( 0 === $res ) {
|
| 1059 |
$this->set_action_status( 'none', '' );
|
| 1060 |
} else {
|
| 1061 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'Failed to new member registration.', 'usces' ) );
|
| 1062 |
}
|
| 1063 |
} else {
|
| 1064 |
$this->set_action_status( 'error', $this->error_message );
|
| 1065 |
$member_action = 'new';
|
| 1066 |
}
|
| 1067 |
require_once $member_edit_form;
|
| 1068 |
break;
|
| 1069 |
case 'new':
|
| 1070 |
require_once $member_edit_form;
|
| 1071 |
break;
|
| 1072 |
case 'edit':
|
| 1073 |
check_admin_referer( 'member_list', 'wc_nonce' );
|
| 1074 |
require_once $member_edit_form;
|
| 1075 |
break;
|
| 1076 |
case 'delete':
|
| 1077 |
check_admin_referer( 'delete_member', 'wc_nonce' );
|
| 1078 |
if ( ! isset( $_REQUEST['member_id'] ) || WCUtils::is_blank( $_REQUEST['member_id'] ) ) {
|
| 1079 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
|
| 1080 |
} else {
|
| 1081 |
$logger = Logger::start( $_REQUEST['member_id'], 'memberlist', 'delete' );
|
| 1082 |
$member_id = $_REQUEST['member_id'];
|
| 1083 |
$del = usces_delete_member_check( $member_id );
|
| 1084 |
if ( $del ) {
|
| 1085 |
$res = usces_delete_memberdata( $member_id );
|
| 1086 |
if ( 1 === $res ) {
|
| 1087 |
$this->set_action_status( 'success', __( 'The member data is deleted', 'usces' ) );
|
| 1088 |
} elseif ( 0 === $res ) {
|
| 1089 |
$this->set_action_status( 'none', '' );
|
| 1090 |
} else {
|
| 1091 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
|
| 1092 |
}
|
| 1093 |
$logger->flush();
|
| 1094 |
} else {
|
| 1095 |
$this->set_action_status( 'error', 'ERROR : ' . __( 'failure in delete', 'usces' ) );
|
| 1096 |
}
|
| 1097 |
}
|
| 1098 |
default:
|
| 1099 |
require_once $member_list;
|
| 1100 |
}
|
| 1101 |
}
|
| 1102 |
|
| 1103 |
/**
|
| 1104 |
* Shop Top Page.
|
| 1105 |
*/
|
| 1106 |
public function admin_top_page() {
|
| 1107 |
$action = filter_input( INPUT_GET, 'wel_action', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR );
|
| 1108 |
if ( ! wel_need_to_update_db() ) {
|
| 1109 |
$action = '';
|
| 1110 |
}
|
| 1111 |
switch ( $action ) {
|
| 1112 |
case 'update_db':
|
| 1113 |
if ( ! current_user_can( 'wel_manage_setting' ) ) {
|
| 1114 |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
| 1115 |
}
|
| 1116 |
check_admin_referer( 'wel_update_database', '_welnonce' );
|
| 1117 |
require_once USCES_PLUGIN_DIR . '/includes/database/db-progress-screen.php';
|
| 1118 |
break;
|
| 1119 |
default:
|
| 1120 |
$path = apply_filters( 'usces_filter_admin_top_page', USCES_PLUGIN_DIR . '/includes/admin_top.php' );
|
| 1121 |
require_once $path;
|
| 1122 |
}
|
| 1123 |
}
|
| 1124 |
|
| 1125 |
/**
|
| 1126 |
* Shop Setup Page.
|
| 1127 |
*/
|
| 1128 |
public function admin_setup_page() {
|
| 1129 |
$this->options = get_option( 'usces' );
|
| 1130 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1131 |
|
| 1132 |
check_admin_referer( 'admin_setup', 'wc_nonce' );
|
| 1133 |
|
| 1134 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1135 |
|
| 1136 |
$order_mail = '';
|
| 1137 |
if ( isset( $_POST['order_mail'] ) ) {
|
| 1138 |
$order_mails = array_map( 'trim', explode( ',', $_POST['order_mail'] ) );
|
| 1139 |
$valid_mails = array();
|
| 1140 |
foreach ( $order_mails as $mail ) {
|
| 1141 |
if ( is_email( $mail ) ) {
|
| 1142 |
$valid_mails[] = $mail;
|
| 1143 |
}
|
| 1144 |
}
|
| 1145 |
$order_mail = implode( ',', $valid_mails );
|
| 1146 |
} else {
|
| 1147 |
$order_mail = '';
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
$this->options['display_mode'] = isset( $_POST['display_mode'] ) ? trim( $_POST['display_mode'] ) : '';
|
| 1151 |
$this->options['campaign_category'] = empty( $_POST['cat'] ) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat'];
|
| 1152 |
$this->options['campaign_privilege'] = isset( $_POST['cat_privilege'] ) ? trim( $_POST['cat_privilege'] ) : '';
|
| 1153 |
$this->options['privilege_point'] = isset( $_POST['point_num'] ) ? (int) $_POST['point_num'] : '';
|
| 1154 |
$this->options['privilege_discount'] = isset( $_POST['discount_num'] ) ? (int) $_POST['discount_num'] : '';
|
| 1155 |
$this->options['company_name'] = isset( $_POST['company_name'] ) ? trim( $_POST['company_name'] ) : '';
|
| 1156 |
$this->options['zip_code'] = isset( $_POST['zip_code'] ) ? trim( $_POST['zip_code'] ) : '';
|
| 1157 |
$this->options['address1'] = isset( $_POST['address1'] ) ? trim( $_POST['address1'] ) : '';
|
| 1158 |
$this->options['address2'] = isset( $_POST['address2'] ) ? trim( $_POST['address2'] ) : '';
|
| 1159 |
$this->options['tel_number'] = isset( $_POST['tel_number'] ) ? trim( $_POST['tel_number'] ) : '';
|
| 1160 |
$this->options['fax_number'] = isset( $_POST['fax_number'] ) ? trim( $_POST['fax_number'] ) : '';
|
| 1161 |
$this->options['order_mail'] = $order_mail;
|
| 1162 |
$this->options['inquiry_mail'] = isset( $_POST['inquiry_mail'] ) && is_email( trim( $_POST['inquiry_mail'] ) ) ? trim( $_POST['inquiry_mail'] ) : '';
|
| 1163 |
$this->options['sender_mail'] = isset( $_POST['sender_mail'] ) && is_email( trim( $_POST['sender_mail'] ) ) ? trim( $_POST['sender_mail'] ) : '';
|
| 1164 |
$this->options['error_mail'] = isset( $_POST['error_mail'] ) && is_email( trim( $_POST['error_mail'] ) ) ? trim( $_POST['error_mail'] ) : '';
|
| 1165 |
$this->options['postage_privilege'] = isset( $_POST['postage_privilege'] ) ? trim( $_POST['postage_privilege'] ) : '';
|
| 1166 |
$this->options['purchase_limit'] = isset( $_POST['purchase_limit'] ) ? trim( $_POST['purchase_limit'] ) : '';
|
| 1167 |
$this->options['point_rate'] = isset( $_POST['point_rate'] ) ? (int) $_POST['point_rate'] : 1;
|
| 1168 |
$this->options['start_point'] = isset( $_POST['start_point'] ) ? (int) $_POST['start_point'] : '';
|
| 1169 |
$this->options['shipping_rule'] = isset( $_POST['shipping_rule'] ) ? trim( $_POST['shipping_rule'] ) : '';
|
| 1170 |
$this->options['tax_display'] = isset( $_POST['tax_display'] ) ? trim( $_POST['tax_display'] ) : 'activate';
|
| 1171 |
$this->options['tax_mode'] = isset( $_POST['tax_mode'] ) ? trim( $_POST['tax_mode'] ) : 'include';
|
| 1172 |
$this->options['tax_target'] = isset( $_POST['tax_target'] ) ? trim( $_POST['tax_target'] ) : 'products';
|
| 1173 |
$this->options['tax_rate'] = isset( $_POST['tax_rate'] ) ? (int) $_POST['tax_rate'] : '';
|
| 1174 |
$this->options['tax_method'] = isset( $_POST['tax_method'] ) ? trim( $_POST['tax_method'] ) : '';
|
| 1175 |
$this->options['applicable_taxrate'] = ( isset( $_POST['applicable_taxrate'] ) ) ? $_POST['applicable_taxrate'] : 'standard';
|
| 1176 |
$this->options['tax_rate_reduced'] = ( isset( $_POST['tax_rate_reduced'] ) ) ? (int) $_POST['tax_rate_reduced'] : '';
|
| 1177 |
$this->options['cod_type'] = isset( $this->options['cod_type'] ) ? $this->options['cod_type'] : 'fix';
|
| 1178 |
$this->options['fee_subject'] = ( isset( $_POST['fee_subject'] ) ) ? trim( $_POST['fee_subject'] ) : 'all';
|
| 1179 |
$this->options['transferee'] = isset( $_POST['transferee'] ) ? trim( $_POST['transferee'] ) : '';
|
| 1180 |
$this->options['tatransfer_limit'] = isset( $_POST['tatransfer_limit'] ) ? trim( $_POST['tatransfer_limit'] ) : '';
|
| 1181 |
$this->options['copyright'] = isset( $_POST['copyright'] ) ? trim( $_POST['copyright'] ) : '';
|
| 1182 |
$this->options['business_registration_number'] = ( isset( $_POST['business_registration_number'] ) ) ? trim( $_POST['business_registration_number'] ) : '';
|
| 1183 |
$this->options['membersystem_state'] = isset( $_POST['membersystem_state'] ) ? trim( $_POST['membersystem_state'] ) : '';
|
| 1184 |
$this->options['membersystem_point'] = isset( $_POST['membersystem_point'] ) ? trim( $_POST['membersystem_point'] ) : '';
|
| 1185 |
$this->options['point_coverage'] = isset( $_POST['point_coverage'] ) ? (int) $_POST['point_coverage'] : 0;
|
| 1186 |
$this->options['point_assign'] = isset( $_POST['point_assign'] ) ? (int) $_POST['point_assign'] : 1;
|
| 1187 |
$this->options['address_search'] = isset( $_POST['address_search'] ) ? trim( $_POST['address_search'] ) : 'deactivate';
|
| 1188 |
$this->options['stock_status_label'] = ( isset( $_POST['stock_status_label'] ) ) ? $_POST['stock_status_label'] : array();
|
| 1189 |
$this->options['order_acceptable_label'] = ( isset( $_POST['order_acceptable_label'] ) ) ? trim( $_POST['order_acceptable_label'] ) : '';
|
| 1190 |
|
| 1191 |
$this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options );
|
| 1192 |
|
| 1193 |
update_option( 'usces', $this->options );
|
| 1194 |
|
| 1195 |
$this->action_status = 'success';
|
| 1196 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1197 |
|
| 1198 |
} else {
|
| 1199 |
$this->action_status = 'none';
|
| 1200 |
$this->action_message = '';
|
| 1201 |
}
|
| 1202 |
|
| 1203 |
require_once USCES_PLUGIN_DIR . '/includes/admin_setup.php';
|
| 1204 |
}
|
| 1205 |
|
| 1206 |
/**
|
| 1207 |
* Shop Schedule Page
|
| 1208 |
*/
|
| 1209 |
public function admin_schedule_page() {
|
| 1210 |
$this->options = get_option( 'usces' );
|
| 1211 |
|
| 1212 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1213 |
|
| 1214 |
check_admin_referer( 'admin_schedule', 'wc_nonce' );
|
| 1215 |
|
| 1216 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1217 |
|
| 1218 |
$this->options['campaign_schedule'] = isset( $_POST['campaign_schedule'] ) ? $_POST['campaign_schedule'] : '0';
|
| 1219 |
if ( isset( $_POST['business_days'] ) ) {
|
| 1220 |
$this->options['business_days'] = $_POST['business_days'];
|
| 1221 |
}
|
| 1222 |
update_option( 'usces', $this->options );
|
| 1223 |
|
| 1224 |
do_action( 'usces_action_admin_schedule_update' );
|
| 1225 |
|
| 1226 |
$this->action_status = 'success';
|
| 1227 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1228 |
} else {
|
| 1229 |
$this->action_status = 'none';
|
| 1230 |
$this->action_message = '';
|
| 1231 |
}
|
| 1232 |
|
| 1233 |
require_once USCES_PLUGIN_DIR . '/includes/admin_schedule.php';
|
| 1234 |
}
|
| 1235 |
|
| 1236 |
/**
|
| 1237 |
* Shop Delivery Page.
|
| 1238 |
*/
|
| 1239 |
public function admin_delivery_page() {
|
| 1240 |
$this->options = get_option( 'usces' );
|
| 1241 |
|
| 1242 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1243 |
|
| 1244 |
check_admin_referer( 'admin_delivery', 'wc_nonce' );
|
| 1245 |
|
| 1246 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1247 |
|
| 1248 |
if ( isset( $_POST['delivery_time_limit'] ) ) {
|
| 1249 |
$this->options['delivery_time_limit'] = $_POST['delivery_time_limit'];
|
| 1250 |
}
|
| 1251 |
if ( isset( $_POST['shortest_delivery_time'] ) ) {
|
| 1252 |
$this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time'];
|
| 1253 |
}
|
| 1254 |
if ( isset( $_POST['delivery_after_days'] ) ) {
|
| 1255 |
$this->options['delivery_after_days'] = $_POST['delivery_after_days'];
|
| 1256 |
}
|
| 1257 |
$this->options = apply_filters( 'usces_filter_admin_delivery_options', $this->options );
|
| 1258 |
|
| 1259 |
update_option( 'usces', $this->options );
|
| 1260 |
|
| 1261 |
$this->action_status = 'success';
|
| 1262 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1263 |
} else {
|
| 1264 |
$this->action_status = 'none';
|
| 1265 |
$this->action_message = '';
|
| 1266 |
}
|
| 1267 |
|
| 1268 |
require_once USCES_PLUGIN_DIR . '/includes/admin_delivery.php';
|
| 1269 |
}
|
| 1270 |
|
| 1271 |
/**
|
| 1272 |
* Shop Mail Page.
|
| 1273 |
*/
|
| 1274 |
public function admin_mail_page() {
|
| 1275 |
global $allowedposttags;
|
| 1276 |
|
| 1277 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1278 |
check_admin_referer( 'admin_mail', 'wc_nonce' );
|
| 1279 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1280 |
|
| 1281 |
$mail_othermail = get_option( 'usces_mail_othermail', array() );
|
| 1282 |
foreach ( $_POST['title'] as $key => $value ) {
|
| 1283 |
$value = wel_esc_script( $value );
|
| 1284 |
if ( 'othermail' == $key ) {
|
| 1285 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1286 |
if ( empty( $mail_othermail['title'] ) && isset( $this->options['mail_default']['title'][ $key ] ) ) {
|
| 1287 |
$mail_othermail['title'] = $this->options['mail_default']['title'][ $key ];
|
| 1288 |
$this->options['mail_data']['title'][ $key ] = $mail_othermail['title'];
|
| 1289 |
}
|
| 1290 |
} else {
|
| 1291 |
$mail_othermail['title'] = trim( $value );
|
| 1292 |
$this->options['mail_data']['title'][ $key ] = $mail_othermail['title'];
|
| 1293 |
}
|
| 1294 |
} else {
|
| 1295 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1296 |
$this->options['mail_data']['title'][ $key ] = isset( $this->options['mail_default']['title'][ $key ] ) ? $this->options['mail_default']['title'][ $key ] : '';
|
| 1297 |
} else {
|
| 1298 |
$this->options['mail_data']['title'][ $key ] = trim( $value );
|
| 1299 |
}
|
| 1300 |
}
|
| 1301 |
}
|
| 1302 |
foreach ( $_POST['header'] as $key => $value ) {
|
| 1303 |
$value = wel_esc_script( $value );
|
| 1304 |
if ( 'othermail' == $key ) {
|
| 1305 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1306 |
if ( empty( $mail_othermail['header'] ) && isset( $this->options['mail_default']['header'][ $key ] ) ) {
|
| 1307 |
$mail_othermail['header'] = $this->options['mail_default']['header'][ $key ];
|
| 1308 |
$this->options['mail_data']['header'][ $key ] = $mail_othermail['header'];
|
| 1309 |
}
|
| 1310 |
} else {
|
| 1311 |
$mail_othermail['header'] = $value;
|
| 1312 |
$this->options['mail_data']['header'][ $key ] = $mail_othermail['header'];
|
| 1313 |
}
|
| 1314 |
} else {
|
| 1315 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1316 |
$this->options['mail_data']['header'][ $key ] = isset( $this->options['mail_default']['header'][ $key ] ) ? $this->options['mail_default']['header'][ $key ] : '';
|
| 1317 |
} else {
|
| 1318 |
$this->options['mail_data']['header'][ $key ] = $value;
|
| 1319 |
}
|
| 1320 |
}
|
| 1321 |
}
|
| 1322 |
foreach ( $_POST['footer'] as $key => $value ) {
|
| 1323 |
$value = wel_esc_script( $value );
|
| 1324 |
if ( 'othermail' == $key ) {
|
| 1325 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1326 |
if ( empty( $mail_othermail['footer'] ) && isset( $this->options['mail_default']['footer'][ $key ] ) ) {
|
| 1327 |
$mail_othermail['footer'] = $this->options['mail_default']['footer'][ $key ];
|
| 1328 |
$this->options['mail_data']['footer'][ $key ] = $mail_othermail['footer'];
|
| 1329 |
}
|
| 1330 |
} else {
|
| 1331 |
$mail_othermail['footer'] = $value;
|
| 1332 |
$this->options['mail_data']['footer'][ $key ] = $mail_othermail['footer'];
|
| 1333 |
}
|
| 1334 |
} else {
|
| 1335 |
if ( WCUtils::is_blank( $value ) ) {
|
| 1336 |
$this->options['mail_data']['footer'][ $key ] = isset( $this->options['mail_default']['footer'][ $key ] ) ? $this->options['mail_default']['footer'][ $key ] : '';
|
| 1337 |
} else {
|
| 1338 |
$this->options['mail_data']['footer'][ $key ] = $value;
|
| 1339 |
}
|
| 1340 |
}
|
| 1341 |
}
|
| 1342 |
update_option( 'usces', $this->options );
|
| 1343 |
update_option( 'usces_mail_othermail', $mail_othermail );
|
| 1344 |
|
| 1345 |
$this->action_status = 'success';
|
| 1346 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1347 |
|
| 1348 |
} elseif ( isset( $_POST['usces_option_update_top'] ) ) {
|
| 1349 |
check_admin_referer( 'admin_mail', 'wc_nonce' );
|
| 1350 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1351 |
|
| 1352 |
$email_attach_file_extension = wel_email_attach_file_extension( explode( ',', trim( wel_esc_script( $_POST['email_attach_file_extension'] ) ) ) );
|
| 1353 |
|
| 1354 |
$this->options['smtp_hostname'] = esc_html( trim( $_POST['smtp_hostname'] ) );
|
| 1355 |
$this->options['newmem_admin_mail'] = (int) $_POST['newmem_admin_mail'];
|
| 1356 |
$this->options['updmem_admin_mail'] = (int) $_POST['updmem_admin_mail'];
|
| 1357 |
$this->options['updmem_customer_mail'] = (int) $_POST['updmem_customer_mail'];
|
| 1358 |
$this->options['delmem_admin_mail'] = (int) $_POST['delmem_admin_mail'];
|
| 1359 |
$this->options['delmem_customer_mail'] = (int) $_POST['delmem_customer_mail'];
|
| 1360 |
$this->options['put_customer_name'] = (int) $_POST['put_customer_name'];
|
| 1361 |
$this->options['email_attach_feature'] = (int) $_POST['email_attach_feature'];
|
| 1362 |
$this->options['email_attach_file_extension'] = implode( ',', $email_attach_file_extension );
|
| 1363 |
$this->options['email_attach_file_size'] = (int) $_POST['email_attach_file_size'];
|
| 1364 |
$this->options['add_html_email_option'] = (int) $_POST['add_html_email_option'];
|
| 1365 |
update_option( 'usces', $this->options );
|
| 1366 |
|
| 1367 |
$this->action_status = 'success';
|
| 1368 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1369 |
|
| 1370 |
} elseif ( isset( $_POST['usces_option_update_auto'] ) ) {
|
| 1371 |
check_admin_referer( 'admin_mail', 'wc_nonce' );
|
| 1372 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1373 |
|
| 1374 |
$mail_thankyou = get_option( 'usces_mail_thankyou', array() );
|
| 1375 |
if ( WCUtils::is_blank( $_POST['title']['thankyou'] ) ) {
|
| 1376 |
if ( empty( $mail_thankyou['title'] ) && isset( $this->options['mail_default']['title']['thankyou'] ) ) {
|
| 1377 |
$mail_thankyou['title'] = $this->options['mail_default']['title']['thankyou'];
|
| 1378 |
$this->options['mail_data']['title']['thankyou'] = $mail_thankyou['title'];
|
| 1379 |
}
|
| 1380 |
} else {
|
| 1381 |
$mail_thankyou['title'] = trim( wel_esc_script( $_POST['title']['thankyou'] ) );
|
| 1382 |
$this->options['mail_data']['title']['thankyou'] = $mail_thankyou['title'];
|
| 1383 |
}
|
| 1384 |
if ( WCUtils::is_blank( $_POST['header']['thankyou'] ) ) {
|
| 1385 |
if ( empty( $mail_thankyou['header'] ) && isset( $this->options['mail_default']['header']['thankyou'] ) ) {
|
| 1386 |
$mail_thankyou['header'] = $this->options['mail_default']['header']['thankyou'];
|
| 1387 |
$this->options['mail_data']['header']['thankyou'] = $mail_thankyou['header'];
|
| 1388 |
}
|
| 1389 |
} else {
|
| 1390 |
$mail_thankyou['header'] = trim( wel_esc_script( $_POST['header']['thankyou'] ) );
|
| 1391 |
$this->options['mail_data']['header']['thankyou'] = $mail_thankyou['header'];
|
| 1392 |
}
|
| 1393 |
if ( WCUtils::is_blank( $_POST['footer']['thankyou'] ) ) {
|
| 1394 |
if ( empty( $mail_thankyou['footer'] ) && isset( $this->options['mail_default']['footer']['thankyou'] ) ) {
|
| 1395 |
$mail_thankyou['footer'] = $this->options['mail_default']['footer']['thankyou'];
|
| 1396 |
$this->options['mail_data']['footer']['thankyou'] = $mail_thankyou['footer'];
|
| 1397 |
}
|
| 1398 |
} else {
|
| 1399 |
$mail_thankyou['footer'] = trim( wel_esc_script( $_POST['footer']['thankyou'] ) );
|
| 1400 |
$this->options['mail_data']['footer']['thankyou'] = $mail_thankyou['footer'];
|
| 1401 |
}
|
| 1402 |
update_option( 'usces_mail_thankyou', $mail_thankyou );
|
| 1403 |
|
| 1404 |
$mail_order = get_option( 'usces_mail_order', array() );
|
| 1405 |
if ( WCUtils::is_blank( $_POST['title']['order'] ) ) {
|
| 1406 |
if ( empty( $mail_order['title'] ) && isset( $this->options['mail_default']['title']['order'] ) ) {
|
| 1407 |
$mail_order['title'] = $this->options['mail_default']['title']['order'];
|
| 1408 |
$this->options['mail_data']['title']['order'] = $mail_order['title'];
|
| 1409 |
}
|
| 1410 |
} else {
|
| 1411 |
$mail_order['title'] = trim( wel_esc_script( $_POST['title']['order'] ) );
|
| 1412 |
$this->options['mail_data']['title']['order'] = $mail_order['title'];
|
| 1413 |
}
|
| 1414 |
if ( WCUtils::is_blank( $_POST['header']['order'] ) ) {
|
| 1415 |
if ( empty( $mail_order['header'] ) && isset( $this->options['mail_default']['header']['order'] ) ) {
|
| 1416 |
$mail_order['header'] = $this->options['mail_default']['header']['order'];
|
| 1417 |
$this->options['mail_data']['header']['order'] = $mail_order['header'];
|
| 1418 |
}
|
| 1419 |
} else {
|
| 1420 |
$mail_order['header'] = trim( wel_esc_script( $_POST['header']['order'] ) );
|
| 1421 |
$this->options['mail_data']['header']['order'] = $mail_order['header'];
|
| 1422 |
}
|
| 1423 |
if ( WCUtils::is_blank( $_POST['footer']['order'] ) ) {
|
| 1424 |
if ( empty( $mail_order['footer'] ) && isset( $this->options['mail_default']['footer']['order'] ) ) {
|
| 1425 |
$mail_order['footer'] = $this->options['mail_default']['footer']['order'];
|
| 1426 |
$this->options['mail_data']['footer']['order'] = $mail_order['footer'];
|
| 1427 |
}
|
| 1428 |
} else {
|
| 1429 |
$mail_order['footer'] = trim( wel_esc_script( $_POST['footer']['order'] ) );
|
| 1430 |
$this->options['mail_data']['footer']['order'] = $mail_order['footer'];
|
| 1431 |
}
|
| 1432 |
update_option( 'usces_mail_order', $mail_order );
|
| 1433 |
|
| 1434 |
$mail_inquiry = get_option( 'usces_mail_inquiry', array() );
|
| 1435 |
if ( WCUtils::is_blank( $_POST['title']['inquiry'] ) ) {
|
| 1436 |
if ( empty( $mail_inquiry['title'] ) && isset( $this->options['mail_default']['title']['inquiry'] ) ) {
|
| 1437 |
$mail_inquiry['title'] = $this->options['mail_default']['title']['inquiry'];
|
| 1438 |
$this->options['mail_data']['title']['inquiry'] = $mail_inquiry['title'];
|
| 1439 |
}
|
| 1440 |
} else {
|
| 1441 |
$mail_inquiry['title'] = trim( wel_esc_script( $_POST['title']['inquiry'] ) );
|
| 1442 |
$this->options['mail_data']['title']['inquiry'] = $mail_inquiry['title'];
|
| 1443 |
}
|
| 1444 |
if ( WCUtils::is_blank( $_POST['header']['inquiry'] ) ) {
|
| 1445 |
if ( empty( $mail_inquiry['header'] ) && isset( $this->options['mail_default']['header']['inquiry'] ) ) {
|
| 1446 |
$mail_inquiry['header'] = $this->options['mail_default']['header']['inquiry'];
|
| 1447 |
$this->options['mail_data']['header']['inquiry'] = $mail_inquiry['header'];
|
| 1448 |
}
|
| 1449 |
} else {
|
| 1450 |
$mail_inquiry['header'] = trim( wel_esc_script( $_POST['header']['inquiry'] ) );
|
| 1451 |
$this->options['mail_data']['header']['inquiry'] = $mail_inquiry['header'];
|
| 1452 |
}
|
| 1453 |
if ( WCUtils::is_blank( $_POST['footer']['inquiry'] ) ) {
|
| 1454 |
if ( empty( $mail_inquiry['footer'] ) && isset( $this->options['mail_default']['footer']['inquiry'] ) ) {
|
| 1455 |
$mail_inquiry['footer'] = $this->options['mail_default']['footer']['inquiry'];
|
| 1456 |
$this->options['mail_data']['footer']['inquiry'] = $mail_inquiry['footer'];
|
| 1457 |
}
|
| 1458 |
} else {
|
| 1459 |
$mail_inquiry['footer'] = trim( wel_esc_script( $_POST['footer']['inquiry'] ) );
|
| 1460 |
$this->options['mail_data']['footer']['inquiry'] = $mail_inquiry['footer'];
|
| 1461 |
}
|
| 1462 |
update_option( 'usces_mail_inquiry', $mail_inquiry );
|
| 1463 |
|
| 1464 |
$mail_membercomp = get_option( 'usces_mail_membercomp', array() );
|
| 1465 |
if ( WCUtils::is_blank( $_POST['title']['membercomp'] ) ) {
|
| 1466 |
if ( empty( $mail_membercomp['title'] ) && isset( $this->options['mail_default']['title']['membercomp'] ) ) {
|
| 1467 |
$mail_membercomp['title'] = $this->options['mail_default']['title']['membercomp'];
|
| 1468 |
$this->options['mail_data']['title']['membercomp'] = $mail_membercomp['title'];
|
| 1469 |
}
|
| 1470 |
} else {
|
| 1471 |
$mail_membercomp['title'] = trim( wel_esc_script( $_POST['title']['membercomp'] ) );
|
| 1472 |
$this->options['mail_data']['title']['membercomp'] = $mail_membercomp['title'];
|
| 1473 |
}
|
| 1474 |
if ( WCUtils::is_blank( wel_esc_script( $_POST['header']['membercomp'] ) ) ) {
|
| 1475 |
if ( empty( $mail_membercomp['header'] ) && isset( $this->options['mail_default']['header']['membercomp'] ) ) {
|
| 1476 |
$mail_membercomp['header'] = $this->options['mail_default']['header']['membercomp'];
|
| 1477 |
$this->options['mail_data']['header']['membercomp'] = $mail_membercomp['header'];
|
| 1478 |
}
|
| 1479 |
} else {
|
| 1480 |
$mail_membercomp['header'] = trim( wel_esc_script( $_POST['header']['membercomp'] ) );
|
| 1481 |
$this->options['mail_data']['header']['membercomp'] = $mail_membercomp['header'];
|
| 1482 |
}
|
| 1483 |
if ( WCUtils::is_blank( $_POST['footer']['membercomp'] ) ) {
|
| 1484 |
if ( empty( $mail_membercomp['footer'] ) && isset( $this->options['mail_default']['footer']['membercomp'] ) ) {
|
| 1485 |
$mail_membercomp['footer'] = $this->options['mail_default']['footer']['membercomp'];
|
| 1486 |
$this->options['mail_data']['footer']['membercomp'] = $mail_membercomp['footer'];
|
| 1487 |
}
|
| 1488 |
} else {
|
| 1489 |
$mail_membercomp['footer'] = trim( wel_esc_script( $_POST['footer']['membercomp'] ) );
|
| 1490 |
$this->options['mail_data']['footer']['membercomp'] = $mail_membercomp['footer'];
|
| 1491 |
}
|
| 1492 |
update_option( 'usces_mail_membercomp', $mail_membercomp );
|
| 1493 |
|
| 1494 |
$this->action_status = 'success';
|
| 1495 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1496 |
|
| 1497 |
} elseif ( isset( $_POST['usces_option_update_manual'] ) ) {
|
| 1498 |
check_admin_referer( 'admin_mail', 'wc_nonce' );
|
| 1499 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1500 |
|
| 1501 |
$mail_completionmail = get_option( 'usces_mail_completionmail', array() );
|
| 1502 |
if ( WCUtils::is_blank( $_POST['title']['completionmail'] ) ) {
|
| 1503 |
if ( empty( $mail_completionmail['title'] ) && isset( $this->options['mail_default']['title']['completionmail'] ) ) {
|
| 1504 |
$mail_completionmail['title'] = $this->options['mail_default']['title']['completionmail'];
|
| 1505 |
$this->options['mail_data']['title']['completionmail'] = $mail_completionmail['title'];
|
| 1506 |
}
|
| 1507 |
} else {
|
| 1508 |
$mail_completionmail['title'] = trim( wel_esc_script( $_POST['title']['completionmail'] ) );
|
| 1509 |
$this->options['mail_data']['title']['completionmail'] = $mail_completionmail['title'];
|
| 1510 |
}
|
| 1511 |
if ( WCUtils::is_blank( $_POST['header']['completionmail'] ) ) {
|
| 1512 |
if ( empty( $mail_completionmail['header'] ) && isset( $this->options['mail_default']['header']['completionmail'] ) ) {
|
| 1513 |
$mail_completionmail['header'] = $this->options['mail_default']['header']['completionmail'];
|
| 1514 |
$this->options['mail_data']['header']['completionmail'] = $mail_completionmail['header'];
|
| 1515 |
}
|
| 1516 |
} else {
|
| 1517 |
$mail_completionmail['header'] = trim( wel_esc_script( $_POST['header']['completionmail'] ) );
|
| 1518 |
$this->options['mail_data']['header']['completionmail'] = $mail_completionmail['header'];
|
| 1519 |
}
|
| 1520 |
if ( WCUtils::is_blank( $_POST['footer']['completionmail'] ) ) {
|
| 1521 |
if ( empty( $mail_completionmail['footer'] ) && isset( $this->options['mail_default']['footer']['completionmail'] ) ) {
|
| 1522 |
$mail_completionmail['footer'] = $this->options['mail_default']['footer']['completionmail'];
|
| 1523 |
$this->options['mail_data']['footer']['completionmail'] = $mail_completionmail['footer'];
|
| 1524 |
}
|
| 1525 |
} else {
|
| 1526 |
$mail_completionmail['footer'] = trim( wel_esc_script( $_POST['footer']['completionmail'] ) );
|
| 1527 |
$this->options['mail_data']['footer']['completionmail'] = $mail_completionmail['footer'];
|
| 1528 |
}
|
| 1529 |
update_option( 'usces_mail_completionmail', $mail_completionmail );
|
| 1530 |
|
| 1531 |
$mail_ordermail = get_option( 'usces_mail_ordermail', array() );
|
| 1532 |
if ( WCUtils::is_blank( $_POST['title']['ordermail'] ) ) {
|
| 1533 |
if ( empty( $mail_ordermail['title'] ) && isset( $this->options['mail_default']['title']['ordermail'] ) ) {
|
| 1534 |
$mail_ordermail['title'] = $this->options['mail_default']['title']['ordermail'];
|
| 1535 |
$this->options['mail_data']['title']['ordermail'] = $mail_ordermail['title'];
|
| 1536 |
}
|
| 1537 |
} else {
|
| 1538 |
$mail_ordermail['title'] = trim( wel_esc_script( $_POST['title']['ordermail'] ) );
|
| 1539 |
$this->options['mail_data']['title']['ordermail'] = $mail_ordermail['title'];
|
| 1540 |
}
|
| 1541 |
if ( WCUtils::is_blank( $_POST['header']['ordermail'] ) ) {
|
| 1542 |
if ( empty( $mail_ordermail['header'] ) && isset( $this->options['mail_default']['header']['ordermail'] ) ) {
|
| 1543 |
$mail_ordermail['header'] = $this->options['mail_default']['header']['ordermail'];
|
| 1544 |
$this->options['mail_data']['header']['ordermail'] = $mail_ordermail['header'];
|
| 1545 |
}
|
| 1546 |
} else {
|
| 1547 |
$mail_ordermail['header'] = trim( wel_esc_script( $_POST['header']['ordermail'] ) );
|
| 1548 |
$this->options['mail_data']['header']['ordermail'] = $mail_ordermail['header'];
|
| 1549 |
}
|
| 1550 |
if ( WCUtils::is_blank( $_POST['footer']['ordermail'] ) ) {
|
| 1551 |
if ( empty( $mail_ordermail['footer'] ) && isset( $this->options['mail_default']['footer']['ordermail'] ) ) {
|
| 1552 |
$mail_ordermail['footer'] = $this->options['mail_default']['footer']['ordermail'];
|
| 1553 |
$this->options['mail_data']['footer']['ordermail'] = $mail_ordermail['footer'];
|
| 1554 |
}
|
| 1555 |
} else {
|
| 1556 |
$mail_ordermail['footer'] = trim( wel_esc_script( $_POST['footer']['ordermail'] ) );
|
| 1557 |
$this->options['mail_data']['footer']['ordermail'] = $mail_ordermail['footer'];
|
| 1558 |
}
|
| 1559 |
update_option( 'usces_mail_ordermail', $mail_ordermail );
|
| 1560 |
|
| 1561 |
$mail_changemail = get_option( 'usces_mail_changemail', array() );
|
| 1562 |
if ( WCUtils::is_blank( $_POST['title']['changemail'] ) ) {
|
| 1563 |
if ( empty( $mail_changemail['title'] ) && isset( $this->options['mail_default']['title']['changemail'] ) ) {
|
| 1564 |
$mail_changemail['title'] = $this->options['mail_default']['title']['changemail'];
|
| 1565 |
$this->options['mail_data']['title']['changemail'] = $mail_changemail['title'];
|
| 1566 |
}
|
| 1567 |
} else {
|
| 1568 |
$mail_changemail['title'] = trim( wel_esc_script( $_POST['title']['changemail'] ) );
|
| 1569 |
$this->options['mail_data']['title']['changemail'] = $mail_changemail['title'];
|
| 1570 |
}
|
| 1571 |
if ( WCUtils::is_blank( $_POST['header']['changemail'] ) ) {
|
| 1572 |
if ( empty( $mail_changemail['header'] ) && isset( $this->options['mail_default']['header']['changemail'] ) ) {
|
| 1573 |
$mail_changemail['header'] = $this->options['mail_default']['header']['changemail'];
|
| 1574 |
$this->options['mail_data']['header']['changemail'] = $mail_changemail['header'];
|
| 1575 |
}
|
| 1576 |
} else {
|
| 1577 |
$mail_changemail['header'] = trim( wel_esc_script( $_POST['header']['changemail'] ) );
|
| 1578 |
$this->options['mail_data']['header']['changemail'] = $mail_changemail['header'];
|
| 1579 |
}
|
| 1580 |
if ( WCUtils::is_blank( $_POST['footer']['changemail'] ) ) {
|
| 1581 |
if ( empty( $mail_changemail['footer'] ) && isset( $this->options['mail_default']['footer']['changemail'] ) ) {
|
| 1582 |
$mail_changemail['footer'] = $this->options['mail_default']['footer']['changemail'];
|
| 1583 |
$this->options['mail_data']['footer']['changemail'] = $mail_changemail['footer'];
|
| 1584 |
}
|
| 1585 |
} else {
|
| 1586 |
$mail_changemail['footer'] = trim( wel_esc_script( $_POST['footer']['changemail'] ) );
|
| 1587 |
$this->options['mail_data']['footer']['changemail'] = $mail_changemail['footer'];
|
| 1588 |
}
|
| 1589 |
update_option( 'usces_mail_changemail', $mail_changemail );
|
| 1590 |
|
| 1591 |
$mail_receiptmail = get_option( 'usces_mail_receiptmail', array() );
|
| 1592 |
if ( WCUtils::is_blank( $_POST['title']['receiptmail'] ) ) {
|
| 1593 |
if ( empty( $mail_receiptmail['title'] ) && isset( $this->options['mail_default']['title']['receiptmail'] ) ) {
|
| 1594 |
$mail_receiptmail['title'] = $this->options['mail_default']['title']['receiptmail'];
|
| 1595 |
$this->options['mail_data']['title']['receiptmail'] = $mail_receiptmail['title'];
|
| 1596 |
}
|
| 1597 |
} else {
|
| 1598 |
$mail_receiptmail['title'] = trim( wel_esc_script( $_POST['title']['receiptmail'] ) );
|
| 1599 |
$this->options['mail_data']['title']['receiptmail'] = $mail_receiptmail['title'];
|
| 1600 |
}
|
| 1601 |
if ( WCUtils::is_blank( $_POST['header']['receiptmail'] ) ) {
|
| 1602 |
if ( empty( $mail_receiptmail['header'] ) && isset( $this->options['mail_default']['header']['receiptmail'] ) ) {
|
| 1603 |
$mail_receiptmail['header'] = $this->options['mail_default']['header']['receiptmail'];
|
| 1604 |
$this->options['mail_data']['header']['receiptmail'] = $mail_receiptmail['header'];
|
| 1605 |
}
|
| 1606 |
} else {
|
| 1607 |
$mail_receiptmail['header'] = trim( wel_esc_script( $_POST['header']['receiptmail'] ) );
|
| 1608 |
$this->options['mail_data']['header']['receiptmail'] = $mail_receiptmail['header'];
|
| 1609 |
}
|
| 1610 |
if ( WCUtils::is_blank( $_POST['footer']['receiptmail'] ) ) {
|
| 1611 |
if ( empty( $mail_receiptmail['footer'] ) && isset( $this->options['mail_default']['footer']['receiptmail'] ) ) {
|
| 1612 |
$mail_receiptmail['footer'] = $this->options['mail_default']['footer']['receiptmail'];
|
| 1613 |
$this->options['mail_data']['footer']['receiptmail'] = $mail_receiptmail['footer'];
|
| 1614 |
}
|
| 1615 |
} else {
|
| 1616 |
$mail_receiptmail['footer'] = trim( wel_esc_script( $_POST['footer']['receiptmail'] ) );
|
| 1617 |
$this->options['mail_data']['footer']['receiptmail'] = $mail_receiptmail['footer'];
|
| 1618 |
}
|
| 1619 |
update_option( 'usces_mail_receiptmail', $mail_receiptmail );
|
| 1620 |
|
| 1621 |
$mail_mitumorimail = get_option( 'usces_mail_mitumorimail', array() );
|
| 1622 |
if ( WCUtils::is_blank( $_POST['title']['mitumorimail'] ) ) {
|
| 1623 |
if ( empty( $mail_mitumorimail['title'] ) && isset( $this->options['mail_default']['title']['mitumorimail'] ) ) {
|
| 1624 |
$mail_mitumorimail['title'] = $this->options['mail_default']['title']['mitumorimail'];
|
| 1625 |
$this->options['mail_data']['title']['mitumorimail'] = $mail_mitumorimail['title'];
|
| 1626 |
}
|
| 1627 |
} else {
|
| 1628 |
$mail_mitumorimail['title'] = trim( wel_esc_script( $_POST['title']['mitumorimail'] ) );
|
| 1629 |
$this->options['mail_data']['title']['mitumorimail'] = $mail_mitumorimail['title'];
|
| 1630 |
}
|
| 1631 |
if ( WCUtils::is_blank( $_POST['header']['mitumorimail'] ) ) {
|
| 1632 |
if ( empty( $mail_mitumorimail['header'] ) && isset( $this->options['mail_default']['header']['mitumorimail'] ) ) {
|
| 1633 |
$mail_mitumorimail['header'] = $this->options['mail_default']['header']['mitumorimail'];
|
| 1634 |
$this->options['mail_data']['header']['mitumorimail'] = $mail_mitumorimail['header'];
|
| 1635 |
}
|
| 1636 |
} else {
|
| 1637 |
$mail_mitumorimail['header'] = trim( wel_esc_script( $_POST['header']['mitumorimail'] ) );
|
| 1638 |
$this->options['mail_data']['header']['mitumorimail'] = $mail_mitumorimail['header'];
|
| 1639 |
}
|
| 1640 |
if ( WCUtils::is_blank( $_POST['footer']['mitumorimail'] ) ) {
|
| 1641 |
if ( empty( $mail_mitumorimail['footer'] ) && isset( $this->options['mail_default']['footer']['mitumorimail'] ) ) {
|
| 1642 |
$mail_mitumorimail['footer'] = $this->options['mail_default']['footer']['mitumorimail'];
|
| 1643 |
$this->options['mail_data']['footer']['mitumorimail'] = $mail_mitumorimail['footer'];
|
| 1644 |
}
|
| 1645 |
} else {
|
| 1646 |
$mail_mitumorimail['footer'] = trim( wel_esc_script( $_POST['footer']['mitumorimail'] ) );
|
| 1647 |
$this->options['mail_data']['footer']['mitumorimail'] = $mail_mitumorimail['footer'];
|
| 1648 |
}
|
| 1649 |
update_option( 'usces_mail_mitumorimail', $mail_mitumorimail );
|
| 1650 |
|
| 1651 |
$mail_cancelmail = get_option( 'usces_mail_cancelmail', array() );
|
| 1652 |
if ( WCUtils::is_blank( $_POST['title']['cancelmail'] ) ) {
|
| 1653 |
if ( empty( $mail_cancelmail['title'] ) && isset( $this->options['mail_default']['title']['cancelmail'] ) ) {
|
| 1654 |
$mail_cancelmail['title'] = $this->options['mail_default']['title']['cancelmail'];
|
| 1655 |
$this->options['mail_data']['title']['cancelmail'] = $mail_cancelmail['title'];
|
| 1656 |
}
|
| 1657 |
} else {
|
| 1658 |
$mail_cancelmail['title'] = trim( wel_esc_script( $_POST['title']['cancelmail'] ) );
|
| 1659 |
$this->options['mail_data']['title']['cancelmail'] = $mail_cancelmail['title'];
|
| 1660 |
}
|
| 1661 |
if ( WCUtils::is_blank( $_POST['header']['cancelmail'] ) ) {
|
| 1662 |
if ( empty( $mail_cancelmail['header'] ) && isset( $this->options['mail_default']['header']['cancelmail'] ) ) {
|
| 1663 |
$mail_cancelmail['header'] = $this->options['mail_default']['header']['cancelmail'];
|
| 1664 |
$this->options['mail_data']['header']['cancelmail'] = $mail_cancelmail['header'];
|
| 1665 |
}
|
| 1666 |
} else {
|
| 1667 |
$mail_cancelmail['header'] = trim( wel_esc_script( $_POST['header']['cancelmail'] ) );
|
| 1668 |
$this->options['mail_data']['header']['cancelmail'] = $mail_cancelmail['header'];
|
| 1669 |
}
|
| 1670 |
if ( WCUtils::is_blank( $_POST['footer']['cancelmail'] ) ) {
|
| 1671 |
if ( empty( $mail_cancelmail['footer'] ) && isset( $this->options['mail_default']['footer']['cancelmail'] ) ) {
|
| 1672 |
$mail_cancelmail['footer'] = $this->options['mail_default']['footer']['cancelmail'];
|
| 1673 |
$this->options['mail_data']['footer']['cancelmail'] = $mail_cancelmail['footer'];
|
| 1674 |
}
|
| 1675 |
} else {
|
| 1676 |
$mail_cancelmail['footer'] = trim( wel_esc_script( $_POST['footer']['cancelmail'] ) );
|
| 1677 |
$this->options['mail_data']['footer']['cancelmail'] = $mail_cancelmail['footer'];
|
| 1678 |
}
|
| 1679 |
update_option( 'usces_mail_cancelmail', $mail_cancelmail );
|
| 1680 |
|
| 1681 |
$this->action_status = 'success';
|
| 1682 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1683 |
|
| 1684 |
} else {
|
| 1685 |
$this->action_status = 'none';
|
| 1686 |
$this->action_message = '';
|
| 1687 |
}
|
| 1688 |
|
| 1689 |
do_action( 'usces_action_admin_mail_page' );
|
| 1690 |
|
| 1691 |
if ( isset( $this->options['add_html_email_option'] ) && 1 == $this->options['add_html_email_option'] ) {
|
| 1692 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
| 1693 |
}
|
| 1694 |
|
| 1695 |
require_once USCES_PLUGIN_DIR . '/includes/admin_mail.php';
|
| 1696 |
}
|
| 1697 |
|
| 1698 |
/**
|
| 1699 |
* Admin Cart Page.
|
| 1700 |
*/
|
| 1701 |
public function admin_cart_page() {
|
| 1702 |
global $allowedposttags;
|
| 1703 |
$this->options = get_option( 'usces' );
|
| 1704 |
|
| 1705 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1706 |
|
| 1707 |
check_admin_referer( 'admin_cart', 'wc_nonce' );
|
| 1708 |
|
| 1709 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1710 |
|
| 1711 |
foreach ( $this->options['indi_item_name'] as $key => $value ) {
|
| 1712 |
$this->options['indi_item_name'][ $key ] = isset( $_POST['indication'][ $key ] ) ? 1 : 0;
|
| 1713 |
}
|
| 1714 |
foreach ( $_POST['position'] as $key => $value ) {
|
| 1715 |
$this->options['pos_item_name'][ $key ] = $value;
|
| 1716 |
}
|
| 1717 |
foreach ( $_POST['header'] as $key => $value ) {
|
| 1718 |
$this->options['cart_page_data']['header'][ $key ] = wp_kses( $value, $allowedposttags );
|
| 1719 |
}
|
| 1720 |
foreach ( $_POST['footer'] as $key => $value ) {
|
| 1721 |
$this->options['cart_page_data']['footer'][ $key ] = wp_kses( $value, $allowedposttags );
|
| 1722 |
}
|
| 1723 |
if ( isset( $_POST['confirm_notes'] ) ) {
|
| 1724 |
$this->options['cart_page_data']['confirm_notes'] = wp_kses( $_POST['confirm_notes'], $allowedposttags );
|
| 1725 |
}
|
| 1726 |
update_option( 'usces', $this->options );
|
| 1727 |
|
| 1728 |
$this->action_status = 'success';
|
| 1729 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1730 |
|
| 1731 |
} else {
|
| 1732 |
$this->action_status = 'none';
|
| 1733 |
$this->action_message = '';
|
| 1734 |
}
|
| 1735 |
|
| 1736 |
require_once USCES_PLUGIN_DIR . '/includes/admin_cart.php';
|
| 1737 |
}
|
| 1738 |
|
| 1739 |
/**
|
| 1740 |
* Admin Member Page.
|
| 1741 |
*/
|
| 1742 |
public function admin_member_page() {
|
| 1743 |
global $allowedposttags;
|
| 1744 |
$this->options = get_option( 'usces' );
|
| 1745 |
|
| 1746 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1747 |
|
| 1748 |
check_admin_referer( 'admin_member', 'wc_nonce' );
|
| 1749 |
|
| 1750 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1751 |
|
| 1752 |
foreach ( $_POST['header'] as $key => $value ) {
|
| 1753 |
$this->options['member_page_data']['header'][ $key ] = wp_kses( $value, $allowedposttags );
|
| 1754 |
}
|
| 1755 |
foreach ( $_POST['footer'] as $key => $value ) {
|
| 1756 |
$this->options['member_page_data']['footer'][ $key ] = wp_kses( $value, $allowedposttags );
|
| 1757 |
}
|
| 1758 |
$this->options['member_page_data']['agree_member_exp'] = isset( $_POST['agree_member_exp'] ) ? $_POST['agree_member_exp'] : '';
|
| 1759 |
$this->options['member_page_data']['agree_member_cont'] = isset( $_POST['agree_member_cont'] ) ? $_POST['agree_member_cont'] : '';
|
| 1760 |
|
| 1761 |
$this->options['agree_member'] = isset( $_POST['agree_member'] ) ? $_POST['agree_member'] : 'deactivate';
|
| 1762 |
|
| 1763 |
update_option( 'usces', $this->options );
|
| 1764 |
|
| 1765 |
$this->action_status = 'success';
|
| 1766 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1767 |
|
| 1768 |
} else {
|
| 1769 |
$this->action_status = 'none';
|
| 1770 |
$this->action_message = '';
|
| 1771 |
}
|
| 1772 |
|
| 1773 |
require_once USCES_PLUGIN_DIR . '/includes/admin_member.php';
|
| 1774 |
}
|
| 1775 |
|
| 1776 |
/**
|
| 1777 |
* Admin System Page.
|
| 1778 |
*/
|
| 1779 |
public function admin_system_page() {
|
| 1780 |
global $usces_states;
|
| 1781 |
$action_status = '';
|
| 1782 |
|
| 1783 |
$this->options = get_option( 'usces' );
|
| 1784 |
|
| 1785 |
if ( isset( $_POST['usces_system_option_update'] ) ) {
|
| 1786 |
|
| 1787 |
check_admin_referer( 'admin_system', 'wc_nonce' );
|
| 1788 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1789 |
|
| 1790 |
$this->options['divide_item'] = isset( $_POST['divide_item'] ) ? 1 : 0;
|
| 1791 |
$this->options['itemimg_anchor_rel'] = isset( $_POST['itemimg_anchor_rel'] ) ? trim( $_POST['itemimg_anchor_rel'] ) : '';
|
| 1792 |
$this->options['fukugo_category_orderby'] = isset( $_POST['fukugo_category_orderby'] ) ? $_POST['fukugo_category_orderby'] : '';
|
| 1793 |
$this->options['fukugo_category_order'] = isset( $_POST['fukugo_category_order'] ) ? $_POST['fukugo_category_order'] : '';
|
| 1794 |
$this->options['settlement_path'] = isset( $_POST['settlement_path'] ) ? $_POST['settlement_path'] : '';
|
| 1795 |
if ( WCUtils::is_blank( $this->options['settlement_path'] ) ) {
|
| 1796 |
$this->options['settlement_path'] = USCES_PLUGIN_DIR . 'settlement/';
|
| 1797 |
}
|
| 1798 |
$sl = substr( $this->options['settlement_path'], -1 );
|
| 1799 |
if ( '/' != $sl && '\\' != $sl ) {
|
| 1800 |
$this->options['settlement_path'] .= '/';
|
| 1801 |
}
|
| 1802 |
$this->options['logs_path'] = isset( $_POST['logs_path'] ) ? $_POST['logs_path'] : '';
|
| 1803 |
if ( ! WCUtils::is_blank( $this->options['logs_path'] ) ) {
|
| 1804 |
$sl = substr( $this->options['logs_path'], -1 );
|
| 1805 |
if ( '/' == $sl || '\\' == $sl ) {
|
| 1806 |
$this->options['logs_path'] = substr( $this->options['logs_path'], 0, -1 );
|
| 1807 |
}
|
| 1808 |
}
|
| 1809 |
$this->options['use_ssl'] = isset( $_POST['use_ssl'] ) ? 1 : 0;
|
| 1810 |
$this->options['ssl_url'] = isset( $_POST['ssl_url'] ) ? rtrim( $_POST['ssl_url'], '/' ) : '';
|
| 1811 |
$this->options['ssl_url_admin'] = isset( $_POST['ssl_url_admin'] ) ? rtrim( $_POST['ssl_url_admin'], '/' ) : '';
|
| 1812 |
if ( WCUtils::is_blank( $this->options['ssl_url'] ) || WCUtils::is_blank( $this->options['ssl_url_admin'] ) ) {
|
| 1813 |
$this->options['use_ssl'] = 0;
|
| 1814 |
}
|
| 1815 |
$this->options['inquiry_id'] = isset( $_POST['inquiry_id'] ) ? esc_html( rtrim( $_POST['inquiry_id'] ) ) : '';
|
| 1816 |
$this->options['use_javascript'] = isset( $_POST['use_javascript'] ) ? (int) $_POST['use_javascript'] : 1;
|
| 1817 |
|
| 1818 |
$this->options['system']['no_cart_css'] = isset( $_POST['no_cart_css'] ) ? 1 : 0;
|
| 1819 |
$this->options['system']['dec_orderID_flag'] = isset( $_POST['dec_orderID_flag'] ) ? (int) $_POST['dec_orderID_flag'] : 0;
|
| 1820 |
$this->options['system']['dec_orderID_prefix'] = isset( $_POST['dec_orderID_prefix'] ) ? esc_html( rtrim( $_POST['dec_orderID_prefix'] ) ) : '';
|
| 1821 |
|
| 1822 |
if ( isset( $_POST['dec_orderID_digit'] ) ) {
|
| 1823 |
$dec_orderid_digit = (int) rtrim( $_POST['dec_orderID_digit'] );
|
| 1824 |
if ( 6 > $dec_orderid_digit ) {
|
| 1825 |
$this->options['system']['dec_orderID_digit'] = 6;
|
| 1826 |
} else {
|
| 1827 |
$this->options['system']['dec_orderID_digit'] = $dec_orderid_digit;
|
| 1828 |
}
|
| 1829 |
} else {
|
| 1830 |
$this->options['system']['dec_orderID_digit'] = 6;
|
| 1831 |
}
|
| 1832 |
|
| 1833 |
$this->options['system']['subimage_rule'] = isset( $_POST['subimage_rule'] ) ? (int) $_POST['subimage_rule'] : 0;
|
| 1834 |
$this->options['system']['pdf_delivery'] = isset( $_POST['pdf_delivery'] ) ? (int) $_POST['pdf_delivery'] : 0;
|
| 1835 |
$this->options['system']['member_pass_rule_min'] = isset( $_POST['member_pass_rule_min'] ) ? (int) $_POST['member_pass_rule_min'] : 6;
|
| 1836 |
$this->options['system']['member_pass_rule_max'] = isset( $_POST['member_pass_rule_max'] ) && ! empty( $_POST['member_pass_rule_max'] ) ? (int) $_POST['member_pass_rule_max'] : 30;
|
| 1837 |
$this->options['system']['member_pass_rule_upercase'] = isset( $_POST['member_pass_rule_upercase'] ) ? 1 : 0;
|
| 1838 |
$this->options['system']['member_pass_rule_lowercase'] = isset( $_POST['member_pass_rule_lowercase'] ) ? 1 : 0;
|
| 1839 |
$this->options['system']['member_pass_rule_digit'] = isset( $_POST['member_pass_rule_digit'] ) ? 1 : 0;
|
| 1840 |
$this->options['system']['member_pass_rule_symbols'] = isset( $_POST['member_pass_rule_symbols'] ) ? 1 : 0;
|
| 1841 |
$this->options['system']['member_pass_rule_number'] = isset( $_POST['member_pass_rule_number'] ) ? 1 : 0;
|
| 1842 |
$this->options['system']['member_pass_rule_symbol'] = isset( $_POST['member_pass_rule_symbol'] ) ? 1 : 0;
|
| 1843 |
$this->options['system']['csv_encode_type'] = isset( $_POST['csv_encode_type'] ) ? (int) $_POST['csv_encode_type'] : 0;
|
| 1844 |
$this->options['system']['csv_category_format'] = ( isset( $_POST['csv_category_format'] ) ) ? (int) $_POST['csv_category_format'] : 0;
|
| 1845 |
$this->options['system']['settlement_backup'] = ( isset( $_POST['settlement_backup'] ) ) ? (int) $_POST['settlement_backup'] : 0;
|
| 1846 |
$this->options['system']['settlement_notice'] = ( isset( $_POST['settlement_notice'] ) ) ? (int) $_POST['settlement_notice'] : 0;
|
| 1847 |
$this->options['system']['order_list_delete_link'] = ( isset( $_POST['order_list_delete_link'] ) ) ? (int) $_POST['order_list_delete_link'] : 0;
|
| 1848 |
$this->options['system']['member_list_delete_link'] = ( isset( $_POST['member_list_delete_link'] ) ) ? (int) $_POST['member_list_delete_link'] : 0;
|
| 1849 |
|
| 1850 |
if ( '' != $action_status ) {
|
| 1851 |
$this->action_status = 'error';
|
| 1852 |
$this->action_message = __( 'Data have deficiency.', 'usces' );
|
| 1853 |
} else {
|
| 1854 |
$this->action_status = 'success';
|
| 1855 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1856 |
}
|
| 1857 |
} elseif ( isset( $_POST['usces_locale_option_update'] ) ) {
|
| 1858 |
|
| 1859 |
check_admin_referer( 'admin_system', 'wc_nonce' );
|
| 1860 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1861 |
|
| 1862 |
$this->options['system']['front_lang'] = ( isset( $_POST['front_lang'] ) && 'others' != $_POST['front_lang'] ) ? $_POST['front_lang'] : usces_get_local_language();
|
| 1863 |
$this->options['system']['currency'] = ( isset( $_POST['currency'] ) && 'others' != $_POST['currency'] ) ? $_POST['currency'] : usces_get_base_country();
|
| 1864 |
$this->options['system']['addressform'] = ( isset( $_POST['addressform'] ) ) ? $_POST['addressform'] : usces_get_local_addressform();
|
| 1865 |
$this->options['system']['target_market'] = ( isset( $_POST['target_market'] ) ) ? $_POST['target_market'] : usces_get_local_target_market();
|
| 1866 |
|
| 1867 |
unset ( $this->options['province'] );
|
| 1868 |
foreach ( (array) $this->options['system']['target_market'] as $target_market ) {
|
| 1869 |
$province = array();
|
| 1870 |
if ( ! empty( $_POST[ 'province_' . $target_market ] ) ) {
|
| 1871 |
$_province = usces_change_line_break( $_POST[ 'province_' . $target_market ] );
|
| 1872 |
$temp_pref = explode( "\n", $_province );
|
| 1873 |
$province[] = '-- Select --';
|
| 1874 |
foreach ( $temp_pref as $pref ) {
|
| 1875 |
if ( ! WCUtils::is_blank( $pref ) ) {
|
| 1876 |
$validated = wel_validate_prefecture_name( wp_unslash( $pref ) );
|
| 1877 |
if ( '' !== $validated ) {
|
| 1878 |
$province[] = esc_html( $validated );
|
| 1879 |
}
|
| 1880 |
}
|
| 1881 |
}
|
| 1882 |
if ( 1 == count( $province ) ) {
|
| 1883 |
$action_status = 'error';
|
| 1884 |
}
|
| 1885 |
} else {
|
| 1886 |
if ( isset( $usces_states[ $target_market ] ) && is_array( $usces_states[ $target_market ] ) ) {
|
| 1887 |
$province = $usces_states[ $target_market ];
|
| 1888 |
} else {
|
| 1889 |
$action_status = 'error';
|
| 1890 |
}
|
| 1891 |
}
|
| 1892 |
$this->options['province'][ $target_market ] = $province;
|
| 1893 |
}
|
| 1894 |
|
| 1895 |
if ( '' != $action_status ) {
|
| 1896 |
$this->action_status = 'error';
|
| 1897 |
$this->action_message = __( 'Data have deficiency.', 'usces' );
|
| 1898 |
} else {
|
| 1899 |
$this->action_status = 'success';
|
| 1900 |
$this->action_message = __( 'options are updated', 'usces' );
|
| 1901 |
}
|
| 1902 |
} else {
|
| 1903 |
|
| 1904 |
if ( ! isset( $this->options['province'] ) || empty( $this->options['province'] ) ) {
|
| 1905 |
$this->options['province'][ $this->options['system']['base_country'] ] = $usces_states[ $this->options['system']['base_country'] ];
|
| 1906 |
}
|
| 1907 |
$this->action_status = 'none';
|
| 1908 |
$this->action_message = '';
|
| 1909 |
}
|
| 1910 |
|
| 1911 |
if ( 'error' != $action_status ) {
|
| 1912 |
update_option( 'usces', $this->options );
|
| 1913 |
}
|
| 1914 |
|
| 1915 |
require_once USCES_PLUGIN_DIR . '/includes/admin_system.php';
|
| 1916 |
}
|
| 1917 |
|
| 1918 |
/**
|
| 1919 |
* Settlement Setting Page.
|
| 1920 |
*/
|
| 1921 |
public function admin_settlement_page() {
|
| 1922 |
|
| 1923 |
$this->action_status = 'none';
|
| 1924 |
$this->action_message = '';
|
| 1925 |
|
| 1926 |
$options = get_option( 'usces' );
|
| 1927 |
$mes = '';
|
| 1928 |
|
| 1929 |
if ( isset( $_POST['usces_option_update'] ) ) {
|
| 1930 |
|
| 1931 |
check_admin_referer( 'admin_settlement', 'wc_nonce' );
|
| 1932 |
|
| 1933 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 1934 |
|
| 1935 |
switch ( $_POST['acting'] ) {
|
| 1936 |
case 'settlement_selected':
|
| 1937 |
if ( isset( $_POST['settlement_selected'] ) ) {
|
| 1938 |
$settlement_selected = explode( ',', sanitize_text_field( wp_unslash( $_POST['settlement_selected'] ) ) );
|
| 1939 |
$payments = usces_get_system_option( 'usces_payment_method', 'settlement' );
|
| 1940 |
$acting_payments = array();
|
| 1941 |
foreach ( (array) $payments as $key => $payment ) {
|
| 1942 |
if ( 'activate' == $payment['use'] && false !== strpos( $key, 'acting_' ) ) {
|
| 1943 |
$acting = explode( '_', $key );
|
| 1944 |
if ( ! empty( $acting[1] ) && 'paypal' == $acting[1] ) {
|
| 1945 |
$acting_payments[] = $acting[1] . '_cp';
|
| 1946 |
} else {
|
| 1947 |
$acting_payments[] = apply_filters( 'usces_filter_acting_payment_slug', $acting[1], $acting );
|
| 1948 |
}
|
| 1949 |
}
|
| 1950 |
}
|
| 1951 |
$acting_payments = array_unique( $acting_payments );
|
| 1952 |
$available_settlement = get_option( 'usces_available_settlement', array() );
|
| 1953 |
$available = array_keys( $available_settlement );
|
| 1954 |
foreach ( (array) $settlement_selected as $settlement ) {
|
| 1955 |
if ( ! empty( $settlement ) && ! in_array( $settlement, $available ) ) {
|
| 1956 |
$mes .= __( '* Failed to update payment module.', 'usces' ) . '<br />';
|
| 1957 |
}
|
| 1958 |
}
|
| 1959 |
foreach ( (array) $acting_payments as $payment ) {
|
| 1960 |
if ( ! in_array( $payment, $settlement_selected ) && isset( $available_settlement[ $payment ] ) ) {
|
| 1961 |
$settlement_name = $available_settlement[ $payment ];
|
| 1962 |
$mes .= sprintf( __( '* %s can not be unselected. Please "delete" or "stop" the payment method.', 'usces' ), $settlement_name ) . '<br />';
|
| 1963 |
}
|
| 1964 |
}
|
| 1965 |
if ( WCUtils::is_blank( $mes ) ) {
|
| 1966 |
$unavailable_activate = 0;
|
| 1967 |
$unavailable_payments = apply_filters( 'usces_filter_unavailable_payments', get_option( 'usces_unavailable_settlement', array() ) );
|
| 1968 |
foreach ( (array) $unavailable_payments as $payment ) {
|
| 1969 |
if ( in_array( $payment, $settlement_selected ) ) {
|
| 1970 |
$unavailable_activate++;
|
| 1971 |
}
|
| 1972 |
}
|
| 1973 |
if ( 1 < $unavailable_activate ) {
|
| 1974 |
$mes .= __( '* Settlement that can not be used together is activated.', 'usces' ) . '<br />';
|
| 1975 |
}
|
| 1976 |
}
|
| 1977 |
|
| 1978 |
if ( WCUtils::is_blank( $mes ) ) {
|
| 1979 |
update_option( 'usces_settlement_selected', $settlement_selected );
|
| 1980 |
$this->settlement->setup();
|
| 1981 |
$this->action_status = 'success';
|
| 1982 |
$this->action_message = __( 'Updated.', 'usces' );
|
| 1983 |
} else {
|
| 1984 |
$this->action_status = 'error';
|
| 1985 |
$this->action_message = __( 'Update failed.', 'usces' );
|
| 1986 |
}
|
| 1987 |
}
|
| 1988 |
break;
|
| 1989 |
}
|
| 1990 |
do_action( 'usces_action_admin_settlement_update', $mes );
|
| 1991 |
}
|
| 1992 |
|
| 1993 |
$this->options = get_option( 'usces' );
|
| 1994 |
|
| 1995 |
require_once USCES_PLUGIN_DIR . '/includes/admin_settlement.php';
|
| 1996 |
}
|
| 1997 |
|
| 1998 |
public function selected( $selected, $current ) {
|
| 1999 |
if ( $selected == $current ) {
|
| 2000 |
echo ' selected="selected"';
|
| 2001 |
}
|
| 2002 |
}
|
| 2003 |
|
| 2004 |
public function usces_session_start() {
|
| 2005 |
$options = get_option( 'usces' );
|
| 2006 |
if ( ! isset( $options['usces_key'] ) || empty( $options['usces_key'] ) ) {
|
| 2007 |
$options['usces_key'] = uniqid( 'uk' );
|
| 2008 |
update_option( 'usces', $options );
|
| 2009 |
}
|
| 2010 |
|
| 2011 |
if ( defined( 'USCES_KEY' ) ) {
|
| 2012 |
if ( is_admin() || preg_match( '/\/wp-login\.php/', $_SERVER['REQUEST_URI'] ) ) {
|
| 2013 |
@session_name( 'adm' . USCES_KEY );
|
| 2014 |
} else {
|
| 2015 |
@session_name( USCES_KEY );
|
| 2016 |
}
|
| 2017 |
} else {
|
| 2018 |
if ( is_admin() || preg_match( '/\/wp-login\.php/', $_SERVER['REQUEST_URI'] ) ) {
|
| 2019 |
@session_name( 'adm' . $options['usces_key'] );
|
| 2020 |
} else {
|
| 2021 |
@session_name( $options['usces_key'] );
|
| 2022 |
}
|
| 2023 |
}
|
| 2024 |
|
| 2025 |
if ( isset( $_GET['uscesid'] ) && ! WCUtils::is_blank( $_GET['uscesid'] ) ) {
|
| 2026 |
$sessid = $_GET['uscesid'];
|
| 2027 |
$sessid = $this->uscesdc( $sessid );
|
| 2028 |
session_id( $sessid );
|
| 2029 |
}
|
| 2030 |
|
| 2031 |
do_action( 'usces_action_session_start' );
|
| 2032 |
|
| 2033 |
$httponly = true;
|
| 2034 |
$sitescheme = substr( get_option( 'siteurl' ), 0, 5 );
|
| 2035 |
$homescheme = substr( get_option( 'home' ), 0, 5 );
|
| 2036 |
if ( 'https' == $sitescheme && 'https' == $homescheme ) {
|
| 2037 |
$sslonly = true;
|
| 2038 |
$samesite = 'None';
|
| 2039 |
} else {
|
| 2040 |
$sslonly = false;
|
| 2041 |
$samesite = '';
|
| 2042 |
}
|
| 2043 |
|
| 2044 |
if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) {
|
| 2045 |
$cookie_options = array(
|
| 2046 |
'lifetime' => 0,
|
| 2047 |
'path' => USCES_COOKIEPATH,
|
| 2048 |
'domain' => '',
|
| 2049 |
'secure' => $sslonly,
|
| 2050 |
'httponly' => $httponly,
|
| 2051 |
'samesite' => $samesite,
|
| 2052 |
);
|
| 2053 |
session_set_cookie_params( $cookie_options );
|
| 2054 |
} else {
|
| 2055 |
session_set_cookie_params( 0, USCES_COOKIEPATH, '', $sslonly, $httponly );
|
| 2056 |
}
|
| 2057 |
|
| 2058 |
@session_start();
|
| 2059 |
|
| 2060 |
if ( ! isset( $_SESSION['usces_member'] ) || 'activate' != $options['membersystem_state'] ) {
|
| 2061 |
$_SESSION['usces_member'] = array();
|
| 2062 |
}
|
| 2063 |
|
| 2064 |
if ( ! isset( $_SESSION['usces_checked_business_days'] ) ) {
|
| 2065 |
$this->update_business_days();
|
| 2066 |
}
|
| 2067 |
}
|
| 2068 |
|
| 2069 |
public function usces_cookie() {
|
| 2070 |
if ( is_admin() ) {
|
| 2071 |
return;
|
| 2072 |
}
|
| 2073 |
|
| 2074 |
$actionflag = false;
|
| 2075 |
$sess = null;
|
| 2076 |
$addr = null;
|
| 2077 |
$rckid = null;
|
| 2078 |
$none = null;
|
| 2079 |
$cookie = $this->get_cookie();
|
| 2080 |
|
| 2081 |
if ( isset( $_GET['uscesid'] ) && ! WCUtils::is_blank( $_GET['uscesid'] ) ) {
|
| 2082 |
$sessid = base64_decode( urldecode( $_GET['uscesid'] ) );
|
| 2083 |
list( $sess, $addr, $rckid, $none ) = explode( '_', $sessid, 4 );
|
| 2084 |
}
|
| 2085 |
if ( 'acting' == $addr ) {
|
| 2086 |
return;
|
| 2087 |
}
|
| 2088 |
if ( apply_filters( 'usces_filter_cookie', false ) ) {
|
| 2089 |
return;
|
| 2090 |
}
|
| 2091 |
|
| 2092 |
// We need to consider.
|
| 2093 |
return;
|
| 2094 |
|
| 2095 |
if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) {
|
| 2096 |
|
| 2097 |
$refer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
|
| 2098 |
$sslid = isset( $cookie['sslid'] ) ? $cookie['sslid'] : null;
|
| 2099 |
$option = get_option( 'usces' );
|
| 2100 |
$parsed = parse_url( get_option( 'home' ) );
|
| 2101 |
$home = $parsed['host'] . ( isset( $parsed['path'] ) ? $parsed['path'] : '' );
|
| 2102 |
$parsed = parse_url( $option['ssl_url'] );
|
| 2103 |
$sslhome = $parsed['host'] . ( isset( $parsed['path'] ) ? $parsed['path'] : '' );
|
| 2104 |
|
| 2105 |
if ( empty( $refer ) || ( false === strpos( $refer, $home ) && false === strpos( $refer, $sslhome ) ) ) {
|
| 2106 |
if ( ! empty( $sslid ) && ! empty( $rckid ) && $sslid === $rckid ) {
|
| 2107 |
$actionflag = true;
|
| 2108 |
} else {
|
| 2109 |
$actionflag = false;
|
| 2110 |
}
|
| 2111 |
} else {
|
| 2112 |
if ( ! empty( $sslid ) && $sslid !== $rckid ) {
|
| 2113 |
$actionflag = false;
|
| 2114 |
} else {
|
| 2115 |
$actionflag = true;
|
| 2116 |
}
|
| 2117 |
}
|
| 2118 |
|
| 2119 |
if ( $actionflag ) {
|
| 2120 |
$values = array(
|
| 2121 |
'id' => $rckid,
|
| 2122 |
'sslid' => $rckid,
|
| 2123 |
'name' => '',
|
| 2124 |
'rme' => '',
|
| 2125 |
);
|
| 2126 |
if ( 'acting' !== $rckid ) {
|
| 2127 |
$this->set_cookie( $values );
|
| 2128 |
}
|
| 2129 |
} else {
|
| 2130 |
if ( 'acting' !== $rckid ) {
|
| 2131 |
unset( $_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] );
|
| 2132 |
wp_redirect( 'http://' . $home );
|
| 2133 |
}
|
| 2134 |
}
|
| 2135 |
} else {
|
| 2136 |
if ( ! isset( $cookie['id'] ) || WCUtils::is_blank( $cookie['id'] ) ) {
|
| 2137 |
$values = array(
|
| 2138 |
'id' => md5( uniqid( rand(), true ) ),
|
| 2139 |
'name' => '',
|
| 2140 |
'rme' => '',
|
| 2141 |
);
|
| 2142 |
$this->set_cookie( $values );
|
| 2143 |
$_SESSION['usces_cookieid'] = $values['id'];
|
| 2144 |
} else {
|
| 2145 |
if ( ! isset( $_SESSION['usces_cookieid'] ) || $_SESSION['usces_cookieid'] != $cookie['id'] ) {
|
| 2146 |
$_SESSION['usces_cookieid'] = $cookie['id'];
|
| 2147 |
}
|
| 2148 |
}
|
| 2149 |
|
| 2150 |
$actionflag = true;
|
| 2151 |
}
|
| 2152 |
}
|
| 2153 |
|
| 2154 |
public function set_cookie( $values, $key = 'usces_cookie' ) {
|
| 2155 |
if ( ! isset( $_GET['uscesid'] ) || WCUtils::is_blank( $_GET['uscesid'] ) ) {
|
| 2156 |
session_regenerate_id( true );
|
| 2157 |
}
|
| 2158 |
$value = usces_serialize( $values );
|
| 2159 |
$timeout = time()+7*86400;
|
| 2160 |
$timeout = apply_filters( 'usces_filter_set_cookie_timeout', $timeout, $values, $key );
|
| 2161 |
$domain = $_SERVER['SERVER_NAME'];
|
| 2162 |
|
| 2163 |
$httponly = true;
|
| 2164 |
$sitescheme = substr( get_option( 'siteurl' ), 0, 5 );
|
| 2165 |
$homescheme = substr( get_option( 'home' ), 0, 5 );
|
| 2166 |
if ( 'https' == $sitescheme && 'https' == $homescheme ) {
|
| 2167 |
$sslonly = true;
|
| 2168 |
$samesite = 'None';
|
| 2169 |
} else {
|
| 2170 |
$sslonly = false;
|
| 2171 |
$samesite = '';
|
| 2172 |
}
|
| 2173 |
|
| 2174 |
if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) {
|
| 2175 |
$cookie_options = array(
|
| 2176 |
'expires' => $timeout,
|
| 2177 |
'path' => USCES_COOKIEPATH,
|
| 2178 |
'domain' => $domain,
|
| 2179 |
'secure' => $sslonly,
|
| 2180 |
'httponly' => $httponly,
|
| 2181 |
'samesite' => $samesite,
|
| 2182 |
);
|
| 2183 |
$res = setcookie( $key, $value, $cookie_options );
|
| 2184 |
} else {
|
| 2185 |
$res = setcookie( $key, $value, $timeout, USCES_COOKIEPATH, $domain, true, true );
|
| 2186 |
}
|
| 2187 |
}
|
| 2188 |
|
| 2189 |
public function get_cookie( $key = 'usces_cookie' ) {
|
| 2190 |
$values = isset( $_COOKIE[ $key ] ) ? usces_unserialize( stripslashes( $_COOKIE[ $key ] ) ) : null;
|
| 2191 |
return $values;
|
| 2192 |
}
|
| 2193 |
|
| 2194 |
public function get_access( $key, $type, $date ) {
|
| 2195 |
global $wpdb;
|
| 2196 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 2197 |
|
| 2198 |
$query = $wpdb->prepare( "SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date );
|
| 2199 |
$value = $wpdb->get_var( $query );
|
| 2200 |
if ( ! $value ) {
|
| 2201 |
$res = null;
|
| 2202 |
} else {
|
| 2203 |
$res = @unserialize( $value );
|
| 2204 |
}
|
| 2205 |
|
| 2206 |
return $res;
|
| 2207 |
}
|
| 2208 |
|
| 2209 |
public function get_access_piriod( $key, $type, $startday, $endday ) {
|
| 2210 |
global $wpdb;
|
| 2211 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 2212 |
$query = $wpdb->prepare( "SELECT acc_type, acc_value, acc_date FROM $table_name WHERE acc_key = %s AND acc_type = %s AND (acc_date >= %s AND acc_date <= %s)", $key, $type, $startday, $endday );
|
| 2213 |
$res = $wpdb->get_results( $query, ARRAY_A );
|
| 2214 |
|
| 2215 |
return $res;
|
| 2216 |
}
|
| 2217 |
|
| 2218 |
public function update_access( $array ) {
|
| 2219 |
global $wpdb;
|
| 2220 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 2221 |
|
| 2222 |
$query = $wpdb->prepare( "SELECT ID FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $array['acc_key'], $array['acc_type'], $array['acc_date'] );
|
| 2223 |
$res = $wpdb->get_var( $query );
|
| 2224 |
if ( empty( $res ) ) {
|
| 2225 |
$query = $wpdb->prepare( "INSERT INTO $table_name (acc_key, acc_type, acc_value, acc_date) VALUES(%s, %s, %s, %s)", $array['acc_key'], $array['acc_type'], serialize( $array['acc_value'] ), $array['acc_date'] );
|
| 2226 |
$wpdb->query( $query );
|
| 2227 |
} else {
|
| 2228 |
$query = $wpdb->prepare( "UPDATE $table_name SET acc_value = %s WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", serialize( $array['acc_value'] ), $array['acc_key'], $array['acc_type'], $array['acc_date'] );
|
| 2229 |
$wpdb->query( $query );
|
| 2230 |
}
|
| 2231 |
}
|
| 2232 |
|
| 2233 |
public function get_uscesid( $flag = true ) {
|
| 2234 |
$sessname = session_name();
|
| 2235 |
$sessid = session_id();
|
| 2236 |
$sessid = $this->uscescv( $sessid, $flag );
|
| 2237 |
return $sessid;
|
| 2238 |
}
|
| 2239 |
|
| 2240 |
public function shop_head() {
|
| 2241 |
global $post;
|
| 2242 |
$this->item = $post;
|
| 2243 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 2244 |
echo "<meta name='robots' content='noindex,nofollow' />\n";
|
| 2245 |
}
|
| 2246 |
}
|
| 2247 |
|
| 2248 |
/**
|
| 2249 |
* Caught by wp_footer action hook
|
| 2250 |
*/
|
| 2251 |
public function shop_foot() {
|
| 2252 |
global $current_user;
|
| 2253 |
|
| 2254 |
$item = $this->item;
|
| 2255 |
if ( empty( $item ) ) {
|
| 2256 |
$item = new stdClass;
|
| 2257 |
$item->ID = 0;
|
| 2258 |
$item->post_mime_type = '';
|
| 2259 |
}
|
| 2260 |
|
| 2261 |
wp_get_current_user();
|
| 2262 |
|
| 2263 |
// usces_cart.js is not used.
|
| 2264 |
if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 2265 |
$javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js';
|
| 2266 |
} else {
|
| 2267 |
$javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js';
|
| 2268 |
}
|
| 2269 |
|
| 2270 |
$this->previous_url = isset( $_SESSION['usces_previous_url'] ) ? $_SESSION['usces_previous_url'] : get_home_url();
|
| 2271 |
|
| 2272 |
// If the product object does't exists.
|
| 2273 |
if ( $this->use_js && empty( $this->item ) ) {
|
| 2274 |
?>
|
| 2275 |
<script type='text/javascript'>
|
| 2276 |
uscesL10n = {
|
| 2277 |
<?php echo apply_filters( 'usces_filter_uscesL10n', null, $item->ID ); ?>
|
| 2278 |
|
| 2279 |
'ajaxurl': "<?php echo esc_url( $this->ssl_admin_ajax_url() ); ?>"
|
| 2280 |
}
|
| 2281 |
</script>
|
| 2282 |
<?php
|
| 2283 |
|
| 2284 |
// If the product object exists.
|
| 2285 |
} elseif ( $this->use_js && ! empty( $this->item ) ) {
|
| 2286 |
|
| 2287 |
$ioptkeys = $this->get_itemOptionKey( $item->ID );
|
| 2288 |
$mes_opts_str = '';
|
| 2289 |
$key_opts_str = '';
|
| 2290 |
$opt_means = '';
|
| 2291 |
$opt_esse = '';
|
| 2292 |
if ( $ioptkeys ) {
|
| 2293 |
foreach ( $ioptkeys as $key => $value ) {
|
| 2294 |
$optValues = $this->get_itemOptions( $value, $item->ID );
|
| 2295 |
if ( false === $optValues ) {
|
| 2296 |
continue;
|
| 2297 |
}
|
| 2298 |
if ( $optValues['means'] < 2 || 3 == $optValues['means'] || 4 == $optValues['means'] ) {
|
| 2299 |
$mes_opts_str .= "'" . sprintf( __( 'Chose the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',";
|
| 2300 |
} else {
|
| 2301 |
$mes_opts_str .= "'" . sprintf( __( 'Input the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',";
|
| 2302 |
}
|
| 2303 |
$key_opts_str .= "'" . urlencode( esc_js( $value ) ) . "',";
|
| 2304 |
$opt_means .= "'" . esc_js( $optValues['means'] ) . "',";
|
| 2305 |
$opt_esse .= "'" . esc_js( $optValues['essential'] ) . "',";
|
| 2306 |
}
|
| 2307 |
$mes_opts_str = rtrim( $mes_opts_str, ',' );
|
| 2308 |
$key_opts_str = rtrim( $key_opts_str, ',' );
|
| 2309 |
$opt_means = rtrim( $opt_means, ',' );
|
| 2310 |
$opt_esse = rtrim( $opt_esse, ',' );
|
| 2311 |
}
|
| 2312 |
|
| 2313 |
$product = wel_get_product( $item->ID );
|
| 2314 |
$itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : '';
|
| 2315 |
$wcpage = usces_page_name( 'return' );
|
| 2316 |
$nonce_action = 'wc_confirm';
|
| 2317 |
$itemOrderAcceptable = $this->getItemOrderAcceptable( $item->ID );
|
| 2318 |
?>
|
| 2319 |
<script type='text/javascript'>
|
| 2320 |
uscesL10n = {
|
| 2321 |
<?php echo apply_filters( 'usces_filter_uscesL10n', null, $item->ID ); ?>
|
| 2322 |
|
| 2323 |
'ajaxurl': "<?php echo esc_url( $this->ssl_admin_ajax_url() ); ?>",
|
| 2324 |
'loaderurl': "<?php echo USCES_PLUGIN_URL . 'images/loading.gif'; ?>",
|
| 2325 |
'post_id': "<?php echo esc_js( $item->ID ); ?>",
|
| 2326 |
'cart_number': "<?php echo get_option( 'usces_cart_number' ); ?>",
|
| 2327 |
'is_cart_row': <?php echo ( ( 0 < $this->cart->num_row() ) ? 'true' : 'false' ); ?>,
|
| 2328 |
'opt_esse': new Array( <?php wel_esc_script_e( $opt_esse ); ?> ),
|
| 2329 |
'opt_means': new Array( <?php wel_esc_script_e( $opt_means ); ?> ),
|
| 2330 |
'mes_opts': new Array( <?php wel_esc_script_e( $mes_opts_str ); ?> ),
|
| 2331 |
'key_opts': new Array( <?php wel_esc_script_e( $key_opts_str ); ?> ),
|
| 2332 |
'previous_url': "<?php echo esc_url( $this->previous_url ); ?>",
|
| 2333 |
'itemRestriction': "<?php echo esc_js( $itemRestriction ); ?>",
|
| 2334 |
'itemOrderAcceptable': "<?php echo esc_js( $itemOrderAcceptable ); ?>",
|
| 2335 |
'uscespage': "<?php echo esc_js( $wcpage ); ?>",
|
| 2336 |
'uscesid': "<?php echo esc_js( $this->get_uscesid( false ) ); ?>",
|
| 2337 |
'wc_nonce': "<?php echo wp_create_nonce( $nonce_action ); ?>"
|
| 2338 |
}
|
| 2339 |
</script>
|
| 2340 |
<script type='text/javascript' src='<?php echo esc_url( $javascript_url ); ?>'></script>
|
| 2341 |
<?php
|
| 2342 |
}
|
| 2343 |
|
| 2344 |
ob_start();
|
| 2345 |
|
| 2346 |
// If it's Product Details page.
|
| 2347 |
if ( $this->use_js && ( is_singular() && 'item' == $item->post_mime_type ) ) {
|
| 2348 |
?>
|
| 2349 |
<script type='text/javascript'>
|
| 2350 |
(function($) {
|
| 2351 |
uscesCart = {
|
| 2352 |
intoCart : function (post_id, sku) {
|
| 2353 |
var zaikonum = $("[id='zaikonum["+post_id+"]["+sku+"]']").val();
|
| 2354 |
var zaiko = $("[id='zaiko["+post_id+"]["+sku+"]']").val();
|
| 2355 |
if( <?php echo apply_filters( 'usces_intoCart_zaiko_check_js', "( uscesL10n.itemOrderAcceptable != '1' && zaiko != '0' && zaiko != '1' ) || ( uscesL10n.itemOrderAcceptable != '1' && parseInt(zaikonum) == 0 )" ); ?> ){
|
| 2356 |
alert('<?php _e( 'temporaly out of stock now', 'usces' ); ?>');
|
| 2357 |
return false;
|
| 2358 |
}
|
| 2359 |
|
| 2360 |
var mes = '';
|
| 2361 |
if( $("[id='quant["+post_id+"]["+sku+"]']").length ){
|
| 2362 |
var quant = $("[id='quant["+post_id+"]["+sku+"]']").val();
|
| 2363 |
if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
|
| 2364 |
mes += "<?php _e( 'enter the correct amount', 'usces' ); ?>\n";
|
| 2365 |
}
|
| 2366 |
var checknum = '';
|
| 2367 |
var checkmode = '';
|
| 2368 |
if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
|
| 2369 |
checknum = uscesL10n.itemRestriction;
|
| 2370 |
checkmode ='rest';
|
| 2371 |
} else if( uscesL10n.itemOrderAcceptable != '1' && parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) {
|
| 2372 |
checknum = zaikonum;
|
| 2373 |
checkmode ='zaiko';
|
| 2374 |
} else if( uscesL10n.itemOrderAcceptable != '1' && (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) {
|
| 2375 |
checknum = zaikonum;
|
| 2376 |
checkmode ='zaiko';
|
| 2377 |
} else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) ) ) {
|
| 2378 |
checknum = uscesL10n.itemRestriction;
|
| 2379 |
checkmode ='rest';
|
| 2380 |
}
|
| 2381 |
|
| 2382 |
if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
|
| 2383 |
if(checkmode == 'rest'){
|
| 2384 |
mes += <?php _e( "'This article is limited by '+checknum+' at a time.'", 'usces' ); ?>+"\n";
|
| 2385 |
}else{
|
| 2386 |
mes += <?php _e( "'Stock is remainder '+checknum+'.'", 'usces' ); ?>+"\n";
|
| 2387 |
}
|
| 2388 |
}
|
| 2389 |
}
|
| 2390 |
for(i=0; i<uscesL10n.key_opts.length; i++){
|
| 2391 |
if( uscesL10n.opt_esse[i] == '1' ){
|
| 2392 |
var skuob = $("[id='itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]']");
|
| 2393 |
var itemOption = "itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]";
|
| 2394 |
var opt_obj_radio = $(":radio[name*='"+itemOption+"']");
|
| 2395 |
var opt_obj_checkbox = $(":checkbox[name*='"+itemOption+"']:checked");
|
| 2396 |
|
| 2397 |
if( uscesL10n.opt_means[i] == '3' ){
|
| 2398 |
|
| 2399 |
if( !opt_obj_radio.is(':checked') ){
|
| 2400 |
mes += uscesL10n.mes_opts[i]+"\n";
|
| 2401 |
}
|
| 2402 |
|
| 2403 |
}else if( uscesL10n.opt_means[i] == '4' ){
|
| 2404 |
|
| 2405 |
if( !opt_obj_checkbox.length ){
|
| 2406 |
mes += uscesL10n.mes_opts[i]+"\n";
|
| 2407 |
}
|
| 2408 |
|
| 2409 |
}else{
|
| 2410 |
|
| 2411 |
if( skuob.length ){
|
| 2412 |
if( uscesL10n.opt_means[i] == 0 && skuob.val() == '#NONE#' ){
|
| 2413 |
mes += uscesL10n.mes_opts[i]+"\n";
|
| 2414 |
}else if( uscesL10n.opt_means[i] == 1 && ( skuob.val() == '' || skuob.val() == '#NONE#' ) ){
|
| 2415 |
mes += uscesL10n.mes_opts[i]+"\n";
|
| 2416 |
}else if( uscesL10n.opt_means[i] >= 2 && skuob.val() == '' ){
|
| 2417 |
mes += uscesL10n.mes_opts[i]+"\n";
|
| 2418 |
}
|
| 2419 |
}
|
| 2420 |
}
|
| 2421 |
}
|
| 2422 |
}
|
| 2423 |
|
| 2424 |
<?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); // Unavailable. ?>
|
| 2425 |
<?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?>
|
| 2426 |
|
| 2427 |
if( mes != '' ){
|
| 2428 |
alert( mes );
|
| 2429 |
return false;
|
| 2430 |
}else{
|
| 2431 |
<?php echo apply_filters( 'usces_filter_js_intoCart', "return true;\n", $item->ID, null ); ?>
|
| 2432 |
}
|
| 2433 |
},
|
| 2434 |
|
| 2435 |
isNum : function (num) {
|
| 2436 |
if (num.match(/[^0-9]/g)) {
|
| 2437 |
return false;
|
| 2438 |
}
|
| 2439 |
return true;
|
| 2440 |
}
|
| 2441 |
};
|
| 2442 |
})(jQuery);
|
| 2443 |
</script>
|
| 2444 |
<?php
|
| 2445 |
// If it's Product Details page.
|
| 2446 |
} elseif ( $this->use_js && ( is_page( USCES_CART_NUMBER ) || $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) ) {
|
| 2447 |
?>
|
| 2448 |
<script type='text/javascript'>
|
| 2449 |
(function($) {
|
| 2450 |
uscesCart = {
|
| 2451 |
upCart : function () {
|
| 2452 |
|
| 2453 |
var zaikoob = $("input[name*='zaikonum']");
|
| 2454 |
var quantob = $("input[name*='quant']");
|
| 2455 |
var postidob = $("input[name*='itempostid']");
|
| 2456 |
var skuob = $("input[name*='itemsku']");
|
| 2457 |
|
| 2458 |
var zaikonum = '';
|
| 2459 |
var zaiko = '';
|
| 2460 |
var quant = '';
|
| 2461 |
var mes = '';
|
| 2462 |
var checknum = '';
|
| 2463 |
var post_id = '';
|
| 2464 |
var sku = '';
|
| 2465 |
var itemRestriction = '';
|
| 2466 |
var itemOrderAcceptable = '';
|
| 2467 |
|
| 2468 |
var ct = zaikoob.length;
|
| 2469 |
for(var i=0; i< ct; i++){
|
| 2470 |
post_id = postidob[i].value;
|
| 2471 |
sku = skuob[i].value;
|
| 2472 |
itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
|
| 2473 |
itemOrderAcceptable = $("input[name='itemOrderAcceptable\[" + i + "\]']").val();
|
| 2474 |
zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
|
| 2475 |
|
| 2476 |
quant = $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
|
| 2477 |
if( $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").length ){
|
| 2478 |
if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
|
| 2479 |
mes += <?php _e( "'enter the correct amount for the No.' + (i+1) + ' item'", 'usces' ); ?>+"\n";
|
| 2480 |
}
|
| 2481 |
var checknum = '';
|
| 2482 |
var checkmode = '';
|
| 2483 |
if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
|
| 2484 |
checknum = itemRestriction;
|
| 2485 |
checkmode ='rest';
|
| 2486 |
} else if( itemOrderAcceptable != '1' && parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
|
| 2487 |
checknum = zaikonum;
|
| 2488 |
checkmode ='zaiko';
|
| 2489 |
} else if( itemOrderAcceptable != '1' && (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
|
| 2490 |
checknum = zaikonum;
|
| 2491 |
checkmode ='zaiko';
|
| 2492 |
} else if( itemRestriction != '' && itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(itemRestriction) > parseInt(zaikonum) ) ) {
|
| 2493 |
checknum = itemRestriction;
|
| 2494 |
checkmode ='rest';
|
| 2495 |
}
|
| 2496 |
if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
|
| 2497 |
if(checkmode == 'rest'){
|
| 2498 |
mes += <?php _e( "'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces' ); ?>+"\n";
|
| 2499 |
}else{
|
| 2500 |
mes += <?php _e( "'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces' ); ?>+"\n";
|
| 2501 |
}
|
| 2502 |
}
|
| 2503 |
}
|
| 2504 |
}
|
| 2505 |
|
| 2506 |
<?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); // Unavailable. ?>
|
| 2507 |
<?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?>
|
| 2508 |
|
| 2509 |
if( mes != '' ){
|
| 2510 |
alert( mes );
|
| 2511 |
return false;
|
| 2512 |
}else{
|
| 2513 |
<?php echo apply_filters( 'usces_filter_js_upCart', "return true;\n", $item->ID, null ); ?>
|
| 2514 |
}
|
| 2515 |
},
|
| 2516 |
|
| 2517 |
cartNext : function () {
|
| 2518 |
|
| 2519 |
var zaikoob = $("input[name*='zaikonum']");
|
| 2520 |
var quantob = $("input[name*='quant']");
|
| 2521 |
var postidob = $("input[name*='itempostid']");
|
| 2522 |
var skuob = $("input[name*='itemsku']");
|
| 2523 |
|
| 2524 |
var zaikonum = '';
|
| 2525 |
var zaiko = '';
|
| 2526 |
var quant = '';
|
| 2527 |
var mes = '';
|
| 2528 |
var checknum = '';
|
| 2529 |
var post_id = '';
|
| 2530 |
var sku = '';
|
| 2531 |
var itemRestriction = '';
|
| 2532 |
var itemOrderAcceptable = '';
|
| 2533 |
|
| 2534 |
var ct = zaikoob.length;
|
| 2535 |
for(var i=0; i< ct; i++){
|
| 2536 |
post_id = postidob[i].value;
|
| 2537 |
sku = skuob[i].value;
|
| 2538 |
itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val();
|
| 2539 |
itemOrderAcceptable = $("input[name='itemOrderAcceptable\[" + i + "\]']").val();
|
| 2540 |
zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
|
| 2541 |
|
| 2542 |
quant = $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val();
|
| 2543 |
if( $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").length ){
|
| 2544 |
if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){
|
| 2545 |
mes += <?php _e( "'enter the correct amount for the No.' + (i+1) + ' item'", 'usces' ); ?>+"\n";
|
| 2546 |
}
|
| 2547 |
var checknum = '';
|
| 2548 |
var checkmode = '';
|
| 2549 |
if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
|
| 2550 |
checknum = itemRestriction;
|
| 2551 |
checkmode ='rest';
|
| 2552 |
} else if( itemOrderAcceptable != '1' && parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) {
|
| 2553 |
checknum = zaikonum;
|
| 2554 |
checkmode ='zaiko';
|
| 2555 |
} else if( itemOrderAcceptable != '1' && (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) {
|
| 2556 |
checknum = zaikonum;
|
| 2557 |
checkmode ='zaiko';
|
| 2558 |
} else if( itemRestriction != '' && itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(itemRestriction) > parseInt(zaikonum) ) ) {
|
| 2559 |
checknum = itemRestriction;
|
| 2560 |
checkmode ='rest';
|
| 2561 |
}
|
| 2562 |
|
| 2563 |
if( parseInt(quant) > parseInt(checknum) && checknum != '' ){
|
| 2564 |
if(checkmode == 'rest'){
|
| 2565 |
mes += <?php _e( "'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces' ); ?>+"\n";
|
| 2566 |
}else{
|
| 2567 |
mes += <?php _e( "'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces' ); ?>+"\n";
|
| 2568 |
}
|
| 2569 |
}
|
| 2570 |
}
|
| 2571 |
}
|
| 2572 |
|
| 2573 |
<?php do_action( 'usces_action_nextCart_js_check', $item->ID ); ?>
|
| 2574 |
|
| 2575 |
if( mes != '' ){
|
| 2576 |
alert( mes );
|
| 2577 |
return false;
|
| 2578 |
}else{
|
| 2579 |
return true;
|
| 2580 |
}
|
| 2581 |
},
|
| 2582 |
|
| 2583 |
customerNext : function () {
|
| 2584 |
<?php do_action( 'usces_action_customerNext_js_check', $item->ID ); ?>
|
| 2585 |
},
|
| 2586 |
|
| 2587 |
customerPre : function () {
|
| 2588 |
<?php do_action( 'usces_action_customerPre_js_check', $item->ID ); ?>
|
| 2589 |
},
|
| 2590 |
|
| 2591 |
previousCart : function () {
|
| 2592 |
location.href = uscesL10n.previous_url;
|
| 2593 |
},
|
| 2594 |
|
| 2595 |
settings: {
|
| 2596 |
url: uscesL10n.ajaxurl,
|
| 2597 |
type: 'POST',
|
| 2598 |
cache: false
|
| 2599 |
},
|
| 2600 |
|
| 2601 |
changeStates : function( country ) {
|
| 2602 |
var s = this.settings;
|
| 2603 |
s.data = "action=change_states_ajax&country=" + country;
|
| 2604 |
$.ajax( s ).done(function(data, dataType){
|
| 2605 |
|
| 2606 |
if( 'error' == data ){
|
| 2607 |
alert('error');
|
| 2608 |
}else{
|
| 2609 |
$("select#pref").html( data );
|
| 2610 |
}
|
| 2611 |
}).fail(function(msg){
|
| 2612 |
alert("error");
|
| 2613 |
});
|
| 2614 |
return false;
|
| 2615 |
},
|
| 2616 |
|
| 2617 |
isNum : function (num) {
|
| 2618 |
if (num.match(/[^0-9]/g)) {
|
| 2619 |
return false;
|
| 2620 |
}
|
| 2621 |
return true;
|
| 2622 |
},
|
| 2623 |
purchase : 0
|
| 2624 |
};
|
| 2625 |
$("#country").change(function () {
|
| 2626 |
var country = $("#country option:selected").val();
|
| 2627 |
$("#newcharging_type option:selected").val()
|
| 2628 |
uscesCart.changeStates( country );
|
| 2629 |
});
|
| 2630 |
$("#purchase_form").submit(function () {
|
| 2631 |
if( 0 == uscesCart.purchase ){
|
| 2632 |
uscesCart.purchase = 1;
|
| 2633 |
return true;
|
| 2634 |
}else{
|
| 2635 |
$("#purchase_button").prop("disabled", true);
|
| 2636 |
$("#back_button").prop("disabled", true);
|
| 2637 |
return false;
|
| 2638 |
}
|
| 2639 |
});
|
| 2640 |
|
| 2641 |
})(jQuery);
|
| 2642 |
</script>
|
| 2643 |
<?php
|
| 2644 |
}
|
| 2645 |
|
| 2646 |
usces_states_form_js();
|
| 2647 |
$js = apply_filters( 'usces_filter_shop_foot_js', ob_get_contents() );
|
| 2648 |
ob_end_clean();
|
| 2649 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
| 2650 |
echo $js;
|
| 2651 |
}
|
| 2652 |
|
| 2653 |
public function admin_head() {
|
| 2654 |
global $wp_version;
|
| 2655 |
$wcex_str = '';
|
| 2656 |
$wcex = usces_get_wcex();
|
| 2657 |
foreach ( (array) $wcex as $key => $values ) {
|
| 2658 |
$wcex_str .= "'" . esc_js( $key ) . '-' . esc_js( $values['version'] ) . "', ";
|
| 2659 |
}
|
| 2660 |
$wcex_str = rtrim( $wcex_str, ', ' );
|
| 2661 |
$theme_ob = wp_get_theme();
|
| 2662 |
if ( $theme_ob ) {
|
| 2663 |
$theme = array(
|
| 2664 |
'Name' => esc_js( $theme_ob->get( 'Name' ) ),
|
| 2665 |
'Version' => esc_js( $theme_ob->get( 'Version' ) ),
|
| 2666 |
);
|
| 2667 |
} else {
|
| 2668 |
$theme = array( 'Name' => '', 'Version' => '' );
|
| 2669 |
}
|
| 2670 |
$message = usces_get_admin_script_message();
|
| 2671 |
?>
|
| 2672 |
<link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" />
|
| 2673 |
<script type='text/javascript'>
|
| 2674 |
/* <![CDATA[ */
|
| 2675 |
uscesL10n = {
|
| 2676 |
<?php echo apply_filters( 'usces_filter_admin_uscesL10n', null ); ?>
|
| 2677 |
'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php",
|
| 2678 |
'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>",
|
| 2679 |
'version': "<?php echo USCES_VERSION; ?>",
|
| 2680 |
'wcid': "<?php echo get_option( 'usces_wcid' ); ?>",
|
| 2681 |
'locale': '<?php echo get_locale(); ?>',
|
| 2682 |
'cart_number': "<?php echo get_option( 'usces_cart_number' ); ?>",
|
| 2683 |
'purchase_limit': "<?php echo esc_js( $this->options['purchase_limit'] ); ?>",
|
| 2684 |
'point_rate': "<?php echo esc_js( $this->options['point_rate'] ); ?>",
|
| 2685 |
'shipping_rule': "<?php echo esc_js( $this->options['shipping_rule'] ); ?>",
|
| 2686 |
'theme': "<?php echo esc_html( $theme['Name'] . '-' . $theme['Version'] ); ?>",
|
| 2687 |
'wcex': new Array( <?php wel_esc_script_e( $wcex_str ); ?> ),
|
| 2688 |
'message': new Array( <?php wel_esc_script_e( $message ); ?> ),
|
| 2689 |
'now_loading': "<?php _e( 'now loading', 'usces' ); ?>"
|
| 2690 |
};
|
| 2691 |
/* ]]> */
|
| 2692 |
</script>
|
| 2693 |
<script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js?ver=<?php echo USCES_VERSION; ?>'></script>
|
| 2694 |
<?php
|
| 2695 |
if ( 'edit' == $this->action_status || 'editpost' == $this->action_status ) {
|
| 2696 |
?>
|
| 2697 |
<link rel='stylesheet' href='<?php echo site_url(); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' />
|
| 2698 |
<?php
|
| 2699 |
}
|
| 2700 |
if ( isset( $_REQUEST['page'] ) ) {
|
| 2701 |
switch ( $_REQUEST['page'] ) {
|
| 2702 |
case 'usces_initial':
|
| 2703 |
$cod_type = ( 'change' == $this->options['cod_type'] ) ? 'change' : 'fix';
|
| 2704 |
?>
|
| 2705 |
<script type='text/javascript'>
|
| 2706 |
/* <![CDATA[ */
|
| 2707 |
usces_ini = {
|
| 2708 |
'cod_type': "<?php echo esc_js( $cod_type ); ?>",
|
| 2709 |
'cod_type_fix': "<?php echo esc_js( __( 'Fixation C.O.D.', 'usces' ) ); ?>",
|
| 2710 |
'cod_type_change': "<?php echo esc_js( __( 'Variable C.O.D.', 'usces' ) ); ?>",
|
| 2711 |
'cod_unit': "<?php echo esc_js( __( 'dollars', 'usces' ) ); ?>",
|
| 2712 |
'cod_failure': "<?php echo esc_js( __( 'failure in update', 'usces' ) ); ?>",
|
| 2713 |
'cod_updated': "<?php echo esc_js( __( 'options are updated', 'usces' ) ); ?>",
|
| 2714 |
'cod_limit': "<?php echo esc_js( __( 'A value of the amount of upper limit is incorrect.', 'usces' ) ); ?>",
|
| 2715 |
'cod_label_close': "<?php echo esc_js( __( 'Close', 'usces' ) ); ?>",
|
| 2716 |
'cod_label_update': "<?php echo esc_js( __( 'Update', 'usces' ) ); ?>"
|
| 2717 |
};
|
| 2718 |
/* ]]> */
|
| 2719 |
</script>
|
| 2720 |
<?php
|
| 2721 |
break;
|
| 2722 |
case 'usces_itemnew':
|
| 2723 |
case 'usces_itemedit':
|
| 2724 |
?>
|
| 2725 |
<style type="text/css">
|
| 2726 |
<!--
|
| 2727 |
#usces_mess {
|
| 2728 |
color: #FF0000;
|
| 2729 |
font-weight: bold;
|
| 2730 |
}
|
| 2731 |
-->
|
| 2732 |
</style>
|
| 2733 |
<?php
|
| 2734 |
break;
|
| 2735 |
}
|
| 2736 |
}
|
| 2737 |
|
| 2738 |
if ( is_admin() && ( ( isset( $_GET['order_action'] ) && 'newpost' == $_GET['order_action'] )
|
| 2739 |
|| ( isset( $_GET['page'] ) && 'usces_ordernew' == $_GET['page'] )
|
| 2740 |
|| ( isset( $_GET['order_action'] ) && 'edit' == $_GET['order_action'] )
|
| 2741 |
|| ( isset( $_GET['order_action'] ) && 'editpost' == $_GET['order_action'] )
|
| 2742 |
|| ( isset( $_GET['page'] ) && 'usces_membernew' == $_GET['page'] )
|
| 2743 |
|| ( isset( $_GET['member_action'] ) && 'edit' == $_GET['member_action'] )
|
| 2744 |
|| ( isset( $_GET['member_action'] ) && 'editpost' == $_GET['member_action'] ) ) ) :
|
| 2745 |
switch ( $_GET['page'] ) {
|
| 2746 |
case 'usces_ordernew':
|
| 2747 |
case 'usces_orderlist':
|
| 2748 |
$admin_page = 'order';
|
| 2749 |
break;
|
| 2750 |
case 'usces_membernew':
|
| 2751 |
case 'usces_memberlist':
|
| 2752 |
$admin_page = 'member';
|
| 2753 |
break;
|
| 2754 |
}
|
| 2755 |
?>
|
| 2756 |
<script type='text/javascript'>
|
| 2757 |
jQuery(function($) {
|
| 2758 |
uscesForm = {
|
| 2759 |
settings: {
|
| 2760 |
url: uscesL10n.requestFile,
|
| 2761 |
type: 'POST',
|
| 2762 |
cache: false
|
| 2763 |
},
|
| 2764 |
|
| 2765 |
changeStates : function( country, type ) {
|
| 2766 |
var s = this.settings;
|
| 2767 |
s.data = "action=change_states_ajax&country=" + country;
|
| 2768 |
$.ajax( s ).done(function(data, dataType){
|
| 2769 |
if( 'error' == data ){
|
| 2770 |
alert('error');
|
| 2771 |
}else{
|
| 2772 |
$("select#" + type + "_pref").html( data );
|
| 2773 |
if( customercountry == country && 'customer' == type ){
|
| 2774 |
$("#" + type + "_pref").prop({selectedIndex:customerstate});
|
| 2775 |
}else if( deliverycountry == country && 'delivery' == type ){
|
| 2776 |
$("#" + type + "_pref").prop({selectedIndex:deliverystate});
|
| 2777 |
}else if( customercountry == country && 'member' == type ){
|
| 2778 |
$("#" + type + "_pref").prop({selectedIndex:customerstate});
|
| 2779 |
}
|
| 2780 |
}
|
| 2781 |
}).fail(function(msg){
|
| 2782 |
alert("error");
|
| 2783 |
});
|
| 2784 |
return false;
|
| 2785 |
},
|
| 2786 |
|
| 2787 |
isNum : function (num) {
|
| 2788 |
if (num.match(/[^0-9]/g)) {
|
| 2789 |
return false;
|
| 2790 |
}
|
| 2791 |
return true;
|
| 2792 |
}
|
| 2793 |
};
|
| 2794 |
<?php
|
| 2795 |
if ( 'order' == $admin_page ) {
|
| 2796 |
?>
|
| 2797 |
if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) {
|
| 2798 |
var customerstate = $("#customer_pref").get(0).selectedIndex;
|
| 2799 |
var customercountry = $("#customer_country").val();
|
| 2800 |
var deliverystate = $("#delivery_pref").get(0).selectedIndex;
|
| 2801 |
var deliverycountry = $("#delivery_country").val();
|
| 2802 |
|
| 2803 |
$("#customer_country").change(function () {
|
| 2804 |
var country = $("#customer_country option:selected").val();
|
| 2805 |
uscesForm.changeStates( country, 'customer' );
|
| 2806 |
});
|
| 2807 |
$("#delivery_country").change(function () {
|
| 2808 |
var country = $("#delivery_country option:selected").val();
|
| 2809 |
uscesForm.changeStates( country, 'delivery' );
|
| 2810 |
});
|
| 2811 |
}
|
| 2812 |
<?php
|
| 2813 |
} elseif ( 'member' == $admin_page ) {
|
| 2814 |
?>
|
| 2815 |
if( undefined != $("#member_pref").get(0) ) {
|
| 2816 |
var customerstate = $("#member_pref").get(0).selectedIndex;
|
| 2817 |
var customercountry = $("#member_country").val();
|
| 2818 |
var deliverystate = '';
|
| 2819 |
var deliverycountry = '';
|
| 2820 |
|
| 2821 |
$("#member_country").change(function () {
|
| 2822 |
var country = $("#member_country option:selected").val();
|
| 2823 |
uscesForm.changeStates( country, 'member' );
|
| 2824 |
});
|
| 2825 |
}
|
| 2826 |
<?php
|
| 2827 |
}
|
| 2828 |
?>
|
| 2829 |
});
|
| 2830 |
</script>
|
| 2831 |
<?php
|
| 2832 |
endif;
|
| 2833 |
}
|
| 2834 |
|
| 2835 |
/**
|
| 2836 |
* Main Process.
|
| 2837 |
*/
|
| 2838 |
public function main() {
|
| 2839 |
global $wpdb, $wp_locale, $wp_version, $post_ID;
|
| 2840 |
global $wp_query, $usces_action, $post, $action, $editing;
|
| 2841 |
|
| 2842 |
update_option( 'usces_shipping_rule', apply_filters( 'usces_filter_shipping_rule', get_option( 'usces_shipping_rule' ) ) );
|
| 2843 |
$this->shipping_rule = get_option( 'usces_shipping_rule' );
|
| 2844 |
|
| 2845 |
if ( ! is_admin() ) {
|
| 2846 |
$this->usces_cookie();
|
| 2847 |
} else {
|
| 2848 |
$this->user_level = usces_get_admin_user_level();
|
| 2849 |
}
|
| 2850 |
$this->make_url();
|
| 2851 |
|
| 2852 |
add_filter( 'cron_schedules', 'usces_schedules_intervals' );
|
| 2853 |
add_action( 'wp', 'usces_wevent' );
|
| 2854 |
do_action( 'usces_main' );
|
| 2855 |
$this->update_table();
|
| 2856 |
|
| 2857 |
require_once USCES_PLUGIN_DIR . '/classes/cart.class.php';
|
| 2858 |
$this->cart = new usces_cart();
|
| 2859 |
|
| 2860 |
do_action( 'usces_after_cart_instant' );
|
| 2861 |
|
| 2862 |
if ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'duplicate' == $_REQUEST['action'] ) {
|
| 2863 |
$post_id = (int) $_GET['post'];
|
| 2864 |
$new_id = usces_item_duplicate( $post_id );
|
| 2865 |
$ref = isset( $_REQUEST['usces_referer'] ) ? urlencode( esc_url( $_REQUEST['usces_referer'] ) ) : '';
|
| 2866 |
$url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref;
|
| 2867 |
wp_redirect( $url );
|
| 2868 |
exit;
|
| 2869 |
} elseif ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'itemcsv' == $_REQUEST['action'] ) {
|
| 2870 |
// $filename = usces_item_uploadcsv();
|
| 2871 |
// $mode = ( isset( $_REQUEST['upload_mode'] ) ) ? $_REQUEST['upload_mode'] : 'all';
|
| 2872 |
// $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&mode=' . $mode . '®file=' . $filename;
|
| 2873 |
// wp_redirect( $url );
|
| 2874 |
// exit;
|
| 2875 |
}
|
| 2876 |
|
| 2877 |
$this->ad_controller();
|
| 2878 |
|
| 2879 |
if ( isset( $_GET['page'] ) && 'usces_itemnew' == $_GET['page'] ) {
|
| 2880 |
$itemnew = 'new';
|
| 2881 |
} else {
|
| 2882 |
$itemnew = '';
|
| 2883 |
}
|
| 2884 |
|
| 2885 |
wp_enqueue_script( 'jquery' );
|
| 2886 |
|
| 2887 |
if ( is_admin() && isset( $_REQUEST['page'] ) && ( ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) || 'new' == $itemnew || ( isset( $_REQUEST['action'] ) && 'editpost' == $_REQUEST['action'] ) ) ) {
|
| 2888 |
|
| 2889 |
if ( isset( $_REQUEST['action'] ) && 'editpost' != $_REQUEST['action'] && 'new' == $itemnew ) {
|
| 2890 |
if ( version_compare( $wp_version, '3.0-beta', '>' ) ) {
|
| 2891 |
if ( ! isset( $_GET['post_type'] ) ) {
|
| 2892 |
$post_type = 'post';
|
| 2893 |
} elseif ( in_array( $_GET['post_type'], get_post_types( array( 'public' => true ) ) ) ) {
|
| 2894 |
$post_type = $_GET['post_type'];
|
| 2895 |
} else {
|
| 2896 |
wp_die( __( 'Invalid post type' ) );
|
| 2897 |
}
|
| 2898 |
$post_type_object = get_post_type_object( $post_type );
|
| 2899 |
$editing = true;
|
| 2900 |
$post = $this->get_default_post_to_edit30( $post_type, true );
|
| 2901 |
$post_ID = $post->ID;
|
| 2902 |
} else {
|
| 2903 |
$post = $this->get_default_post_to_edit();
|
| 2904 |
}
|
| 2905 |
} else {
|
| 2906 |
if ( version_compare( $wp_version, '3.0-beta', '>' ) ) {
|
| 2907 |
if ( isset( $_GET['post'] ) ) {
|
| 2908 |
$post_id = (int) $_GET['post'];
|
| 2909 |
} elseif ( isset( $_POST['post_ID'] ) ) {
|
| 2910 |
$post_id = (int) $_POST['post_ID'];
|
| 2911 |
} else {
|
| 2912 |
$post_id = 0;
|
| 2913 |
}
|
| 2914 |
$post_ID = $post_id;
|
| 2915 |
$post = null;
|
| 2916 |
$post_type_object = null;
|
| 2917 |
$post_type = null;
|
| 2918 |
if ( $post_id ) {
|
| 2919 |
$product = wel_get_product( $post_id );
|
| 2920 |
$post = $product['_pst'];
|
| 2921 |
if ( $post ) {
|
| 2922 |
$post_type_object = get_post_type_object( $post->post_type );
|
| 2923 |
if ( $post_type_object ) {
|
| 2924 |
$post_type = $post->post_type;
|
| 2925 |
if ( ! isset( $current_screen ) ) {
|
| 2926 |
$current_screen = new stdClass();
|
| 2927 |
}
|
| 2928 |
$current_screen->post_type = $post->post_type;
|
| 2929 |
$current_screen->id = $current_screen->post_type;
|
| 2930 |
}
|
| 2931 |
}
|
| 2932 |
} elseif ( isset( $_POST['post_type'] ) ) {
|
| 2933 |
$post_type_object = get_post_type_object( $_POST['post_type'] );
|
| 2934 |
if ( $post_type_object ) {
|
| 2935 |
$post_type = $post_type_object->name;
|
| 2936 |
$current_screen->post_type = $post_type;
|
| 2937 |
$current_screen->id = $current_screen->post_type;
|
| 2938 |
}
|
| 2939 |
}
|
| 2940 |
} else {
|
| 2941 |
if ( isset( $_GET['post'] ) ) {
|
| 2942 |
$post_ID = (int) $_GET['post'];
|
| 2943 |
$product = wel_get_product( $post_ID );
|
| 2944 |
$post = $product['_pst'];
|
| 2945 |
} else {
|
| 2946 |
$post_ID = isset( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0;
|
| 2947 |
if ( ! empty( $post_ID ) ) {
|
| 2948 |
$product = wel_get_product( $post_ID );
|
| 2949 |
$post = $product['_pst'];
|
| 2950 |
}
|
| 2951 |
}
|
| 2952 |
}
|
| 2953 |
}
|
| 2954 |
|
| 2955 |
$editing = true;
|
| 2956 |
wp_enqueue_script( 'autosave' );
|
| 2957 |
wp_enqueue_script( 'post' );
|
| 2958 |
add_thickbox();
|
| 2959 |
wp_enqueue_script( 'media-upload' );
|
| 2960 |
wp_enqueue_script( 'word-count' );
|
| 2961 |
wp_enqueue_script( 'admin-comments' );
|
| 2962 |
|
| 2963 |
if ( version_compare( $wp_version, '3.3', '<' ) ) {
|
| 2964 |
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
|
| 2965 |
}
|
| 2966 |
wp_enqueue_script( 'quicktags' );
|
| 2967 |
}
|
| 2968 |
|
| 2969 |
if ( is_admin() && isset( $_REQUEST['page'] ) ) {
|
| 2970 |
|
| 2971 |
wp_enqueue_script( 'jquery-color' );
|
| 2972 |
|
| 2973 |
switch ( $_REQUEST['page'] ) {
|
| 2974 |
case 'usces_initial':
|
| 2975 |
$js = USCES_FRONT_PLUGIN_URL . '/js/usces_initial.js';
|
| 2976 |
wp_enqueue_script( 'usces_initial.js', $js, array( 'jquery-ui-dialog', 'jquery-ui-sortable' ) );
|
| 2977 |
break;
|
| 2978 |
case 'usces_settlement':
|
| 2979 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 2980 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 2981 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 2982 |
$jquery_color_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/color/jscolor.js';
|
| 2983 |
wp_enqueue_script( 'jquery-jscolor', $jquery_color_url, array( 'jquery-color' ) );
|
| 2984 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
| 2985 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
| 2986 |
break;
|
| 2987 |
case 'usces_cart':
|
| 2988 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 2989 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 2990 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 2991 |
break;
|
| 2992 |
case 'usces_member':
|
| 2993 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 2994 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 2995 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 2996 |
break;
|
| 2997 |
case 'usces_orderlist':
|
| 2998 |
case 'usces_ordernew':
|
| 2999 |
wp_enqueue_script( 'jquery-ui-datepicker' );
|
| 3000 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
| 3001 |
break;
|
| 3002 |
case 'usces_memberlist':
|
| 3003 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
| 3004 |
break;
|
| 3005 |
case 'usces_itemnew':
|
| 3006 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
| 3007 |
break;
|
| 3008 |
case 'usces_itemedit':
|
| 3009 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 3010 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 3011 |
if ( isset( $_REQUEST['action'] ) && 'upload_register' == $_REQUEST['action'] ) {
|
| 3012 |
// $upload_registerUrl = USCES_FRONT_PLUGIN_URL . '/js/usces-item-upload.js';
|
| 3013 |
// wp_enqueue_script( 'upload_register', $upload_registerUrl, array( 'jquery' ), USCES_VERSION, true );
|
| 3014 |
// @ob_end_clean();
|
| 3015 |
// ob_start();
|
| 3016 |
} else {
|
| 3017 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
| 3018 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
| 3019 |
}
|
| 3020 |
break;
|
| 3021 |
case 'usces_delivery':
|
| 3022 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 3023 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 3024 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 3025 |
break;
|
| 3026 |
case 'usces_system':
|
| 3027 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 3028 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 3029 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 3030 |
break;
|
| 3031 |
case 'usces_mail':
|
| 3032 |
wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) );
|
| 3033 |
$jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js';
|
| 3034 |
wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) );
|
| 3035 |
break;
|
| 3036 |
}
|
| 3037 |
}
|
| 3038 |
|
| 3039 |
if ( isset( $_REQUEST['order_action'] ) && 'pdfout' == $_REQUEST['order_action'] ) {
|
| 3040 |
check_admin_referer( 'order_edit', 'wc_nonce' );
|
| 3041 |
|
| 3042 |
$oid = filter_input( INPUT_GET, 'order_id' );
|
| 3043 |
if ( ! is_user_logged_in() ) {
|
| 3044 |
$this->get_current_member();
|
| 3045 |
$mid = $this->current_member['id'];
|
| 3046 |
if ( 0 === (int) $mid || ! $this->is_order( $mid, $oid ) ) {
|
| 3047 |
die( 'No permission' );
|
| 3048 |
}
|
| 3049 |
}
|
| 3050 |
if ( ( isset( $this->options['tax_display'] ) && 'activate' == $this->options['tax_display'] ) && usces_is_reduced_taxrate( $oid ) ) {
|
| 3051 |
require_once( apply_filters( 'usces_filter_orderpdf_path_ex', USCES_PLUGIN_DIR . '/includes/order_print_ex.php' ) );
|
| 3052 |
} else {
|
| 3053 |
require_once( apply_filters( 'usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php' ) );
|
| 3054 |
}
|
| 3055 |
}
|
| 3056 |
|
| 3057 |
if ( ! empty( $this->settlement_notice ) &&
|
| 3058 |
( 1 === (int) $this->options['system']['settlement_notice'] || defined( 'WCEX_DLSELLER' ) || defined( 'WCEX_AUTO_DELIVERY' ) ) ) {
|
| 3059 |
add_action( 'admin_notices', 'usces_display_settlement_notice' );
|
| 3060 |
}
|
| 3061 |
|
| 3062 |
do_action( 'usces_after_main' );
|
| 3063 |
}
|
| 3064 |
|
| 3065 |
public function stripslashes_deep_post( $array ) {
|
| 3066 |
$res = array();
|
| 3067 |
foreach ( $array as $key => $value ) {
|
| 3068 |
$key = stripslashes( $key );
|
| 3069 |
if ( is_array( $value ) ) {
|
| 3070 |
$value = $this->stripslashes_deep_post( $value );
|
| 3071 |
} else {
|
| 3072 |
$value = is_null( $value ) ? $value : usces_erase_emoji( stripslashes( $value ) );
|
| 3073 |
}
|
| 3074 |
$res[ $key ] = $value;
|
| 3075 |
}
|
| 3076 |
return $res;
|
| 3077 |
}
|
| 3078 |
|
| 3079 |
public function make_url() {
|
| 3080 |
$permalink_structure = get_option( 'permalink_structure' );
|
| 3081 |
if ( $this->use_ssl ) {
|
| 3082 |
if ( $permalink_structure ) {
|
| 3083 |
$this->delim = '&';
|
| 3084 |
$home_perse = parse_url( get_option( 'home' ) );
|
| 3085 |
$home_perse_path = isset( $home_perse['path'] ) ? $home_perse['path'] : '';
|
| 3086 |
$home_path = $home_perse['host'] . $home_perse_path;
|
| 3087 |
$ssl_perse = parse_url( $this->options['ssl_url'] );
|
| 3088 |
$ssl_perse_path = isset( $ssl_perse['path'] ) ? $ssl_perse['path'] : '';
|
| 3089 |
$ssl_path = $ssl_perse['host'] . $ssl_perse_path;
|
| 3090 |
if ( $home_perse_path != $ssl_perse_path ) {
|
| 3091 |
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
|
| 3092 |
define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid() );
|
| 3093 |
}
|
| 3094 |
if ( ! defined( 'USCES_CART_URL' ) ) {
|
| 3095 |
define( 'USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid() );
|
| 3096 |
}
|
| 3097 |
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
|
| 3098 |
define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
|
| 3099 |
}
|
| 3100 |
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
|
| 3101 |
define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
|
| 3102 |
}
|
| 3103 |
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
|
| 3104 |
define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=login' );
|
| 3105 |
}
|
| 3106 |
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
|
| 3107 |
define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
|
| 3108 |
}
|
| 3109 |
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
|
| 3110 |
define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() );
|
| 3111 |
}
|
| 3112 |
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
|
| 3113 |
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
|
| 3114 |
define( 'USCES_INQUIRY_URL', $inquiry_url );
|
| 3115 |
}
|
| 3116 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3117 |
define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER );
|
| 3118 |
}
|
| 3119 |
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
|
| 3120 |
define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
|
| 3121 |
}
|
| 3122 |
} else {
|
| 3123 |
$ssl_plink_cart = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_CART_NUMBER ) ) );
|
| 3124 |
$ssl_plink_member = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_MEMBER_NUMBER ) ) );
|
| 3125 |
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
|
| 3126 |
define( 'USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1' );
|
| 3127 |
}
|
| 3128 |
if ( ! defined( 'USCES_CART_URL' ) ) {
|
| 3129 |
define( 'USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() );
|
| 3130 |
}
|
| 3131 |
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
|
| 3132 |
define( 'USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
|
| 3133 |
}
|
| 3134 |
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
|
| 3135 |
define( 'USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
|
| 3136 |
}
|
| 3137 |
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
|
| 3138 |
define( 'USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=login' );
|
| 3139 |
}
|
| 3140 |
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
|
| 3141 |
define( 'USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
|
| 3142 |
}
|
| 3143 |
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
|
| 3144 |
define( 'USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() );
|
| 3145 |
}
|
| 3146 |
if ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) {
|
| 3147 |
$inquiry_url = get_home_url();
|
| 3148 |
} else {
|
| 3149 |
$ssl_plink_inquiry = str_replace( 'http://', 'https://', str_replace( $home_path, $ssl_path, get_page_link( $this->options['inquiry_id'] ) ) );
|
| 3150 |
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid();
|
| 3151 |
}
|
| 3152 |
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
|
| 3153 |
define( 'USCES_INQUIRY_URL', $inquiry_url );
|
| 3154 |
}
|
| 3155 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3156 |
define( 'USCES_CART_NONSESSION_URL', $ssl_plink_cart );
|
| 3157 |
}
|
| 3158 |
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
|
| 3159 |
define( 'USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
|
| 3160 |
}
|
| 3161 |
}
|
| 3162 |
} else {
|
| 3163 |
$this->delim = '&';
|
| 3164 |
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
|
| 3165 |
define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid() );
|
| 3166 |
}
|
| 3167 |
if ( ! defined( 'USCES_CART_URL' ) ) {
|
| 3168 |
define( 'USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid() );
|
| 3169 |
}
|
| 3170 |
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
|
| 3171 |
define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=lostmemberpassword' );
|
| 3172 |
}
|
| 3173 |
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
|
| 3174 |
define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=newmember' );
|
| 3175 |
}
|
| 3176 |
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
|
| 3177 |
define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=login' );
|
| 3178 |
}
|
| 3179 |
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
|
| 3180 |
define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&usces_page=logout' );
|
| 3181 |
}
|
| 3182 |
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
|
| 3183 |
define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() );
|
| 3184 |
}
|
| 3185 |
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid();
|
| 3186 |
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
|
| 3187 |
define( 'USCES_INQUIRY_URL', $inquiry_url );
|
| 3188 |
}
|
| 3189 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3190 |
define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER );
|
| 3191 |
}
|
| 3192 |
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
|
| 3193 |
define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
|
| 3194 |
}
|
| 3195 |
}
|
| 3196 |
if ( ! is_admin() ) {
|
| 3197 |
add_filter( 'home_url', array( $this, 'usces_ssl_page_link' ) );
|
| 3198 |
add_filter( 'wp_get_attachment_url', array( $this, 'usces_ssl_attachment_link' ) );
|
| 3199 |
add_filter( 'icon_dir_uri', array( $this, 'usces_ssl_icon_dir_uri' ) );
|
| 3200 |
add_filter( 'stylesheet_directory_uri', array( $this, 'usces_ssl_contents_link' ) );
|
| 3201 |
add_filter( 'template_directory_uri', array( $this, 'usces_ssl_contents_link' ) );
|
| 3202 |
add_filter( 'script_loader_src', array( $this, 'usces_ssl_script_link' ) );
|
| 3203 |
add_filter( 'style_loader_src', array( $this, 'usces_ssl_script_link' ) );
|
| 3204 |
}
|
| 3205 |
} else {
|
| 3206 |
if ( $permalink_structure ) {
|
| 3207 |
$this->delim = '?';
|
| 3208 |
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
|
| 3209 |
define( 'USCES_CUSTOMER_URL', get_page_link( USCES_CART_NUMBER ) . '?customerinfo=1' );
|
| 3210 |
}
|
| 3211 |
if ( ! defined( 'USCES_CART_URL' ) ) {
|
| 3212 |
define( 'USCES_CART_URL', get_page_link( USCES_CART_NUMBER ) );
|
| 3213 |
}
|
| 3214 |
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
|
| 3215 |
define( 'USCES_LOSTMEMBERPASSWORD_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=lostmemberpassword' );
|
| 3216 |
}
|
| 3217 |
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
|
| 3218 |
define( 'USCES_NEWMEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=newmember' );
|
| 3219 |
}
|
| 3220 |
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
|
| 3221 |
define( 'USCES_LOGIN_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=login' );
|
| 3222 |
}
|
| 3223 |
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
|
| 3224 |
define( 'USCES_LOGOUT_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=logout' );
|
| 3225 |
}
|
| 3226 |
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
|
| 3227 |
define( 'USCES_MEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) );
|
| 3228 |
}
|
| 3229 |
$inquiry_url = ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) ? get_home_url() : get_page_link( $this->options['inquiry_id'] );
|
| 3230 |
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
|
| 3231 |
define( 'USCES_INQUIRY_URL', $inquiry_url );
|
| 3232 |
}
|
| 3233 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3234 |
define( 'USCES_CART_NONSESSION_URL', get_page_link( USCES_CART_NUMBER ) );
|
| 3235 |
}
|
| 3236 |
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
|
| 3237 |
define( 'USCES_PAYPAL_NOTIFY_URL', get_page_link( USCES_CART_NUMBER ) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
|
| 3238 |
}
|
| 3239 |
} else {
|
| 3240 |
$this->delim = '&';
|
| 3241 |
if ( ! defined( 'USCES_CUSTOMER_URL' ) ) {
|
| 3242 |
define( 'USCES_CUSTOMER_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1' );
|
| 3243 |
}
|
| 3244 |
if ( ! defined( 'USCES_CART_URL' ) ) {
|
| 3245 |
define( 'USCES_CART_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER );
|
| 3246 |
}
|
| 3247 |
if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) {
|
| 3248 |
define( 'USCES_LOSTMEMBERPASSWORD_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=lostmemberpassword' );
|
| 3249 |
}
|
| 3250 |
if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) {
|
| 3251 |
define( 'USCES_NEWMEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=newmember' );
|
| 3252 |
}
|
| 3253 |
if ( ! defined( 'USCES_LOGIN_URL' ) ) {
|
| 3254 |
define( 'USCES_LOGIN_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=login' );
|
| 3255 |
}
|
| 3256 |
if ( ! defined( 'USCES_LOGOUT_URL' ) ) {
|
| 3257 |
define( 'USCES_LOGOUT_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' );
|
| 3258 |
}
|
| 3259 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3260 |
define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' );
|
| 3261 |
}
|
| 3262 |
if ( ! defined( 'USCES_MEMBER_URL' ) ) {
|
| 3263 |
define( 'USCES_MEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER );
|
| 3264 |
}
|
| 3265 |
$inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option( 'home' ) . '/?page_id=' . $this->options['inquiry_id'];
|
| 3266 |
if ( ! defined( 'USCES_INQUIRY_URL' ) ) {
|
| 3267 |
define( 'USCES_INQUIRY_URL', $inquiry_url );
|
| 3268 |
}
|
| 3269 |
if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) {
|
| 3270 |
define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER );
|
| 3271 |
}
|
| 3272 |
if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) {
|
| 3273 |
define( 'USCES_PAYPAL_NOTIFY_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid( false ) );
|
| 3274 |
}
|
| 3275 |
}
|
| 3276 |
}
|
| 3277 |
}
|
| 3278 |
|
| 3279 |
public function regist_action() {
|
| 3280 |
usces_register_action( 'inCart', 'post', 'inCart', null, 'inCart' );
|
| 3281 |
usces_register_action( 'upButton', 'post', 'upButton', null, 'upButton' );
|
| 3282 |
usces_register_action( 'delButton', 'post', 'delButton', null, 'delButton' );
|
| 3283 |
usces_register_action( 'backCart', 'post', 'backCart', null, 'backCart' );
|
| 3284 |
usces_register_action( 'customerinfo', 'request', 'customerinfo', null, 'customerinfo' );
|
| 3285 |
usces_register_action( 'backCustomer', 'post', 'backCustomer', null, 'backCustomer' );
|
| 3286 |
usces_register_action( 'customerlogin', 'post', 'customerlogin', null, 'customerlogin' );
|
| 3287 |
usces_register_action( 'reganddeliveryinfo', 'post', 'reganddeliveryinfo', null, 'reganddeliveryinfo' );
|
| 3288 |
usces_register_action( 'deliveryinfo', 'post', 'deliveryinfo', null, 'deliveryinfo' );
|
| 3289 |
usces_register_action( 'backDelivery', 'request', 'backDelivery', null, 'backDelivery' );
|
| 3290 |
usces_register_action( 'confirm', 'request', 'confirm', null, 'confirm' );
|
| 3291 |
usces_register_action( 'use_point', 'post', 'use_point', null, 'use_point' );
|
| 3292 |
usces_register_action( 'backConfirm', 'post', 'backConfirm', null, 'backConfirm' );
|
| 3293 |
usces_register_action( 'purchase', 'request', 'purchase', null, 'purchase' );
|
| 3294 |
usces_register_action( 'acting_return', 'request', 'acting_return', null, 'acting_return' );
|
| 3295 |
usces_register_action( 'settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon' );
|
| 3296 |
usces_register_action( 'inquiry_button', 'post', 'inquiry_button', null, 'inquiry_button' );
|
| 3297 |
usces_register_action( 'member_login', 'request', 'member_login', null, 'member_login_page' );
|
| 3298 |
usces_register_action( 'regmember', 'request', 'regmember', null, 'regmember' );
|
| 3299 |
usces_register_action( 'editmember', 'request', 'editmember', null, 'editmember' );
|
| 3300 |
usces_register_action( 'deletemember', 'request', 'deletemember', null, 'deletemember' );
|
| 3301 |
usces_register_action( 'page_login', 'get', 'usces_page', 'login', 'member_login_page' );
|
| 3302 |
usces_register_action( 'page_logout', 'get', 'usces_page', 'logout', 'page_logout' );
|
| 3303 |
usces_register_action( 'page_lostmemberpassword', 'get', 'usces_page', 'lostmemberpassword', 'page_lostmemberpassword' );
|
| 3304 |
usces_register_action( 'lostpassword', 'request', 'lostpassword', null, 'lostpassword' );
|
| 3305 |
usces_register_action( 'uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword' );
|
| 3306 |
usces_register_action( 'changepassword', 'request', 'changepassword', null, 'changepassword_page' );
|
| 3307 |
usces_register_action( 'page_newmember', 'get', 'usces_page', 'newmember', 'page_newmember' );
|
| 3308 |
usces_register_action( 'page_search_item', 'get', 'usces_page', 'search_item', 'page_search_item' );
|
| 3309 |
usces_register_action( 'front_ajax', 'post', 'usces_ajax_action', null, 'front_ajax' );
|
| 3310 |
}
|
| 3311 |
|
| 3312 |
public function ad_controller() {
|
| 3313 |
global $usces_action;
|
| 3314 |
ksort( $usces_action );
|
| 3315 |
if ( $this->is_maintenance() && ! is_user_logged_in() ) {
|
| 3316 |
$this->maintenance();
|
| 3317 |
} else {
|
| 3318 |
$action_array = array(
|
| 3319 |
'inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer',
|
| 3320 |
'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point',
|
| 3321 |
'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login',
|
| 3322 |
'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword',
|
| 3323 |
'uscesmode_changepassword', 'changepassword', 'page_newmember',
|
| 3324 |
'page_search_item', 'front_ajax',
|
| 3325 |
);
|
| 3326 |
|
| 3327 |
$action_array = apply_filters( 'usces_filter_action_array', $action_array );
|
| 3328 |
|
| 3329 |
$flg = 0;
|
| 3330 |
$res = true;
|
| 3331 |
foreach ( $usces_action as $handle => $action ) {
|
| 3332 |
extract( $action );
|
| 3333 |
switch ( $type ) {
|
| 3334 |
case 'post':
|
| 3335 |
if ( empty( $value ) ) {
|
| 3336 |
if ( isset( $_POST[ $key ] ) ) {
|
| 3337 |
if ( in_array( $handle, $action_array ) ) {
|
| 3338 |
$res = call_user_func( array( $this, $function ) );
|
| 3339 |
} else {
|
| 3340 |
$res = call_user_func( $function );
|
| 3341 |
}
|
| 3342 |
$flg = 1;
|
| 3343 |
}
|
| 3344 |
} else {
|
| 3345 |
if ( isset( $_POST[ $key ] ) && $_POST[ $key ] == $value ) {
|
| 3346 |
if ( in_array( $handle, $action_array ) ) {
|
| 3347 |
$res = call_user_func( array( $this, $function ) );
|
| 3348 |
} else {
|
| 3349 |
$res = call_user_func( $function );
|
| 3350 |
}
|
| 3351 |
$flg = 1;
|
| 3352 |
}
|
| 3353 |
}
|
| 3354 |
break;
|
| 3355 |
case 'get':
|
| 3356 |
if ( empty( $value ) ) {
|
| 3357 |
if ( isset( $_GET[ $key ] ) ) {
|
| 3358 |
if ( in_array( $handle, $action_array ) ) {
|
| 3359 |
$res = call_user_func( array( $this, $function ) );
|
| 3360 |
} else {
|
| 3361 |
$res = call_user_func( $function );
|
| 3362 |
}
|
| 3363 |
$flg = 1;
|
| 3364 |
}
|
| 3365 |
} else {
|
| 3366 |
if ( isset( $_GET[ $key ] ) && $_GET[ $key ] == $value ) {
|
| 3367 |
if ( in_array( $handle, $action_array ) ) {
|
| 3368 |
$res = call_user_func( array( $this, $function ) );
|
| 3369 |
} else {
|
| 3370 |
$res = call_user_func( $function );
|
| 3371 |
}
|
| 3372 |
$flg = 1;
|
| 3373 |
}
|
| 3374 |
}
|
| 3375 |
break;
|
| 3376 |
case 'request':
|
| 3377 |
if ( empty( $value ) ) {
|
| 3378 |
if ( isset( $_REQUEST[ $key ] ) ) {
|
| 3379 |
if ( in_array( $handle, $action_array ) ) {
|
| 3380 |
$res = call_user_func( array( $this, $function ) );
|
| 3381 |
} else {
|
| 3382 |
$res = call_user_func( $function );
|
| 3383 |
}
|
| 3384 |
$flg = 1;
|
| 3385 |
}
|
| 3386 |
} else {
|
| 3387 |
if ( isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] == $value ) {
|
| 3388 |
if ( in_array( $handle, $action_array ) ) {
|
| 3389 |
$res = call_user_func( array( $this, $function ) );
|
| 3390 |
} else {
|
| 3391 |
$res = call_user_func( $function );
|
| 3392 |
}
|
| 3393 |
$flg = 1;
|
| 3394 |
}
|
| 3395 |
}
|
| 3396 |
break;
|
| 3397 |
}
|
| 3398 |
if ( ! $res ) {
|
| 3399 |
break;
|
| 3400 |
}
|
| 3401 |
}
|
| 3402 |
if ( ! $flg ) {
|
| 3403 |
$this->default_page();
|
| 3404 |
}
|
| 3405 |
}
|
| 3406 |
}
|
| 3407 |
|
| 3408 |
/**
|
| 3409 |
* Action function.
|
| 3410 |
*/
|
| 3411 |
public function front_ajax() {
|
| 3412 |
switch ( $_POST['usces_ajax_action'] ) {
|
| 3413 |
case 'change_states':
|
| 3414 |
change_states_ajax();
|
| 3415 |
break;
|
| 3416 |
}
|
| 3417 |
do_action( 'usces_front_ajax' );
|
| 3418 |
}
|
| 3419 |
|
| 3420 |
public function maintenance() {
|
| 3421 |
$this->page = 'maintenance';
|
| 3422 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3423 |
}
|
| 3424 |
|
| 3425 |
public function inCart() {
|
| 3426 |
global $wp_query;
|
| 3427 |
$this->page = 'cart';
|
| 3428 |
$this->incart_check();
|
| 3429 |
$this->cart->inCart();
|
| 3430 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3431 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3432 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3433 |
}
|
| 3434 |
|
| 3435 |
public function upButton() {
|
| 3436 |
global $wp_query;
|
| 3437 |
$this->page = 'cart';
|
| 3438 |
$this->error_message = $this->cart->upCart();
|
| 3439 |
if ( empty( $this->error_message ) ) {
|
| 3440 |
$this->error_message = $this->zaiko_check();
|
| 3441 |
}
|
| 3442 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3443 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3444 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3445 |
}
|
| 3446 |
|
| 3447 |
public function delButton() {
|
| 3448 |
global $wp_query;
|
| 3449 |
$this->page = 'cart';
|
| 3450 |
$this->cart->del_row();
|
| 3451 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3452 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3453 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3454 |
}
|
| 3455 |
|
| 3456 |
public function backCart() {
|
| 3457 |
global $wp_query;
|
| 3458 |
$this->page = 'cart';
|
| 3459 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3460 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3461 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3462 |
}
|
| 3463 |
|
| 3464 |
public function customerinfo() {
|
| 3465 |
global $wp_query;
|
| 3466 |
if ( false === $this->cart->num_row() ) {
|
| 3467 |
header( 'location: ' . get_option( 'home' ) );
|
| 3468 |
exit;
|
| 3469 |
}
|
| 3470 |
do_action( 'usces_action_customerinfo' );
|
| 3471 |
$this->cart->entry();
|
| 3472 |
$this->error_message = $this->zaiko_check();
|
| 3473 |
$this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message );
|
| 3474 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 3475 |
if ( $this->is_member_logged_in() ) {
|
| 3476 |
$this->error_message = has_custom_customer_field_essential();
|
| 3477 |
$this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'delivery' : 'customer';
|
| 3478 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3479 |
} else {
|
| 3480 |
$this->page = 'customer';
|
| 3481 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3482 |
}
|
| 3483 |
} else {
|
| 3484 |
$this->page = 'cart';
|
| 3485 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3486 |
}
|
| 3487 |
if ( ! $this->cart->is_order_condition() ) {
|
| 3488 |
$order_conditions = $this->get_condition();
|
| 3489 |
$this->cart->set_order_condition( $order_conditions );
|
| 3490 |
}
|
| 3491 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3492 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3493 |
}
|
| 3494 |
|
| 3495 |
public function backCustomer() {
|
| 3496 |
global $wp_query;
|
| 3497 |
if ( false === $this->cart->num_row() ) {
|
| 3498 |
header( 'location: ' . get_option( 'home' ) );
|
| 3499 |
exit;
|
| 3500 |
}
|
| 3501 |
$this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' );
|
| 3502 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3503 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3504 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3505 |
}
|
| 3506 |
|
| 3507 |
public function customerlogin() {
|
| 3508 |
global $wp_query;
|
| 3509 |
if ( false === $this->cart->num_row() ) {
|
| 3510 |
header( 'location: ' . get_option( 'home' ) );
|
| 3511 |
exit;
|
| 3512 |
}
|
| 3513 |
if ( 'member' == $this->member_login() ) {
|
| 3514 |
do_action( 'usces_action_member_customer_logined' );
|
| 3515 |
$this->cart->entry();
|
| 3516 |
// $this->error_message = has_custom_customer_field_essential();
|
| 3517 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 3518 |
$this->page = 'delivery';
|
| 3519 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3520 |
} else {
|
| 3521 |
$this->page = 'customer';
|
| 3522 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3523 |
}
|
| 3524 |
} else {
|
| 3525 |
$this->cart->entry();
|
| 3526 |
$this->page = 'customer';
|
| 3527 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3528 |
}
|
| 3529 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3530 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3531 |
}
|
| 3532 |
|
| 3533 |
public function reganddeliveryinfo() {
|
| 3534 |
global $wp_query;
|
| 3535 |
if ( false === $this->cart->num_row() ) {
|
| 3536 |
header( 'location: ' . get_option( 'home' ) );
|
| 3537 |
exit;
|
| 3538 |
}
|
| 3539 |
|
| 3540 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3541 |
$noncekey = 'post_member' . $this->get_uscesid( false );
|
| 3542 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) && ! $this->is_member_logged_in() ) {
|
| 3543 |
die( 'Security check2' );
|
| 3544 |
}
|
| 3545 |
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
|
| 3546 |
if ( $check_verify_recaptcha ) {
|
| 3547 |
$this->cart->entry();
|
| 3548 |
if ( empty( $_POST['member_regmode'] ) || 'editmemberfromcart' != $_POST['member_regmode'] ) {
|
| 3549 |
$_POST['member_regmode'] = 'newmemberfromcart';
|
| 3550 |
}
|
| 3551 |
$res = $this->regist_member();
|
| 3552 |
} else {
|
| 3553 |
// return back page register and show message.
|
| 3554 |
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'reganddeliveryinfo' );
|
| 3555 |
$res = trim( $_POST['member_regmode'] );
|
| 3556 |
}
|
| 3557 |
|
| 3558 |
if ( 'newcompletion' == $res ) {
|
| 3559 |
$this->page = 'delivery';
|
| 3560 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3561 |
} elseif ( 'cartverifying' == $res ) {
|
| 3562 |
$this->page = 'cartverifying';
|
| 3563 |
} else {
|
| 3564 |
$this->page = 'customer';
|
| 3565 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3566 |
}
|
| 3567 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3568 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3569 |
}
|
| 3570 |
|
| 3571 |
public function deliveryinfo() {
|
| 3572 |
global $wp_query;
|
| 3573 |
if ( false === $this->cart->num_row() ) {
|
| 3574 |
header( 'location: ' . get_option( 'home' ) );
|
| 3575 |
exit;
|
| 3576 |
}
|
| 3577 |
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
|
| 3578 |
if ( $check_verify_recaptcha ) {
|
| 3579 |
// continue process.
|
| 3580 |
$this->cart->entry();
|
| 3581 |
$this->error_message = $this->customer_check();
|
| 3582 |
} else {
|
| 3583 |
// return back page register and show message.
|
| 3584 |
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'deliveryinfo' );
|
| 3585 |
}
|
| 3586 |
|
| 3587 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 3588 |
$this->page = 'delivery';
|
| 3589 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3590 |
} else {
|
| 3591 |
$this->page = 'customer';
|
| 3592 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' );
|
| 3593 |
}
|
| 3594 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3595 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3596 |
}
|
| 3597 |
|
| 3598 |
public function backDelivery() {
|
| 3599 |
global $wp_query;
|
| 3600 |
if ( false === $this->cart->num_row() ) {
|
| 3601 |
header( 'location: ' . get_option( 'home' ) );
|
| 3602 |
exit;
|
| 3603 |
}
|
| 3604 |
$this->page = 'delivery';
|
| 3605 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3606 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3607 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3608 |
}
|
| 3609 |
|
| 3610 |
public function confirm() {
|
| 3611 |
global $wpdb, $wp_query;
|
| 3612 |
if ( false === $this->cart->num_row() ) {
|
| 3613 |
header( 'location: ' . get_option( 'home' ) );
|
| 3614 |
exit;
|
| 3615 |
}
|
| 3616 |
|
| 3617 |
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
|
| 3618 |
if ( $check_verify_recaptcha ) {
|
| 3619 |
// continue process.
|
| 3620 |
$this->cart->entry();
|
| 3621 |
$this->error_message = $this->zaiko_check();
|
| 3622 |
} else {
|
| 3623 |
// return back page register and show message.
|
| 3624 |
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'confirm' );
|
| 3625 |
}
|
| 3626 |
|
| 3627 |
if ( '' != $this->error_message ) {
|
| 3628 |
$this->page = 'cart';
|
| 3629 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3630 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3631 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3632 |
return;
|
| 3633 |
}
|
| 3634 |
/*
|
| 3635 |
$referrer = wp_get_referer();
|
| 3636 |
$site_url = parse_url( home_url(), PHP_URL_HOST );
|
| 3637 |
$referrer_host = parse_url( $referrer, PHP_URL_HOST );
|
| 3638 |
if ( false === $referrer || $referrer_host !== $site_url ) {
|
| 3639 |
$this->page = 'cart';
|
| 3640 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3641 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3642 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3643 |
return;
|
| 3644 |
}
|
| 3645 |
*/
|
| 3646 |
$this->set_reserve_pre_order_id();
|
| 3647 |
if ( isset( $_POST['confirm'] ) ) {
|
| 3648 |
$this->error_message = $this->delivery_check();
|
| 3649 |
}
|
| 3650 |
$this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'confirm' : 'delivery';
|
| 3651 |
if ( WCUtils::is_blank( $this->error_message ) ) {
|
| 3652 |
if ( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) {
|
| 3653 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 3654 |
$query = $wpdb->prepare( "SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID'] );
|
| 3655 |
$mem_point = $wpdb->get_var( $query );
|
| 3656 |
$_SESSION['usces_member']['point'] = $mem_point;
|
| 3657 |
}
|
| 3658 |
$this->page = 'confirm';
|
| 3659 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
|
| 3660 |
} else {
|
| 3661 |
$this->page = apply_filters( 'usces_filter_delivery_check_error_page', 'delivery', $this->error_message );
|
| 3662 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' );
|
| 3663 |
}
|
| 3664 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3665 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3666 |
}
|
| 3667 |
|
| 3668 |
public function use_point() {
|
| 3669 |
global $wp_query, $usces;
|
| 3670 |
$noncekey = 'use_point' . $usces->get_uscesid( false );
|
| 3671 |
|
| 3672 |
if ( ! isset( $_REQUEST['wc_nonce'] ) || ! wp_verify_nonce( $_REQUEST['wc_nonce'], $noncekey ) ) {
|
| 3673 |
die( 'Security check1' );
|
| 3674 |
}
|
| 3675 |
|
| 3676 |
$this->error_message = $this->point_check( $this->cart->get_entry() );
|
| 3677 |
if ( empty( $this->error_message ) ) {
|
| 3678 |
$this->cart->entry();
|
| 3679 |
}
|
| 3680 |
$this->page = 'confirm';
|
| 3681 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
|
| 3682 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3683 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3684 |
}
|
| 3685 |
|
| 3686 |
public function backConfirm() {
|
| 3687 |
global $wp_query;
|
| 3688 |
if ( false === $this->cart->num_row() ) {
|
| 3689 |
header( 'location: ' . get_option( 'home' ) );
|
| 3690 |
exit;
|
| 3691 |
}
|
| 3692 |
$this->page = 'confirm';
|
| 3693 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' );
|
| 3694 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3695 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3696 |
}
|
| 3697 |
|
| 3698 |
/**
|
| 3699 |
* Purchase
|
| 3700 |
*/
|
| 3701 |
public function purchase() {
|
| 3702 |
global $wp_query;
|
| 3703 |
do_action( 'usces_pre_purchase' );
|
| 3704 |
if ( false === $this->cart->num_row() ) {
|
| 3705 |
header( 'location: ' . get_option( 'home' ) );
|
| 3706 |
exit;
|
| 3707 |
}
|
| 3708 |
|
| 3709 |
if ( isset( $_POST['wc_purchase_nonce'] ) ) {
|
| 3710 |
if ( ! wp_verify_nonce( $_POST['wc_purchase_nonce'], 'wc_purchase_nonce' ) ) {
|
| 3711 |
$this->error_message = __( 'Security check failed. Please try again.', 'usces' );
|
| 3712 |
$this->page = 'confirm';
|
| 3713 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3714 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3715 |
return;
|
| 3716 |
}
|
| 3717 |
}
|
| 3718 |
|
| 3719 |
if ( ! apply_filters( 'usces_purchase_check', true ) ) {
|
| 3720 |
return;
|
| 3721 |
}
|
| 3722 |
|
| 3723 |
do_action( 'usces_purchase_validate' );
|
| 3724 |
|
| 3725 |
$entry = $this->cart->get_entry();
|
| 3726 |
$this->error_message = $this->zaiko_check();
|
| 3727 |
if ( WCUtils::is_blank( $this->error_message ) && 0 < $this->cart->num_row() ) {
|
| 3728 |
$acting_status = '';
|
| 3729 |
$payments = $this->getPayments( $entry['order']['payment_name'] );
|
| 3730 |
if ( null === $payments['id'] && 0 < $entry['order']['total_full_price'] ) {
|
| 3731 |
header( 'HTTP/1.0 400 Bad request' );
|
| 3732 |
die();
|
| 3733 |
}
|
| 3734 |
$payment_settlement = $payments['settlement'] ?? '';
|
| 3735 |
if ( substr( $payment_settlement, 0, 6 ) == 'acting' && $entry['order']['total_full_price'] > 0 ) {
|
| 3736 |
$acting_flg = ( 'acting' == $payment_settlement ) ? $payments['module'] : $payment_settlement;
|
| 3737 |
unset( $_POST['purchase'] );
|
| 3738 |
$post_query = '&' . http_build_query( $_POST );
|
| 3739 |
$acting_status = $this->acting_processing( $acting_flg, $post_query, $acting_status );
|
| 3740 |
}
|
| 3741 |
|
| 3742 |
if ( 'error' == $acting_status ) {
|
| 3743 |
$this->page = 'error';
|
| 3744 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
|
| 3745 |
} else {
|
| 3746 |
$res = $this->order_processing();
|
| 3747 |
if ( 'ordercompletion' == $res ) {
|
| 3748 |
$this->page = 'ordercompletion';
|
| 3749 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
|
| 3750 |
} else {
|
| 3751 |
$this->page = 'error';
|
| 3752 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
|
| 3753 |
}
|
| 3754 |
}
|
| 3755 |
} else {
|
| 3756 |
$this->page = 'cart';
|
| 3757 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' );
|
| 3758 |
if ( ! $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 3759 |
wp_redirect( USCES_CART_URL );
|
| 3760 |
exit;
|
| 3761 |
}
|
| 3762 |
}
|
| 3763 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3764 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3765 |
}
|
| 3766 |
|
| 3767 |
public function acting_return() {
|
| 3768 |
global $wp_query;
|
| 3769 |
|
| 3770 |
do_action( 'usces_pre_acting_return' );
|
| 3771 |
|
| 3772 |
$entry = $this->cart->get_entry();
|
| 3773 |
if ( isset( $_GET['acting'] ) && 'anotherlane_card' != $_GET['acting'] ) {
|
| 3774 |
if ( false === $this->cart->num_row() && ( 'paypal' != $_GET['acting'] && 1 !== (int) $_GET['acting_return'] ) ) {
|
| 3775 |
header( 'location: ' . get_option( 'home' ) );
|
| 3776 |
exit;
|
| 3777 |
}
|
| 3778 |
}
|
| 3779 |
|
| 3780 |
$this->payment_results = usces_check_acting_return();
|
| 3781 |
|
| 3782 |
if ( isset( $this->payment_results[0] ) && 'duplicate' === $this->payment_results[0] ) {
|
| 3783 |
|
| 3784 |
header( 'location: ' . get_option( 'home' ) );
|
| 3785 |
exit;
|
| 3786 |
|
| 3787 |
} elseif ( isset( $this->payment_results[0] ) && $this->payment_results[0] ) { // result OK.
|
| 3788 |
|
| 3789 |
if ( ! $this->payment_results['reg_order'] ) { // without Registration Order.
|
| 3790 |
$this->page = 'ordercompletion';
|
| 3791 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
|
| 3792 |
|
| 3793 |
} else {
|
| 3794 |
$res = $this->order_processing( $this->payment_results );
|
| 3795 |
|
| 3796 |
if ( 'ordercompletion' == $res ) {
|
| 3797 |
$this->page = 'ordercompletion';
|
| 3798 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' );
|
| 3799 |
} else {
|
| 3800 |
$this->page = 'error';
|
| 3801 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
|
| 3802 |
}
|
| 3803 |
}
|
| 3804 |
|
| 3805 |
} else { // result NG.
|
| 3806 |
$this->page = 'error';
|
| 3807 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' );
|
| 3808 |
}
|
| 3809 |
|
| 3810 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 3811 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3812 |
}
|
| 3813 |
|
| 3814 |
public function settlement_epsilon() {
|
| 3815 |
global $wp_query;
|
| 3816 |
require_once $this->options['settlement_path'] . 'epsilon.php';
|
| 3817 |
}
|
| 3818 |
|
| 3819 |
public function inquiry_button() {
|
| 3820 |
if ( ( isset( $_POST['kakuninyou'] ) && empty( $_POST['kakuninyou'] ) ) && isset( $_POST['inq_name'] ) && ! WCUtils::is_blank( $_POST['inq_name'] ) && isset( $_POST['inq_mailaddress'] ) && is_email( trim( $_POST['inq_mailaddress'] ) ) && ! WCUtils::is_blank( $_POST['inq_contents'] ) ) {
|
| 3821 |
$res = $this->inquiry_processing();
|
| 3822 |
} else {
|
| 3823 |
$res = 'deficiency';
|
| 3824 |
}
|
| 3825 |
|
| 3826 |
$this->page = $res;
|
| 3827 |
}
|
| 3828 |
|
| 3829 |
public function member_login_page() {
|
| 3830 |
global $wp_query;
|
| 3831 |
if ( ! class_exists( 'RateLimiter' ) ) {
|
| 3832 |
require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php';
|
| 3833 |
}
|
| 3834 |
$rateLimiter = new RateLimiter();
|
| 3835 |
if ( $rateLimiter->checkBlockIP() ) {
|
| 3836 |
$wp_query->set_403();
|
| 3837 |
status_header( 403 );
|
| 3838 |
exit();
|
| 3839 |
}
|
| 3840 |
|
| 3841 |
if ( isset( $_GET['redirect_to'] ) ) {
|
| 3842 |
$_SESSION['redirect_to'] = $_GET['redirect_to'];
|
| 3843 |
}
|
| 3844 |
|
| 3845 |
$res = $this->member_login();
|
| 3846 |
if ( 'member' == $res ) {
|
| 3847 |
$this->page = 'member';
|
| 3848 |
do_action( 'usces_action_member_logined' );
|
| 3849 |
|
| 3850 |
if ( isset( $_SESSION['redirect_to'] ) ) {
|
| 3851 |
if ( wp_safe_redirect( esc_url( $_SESSION['redirect_to'] ) ) ) {
|
| 3852 |
unset( $_SESSION['redirect_to'] );
|
| 3853 |
exit;
|
| 3854 |
}
|
| 3855 |
}
|
| 3856 |
|
| 3857 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_member' );
|
| 3858 |
} elseif ( 'login' == $res ) {
|
| 3859 |
$this->page = 'login';
|
| 3860 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_login' );
|
| 3861 |
}
|
| 3862 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3863 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3864 |
}
|
| 3865 |
|
| 3866 |
public function regmember() {
|
| 3867 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3868 |
$noncekey = 'post_member' . $this->get_uscesid( false );
|
| 3869 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
|
| 3870 |
die( 'Security check2' );
|
| 3871 |
}
|
| 3872 |
|
| 3873 |
$check_verify_recaptcha = $this->verifyGoogleRecapcha();
|
| 3874 |
if ( $check_verify_recaptcha ) {
|
| 3875 |
// continue register form.
|
| 3876 |
global $wp_query;
|
| 3877 |
$res = $this->regist_member();
|
| 3878 |
} else {
|
| 3879 |
// return back page register and show message.
|
| 3880 |
$this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'regmember' );
|
| 3881 |
$res = trim( $_POST['member_regmode'] );
|
| 3882 |
}
|
| 3883 |
|
| 3884 |
if ( 'editmemberform' == $res ) {
|
| 3885 |
$this->page = 'editmemberform';
|
| 3886 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' );
|
| 3887 |
} elseif ( 'newcompletion' == $res ) {
|
| 3888 |
$this->page = 'newcompletion';
|
| 3889 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' );
|
| 3890 |
} else {
|
| 3891 |
$this->page = $res;
|
| 3892 |
}
|
| 3893 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3894 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3895 |
}
|
| 3896 |
|
| 3897 |
public function editmember() {
|
| 3898 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3899 |
$noncekey = 'post_member' . $this->get_uscesid( false );
|
| 3900 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
|
| 3901 |
die( 'Security check3' );
|
| 3902 |
}
|
| 3903 |
|
| 3904 |
global $wp_query;
|
| 3905 |
$res = $this->regist_member();
|
| 3906 |
if ( 'editmemberform' == $res ) {
|
| 3907 |
$this->page = 'editmemberform';
|
| 3908 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' );
|
| 3909 |
} elseif ( 'newcompletion' == $res ) {
|
| 3910 |
$this->page = 'newcompletion';
|
| 3911 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' );
|
| 3912 |
} elseif ( 'updatememberform' == $res ) {
|
| 3913 |
$this->page = 'member_edit';
|
| 3914 |
} else {
|
| 3915 |
$this->page = $res;
|
| 3916 |
}
|
| 3917 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3918 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3919 |
}
|
| 3920 |
|
| 3921 |
public function deletemember() {
|
| 3922 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3923 |
$noncekey = 'post_member' . $this->get_uscesid( false );
|
| 3924 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
|
| 3925 |
die( 'Security check4' );
|
| 3926 |
}
|
| 3927 |
|
| 3928 |
$res = $this->delete_member();
|
| 3929 |
if ( $res ) {
|
| 3930 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember' );
|
| 3931 |
$this->member_logout();
|
| 3932 |
} else {
|
| 3933 |
$this->page = 'editmemberform';
|
| 3934 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3935 |
}
|
| 3936 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3937 |
}
|
| 3938 |
|
| 3939 |
public function page_logout() {
|
| 3940 |
global $wp_query;
|
| 3941 |
$this->member_logout();
|
| 3942 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3943 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3944 |
}
|
| 3945 |
|
| 3946 |
public function page_lostmemberpassword() {
|
| 3947 |
global $wp_query;
|
| 3948 |
$this->page = 'lostmemberpassword';
|
| 3949 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3950 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3951 |
}
|
| 3952 |
|
| 3953 |
public function lostpassword() {
|
| 3954 |
global $usces, $wp_query;
|
| 3955 |
|
| 3956 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3957 |
$noncekey = 'post_member' . $usces->get_uscesid( false );
|
| 3958 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
|
| 3959 |
$wp_query->set_403();
|
| 3960 |
status_header( 403 );
|
| 3961 |
exit();
|
| 3962 |
}
|
| 3963 |
|
| 3964 |
$this->error_message = $this->lostpass_mailaddcheck();
|
| 3965 |
if ( '' != $this->error_message ) {
|
| 3966 |
$this->page = 'lostmemberpassword';
|
| 3967 |
} else {
|
| 3968 |
$res = $this->lostmail();
|
| 3969 |
$this->page = $res; // 'lostcompletion';.
|
| 3970 |
}
|
| 3971 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3972 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3973 |
}
|
| 3974 |
|
| 3975 |
public function uscesmode_changepassword() {
|
| 3976 |
global $wp_query;
|
| 3977 |
|
| 3978 |
if ( ! isset( $_REQUEST['mem'] ) || ! isset( $_REQUEST['key'] ) ) {
|
| 3979 |
die( 'Invalid request 1' );
|
| 3980 |
}
|
| 3981 |
|
| 3982 |
$mem_mail = $_REQUEST['mem'];
|
| 3983 |
$lostkey = $_REQUEST['key'];
|
| 3984 |
$res = usces_check_lostkey( $mem_mail, $lostkey );
|
| 3985 |
if ( empty( $res ) ) {
|
| 3986 |
die( 'Invalid request 2' );
|
| 3987 |
}
|
| 3988 |
|
| 3989 |
$this->page = 'changepassword';
|
| 3990 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 3991 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 3992 |
}
|
| 3993 |
|
| 3994 |
public function changepassword_page() {
|
| 3995 |
global $usces;
|
| 3996 |
|
| 3997 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 3998 |
$noncekey = 'post_member' . $usces->get_uscesid( false );
|
| 3999 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) ) {
|
| 4000 |
die( 'Security check6' );
|
| 4001 |
}
|
| 4002 |
|
| 4003 |
$lostmail = $_POST['mem'];
|
| 4004 |
$lostkey = $_POST['key'];
|
| 4005 |
$res = usces_check_lostkey( $lostmail, $lostkey );
|
| 4006 |
if ( empty( $res ) ) {
|
| 4007 |
die( 'Invalid request 7' );
|
| 4008 |
}
|
| 4009 |
|
| 4010 |
global $wp_query;
|
| 4011 |
$this->error_message = $this->changepass_check();
|
| 4012 |
if ( '' != $this->error_message ) {
|
| 4013 |
$this->page = 'changepassword';
|
| 4014 |
} else {
|
| 4015 |
$res = $this->changepassword();
|
| 4016 |
$this->page = $res; // 'changepasscompletion';.
|
| 4017 |
}
|
| 4018 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 4019 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 4020 |
}
|
| 4021 |
|
| 4022 |
public function page_newmember() {
|
| 4023 |
global $wp_query;
|
| 4024 |
$this->page = 'newmemberform';
|
| 4025 |
add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform' );
|
| 4026 |
add_action( 'the_post', array( $this, 'action_memberFilter' ) );
|
| 4027 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 4028 |
}
|
| 4029 |
|
| 4030 |
public function page_search_item() {
|
| 4031 |
global $wp_query;
|
| 4032 |
$this->page = 'search_item';
|
| 4033 |
add_action( 'the_post', array( $this, 'action_cartFilter' ) );
|
| 4034 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 4035 |
}
|
| 4036 |
|
| 4037 |
public function default_page() {
|
| 4038 |
global $wp_query;
|
| 4039 |
add_action( 'the_post', array( $this, 'goDefaultPage' ) );
|
| 4040 |
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
| 4041 |
}
|
| 4042 |
|
| 4043 |
public function verifyGoogleRecapcha() {
|
| 4044 |
// check google re-captcha v3.
|
| 4045 |
$option = get_option( 'usces_ex' );
|
| 4046 |
$is_human = true;
|
| 4047 |
if ( isset( $option['system']['google_recaptcha']['status'] ) && $option['system']['google_recaptcha']['status'] && ! ( empty( $option['system']['google_recaptcha']['site_key'] ) ) && ! ( empty( $option['system']['google_recaptcha']['secret_key'] ) ) ) {
|
| 4048 |
if ( isset( $_POST['recaptcha_response'] ) ) {
|
| 4049 |
$secret = isset( $option['system']['google_recaptcha']['secret_key'] ) ? $option['system']['google_recaptcha']['secret_key'] : '';
|
| 4050 |
$token = trim( $_POST['recaptcha_response'] );
|
| 4051 |
$is_human = $this->google_recaptcha_v3_response( $token, $secret );
|
| 4052 |
}
|
| 4053 |
}
|
| 4054 |
return $is_human;
|
| 4055 |
}
|
| 4056 |
|
| 4057 |
/**
|
| 4058 |
* Handle check google recaptcha v3 response.
|
| 4059 |
*
|
| 4060 |
* @param string $token string token.
|
| 4061 |
* @param string $secret string secret key config.
|
| 4062 |
*
|
| 4063 |
* @return boolean $is_human.
|
| 4064 |
*/
|
| 4065 |
public function google_recaptcha_v3_response( $token, $secret ) {
|
| 4066 |
$is_human = true;
|
| 4067 |
if ( empty( $token ) || empty( $secret ) ) {
|
| 4068 |
return $is_human;
|
| 4069 |
}
|
| 4070 |
$option = get_option( 'usces_ex' );
|
| 4071 |
$threshold = isset( $option['system']['google_recaptcha']['score'] ) ? $option['system']['google_recaptcha']['score'] : 0.5;
|
| 4072 |
|
| 4073 |
$endpoint = 'https://www.google.com/recaptcha/api/siteverify';
|
| 4074 |
$request = array(
|
| 4075 |
'body' => array(
|
| 4076 |
'secret' => $secret,
|
| 4077 |
'response' => $token,
|
| 4078 |
),
|
| 4079 |
);
|
| 4080 |
|
| 4081 |
$response = wp_remote_post( esc_url_raw( $endpoint ), $request );
|
| 4082 |
|
| 4083 |
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
| 4084 |
update_option( 'usces_recaptcha_condition', 'response_NG' );
|
| 4085 |
return $is_human;
|
| 4086 |
} else {
|
| 4087 |
update_option( 'usces_recaptcha_condition', 'response_OK' );
|
| 4088 |
}
|
| 4089 |
|
| 4090 |
$response_body = wp_remote_retrieve_body( $response );
|
| 4091 |
$response_body = json_decode( $response_body, true );
|
| 4092 |
|
| 4093 |
$action = isset( $response_body['action'] ) ? $response_body['action'] : '';
|
| 4094 |
$actions = array(
|
| 4095 |
'create_new_member',
|
| 4096 |
'customer_order_page',
|
| 4097 |
'delivery_order_page',
|
| 4098 |
'member_register_settlement',
|
| 4099 |
'member_update_settlement',
|
| 4100 |
);
|
| 4101 |
if ( ! $response_body['success'] || ! in_array( $action, $actions ) ) {
|
| 4102 |
update_option( 'usces_recaptcha_condition', 'response_ERROR' );
|
| 4103 |
return $is_human;
|
| 4104 |
} else {
|
| 4105 |
update_option( 'usces_recaptcha_condition', 'response_OK' );
|
| 4106 |
}
|
| 4107 |
$score = isset( $response_body['score'] ) ? $response_body['score'] : 0;
|
| 4108 |
$is_human = $threshold <= $score;
|
| 4109 |
return $is_human;
|
| 4110 |
}
|
| 4111 |
|
| 4112 |
public function goDefaultPage() {
|
| 4113 |
global $post;
|
| 4114 |
|
| 4115 |
if ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_CART_NUMBER ) {
|
| 4116 |
|
| 4117 |
$this->page = 'cart';
|
| 4118 |
add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 );
|
| 4119 |
|
| 4120 |
} elseif ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_MEMBER_NUMBER ) {
|
| 4121 |
|
| 4122 |
$this->page = 'member';
|
| 4123 |
|
| 4124 |
if ( $this->is_member_logged_in() ) {
|
| 4125 |
$this->get_current_member();
|
| 4126 |
$this->set_member_session_data( $this->current_member['id'] );
|
| 4127 |
$this->page = 'member';
|
| 4128 |
} else {
|
| 4129 |
$this->page = 'login';
|
| 4130 |
}
|
| 4131 |
add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 );
|
| 4132 |
add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 );
|
| 4133 |
|
| 4134 |
} elseif ( ! is_singular() ) {
|
| 4135 |
$this->page = 'wp_search';
|
| 4136 |
add_filter( 'the_excerpt', array( $this, 'filter_cartContent' ), 20 );
|
| 4137 |
add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 );
|
| 4138 |
|
| 4139 |
} else {
|
| 4140 |
add_filter( 'the_content', array( &$this, 'filter_itemPage' ) );
|
| 4141 |
}
|
| 4142 |
}
|
| 4143 |
|
| 4144 |
public function template_redirect() {
|
| 4145 |
global $wpdb, $wp_version, $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode;
|
| 4146 |
|
| 4147 |
if ( version_compare( $wp_version, '4.4-beta', '>' ) && is_embed() ) {
|
| 4148 |
return;
|
| 4149 |
}
|
| 4150 |
|
| 4151 |
if ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 4152 |
if ( '' == $this->page && empty( $this->error_message ) ) {
|
| 4153 |
$this->error_message = $this->zaiko_check();
|
| 4154 |
if ( $this->error_message ) {
|
| 4155 |
$this->page = 'cart';
|
| 4156 |
}
|
| 4157 |
}
|
| 4158 |
}
|
| 4159 |
|
| 4160 |
if ( apply_filters( 'usces_action_template_redirect', false ) ) {
|
| 4161 |
return; // Deprecated.
|
| 4162 |
}
|
| 4163 |
if ( apply_filters( 'usces_filter_template_redirect', false ) ) {
|
| 4164 |
return;
|
| 4165 |
}
|
| 4166 |
|
| 4167 |
$parent_path = get_template_directory() . '/wc_templates';
|
| 4168 |
$child_path = get_stylesheet_directory() . '/wc_templates';
|
| 4169 |
|
| 4170 |
if ( is_single() && is_object( $post ) && 'item' === $post->post_mime_type ) {
|
| 4171 |
|
| 4172 |
if ( file_exists( $child_path . '/wc_item_single.php' ) ) {
|
| 4173 |
if ( ! post_password_required( $post ) ) {
|
| 4174 |
include $child_path . '/wc_item_single.php';
|
| 4175 |
exit;
|
| 4176 |
}
|
| 4177 |
} elseif ( file_exists( $parent_path . '/wc_item_single.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4178 |
if ( ! post_password_required( $post ) ) {
|
| 4179 |
include $parent_path . '/wc_item_single.php';
|
| 4180 |
exit;
|
| 4181 |
}
|
| 4182 |
}
|
| 4183 |
|
| 4184 |
} elseif ( isset( $_REQUEST['usces_page'] ) && ( 'search_item' == $_REQUEST['usces_page'] || 'usces_search' == $_REQUEST['usces_page'] ) && $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 4185 |
|
| 4186 |
if ( file_exists( $child_path . '/wc_search_page.php' ) ) {
|
| 4187 |
include $child_path . '/wc_search_page.php';
|
| 4188 |
exit;
|
| 4189 |
} elseif ( file_exists( $parent_path . '/wc_search_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4190 |
include $parent_path . '/wc_search_page.php';
|
| 4191 |
exit;
|
| 4192 |
}
|
| 4193 |
|
| 4194 |
} elseif ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 4195 |
|
| 4196 |
switch ( $this->page ) {
|
| 4197 |
|
| 4198 |
case 'customer':
|
| 4199 |
if ( file_exists( $child_path . '/cart/wc_customer_page.php' ) ) {
|
| 4200 |
usces_get_entries();
|
| 4201 |
usces_get_member_regmode();
|
| 4202 |
include $child_path . '/cart/wc_customer_page.php';
|
| 4203 |
exit;
|
| 4204 |
} elseif ( file_exists( $parent_path . '/cart/wc_customer_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4205 |
usces_get_entries();
|
| 4206 |
usces_get_member_regmode();
|
| 4207 |
include $parent_path . '/cart/wc_customer_page.php';
|
| 4208 |
exit;
|
| 4209 |
}
|
| 4210 |
break;
|
| 4211 |
|
| 4212 |
case 'delivery':
|
| 4213 |
if ( file_exists( $child_path . '/cart/wc_delivery_page.php' ) ) {
|
| 4214 |
usces_get_entries();
|
| 4215 |
usces_get_carts();
|
| 4216 |
include $child_path . '/cart/wc_delivery_page.php';
|
| 4217 |
exit;
|
| 4218 |
} elseif ( file_exists( $parent_path . '/cart/wc_delivery_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4219 |
usces_get_entries();
|
| 4220 |
usces_get_carts();
|
| 4221 |
include $parent_path . '/cart/wc_delivery_page.php';
|
| 4222 |
exit;
|
| 4223 |
}
|
| 4224 |
break;
|
| 4225 |
|
| 4226 |
case 'confirm':
|
| 4227 |
if ( file_exists( $child_path . '/cart/wc_confirm_page.php' ) ) {
|
| 4228 |
usces_get_entries();
|
| 4229 |
usces_get_carts();
|
| 4230 |
usces_get_members();
|
| 4231 |
include $child_path . '/cart/wc_confirm_page.php';
|
| 4232 |
exit;
|
| 4233 |
} elseif ( file_exists( $parent_path . '/cart/wc_confirm_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4234 |
usces_get_entries();
|
| 4235 |
usces_get_carts();
|
| 4236 |
usces_get_members();
|
| 4237 |
include $parent_path . '/cart/wc_confirm_page.php';
|
| 4238 |
exit;
|
| 4239 |
}
|
| 4240 |
break;
|
| 4241 |
|
| 4242 |
case 'ordercompletion':
|
| 4243 |
if ( file_exists( $child_path . '/cart/wc_completion_page.php' ) ) {
|
| 4244 |
usces_get_entries();
|
| 4245 |
usces_get_carts();
|
| 4246 |
include $child_path . '/cart/wc_completion_page.php';
|
| 4247 |
exit;
|
| 4248 |
} elseif ( file_exists( $parent_path . '/cart/wc_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4249 |
usces_get_entries();
|
| 4250 |
usces_get_carts();
|
| 4251 |
include $parent_path . '/cart/wc_completion_page.php';
|
| 4252 |
exit;
|
| 4253 |
}
|
| 4254 |
break;
|
| 4255 |
|
| 4256 |
case 'error':
|
| 4257 |
if ( file_exists( $child_path . '/cart/wc_cart_error_page.php' ) ) {
|
| 4258 |
include $child_path . '/cart/wc_cart_error_page.php';
|
| 4259 |
exit;
|
| 4260 |
} elseif ( file_exists( $parent_path . '/cart/wc_cart_error_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4261 |
include $parent_path . '/cart/wc_cart_error_page.php';
|
| 4262 |
exit;
|
| 4263 |
}
|
| 4264 |
break;
|
| 4265 |
|
| 4266 |
case 'cart':
|
| 4267 |
default:
|
| 4268 |
$this->page = 'cart';
|
| 4269 |
if ( file_exists( $child_path . '/cart/wc_cart_page.php' ) ) {
|
| 4270 |
include $child_path . '/cart/wc_cart_page.php';
|
| 4271 |
exit;
|
| 4272 |
} elseif ( file_exists( $parent_path . '/cart/wc_cart_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4273 |
include $parent_path . '/cart/wc_cart_page.php';
|
| 4274 |
exit;
|
| 4275 |
}
|
| 4276 |
}
|
| 4277 |
|
| 4278 |
} elseif ( $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 4279 |
|
| 4280 |
} elseif ( $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 4281 |
if ( 'activate' != $this->options['membersystem_state'] ) {
|
| 4282 |
return;
|
| 4283 |
}
|
| 4284 |
|
| 4285 |
if ( $this->is_member_logged_in() ) {
|
| 4286 |
|
| 4287 |
if ( isset( $_SESSION['usces_member'] ) ) {
|
| 4288 |
$member_table_name = usces_get_tablename( 'usces_member' );
|
| 4289 |
$this->get_current_member();
|
| 4290 |
$query = $wpdb->prepare( "SELECT mem_point FROM $member_table_name WHERE ID = %d", $this->current_member['id'] );
|
| 4291 |
$point = $wpdb->get_var( $query );
|
| 4292 |
$_SESSION['usces_member']['point'] = $point;
|
| 4293 |
}
|
| 4294 |
|
| 4295 |
$member_regmode = 'editmemberform';
|
| 4296 |
if ( file_exists( $child_path . '/member/wc_member_page.php' ) ) {
|
| 4297 |
include $child_path . '/member/wc_member_page.php';
|
| 4298 |
exit;
|
| 4299 |
} elseif ( file_exists( $parent_path . '/member/wc_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4300 |
include $parent_path . '/member/wc_member_page.php';
|
| 4301 |
exit;
|
| 4302 |
}
|
| 4303 |
|
| 4304 |
} else {
|
| 4305 |
|
| 4306 |
switch ( $this->page ) {
|
| 4307 |
|
| 4308 |
case 'login':
|
| 4309 |
if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) {
|
| 4310 |
include $child_path . '/member/wc_login_page.php';
|
| 4311 |
exit;
|
| 4312 |
} elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4313 |
include $parent_path . '/member/wc_login_page.php';
|
| 4314 |
exit;
|
| 4315 |
}
|
| 4316 |
break;
|
| 4317 |
|
| 4318 |
case 'newmemberform':
|
| 4319 |
if ( file_exists( $child_path . '/member/wc_new_member_page.php' ) ) {
|
| 4320 |
$member_regmode = 'newmemberform';
|
| 4321 |
include $child_path . '/member/wc_new_member_page.php';
|
| 4322 |
exit;
|
| 4323 |
} elseif ( file_exists( $parent_path . '/member/wc_new_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4324 |
$member_regmode = 'newmemberform';
|
| 4325 |
include $parent_path . '/member/wc_new_member_page.php';
|
| 4326 |
exit;
|
| 4327 |
}
|
| 4328 |
break;
|
| 4329 |
|
| 4330 |
case 'lostmemberpassword':
|
| 4331 |
if ( file_exists( $child_path . '/member/wc_lostpassword_page.php' ) ) {
|
| 4332 |
include $child_path . '/member/wc_lostpassword_page.php';
|
| 4333 |
exit;
|
| 4334 |
} elseif ( file_exists( $parent_path . '/member/wc_lostpassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4335 |
include $parent_path . '/member/wc_lostpassword_page.php';
|
| 4336 |
exit;
|
| 4337 |
}
|
| 4338 |
break;
|
| 4339 |
|
| 4340 |
case 'changepassword':
|
| 4341 |
if ( file_exists( $child_path . '/member/wc_changepassword_page.php' ) ) {
|
| 4342 |
include $child_path . '/member/wc_changepassword_page.php';
|
| 4343 |
exit;
|
| 4344 |
} elseif ( file_exists( $parent_path . '/member/wc_changepassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4345 |
include $parent_path . '/member/wc_changepassword_page.php';
|
| 4346 |
exit;
|
| 4347 |
}
|
| 4348 |
break;
|
| 4349 |
|
| 4350 |
case 'newcompletion':
|
| 4351 |
case 'editcompletion':
|
| 4352 |
case 'lostcompletion':
|
| 4353 |
case 'changepasscompletion':
|
| 4354 |
if ( file_exists( $child_path . '/member/wc_member_completion_page.php' ) ) {
|
| 4355 |
include $child_path . '/member/wc_member_completion_page.php';
|
| 4356 |
exit;
|
| 4357 |
} elseif ( file_exists( $parent_path . '/member/wc_member_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4358 |
include $parent_path . '/member/wc_member_completion_page.php';
|
| 4359 |
exit;
|
| 4360 |
}
|
| 4361 |
break;
|
| 4362 |
|
| 4363 |
default:
|
| 4364 |
$this->page = 'login';
|
| 4365 |
if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) {
|
| 4366 |
include $child_path . '/member/wc_login_page.php';
|
| 4367 |
exit;
|
| 4368 |
} elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) {
|
| 4369 |
include $parent_path . '/member/wc_login_page.php';
|
| 4370 |
exit;
|
| 4371 |
}
|
| 4372 |
}
|
| 4373 |
}
|
| 4374 |
}
|
| 4375 |
}
|
| 4376 |
|
| 4377 |
public function changepassword() {
|
| 4378 |
global $wpdb;
|
| 4379 |
|
| 4380 |
$lostmail = $_POST['mem'];
|
| 4381 |
$lost_key = $_POST['key'];
|
| 4382 |
|
| 4383 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4384 |
// $hash = usces_get_hash(trim($_POST['loginpass1']));
|
| 4385 |
$salt = usces_get_salt( $lostmail );
|
| 4386 |
$hash = usces_get_hash( trim( $_POST['loginpass1'] ), $salt );
|
| 4387 |
$query = $wpdb->prepare( "UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s",
|
| 4388 |
$hash, $lostmail
|
| 4389 |
);
|
| 4390 |
$res = $wpdb->query( $query );
|
| 4391 |
|
| 4392 |
if ( $res === false ) {
|
| 4393 |
$this->error_message = __( 'Error: failure in updating password', 'usces' );
|
| 4394 |
return 'login';
|
| 4395 |
} else {
|
| 4396 |
usces_remove_lostmail_key( $lostmail, $lost_key );
|
| 4397 |
return 'changepasscompletion';
|
| 4398 |
}
|
| 4399 |
}
|
| 4400 |
|
| 4401 |
public function lostmail() {
|
| 4402 |
$delim = apply_filters( 'usces_filter_delim', $this->delim );
|
| 4403 |
|
| 4404 |
$lostmail = trim( $_POST['loginmail'] );
|
| 4405 |
if ( ! $this->is_member( $lostmail ) ) {
|
| 4406 |
return 'lostcompletion';
|
| 4407 |
}
|
| 4408 |
|
| 4409 |
$lost_key = usces_make_lost_key();
|
| 4410 |
usces_store_lostmail_key( $lostmail, $lost_key );
|
| 4411 |
|
| 4412 |
$uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword&mem=' . urlencode( $lostmail ) . '&key=' . urlencode( $lost_key );
|
| 4413 |
|
| 4414 |
$res = usces_lostmail( $uri );
|
| 4415 |
return $res;
|
| 4416 |
}
|
| 4417 |
|
| 4418 |
public function regist_member() {
|
| 4419 |
global $wpdb;
|
| 4420 |
|
| 4421 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 4422 |
|
| 4423 |
$member = $this->get_member();
|
| 4424 |
$mode = $_POST['member_regmode'];
|
| 4425 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4426 |
$member_meta_table = usces_get_tablename( 'usces_member_meta' );
|
| 4427 |
|
| 4428 |
$error_mes = ( 'newmemberfromcart' == $_POST['member_regmode'] || 'editmemberfromcart' == $_POST['member_regmode'] ) ? $this->member_check_fromcart() : $this->member_check();
|
| 4429 |
|
| 4430 |
if ( '' != $error_mes ) {
|
| 4431 |
|
| 4432 |
$this->error_message = $error_mes;
|
| 4433 |
return $mode;
|
| 4434 |
|
| 4435 |
} elseif ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) {
|
| 4436 |
|
| 4437 |
$this->get_current_member();
|
| 4438 |
$mem_id = $this->current_member['id'];
|
| 4439 |
|
| 4440 |
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1']));
|
| 4441 |
// $id = $wpdb->get_var( $query );
|
| 4442 |
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
| 4443 |
if ( ! empty( $id ) && $id != $mem_id ) {
|
| 4444 |
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
|
| 4445 |
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
|
| 4446 |
return $mode;
|
| 4447 |
}
|
| 4448 |
|
| 4449 |
do_action( 'usces_action_pre_edit_memberdata', $_POST['member'], $mem_id );
|
| 4450 |
|
| 4451 |
$query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id );
|
| 4452 |
$pass = $wpdb->get_var( $query );
|
| 4453 |
// $password = ( !empty( $_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? usces_get_hash(trim($_POST['member']['password1'])) : $pass;
|
| 4454 |
if ( ! empty( $_POST['member']['password1'] ) && trim( $_POST['member']['password1'] ) == trim( $_POST['member']['password2'] ) ) {
|
| 4455 |
$salt = usces_get_salt( $mem_id );
|
| 4456 |
$password = usces_get_hash( trim( $_POST['member']['password1'] ), $salt );
|
| 4457 |
} else {
|
| 4458 |
$password = $pass;
|
| 4459 |
}
|
| 4460 |
$name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : '';
|
| 4461 |
$name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : '';
|
| 4462 |
$name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : '';
|
| 4463 |
$name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : '';
|
| 4464 |
$zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : '';
|
| 4465 |
$pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : '';
|
| 4466 |
$address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : '';
|
| 4467 |
$address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : '';
|
| 4468 |
$address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : '';
|
| 4469 |
$tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : '';
|
| 4470 |
$fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : '';
|
| 4471 |
$country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : '';
|
| 4472 |
|
| 4473 |
$query = $wpdb->prepare(
|
| 4474 |
"UPDATE $member_table SET
|
| 4475 |
mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
|
| 4476 |
mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
|
| 4477 |
mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
|
| 4478 |
$password,
|
| 4479 |
$name1,
|
| 4480 |
$name2,
|
| 4481 |
$name3,
|
| 4482 |
$name4,
|
| 4483 |
$zipcode,
|
| 4484 |
$pref,
|
| 4485 |
$address1,
|
| 4486 |
$address2,
|
| 4487 |
$address3,
|
| 4488 |
$tel,
|
| 4489 |
$fax,
|
| 4490 |
trim( $_POST['member']['mailaddress1'] ),
|
| 4491 |
$mem_id
|
| 4492 |
);
|
| 4493 |
$res = $wpdb->query( $query );
|
| 4494 |
|
| 4495 |
if ( false !== $res ) {
|
| 4496 |
$this->set_member_meta_value( 'customer_country', $country, $mem_id );
|
| 4497 |
$res = $this->reg_custom_member( $mem_id );
|
| 4498 |
unset( $_SESSION['usces_entry']['custom_customer'] );
|
| 4499 |
$this->cart->entry();
|
| 4500 |
do_action( 'usces_action_edit_memberdata', $_POST['member'], $mem_id );
|
| 4501 |
$meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" );
|
| 4502 |
$query = $wpdb->prepare( "DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )",
|
| 4503 |
$mem_id
|
| 4504 |
);
|
| 4505 |
$res = $wpdb->query( $query );
|
| 4506 |
|
| 4507 |
$user = $_POST['member'];
|
| 4508 |
$user['ID'] = $mem_id;
|
| 4509 |
usces_send_updmembermail( $user );
|
| 4510 |
|
| 4511 |
$this->get_current_member();
|
| 4512 |
// return 'editmemberform';
|
| 4513 |
return $mode;
|
| 4514 |
|
| 4515 |
} else {
|
| 4516 |
$this->error_message = __( 'Error:failure in update', 'usces' );
|
| 4517 |
return $mode;
|
| 4518 |
}
|
| 4519 |
|
| 4520 |
} elseif ( 'newmemberform' == $_POST['member_regmode'] ) {
|
| 4521 |
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['member']['mailaddress1']));
|
| 4522 |
// $id = $wpdb->get_var( $query );
|
| 4523 |
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
| 4524 |
if ( ! empty( $id ) ) {
|
| 4525 |
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
|
| 4526 |
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
|
| 4527 |
return $mode;
|
| 4528 |
} else {
|
| 4529 |
$point = $this->options['start_point'];
|
| 4530 |
// $pass = usces_get_hash(trim($_POST['member']['password1']));
|
| 4531 |
$salt = usces_get_salt( '', 1 );
|
| 4532 |
$pass = usces_get_hash( trim( $_POST['member']['password1'] ), $salt );
|
| 4533 |
$name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : '';
|
| 4534 |
$name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : '';
|
| 4535 |
$name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : '';
|
| 4536 |
$name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : '';
|
| 4537 |
$zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : '';
|
| 4538 |
$pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : '';
|
| 4539 |
$address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : '';
|
| 4540 |
$address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : '';
|
| 4541 |
$address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : '';
|
| 4542 |
$tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : '';
|
| 4543 |
$fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : '';
|
| 4544 |
$country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : '';
|
| 4545 |
|
| 4546 |
$query = $wpdb->prepare(
|
| 4547 |
"INSERT INTO $member_table
|
| 4548 |
(mem_email, mem_pass, mem_status, mem_cookie, mem_point,
|
| 4549 |
mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
|
| 4550 |
mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
|
| 4551 |
mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
|
| 4552 |
VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
|
| 4553 |
trim( $_POST['member']['mailaddress1'] ),
|
| 4554 |
$pass,
|
| 4555 |
0,
|
| 4556 |
'',
|
| 4557 |
$point,
|
| 4558 |
$name1,
|
| 4559 |
$name2,
|
| 4560 |
$name3,
|
| 4561 |
$name4,
|
| 4562 |
$zipcode,
|
| 4563 |
$pref,
|
| 4564 |
$address1,
|
| 4565 |
$address2,
|
| 4566 |
$address3,
|
| 4567 |
$tel,
|
| 4568 |
$fax,
|
| 4569 |
'',
|
| 4570 |
'',
|
| 4571 |
get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ),
|
| 4572 |
''
|
| 4573 |
);
|
| 4574 |
$res = $wpdb->query( $query );
|
| 4575 |
|
| 4576 |
if ( false !== $res ) {
|
| 4577 |
$user = $_POST['member'];
|
| 4578 |
$user['ID'] = $wpdb->insert_id;
|
| 4579 |
$this->set_member_meta_value( 'customer_country', $country, $user['ID'] );
|
| 4580 |
|
| 4581 |
if ( ! empty( $salt ) ) {
|
| 4582 |
$this->set_member_meta_value( 'mem_salt', $salt, $user['ID'] );
|
| 4583 |
}
|
| 4584 |
|
| 4585 |
$res = $this->reg_custom_member( $user['ID'] );
|
| 4586 |
|
| 4587 |
if ( apply_filters( 'usces_filter_veirfyemail_newmemberform', false, $user ) ) {
|
| 4588 |
return 'memberverifying';
|
| 4589 |
}
|
| 4590 |
|
| 4591 |
do_action( 'usces_action_member_registered', $_POST['member'], $user['ID'] );
|
| 4592 |
unset( $_SESSION['usces_member'] );
|
| 4593 |
usces_send_regmembermail( $user );
|
| 4594 |
return 'newcompletion';
|
| 4595 |
|
| 4596 |
} else {
|
| 4597 |
$this->error_message = __( 'Error:failure in update', 'usces' );
|
| 4598 |
return $mode;
|
| 4599 |
}
|
| 4600 |
}
|
| 4601 |
|
| 4602 |
} elseif ( 'newmemberfromcart' == $_POST['member_regmode'] ) {
|
| 4603 |
|
| 4604 |
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1']));
|
| 4605 |
// $id = $wpdb->get_var( $query );
|
| 4606 |
$id = $this->check_member_email( $_POST['customer']['mailaddress1'] );
|
| 4607 |
if ( ! empty( $id ) ) {
|
| 4608 |
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
|
| 4609 |
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
|
| 4610 |
return $mode;
|
| 4611 |
} else {
|
| 4612 |
$point = $this->options['start_point'];
|
| 4613 |
// $pass = usces_get_hash(trim( $_POST['customer']['password1']));
|
| 4614 |
$salt = usces_get_salt( '', 1 );
|
| 4615 |
$pass = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt );
|
| 4616 |
$name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : '';
|
| 4617 |
$name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : '';
|
| 4618 |
$name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : '';
|
| 4619 |
$name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : '';
|
| 4620 |
$zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : '';
|
| 4621 |
$pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : '';
|
| 4622 |
$address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : '';
|
| 4623 |
$address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : '';
|
| 4624 |
$address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : '';
|
| 4625 |
$tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : '';
|
| 4626 |
$fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : '';
|
| 4627 |
$country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : '';
|
| 4628 |
|
| 4629 |
$query = $wpdb->prepare(
|
| 4630 |
"INSERT INTO $member_table
|
| 4631 |
(mem_email, mem_pass, mem_status, mem_cookie, mem_point,
|
| 4632 |
mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref,
|
| 4633 |
mem_address1, mem_address2, mem_address3, mem_tel, mem_fax,
|
| 4634 |
mem_delivery_flag, mem_delivery, mem_registered, mem_nicename)
|
| 4635 |
VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)",
|
| 4636 |
trim( $_POST['customer']['mailaddress1'] ),
|
| 4637 |
$pass,
|
| 4638 |
0,
|
| 4639 |
'',
|
| 4640 |
$point,
|
| 4641 |
$name1,
|
| 4642 |
$name2,
|
| 4643 |
$name3,
|
| 4644 |
$name4,
|
| 4645 |
$zipcode,
|
| 4646 |
$pref,
|
| 4647 |
$address1,
|
| 4648 |
$address2,
|
| 4649 |
$address3,
|
| 4650 |
$tel,
|
| 4651 |
$fax,
|
| 4652 |
'',
|
| 4653 |
'',
|
| 4654 |
get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ),
|
| 4655 |
''
|
| 4656 |
);
|
| 4657 |
$res = $wpdb->query( $query );
|
| 4658 |
|
| 4659 |
if ( false !== $res ) {
|
| 4660 |
$member_id = $wpdb->insert_id;
|
| 4661 |
$user = $_POST['customer'];
|
| 4662 |
$user['ID'] = $member_id;
|
| 4663 |
$this->set_member_meta_value( 'customer_country', $country, $member_id );
|
| 4664 |
|
| 4665 |
if ( ! empty( $salt ) ) {
|
| 4666 |
$this->set_member_meta_value( 'mem_salt', $salt, $member_id );
|
| 4667 |
}
|
| 4668 |
|
| 4669 |
$res = $this->reg_custom_member( $member_id );
|
| 4670 |
|
| 4671 |
if ( apply_filters( 'usces_filter_veirfyemail_newmemberfromcart', false, $user ) ) {
|
| 4672 |
return 'cartverifying';
|
| 4673 |
}
|
| 4674 |
|
| 4675 |
do_action( 'usces_action_member_registered', $_POST['customer'], $member_id );
|
| 4676 |
usces_send_regmembermail( $user );
|
| 4677 |
$_POST['loginmail'] = trim( $_POST['customer']['mailaddress1'] );
|
| 4678 |
$_POST['loginpass'] = trim( $_POST['customer']['password1'] );
|
| 4679 |
if ( 'member' == $this->member_login() ) {
|
| 4680 |
$_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart';
|
| 4681 |
return 'newcompletion';
|
| 4682 |
}
|
| 4683 |
|
| 4684 |
} else {
|
| 4685 |
$this->error_message = __( 'Error:failure in update', 'usces' );
|
| 4686 |
return $mode;
|
| 4687 |
}
|
| 4688 |
}
|
| 4689 |
|
| 4690 |
} elseif ( 'editmemberfromcart' == $_POST['member_regmode'] ) {
|
| 4691 |
|
| 4692 |
$this->get_current_member();
|
| 4693 |
$mem_id = $this->current_member['id'];
|
| 4694 |
|
| 4695 |
// $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['customer']['mailaddress1']));
|
| 4696 |
// $id = $wpdb->get_var( $query );
|
| 4697 |
$id = $this->check_member_email( $_POST['customer']['mailaddress1'] );
|
| 4698 |
if ( ! empty( $id ) && $id != $mem_id ) {
|
| 4699 |
// $this->error_message = __( 'This e-mail address has been already registered.', 'usces' );
|
| 4700 |
$this->error_message = __( 'This e-mail address can not be registered.', 'usces' );
|
| 4701 |
return $mode;
|
| 4702 |
}
|
| 4703 |
|
| 4704 |
do_action( 'usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id );
|
| 4705 |
|
| 4706 |
$query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id );
|
| 4707 |
$pass = $wpdb->get_var( $query );
|
| 4708 |
// $password = ( !empty( $_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? usces_get_hash(trim($_POST['customer']['password1'])) : $pass;
|
| 4709 |
if ( ! empty( $_POST['customer']['password1'] ) && trim( $_POST['customer']['password1'] ) == trim( $_POST['customer']['password2'] ) ) {
|
| 4710 |
$salt = usces_get_salt( $mem_id );
|
| 4711 |
$password = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt );
|
| 4712 |
} else {
|
| 4713 |
$password = $pass;
|
| 4714 |
}
|
| 4715 |
$name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : '';
|
| 4716 |
$name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : '';
|
| 4717 |
$name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : '';
|
| 4718 |
$name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : '';
|
| 4719 |
$zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : '';
|
| 4720 |
$pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : '';
|
| 4721 |
$address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : '';
|
| 4722 |
$address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : '';
|
| 4723 |
$address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : '';
|
| 4724 |
$tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : '';
|
| 4725 |
$fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : '';
|
| 4726 |
$country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : '';
|
| 4727 |
|
| 4728 |
$query = $wpdb->prepare(
|
| 4729 |
"UPDATE $member_table SET
|
| 4730 |
mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s,
|
| 4731 |
mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s,
|
| 4732 |
mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d",
|
| 4733 |
$password,
|
| 4734 |
$name1,
|
| 4735 |
$name2,
|
| 4736 |
$name3,
|
| 4737 |
$name4,
|
| 4738 |
$zipcode,
|
| 4739 |
$pref,
|
| 4740 |
$address1,
|
| 4741 |
$address2,
|
| 4742 |
$address3,
|
| 4743 |
$tel,
|
| 4744 |
$fax,
|
| 4745 |
trim( $_POST['customer']['mailaddress1'] ),
|
| 4746 |
$mem_id
|
| 4747 |
);
|
| 4748 |
$res = $wpdb->query( $query );
|
| 4749 |
if ( false !== $res ) {
|
| 4750 |
$this->set_member_meta_value( 'customer_country', $country, $mem_id );
|
| 4751 |
$res = $this->reg_custom_member( $mem_id );
|
| 4752 |
do_action( 'usces_action_edit_memberdata', $_POST['customer'], $mem_id );
|
| 4753 |
unset( $_SESSION['usces_member'] );
|
| 4754 |
$this->member_just_login( trim( $_POST['customer']['mailaddress1'] ), trim( $_POST['customer']['password1'] ) );
|
| 4755 |
return 'newcompletion';
|
| 4756 |
|
| 4757 |
} else {
|
| 4758 |
$this->error_message = __( 'Error:failure in update', 'usces' );
|
| 4759 |
return $mode;
|
| 4760 |
}
|
| 4761 |
}
|
| 4762 |
}
|
| 4763 |
|
| 4764 |
public function delete_member() {
|
| 4765 |
$res = false;
|
| 4766 |
|
| 4767 |
if ( ! $this->is_member_logged_in() ) {
|
| 4768 |
return $res;
|
| 4769 |
}
|
| 4770 |
$mem = $this->get_member();
|
| 4771 |
if ( ! $mem['ID'] ) {
|
| 4772 |
return $res;
|
| 4773 |
}
|
| 4774 |
|
| 4775 |
$del = usces_delete_member_check_front( $mem['ID'] );
|
| 4776 |
if ( $del ) {
|
| 4777 |
$res = usces_delete_memberdata( $mem['ID'] );
|
| 4778 |
if ( $res ) {
|
| 4779 |
usces_send_delmembermail( $mem );
|
| 4780 |
}
|
| 4781 |
}
|
| 4782 |
|
| 4783 |
return $res;
|
| 4784 |
}
|
| 4785 |
|
| 4786 |
public function is_member_logged_in( $id = false ) {
|
| 4787 |
if ( false === $id ) {
|
| 4788 |
if ( ! empty( $_SESSION['usces_member']['ID'] ) ) {
|
| 4789 |
return true;
|
| 4790 |
} else {
|
| 4791 |
return false;
|
| 4792 |
}
|
| 4793 |
} else {
|
| 4794 |
if ( ! empty( $_SESSION['usces_member']['ID'] ) && $_SESSION['usces_member']['ID'] == $id ) {
|
| 4795 |
return true;
|
| 4796 |
} else {
|
| 4797 |
return false;
|
| 4798 |
}
|
| 4799 |
}
|
| 4800 |
}
|
| 4801 |
|
| 4802 |
public function is_member( $email ) {
|
| 4803 |
global $wpdb;
|
| 4804 |
|
| 4805 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4806 |
$query = $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE mem_email = %s", $email );
|
| 4807 |
$member = $wpdb->get_row( $query, ARRAY_A );
|
| 4808 |
if ( empty( $member ) ) {
|
| 4809 |
return false;
|
| 4810 |
} else {
|
| 4811 |
return true;
|
| 4812 |
}
|
| 4813 |
}
|
| 4814 |
|
| 4815 |
public function member_login() {
|
| 4816 |
global $wpdb;
|
| 4817 |
$_POST = $this->stripslashes_deep_post( $_POST );
|
| 4818 |
|
| 4819 |
$cookie = $this->get_cookie();
|
| 4820 |
$metatable_name = usces_get_tablename( 'usces_member_meta' );
|
| 4821 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4822 |
if ( ! class_exists( 'RateLimiter' ) ) {
|
| 4823 |
require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php';
|
| 4824 |
}
|
| 4825 |
$rateLimiter = new RateLimiter();
|
| 4826 |
|
| 4827 |
if ( isset( $cookie['rme'] ) && 'forever' == $cookie['rme'] && ! isset( $_POST['rememberme'] ) && ! isset( $_POST['loginmail'] ) ) {
|
| 4828 |
|
| 4829 |
$_forever = isset( $cookie['name'] ) ? $cookie['name'] : '';
|
| 4830 |
if ( $_forever ) {
|
| 4831 |
$query = $wpdb->prepare( "SELECT member_id FROM $metatable_name WHERE meta_value = %s AND meta_key = %s",
|
| 4832 |
$_forever, '_forever'
|
| 4833 |
);
|
| 4834 |
$id = $wpdb->get_var( $query );
|
| 4835 |
} else {
|
| 4836 |
$id = '';
|
| 4837 |
}
|
| 4838 |
|
| 4839 |
if ( ! $id ) {
|
| 4840 |
$cookie['name'] = '';
|
| 4841 |
$cookie['rme'] = '';
|
| 4842 |
$this->set_cookie( $cookie );
|
| 4843 |
$rateLimiter->saveLoginFailed();
|
| 4844 |
return 'login';
|
| 4845 |
} else {
|
| 4846 |
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $id );
|
| 4847 |
$member = $wpdb->get_row( $query, ARRAY_A );
|
| 4848 |
if ( empty( $member ) ) {
|
| 4849 |
$rateLimiter->saveLoginFailed();
|
| 4850 |
$this->error_message = __( '<b>Error:</b> Your E-mail or password is incorrect.', 'usces' );
|
| 4851 |
return 'login';
|
| 4852 |
} else {
|
| 4853 |
$_SESSION['usces_member']['ID'] = $member['ID'];
|
| 4854 |
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
|
| 4855 |
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
|
| 4856 |
$_SESSION['usces_member']['point'] = $member['mem_point'];
|
| 4857 |
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
|
| 4858 |
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
|
| 4859 |
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
|
| 4860 |
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
|
| 4861 |
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
|
| 4862 |
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
|
| 4863 |
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
|
| 4864 |
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
|
| 4865 |
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
|
| 4866 |
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
|
| 4867 |
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
|
| 4868 |
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
|
| 4869 |
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
|
| 4870 |
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
|
| 4871 |
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
|
| 4872 |
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
|
| 4873 |
$_SESSION['usces_member']['status'] = $member['mem_status'];
|
| 4874 |
$this->set_session_custom_member( $member['ID'] );
|
| 4875 |
$this->get_current_member();
|
| 4876 |
|
| 4877 |
do_action( 'usces_action_after_login' );
|
| 4878 |
$this->set_cookie( $cookie );
|
| 4879 |
return apply_filters( 'usces_filter_member_login', 'member', $member );
|
| 4880 |
}
|
| 4881 |
}
|
| 4882 |
} elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginmail'] ) && isset( $_POST['loginpass'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) {
|
| 4883 |
$rateLimiter->saveLoginFailed();
|
| 4884 |
return 'login';
|
| 4885 |
} elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) {
|
| 4886 |
$rateLimiter->saveLoginFailed();
|
| 4887 |
$this->error_message = __( '<b>Error:</b> Enter the password.', 'usces' );
|
| 4888 |
return 'login';
|
| 4889 |
} elseif ( ! isset( $_POST['loginmail'] ) ) {
|
| 4890 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
|
| 4891 |
$rateLimiter->saveLoginFailed();
|
| 4892 |
}
|
| 4893 |
return 'login';
|
| 4894 |
} else {
|
| 4895 |
|
| 4896 |
if ( isset( $_POST['loginmail'] ) ) {
|
| 4897 |
$nonce = isset( $_REQUEST['wel_nonce'] ) ? $_REQUEST['wel_nonce'] : '';
|
| 4898 |
if ( ! $nonce ) {
|
| 4899 |
$nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : '';
|
| 4900 |
}
|
| 4901 |
$noncekey = 'post_member' . $this->get_uscesid( false );
|
| 4902 |
if ( ! wp_verify_nonce( $nonce, $noncekey ) && ! $this->is_member_logged_in() ) {
|
| 4903 |
$rateLimiter->saveLoginFailed();
|
| 4904 |
die( 'Security check4' );
|
| 4905 |
}
|
| 4906 |
}
|
| 4907 |
|
| 4908 |
$email = isset( $_POST['loginmail'] ) ? trim( $_POST['loginmail'] ) : '';
|
| 4909 |
// $pass = isset( $_POST['loginpass']) ? usces_get_hash(trim( $_POST['loginpass'])) : '';
|
| 4910 |
$salt = usces_get_salt( $email );
|
| 4911 |
$pass = usces_get_hash( trim( $_POST['loginpass'] ), $salt );
|
| 4912 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4913 |
|
| 4914 |
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass );
|
| 4915 |
$query = apply_filters( 'usces_filter_member_login_query', $query, $email, $pass );
|
| 4916 |
$member = $wpdb->get_row( $query, ARRAY_A );
|
| 4917 |
|
| 4918 |
if ( empty( $member ) ) {
|
| 4919 |
$rateLimiter->saveLoginFailed();
|
| 4920 |
$this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT );
|
| 4921 |
$this->error_message = __( '<b>Error:</b> Your E-mail or password is incorrect.', 'usces' );
|
| 4922 |
return 'login';
|
| 4923 |
} else {
|
| 4924 |
|
| 4925 |
if ( USCES_VERIFY_MEMBERS_EMAIL::$opts['switch_flag'] ) {
|
| 4926 |
$verify_flag = $this->get_member_meta_value( '_verifying', $member['ID'] );
|
| 4927 |
} else {
|
| 4928 |
$verify_flag = '';
|
| 4929 |
}
|
| 4930 |
if ( ! empty( $verify_flag ) ) {
|
| 4931 |
$rateLimiter->saveLoginFailed();
|
| 4932 |
$this->error_message = __( '<b>Error:</b> Membership registration is not complete.', 'usces' );
|
| 4933 |
return 'login';
|
| 4934 |
}
|
| 4935 |
|
| 4936 |
$_SESSION['usces_member']['ID'] = $member['ID'];
|
| 4937 |
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
|
| 4938 |
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
|
| 4939 |
$_SESSION['usces_member']['point'] = $member['mem_point'];
|
| 4940 |
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
|
| 4941 |
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
|
| 4942 |
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
|
| 4943 |
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
|
| 4944 |
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
|
| 4945 |
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
|
| 4946 |
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
|
| 4947 |
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
|
| 4948 |
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
|
| 4949 |
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
|
| 4950 |
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
|
| 4951 |
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
|
| 4952 |
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
|
| 4953 |
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
|
| 4954 |
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
|
| 4955 |
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
|
| 4956 |
$_SESSION['usces_member']['status'] = $member['mem_status'];
|
| 4957 |
$this->set_session_custom_member( $member['ID'] );
|
| 4958 |
$this->get_current_member();
|
| 4959 |
$rateLimiter->clear_login_failed();
|
| 4960 |
|
| 4961 |
if ( isset( $_POST['rememberme'] ) ) {
|
| 4962 |
$_forever = $this->set_login_forever( $member['ID'] );
|
| 4963 |
$cookie['name'] = $_forever;
|
| 4964 |
$cookie['rme'] = 'forever';
|
| 4965 |
$this->set_cookie( $cookie );
|
| 4966 |
} else {
|
| 4967 |
$cookie['name'] = '';
|
| 4968 |
$cookie['rme'] = '';
|
| 4969 |
$this->set_cookie( $cookie );
|
| 4970 |
}
|
| 4971 |
|
| 4972 |
do_action( 'usces_action_after_login' );
|
| 4973 |
return apply_filters( 'usces_filter_member_login', 'member', $member );
|
| 4974 |
}
|
| 4975 |
}
|
| 4976 |
}
|
| 4977 |
|
| 4978 |
public function set_login_forever( $member_id ) {
|
| 4979 |
if ( ! $member_id ) {
|
| 4980 |
return false;
|
| 4981 |
}
|
| 4982 |
|
| 4983 |
$_forever = wp_generate_password( 32, false, false );
|
| 4984 |
$this->set_member_meta_value( '_forever', $_forever, $member_id );
|
| 4985 |
return $_forever;
|
| 4986 |
}
|
| 4987 |
|
| 4988 |
public function set_member_session_data( $member_id ) {
|
| 4989 |
global $wpdb;
|
| 4990 |
|
| 4991 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 4992 |
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $member_id );
|
| 4993 |
$member = $wpdb->get_row( $query, ARRAY_A );
|
| 4994 |
if ( ! empty( $member ) ) {
|
| 4995 |
$_SESSION['usces_member']['ID'] = $member['ID'];
|
| 4996 |
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
|
| 4997 |
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
|
| 4998 |
$_SESSION['usces_member']['point'] = $member['mem_point'];
|
| 4999 |
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
|
| 5000 |
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
|
| 5001 |
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
|
| 5002 |
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
|
| 5003 |
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
|
| 5004 |
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
|
| 5005 |
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
|
| 5006 |
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
|
| 5007 |
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
|
| 5008 |
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
|
| 5009 |
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
|
| 5010 |
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
|
| 5011 |
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
|
| 5012 |
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
|
| 5013 |
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
|
| 5014 |
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
|
| 5015 |
$_SESSION['usces_member']['status'] = $member['mem_status'];
|
| 5016 |
$this->set_session_custom_member( $member['ID'] );
|
| 5017 |
$this->get_current_member();
|
| 5018 |
}
|
| 5019 |
return;
|
| 5020 |
}
|
| 5021 |
|
| 5022 |
public function member_just_login( $email, $pass ) {
|
| 5023 |
global $wpdb;
|
| 5024 |
// $pass = usces_get_hash($pass);
|
| 5025 |
$salt = usces_get_salt( $email );
|
| 5026 |
$pass = usces_get_hash( $pass, $salt );
|
| 5027 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 5028 |
|
| 5029 |
$query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass );
|
| 5030 |
$member = $wpdb->get_row( $query, ARRAY_A );
|
| 5031 |
if ( empty( $member ) ) {
|
| 5032 |
$this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT );
|
| 5033 |
$this->error_message = __( '<b>Error:</b> Password is not correct.', 'usces' );
|
| 5034 |
return 'login';
|
| 5035 |
} else {
|
| 5036 |
$_SESSION['usces_member']['ID'] = $member['ID'];
|
| 5037 |
$_SESSION['usces_member']['mailaddress1'] = $member['mem_email'];
|
| 5038 |
$_SESSION['usces_member']['mailaddress2'] = $member['mem_email'];
|
| 5039 |
$_SESSION['usces_member']['point'] = $member['mem_point'];
|
| 5040 |
$_SESSION['usces_member']['name1'] = $member['mem_name1'];
|
| 5041 |
$_SESSION['usces_member']['name2'] = $member['mem_name2'];
|
| 5042 |
$_SESSION['usces_member']['name3'] = $member['mem_name3'];
|
| 5043 |
$_SESSION['usces_member']['name4'] = $member['mem_name4'];
|
| 5044 |
$_SESSION['usces_member']['zipcode'] = $member['mem_zip'];
|
| 5045 |
$_SESSION['usces_member']['pref'] = $member['mem_pref'];
|
| 5046 |
$_SESSION['usces_member']['address1'] = $member['mem_address1'];
|
| 5047 |
$_SESSION['usces_member']['address2'] = $member['mem_address2'];
|
| 5048 |
$_SESSION['usces_member']['address3'] = $member['mem_address3'];
|
| 5049 |
$_SESSION['usces_member']['tel'] = $member['mem_tel'];
|
| 5050 |
$_SESSION['usces_member']['fax'] = $member['mem_fax'];
|
| 5051 |
$_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag'];
|
| 5052 |
$_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? unserialize( $member['mem_delivery'] ) : '';
|
| 5053 |
$_SESSION['usces_member']['registered'] = $member['mem_registered'];
|
| 5054 |
$_SESSION['usces_member']['nicename'] = $member['mem_nicename'];
|
| 5055 |
$_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] );
|
| 5056 |
$_SESSION['usces_member']['status'] = $member['mem_status'];
|
| 5057 |
$this->set_session_custom_member( $member['ID'] );
|
| 5058 |
$this->get_current_member();
|
| 5059 |
|
| 5060 |
do_action( 'usces_action_after_login' );
|
| 5061 |
return apply_filters( 'usces_filter_member_login', 'member', $member );
|
| 5062 |
}
|
| 5063 |
}
|
| 5064 |
|
| 5065 |
public function member_logout() {
|
| 5066 |
do_action( 'usces_action_before_logout' );
|
| 5067 |
$cookie = $this->get_cookie();
|
| 5068 |
$cookie['name'] = '';
|
| 5069 |
$cookie['rme'] = '';
|
| 5070 |
$options = get_option( 'usces' );
|
| 5071 |
|
| 5072 |
$this->set_cookie( $cookie );
|
| 5073 |
|
| 5074 |
$fcookie = $this->get_cookie( $options['usces_key'] );
|
| 5075 |
|
| 5076 |
unset( $_SESSION['usces_member'], $_SESSION['usces_entry'] );
|
| 5077 |
do_action( 'usces_action_member_logout' );
|
| 5078 |
}
|
| 5079 |
|
| 5080 |
public function get_current_member() {
|
| 5081 |
if ( isset( $_SESSION['usces_member']['ID'] ) ) {
|
| 5082 |
$this->current_member['id'] = $_SESSION['usces_member']['ID'];
|
| 5083 |
$this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return' );
|
| 5084 |
} else {
|
| 5085 |
$this->current_member['id'] = 0;
|
| 5086 |
$this->current_member['name'] = __( 'guest', 'usces' );
|
| 5087 |
}
|
| 5088 |
}
|
| 5089 |
|
| 5090 |
public function get_member() {
|
| 5091 |
$res = array(
|
| 5092 |
'ID' => '',
|
| 5093 |
'registered' => '',
|
| 5094 |
'mailaddress1' => '',
|
| 5095 |
'mailaddress2' => '',
|
| 5096 |
'password1' => '',
|
| 5097 |
'password2' => '',
|
| 5098 |
'point' => '',
|
| 5099 |
'name1' => '',
|
| 5100 |
'name2' => '',
|
| 5101 |
'name3' => '',
|
| 5102 |
'name4' => '',
|
| 5103 |
'zipcode' => '',
|
| 5104 |
'address1' => '',
|
| 5105 |
'address2' => '',
|
| 5106 |
'address3' => '',
|
| 5107 |
'tel' => '',
|
| 5108 |
'fax' => '',
|
| 5109 |
'country' => '',
|
| 5110 |
'pref' => '',
|
| 5111 |
'status' => '',
|
| 5112 |
);
|
| 5113 |
if ( ! empty( $_SESSION['usces_member'] ) ) {
|
| 5114 |
foreach ( $_SESSION['usces_member'] as $key => $value ) {
|
| 5115 |
if ( is_array( $_SESSION['usces_member'][ $key ] ) ) {
|
| 5116 |
$res[ $key ] = stripslashes_deep( $value );
|
| 5117 |
} else {
|
| 5118 |
$res[ $key ] = null !== $value ? stripslashes( $value ) : '';
|
| 5119 |
}
|
| 5120 |
}
|
| 5121 |
}
|
| 5122 |
return $res;
|
| 5123 |
}
|
| 5124 |
|
| 5125 |
public function get_member_info( $mid ) {
|
| 5126 |
global $wpdb;
|
| 5127 |
$infos = array();
|
| 5128 |
$table = usces_get_tablename( 'usces_member' );
|
| 5129 |
$query = $wpdb->prepare( "SELECT * FROM $table WHERE ID = %d", $mid );
|
| 5130 |
$datas = $wpdb->get_results( $query, ARRAY_A );
|
| 5131 |
if ( $datas ) {
|
| 5132 |
$infos = $datas[0];
|
| 5133 |
|
| 5134 |
$table = usces_get_tablename( 'usces_member_meta' );
|
| 5135 |
$query = $wpdb->prepare( "SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid );
|
| 5136 |
$metas = $wpdb->get_results( $query, ARRAY_A );
|
| 5137 |
|
| 5138 |
foreach ( $metas as $meta ) {
|
| 5139 |
$infos[ $meta['meta_key'] ] = maybe_unserialize( $meta['meta_value'] );
|
| 5140 |
}
|
| 5141 |
}
|
| 5142 |
return $infos;
|
| 5143 |
}
|
| 5144 |
|
| 5145 |
public function set_member_info( $data = array(), $mid = '' ) {
|
| 5146 |
global $wpdb;
|
| 5147 |
|
| 5148 |
$table = usces_get_tablename( 'usces_member' );
|
| 5149 |
$res = $wpdb->update( $table, $data, array( 'ID' => $mid ), null, array( '%d' ) );
|
| 5150 |
return $res;
|
| 5151 |
}
|
| 5152 |
|
| 5153 |
public function check_member_email( $email ) {
|
| 5154 |
global $wpdb;
|
| 5155 |
|
| 5156 |
$member_table_name = usces_get_tablename( 'usces_member' );
|
| 5157 |
$query = $wpdb->prepare( "SELECT ID FROM $member_table_name WHERE mem_email = %s", trim( $email ) );
|
| 5158 |
$id = $wpdb->get_var( $query );
|
| 5159 |
return $id;
|
| 5160 |
}
|
| 5161 |
|
| 5162 |
public function is_order( $mid, $oid ) {
|
| 5163 |
global $wpdb;
|
| 5164 |
|
| 5165 |
$mid = (int) $mid;
|
| 5166 |
$oid = (int) $oid;
|
| 5167 |
|
| 5168 |
$table = $wpdb->prefix . 'usces_order';
|
| 5169 |
$query = $wpdb->prepare( "SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid );
|
| 5170 |
$mem_id = $wpdb->get_var( $query );
|
| 5171 |
if ( empty( $mem_id ) ) {
|
| 5172 |
return false;
|
| 5173 |
} else {
|
| 5174 |
return true;
|
| 5175 |
}
|
| 5176 |
}
|
| 5177 |
|
| 5178 |
public function is_purchased_item( $mid, $post_id, $sku = null, $order_id = null ) {
|
| 5179 |
global $wpdb;
|
| 5180 |
$res = false;
|
| 5181 |
|
| 5182 |
if ( empty( $order_id ) ) {
|
| 5183 |
$history = $this->get_member_history( $mid, true );
|
| 5184 |
foreach ( $history as $umhs ) {
|
| 5185 |
$cart = $umhs['cart'];
|
| 5186 |
$status = $umhs['order_status'];
|
| 5187 |
$cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
|
| 5188 |
for ( $i = 0; $i < $cart_count; $i++ ) {
|
| 5189 |
$cart_row = $cart[ $i ];
|
| 5190 |
$sku_code = urldecode( $cart_row['sku'] );
|
| 5191 |
if ( empty( $sku ) ) {
|
| 5192 |
if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) {
|
| 5193 |
$res = true;
|
| 5194 |
break 2;
|
| 5195 |
} elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) {
|
| 5196 |
$res = 'noreceipt';
|
| 5197 |
break 2;
|
| 5198 |
}
|
| 5199 |
} else {
|
| 5200 |
if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) {
|
| 5201 |
$res = true;
|
| 5202 |
break 2;
|
| 5203 |
} elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) {
|
| 5204 |
$res = 'noreceipt';
|
| 5205 |
break 2;
|
| 5206 |
}
|
| 5207 |
}
|
| 5208 |
}
|
| 5209 |
}
|
| 5210 |
} else {
|
| 5211 |
$order_table_name = $wpdb->prefix . 'usces_order';
|
| 5212 |
$query = $wpdb->prepare( "SELECT order_status FROM $order_table_name WHERE ID = %d AND mem_id = %d",
|
| 5213 |
$order_id, $mid
|
| 5214 |
);
|
| 5215 |
$order = $wpdb->get_row( $query );
|
| 5216 |
if ( is_null( $order ) ) { // 該当の受注データが一件も見つからなかった場合、購入していないと判断する.
|
| 5217 |
$res = false;
|
| 5218 |
} else { // 該当の受注データが見つかった場合には受注ステータスを確認する処理を行う.
|
| 5219 |
$status = $order->order_status;
|
| 5220 |
$cart = usces_get_ordercartdata( $order_id );
|
| 5221 |
foreach ( $cart as $cart_row ) {
|
| 5222 |
$sku_code = urldecode( $cart_row['sku'] );
|
| 5223 |
if ( empty( $sku ) ) {
|
| 5224 |
if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) {
|
| 5225 |
$res = true;
|
| 5226 |
break;
|
| 5227 |
} elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) {
|
| 5228 |
$res = 'noreceipt';
|
| 5229 |
break;
|
| 5230 |
}
|
| 5231 |
} else {
|
| 5232 |
if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) {
|
| 5233 |
$res = true;
|
| 5234 |
break;
|
| 5235 |
} elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) {
|
| 5236 |
$res = 'noreceipt';
|
| 5237 |
break;
|
| 5238 |
}
|
| 5239 |
}
|
| 5240 |
}
|
| 5241 |
}
|
| 5242 |
}
|
| 5243 |
|
| 5244 |
return apply_filters( 'usces_filter_is_purchased_item', $res, $mid, $post_id, $sku, $order_id );
|
| 5245 |
}
|
| 5246 |
|
| 5247 |
public function get_order_data( $order_id, $mode = '' ) {
|
| 5248 |
global $wpdb;
|
| 5249 |
$order_table = $wpdb->prefix . 'usces_order';
|
| 5250 |
|
| 5251 |
$query = $wpdb->prepare( "SELECT * FROM $order_table WHERE ID = %d", $order_id );
|
| 5252 |
|
| 5253 |
if ( 'direct' == $mode ) {
|
| 5254 |
$value = $wpdb->get_row( $query, ARRAY_A );
|
| 5255 |
return $value;
|
| 5256 |
}
|
| 5257 |
|
| 5258 |
$value = $wpdb->get_row( $query );
|
| 5259 |
|
| 5260 |
if ( null == $value ) {
|
| 5261 |
return false;
|
| 5262 |
} else {
|
| 5263 |
$res = array();
|
| 5264 |
}
|
| 5265 |
if ( strpos( $value->order_status, 'cancel' ) !== false || strpos( $value->order_status, 'estimate' ) !== false ) {
|
| 5266 |
return false;
|
| 5267 |
}
|
| 5268 |
|
| 5269 |
$total_price = $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax;
|
| 5270 |
if ( $total_price < 0 ) {
|
| 5271 |
$total_price = 0;
|
| 5272 |
}
|
| 5273 |
$res = array(
|
| 5274 |
'ID' => $value->ID,
|
| 5275 |
'mem_id' => $value->mem_id,
|
| 5276 |
'cart' => unserialize( $value->order_cart ),
|
| 5277 |
'condition' => unserialize( $value->order_condition ),
|
| 5278 |
'getpoint' => $value->order_getpoint,
|
| 5279 |
'usedpoint' => $value->order_usedpoint,
|
| 5280 |
'discount' => $value->order_discount,
|
| 5281 |
'payment_name' => $value->order_payment_name,
|
| 5282 |
'shipping_charge' => $value->order_shipping_charge,
|
| 5283 |
'cod_fee' => $value->order_cod_fee,
|
| 5284 |
'tax' => $value->order_tax,
|
| 5285 |
'end_price' => $total_price,
|
| 5286 |
'status' => $value->order_status,
|
| 5287 |
'date' => mysql2date( __( 'Y/m/d' ), $value->order_date ),
|
| 5288 |
'modified' => mysql2date( __( 'Y/m/d' ), $value->order_modified ),
|
| 5289 |
);
|
| 5290 |
|
| 5291 |
return $res;
|
| 5292 |
}
|
| 5293 |
|
| 5294 |
public function get_orderIDs_by_postID( $mem_id, $post_id ) {
|
| 5295 |
global $wpdb;
|
| 5296 |
$order_table = $wpdb->prefix . 'usces_order';
|
| 5297 |
|
| 5298 |
$query = $wpdb->prepare( "SELECT ID, order_cart, order_status FROM $order_table WHERE mem_id = %d ORDER BY order_modified DESC, order_date DESC", $mem_id );
|
| 5299 |
$rows = $wpdb->get_query( $query, ARRAY_A );
|
| 5300 |
|
| 5301 |
if ( null == $value ) {
|
| 5302 |
return false;
|
| 5303 |
} else {
|
| 5304 |
foreach ( $rows as $row ) {
|
| 5305 |
if ( strpos( $row['order_status'], 'cancel' ) !== false || strpos( $row['order_status'], 'estimate' ) !== false ) {
|
| 5306 |
continue;
|
| 5307 |
} else {
|
| 5308 |
$carts = unserialize( $row['order_cart'] );
|
| 5309 |
foreach ( $carts as $cart ) {
|
| 5310 |
if ( $post_id == $cart['post_id'] ) {
|
| 5311 |
$res[] = $row['ID'];
|
| 5312 |
break;
|
| 5313 |
}
|
| 5314 |
}
|
| 5315 |
}
|
| 5316 |
}
|
| 5317 |
}
|
| 5318 |
return $res;
|
| 5319 |
}
|
| 5320 |
|
| 5321 |
public function incart_check() {
|
| 5322 |
$mes = array();
|
| 5323 |
|
| 5324 |
$ids = array_keys( $_POST['inCart'] );
|
| 5325 |
$post_id = $ids[0];
|
| 5326 |
$skus = array_keys( $_POST['inCart'][ $post_id ] );
|
| 5327 |
$sku = $skus[0];
|
| 5328 |
$sku_code = urldecode( $sku );
|
| 5329 |
$quant = isset( $_POST['quant'][ $post_id ][ $sku ] ) ? (int) $_POST['quant'][ $post_id ][ $sku ] : 1;
|
| 5330 |
$stock = $this->getItemZaikoNum( $post_id, $sku );
|
| 5331 |
$zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku );
|
| 5332 |
$product = wel_get_product( $post_id );
|
| 5333 |
$itemRestriction = $product['itemRestriction'];
|
| 5334 |
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
|
| 5335 |
|
| 5336 |
if ( 1 > $quant ) {
|
| 5337 |
$mes[ $post_id ][ $sku ] = __( 'enter the correct amount', 'usces' ) . '<br />';
|
| 5338 |
} elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) {
|
| 5339 |
$mes[ $post_id ][ $sku ] = sprintf( __( 'This article is limited by %d at a time.', 'usces' ), $itemRestriction ) . '<br />';
|
| 5340 |
} elseif ( 1 != $itemOrderAcceptable && $quant > (int) $stock && ! WCUtils::is_blank( $stock ) ) {
|
| 5341 |
$mes[ $post_id ][ $sku ] = __( 'Sorry, stock is insufficient.', 'usces' ) . ' ' . __( 'Current stock', 'usces' ) . $stock . '<br />';
|
| 5342 |
} elseif ( 1 != $itemOrderAcceptable && !$this->is_item_zaiko( $post_id, $sku_code ) ) {
|
| 5343 |
$mes[ $post_id ][ $sku ] = __( 'Sorry, this item is sold out.', 'usces' ) . '<br />';
|
| 5344 |
} else {
|
| 5345 |
$mes[ $post_id ][ $sku ] = '';
|
| 5346 |
}
|
| 5347 |
|
| 5348 |
$ioptkeys = $this->get_itemOptionKey( $post_id, true );
|
| 5349 |
if ( $ioptkeys ) {
|
| 5350 |
foreach ( $ioptkeys as $key => $value ) {
|
| 5351 |
$optValues = $this->get_itemOptions( urldecode( $value ), $post_id );
|
| 5352 |
if ( 0 == $optValues['means'] ) { // case of select.
|
| 5353 |
if ( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) {
|
| 5354 |
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />';
|
| 5355 |
}
|
| 5356 |
} elseif ( 1 == $optValues['means'] ) { // case of multiselect.
|
| 5357 |
if ( $optValues['essential'] ) {
|
| 5358 |
$mselect = 0;
|
| 5359 |
foreach ( (array) $_POST['itemOption'][ $post_id ][ $sku ][ $value ] as $mvalue ) {
|
| 5360 |
if ( ! empty( $mvalue ) && '#NONE#' != $mvalue ) {
|
| 5361 |
$mselect++;
|
| 5362 |
}
|
| 5363 |
}
|
| 5364 |
if ( $mselect == 0 ) {
|
| 5365 |
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />';
|
| 5366 |
}
|
| 5367 |
}
|
| 5368 |
} elseif ( in_array( $optValues['means'], array( 3, 4 ) ) ) { // case of radio & checkbox.
|
| 5369 |
if ( $optValues['essential'] ) {
|
| 5370 |
if ( ! isset( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) {
|
| 5371 |
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />';
|
| 5372 |
}
|
| 5373 |
}
|
| 5374 |
} else { // case of text.
|
| 5375 |
if ( $optValues['essential'] && WCUtils::is_blank( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) {
|
| 5376 |
$mes[ $post_id ][ $sku ] .= sprintf( __( 'Input the %s', 'usces' ), urldecode( $value ) ) . '<br />';
|
| 5377 |
}
|
| 5378 |
}
|
| 5379 |
}
|
| 5380 |
}
|
| 5381 |
|
| 5382 |
$mes = apply_filters( 'usces_filter_incart_check', $mes, $post_id, $sku );
|
| 5383 |
|
| 5384 |
if ( isset( $mes[ $post_id ] ) && is_array( $mes[ $post_id ] ) ) {
|
| 5385 |
$rembr = array();
|
| 5386 |
foreach ( $mes[ $post_id ] as $skukey => $skuvalue ) {
|
| 5387 |
if ( ! empty( $skuvalue ) ) {
|
| 5388 |
$rembr[ $post_id ][ $skukey ] = preg_replace( '/<br\s*\/?>\s*$/', '', $skuvalue );
|
| 5389 |
}
|
| 5390 |
}
|
| 5391 |
$mes = $rembr;
|
| 5392 |
}
|
| 5393 |
|
| 5394 |
if ( ! empty( $mes ) ) {
|
| 5395 |
$_SESSION['usces_singleitem']['itemOption'] = isset( $_POST['itemOption'] ) ? $_POST['itemOption'] : array();
|
| 5396 |
$_SESSION['usces_singleitem']['quant'] = isset( $_POST['quant'] ) ? (int) $_POST['quant'] : 1;
|
| 5397 |
$_SESSION['usces_singleitem']['error_message'] = $mes;
|
| 5398 |
if ( false === strpos( $_POST['usces_referer'], 'http' ) ) {
|
| 5399 |
$parse_url = parse_url( get_home_url() );
|
| 5400 |
$port = '';
|
| 5401 |
if ( isset( $parse_url['port'] ) && ! empty( $parse_url['port'] ) ) {
|
| 5402 |
$port = ':' . $parse_url['port'];
|
| 5403 |
}
|
| 5404 |
header( 'location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $port . esc_url( $_POST['usces_referer'] ) . apply_filters( 'usces_filter_incart_redirect', '#cart_button', $post_id, $sku ) );
|
| 5405 |
} else {
|
| 5406 |
header( 'location: ' . esc_url( $_POST['usces_referer'] ) . apply_filters( 'usces_filter_incart_redirect', '#cart_button', $post_id, $sku ) );
|
| 5407 |
}
|
| 5408 |
exit;
|
| 5409 |
}
|
| 5410 |
|
| 5411 |
do_action( 'usces_action_incart_checked', $mes, $post_id, $sku );
|
| 5412 |
}
|
| 5413 |
|
| 5414 |
public function zaiko_check() {
|
| 5415 |
|
| 5416 |
$logged_in_member = $this->get_member();
|
| 5417 |
if ( ! empty( $logged_in_member['ID'] ) ) {
|
| 5418 |
if ( ! $this->member_exists( $logged_in_member['ID'] ) ) {
|
| 5419 |
$mes = __( 'Your membership information could not be verified.', 'usces' );
|
| 5420 |
$this->error_message = $mes;
|
| 5421 |
$this->member_logout();
|
| 5422 |
return $mes;
|
| 5423 |
}
|
| 5424 |
}
|
| 5425 |
|
| 5426 |
$mes = '';
|
| 5427 |
$cart = $this->cart->get_cart();
|
| 5428 |
$stocks = array();
|
| 5429 |
|
| 5430 |
$cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
|
| 5431 |
for ( $i = 0; $i < $cart_count; $i++ ) {
|
| 5432 |
$cart_row = $cart[ $i ];
|
| 5433 |
$post_id = $cart_row['post_id'];
|
| 5434 |
$sku = $cart_row['sku'];
|
| 5435 |
$sku_code = urldecode( $cart_row['sku'] );
|
| 5436 |
|
| 5437 |
$quant = ( isset( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) ) ? trim( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) : $cart_row['quantity'];
|
| 5438 |
$zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku_code );
|
| 5439 |
$stock = $this->getItemZaikoNum( $post_id, $sku_code );
|
| 5440 |
if ( ! isset( $stocks[ $post_id ][ $sku ] ) ) {
|
| 5441 |
if ( ! WCUtils::is_blank( $stock ) ) {
|
| 5442 |
$stocks[ $post_id ][ $sku ] = $stock;
|
| 5443 |
} else {
|
| 5444 |
$stocks[ $post_id ][ $sku ] = null;
|
| 5445 |
}
|
| 5446 |
}
|
| 5447 |
$checkstock = $stocks[ $post_id ][ $sku ];
|
| 5448 |
$stocks[ $post_id ][ $sku ] = $stocks[ $post_id ][ $sku ] - $quant;
|
| 5449 |
$product = wel_get_product( $post_id );
|
| 5450 |
$itemRestriction = $product['itemRestriction'];
|
| 5451 |
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
|
| 5452 |
$post_status = get_post_status( $post_id );
|
| 5453 |
|
| 5454 |
if ( 1 > (int) $quant ) {
|
| 5455 |
$mes .= sprintf( __( 'Enter the correct amount for the No.%d item.', 'usces' ), ( $i + 1 ) ) . '<br />';
|
| 5456 |
} elseif ( ! $this->is_item_zaiko( $post_id, $sku_code ) || ( 1 != $itemOrderAcceptable && WCUtils::is_zero( $stock ) ) || 'publish' != $post_status ) {
|
| 5457 |
$mes .= sprintf( __( 'Sorry, No.%d item is sold out.', 'usces' ), ( $i + 1 ) ) . '<br />';
|
| 5458 |
} elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) {
|
| 5459 |
$mes .= sprintf( __( 'This article is limited by %1$d at a time for the No.%2$d item.', 'usces' ), $itemRestriction, ( $i + 1 ) ) . '<br />';
|
| 5460 |
} elseif ( 1 != $itemOrderAcceptable && 0 > $stocks[ $post_id ][ $sku ] && ! WCUtils::is_blank( $stock ) ) {
|
| 5461 |
$mes .= sprintf( __( 'Stock of No.%1$d item is remainder %2$d.', 'usces' ), ( $i + 1 ), $checkstock ) . '<br />';
|
| 5462 |
}
|
| 5463 |
}
|
| 5464 |
$mes = apply_filters( 'usces_filter_zaiko_check', $mes, $cart);
|
| 5465 |
return $mes;
|
| 5466 |
}
|
| 5467 |
|
| 5468 |
/**
|
| 5469 |
* Check if the member exists in the database or not.
|
| 5470 |
*
|
| 5471 |
* @param integer $member_id The id of the member.
|
| 5472 |
* @return boolean true/false
|
| 5473 |
*/
|
| 5474 |
public function member_exists( $member_id ) {
|
| 5475 |
$member_info = $this->get_member_info( $member_id );
|
| 5476 |
if ( empty( $member_info ) ) {
|
| 5477 |
return false;
|
| 5478 |
} else {
|
| 5479 |
return true;
|
| 5480 |
}
|
| 5481 |
}
|
| 5482 |
|
| 5483 |
public function get_pwd_errors( $password ) {
|
| 5484 |
if ( WCUtils::is_blank( $password ) ) {
|
| 5485 |
return __( 'Please enter a password.', 'usces' ) . '<br />';
|
| 5486 |
}
|
| 5487 |
|
| 5488 |
$ret = '';
|
| 5489 |
$system_option = $this->options['system'];
|
| 5490 |
$pwd_rule_min = $system_option['member_pass_rule_min'];
|
| 5491 |
$pwd_rule_max = empty( $system_option['member_pass_rule_max'] ) ? 30 : $system_option['member_pass_rule_max'];
|
| 5492 |
if ( strlen( $password ) < $pwd_rule_min || strlen( $password ) > $pwd_rule_max ) {
|
| 5493 |
if ( $pwd_rule_min === $pwd_rule_max ) {
|
| 5494 |
$rule = sprintf( __( '%s characters long', 'usces' ), $pwd_rule_min );
|
| 5495 |
} else {
|
| 5496 |
$rule = sprintf( __( '%1$s characters and no more than %2$s characters', 'usces' ), $pwd_rule_min, $pwd_rule_max );
|
| 5497 |
}
|
| 5498 |
$ret .= sprintf( __( 'Password must be at least %s.', 'usces' ), $rule ) . '<br />';
|
| 5499 |
}
|
| 5500 |
if ( ! empty( $system_option['member_pass_rule_upercase'] ) && ! preg_match( '@[A-Z]@', $password ) ) {
|
| 5501 |
$ret .= __( 'Password must contain at least one upper-case alphabetics character.', 'usces' ) . '<br />';
|
| 5502 |
}
|
| 5503 |
if ( ! empty( $system_option['member_pass_rule_lowercase'] ) && ! preg_match( '@[a-z]@', $password ) ) {
|
| 5504 |
$ret .= __( 'Password must contain at least one lower-case alphabetics character.', 'usces' ) . '<br />';
|
| 5505 |
}
|
| 5506 |
if ( ! empty( $system_option['member_pass_rule_digit'] ) && ! preg_match( '@[0-9]@', $password ) ) {
|
| 5507 |
$ret .= __( 'Password must contain at least one numeric character.', 'usces' ) . '<br />';
|
| 5508 |
}
|
| 5509 |
if ( ! empty( $system_option['member_pass_rule_symbol'] ) && ! preg_match( '@[\W]@', $password ) ) {
|
| 5510 |
$ret .= __( 'Password must contain at least one symbolic character.', 'usces' ) . '<br />';
|
| 5511 |
}
|
| 5512 |
|
| 5513 |
return $ret;
|
| 5514 |
}
|
| 5515 |
|
| 5516 |
public function member_check() {
|
| 5517 |
do_action( 'usces_action_before_member_check' );
|
| 5518 |
|
| 5519 |
$mes = '';
|
| 5520 |
$usces_member_old = $_SESSION['usces_member'];
|
| 5521 |
foreach ( $_POST['member'] as $key => $vlue ) {
|
| 5522 |
if ( 'password1' !== $key && 'password2' !== $key && 'mailaddress2' !== $key ) {
|
| 5523 |
$_SESSION['usces_member'][ $key ] = trim( $vlue );
|
| 5524 |
}
|
| 5525 |
}
|
| 5526 |
|
| 5527 |
if ( 'newmemberform' == $_POST['member_regmode'] ||
|
| 5528 |
( 'editmemberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) ||
|
| 5529 |
( 'updatememberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) ) {
|
| 5530 |
$mes = $this->get_pwd_errors( $_POST['member']['password1'] );
|
| 5531 |
}
|
| 5532 |
|
| 5533 |
if ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) {
|
| 5534 |
if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) {
|
| 5535 |
$mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />';
|
| 5536 |
}
|
| 5537 |
if ( ! is_email( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress1'] ) ) {
|
| 5538 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5539 |
} else {
|
| 5540 |
$this->get_current_member();
|
| 5541 |
$mem_id = $this->current_member['id'];
|
| 5542 |
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
| 5543 |
if ( ! empty( $id ) && $id != $mem_id ) {
|
| 5544 |
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '<br />';
|
| 5545 |
} else {
|
| 5546 |
if ( isset( $_POST['member']['mailaddress2'] ) ) {
|
| 5547 |
if ( WCUtils::is_blank( $_POST['member']['mailaddress2'] ) ) {
|
| 5548 |
if ( $usces_member_old['mailaddress1'] !== $_POST['member']['mailaddress1'] ) {
|
| 5549 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5550 |
}
|
| 5551 |
} else {
|
| 5552 |
if ( trim( $_POST['member']['mailaddress1'] ) != trim( $_POST['member']['mailaddress2'] ) ) {
|
| 5553 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5554 |
}
|
| 5555 |
}
|
| 5556 |
}
|
| 5557 |
}
|
| 5558 |
}
|
| 5559 |
} elseif ( 'newmemberform' == $_POST['member_regmode'] ) {
|
| 5560 |
if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) {
|
| 5561 |
$mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />';
|
| 5562 |
}
|
| 5563 |
if ( ! is_email( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress2'] ) || trim( $_POST['member']['mailaddress1'] ) != trim( $_POST['member']['mailaddress2'] ) ) {
|
| 5564 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5565 |
} else {
|
| 5566 |
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
| 5567 |
if ( ! empty( $id ) ) {
|
| 5568 |
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '<br />';
|
| 5569 |
}
|
| 5570 |
}
|
| 5571 |
} else {
|
| 5572 |
$mes .= __( 'ERROR: I was not able to complete collective operation', 'usces' ) . '<br />';
|
| 5573 |
}
|
| 5574 |
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
|
| 5575 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5576 |
}
|
| 5577 |
|
| 5578 |
$zip_check = false;
|
| 5579 |
$addressform = $this->options['system']['addressform'];
|
| 5580 |
$applyform = usces_get_apply_addressform( $addressform );
|
| 5581 |
if ( 'JP' === $applyform ) {
|
| 5582 |
if ( isset( $_POST['member']['country'] ) ) {
|
| 5583 |
if ( 'JP' === $_POST['member']['country'] ) {
|
| 5584 |
$zip_check = true;
|
| 5585 |
}
|
| 5586 |
} else {
|
| 5587 |
$base = usces_get_base_country();
|
| 5588 |
if ( 'JP' === $base ) {
|
| 5589 |
$zip_check = true;
|
| 5590 |
}
|
| 5591 |
}
|
| 5592 |
}
|
| 5593 |
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
|
| 5594 |
if ( WCUtils::is_blank( $_POST['member']['zipcode'] ) ) {
|
| 5595 |
if ( usces_is_required_field('zipcode') ) {
|
| 5596 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5597 |
}
|
| 5598 |
} else {
|
| 5599 |
if ( $zip_check ) {
|
| 5600 |
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['member']['zipcode'] ) ) {
|
| 5601 |
$_SESSION['usces_member']['zipcode'] = usces_convert_zipcode( $_POST['member']['zipcode'] );
|
| 5602 |
}
|
| 5603 |
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_member']['zipcode'] ) ) {
|
| 5604 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5605 |
}
|
| 5606 |
}
|
| 5607 |
}
|
| 5608 |
if ( __( '-- Select --', 'usces_dual' ) == $_POST['member']['pref'] && usces_is_required_field( 'states' ) ) {
|
| 5609 |
$mes .= __( 'enter the prefecture', 'usces' ) . '<br />';
|
| 5610 |
}
|
| 5611 |
if ( WCUtils::is_blank( $_POST['member']['address1'] ) && usces_is_required_field( 'address1' ) ) {
|
| 5612 |
$mes .= __( 'enter the city name', 'usces' ) . '<br />';
|
| 5613 |
}
|
| 5614 |
if ( WCUtils::is_blank( $_POST['member']['address2'] ) && usces_is_required_field( 'address2' ) ) {
|
| 5615 |
$mes .= __( 'enter house numbers', 'usces' ) . '<br />';
|
| 5616 |
}
|
| 5617 |
if ( WCUtils::is_blank( $_POST['member']['tel'] ) && usces_is_required_field( 'tel' ) ) {
|
| 5618 |
$mes .= __( 'enter phone numbers', 'usces' ) . '<br />';
|
| 5619 |
}
|
| 5620 |
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
|
| 5621 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5622 |
}
|
| 5623 |
|
| 5624 |
if ( 'editmemberform' !== $_POST['member_regmode'] && 'updatememberform' !== $_POST['member_regmode'] && isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) {
|
| 5625 |
if ( ! isset( $_POST['agree_member_check'] ) ) {
|
| 5626 |
$mes .= __( 'Please accept the membership agreement.', 'usces' ) . '<br />';
|
| 5627 |
}
|
| 5628 |
}
|
| 5629 |
|
| 5630 |
$mes = apply_filters( 'usces_filter_member_check', $mes );
|
| 5631 |
|
| 5632 |
if ( ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) && '' != $mes ) {
|
| 5633 |
$_SESSION['usces_member'] = $usces_member_old;
|
| 5634 |
}
|
| 5635 |
|
| 5636 |
return $mes;
|
| 5637 |
}
|
| 5638 |
|
| 5639 |
public function member_check_fromcart() {
|
| 5640 |
|
| 5641 |
do_action( 'usces_action_before_member_check_fromcart' );
|
| 5642 |
|
| 5643 |
$mes = $this->get_pwd_errors( $_POST['customer']['password1'] );
|
| 5644 |
|
| 5645 |
if ( trim( $_POST['customer']['password1'] ) != trim( $_POST['customer']['password2'] ) ) {
|
| 5646 |
$mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />';
|
| 5647 |
}
|
| 5648 |
if ( ! is_email( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress2'] ) || trim( $_POST['customer']['mailaddress1'] ) != trim( $_POST['customer']['mailaddress2'] ) ) {
|
| 5649 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5650 |
}
|
| 5651 |
if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) {
|
| 5652 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5653 |
}
|
| 5654 |
$zip_check = false;
|
| 5655 |
$addressform = $this->options['system']['addressform'];
|
| 5656 |
$applyform = usces_get_apply_addressform( $addressform );
|
| 5657 |
if ( 'JP' === $applyform ) {
|
| 5658 |
if ( isset( $_POST['customer']['country'] ) ) {
|
| 5659 |
if ( 'JP' === $_POST['customer']['country'] ) {
|
| 5660 |
$zip_check = true;
|
| 5661 |
}
|
| 5662 |
} else {
|
| 5663 |
$base = usces_get_base_country();
|
| 5664 |
if ( 'JP' === $base ) {
|
| 5665 |
$zip_check = true;
|
| 5666 |
}
|
| 5667 |
}
|
| 5668 |
}
|
| 5669 |
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
|
| 5670 |
if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) {
|
| 5671 |
if ( usces_is_required_field( 'zipcode' ) ) {
|
| 5672 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5673 |
}
|
| 5674 |
} else {
|
| 5675 |
if ( $zip_check ) {
|
| 5676 |
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) {
|
| 5677 |
$_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] );
|
| 5678 |
}
|
| 5679 |
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) {
|
| 5680 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5681 |
}
|
| 5682 |
}
|
| 5683 |
}
|
| 5684 |
if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) {
|
| 5685 |
$mes .= __( 'enter the prefecture', 'usces' ) . '<br />';
|
| 5686 |
}
|
| 5687 |
if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) {
|
| 5688 |
$mes .= __( 'enter the city name', 'usces' ) . '<br />';
|
| 5689 |
}
|
| 5690 |
if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) {
|
| 5691 |
$mes .= __( 'enter house numbers', 'usces' ) . '<br />';
|
| 5692 |
}
|
| 5693 |
if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) {
|
| 5694 |
$mes .= __( 'enter phone numbers', 'usces' ) . '<br />';
|
| 5695 |
}
|
| 5696 |
if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
|
| 5697 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5698 |
}
|
| 5699 |
|
| 5700 |
if ( isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) {
|
| 5701 |
if ( ! isset( $_POST['agree_member_check'] ) ) {
|
| 5702 |
$mes .= __( 'Please accept the membership agreement.', 'usces' ) . '<br />';
|
| 5703 |
}
|
| 5704 |
}
|
| 5705 |
|
| 5706 |
$mes = apply_filters( 'usces_filter_member_check_fromcart', $mes );
|
| 5707 |
|
| 5708 |
return $mes;
|
| 5709 |
}
|
| 5710 |
|
| 5711 |
public function admin_member_check() {
|
| 5712 |
global $wpdb;
|
| 5713 |
$mes = '';
|
| 5714 |
if ( ! is_email( trim( $_POST['member']['email'] ) ) ) {
|
| 5715 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5716 |
} else {
|
| 5717 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 5718 |
$mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) );
|
| 5719 |
if ( trim( $_POST['member']['email'] ) != $mem_email ) {
|
| 5720 |
$mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) );
|
| 5721 |
if ( ! empty( $mem_ID ) ) {
|
| 5722 |
$mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '<br />';
|
| 5723 |
}
|
| 5724 |
}
|
| 5725 |
}
|
| 5726 |
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
|
| 5727 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5728 |
}
|
| 5729 |
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) {
|
| 5730 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5731 |
}
|
| 5732 |
$mes = apply_filters( 'usces_filter_admin_member_check', $mes );
|
| 5733 |
|
| 5734 |
return $mes;
|
| 5735 |
}
|
| 5736 |
|
| 5737 |
public function customer_check() {
|
| 5738 |
|
| 5739 |
do_action( 'usces_action_before_customer_check' );
|
| 5740 |
|
| 5741 |
$mes = '';
|
| 5742 |
if ( ! is_email( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress1'] ) || WCUtils::is_blank( $_POST['customer']['mailaddress2'] ) || trim( $_POST['customer']['mailaddress1'] ) != trim( $_POST['customer']['mailaddress2'] ) ) {
|
| 5743 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5744 |
}
|
| 5745 |
if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) {
|
| 5746 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5747 |
}
|
| 5748 |
$zip_check = false;
|
| 5749 |
$addressform = $this->options['system']['addressform'];
|
| 5750 |
$applyform = usces_get_apply_addressform( $addressform );
|
| 5751 |
if ( 'JP' === $applyform ) {
|
| 5752 |
if ( isset( $_POST['customer']['country'] ) ) {
|
| 5753 |
if ( 'JP' === $_POST['customer']['country'] ) {
|
| 5754 |
$zip_check = true;
|
| 5755 |
}
|
| 5756 |
} else {
|
| 5757 |
$base = usces_get_base_country();
|
| 5758 |
if ( 'JP' === $base ) {
|
| 5759 |
$zip_check = true;
|
| 5760 |
}
|
| 5761 |
}
|
| 5762 |
}
|
| 5763 |
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
|
| 5764 |
if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) {
|
| 5765 |
if ( usces_is_required_field( 'zipcode' ) ) {
|
| 5766 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5767 |
}
|
| 5768 |
} else {
|
| 5769 |
if ( $zip_check ) {
|
| 5770 |
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) {
|
| 5771 |
$_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] );
|
| 5772 |
}
|
| 5773 |
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) {
|
| 5774 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5775 |
}
|
| 5776 |
}
|
| 5777 |
}
|
| 5778 |
if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) {
|
| 5779 |
$mes .= __( 'enter the prefecture', 'usces' ) . '<br />';
|
| 5780 |
}
|
| 5781 |
if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) {
|
| 5782 |
$mes .= __( 'enter the city name', 'usces' ) . '<br />';
|
| 5783 |
}
|
| 5784 |
if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) {
|
| 5785 |
$mes .= __( 'enter house numbers', 'usces' ) . '<br />';
|
| 5786 |
}
|
| 5787 |
if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) {
|
| 5788 |
$mes .= __( 'enter phone numbers', 'usces' ) . '<br />';
|
| 5789 |
}
|
| 5790 |
if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
|
| 5791 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5792 |
}
|
| 5793 |
|
| 5794 |
$mes = apply_filters( 'usces_filter_customer_check', $mes );
|
| 5795 |
|
| 5796 |
return $mes;
|
| 5797 |
}
|
| 5798 |
|
| 5799 |
public function admin_new_member_check() {
|
| 5800 |
global $wpdb;
|
| 5801 |
|
| 5802 |
$mes = $this->get_pwd_errors( $_POST['member']['password'] );
|
| 5803 |
|
| 5804 |
if ( ! is_email( trim( $_POST['member']['email'] ) ) ) {
|
| 5805 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 5806 |
} else {
|
| 5807 |
$member_table = usces_get_tablename( 'usces_member' );
|
| 5808 |
$mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) );
|
| 5809 |
if ( trim( $_POST['member']['email'] ) != $mem_email ) {
|
| 5810 |
$mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) );
|
| 5811 |
if ( ! empty( $mem_ID ) ) {
|
| 5812 |
$mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '<br />';
|
| 5813 |
}
|
| 5814 |
}
|
| 5815 |
}
|
| 5816 |
|
| 5817 |
if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) {
|
| 5818 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5819 |
}
|
| 5820 |
if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) {
|
| 5821 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5822 |
}
|
| 5823 |
$mes = apply_filters( 'usces_filter_admin_member_check', $mes );
|
| 5824 |
|
| 5825 |
return $mes;
|
| 5826 |
}
|
| 5827 |
|
| 5828 |
public function delivery_check() {
|
| 5829 |
global $usces_settings;
|
| 5830 |
|
| 5831 |
do_action( 'usces_action_before_delivery_check' );
|
| 5832 |
|
| 5833 |
$mes = '';
|
| 5834 |
if ( isset( $_POST['delivery']['delivery_flag'] ) && 1 === (int) $_POST['delivery']['delivery_flag'] ) {
|
| 5835 |
if ( WCUtils::is_blank( $_POST['delivery']['name1'] ) ) {
|
| 5836 |
$mes .= __( 'Name is not correct', 'usces' ) . '<br />';
|
| 5837 |
}
|
| 5838 |
$zip_check = false;
|
| 5839 |
$addressform = $this->options['system']['addressform'];
|
| 5840 |
$applyform = usces_get_apply_addressform( $addressform );
|
| 5841 |
if ( 'JP' === $applyform ) {
|
| 5842 |
if ( isset( $_POST['delivery']['country'] ) ) {
|
| 5843 |
if ( 'JP' === $_POST['delivery']['country'] ) {
|
| 5844 |
$zip_check = true;
|
| 5845 |
}
|
| 5846 |
} else {
|
| 5847 |
$base = usces_get_base_country();
|
| 5848 |
if ( 'JP' === $base ) {
|
| 5849 |
$zip_check = true;
|
| 5850 |
}
|
| 5851 |
}
|
| 5852 |
}
|
| 5853 |
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
|
| 5854 |
if ( WCUtils::is_blank( $_POST['delivery']['zipcode'] ) ) {
|
| 5855 |
if ( usces_is_required_field( 'zipcode' ) ) {
|
| 5856 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5857 |
}
|
| 5858 |
} else {
|
| 5859 |
if ( $zip_check ) {
|
| 5860 |
if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['delivery']['zipcode'] ) ) {
|
| 5861 |
$_SESSION['usces_entry']['delivery']['zipcode'] = usces_convert_zipcode( $_POST['delivery']['zipcode'] );
|
| 5862 |
}
|
| 5863 |
if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['delivery']['zipcode'] ) ) {
|
| 5864 |
$mes .= __( 'postal code is not correct', 'usces' ) . '<br />';
|
| 5865 |
}
|
| 5866 |
}
|
| 5867 |
}
|
| 5868 |
if ( ( __( '-- Select --', 'usces' ) == $_POST['delivery']['pref'] || '-- Select --' == $_POST['delivery']['pref'] ) && usces_is_required_field( 'states' ) ) {
|
| 5869 |
$mes .= __( 'enter the prefecture', 'usces' ) . '<br />';
|
| 5870 |
}
|
| 5871 |
if ( WCUtils::is_blank( $_POST['delivery']['address1'] ) && usces_is_required_field( 'address1' ) ) {
|
| 5872 |
$mes .= __( 'enter the city name', 'usces' ) . '<br />';
|
| 5873 |
}
|
| 5874 |
if ( WCUtils::is_blank( $_POST['delivery']['address2'] ) && usces_is_required_field( 'address2' ) ) {
|
| 5875 |
$mes .= __( 'enter house numbers', 'usces' ) . '<br />';
|
| 5876 |
}
|
| 5877 |
if ( WCUtils::is_blank( $_POST['delivery']['tel'] ) && usces_is_required_field( 'tel' ) ) {
|
| 5878 |
$mes .= __( 'enter phone numbers', 'usces' ) . '<br />';
|
| 5879 |
}
|
| 5880 |
if ( ! WCUtils::is_blank( $_POST['delivery']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['delivery']['tel'] ) ) && usces_is_required_field( 'tel' ) ) {
|
| 5881 |
$mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />';
|
| 5882 |
}
|
| 5883 |
$post_offer = filter_input( INPUT_POST, 'offer', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
| 5884 |
if ( ! empty( $post_offer['delivery_date'] ) && usces_is_date( $post_offer['delivery_date'] ) && isset( $post_offer['delivery_method'] ) ) {
|
| 5885 |
$post_delivery = filter_input( INPUT_POST, 'delivery', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
|
| 5886 |
$deli_method_index = $this->get_delivery_method_index( $post_offer['delivery_method'] );
|
| 5887 |
$delivery_days_id = isset( $this->options['delivery_method'][ $deli_method_index ]['days'] ) ? $this->options['delivery_method'][ $deli_method_index ]['days'] : -1;
|
| 5888 |
if ( 0 <= $delivery_days_id ) {
|
| 5889 |
$delivery_days_list = $this->options['delivery_days'];
|
| 5890 |
$delivery_days = 0;
|
| 5891 |
foreach ( (array) $delivery_days_list as $delivery_days_value ) {
|
| 5892 |
if ( (int) $delivery_days_value['id'] === (int) $delivery_days_id ) {
|
| 5893 |
$delivery_days = (int) $delivery_days_value[ $applyform ][ $post_delivery['pref'] ];
|
| 5894 |
}
|
| 5895 |
}
|
| 5896 |
$sendout = usces_get_send_out_date();
|
| 5897 |
$sendout_date = implode( '-', $sendout['sendout_date'] );
|
| 5898 |
$arrival_date = new DateTime( $sendout_date );
|
| 5899 |
$arrival_date->modify( '+' . $delivery_days . ' days' );
|
| 5900 |
$offer_deli_date = new DateTime( $post_offer['delivery_date'] );
|
| 5901 |
if ( $offer_deli_date < $arrival_date ) {
|
| 5902 |
$mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '<br />';
|
| 5903 |
}
|
| 5904 |
} else {
|
| 5905 |
$mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '<br />';
|
| 5906 |
}
|
| 5907 |
}
|
| 5908 |
}
|
| 5909 |
if ( ! isset( $_POST['offer']['delivery_method'] ) || ( empty( $_POST['offer']['delivery_method'] ) && ! WCUtils::is_zero( $_POST['offer']['delivery_method'] ) ) ) {
|
| 5910 |
$mes .= __( 'chose one from delivery method.', 'usces' ) . '<br />';
|
| 5911 |
} else {
|
| 5912 |
$d_method_index = $this->get_delivery_method_index( (int) $_POST['offer']['delivery_method'] );
|
| 5913 |
if ( 0 > $d_method_index ) {
|
| 5914 |
$mes .= __( 'chose one from delivery method.', 'usces' ) . '<br />';
|
| 5915 |
} elseif ( isset( $_SESSION['usces_entry']['delivery']['country'] ) ) {
|
| 5916 |
$country = $_SESSION['usces_entry']['delivery']['country'];
|
| 5917 |
$current_locate = get_locale();
|
| 5918 |
$wplang = get_option( 'WPLANG', $current_locate );
|
| 5919 |
$local_country = $usces_settings['lungage2country'][ $wplang ];
|
| 5920 |
|
| 5921 |
if ( $country == $local_country ) {
|
| 5922 |
if ( 1 == $this->options['delivery_method'][ $d_method_index ]['intl'] ) {
|
| 5923 |
$mes .= __( 'Delivery method is incorrect. Can not specify an international flight.', 'usces' ) . '<br />';
|
| 5924 |
}
|
| 5925 |
} else {
|
| 5926 |
if ( WCUtils::is_zero( $this->options['delivery_method'][ $d_method_index ]['intl'] ) ) {
|
| 5927 |
$mes .= __( 'Delivery method is incorrect. Specify the international flights.', 'usces' ) . '<br />';
|
| 5928 |
}
|
| 5929 |
}
|
| 5930 |
}
|
| 5931 |
}
|
| 5932 |
if ( ! isset( $_POST['offer']['payment_name'] ) ) {
|
| 5933 |
$mes .= __( 'chose one from payment options.', 'usces' ) . '<br />';
|
| 5934 |
} else {
|
| 5935 |
$payments = $this->getPayments( $_POST['offer']['payment_name'] );
|
| 5936 |
if ( 'COD' == $payments['settlement'] ) {
|
| 5937 |
$total_items_price = $this->get_total_price();
|
| 5938 |
$usces_entries = $this->cart->get_entry();
|
| 5939 |
$materials = array(
|
| 5940 |
'total_items_price' => $usces_entries['order']['total_items_price'],
|
| 5941 |
'discount' => ( isset( $usces_entries['order']['discount'] ) ) ? $usces_entries['order']['discount'] : 0,
|
| 5942 |
'shipping_charge' => $usces_entries['order']['shipping_charge'],
|
| 5943 |
'cod_fee' => $usces_entries['order']['cod_fee'],
|
| 5944 |
'use_point' => ( isset( $usces_entries['order']['use_point'] ) ) ? $usces_entries['order']['use_point'] : 0,
|
| 5945 |
);
|
| 5946 |
$tax = $this->getTax( $total_items_price, $materials );
|
| 5947 |
$total_items_price = $total_items_price + $tax;
|
| 5948 |
$cod_limit_amount = ( isset( $this->options['cod_limit_amount'] ) && 0 < (int) $this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
|
| 5949 |
if ( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount ) {
|
| 5950 |
$mes .= sprintf( __( 'A total products amount of money surpasses the upper limit(%s) that I can purchase in C.O.D.', 'usces' ), usces_crform( $this->options['cod_limit_amount'], true, false, 'return' ) ) . '<br />';
|
| 5951 |
}
|
| 5952 |
}
|
| 5953 |
}
|
| 5954 |
if ( isset( $d_method_index ) && isset( $payments ) ) {
|
| 5955 |
if ( 1 == $this->options['delivery_method'][ $d_method_index ]['nocod'] ) {
|
| 5956 |
if ( 'COD' == $payments['settlement'] ) {
|
| 5957 |
$mes .= __( 'COD is not available.', 'usces' ) . '<br />';
|
| 5958 |
}
|
| 5959 |
}
|
| 5960 |
}
|
| 5961 |
$mes = apply_filters( 'usces_filter_delivery_check', $mes );
|
| 5962 |
return $mes;
|
| 5963 |
}
|
| 5964 |
|
| 5965 |
public function point_check( $entries ) {
|
| 5966 |
$member = $this->get_member();
|
| 5967 |
$this->set_cart_fees( $member, $entries );
|
| 5968 |
|
| 5969 |
$mes = '';
|
| 5970 |
if ( isset( $_POST['offer']['usedpoint'] ) ) {
|
| 5971 |
if ( WCUtils::is_blank( $_POST['offer']['usedpoint'] ) || ! preg_match( '/^[0-9]+$/', $_POST['offer']['usedpoint'] ) || (int) $_POST['offer']['usedpoint'] < 0 ) {
|
| 5972 |
$mes .= __( 'Invalid value. Please enter in the numbers.', 'usces' ) . '<br />';
|
| 5973 |
|
| 5974 |
} else {
|
| 5975 |
$payments = $this->getPayments( $entries['order']['payment_name'] );
|
| 5976 |
$usedpoint = (int) trim( $_POST['offer']['usedpoint'] );
|
| 5977 |
if ( $usedpoint > $member['point'] ) {
|
| 5978 |
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $member['point'] . ' ' . __( 'points', 'usces' ) . '<br />';
|
| 5979 |
|
| 5980 |
} elseif ( 'acting_paypal_ec' == $payments['settlement'] ) {
|
| 5981 |
$target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax'];
|
| 5982 |
$target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount'];
|
| 5983 |
if ( 1 == $this->options['point_coverage'] && $usedpoint >= $target_full_price ) {
|
| 5984 |
$target_item_price = $target_full_price;
|
| 5985 |
} elseif ( 'products' == $this->options['tax_target'] ) {
|
| 5986 |
$target_item_price += $entries['order']['tax'];
|
| 5987 |
}
|
| 5988 |
if ( $usedpoint > $target_item_price ) {
|
| 5989 |
$mes .= __( "In the case of settlement method you choose, the upper limit of the point you'll find that will change. If you became a settlement error, please reduce the point that you want to use.", 'usces' ) . '<br />';
|
| 5990 |
}
|
| 5991 |
|
| 5992 |
} else {
|
| 5993 |
if ( 1 == $this->options['point_coverage'] ) {
|
| 5994 |
$target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax'];
|
| 5995 |
if ( $usedpoint > $target_full_price ) {
|
| 5996 |
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_full_price . ' ' . __( 'points', 'usces' ) . '<br />';
|
| 5997 |
}
|
| 5998 |
} else {
|
| 5999 |
$target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount'];
|
| 6000 |
if ( 'products' == $this->options['tax_target'] ) {
|
| 6001 |
$target_item_price += $entries['order']['tax'];
|
| 6002 |
}
|
| 6003 |
if ( $usedpoint > $target_item_price ) {
|
| 6004 |
$mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_item_price . ' ' . __( 'points', 'usces' ) . '<br />';
|
| 6005 |
}
|
| 6006 |
}
|
| 6007 |
}
|
| 6008 |
$mes = apply_filters( 'usces_filter_point_check', $mes );
|
| 6009 |
if ( '' != $mes ) {
|
| 6010 |
$_POST['offer']['usedpoint'] = 0;
|
| 6011 |
$array = array(
|
| 6012 |
'usedpoint' => 0,
|
| 6013 |
);
|
| 6014 |
$this->cart->set_order_entry( $array );
|
| 6015 |
}
|
| 6016 |
}
|
| 6017 |
}
|
| 6018 |
$mes = apply_filters( 'usces_filter_point_check_last', $mes );
|
| 6019 |
return $mes;
|
| 6020 |
}
|
| 6021 |
|
| 6022 |
public function lostpass_mailaddcheck() {
|
| 6023 |
$mes = '';
|
| 6024 |
if ( ! is_email( $_POST['loginmail'] ) || WCUtils::is_blank( $_POST['loginmail'] ) ) {
|
| 6025 |
$mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />';
|
| 6026 |
}
|
| 6027 |
|
| 6028 |
return $mes;
|
| 6029 |
}
|
| 6030 |
|
| 6031 |
public function changepass_check() {
|
| 6032 |
$mes = $this->get_pwd_errors( $_POST['loginpass1'] );
|
| 6033 |
|
| 6034 |
if ( trim( $_POST['loginpass1'] ) != trim( $_POST['loginpass2'] ) ) {
|
| 6035 |
$mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />';
|
| 6036 |
}
|
| 6037 |
|
| 6038 |
return $mes;
|
| 6039 |
}
|
| 6040 |
|
| 6041 |
public function get_page() {
|
| 6042 |
return $this->page;
|
| 6043 |
}
|
| 6044 |
|
| 6045 |
public function check_display_mode() {
|
| 6046 |
$options = get_option( 'usces' );
|
| 6047 |
if ( isset( $options['display_mode'] ) && 'Maintenancemode' == $options['display_mode'] ) {
|
| 6048 |
return;
|
| 6049 |
}
|
| 6050 |
|
| 6051 |
$start['hour'] = empty( $options['campaign_schedule']['start']['hour'] ) ? 0 : $options['campaign_schedule']['start']['hour'];
|
| 6052 |
$start['min'] = empty( $options['campaign_schedule']['start']['min'] ) ? 0 : $options['campaign_schedule']['start']['min'];
|
| 6053 |
$start['month'] = empty( $options['campaign_schedule']['start']['month'] ) ? 0 : $options['campaign_schedule']['start']['month'];
|
| 6054 |
$start['day'] = empty( $options['campaign_schedule']['start']['day'] ) ? 0 : $options['campaign_schedule']['start']['day'];
|
| 6055 |
$start['year'] = empty( $options['campaign_schedule']['start']['year'] ) ? 0 : $options['campaign_schedule']['start']['year'];
|
| 6056 |
$end['hour'] = empty( $options['campaign_schedule']['end']['hour'] ) ? 0 : $options['campaign_schedule']['end']['hour'];
|
| 6057 |
$end['min'] = empty( $options['campaign_schedule']['end']['min'] ) ? 0 : $options['campaign_schedule']['end']['min'];
|
| 6058 |
$end['month'] = empty( $options['campaign_schedule']['end']['month'] ) ? 0 : $options['campaign_schedule']['end']['month'];
|
| 6059 |
$end['day'] = empty( $options['campaign_schedule']['end']['day'] ) ? 0 : $options['campaign_schedule']['end']['day'];
|
| 6060 |
$end['year'] = empty( $options['campaign_schedule']['end']['year'] ) ? 0 : $options['campaign_schedule']['end']['year'];
|
| 6061 |
$starttime = mktime( $start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year'] );
|
| 6062 |
$endtime = mktime( $end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year'] );
|
| 6063 |
$current_time = current_time( 'timestamp' );
|
| 6064 |
|
| 6065 |
if ( ( $current_time >= $starttime ) && ( $current_time <= $endtime ) ) {
|
| 6066 |
$options['display_mode'] = 'Promotionsale';
|
| 6067 |
} else {
|
| 6068 |
$options['display_mode'] = 'Usualsale';
|
| 6069 |
}
|
| 6070 |
update_option( 'usces', $options );
|
| 6071 |
}
|
| 6072 |
|
| 6073 |
public function update_business_days() {
|
| 6074 |
$options = get_option( 'usces' );
|
| 6075 |
$datetimestr = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) );
|
| 6076 |
$dhour = (int) substr( $datetimestr, 11, 2 );
|
| 6077 |
$dminute = (int) substr( $datetimestr, 14, 2 );
|
| 6078 |
$dsecond = (int) substr( $datetimestr, 17, 2 );
|
| 6079 |
$dmonth = (int) substr( $datetimestr, 5, 2 );
|
| 6080 |
$dday = (int) substr( $datetimestr, 8, 2 );
|
| 6081 |
$dyear = (int) substr( $datetimestr, 0, 4 );
|
| 6082 |
$dtimestamp = mktime( $dhour, $dminute, $dsecond, $dmonth, $dday, $dyear );
|
| 6083 |
$datenow = getdate( $dtimestamp );
|
| 6084 |
list( $year, $mon, $mday ) = getBeforeMonth( $datenow['year'], $datenow['mon'], 1, 1 );
|
| 6085 |
|
| 6086 |
if ( isset( $options['business_days'][ $year ][ $mon ][1] ) ) {
|
| 6087 |
unset( $options['business_days'][ $year ][ $mon ] );
|
| 6088 |
}
|
| 6089 |
|
| 6090 |
for ( $i = 0; $i < 12; $i++ ) {
|
| 6091 |
list( $year, $mon, $mday ) = getAfterMonth( $datenow['year'], $datenow['mon'], 1, $i );
|
| 6092 |
$last = getLastDay( $year, $mon );
|
| 6093 |
for ( $j = 1; $j <= $last; $j++ ) {
|
| 6094 |
if ( ! isset( $options['business_days'][ $year ][ $mon ][ $j ] ) ) {
|
| 6095 |
$options['business_days'][ $year ][ $mon ][ $j ] = 1;
|
| 6096 |
}
|
| 6097 |
}
|
| 6098 |
}
|
| 6099 |
update_option( 'usces', $options );
|
| 6100 |
$this->options = get_option( 'usces' );
|
| 6101 |
$_SESSION['usces_checked_business_days'] = '';
|
| 6102 |
}
|
| 6103 |
|
| 6104 |
public function display_cart() {
|
| 6105 |
if ( $this->cart->num_row() > 0 ) {
|
| 6106 |
// include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
|
| 6107 |
} else {
|
| 6108 |
echo "<div class='no_cart'>" . __( 'There are no items in your cart.', 'usces' ) . "</div>\n";
|
| 6109 |
}
|
| 6110 |
}
|
| 6111 |
|
| 6112 |
public function display_cart_confirm() {
|
| 6113 |
if ( $this->cart->num_row() > 0 ) {
|
| 6114 |
// include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
|
| 6115 |
} else {
|
| 6116 |
echo "<div class='no_cart'>" . __( 'There are no items in your cart.', 'usces' ) . "</div>\n";
|
| 6117 |
}
|
| 6118 |
}
|
| 6119 |
|
| 6120 |
public function set_initial() {
|
| 6121 |
$this->set_default_page();
|
| 6122 |
$this->set_default_categories();
|
| 6123 |
$this->create_table();
|
| 6124 |
$this->update_table();
|
| 6125 |
$rets07 = usces_upgrade_07();
|
| 6126 |
if ( $rets07 ) {
|
| 6127 |
$rets11 = usces_upgrade_11();
|
| 6128 |
}
|
| 6129 |
if ( $rets11 ) {
|
| 6130 |
$rets14 = usces_upgrade_14();
|
| 6131 |
}
|
| 6132 |
if ( $rets14 ) {
|
| 6133 |
$rets141 = usces_upgrade_141();
|
| 6134 |
}
|
| 6135 |
if ( $rets141 ) {
|
| 6136 |
$rets143 = usces_upgrade_143();
|
| 6137 |
}
|
| 6138 |
$this->update_options();
|
| 6139 |
usces_schedule_event();
|
| 6140 |
do_action( 'usces_on_plugin_activate' );
|
| 6141 |
}
|
| 6142 |
|
| 6143 |
public function deactivate() {
|
| 6144 |
wp_clear_scheduled_hook( 'wc_cron' );
|
| 6145 |
wp_clear_scheduled_hook( 'wc_cron_w' );
|
| 6146 |
usces_wcsite_deactivate();
|
| 6147 |
}
|
| 6148 |
|
| 6149 |
public function create_table() {
|
| 6150 |
global $wpdb;
|
| 6151 |
|
| 6152 |
if ( ! empty( $wpdb->charset ) ) {
|
| 6153 |
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
| 6154 |
}
|
| 6155 |
if ( ! empty( $wpdb->collate ) ) {
|
| 6156 |
$charset_collate .= " COLLATE $wpdb->collate";
|
| 6157 |
}
|
| 6158 |
$access_table = $wpdb->prefix . 'usces_access';
|
| 6159 |
$member_table = $wpdb->prefix . 'usces_member';
|
| 6160 |
$member_meta_table = $wpdb->prefix . 'usces_member_meta';
|
| 6161 |
$order_table = $wpdb->prefix . 'usces_order';
|
| 6162 |
$order_meta_table = $wpdb->prefix . 'usces_order_meta';
|
| 6163 |
$ordercart_table = $wpdb->prefix . 'usces_ordercart';
|
| 6164 |
$ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta';
|
| 6165 |
$log_table = $wpdb->prefix . 'usces_log';
|
| 6166 |
$acting_log_table = $wpdb->prefix . 'usces_acting_log';
|
| 6167 |
$item_table = $wpdb->prefix . 'usces_item';
|
| 6168 |
$sku_table = $wpdb->prefix . 'usces_skus';
|
| 6169 |
$opt_table = $wpdb->prefix . 'usces_opts';
|
| 6170 |
$admin_log_table = $wpdb->prefix . 'usces_admin_log';
|
| 6171 |
|
| 6172 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6173 |
|
| 6174 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$access_table'" ) != $access_table ) {
|
| 6175 |
$sql = 'CREATE TABLE ' . $access_table . " (
|
| 6176 |
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6177 |
acc_key VARCHAR( 50 ) NOT NULL ,
|
| 6178 |
acc_type VARCHAR( 50 ) NULL ,
|
| 6179 |
acc_value LONGTEXT NULL ,
|
| 6180 |
acc_date DATE NOT NULL DEFAULT '0000-00-00',
|
| 6181 |
acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
|
| 6182 |
acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
|
| 6183 |
acc_str1 VARCHAR( 200 ) NULL ,
|
| 6184 |
acc_str2 VARCHAR( 200 ) NULL ,
|
| 6185 |
PRIMARY KEY (`ID`),
|
| 6186 |
KEY acc_key ( acc_key ),
|
| 6187 |
KEY acc_type ( acc_type ),
|
| 6188 |
KEY acc_date ( acc_date ),
|
| 6189 |
KEY acc_num1 ( acc_num1 ),
|
| 6190 |
KEY acc_num2 ( acc_num2 )
|
| 6191 |
) AUTO_INCREMENT=0 $charset_collate;";
|
| 6192 |
dbDelta( $sql );
|
| 6193 |
add_option( 'usces_db_access', USCES_DB_ACCESS );
|
| 6194 |
}
|
| 6195 |
|
| 6196 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$member_table'" ) != $member_table ) {
|
| 6197 |
$sql = 'CREATE TABLE ' . $member_table . " (
|
| 6198 |
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6199 |
mem_email VARCHAR( 100 ) NOT NULL ,
|
| 6200 |
mem_pass VARCHAR( 64 ) NOT NULL ,
|
| 6201 |
mem_status INT( 11 ) NOT NULL DEFAULT '0',
|
| 6202 |
mem_cookie VARCHAR( 13 ) NULL ,
|
| 6203 |
mem_point INT( 11 ) NOT NULL DEFAULT '0',
|
| 6204 |
mem_name1 VARCHAR( 100 ) NOT NULL ,
|
| 6205 |
mem_name2 VARCHAR( 100 ) NULL ,
|
| 6206 |
mem_name3 VARCHAR( 100 ) NULL ,
|
| 6207 |
mem_name4 VARCHAR( 100 ) NULL ,
|
| 6208 |
mem_zip VARCHAR( 50 ) NULL ,
|
| 6209 |
mem_pref VARCHAR( 100 ) NOT NULL ,
|
| 6210 |
mem_address1 VARCHAR( 100 ) NOT NULL ,
|
| 6211 |
mem_address2 VARCHAR( 100 ) NULL ,
|
| 6212 |
mem_address3 VARCHAR( 100 ) NULL ,
|
| 6213 |
mem_tel VARCHAR( 100 ) NOT NULL ,
|
| 6214 |
mem_fax VARCHAR( 100 ) NULL ,
|
| 6215 |
mem_delivery_flag TINYINT ( 1 ) NULL ,
|
| 6216 |
mem_delivery LONGTEXT,
|
| 6217 |
mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6218 |
mem_nicename VARCHAR( 50 ) NULL ,
|
| 6219 |
PRIMARY KEY (`ID`),
|
| 6220 |
KEY mem_email ( mem_email ) ,
|
| 6221 |
KEY mem_pass ( mem_pass )
|
| 6222 |
) AUTO_INCREMENT=1000 $charset_collate;";
|
| 6223 |
dbDelta( $sql );
|
| 6224 |
add_option( 'usces_db_member', USCES_DB_MEMBER );
|
| 6225 |
}
|
| 6226 |
|
| 6227 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$member_meta_table'" ) != $member_meta_table ) {
|
| 6228 |
$sql = 'CREATE TABLE ' . $member_meta_table . " (
|
| 6229 |
mmeta_id bigint(20) NOT NULL auto_increment,
|
| 6230 |
member_id bigint(20) NOT NULL default '0',
|
| 6231 |
meta_key varchar(255) default NULL,
|
| 6232 |
meta_value longtext,
|
| 6233 |
PRIMARY KEY (mmeta_id),
|
| 6234 |
KEY order_id (member_id),
|
| 6235 |
KEY meta_key (meta_key(191))
|
| 6236 |
) $charset_collate;";
|
| 6237 |
dbDelta( $sql );
|
| 6238 |
add_option( 'usces_db_member_meta', USCES_DB_MEMBER_META );
|
| 6239 |
}
|
| 6240 |
|
| 6241 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$order_table'" ) != $order_table ) {
|
| 6242 |
$sql = 'CREATE TABLE ' . $order_table . " (
|
| 6243 |
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6244 |
mem_id BIGINT( 20 ) UNSIGNED NULL ,
|
| 6245 |
order_email VARCHAR( 100 ) NOT NULL ,
|
| 6246 |
order_name1 VARCHAR( 100 ) NOT NULL ,
|
| 6247 |
order_name2 VARCHAR( 100 ) NULL ,
|
| 6248 |
order_name3 VARCHAR( 100 ) NULL ,
|
| 6249 |
order_name4 VARCHAR( 100 ) NULL ,
|
| 6250 |
order_zip VARCHAR( 50 ) NULL ,
|
| 6251 |
order_pref VARCHAR( 100 ) NOT NULL ,
|
| 6252 |
order_address1 VARCHAR( 100 ) NOT NULL ,
|
| 6253 |
order_address2 VARCHAR( 100 ) NULL ,
|
| 6254 |
order_address3 VARCHAR( 100 ) NULL ,
|
| 6255 |
order_tel VARCHAR( 100 ) NOT NULL ,
|
| 6256 |
order_fax VARCHAR( 100 ) NULL ,
|
| 6257 |
order_delivery LONGTEXT,
|
| 6258 |
order_cart LONGTEXT,
|
| 6259 |
order_note TEXT,
|
| 6260 |
order_delivery_time VARCHAR( 100 ) NOT NULL ,
|
| 6261 |
order_payment_name VARCHAR( 100 ) NOT NULL ,
|
| 6262 |
order_condition TEXT,
|
| 6263 |
order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
|
| 6264 |
order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
|
| 6265 |
order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
|
| 6266 |
order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
|
| 6267 |
order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
|
| 6268 |
order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
|
| 6269 |
order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
|
| 6270 |
order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6271 |
order_modified VARCHAR( 20 ) NULL ,
|
| 6272 |
order_status VARCHAR( 255 ) NULL ,
|
| 6273 |
order_check TEXT NULL ,
|
| 6274 |
order_delidue_date VARCHAR( 30 ) NULL ,
|
| 6275 |
order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
|
| 6276 |
order_delivery_date VARCHAR( 100 ) NULL,
|
| 6277 |
PRIMARY KEY (`ID`),
|
| 6278 |
KEY order_email ( order_email ) ,
|
| 6279 |
KEY order_name1 ( order_name1 ) ,
|
| 6280 |
KEY order_name2 ( order_name2 ) ,
|
| 6281 |
KEY order_pref ( order_pref ) ,
|
| 6282 |
KEY order_address1 ( order_address1 ) ,
|
| 6283 |
KEY order_tel ( order_tel ) ,
|
| 6284 |
KEY mem_id ( mem_id ) ,
|
| 6285 |
KEY order_date ( order_date )
|
| 6286 |
) AUTO_INCREMENT=1000 $charset_collate;";
|
| 6287 |
dbDelta( $sql );
|
| 6288 |
add_option( 'usces_db_order', USCES_DB_ORDER );
|
| 6289 |
}
|
| 6290 |
|
| 6291 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$order_meta_table'" ) != $order_meta_table ) {
|
| 6292 |
$sql = 'CREATE TABLE ' . $order_meta_table . " (
|
| 6293 |
ometa_id bigint(20) NOT NULL auto_increment,
|
| 6294 |
order_id bigint(20) NOT NULL default '0',
|
| 6295 |
meta_key varchar(255) default NULL,
|
| 6296 |
meta_value longtext,
|
| 6297 |
PRIMARY KEY (ometa_id),
|
| 6298 |
KEY order_id (order_id),
|
| 6299 |
KEY meta_key (meta_key(191))
|
| 6300 |
) $charset_collate;";
|
| 6301 |
dbDelta( $sql );
|
| 6302 |
add_option( 'usces_db_order_meta', USCES_DB_ORDER_META );
|
| 6303 |
}
|
| 6304 |
|
| 6305 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$ordercart_table'" ) != $ordercart_table ) {
|
| 6306 |
$sql = 'CREATE TABLE ' . $ordercart_table . " (
|
| 6307 |
`cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
|
| 6308 |
`order_id` bigint( 20 ) NOT NULL ,
|
| 6309 |
`group_id` int( 3 ) NOT NULL DEFAULT '0',
|
| 6310 |
`row_index` int( 3 ) NOT NULL ,
|
| 6311 |
`post_id` bigint( 20 ) NOT NULL ,
|
| 6312 |
`item_code` varchar( 100 ) NOT NULL ,
|
| 6313 |
`item_name` varchar( 250 ) NOT NULL ,
|
| 6314 |
`cprice` decimal( 12, 0 ) DEFAULT NULL ,
|
| 6315 |
`sku_code` varchar( 100 ) NOT NULL ,
|
| 6316 |
`sku_name` varchar( 250 ) DEFAULT NULL ,
|
| 6317 |
`price` decimal( 12, 0 ) NOT NULL ,
|
| 6318 |
`quantity` float NOT NULL ,
|
| 6319 |
`unit` varchar( 50 ) DEFAULT NULL ,
|
| 6320 |
`tax` decimal( 10, 0 ) DEFAULT NULL ,
|
| 6321 |
`destination_id` int( 10 ) DEFAULT NULL ,
|
| 6322 |
`cart_serial` text,
|
| 6323 |
PRIMARY KEY ( `cart_id` ) ,
|
| 6324 |
UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) ,
|
| 6325 |
KEY `order_id` ( `order_id` ) ,
|
| 6326 |
KEY `post_id` ( `post_id` ) ,
|
| 6327 |
KEY `item_code` ( `item_code` ) ,
|
| 6328 |
KEY `item_name` ( `item_name`(191) ) ,
|
| 6329 |
KEY `sku_code` ( `sku_code` ) ,
|
| 6330 |
KEY `sku_name` ( `sku_name`(191) )
|
| 6331 |
) AUTO_INCREMENT=1000 $charset_collate;";
|
| 6332 |
dbDelta( $sql );
|
| 6333 |
add_option( 'usces_db_ordercart', USCES_DB_ORDERCART );
|
| 6334 |
}
|
| 6335 |
|
| 6336 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$ordercart_meta_table'" ) != $ordercart_meta_table ) {
|
| 6337 |
$sql = 'CREATE TABLE ' . $ordercart_meta_table . " (
|
| 6338 |
`cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT ,
|
| 6339 |
`cart_id` bigint( 20 ) NOT NULL DEFAULT '0',
|
| 6340 |
`meta_type` varchar( 100 ) NOT NULL ,
|
| 6341 |
`meta_key` varchar( 255 ) DEFAULT NULL ,
|
| 6342 |
`meta_value` longtext,
|
| 6343 |
PRIMARY KEY ( `cartmeta_id` ) ,
|
| 6344 |
KEY `cart_id` ( `cart_id` ) ,
|
| 6345 |
KEY `meta_key` ( `meta_key`(191) )
|
| 6346 |
) $charset_collate;";
|
| 6347 |
dbDelta( $sql );
|
| 6348 |
add_option( 'usces_db_ordercart_meta', USCES_DB_ORDERCART_META );
|
| 6349 |
}
|
| 6350 |
|
| 6351 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$log_table'") != $log_table ) {
|
| 6352 |
$sql = 'CREATE TABLE ' . $log_table . " (
|
| 6353 |
ID BIGINT( 20 ) NOT NULL AUTO_INCREMENT,
|
| 6354 |
datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6355 |
log LONGTEXT NULL,
|
| 6356 |
log_type VARCHAR( 100 ) DEFAULT NULL,
|
| 6357 |
log_key VARCHAR( 255 ) DEFAULT NULL,
|
| 6358 |
PRIMARY KEY ( ID ) ,
|
| 6359 |
KEY datetime ( datetime ),
|
| 6360 |
KEY log_type ( log_type ),
|
| 6361 |
KEY log_key ( log_key(191) )
|
| 6362 |
) $charset_collate;";
|
| 6363 |
dbDelta( $sql );
|
| 6364 |
add_option( 'usces_db_log', USCES_DB_LOG );
|
| 6365 |
}
|
| 6366 |
|
| 6367 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '$acting_log_table'" ) != $acting_log_table ) {
|
| 6368 |
$sql = 'CREATE TABLE ' . $acting_log_table . " (
|
| 6369 |
`ID` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
| 6370 |
`datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6371 |
`log` LONGTEXT NULL,
|
| 6372 |
`acting` CHAR(32) DEFAULT NULL,
|
| 6373 |
`status` CHAR(32) DEFAULT NULL,
|
| 6374 |
`result` CHAR(32) DEFAULT NULL,
|
| 6375 |
`amount` DECIMAL( 10, 2 ) DEFAULT NULL,
|
| 6376 |
`order_id` BIGINT(20) NOT NULL,
|
| 6377 |
`tracking_id` CHAR(32) DEFAULT NULL,
|
| 6378 |
PRIMARY KEY (`ID`),
|
| 6379 |
KEY `datetime` (`datetime`),
|
| 6380 |
KEY `order_id` (`order_id`),
|
| 6381 |
KEY `tracking_id` (`tracking_id`),
|
| 6382 |
KEY `history_key` (`order_id`,`tracking_id`)
|
| 6383 |
) $charset_collate;";
|
| 6384 |
dbDelta( $sql );
|
| 6385 |
add_option( 'usces_db_acting_log', USCES_DB_ACTING_LOG );
|
| 6386 |
}
|
| 6387 |
|
| 6388 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$item_table}'" ) !== $item_table ) {
|
| 6389 |
$sql = 'CREATE TABLE ' . $item_table . ' (
|
| 6390 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL,
|
| 6391 |
itemCode VARCHAR( 200 ) NULL ,
|
| 6392 |
itemName VARCHAR( 250 ) NULL ,
|
| 6393 |
itemRestriction VARCHAR( 20 ) NULL ,
|
| 6394 |
itemPointrate VARCHAR( 20 ) NULL ,
|
| 6395 |
itemGpNum1 VARCHAR( 20 ) NULL ,
|
| 6396 |
itemGpNum2 VARCHAR( 20 ) NULL ,
|
| 6397 |
itemGpNum3 VARCHAR( 20 ) NULL ,
|
| 6398 |
itemGpDis1 VARCHAR( 20 ) NULL ,
|
| 6399 |
itemGpDis2 VARCHAR( 20 ) NULL ,
|
| 6400 |
itemGpDis3 VARCHAR( 20 ) NULL ,
|
| 6401 |
itemOrderAcceptable INT( 2 ) NULL ,
|
| 6402 |
itemShipping INT( 3 ) NULL ,
|
| 6403 |
itemDeliveryMethod LONGTEXT ,
|
| 6404 |
itemShippingCharge VARCHAR( 200 ) NULL ,
|
| 6405 |
itemIndividualSCharge VARCHAR( 20 ) NULL ,
|
| 6406 |
item_charging_type INT( 3 ) NULL ,
|
| 6407 |
item_division VARCHAR( 50 ) NULL ,
|
| 6408 |
dlseller_date VARCHAR( 100 ) NULL ,
|
| 6409 |
dlseller_file VARCHAR( 200 ) NULL ,
|
| 6410 |
dlseller_interval VARCHAR( 20 ) NULL ,
|
| 6411 |
dlseller_validity VARCHAR( 20 ) NULL ,
|
| 6412 |
dlseller_version VARCHAR( 100 ) NULL ,
|
| 6413 |
dlseller_author VARCHAR( 200 ) NULL ,
|
| 6414 |
dlseller_purchases VARCHAR( 20 ) NULL ,
|
| 6415 |
dlseller_downloads VARCHAR( 20 ) NULL ,
|
| 6416 |
item_chargingday VARCHAR( 20 ) NULL ,
|
| 6417 |
item_frequency VARCHAR( 20 ) NULL ,
|
| 6418 |
wcad_regular_unit VARCHAR( 20 ) NULL ,
|
| 6419 |
wcad_regular_interval INT( 10 ) NULL ,
|
| 6420 |
wcad_regular_frequency INT( 10 ) NULL ,
|
| 6421 |
select_sku_switch INT( 10 ) NULL ,
|
| 6422 |
select_sku_display INT( 10 ) NULL ,
|
| 6423 |
select_sku LONGTEXT ,
|
| 6424 |
atobarai_propriety INT( 5 ) NULL ,
|
| 6425 |
atodene_propriety INT( 5 ) NULL ,
|
| 6426 |
structuredDataSku VARCHAR( 200 ) NULL ,
|
| 6427 |
lower_limit INT( 10 ) NULL ,
|
| 6428 |
popularity INT( 10 ) NULL ,
|
| 6429 |
main_price DECIMAL( 10, 2 ) NULL ,
|
| 6430 |
itemPicts TEXT NULL ,
|
| 6431 |
itemAdvanced LONGTEXT NULL ,
|
| 6432 |
PRIMARY KEY (`post_id`),
|
| 6433 |
KEY itemCode ( itemCode ) ,
|
| 6434 |
KEY itemName ( itemName )
|
| 6435 |
) ' . $charset_collate . ';';
|
| 6436 |
dbDelta( $sql );
|
| 6437 |
add_option( 'usces_db_item', USCES_DB_ITEM );
|
| 6438 |
}
|
| 6439 |
|
| 6440 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$sku_table}'" ) !== $sku_table ) {
|
| 6441 |
$sql = 'CREATE TABLE ' . $sku_table . ' (
|
| 6442 |
meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6443 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL ,
|
| 6444 |
code VARCHAR( 200 ) NULL ,
|
| 6445 |
name VARCHAR( 250 ) NULL ,
|
| 6446 |
cprice DECIMAL( 10, 2 ) NULL ,
|
| 6447 |
price DECIMAL( 10, 2 ) NULL ,
|
| 6448 |
unit TEXT NULL ,
|
| 6449 |
stocknum VARCHAR( 50 ) NULL ,
|
| 6450 |
stock INT( 5 ) NULL ,
|
| 6451 |
gp INT( 2 ) NULL ,
|
| 6452 |
taxrate VARCHAR( 20 ) NULL ,
|
| 6453 |
size VARCHAR( 20 ) NULL ,
|
| 6454 |
weight VARCHAR( 20 ) NULL ,
|
| 6455 |
pict_id VARCHAR( 20 ) NULL ,
|
| 6456 |
advance LONGTEXT ,
|
| 6457 |
paternkey VARCHAR( 100 ) NULL ,
|
| 6458 |
sort INT( 5 ) NULL ,
|
| 6459 |
PRIMARY KEY (`meta_id`),
|
| 6460 |
KEY post_id ( post_id ) ,
|
| 6461 |
KEY code ( code ) ,
|
| 6462 |
KEY name ( name ) ,
|
| 6463 |
KEY price ( price ) ,
|
| 6464 |
KEY paternkey ( paternkey )
|
| 6465 |
) ' . $charset_collate . ';';
|
| 6466 |
dbDelta( $sql );
|
| 6467 |
add_option( 'usces_db_skus', USCES_DB_SKUS );
|
| 6468 |
}
|
| 6469 |
|
| 6470 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$opt_table}'" ) !== $opt_table ) {
|
| 6471 |
$sql = 'CREATE TABLE ' . $opt_table . ' (
|
| 6472 |
meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6473 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL ,
|
| 6474 |
code VARCHAR( 200 ) NULL ,
|
| 6475 |
name VARCHAR( 250 ) NULL ,
|
| 6476 |
means INT( 3 ) NULL ,
|
| 6477 |
essential INT( 3 ) NULL ,
|
| 6478 |
value TEXT ,
|
| 6479 |
sort INT( 5 ) NULL ,
|
| 6480 |
PRIMARY KEY (`meta_id`),
|
| 6481 |
KEY post_id ( post_id ) ,
|
| 6482 |
KEY code ( code ) ,
|
| 6483 |
KEY name ( name )
|
| 6484 |
) ' . $charset_collate . ';';
|
| 6485 |
dbDelta( $sql );
|
| 6486 |
add_option( 'usces_db_opts', USCES_DB_OPTS );
|
| 6487 |
}
|
| 6488 |
|
| 6489 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$admin_log_table}'" ) !== $admin_log_table ) {
|
| 6490 |
$sql = "CREATE TABLE {$admin_log_table} (
|
| 6491 |
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
| 6492 |
`author` varchar(64) NOT NULL,
|
| 6493 |
`message` longtext NOT NULL,
|
| 6494 |
`screen` varchar(64) NOT NULL,
|
| 6495 |
`entity_id` varchar(64) DEFAULT NULL,
|
| 6496 |
`action` varchar(64) NOT NULL,
|
| 6497 |
`data` longblob DEFAULT NULL,
|
| 6498 |
`datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6499 |
PRIMARY KEY (`ID`),
|
| 6500 |
KEY entity_id ( entity_id )
|
| 6501 |
) " . $charset_collate . ';';
|
| 6502 |
dbDelta( $sql );
|
| 6503 |
add_option( 'usces_db_admin_log', USCES_DB_ADMIN_LOG );
|
| 6504 |
}
|
| 6505 |
|
| 6506 |
do_action( 'usces_action_create_table' );
|
| 6507 |
}
|
| 6508 |
|
| 6509 |
public function update_table() {
|
| 6510 |
global $wpdb;
|
| 6511 |
$access_table = $wpdb->prefix . 'usces_access';
|
| 6512 |
$member_table = $wpdb->prefix . 'usces_member';
|
| 6513 |
$member_meta_table = $wpdb->prefix . 'usces_member_meta';
|
| 6514 |
$order_table = $wpdb->prefix . 'usces_order';
|
| 6515 |
$order_meta_table = $wpdb->prefix . 'usces_order_meta';
|
| 6516 |
$ordercart_table = $wpdb->prefix . 'usces_ordercart';
|
| 6517 |
$ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta';
|
| 6518 |
$log_table = $wpdb->prefix . 'usces_log';
|
| 6519 |
$acting_log_table = $wpdb->prefix . 'usces_acting_log';
|
| 6520 |
$item_table = $wpdb->prefix . 'usces_item';
|
| 6521 |
$sku_table = $wpdb->prefix . 'usces_skus';
|
| 6522 |
$opt_table = $wpdb->prefix . 'usces_opts';
|
| 6523 |
$admin_log_table = $wpdb->prefix . 'usces_admin_log';
|
| 6524 |
|
| 6525 |
$access_ver = get_option( 'usces_db_access' );
|
| 6526 |
$member_ver = get_option( 'usces_db_member' );
|
| 6527 |
$member_meta_ver = get_option( 'usces_db_member_meta' );
|
| 6528 |
$order_ver = get_option( 'usces_db_order' );
|
| 6529 |
$order_meta_ver = get_option( 'usces_db_order_meta' );
|
| 6530 |
$ordercart_ver = get_option( 'usces_db_ordercart' );
|
| 6531 |
$ordercart_meta_ver = get_option( 'usces_db_ordercart_meta' );
|
| 6532 |
$log_ver = get_option( 'usces_db_log' );
|
| 6533 |
$acting_log_ver = get_option( 'usces_db_acting_log' );
|
| 6534 |
$db_item = get_option( 'usces_db_item' );
|
| 6535 |
$db_skus = get_option( 'usces_db_skus' );
|
| 6536 |
$db_opts = get_option( 'usces_db_opts' );
|
| 6537 |
$db_admin_log = get_option( 'usces_db_admin_log' );
|
| 6538 |
|
| 6539 |
if ( $access_ver != USCES_DB_ACCESS ) {
|
| 6540 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6541 |
$sql = 'CREATE TABLE ' . $access_table . " (
|
| 6542 |
ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6543 |
acc_key VARCHAR(50) NOT NULL ,
|
| 6544 |
acc_type VARCHAR(50) NULL ,
|
| 6545 |
acc_value LONGTEXT NULL ,
|
| 6546 |
acc_date DATE NOT NULL DEFAULT '0000-00-00',
|
| 6547 |
acc_num1 INT(11) NOT NULL DEFAULT 0,
|
| 6548 |
acc_num2 INT(11) NOT NULL DEFAULT 0,
|
| 6549 |
acc_str1 VARCHAR(200) NULL ,
|
| 6550 |
acc_str2 VARCHAR(200) NULL ,
|
| 6551 |
PRIMARY KEY (`ID`),
|
| 6552 |
KEY acc_key (acc_key),
|
| 6553 |
KEY acc_type (acc_type),
|
| 6554 |
KEY acc_date (acc_date),
|
| 6555 |
KEY acc_num1 (acc_num1),
|
| 6556 |
KEY acc_num2 (acc_num2)
|
| 6557 |
);";
|
| 6558 |
dbDelta( $sql );
|
| 6559 |
update_option( 'usces_db_access', USCES_DB_ACCESS );
|
| 6560 |
}
|
| 6561 |
|
| 6562 |
if ( USCES_DB_MEMBER != $member_ver ) {
|
| 6563 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6564 |
$sql = 'CREATE TABLE ' . $member_table . " (
|
| 6565 |
ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
| 6566 |
mem_email VARCHAR(100) NOT NULL ,
|
| 6567 |
mem_pass VARCHAR(64) NOT NULL ,
|
| 6568 |
mem_status INT(11) NOT NULL DEFAULT '0',
|
| 6569 |
mem_cookie VARCHAR(13) NULL ,
|
| 6570 |
mem_point INT(11) NOT NULL DEFAULT '0',
|
| 6571 |
mem_name1 VARCHAR(100) NOT NULL ,
|
| 6572 |
mem_name2 VARCHAR(100) NULL ,
|
| 6573 |
mem_name3 VARCHAR(100) NULL ,
|
| 6574 |
mem_name4 VARCHAR(100) NULL ,
|
| 6575 |
mem_zip VARCHAR(50) NULL ,
|
| 6576 |
mem_pref VARCHAR(100) NOT NULL ,
|
| 6577 |
mem_address1 VARCHAR(100) NOT NULL ,
|
| 6578 |
mem_address2 VARCHAR(100) NULL ,
|
| 6579 |
mem_address3 VARCHAR(100) NULL ,
|
| 6580 |
mem_tel VARCHAR(100) NOT NULL ,
|
| 6581 |
mem_fax VARCHAR(100) NULL ,
|
| 6582 |
mem_delivery_flag TINYINT (1) NULL ,
|
| 6583 |
mem_delivery LONGTEXT,
|
| 6584 |
mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6585 |
mem_nicename VARCHAR(50) NULL ,
|
| 6586 |
PRIMARY KEY (`ID`),
|
| 6587 |
KEY mem_email (mem_email) ,
|
| 6588 |
KEY mem_pass (mem_pass)
|
| 6589 |
);";
|
| 6590 |
dbDelta( $sql );
|
| 6591 |
update_option( 'usces_db_member', USCES_DB_MEMBER );
|
| 6592 |
}
|
| 6593 |
|
| 6594 |
if ( USCES_DB_MEMBER_META != $member_meta_ver ) {
|
| 6595 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6596 |
$sql = 'CREATE TABLE ' . $member_meta_table . " (
|
| 6597 |
mmeta_id bigint(20) NOT NULL auto_increment,
|
| 6598 |
member_id bigint(20) NOT NULL default '0',
|
| 6599 |
meta_key varchar(255) default NULL,
|
| 6600 |
meta_value longtext,
|
| 6601 |
PRIMARY KEY (`mmeta_id`),
|
| 6602 |
KEY order_id (member_id),
|
| 6603 |
KEY meta_key (meta_key(191))
|
| 6604 |
);";
|
| 6605 |
dbDelta( $sql );
|
| 6606 |
update_option( 'usces_db_member_meta', USCES_DB_MEMBER_META );
|
| 6607 |
}
|
| 6608 |
|
| 6609 |
if ( USCES_DB_ORDER != $order_ver ) {
|
| 6610 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6611 |
$sql = 'CREATE TABLE ' . $order_table . " (
|
| 6612 |
ID bigint(20) unsigned NOT NULL auto_increment,
|
| 6613 |
mem_id BIGINT(20) UNSIGNED NULL,
|
| 6614 |
order_email VARCHAR(100) NOT NULL,
|
| 6615 |
order_name1 VARCHAR(100) NOT NULL,
|
| 6616 |
order_name2 VARCHAR(100) NULL,
|
| 6617 |
order_name3 VARCHAR(100) NULL,
|
| 6618 |
order_name4 VARCHAR(100) NULL,
|
| 6619 |
order_zip VARCHAR(50) NULL,
|
| 6620 |
order_pref VARCHAR(100) NOT NULL,
|
| 6621 |
order_address1 VARCHAR(100) NOT NULL,
|
| 6622 |
order_address2 VARCHAR(100) NULL,
|
| 6623 |
order_address3 VARCHAR(100) NULL,
|
| 6624 |
order_tel VARCHAR(100) NOT NULL,
|
| 6625 |
order_fax VARCHAR(100) NULL,
|
| 6626 |
order_delivery LONGTEXT,
|
| 6627 |
order_cart LONGTEXT,
|
| 6628 |
order_note TEXT,
|
| 6629 |
order_delivery_time VARCHAR(100) NOT NULL,
|
| 6630 |
order_payment_name VARCHAR(100) NOT NULL,
|
| 6631 |
order_condition TEXT,
|
| 6632 |
order_item_total_price DECIMAL(10,2) NOT NULL DEFAULT '0.00',
|
| 6633 |
order_getpoint INT(10) NOT NULL DEFAULT '0',
|
| 6634 |
order_usedpoint INT(10) NOT NULL DEFAULT '0',
|
| 6635 |
order_discount DECIMAL(10,2) NOT NULL DEFAULT '0.00',
|
| 6636 |
order_shipping_charge DECIMAL(10,2) NOT NULL DEFAULT '0.00',
|
| 6637 |
order_cod_fee DECIMAL(10,2) NOT NULL DEFAULT '0.00',
|
| 6638 |
order_tax DECIMAL(10,2) NOT NULL DEFAULT '0.00',
|
| 6639 |
order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6640 |
order_modified VARCHAR(20) NULL,
|
| 6641 |
order_status VARCHAR(255) NULL,
|
| 6642 |
order_check TEXT NULL,
|
| 6643 |
order_delidue_date VARCHAR(30) NULL,
|
| 6644 |
order_delivery_method INT(10) NOT NULL DEFAULT -1,
|
| 6645 |
order_delivery_date VARCHAR(100) NULL,
|
| 6646 |
PRIMARY KEY (`ID`),
|
| 6647 |
KEY order_email (order_email),
|
| 6648 |
KEY order_name1 (order_name1),
|
| 6649 |
KEY order_name2 (order_name2),
|
| 6650 |
KEY order_pref (order_pref),
|
| 6651 |
KEY order_address1 (order_address1),
|
| 6652 |
KEY order_tel (order_tel),
|
| 6653 |
KEY mem_id ( mem_id ) ,
|
| 6654 |
KEY order_date (order_date)
|
| 6655 |
);";
|
| 6656 |
dbDelta( $sql );
|
| 6657 |
update_option( 'usces_db_order', USCES_DB_ORDER );
|
| 6658 |
}
|
| 6659 |
|
| 6660 |
if ( USCES_DB_ORDER_META != $order_meta_ver ) {
|
| 6661 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6662 |
$sql = 'CREATE TABLE ' . $order_meta_table . " (
|
| 6663 |
ometa_id bigint(20) NOT NULL auto_increment,
|
| 6664 |
order_id bigint(20) NOT NULL default '0',
|
| 6665 |
meta_key varchar(255) default NULL,
|
| 6666 |
meta_value longtext,
|
| 6667 |
PRIMARY KEY (`ometa_id`),
|
| 6668 |
KEY order_id (order_id),
|
| 6669 |
KEY meta_key (meta_key)
|
| 6670 |
);";
|
| 6671 |
dbDelta( $sql );
|
| 6672 |
update_option( 'usces_db_order_meta', USCES_DB_ORDER_META );
|
| 6673 |
}
|
| 6674 |
|
| 6675 |
if ( USCES_DB_ORDERCART != $ordercart_ver ) {
|
| 6676 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6677 |
$sql = 'CREATE TABLE ' . $ordercart_table . " (
|
| 6678 |
cart_id bigint(20) unsigned NOT NULL AUTO_INCREMENT ,
|
| 6679 |
order_id bigint(20) NOT NULL ,
|
| 6680 |
group_id int(3) NOT NULL DEFAULT '0',
|
| 6681 |
row_index int(3) NOT NULL ,
|
| 6682 |
post_id bigint(20) NOT NULL ,
|
| 6683 |
item_code varchar(100) NOT NULL ,
|
| 6684 |
item_name varchar(250) NOT NULL ,
|
| 6685 |
cprice decimal(12,0) DEFAULT NULL ,
|
| 6686 |
sku_code varchar(100) NOT NULL ,
|
| 6687 |
sku_name varchar(250) DEFAULT NULL ,
|
| 6688 |
price decimal(12,0) NOT NULL ,
|
| 6689 |
quantity float NOT NULL ,
|
| 6690 |
unit varchar(50) DEFAULT NULL ,
|
| 6691 |
tax decimal(10,0) DEFAULT NULL ,
|
| 6692 |
destination_id int(10) DEFAULT NULL ,
|
| 6693 |
cart_serial text,
|
| 6694 |
UNIQUE KEY row (row_index,destination_id,order_id) ,
|
| 6695 |
PRIMARY KEY (`cart_id`),
|
| 6696 |
KEY order_id (order_id) ,
|
| 6697 |
KEY post_id (post_id) ,
|
| 6698 |
KEY item_code (item_code) ,
|
| 6699 |
KEY item_name (item_name(191)) ,
|
| 6700 |
KEY sku_code (sku_code) ,
|
| 6701 |
KEY sku_name (sku_name(191))
|
| 6702 |
);";
|
| 6703 |
dbDelta( $sql );
|
| 6704 |
update_option( 'usces_db_ordercart', USCES_DB_ORDERCART );
|
| 6705 |
}
|
| 6706 |
|
| 6707 |
if ( USCES_DB_ORDERCART_META != $ordercart_meta_ver ) {
|
| 6708 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6709 |
$sql = 'CREATE TABLE ' . $ordercart_meta_table . " (
|
| 6710 |
cartmeta_id bigint(20) NOT NULL AUTO_INCREMENT,
|
| 6711 |
cart_id bigint(20) NOT NULL DEFAULT '0',
|
| 6712 |
meta_type varchar(100) NOT NULL ,
|
| 6713 |
meta_key varchar(255) DEFAULT NULL ,
|
| 6714 |
meta_value longtext,
|
| 6715 |
PRIMARY KEY (`cartmeta_id`),
|
| 6716 |
KEY cart_id (cart_id) ,
|
| 6717 |
KEY meta_key (meta_key(191))
|
| 6718 |
);";
|
| 6719 |
dbDelta( $sql );
|
| 6720 |
update_option( 'usces_db_ordercart_meta', USCES_DB_ORDERCART_META );
|
| 6721 |
}
|
| 6722 |
|
| 6723 |
if ( USCES_DB_LOG != $log_ver ) {
|
| 6724 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6725 |
$sql = 'CREATE TABLE ' . $log_table . " (
|
| 6726 |
ID bigint(20) NOT NULL AUTO_INCREMENT,
|
| 6727 |
datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6728 |
log LONGTEXT NULL,
|
| 6729 |
log_type VARCHAR(100) DEFAULT NULL,
|
| 6730 |
log_key VARCHAR(255) DEFAULT NULL,
|
| 6731 |
PRIMARY KEY (`ID`),
|
| 6732 |
KEY datetime (datetime),
|
| 6733 |
KEY log_type (log_type),
|
| 6734 |
KEY log_key (log_key(191))
|
| 6735 |
);";
|
| 6736 |
dbDelta( $sql );
|
| 6737 |
update_option( 'usces_db_log', USCES_DB_LOG );
|
| 6738 |
}
|
| 6739 |
|
| 6740 |
if ( USCES_DB_ACTING_LOG != $acting_log_ver ) {
|
| 6741 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6742 |
$sql = 'CREATE TABLE ' . $acting_log_table . " (
|
| 6743 |
`ID` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
| 6744 |
`datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6745 |
`log` LONGTEXT NULL,
|
| 6746 |
`acting` CHAR(32) DEFAULT NULL,
|
| 6747 |
`status` CHAR(32) DEFAULT NULL,
|
| 6748 |
`result` CHAR(32) DEFAULT NULL,
|
| 6749 |
`amount` DECIMAL( 10, 2 ) DEFAULT NULL,
|
| 6750 |
`order_id` BIGINT(20) NOT NULL,
|
| 6751 |
`tracking_id` CHAR(32) DEFAULT NULL,
|
| 6752 |
PRIMARY KEY (`ID`),
|
| 6753 |
KEY `datetime` (`datetime`),
|
| 6754 |
KEY `order_id` (`order_id`),
|
| 6755 |
KEY `tracking_id` (`tracking_id`),
|
| 6756 |
KEY `history_key` (`order_id`,`tracking_id`)
|
| 6757 |
);";
|
| 6758 |
dbDelta( $sql );
|
| 6759 |
update_option( 'usces_db_acting_log', USCES_DB_ACTING_LOG );
|
| 6760 |
}
|
| 6761 |
|
| 6762 |
if ( USCES_DB_ITEM != $db_item ) {
|
| 6763 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6764 |
$sql = 'CREATE TABLE ' . $item_table . ' (
|
| 6765 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL ,
|
| 6766 |
itemCode VARCHAR( 200 ) NULL ,
|
| 6767 |
itemName VARCHAR( 250 ) NULL ,
|
| 6768 |
itemRestriction VARCHAR( 20 ) NULL ,
|
| 6769 |
itemPointrate VARCHAR( 20 ) NULL ,
|
| 6770 |
itemGpNum1 VARCHAR( 20 ) NULL ,
|
| 6771 |
itemGpNum2 VARCHAR( 20 ) NULL ,
|
| 6772 |
itemGpNum3 VARCHAR( 20 ) NULL ,
|
| 6773 |
itemGpDis1 VARCHAR( 20 ) NULL ,
|
| 6774 |
itemGpDis2 VARCHAR( 20 ) NULL ,
|
| 6775 |
itemGpDis3 VARCHAR( 20 ) NULL ,
|
| 6776 |
itemOrderAcceptable INT( 2 ) NULL ,
|
| 6777 |
itemShipping INT( 3 ) NULL ,
|
| 6778 |
itemDeliveryMethod LONGTEXT ,
|
| 6779 |
itemShippingCharge VARCHAR( 200 ) NULL ,
|
| 6780 |
itemIndividualSCharge VARCHAR( 20 ) NULL ,
|
| 6781 |
item_charging_type INT( 3 ) NULL ,
|
| 6782 |
item_division VARCHAR( 50 ) NULL ,
|
| 6783 |
dlseller_date VARCHAR( 100 ) NULL ,
|
| 6784 |
dlseller_file VARCHAR( 200 ) NULL ,
|
| 6785 |
dlseller_interval VARCHAR( 20 ) NULL ,
|
| 6786 |
dlseller_validity VARCHAR( 20 ) NULL ,
|
| 6787 |
dlseller_version VARCHAR( 100 ) NULL ,
|
| 6788 |
dlseller_author VARCHAR( 200 ) NULL ,
|
| 6789 |
dlseller_purchases VARCHAR( 20 ) NULL ,
|
| 6790 |
dlseller_downloads VARCHAR( 20 ) NULL ,
|
| 6791 |
item_chargingday VARCHAR( 20 ) NULL ,
|
| 6792 |
item_frequency VARCHAR( 20 ) NULL ,
|
| 6793 |
wcad_regular_unit VARCHAR( 20 ) NULL ,
|
| 6794 |
wcad_regular_interval INT( 10 ) NULL ,
|
| 6795 |
wcad_regular_frequency INT( 10 ) NULL ,
|
| 6796 |
select_sku_switch INT( 10 ) NULL ,
|
| 6797 |
select_sku_display INT( 10 ) NULL ,
|
| 6798 |
select_sku LONGTEXT ,
|
| 6799 |
atobarai_propriety INT( 5 ) NULL ,
|
| 6800 |
atodene_propriety INT( 5 ) NULL ,
|
| 6801 |
structuredDataSku VARCHAR( 200 ) NULL ,
|
| 6802 |
lower_limit INT( 10 ) NULL ,
|
| 6803 |
popularity INT( 10 ) NULL ,
|
| 6804 |
main_price DECIMAL( 10, 2 ) NULL ,
|
| 6805 |
itemPicts TEXT NULL ,
|
| 6806 |
itemAdvanced LONGTEXT NULL ,
|
| 6807 |
PRIMARY KEY (`post_id`),
|
| 6808 |
KEY itemCode ( itemCode ) ,
|
| 6809 |
KEY itemName ( itemName )
|
| 6810 |
);';
|
| 6811 |
dbDelta( $sql );
|
| 6812 |
update_option( 'usces_db_item', USCES_DB_ITEM );
|
| 6813 |
}
|
| 6814 |
|
| 6815 |
if ( USCES_DB_SKUS != $db_skus ) {
|
| 6816 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6817 |
$sql = 'CREATE TABLE ' . $sku_table . ' (
|
| 6818 |
meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
|
| 6819 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL ,
|
| 6820 |
code VARCHAR( 200 ) NULL ,
|
| 6821 |
name VARCHAR( 250 ) NULL ,
|
| 6822 |
cprice DECIMAL( 10, 2 ) NULL ,
|
| 6823 |
price DECIMAL( 10, 2 ) NULL ,
|
| 6824 |
unit TEXT NULL ,
|
| 6825 |
stocknum VARCHAR( 50 ) NULL ,
|
| 6826 |
stock INT( 5 ) NULL ,
|
| 6827 |
gp INT( 2 ) NULL ,
|
| 6828 |
taxrate VARCHAR( 20 ) NULL ,
|
| 6829 |
size VARCHAR( 20 ) NULL ,
|
| 6830 |
weight VARCHAR( 20 ) NULL ,
|
| 6831 |
pict_id VARCHAR( 20 ) NULL ,
|
| 6832 |
advance LONGTEXT ,
|
| 6833 |
paternkey VARCHAR( 100 ) NULL ,
|
| 6834 |
sort INT( 5 ) NULL ,
|
| 6835 |
PRIMARY KEY (`meta_id`),
|
| 6836 |
KEY post_id ( post_id ) ,
|
| 6837 |
KEY code ( code ) ,
|
| 6838 |
KEY name ( name ) ,
|
| 6839 |
KEY price ( price ) ,
|
| 6840 |
KEY paternkey ( paternkey )
|
| 6841 |
);';
|
| 6842 |
dbDelta( $sql );
|
| 6843 |
update_option( 'usces_db_skus', USCES_DB_SKUS );
|
| 6844 |
}
|
| 6845 |
|
| 6846 |
if ( USCES_DB_OPTS != $db_opts ) {
|
| 6847 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6848 |
$sql = 'CREATE TABLE ' . $opt_table . ' (
|
| 6849 |
meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
|
| 6850 |
post_id BIGINT( 20 ) UNSIGNED NOT NULL ,
|
| 6851 |
code VARCHAR( 200 ) NULL ,
|
| 6852 |
name VARCHAR( 250 ) NULL ,
|
| 6853 |
means INT( 3 ) NULL ,
|
| 6854 |
essential INT( 3 ) NULL ,
|
| 6855 |
value TEXT ,
|
| 6856 |
sort INT( 5 ) NULL ,
|
| 6857 |
PRIMARY KEY (`meta_id`),
|
| 6858 |
KEY post_id ( post_id ) ,
|
| 6859 |
KEY code ( code ) ,
|
| 6860 |
KEY name ( name )
|
| 6861 |
);';
|
| 6862 |
dbDelta( $sql );
|
| 6863 |
update_option( 'usces_db_opts', USCES_DB_OPTS );
|
| 6864 |
}
|
| 6865 |
|
| 6866 |
if ( USCES_DB_ADMIN_LOG != $db_admin_log ) {
|
| 6867 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
| 6868 |
$sql = "CREATE TABLE {$admin_log_table} (
|
| 6869 |
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
| 6870 |
`author` varchar(64) NOT NULL,
|
| 6871 |
`message` longtext NOT NULL,
|
| 6872 |
`screen` varchar(64) NOT NULL,
|
| 6873 |
`entity_id` varchar(64) DEFAULT NULL,
|
| 6874 |
`action` varchar(64) NOT NULL,
|
| 6875 |
`data` longblob DEFAULT NULL,
|
| 6876 |
`datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
| 6877 |
PRIMARY KEY (`ID`),
|
| 6878 |
KEY entity_id ( entity_id )
|
| 6879 |
);";
|
| 6880 |
dbDelta( $sql );
|
| 6881 |
update_option( 'usces_db_admin_log', USCES_DB_ADMIN_LOG );
|
| 6882 |
}
|
| 6883 |
|
| 6884 |
do_action( 'usces_action_update_table' );
|
| 6885 |
}
|
| 6886 |
|
| 6887 |
public function dir_copy( $source, $dest ) {
|
| 6888 |
if ( $res = opendir( $source ) ) {
|
| 6889 |
while ( ( $file = readdir( $res ) ) !== false ) {
|
| 6890 |
$sorce_path = $source . '/' . $file;
|
| 6891 |
$dest_path = $dest . '/' . $file;
|
| 6892 |
$filetype = @filetype( $sorce_path );
|
| 6893 |
if ( 'file' == $filetype ) {
|
| 6894 |
copy( $sorce_path, $dest_path );
|
| 6895 |
} elseif ( 'dir' == $filetype && '..' != $file && '.' != $file ) {
|
| 6896 |
mkdir( $dest_path );
|
| 6897 |
$this->dir_copy( $sorce_path, $dest_path );
|
| 6898 |
}
|
| 6899 |
}
|
| 6900 |
closedir( $res );
|
| 6901 |
}
|
| 6902 |
}
|
| 6903 |
|
| 6904 |
public function set_default_page() {
|
| 6905 |
global $wpdb;
|
| 6906 |
|
| 6907 |
$datetime = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) );
|
| 6908 |
$datetime_gmt = gmdate( 'Y-m-d H:i:s', time() );
|
| 6909 |
|
| 6910 |
// cart_page.
|
| 6911 |
$query = $wpdb->prepare( "SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER );
|
| 6912 |
$cart_number = $wpdb->get_var( $query );
|
| 6913 |
if ( null === $cart_number ) {
|
| 6914 |
$query = $wpdb->prepare(
|
| 6915 |
"INSERT INTO $wpdb->posts
|
| 6916 |
(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
|
| 6917 |
comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
|
| 6918 |
post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
|
| 6919 |
VALUES (%d, %s, %s, %s, %s, %s, %s,
|
| 6920 |
%s, %s, %s, %s, %s, %s, %s, %s,
|
| 6921 |
%s, %d, %s, %d, %s, %s, %d)",
|
| 6922 |
1, $datetime, $datetime_gmt, '', __( 'Cart', 'usces' ), '', 'publish',
|
| 6923 |
'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
|
| 6924 |
'', 0, '', 0, 'page', '', 0
|
| 6925 |
);
|
| 6926 |
$wpdb->query( $query );
|
| 6927 |
$cart_number = $wpdb->insert_id;
|
| 6928 |
if ( null !== $cart_number ) {
|
| 6929 |
$query = $wpdb->prepare(
|
| 6930 |
"INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
|
| 6931 |
$cart_number, '_wp_page_template', 'uscescart.php'
|
| 6932 |
);
|
| 6933 |
$wpdb->query( $query );
|
| 6934 |
}
|
| 6935 |
}
|
| 6936 |
update_option( 'usces_cart_number', $cart_number );
|
| 6937 |
|
| 6938 |
// member_page.
|
| 6939 |
$query = $wpdb->prepare( "SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER );
|
| 6940 |
$member_number = $wpdb->get_var( $query );
|
| 6941 |
if ( null === $member_number ) {
|
| 6942 |
$query = $wpdb->prepare(
|
| 6943 |
"INSERT INTO $wpdb->posts
|
| 6944 |
(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
|
| 6945 |
comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
|
| 6946 |
post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
|
| 6947 |
VALUES (%d, %s, %s, %s, %s, %s, %s,
|
| 6948 |
%s, %s, %s, %s, %s, %s, %s, %s,
|
| 6949 |
%s, %d, %s, %d, %s, %s, %d)",
|
| 6950 |
1, $datetime, $datetime_gmt, '', __( 'Membership', 'usces' ), '', 'publish',
|
| 6951 |
'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
|
| 6952 |
'', 0, '', 0, 'page', '', 0
|
| 6953 |
);
|
| 6954 |
$wpdb->query( $query );
|
| 6955 |
$member_number = $wpdb->insert_id;
|
| 6956 |
if ( null !== $member_number ) {
|
| 6957 |
$query = $wpdb->prepare(
|
| 6958 |
"INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
|
| 6959 |
$member_number, '_wp_page_template', 'uscesmember.php'
|
| 6960 |
);
|
| 6961 |
$wpdb->query( $query );
|
| 6962 |
}
|
| 6963 |
}
|
| 6964 |
update_option( 'usces_member_number', $member_number );
|
| 6965 |
}
|
| 6966 |
|
| 6967 |
public function set_default_categories() {
|
| 6968 |
global $wpdb;
|
| 6969 |
|
| 6970 |
$item_category_slug = apply_filters( 'usces_item_category_slug', 'item' );
|
| 6971 |
|
| 6972 |
$idObj = get_category_by_slug( $item_category_slug );
|
| 6973 |
if ( empty( $idObj ) ) {
|
| 6974 |
$item_cat = array(
|
| 6975 |
'cat_name' => __( 'Items', 'usces' ),
|
| 6976 |
'category_description' => '',
|
| 6977 |
'category_nicename' => $item_category_slug,
|
| 6978 |
'category_parent' => 0,
|
| 6979 |
);
|
| 6980 |
$item_cat_id = wp_insert_category( $item_cat );
|
| 6981 |
update_option( 'usces_item_cat_parent_id', $item_cat_id );
|
| 6982 |
}
|
| 6983 |
|
| 6984 |
$idObj = get_category_by_slug( 'itemreco' );
|
| 6985 |
if ( empty( $idObj ) && isset( $item_cat_id ) ) {
|
| 6986 |
$itemreco_cat = array(
|
| 6987 |
'cat_name' => __( 'Items recommended', 'usces' ),
|
| 6988 |
'category_description' => '',
|
| 6989 |
'category_nicename' => 'itemreco',
|
| 6990 |
'category_parent' => $item_cat_id,
|
| 6991 |
);
|
| 6992 |
$itemreco_cat_id = wp_insert_category( $itemreco_cat );
|
| 6993 |
}
|
| 6994 |
|
| 6995 |
$idObj = get_category_by_slug( 'itemnew' );
|
| 6996 |
if ( empty( $idObj ) && isset( $item_cat_id ) ) {
|
| 6997 |
$itemnew_cat = array(
|
| 6998 |
'cat_name' => __( 'New items', 'usces' ),
|
| 6999 |
'category_description' => '',
|
| 7000 |
'category_nicename' => 'itemnew',
|
| 7001 |
'category_parent' => $item_cat_id,
|
| 7002 |
);
|
| 7003 |
$itemnew_cat_id = wp_insert_category( $itemnew_cat );
|
| 7004 |
}
|
| 7005 |
|
| 7006 |
$idObj = get_category_by_slug( 'itemgenre' );
|
| 7007 |
if ( empty( $idObj ) && isset( $item_cat_id ) ) {
|
| 7008 |
$itemgenre_cat = array(
|
| 7009 |
'cat_name' => __( 'Item genre', 'usces' ),
|
| 7010 |
'category_description' => '',
|
| 7011 |
'category_nicename' => 'itemgenre',
|
| 7012 |
'category_parent' => $item_cat_id,
|
| 7013 |
);
|
| 7014 |
$itemgenre_cat_id = wp_insert_category( $itemgenre_cat );
|
| 7015 |
}
|
| 7016 |
}
|
| 7017 |
|
| 7018 |
public function update_options() {
|
| 7019 |
$target_market = $this->options['system']['target_market'];
|
| 7020 |
|
| 7021 |
$update_shipping_charge = false;
|
| 7022 |
$shipping_charge = isset( $this->options['shipping_charge'] ) ? $this->options['shipping_charge'] : array();
|
| 7023 |
$shipping_charge_count = ( $shipping_charge && is_array( $shipping_charge ) ) ? count( $shipping_charge ) : 0;
|
| 7024 |
foreach ( (array) $target_market as $tm ) {
|
| 7025 |
for ( $i = 0; $i < $shipping_charge_count; $i++ ) {
|
| 7026 |
if ( isset( $shipping_charge[ $i ]['country'] ) && $shipping_charge[ $i ]['country'] == $tm ) {
|
| 7027 |
foreach ( $shipping_charge[ $i ]['value'] as $pref => $value ) {
|
| 7028 |
$shipping_charge[ $i ][ $tm ][ $pref ] = $value;
|
| 7029 |
}
|
| 7030 |
unset( $shipping_charge[ $i ]['country'] );
|
| 7031 |
unset( $shipping_charge[ $i ]['value'] );
|
| 7032 |
$update_shipping_charge = true;
|
| 7033 |
}
|
| 7034 |
}
|
| 7035 |
}
|
| 7036 |
if ( $update_shipping_charge ) {
|
| 7037 |
$this->options['shipping_charge'] = $shipping_charge;
|
| 7038 |
}
|
| 7039 |
|
| 7040 |
$update_delivery_days = false;
|
| 7041 |
$delivery_days = isset( $this->options['delivery_days'] ) ? $this->options['delivery_days'] : array();
|
| 7042 |
$delivery_days_count = ( $delivery_days && is_array( $delivery_days ) ) ? count( $delivery_days ) : 0;
|
| 7043 |
foreach ( (array) $target_market as $tm ) {
|
| 7044 |
for ( $i = 0; $i < $delivery_days_count; $i++ ) {
|
| 7045 |
if ( isset( $delivery_days[ $i ]['country'] ) && $delivery_days[ $i ]['country'] == $tm ) {
|
| 7046 |
foreach ( $delivery_days[ $i ]['value'] as $pref => $value ) {
|
| 7047 |
$delivery_days[ $i ][ $tm ][ $pref ] = $value;
|
| 7048 |
}
|
| 7049 |
unset( $delivery_days[ $i ]['country'] );
|
| 7050 |
unset( $delivery_days[ $i ]['value'] );
|
| 7051 |
$update_delivery_days = true;
|
| 7052 |
}
|
| 7053 |
}
|
| 7054 |
}
|
| 7055 |
if ( $update_delivery_days ) {
|
| 7056 |
$this->options['delivery_days'] = $delivery_days;
|
| 7057 |
}
|
| 7058 |
|
| 7059 |
if ( $update_shipping_charge || $update_delivery_days ) {
|
| 7060 |
update_option( 'usces', $this->options );
|
| 7061 |
}
|
| 7062 |
}
|
| 7063 |
|
| 7064 |
public function get_item_cat_ids() {
|
| 7065 |
$ids = array();
|
| 7066 |
$args = array(
|
| 7067 |
'child_of' => USCES_ITEM_CAT_PARENT_ID,
|
| 7068 |
'hide_empty' => 0,
|
| 7069 |
'hierarchical' => 0,
|
| 7070 |
);
|
| 7071 |
$categories = get_categories( $args );
|
| 7072 |
foreach ( (array) $categories as $category ) {
|
| 7073 |
$ids[] = $category->term_id;
|
| 7074 |
}
|
| 7075 |
return $ids;
|
| 7076 |
}
|
| 7077 |
|
| 7078 |
public function get_item_post_ids() {
|
| 7079 |
global $wpdb;
|
| 7080 |
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item' );
|
| 7081 |
$ids = $wpdb->get_col( $query );
|
| 7082 |
|
| 7083 |
return $ids;
|
| 7084 |
}
|
| 7085 |
|
| 7086 |
public function get_item_cat_genre_ids( $post_id ) {
|
| 7087 |
$ids = array();
|
| 7088 |
$all_ids = array();
|
| 7089 |
$genre = get_category_by_slug( 'itemgenre' );
|
| 7090 |
if ( ! empty( $genre->term_id ) ) {
|
| 7091 |
$genre_id = $genre->term_id;
|
| 7092 |
$args = array(
|
| 7093 |
'child_of' => $genre_id,
|
| 7094 |
'hide_empty' => 0,
|
| 7095 |
'hierarchical' => 0,
|
| 7096 |
);
|
| 7097 |
$categories = get_categories( $args );
|
| 7098 |
foreach ( (array) $categories as $category ) {
|
| 7099 |
$ids[] = $category->term_id;
|
| 7100 |
}
|
| 7101 |
$allcats = get_the_category( $post_id );
|
| 7102 |
foreach ( (array) $allcats as $cat ) {
|
| 7103 |
$all_ids[] = $cat->term_id;
|
| 7104 |
}
|
| 7105 |
$results = array_intersect( $ids, $all_ids );
|
| 7106 |
} else {
|
| 7107 |
$results = array();
|
| 7108 |
}
|
| 7109 |
return $results;
|
| 7110 |
}
|
| 7111 |
|
| 7112 |
public function set_item_mime( $post_id, $str ) {
|
| 7113 |
global $wpdb;
|
| 7114 |
if ( WCUtils::is_blank( $str ) ) {
|
| 7115 |
return;
|
| 7116 |
}
|
| 7117 |
$query = $wpdb->prepare( "UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id );
|
| 7118 |
$results = $wpdb->query( $query );
|
| 7119 |
return $results;
|
| 7120 |
}
|
| 7121 |
|
| 7122 |
public function isAdnminSSL() {
|
| 7123 |
$plugins = get_option( 'active_plugins' );
|
| 7124 |
foreach ( $plugins as $plugin ) {
|
| 7125 |
if ( false !== strpos( $plugin, USCES_ADMIN_SSL_BASE_NAME ) ) {
|
| 7126 |
return true;
|
| 7127 |
}
|
| 7128 |
}
|
| 7129 |
return false;
|
| 7130 |
}
|
| 7131 |
|
| 7132 |
public function getGuidTax() {
|
| 7133 |
if ( isset( $this->options['tax_display'] ) && 'deactivate' == $this->options['tax_display'] ) {
|
| 7134 |
$str = '';
|
| 7135 |
} else {
|
| 7136 |
$tax_rate = (int) $this->options['tax_rate'];
|
| 7137 |
|
| 7138 |
if ( isset( $this->options['tax_mode'] ) ) {
|
| 7139 |
if ( 'exclude' == $this->options['tax_mode'] ) {
|
| 7140 |
$str = '<em class="tax">' . __( '(Excl. Tax)', 'usces' ) . '</em>';
|
| 7141 |
} else {
|
| 7142 |
$str = '<em class="tax">' . __( '(Incl. Tax)', 'usces' ) . '</em>';
|
| 7143 |
}
|
| 7144 |
} else {
|
| 7145 |
if ( 0 < $tax_rate ) {
|
| 7146 |
$str = '<em class="tax">' . __( '(Excl. Tax)', 'usces' ) . '</em>';
|
| 7147 |
} else {
|
| 7148 |
$str = '<em class="tax">' . __( '(Incl. Tax)', 'usces' ) . '</em>';
|
| 7149 |
}
|
| 7150 |
}
|
| 7151 |
$str = apply_filters( 'usces_filter_tax_guid', $str, $tax_rate );
|
| 7152 |
}
|
| 7153 |
return $str;
|
| 7154 |
}
|
| 7155 |
|
| 7156 |
public function getItemCode( $post_id, $cache = true ) {
|
| 7157 |
$product = wel_get_product( $post_id, $cache );
|
| 7158 |
$itemCode = isset( $product['itemCode'] ) ? $product['itemCode'] : null;
|
| 7159 |
return $itemCode;
|
| 7160 |
}
|
| 7161 |
|
| 7162 |
public function getItemName( $post_id, $cache = true ) {
|
| 7163 |
$product = wel_get_product( $post_id, $cache );
|
| 7164 |
$itemName = isset( $product['itemName'] ) ? $product['itemName'] : null;
|
| 7165 |
return $itemName;
|
| 7166 |
}
|
| 7167 |
|
| 7168 |
public function getItemRestriction( $post_id, $cache = true ) {
|
| 7169 |
$product = wel_get_product( $post_id, $cache );
|
| 7170 |
$itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : null;
|
| 7171 |
return $itemRestriction;
|
| 7172 |
}
|
| 7173 |
|
| 7174 |
public function getItemOrderAcceptable( $post_id, $cache = true ) {
|
| 7175 |
$product = wel_get_product( $post_id, $cache );
|
| 7176 |
$value = ( ! empty( $product['itemOrderAcceptable'] ) ) ? (int) $product['itemOrderAcceptable'] : 0;
|
| 7177 |
return $value;
|
| 7178 |
}
|
| 7179 |
|
| 7180 |
public function getItemPointrate( $post_id, $cache = true ) {
|
| 7181 |
$product = wel_get_product( $post_id, $cache );
|
| 7182 |
$itemPointrate = isset( $product['itemPointrate'] ) ? $product['itemPointrate'] : null;
|
| 7183 |
return $itemPointrate;
|
| 7184 |
}
|
| 7185 |
|
| 7186 |
public function getItemShipping( $post_id, $cache = true ) {
|
| 7187 |
$product = wel_get_product( $post_id, $cache );
|
| 7188 |
$itemShipping = isset( $product['itemShipping'] ) ? $product['itemShipping'] : null;
|
| 7189 |
return $itemShipping;
|
| 7190 |
}
|
| 7191 |
|
| 7192 |
public function getItemShippingCharge( $post_id, $cache = true ) {
|
| 7193 |
$product = wel_get_product( $post_id, $cache );
|
| 7194 |
$itemShippingCharge = isset( $product['itemShippingCharge'] ) ? (float) $product['itemShippingCharge'] : null;
|
| 7195 |
return $itemShippingCharge;
|
| 7196 |
}
|
| 7197 |
|
| 7198 |
public function getItemDeliveryMethod( $post_id, $cache = true ) {
|
| 7199 |
$product = wel_get_product( $post_id, $cache );
|
| 7200 |
if ( empty( $product['itemDeliveryMethod'] ) ) {
|
| 7201 |
return array();
|
| 7202 |
} else {
|
| 7203 |
return $product['itemDeliveryMethod'];
|
| 7204 |
}
|
| 7205 |
}
|
| 7206 |
|
| 7207 |
public function getItemIndividualSCharge( $post_id, $cache = true ) {
|
| 7208 |
$product = wel_get_product( $post_id, $cache );
|
| 7209 |
$itemIndividualSCharge = isset( $product['itemIndividualSCharge'] ) ? $product['itemIndividualSCharge'] : null;
|
| 7210 |
return $itemIndividualSCharge;
|
| 7211 |
}
|
| 7212 |
|
| 7213 |
public function getItemGpNum1( $post_id, $cache = true ) {
|
| 7214 |
$product = wel_get_product( $post_id, $cache );
|
| 7215 |
$itemGpNum1 = isset( $product['itemGpNum1'] ) ? $product['itemGpNum1'] : null;
|
| 7216 |
return $itemGpNum1;
|
| 7217 |
}
|
| 7218 |
|
| 7219 |
public function getItemGpNum2( $post_id, $cache = true ) {
|
| 7220 |
$product = wel_get_product( $post_id, $cache );
|
| 7221 |
$itemGpNum2 = isset( $product['itemGpNum2'] ) ? $product['itemGpNum2'] : null;
|
| 7222 |
return $itemGpNum2;
|
| 7223 |
}
|
| 7224 |
|
| 7225 |
public function getItemGpNum3( $post_id, $cache = true ) {
|
| 7226 |
$product = wel_get_product( $post_id, $cache );
|
| 7227 |
$itemGpNum3 = isset( $product['itemGpNum3'] ) ? $product['itemGpNum3'] : null;
|
| 7228 |
return $itemGpNum3;
|
| 7229 |
}
|
| 7230 |
|
| 7231 |
public function getItemGpDis1( $post_id, $cache = true ) {
|
| 7232 |
$product = wel_get_product( $post_id, $cache );
|
| 7233 |
$itemGpDis1 = isset( $product['itemGpDis1'] ) ? $product['itemGpDis1'] : null;
|
| 7234 |
return $itemGpDis1;
|
| 7235 |
}
|
| 7236 |
|
| 7237 |
public function getItemGpDis2( $post_id, $cache = true ) {
|
| 7238 |
$product = wel_get_product( $post_id, $cache );
|
| 7239 |
$itemGpDis2 = isset( $product['itemGpDis2'] ) ? $product['itemGpDis2'] : null;
|
| 7240 |
return $itemGpDis2;
|
| 7241 |
}
|
| 7242 |
|
| 7243 |
public function getItemGpDis3( $post_id, $cache = true ) {
|
| 7244 |
$product = wel_get_product( $post_id, $cache );
|
| 7245 |
$itemGpDis3 = isset( $product['itemGpDis3'] ) ? $product['itemGpDis3'] : null;
|
| 7246 |
return $itemGpDis3;
|
| 7247 |
}
|
| 7248 |
|
| 7249 |
/**
|
| 7250 |
* Unused function
|
| 7251 |
*/
|
| 7252 |
public function getItemSku( $post_id, $index = '', $cache = true ) {
|
| 7253 |
$array = array();
|
| 7254 |
$skus = $this->get_skus( $post_id, 'sort', $cache );
|
| 7255 |
foreach ( (array) $skus as $sku ) {
|
| 7256 |
$array[] = $sku['code'];
|
| 7257 |
}
|
| 7258 |
if ( ! $array ) {
|
| 7259 |
return false;
|
| 7260 |
}
|
| 7261 |
if ( '' == $index ) {
|
| 7262 |
return $array;
|
| 7263 |
} elseif ( isset( $array[ $index ] ) ) {
|
| 7264 |
return $array[ $index ];
|
| 7265 |
} else {
|
| 7266 |
return false;
|
| 7267 |
}
|
| 7268 |
}
|
| 7269 |
|
| 7270 |
public function getItemPrice( $post_id, $skukey = '', $cache = true ) {
|
| 7271 |
$array = array();
|
| 7272 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7273 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7274 |
$array[ $key ] = (float) str_replace( ',', '', $sku['price'] );
|
| 7275 |
}
|
| 7276 |
$array = apply_filters( 'usces_filter_get_item_price', $array, $post_id, $skukey, $skus );
|
| 7277 |
if ( ! $array ) {
|
| 7278 |
return false;
|
| 7279 |
}
|
| 7280 |
if ( '' === $skukey ) {
|
| 7281 |
return $array;
|
| 7282 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7283 |
return $array[ $skukey ];
|
| 7284 |
} else {
|
| 7285 |
return false;
|
| 7286 |
}
|
| 7287 |
}
|
| 7288 |
|
| 7289 |
public function getItemDiscount( $post_id, $skukey = '', $cache = true ) {
|
| 7290 |
$display_mode = $this->options['display_mode'];
|
| 7291 |
$decimal = $this->get_currency_decimal();
|
| 7292 |
$array = array();
|
| 7293 |
|
| 7294 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7295 |
$discount = 0;
|
| 7296 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7297 |
$price = (float) str_replace( ',', '', $sku['price'] );
|
| 7298 |
if ( 'Promotionsale' == $display_mode ) {
|
| 7299 |
if ( 'discount' === $this->options['campaign_privilege'] ) {
|
| 7300 |
if ( 0 === (int) $this->options['campaign_category'] || in_category( (int) $this->options['campaign_category'], $post_id ) ) {
|
| 7301 |
$discount = (float) sprintf( '%.3f', $price * $this->options['privilege_discount'] / 100 );
|
| 7302 |
} else {
|
| 7303 |
$discount = 0;
|
| 7304 |
}
|
| 7305 |
} elseif ( 'point' === $this->options['campaign_privilege'] ) {
|
| 7306 |
$discount = 0;
|
| 7307 |
}
|
| 7308 |
}
|
| 7309 |
if ( 0 != $discount ) {
|
| 7310 |
if ( 0 == $decimal ) {
|
| 7311 |
$discount = ceil( $discount );
|
| 7312 |
} else {
|
| 7313 |
$decipad = (int) str_pad( '1', $decimal + 1, '0', STR_PAD_RIGHT );
|
| 7314 |
$discount = ceil( $discount * $decipad ) / $decipad;
|
| 7315 |
}
|
| 7316 |
}
|
| 7317 |
$discount = apply_filters( 'usces_filter_getItemDiscount', $discount, $price, $post_id, $sku, $display_mode );
|
| 7318 |
$array[ $key ] = $discount;
|
| 7319 |
}
|
| 7320 |
if ( ! $array ) {
|
| 7321 |
return false;
|
| 7322 |
}
|
| 7323 |
if ( '' === $skukey ) {
|
| 7324 |
return $array;
|
| 7325 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7326 |
return $array[ $skukey ];
|
| 7327 |
} else {
|
| 7328 |
return false;
|
| 7329 |
}
|
| 7330 |
}
|
| 7331 |
|
| 7332 |
public function getItemZaiko( $post_id, $skukey = '', $cache = true ) {
|
| 7333 |
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
|
| 7334 |
$array = array();
|
| 7335 |
|
| 7336 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7337 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7338 |
$num = $sku['stock'];
|
| 7339 |
if ( 1 != $itemOrderAcceptable || WCUtils::is_blank( $sku['stocknum'] ) ) {
|
| 7340 |
$array[ $key ] = $this->zaiko_status[ $num ];
|
| 7341 |
} else {
|
| 7342 |
if ( 2 > $num && 0 >= (int) $sku['stocknum'] ) {
|
| 7343 |
$array[ $key ] = ( ! empty( $this->options['order_acceptable_label'] ) ) ? $this->options['order_acceptable_label'] : __( 'Order acceptable', 'usces' );
|
| 7344 |
} else {
|
| 7345 |
$array[ $key ] = $this->zaiko_status[ $num ];
|
| 7346 |
}
|
| 7347 |
}
|
| 7348 |
}
|
| 7349 |
if ( ! $array ) {
|
| 7350 |
return false;
|
| 7351 |
}
|
| 7352 |
if ( '' === $skukey ) {
|
| 7353 |
return $array;
|
| 7354 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7355 |
return $array[ $skukey ];
|
| 7356 |
} else {
|
| 7357 |
return false;
|
| 7358 |
}
|
| 7359 |
}
|
| 7360 |
|
| 7361 |
public function getItemZaikoStatusId( $post_id, $skukey = '', $cache = true ) {
|
| 7362 |
$array = array();
|
| 7363 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7364 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7365 |
$num = $sku['stock'];
|
| 7366 |
$array[ $key ] = $num;
|
| 7367 |
}
|
| 7368 |
if ( ! $array ) {
|
| 7369 |
return false;
|
| 7370 |
}
|
| 7371 |
if ( '' === $skukey ) {
|
| 7372 |
return $array;
|
| 7373 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7374 |
return $array[ $skukey ];
|
| 7375 |
} else {
|
| 7376 |
return false;
|
| 7377 |
}
|
| 7378 |
}
|
| 7379 |
|
| 7380 |
public function updateItemZaiko( $post_id, $skucode, $value ) {
|
| 7381 |
$res = usces_update_sku( $post_id, $skucode, 'stock', $value );
|
| 7382 |
if ( ! $res ) {
|
| 7383 |
return false;
|
| 7384 |
} else {
|
| 7385 |
return true;
|
| 7386 |
}
|
| 7387 |
}
|
| 7388 |
|
| 7389 |
public function getItemZaikoNum( $post_id, $skukey = '', $cache = true ) {
|
| 7390 |
$array = array();
|
| 7391 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7392 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7393 |
$array[ $key ] = $sku['stocknum'];
|
| 7394 |
}
|
| 7395 |
if ( ! $array ) {
|
| 7396 |
return false;
|
| 7397 |
}
|
| 7398 |
if ( '' === $skukey ) {
|
| 7399 |
return $array;
|
| 7400 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7401 |
return $array[ $skukey ];
|
| 7402 |
} else {
|
| 7403 |
return false;
|
| 7404 |
}
|
| 7405 |
}
|
| 7406 |
|
| 7407 |
public function updateItemZaikoNum( $post_id, $skucode, $value ) {
|
| 7408 |
$res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
|
| 7409 |
if ( ! $res ) {
|
| 7410 |
return false;
|
| 7411 |
} else {
|
| 7412 |
return true;
|
| 7413 |
}
|
| 7414 |
}
|
| 7415 |
|
| 7416 |
public function getItemDivision( $post_id, $cache = true ) {
|
| 7417 |
if ( usces_is_item( $post_id ) ) {
|
| 7418 |
$product = wel_get_product( $post_id, $cache );
|
| 7419 |
$item_division = $product['item_division'];
|
| 7420 |
$division = empty( $item_division ) ? 'shipped' : $item_division;
|
| 7421 |
} else {
|
| 7422 |
$division = null;
|
| 7423 |
}
|
| 7424 |
return $division;
|
| 7425 |
}
|
| 7426 |
|
| 7427 |
public function getItemChargingType( $post_id, $cart = array(), $cache = true ) {
|
| 7428 |
if ( usces_is_item( $post_id ) ) {
|
| 7429 |
$product = wel_get_product( $post_id, $cache );
|
| 7430 |
$charging = $product['item_charging_type'];
|
| 7431 |
if ( ! defined( 'WCEX_DLSELLER' ) && ! defined( 'WCEX_AUTO_DELIVERY' ) ) {
|
| 7432 |
$charging = null;
|
| 7433 |
}
|
| 7434 |
} else {
|
| 7435 |
$charging = null;
|
| 7436 |
}
|
| 7437 |
switch ( $charging ) {
|
| 7438 |
case 0:
|
| 7439 |
$type = 'once';
|
| 7440 |
break;
|
| 7441 |
case 1:
|
| 7442 |
$type = 'continue';
|
| 7443 |
break;
|
| 7444 |
case 2:
|
| 7445 |
$type = 'regular';
|
| 7446 |
if ( ! empty( $cart ) ) {
|
| 7447 |
if ( empty( $cart['advance'] ) ) {
|
| 7448 |
$type = 'once';
|
| 7449 |
} else {
|
| 7450 |
if ( is_array( $cart['advance'] ) && array_key_exists( 'regular', $cart['advance'] ) ) {
|
| 7451 |
$regular = maybe_unserialize( $cart['advance']['regular'] );
|
| 7452 |
} else {
|
| 7453 |
$advance = $this->cart->wc_unserialize( $cart['advance'] );
|
| 7454 |
$sku = urldecode( $cart['sku'] );
|
| 7455 |
$sku_encoded = $cart['sku'];
|
| 7456 |
$regular = $advance[ $post_id ][ $sku_encoded ]['regular'];
|
| 7457 |
}
|
| 7458 |
$unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
|
| 7459 |
$interval = isset( $regular['interval'] ) ? (int) $regular['interval'] : 0;
|
| 7460 |
/* Treated as normal billing */
|
| 7461 |
if ( empty( $unit ) || 1 > $interval ) {
|
| 7462 |
$type = 'once';
|
| 7463 |
}
|
| 7464 |
}
|
| 7465 |
}
|
| 7466 |
break;
|
| 7467 |
default:
|
| 7468 |
$type = null;
|
| 7469 |
}
|
| 7470 |
return $type;
|
| 7471 |
}
|
| 7472 |
|
| 7473 |
public function getItemFrequency( $post_id, $cache = true ) {
|
| 7474 |
$product = wel_get_product( $post_id, $cache );
|
| 7475 |
return $product['item_frequency'];
|
| 7476 |
}
|
| 7477 |
|
| 7478 |
public function getItemChargingDay( $post_id, $cache = true ) {
|
| 7479 |
$product = wel_get_product( $post_id, $cache );
|
| 7480 |
$day = (int) $product['item_chargingday'];
|
| 7481 |
|
| 7482 |
$chargingday = empty( $day ) ? 1 : $day;
|
| 7483 |
return $chargingday;
|
| 7484 |
}
|
| 7485 |
|
| 7486 |
public function getItemSkuDisp( $post_id, $skukey = '', $cache = true ) {
|
| 7487 |
$array = array();
|
| 7488 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7489 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7490 |
$array[ $key ] = $sku['name'];
|
| 7491 |
}
|
| 7492 |
if ( ! $array ) {
|
| 7493 |
return false;
|
| 7494 |
}
|
| 7495 |
if ( '' === $skukey ) {
|
| 7496 |
return $array;
|
| 7497 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7498 |
return $array[ $skukey ];
|
| 7499 |
} else {
|
| 7500 |
return false;
|
| 7501 |
}
|
| 7502 |
}
|
| 7503 |
|
| 7504 |
public function getItemSkuUnit( $post_id, $skukey = '', $cache = true ) {
|
| 7505 |
$array = array();
|
| 7506 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7507 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7508 |
$array[ $key ] = $sku['unit'];
|
| 7509 |
}
|
| 7510 |
if ( ! $array ) {
|
| 7511 |
return false;
|
| 7512 |
}
|
| 7513 |
if ( '' === $skukey ) {
|
| 7514 |
return $array;
|
| 7515 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7516 |
return $array[ $skukey ];
|
| 7517 |
} else {
|
| 7518 |
return false;
|
| 7519 |
}
|
| 7520 |
}
|
| 7521 |
|
| 7522 |
public function getItemSkuAdvance( $post_id, $skukey = '', $cache = true ) {
|
| 7523 |
$array = array();
|
| 7524 |
$skus = wel_get_skus( $post_id, 'code', $cache );
|
| 7525 |
foreach ( (array) $skus as $key => $sku ) {
|
| 7526 |
$array[ $key ] = $sku['advance'];
|
| 7527 |
}
|
| 7528 |
if ( ! $array ) {
|
| 7529 |
return false;
|
| 7530 |
}
|
| 7531 |
if ( '' === $skukey ) {
|
| 7532 |
return $array;
|
| 7533 |
} elseif ( isset( $array[ $skukey ] ) ) {
|
| 7534 |
return $array[ $skukey ];
|
| 7535 |
} else {
|
| 7536 |
return false;
|
| 7537 |
}
|
| 7538 |
}
|
| 7539 |
|
| 7540 |
public function get_item( $post_id, $cache = true ) {
|
| 7541 |
return wel_get_product( $post_id, $cache );
|
| 7542 |
}
|
| 7543 |
|
| 7544 |
public function get_itemOptionKey( $post_id, $enc = false, $cache = true ) {
|
| 7545 |
$opts = usces_get_opts( $post_id, 'sort', $cache );
|
| 7546 |
if ( empty( $opts ) ) {
|
| 7547 |
return;
|
| 7548 |
}
|
| 7549 |
|
| 7550 |
$res = array();
|
| 7551 |
foreach ( (array) $opts as $opt ) {
|
| 7552 |
if ( $enc ) {
|
| 7553 |
$res[] = urlencode( $opt['name'] );
|
| 7554 |
} else {
|
| 7555 |
$res[] = $opt['name'];
|
| 7556 |
}
|
| 7557 |
}
|
| 7558 |
return $res;
|
| 7559 |
}
|
| 7560 |
|
| 7561 |
public function get_itemOptions( $key, $post_id, $cache = true ) {
|
| 7562 |
$opts = wel_get_opts( $post_id, 'name', $cache );
|
| 7563 |
if ( ! isset( $opts[ $key ] ) ) {
|
| 7564 |
return false;
|
| 7565 |
} else {
|
| 7566 |
return $opts[ $key ];
|
| 7567 |
}
|
| 7568 |
}
|
| 7569 |
|
| 7570 |
public function get_postIDbyCode( $item_code, $cache = true ) {
|
| 7571 |
if ( null === $item_code ) {
|
| 7572 |
return false;
|
| 7573 |
}
|
| 7574 |
|
| 7575 |
$post_id = wel_get_id_by_item_code( $item_code, $cache );
|
| 7576 |
|
| 7577 |
return $post_id;
|
| 7578 |
}
|
| 7579 |
|
| 7580 |
public function get_itemByCode( $item_code, $cache = true ) {
|
| 7581 |
if ( null === $item_code ) {
|
| 7582 |
return false;
|
| 7583 |
}
|
| 7584 |
|
| 7585 |
$product = wel_get_product_by_code( $item_code, $cache );
|
| 7586 |
|
| 7587 |
return $product;
|
| 7588 |
}
|
| 7589 |
|
| 7590 |
public function get_pictids( $item_code, $cache = true ) {
|
| 7591 |
return wel_get_sub_pict_ids_by_code( $item_code, $cache );
|
| 7592 |
}
|
| 7593 |
|
| 7594 |
public function get_mainpictid( $item_code, $cache = true ) {
|
| 7595 |
return wel_get_main_pict_id_by_code( $item_code, $cache );
|
| 7596 |
}
|
| 7597 |
|
| 7598 |
public function get_subpictid( $sku_code, $cache = true ) {
|
| 7599 |
global $wpdb;
|
| 7600 |
if ( empty( $sku_code) ) {
|
| 7601 |
return 0;
|
| 7602 |
}
|
| 7603 |
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $sku_code );
|
| 7604 |
$id = $wpdb->get_var( $query );
|
| 7605 |
$id = apply_filters( 'usces_filter_get_subpictid', $id, $sku_code );
|
| 7606 |
return $id;
|
| 7607 |
}
|
| 7608 |
|
| 7609 |
public function get_skus( $post_id, $keyflag = 'sort', $cache = true ) {
|
| 7610 |
if ( null === $post_id ) {
|
| 7611 |
return false;
|
| 7612 |
}
|
| 7613 |
|
| 7614 |
$skus = wel_get_skus( $post_id, $keyflag, $cache );
|
| 7615 |
|
| 7616 |
return $skus;
|
| 7617 |
}
|
| 7618 |
|
| 7619 |
public function is_item( $post ) {
|
| 7620 |
if ( 'item' == $post->post_mime_type ) {
|
| 7621 |
return true;
|
| 7622 |
} else {
|
| 7623 |
return false;
|
| 7624 |
}
|
| 7625 |
}
|
| 7626 |
|
| 7627 |
public function getItemIds( $end_type ) {
|
| 7628 |
global $wpdb;
|
| 7629 |
|
| 7630 |
$cache_key = 'wel_item_ids_' . $end_type;
|
| 7631 |
|
| 7632 |
$ids = wp_cache_get( $cache_key );
|
| 7633 |
if ( false === $ids ) {
|
| 7634 |
|
| 7635 |
if ( 'front' == $end_type ) {
|
| 7636 |
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item' );
|
| 7637 |
}
|
| 7638 |
if ( 'back' == $end_type ) {
|
| 7639 |
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item' );
|
| 7640 |
}
|
| 7641 |
$ids = $wpdb->get_col( $query );
|
| 7642 |
|
| 7643 |
if ( null !== $ids ) {
|
| 7644 |
wp_cache_set( $cache_key, $ids );
|
| 7645 |
}
|
| 7646 |
}
|
| 7647 |
|
| 7648 |
if ( null === $ids ) {
|
| 7649 |
return array();
|
| 7650 |
} else {
|
| 7651 |
return $ids;
|
| 7652 |
}
|
| 7653 |
}
|
| 7654 |
|
| 7655 |
public function getNotItemIds() {
|
| 7656 |
global $wpdb;
|
| 7657 |
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item' );
|
| 7658 |
$ids = $wpdb->get_col( $query );
|
| 7659 |
if ( empty( $ids ) ) {
|
| 7660 |
$ids = array();
|
| 7661 |
}
|
| 7662 |
return $ids;
|
| 7663 |
}
|
| 7664 |
|
| 7665 |
public function getPaymentMethod( $name ) {
|
| 7666 |
$res = array();
|
| 7667 |
$payments = $this->options['payment_method'];
|
| 7668 |
foreach ( (array) $payments as $payment ) {
|
| 7669 |
if ( $name == $payment['name'] ) {
|
| 7670 |
$res = $payment;
|
| 7671 |
break;
|
| 7672 |
}
|
| 7673 |
}
|
| 7674 |
return $res;
|
| 7675 |
}
|
| 7676 |
|
| 7677 |
public function order_processing( $results = array() ) {
|
| 7678 |
do_action( 'usces_pre_reg_orderdata' );
|
| 7679 |
$acting = isset( $_REQUEST['acting'] ) ? $_REQUEST['acting'] : '';
|
| 7680 |
global $usces;
|
| 7681 |
$usces_entries = $this->cart->get_entry();
|
| 7682 |
$payments = $this->getPayments( $usces_entries['order']['payment_name'] );
|
| 7683 |
$nonacting_settlements = apply_filters( 'usces_filter_nonacting_settlements', $this->nonacting_settlements );
|
| 7684 |
|
| 7685 |
$res = usces_check_acting_return_duplicate( $results );
|
| 7686 |
if ( $res != null && ! in_array( $payments['settlement'], $nonacting_settlements ) ) {
|
| 7687 |
usces_log( 'order processing duplicate : acting=' . $acting . ', order_id=' . $res, 'acting_transaction.log' );
|
| 7688 |
return 'ordercompletion';
|
| 7689 |
}
|
| 7690 |
if ( isset( $_REQUEST['acting'] ) && ( 'jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'] ) ) {
|
| 7691 |
usces_log( $_REQUEST['acting'] . ' transaction : ' . $_REQUEST['gid'], 'acting_transaction.log' ); // OK.
|
| 7692 |
}
|
| 7693 |
if ( isset( $_REQUEST['acting'] ) && ( 'paypal_ec' == $_REQUEST['acting'] ) ) {
|
| 7694 |
if ( ! usces_paypal_doecp( $results ) ) {
|
| 7695 |
return 'error';
|
| 7696 |
}
|
| 7697 |
}
|
| 7698 |
$order_id = usces_reg_orderdata( $results );
|
| 7699 |
do_action( 'usces_post_reg_orderdata', $order_id, $results );
|
| 7700 |
|
| 7701 |
if ( $order_id ) {
|
| 7702 |
// mail(function.php).
|
| 7703 |
$mail_res = usces_send_ordermail( $order_id );
|
| 7704 |
return 'ordercompletion';
|
| 7705 |
|
| 7706 |
} else {
|
| 7707 |
return 'error';
|
| 7708 |
}
|
| 7709 |
}
|
| 7710 |
|
| 7711 |
/**
|
| 7712 |
* 決済処理
|
| 7713 |
*
|
| 7714 |
* @param string $acting_flg Payment type.
|
| 7715 |
* @param array $post_query Post data.
|
| 7716 |
* @param string $acting_status Status.
|
| 7717 |
* @return mixed
|
| 7718 |
*/
|
| 7719 |
public function acting_processing( $acting_flg, $post_query, $acting_status ) {
|
| 7720 |
global $wpdb;
|
| 7721 |
|
| 7722 |
$entry = $this->cart->get_entry();
|
| 7723 |
$delim = apply_filters( 'usces_filter_delim', $this->delim );
|
| 7724 |
$acting_flg = trim( $acting_flg );
|
| 7725 |
|
| 7726 |
if ( empty( $acting_flg ) ) {
|
| 7727 |
return 'error';
|
| 7728 |
}
|
| 7729 |
|
| 7730 |
if ( 'paypal.php' == $acting_flg ) {
|
| 7731 |
|
| 7732 |
} elseif ( 'epsilon.php' == $acting_flg ) {
|
| 7733 |
|
| 7734 |
} elseif ( 'acting_paypal_ec' == $acting_flg ) {
|
| 7735 |
$acting_opts = $this->options['acting_settings']['paypal'];
|
| 7736 |
$addroverride = '1';
|
| 7737 |
if ( isset( $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) ) {
|
| 7738 |
if ( 'US' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] || 'CA' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) {
|
| 7739 |
$addroverride = '0';
|
| 7740 |
}
|
| 7741 |
} else {
|
| 7742 |
$addroverride = '0';
|
| 7743 |
}
|
| 7744 |
$rand = ( isset( $_POST['PAYMENTREQUEST_0_CUSTOM'] ) ) ? $_POST['PAYMENTREQUEST_0_CUSTOM'] : '(empty key)';
|
| 7745 |
|
| 7746 |
$nvpstr = $post_query;
|
| 7747 |
$nvpstr .= '&ADDROVERRIDE=' . $addroverride;
|
| 7748 |
$nvpstr .= '&PAYMENTREQUEST_0_PAYMENTACTION=' . apply_filters( 'usces_filter_paypal_ec_paymentaction', 'Sale' );
|
| 7749 |
|
| 7750 |
// The returnURL is the location where buyers return to when a payment has been succesfully authorized.
|
| 7751 |
$nvpstr .= '&RETURNURL=' . urlencode( USCES_CART_URL . $delim . 'acting=paypal_ec&acting_return=1' );
|
| 7752 |
|
| 7753 |
// The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow.
|
| 7754 |
$cancelurl = urlencode( USCES_CART_URL . $delim . 'confirm=1' );
|
| 7755 |
$pos = strpos( $post_query, 'paypal_from_cart' );
|
| 7756 |
if ( false !== $pos ) {
|
| 7757 |
$cancelurl = urlencode( USCES_CART_URL );
|
| 7758 |
}
|
| 7759 |
$nvpstr .= '&CANCELURL=' . apply_filters( 'usces_filter_paypal_ec_cancelurl', $cancelurl, $post_query );
|
| 7760 |
|
| 7761 |
$nvpstr .= '&PAYMENTREQUEST_0_NOTIFYURL=' . urlencode( USCES_PAYPAL_NOTIFY_URL );
|
| 7762 |
|
| 7763 |
// Seamless checkout.
|
| 7764 |
if ( isset( $_SESSION['liwpp']['token'] ) && ! empty( $_SESSION['liwpp']['token'] ) ) {
|
| 7765 |
$nvpstr .= '&IDENTITYACCESSTOKEN=' . $_SESSION['liwpp']['token'];
|
| 7766 |
}
|
| 7767 |
|
| 7768 |
$this->paypal->setMethod( 'SetExpressCheckout' );
|
| 7769 |
$this->paypal->setData( $nvpstr );
|
| 7770 |
$res = $this->paypal->doExpressCheckout();
|
| 7771 |
$resArray = $this->paypal->getResponse();
|
| 7772 |
$ack = strtoupper( $resArray['ACK'] );
|
| 7773 |
if ( 'SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack ) {
|
| 7774 |
$token = urldecode( $resArray['TOKEN'] );
|
| 7775 |
$payPalURL = $acting_opts['paypal_url'] . '?cmd=_express-checkout&token=' . $token . '&useraction=commit';
|
| 7776 |
header( 'Location: ' . $payPalURL );
|
| 7777 |
|
| 7778 |
} else {
|
| 7779 |
// Display a user friendly Error on the page using any of the following error information returned by PayPal.
|
| 7780 |
$ErrorCode = urldecode( $resArray['L_ERRORCODE0'] );
|
| 7781 |
$ErrorShortMsg = urldecode( $resArray['L_SHORTMESSAGE0'] );
|
| 7782 |
$ErrorLongMsg = urldecode( $resArray['L_LONGMESSAGE0'] );
|
| 7783 |
$ErrorSeverityCode = urldecode( $resArray['L_SEVERITYCODE0'] );
|
| 7784 |
usces_log( 'PayPal : SetExpressCheckout API call failed. Error Code:[' . $ErrorCode . '] Error Severity Code:[' . $ErrorSeverityCode . '] Short Error Message:' . $ErrorShortMsg . ' Detailed Error Message:' . $ErrorLongMsg, 'acting_transaction.log' );
|
| 7785 |
$log = array(
|
| 7786 |
'acting' => 'paypal_ec',
|
| 7787 |
'key' => $rand,
|
| 7788 |
'result' => $ack,
|
| 7789 |
'data' => $resArray,
|
| 7790 |
);
|
| 7791 |
usces_save_order_acting_error( $log );
|
| 7792 |
header( 'Location: ' . USCES_CART_URL . $delim . 'acting=paypal_ec&acting_return=0' );
|
| 7793 |
}
|
| 7794 |
exit;
|
| 7795 |
|
| 7796 |
} elseif ( 'acting_telecom_edy' == $acting_flg ) { /* テレコムクレジット Edy決済 */
|
| 7797 |
$table_meta_name = $wpdb->prefix . 'usces_order_meta';
|
| 7798 |
$value = array();
|
| 7799 |
$value['usces_cart'] = $_SESSION['usces_cart'];
|
| 7800 |
$value['usces_entry'] = $_SESSION['usces_entry'];
|
| 7801 |
$value['usces_member'] = $_SESSION['usces_member'];
|
| 7802 |
$mvalue = serialize( $value );
|
| 7803 |
$mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
|
| 7804 |
$res = $wpdb->query( $mquery );
|
| 7805 |
|
| 7806 |
unset( $_SESSION['usces_cart'] );
|
| 7807 |
unset( $_SESSION['usces_entry'] );
|
| 7808 |
|
| 7809 |
$acting_opts = $this->options['acting_settings']['telecom'];
|
| 7810 |
header( 'location: ' . $acting_opts['send_url_edy'] . '?acting=telecom_edy' . $post_query );
|
| 7811 |
exit;
|
| 7812 |
|
| 7813 |
} elseif ( 'acting_digitalcheck_card' == $acting_flg ) { /* ペイメントフォー カード決済(旧メタップスペイメント、旧デジタルチェック、旧ペイデザイン) */
|
| 7814 |
$acting_opts = $this->options['acting_settings']['digitalcheck'];
|
| 7815 |
$interface = parse_url( $acting_opts['send_url_user_id'] );
|
| 7816 |
$kakutei = ( empty( $acting_opts['card_kakutei'] ) ) ? '0' : $acting_opts['card_kakutei'];
|
| 7817 |
|
| 7818 |
$params = array(
|
| 7819 |
'IP' => $acting_opts['card_ip'],
|
| 7820 |
'PASS' => $acting_opts['card_pass'],
|
| 7821 |
'SID' => $_POST['SID'],
|
| 7822 |
'IP_USER_ID' => $_POST['IP_USER_ID'],
|
| 7823 |
'N1' => $_POST['N1'],
|
| 7824 |
'K1' => $_POST['K1'],
|
| 7825 |
'FUKA' => $acting_flg,
|
| 7826 |
'KAKUTEI' => $kakutei,
|
| 7827 |
);
|
| 7828 |
$vars = http_build_query( $params );
|
| 7829 |
|
| 7830 |
$header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n";
|
| 7831 |
$header .= 'Host: ' . $interface['host'] . "\r\n";
|
| 7832 |
$header .= "User-Agent: PHP Script\r\n";
|
| 7833 |
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
| 7834 |
$header .= 'Content-Length: ' . strlen( $vars ) . "\r\n";
|
| 7835 |
$header .= "Connection: close\r\n\r\n";
|
| 7836 |
$header .= $vars;
|
| 7837 |
|
| 7838 |
$fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 );
|
| 7839 |
if ( ! $fp ) {
|
| 7840 |
// usces_log( 'digitalcheck card : TLS(v1.2) Error', 'acting_transaction.log' );
|
| 7841 |
$log = array(
|
| 7842 |
'acting' => 'digitalcheck_card',
|
| 7843 |
'key' => $_POST['SID'],
|
| 7844 |
'result' => 'SSL/TLS ERROR (' . $errno . ')',
|
| 7845 |
'data' => array( $errstr ),
|
| 7846 |
);
|
| 7847 |
usces_save_order_acting_error( $log );
|
| 7848 |
wp_redirect(
|
| 7849 |
add_query_arg(
|
| 7850 |
array(
|
| 7851 |
'acting' => 'digitalcheck_card',
|
| 7852 |
'acting_return' => 0,
|
| 7853 |
),
|
| 7854 |
USCES_CART_URL
|
| 7855 |
)
|
| 7856 |
);
|
| 7857 |
exit();
|
| 7858 |
}
|
| 7859 |
|
| 7860 |
if ( $fp ) {
|
| 7861 |
fwrite( $fp, $header );
|
| 7862 |
$headerdone = false;
|
| 7863 |
$page = '';
|
| 7864 |
while ( ! feof( $fp ) ) {
|
| 7865 |
$line = fgets( $fp, 1024 );
|
| 7866 |
if ( 0 == strcmp( $line, "\r\n" ) ) {
|
| 7867 |
$headerdone = true;
|
| 7868 |
} elseif ( $headerdone ) {
|
| 7869 |
$page .= $line;
|
| 7870 |
}
|
| 7871 |
}
|
| 7872 |
fclose( $fp );
|
| 7873 |
$lines = explode( "\n", $page );
|
| 7874 |
if ( false !== strpos( $lines[0], 'OK' ) ) {
|
| 7875 |
// usces_log( 'digitalcheck card entry data (acting_processing) : ' . print_r( $entry, true ), 'acting_transaction.log');
|
| 7876 |
wp_redirect(
|
| 7877 |
add_query_arg(
|
| 7878 |
array(
|
| 7879 |
'acting' => 'digitalcheck_card',
|
| 7880 |
'acting_return' => 1,
|
| 7881 |
'SID' => $_POST['SID'],
|
| 7882 |
'FUKA' => $acting_flg,
|
| 7883 |
),
|
| 7884 |
USCES_CART_URL
|
| 7885 |
)
|
| 7886 |
);
|
| 7887 |
exit();
|
| 7888 |
} else {
|
| 7889 |
// usces_log( 'digitalcheck card : Certification Error : ' . $page, 'acting_transaction.log' );
|
| 7890 |
$log = array(
|
| 7891 |
'acting' => 'digitalcheck_card',
|
| 7892 |
'key' => $_POST['SID'],
|
| 7893 |
'result' => 'CERTIFICATION ERROR',
|
| 7894 |
'data' => $lines,
|
| 7895 |
);
|
| 7896 |
usces_save_order_acting_error( $log );
|
| 7897 |
wp_redirect(
|
| 7898 |
add_query_arg(
|
| 7899 |
array(
|
| 7900 |
'acting' => 'digitalcheck_card',
|
| 7901 |
'acting_return' => 0,
|
| 7902 |
),
|
| 7903 |
USCES_CART_URL
|
| 7904 |
)
|
| 7905 |
);
|
| 7906 |
exit();
|
| 7907 |
}
|
| 7908 |
}
|
| 7909 |
exit();
|
| 7910 |
|
| 7911 |
} elseif ( 'acting_digitalcheck_conv' == $acting_flg ) { /* ペイメントフォー コンビニ決済(旧メタップスペイメント、旧デジタルチェック、旧ペイデザイン) */
|
| 7912 |
if ( isset( $_REQUEST['STORE'] ) && '99' != $_REQUEST['STORE'] ) {
|
| 7913 |
$res = $this->order_processing();
|
| 7914 |
if ( 'ordercompletion' == $res ) {
|
| 7915 |
$table_meta_name = $wpdb->prefix . 'usces_order_meta';
|
| 7916 |
$mquery = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
|
| 7917 |
$order_id = $wpdb->get_var( $mquery );
|
| 7918 |
if ( $order_id ) {
|
| 7919 |
$data = array(
|
| 7920 |
'settltment_status' => __( 'Failure', 'usces' ),
|
| 7921 |
'settltment_errmsg' => __( 'Settlement was not completed.', 'usces' ),
|
| 7922 |
);
|
| 7923 |
$this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
|
| 7924 |
$this->set_order_meta_value( 'wc_trans_id', $_REQUEST['SID'], $order_id );
|
| 7925 |
}
|
| 7926 |
$this->cart->crear_cart();
|
| 7927 |
$acting_opts = $this->options['acting_settings']['digitalcheck'];
|
| 7928 |
header( 'location: ' . $acting_opts['send_url_conv'] . '?acting=digitalcheck_conv' . $post_query );
|
| 7929 |
exit;
|
| 7930 |
} else {
|
| 7931 |
// usces_log( 'digitalcheck conv : order processing error', 'acting_transaction.log' );
|
| 7932 |
$log = array(
|
| 7933 |
'acting' => 'digitalcheck_conv',
|
| 7934 |
'key' => $_REQUEST['SID'],
|
| 7935 |
'result' => 'ORDER DATA REGISTERED ERROR',
|
| 7936 |
'data' => $_REQUEST,
|
| 7937 |
);
|
| 7938 |
usces_save_order_acting_error( $log );
|
| 7939 |
header( 'location: ' . USCES_CART_URL . $delim . 'acting=digitalcheck_conv&acting_return=0' );
|
| 7940 |
exit;
|
| 7941 |
}
|
| 7942 |
} else {
|
| 7943 |
$acting_opts = $this->options['acting_settings']['digitalcheck'];
|
| 7944 |
header( 'location: ' . $acting_opts['send_url_conv'] . '?acting=digitalcheck_conv' . $post_query );
|
| 7945 |
exit;
|
| 7946 |
}
|
| 7947 |
|
| 7948 |
} elseif ( 'acting_veritrans_card' == $acting_flg || 'acting_veritrans_conv' == $acting_flg ) { /* ベリトランス カード決済・コンビニ決済 */
|
| 7949 |
$acting_opts = $this->options['acting_settings']['veritrans'];
|
| 7950 |
$acting = substr( $acting_flg, 7 );
|
| 7951 |
$dummy_payment_flag = ( 'public' == $acting_opts['ope'] ) ? '0' : '1';
|
| 7952 |
$order_id = isset( $_POST['ORDER_ID'] ) ? $_POST['ORDER_ID'] : '';
|
| 7953 |
$regist_url = ( defined( 'VERITRANS_SHA2_TEST' ) ) ? 'https://sair.veritrans.co.jp/web/commodityRegist.action' : $acting_opts['regist_url'];
|
| 7954 |
$url = parse_url( $regist_url );
|
| 7955 |
$path = empty( $url['path'] ) ? '/' : $url['path'];
|
| 7956 |
|
| 7957 |
$postdata = $post_query;
|
| 7958 |
if ( 'acting_veritrans_card' == $acting_flg ) {
|
| 7959 |
$card_capture_flag = ( 'capture' == $acting_opts['card_capture_flag'] ) ? '1' : '0';
|
| 7960 |
$postdata .= '&CARD_CAPTURE_FLAG=' . $card_capture_flag;
|
| 7961 |
}
|
| 7962 |
if ( 'acting_veritrans_conv' == $acting_flg ) {
|
| 7963 |
$postdata .= '&NAME1=' . urlencode( mb_substr( mb_convert_kana( $entry['customer']['name1'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ) );
|
| 7964 |
$postdata .= '&NAME2=' . urlencode( mb_substr( mb_convert_kana( $entry['customer']['name2'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ) );
|
| 7965 |
if ( ! empty( $entry['customer']['name3'] ) ) {
|
| 7966 |
$kana1 = mb_substr( mb_convert_kana( $entry['customer']['name3'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' );
|
| 7967 |
mb_regex_encoding( 'UTF-8' );
|
| 7968 |
if ( mb_ereg( "^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana1 ) ) {
|
| 7969 |
$postdata .= '&KANA1=' . urlencode( $kana1 );
|
| 7970 |
}
|
| 7971 |
}
|
| 7972 |
if ( ! empty( $entry['customer']['name4'] ) ) {
|
| 7973 |
$kana2 = mb_substr( mb_convert_kana( $entry['customer']['name4'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' );
|
| 7974 |
mb_regex_encoding( 'UTF-8' );
|
| 7975 |
if ( mb_ereg( "^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana2 ) ) {
|
| 7976 |
$postdata .= '&KANA2=' . urlencode( $kana2 );
|
| 7977 |
}
|
| 7978 |
}
|
| 7979 |
$postdata .= '&TELEPHONE_NO=' . str_replace( '-', '', $entry['customer']['tel'] );
|
| 7980 |
if ( 1 < (int) $acting_opts['conv_timelimit'] && (int) $acting_opts['conv_timelimit'] <= 60 ) {
|
| 7981 |
$timelimit = date( 'Ymd', strtotime( '+' . $acting_opts['conv_timelimit'] . ' days' ) );
|
| 7982 |
$postdata .= '&TIMELIMIT_OF_PAYMENT=' . $timelimit;
|
| 7983 |
}
|
| 7984 |
}
|
| 7985 |
if ( 'on' == $acting_opts['mailaddress'] ) {
|
| 7986 |
$postdata .= '&MAILADDRESS=' . $entry['customer']['mailaddress1'];
|
| 7987 |
}
|
| 7988 |
$postdata .= '&MERCHANT_ID=' . $acting_opts['merchant_id'];
|
| 7989 |
$postdata .= '&SESSION_ID=' . session_id();
|
| 7990 |
$postdata .= '&FINISH_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&acting_return=1&result=1' );
|
| 7991 |
$postdata .= '&UNFINISH_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&confirm=1' );
|
| 7992 |
$postdata .= '&ERROR_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&acting_return=0' );
|
| 7993 |
$postdata .= '&FINISH_PAYMENT_ACCESS_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting );
|
| 7994 |
$postdata .= '&DUMMY_PAYMENT_FLAG=' . $dummy_payment_flag;
|
| 7995 |
|
| 7996 |
$postlength = strlen( $postdata );
|
| 7997 |
|
| 7998 |
$request = 'POST ' . $path . ' HTTP/1.1' . "\r\n";
|
| 7999 |
$request .= 'Host: ' . $url['host'] . "\r\n";
|
| 8000 |
$request .= 'User-Agent: HttpRequest Powered by ' . phpversion() . "\r\n";
|
| 8001 |
$request .= 'Connection: close' . "\r\n";
|
| 8002 |
$request .= 'Accept-Language: ja' . "\r\n";
|
| 8003 |
$request .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
|
| 8004 |
$request .= 'Content-Length: ' . $postlength . "\r\n\r\n";
|
| 8005 |
$request .= $postdata;
|
| 8006 |
|
| 8007 |
$code = 0;
|
| 8008 |
$resBody = '';
|
| 8009 |
$con = @stream_socket_client( 'tlsv1.2://' . $url['host'] . ':443', $errno, $errstr, 30 );
|
| 8010 |
if ( ! $con ) {
|
| 8011 |
usces_log( 'Veritrans : TLS(v1.2) Error', 'acting_transaction.log' );
|
| 8012 |
$con = @fsockopen( 'ssl://' . $url['host'], 443, $errno, $errstr, 30 );
|
| 8013 |
if ( ! $con ) {
|
| 8014 |
usces_log( 'Veritrans : SSL Error', 'acting_transaction.log' );
|
| 8015 |
$log = array(
|
| 8016 |
'acting' => $acting,
|
| 8017 |
'key' => $order_id,
|
| 8018 |
'result' => 'SSL/TLS ERROR (' . $errno . ')',
|
| 8019 |
'data' => array( $errstr ),
|
| 8020 |
);
|
| 8021 |
usces_save_order_acting_error( $log );
|
| 8022 |
header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' );
|
| 8023 |
exit;
|
| 8024 |
}
|
| 8025 |
}
|
| 8026 |
|
| 8027 |
if ( $con ) {
|
| 8028 |
$ret = fwrite( $con, $request );
|
| 8029 |
if ( $ret == strlen( $request ) ) {
|
| 8030 |
$res = $this->readResponse( $con );
|
| 8031 |
$code = $res['Code'];
|
| 8032 |
$resBody = $res['Body'];
|
| 8033 |
|
| 8034 |
} else {
|
| 8035 |
usces_log( 'Veritrans Write NG: Sent:' . strlen( $request ) . ' Send:' . $ret, 'acting_transaction.log' );
|
| 8036 |
}
|
| 8037 |
fclose( $con );
|
| 8038 |
}
|
| 8039 |
|
| 8040 |
// 正常終了(200 OK)が返ったか.
|
| 8041 |
if ( 200 == intval( $code ) ) {
|
| 8042 |
$merchantKey = null;
|
| 8043 |
$browserKey = null;
|
| 8044 |
$scd = null;
|
| 8045 |
$error_message = null;
|
| 8046 |
|
| 8047 |
// レスポンスデータからマーチャントキー、ブラウザキーを取得.
|
| 8048 |
$bodyLine = explode( "\n", $resBody );
|
| 8049 |
foreach ( $bodyLine as $line ) {
|
| 8050 |
if ( preg_match( '/^MERCHANT_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
|
| 8051 |
$merchantKey = $match[1];
|
| 8052 |
} elseif ( preg_match( '/^BROWSER_ENCRYPTION_KEY=(.+)/', $line, $match ) ) {
|
| 8053 |
$browserKey = $match[1];
|
| 8054 |
} elseif ( preg_match('/^SCD=(.+)/', $line, $match ) ) {
|
| 8055 |
$scd = $match[1];
|
| 8056 |
} elseif ( preg_match( '/^ERROR_MESSAGE=(.+)/', $line, $match ) ) {
|
| 8057 |
$error_message = $match[1];
|
| 8058 |
}
|
| 8059 |
}
|
| 8060 |
|
| 8061 |
// 両方取れたらOK。SCDはカードでセキュリティコードが入力された場合のみ.
|
| 8062 |
if ( ! is_null( $merchantKey ) && ! is_null( $browserKey ) ) {
|
| 8063 |
$getdata = '?MERCHANT_ID=' . $acting_opts['merchant_id'];
|
| 8064 |
$getdata .= '&ORDER_ID=' . $order_id;
|
| 8065 |
$getdata .= '&BROWSER_ENCRYPTION_KEY=' . urlencode( $browserKey );
|
| 8066 |
$payment_url = ( defined( 'VERITRANS_SHA2_TEST' ) ) ? 'https://sair.veritrans.co.jp/web/paymentStart.action' : $acting_opts['payment_url'];
|
| 8067 |
header( 'location: ' . $payment_url . $getdata );
|
| 8068 |
|
| 8069 |
} else {
|
| 8070 |
if ( ! is_null( $error_message ) ) {
|
| 8071 |
usces_log( 'Veritrans AWeb:' . $error_message, 'acting_transaction.log' );
|
| 8072 |
$log = array(
|
| 8073 |
'acting' => $acting,
|
| 8074 |
'key' => $order_id,
|
| 8075 |
'result' => $code,
|
| 8076 |
'data' => $bodyLine,
|
| 8077 |
);
|
| 8078 |
usces_save_order_acting_error( $log );
|
| 8079 |
}
|
| 8080 |
header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' );
|
| 8081 |
}
|
| 8082 |
|
| 8083 |
} else {
|
| 8084 |
usces_log( 'Veritrans Response NG: ' . $resBody, 'acting_transaction.log' );
|
| 8085 |
$bodyLine = explode( "\n", $resBody );
|
| 8086 |
$log = array(
|
| 8087 |
'acting' => $acting,
|
| 8088 |
'key' => $order_id,
|
| 8089 |
'result' => $code,
|
| 8090 |
'data' => $bodyLine,
|
| 8091 |
);
|
| 8092 |
usces_save_order_acting_error( $log );
|
| 8093 |
header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' );
|
| 8094 |
}
|
| 8095 |
exit;
|
| 8096 |
}
|
| 8097 |
|
| 8098 |
do_action( 'usces_action_acting_processing', $acting_flg, $post_query );
|
| 8099 |
$acting_status = apply_filters( 'usces_filter_acting_processing', $acting_flg, $post_query, $acting_status );
|
| 8100 |
return $acting_status;
|
| 8101 |
}
|
| 8102 |
|
| 8103 |
private function readResponse( $fp ) {
|
| 8104 |
$res = array(
|
| 8105 |
'Status' => '',
|
| 8106 |
'Version' => '',
|
| 8107 |
'Code' => 0,
|
| 8108 |
'Message' => '',
|
| 8109 |
'Headers' => array(),
|
| 8110 |
'Body' => '',
|
| 8111 |
);
|
| 8112 |
|
| 8113 |
// HTTPステータスの読み込み.
|
| 8114 |
$line = $this->readLine( $fp );
|
| 8115 |
if ( 0 == preg_match( '/^(HTTP\/1\.[0-9x]+)\s+([0-9]+)\s+(.+)/i', $line, $match ) ) {
|
| 8116 |
return $res;
|
| 8117 |
}
|
| 8118 |
$res['Status'] = $line;
|
| 8119 |
$res['Version'] = $match[1];
|
| 8120 |
$res['Code'] = $match[2];
|
| 8121 |
$res['Message'] = $match[3];
|
| 8122 |
|
| 8123 |
// レスポンスヘッダの読み込み.
|
| 8124 |
while ( ! feof( $fp ) ) {
|
| 8125 |
$line = $this->readLine( $fp );
|
| 8126 |
if ( '' != $line ) {
|
| 8127 |
list( $hname, $hvalue ) = explode( ':', $line, 2 );
|
| 8128 |
$res['Headers'][ strtolower( $hname ) ] = ltrim( $hvalue );
|
| 8129 |
} else {
|
| 8130 |
break;
|
| 8131 |
}
|
| 8132 |
}
|
| 8133 |
// レスポンスデータの読み込み.
|
| 8134 |
while ( ! feof( $fp ) ) {
|
| 8135 |
$data = $this->readLine( $fp ) . "\n";
|
| 8136 |
if ( '' == $data ) {
|
| 8137 |
break;
|
| 8138 |
}
|
| 8139 |
$res['Body'] .= $data;
|
| 8140 |
}
|
| 8141 |
return $res;
|
| 8142 |
}
|
| 8143 |
|
| 8144 |
private function readLine( $fp ) {
|
| 8145 |
if ( ! $fp ) {
|
| 8146 |
return '';
|
| 8147 |
}
|
| 8148 |
// レスポンスデータを受信.
|
| 8149 |
$line = null;
|
| 8150 |
while ( ! feof( $fp ) ) {
|
| 8151 |
$line .= @fgets( $fp, 4096 );
|
| 8152 |
if ( "\n" == substr( $line, -1 ) ) {
|
| 8153 |
return rtrim( $line, "\r\n" );
|
| 8154 |
}
|
| 8155 |
}
|
| 8156 |
return $line;
|
| 8157 |
}
|
| 8158 |
|
| 8159 |
public function inquiry_processing() {
|
| 8160 |
$mail_res = usces_send_inquirymail();
|
| 8161 |
|
| 8162 |
if ( $mail_res ) {
|
| 8163 |
return 'inquiry_comp';
|
| 8164 |
} else {
|
| 8165 |
return 'inquiry_error';
|
| 8166 |
}
|
| 8167 |
}
|
| 8168 |
|
| 8169 |
public function lastprocessing() {
|
| 8170 |
if ( 'ordercompletion' == $this->page ) {
|
| 8171 |
$this->cart->crear_cart();
|
| 8172 |
}
|
| 8173 |
do_action( 'usces_action_lastprocessing' );
|
| 8174 |
|
| 8175 |
unset( $_SESSION['usces_singleitem'] );
|
| 8176 |
}
|
| 8177 |
|
| 8178 |
public function is_item_zaiko( $post_id, $sku_code ) {
|
| 8179 |
$res = false;
|
| 8180 |
$status_num = false;
|
| 8181 |
$zaiko_num = false;
|
| 8182 |
if ( ! empty( $post_id ) ) {
|
| 8183 |
$sku_code = (string) $sku_code;
|
| 8184 |
$status_num = $this->getItemZaikoStatusId( $post_id, $sku_code );
|
| 8185 |
$zaiko_num = $this->getItemZaikoNum( $post_id, $sku_code );
|
| 8186 |
$itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id );
|
| 8187 |
if ( 1 != $itemOrderAcceptable ) {
|
| 8188 |
if ( false !== $zaiko_num
|
| 8189 |
&& ( 0 < (int) $zaiko_num || WCUtils::is_blank( $zaiko_num ) )
|
| 8190 |
&& false !== $status_num
|
| 8191 |
&& 2 > (int) $status_num ) {
|
| 8192 |
$res = true;
|
| 8193 |
} else {
|
| 8194 |
$res = false;
|
| 8195 |
}
|
| 8196 |
} else {
|
| 8197 |
if ( false !== $status_num
|
| 8198 |
&& 2 > (int) $status_num ) {
|
| 8199 |
$res = true;
|
| 8200 |
} else {
|
| 8201 |
$res = false;
|
| 8202 |
}
|
| 8203 |
}
|
| 8204 |
}
|
| 8205 |
return apply_filters( 'usces_is_item_zaiko', $res, $post_id, $sku_code, $status_num, $zaiko_num );
|
| 8206 |
}
|
| 8207 |
|
| 8208 |
public function get_total_price( $cart = array() ) {
|
| 8209 |
if ( empty( $cart ) ) {
|
| 8210 |
$cart = $this->cart->get_cart();
|
| 8211 |
}
|
| 8212 |
$total_price = 0;
|
| 8213 |
|
| 8214 |
if ( ! empty( $cart ) ) {
|
| 8215 |
$cart_count = ( is_array( $cart ) ) ? count( $cart ) : 0;
|
| 8216 |
for ( $i = 0; $i < $cart_count; $i++ ) {
|
| 8217 |
$quantity = (float) $cart[ $i ]['quantity'];
|
| 8218 |
$skuPrice = (float) $cart[ $i ]['price'];
|
| 8219 |
|
| 8220 |
$total_price += ( $skuPrice * $quantity );
|
| 8221 |
}
|
| 8222 |
}
|
| 8223 |
return apply_filters( 'usces_filter_get_total_price', $total_price, $cart );
|
| 8224 |
}
|
| 8225 |
|
| 8226 |
public function get_total_quantity( $cart = array() ) {
|
| 8227 |
if ( empty( $cart ) ) {
|
| 8228 |
$cart = $this->cart->get_cart();
|
| 8229 |
}
|
| 8230 |
$total_quantity = 0;
|
| 8231 |
|
| 8232 |
if ( ! empty( $cart ) ) {
|
| 8233 |
$cart_count = ( is_array( $cart ) ) ? count( $cart ) : 0;
|
| 8234 |
for ( $i = 0; $i < $cart_count; $i++ ) {
|
| 8235 |
$total_quantity += (float) $cart[ $i ]['quantity'];
|
| 8236 |
}
|
| 8237 |
}
|
| 8238 |
return $total_quantity;
|
| 8239 |
}
|
| 8240 |
|
| 8241 |
public function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) {
|
| 8242 |
if ( '' == $mem_id || 'deactivate' == $this->options['membersystem_state'] || 'deactivate' == $this->options['membersystem_point'] ) {
|
| 8243 |
return 0;
|
| 8244 |
}
|
| 8245 |
|
| 8246 |
if ( empty( $cart ) ) {
|
| 8247 |
$cart = $this->cart->get_cart();
|
| 8248 |
}
|
| 8249 |
if ( empty( $display_mode ) ) {
|
| 8250 |
$display_mode = $this->options['display_mode'];
|
| 8251 |
}
|
| 8252 |
$point = 0;
|
| 8253 |
$total = $this->get_total_price( $cart );
|
| 8254 |
if ( 'Promotionsale' == $display_mode ) {
|
| 8255 |
if ( 'discount' == $this->options['campaign_privilege'] ) {
|
| 8256 |
foreach ( $cart as $rows ) {
|
| 8257 |
$cats = $this->get_post_term_ids( $rows['post_id'], 'category' );
|
| 8258 |
if ( ! in_array( $this->options['campaign_category'], $cats ) ) {
|
| 8259 |
$product = wel_get_product( $rows['post_id'] );
|
| 8260 |
$rate = (float) $product['itemPointrate'];
|
| 8261 |
$price = (float) $rows['price'] * (float) $rows['quantity'];
|
| 8262 |
$point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 ) );
|
| 8263 |
}
|
| 8264 |
}
|
| 8265 |
} elseif ( 'point' == $this->options['campaign_privilege'] ) {
|
| 8266 |
foreach ( $cart as $rows ) {
|
| 8267 |
$product = wel_get_product( $rows['post_id'] );
|
| 8268 |
$rate = (float) $product['itemPointrate'];
|
| 8269 |
$price = (float) $rows['price'] * (float) $rows['quantity'];
|
| 8270 |
$cats = $this->get_post_term_ids( $rows['post_id'], 'category' );
|
| 8271 |
if ( in_array( $this->options['campaign_category'], $cats ) ) {
|
| 8272 |
$point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 * (float) $this->options['privilege_point'] ) );
|
| 8273 |
} else {
|
| 8274 |
$point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 ) );
|
| 8275 |
}
|
| 8276 |
}
|
| 8277 |
}
|
| 8278 |
} else {
|
| 8279 |
foreach ( $cart as $rows ) {
|
| 8280 |
$product = wel_get_product( $rows['post_id'] );
|
| 8281 |
$rate = (float) $product['itemPointrate'];
|
| 8282 |
$price = (float) $rows['price'] * (float) $rows['quantity'];
|
| 8283 |
$point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 ) );
|
| 8284 |
}
|
| 8285 |
}
|
| 8286 |
|
| 8287 |
$entry = $this->cart->get_entry();
|
| 8288 |
$use_point = isset( $entry['order']['usedpoint'] ) ? (int) $entry['order']['usedpoint'] : 0;
|
| 8289 |
if ( 0 < $use_point && 0 < $total ) {
|
| 8290 |
$point = (float) sprintf( '%.3f', $point - ( $point * $use_point / $total ) );
|
| 8291 |
$point = ceil( $point );
|
| 8292 |
if ( 0 > $point ) {
|
| 8293 |
$point = 0;
|
| 8294 |
}
|
| 8295 |
} else {
|
| 8296 |
if ( 0 < $point ) {
|
| 8297 |
$point = ceil( $point );
|
| 8298 |
}
|
| 8299 |
}
|
| 8300 |
|
| 8301 |
return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
|
| 8302 |
}
|
| 8303 |
|
| 8304 |
public function get_order_discount( $display_mode = '', $cart = array() ) {
|
| 8305 |
if ( empty( $cart ) ) {
|
| 8306 |
$cart = $this->cart->get_cart();
|
| 8307 |
}
|
| 8308 |
if ( empty( $display_mode ) ) {
|
| 8309 |
$display_mode = $this->options['display_mode'];
|
| 8310 |
}
|
| 8311 |
$discount = 0;
|
| 8312 |
if ( 'Promotionsale' == $display_mode ) {
|
| 8313 |
if ( 'discount' == $this->options['campaign_privilege'] ) {
|
| 8314 |
if ( 0 === (int) $this->options['campaign_category'] ) {
|
| 8315 |
$total = $this->get_total_price( $cart );
|
| 8316 |
$discount = (float) sprintf( '%.3f', $total * (float) $this->options['privilege_discount'] / 100 );
|
| 8317 |
} else {
|
| 8318 |
foreach ( $cart as $cart_row ) {
|
| 8319 |
if ( in_category( (int) $this->options['campaign_category'], $cart_row['post_id'] ) ) {
|
| 8320 |
$discount += (float) sprintf( '%.3f', (float) $cart_row['price'] * (float) $cart_row['quantity'] * (float) $this->options['privilege_discount'] / 100 );
|
| 8321 |
}
|
| 8322 |
}
|
| 8323 |
}
|
| 8324 |
if ( 0 != $discount ) {
|
| 8325 |
$decimal = $this->get_currency_decimal();
|
| 8326 |
if ( 0 == $decimal ) {
|
| 8327 |
$discount = ceil( $discount );
|
| 8328 |
} else {
|
| 8329 |
$decipad = (int) str_pad( '1', $decimal + 1, '0', STR_PAD_RIGHT );
|
| 8330 |
$discount = ceil( $discount * $decipad ) / $decipad;
|
| 8331 |
}
|
| 8332 |
$discount = $discount * -1;
|
| 8333 |
}
|
| 8334 |
} elseif ( 'point' == $this->options['campaign_privilege'] ) {
|
| 8335 |
$discount = 0;
|
| 8336 |
}
|
| 8337 |
}
|
| 8338 |
$discount = apply_filters( 'usces_order_discount', $discount, $cart );
|
| 8339 |
return $discount;
|
| 8340 |
}
|
| 8341 |
|
| 8342 |
public function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
|
| 8343 |
if ( empty( $cart ) ) {
|
| 8344 |
$cart = $this->cart->get_cart();
|
| 8345 |
}
|
| 8346 |
if ( empty( $entry ) ) {
|
| 8347 |
$entry = $this->cart->get_entry();
|
| 8348 |
}
|
| 8349 |
if ( function_exists( 'dlseller_have_shipped' ) && ! dlseller_have_shipped() ) {
|
| 8350 |
$charge = 0;
|
| 8351 |
$charge = apply_filters( 'usces_filter_getShippingCharge', $charge, $cart, $entry );
|
| 8352 |
return $charge;
|
| 8353 |
}
|
| 8354 |
|
| 8355 |
// 配送方法ID.
|
| 8356 |
$d_method_id = $entry['order']['delivery_method'];
|
| 8357 |
// 配送方法index.
|
| 8358 |
$d_method_index = $this->get_delivery_method_index( $d_method_id );
|
| 8359 |
// 送料ID.
|
| 8360 |
$fixed_charge_id = ( isset( $this->options['delivery_method'][ $d_method_index ]['charge'] ) ) ? $this->options['delivery_method'][ $d_method_index ]['charge'] : -1;
|
| 8361 |
$individual_quant = 0;
|
| 8362 |
$total_quant = 0;
|
| 8363 |
$charges = array();
|
| 8364 |
$individual_charges = array();
|
| 8365 |
$country = ( isset( $entry['delivery']['country'] ) && ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : $entry['customer']['country'];
|
| 8366 |
|
| 8367 |
foreach ( $cart as $rows ) {
|
| 8368 |
|
| 8369 |
if ( 'shipped' !== $this->getItemDivision( $rows['post_id'] ) ) {
|
| 8370 |
continue;
|
| 8371 |
}
|
| 8372 |
|
| 8373 |
if ( -1 == $fixed_charge_id ) {
|
| 8374 |
// 商品送料ID.
|
| 8375 |
$s_charge_id = $this->getItemShippingCharge( $rows['post_id'] );
|
| 8376 |
// 商品送料index.
|
| 8377 |
$s_charge_index = $this->get_shipping_charge_index( $s_charge_id );
|
| 8378 |
$s_charge = isset( $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] ) ? (float) $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] : 0;
|
| 8379 |
} else {
|
| 8380 |
$s_charge_index = $this->get_shipping_charge_index( $fixed_charge_id );
|
| 8381 |
$s_charge = isset( $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] ) ? (float) $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] : 0;
|
| 8382 |
}
|
| 8383 |
|
| 8384 |
if ( $this->getItemIndividualSCharge( $rows['post_id'] ) ) {
|
| 8385 |
$individual_quant += (float) $rows['quantity'];
|
| 8386 |
$individual_charges[] = (float) $rows['quantity'] * $s_charge;
|
| 8387 |
} else {
|
| 8388 |
$charges[] = $s_charge;
|
| 8389 |
}
|
| 8390 |
$total_quant += $rows['quantity'];
|
| 8391 |
}
|
| 8392 |
|
| 8393 |
if ( count( $charges ) > 0 ) {
|
| 8394 |
rsort( $charges );
|
| 8395 |
$max_charge = $charges[0];
|
| 8396 |
$charge = $max_charge + array_sum( array_filter( $individual_charges, 'is_numeric' ) );
|
| 8397 |
} else {
|
| 8398 |
$charge = array_sum( array_filter( $individual_charges, 'is_numeric' ) );
|
| 8399 |
}
|
| 8400 |
|
| 8401 |
$charge = apply_filters( 'usces_filter_getShippingCharge', $charge, $cart, $entry );
|
| 8402 |
|
| 8403 |
return $charge;
|
| 8404 |
}
|
| 8405 |
|
| 8406 |
public function getCODFee( $payment_name, $amount_by_cod, $current_entries ) {
|
| 8407 |
global $usces_entries;
|
| 8408 |
|
| 8409 |
$payments = $this->getPayments( $payment_name );
|
| 8410 |
if ( ! isset( $payments['settlement'] ) || 'COD' != $payments['settlement'] ) {
|
| 8411 |
$fee = 0;
|
| 8412 |
|
| 8413 |
} elseif ( 'change' != $this->options['cod_type'] ) {
|
| 8414 |
$fee = isset( $this->options['cod_fee'] ) ? $this->options['cod_fee'] : 0;
|
| 8415 |
|
| 8416 |
} else {
|
| 8417 |
$materials = array(
|
| 8418 |
'total_items_price' => $current_entries['order']['total_items_price'],
|
| 8419 |
'discount' => ( isset( $current_entries['order']['discount'] ) ) ? $current_entries['order']['discount'] : 0,
|
| 8420 |
'shipping_charge' => ( isset( $current_entries['order']['shipping_charge'] ) ) ? $current_entries['order']['shipping_charge'] : 0,
|
| 8421 |
'cod_fee' => 0,
|
| 8422 |
'use_point' => 0,
|
| 8423 |
);
|
| 8424 |
$price = $amount_by_cod + $this->getTax( $amount_by_cod, $materials );
|
| 8425 |
if ( $price <= $this->options['cod_first_amount'] ) {
|
| 8426 |
$fee = $this->options['cod_first_fee'];
|
| 8427 |
|
| 8428 |
} elseif ( isset( $this->options['cod_amounts'] ) ) {
|
| 8429 |
$last = count( $this->options['cod_amounts'] ) - 1;
|
| 8430 |
if ( $price > $this->options['cod_amounts'][ $last ] ) {
|
| 8431 |
$fee = $this->options['cod_end_fee'];
|
| 8432 |
|
| 8433 |
} else {
|
| 8434 |
$fee = 0;
|
| 8435 |
foreach ( $this->options['cod_amounts'] as $key => $value ) {
|
| 8436 |
if ( $price <= $value ) {
|
| 8437 |
$fee = $this->options['cod_fees'][ $key ];
|
| 8438 |
break;
|
| 8439 |
}
|
| 8440 |
}
|
| 8441 |
}
|
| 8442 |
} else {
|
| 8443 |
$fee = $this->options['cod_end_fee'];
|
| 8444 |
}
|
| 8445 |
}
|
| 8446 |
$fee = apply_filters( 'usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod, $current_entries );
|
| 8447 |
return $fee;
|
| 8448 |
}
|
| 8449 |
|
| 8450 |
public function getTax( $total, $materials = array() ) {
|
| 8451 |
global $usces_settings;
|
| 8452 |
|
| 8453 |
if ( isset( $this->options['tax_display'] ) && 'deactivate' == $this->options['tax_display'] ) {
|
| 8454 |
return 0;
|
| 8455 |
}
|
| 8456 |
if ( empty( $this->options['tax_rate'] ) ) {
|
| 8457 |
return 0;
|
| 8458 |
}
|
| 8459 |
// if ( ! empty( $materials ) ) {
|
| 8460 |
// extract( $materials );//need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' )
|
| 8461 |
// }
|
| 8462 |
|
| 8463 |
if ( $this->is_reduced_taxrate() ) {
|
| 8464 |
if ( 'include' == $this->options['tax_mode'] ) {
|
| 8465 |
return 0;
|
| 8466 |
}
|
| 8467 |
if ( ! empty( $materials ) ) {
|
| 8468 |
extract( $materials );
|
| 8469 |
if ( empty( $carts ) ) {
|
| 8470 |
$carts = array();
|
| 8471 |
$materials = compact( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point', 'carts' );
|
| 8472 |
}
|
| 8473 |
}
|
| 8474 |
|
| 8475 |
$usces_tax = Welcart_Tax::get_instance();
|
| 8476 |
$usces_tax->get_order_tax( $materials );
|
| 8477 |
$tax = apply_filters( 'usces_filter_getTax', $usces_tax->tax, $materials );
|
| 8478 |
|
| 8479 |
} else {
|
| 8480 |
|
| 8481 |
if ( empty( $materials ) ) {
|
| 8482 |
|
| 8483 |
if ( 'include' == $this->options['tax_mode'] ) {
|
| 8484 |
$tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / ( 100 + (float) $this->options['tax_rate'] ) );
|
| 8485 |
} else {
|
| 8486 |
$tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / 100 );
|
| 8487 |
}
|
| 8488 |
|
| 8489 |
} else {
|
| 8490 |
if ( 'include' == $this->options['tax_mode'] ) {
|
| 8491 |
return 0;
|
| 8492 |
}
|
| 8493 |
|
| 8494 |
extract( $materials ); // need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' ).
|
| 8495 |
|
| 8496 |
if ( 1 == $this->options['point_coverage'] ) {
|
| 8497 |
if ( 'products' == $this->options['tax_target'] ) {
|
| 8498 |
$total = (float) $total_items_price + (float) $discount;
|
| 8499 |
} else {
|
| 8500 |
$total = (float) $total_items_price + (float) $discount + (float) $shipping_charge + (float) $cod_fee;
|
| 8501 |
}
|
| 8502 |
} else {
|
| 8503 |
if ( 'products' == $this->options['tax_target'] ) {
|
| 8504 |
$total = (float) $total_items_price + (float) $discount;
|
| 8505 |
} else {
|
| 8506 |
if ( empty( $use_point ) ) {
|
| 8507 |
$use_point = 0;
|
| 8508 |
}
|
| 8509 |
$total = (float) $total_items_price + (float) $discount - (int) $use_point + (float) $shipping_charge + (float) $cod_fee;
|
| 8510 |
}
|
| 8511 |
}
|
| 8512 |
$total = apply_filters( 'usces_filter_getTax_total', $total, $materials );
|
| 8513 |
|
| 8514 |
$tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / 100 );
|
| 8515 |
}
|
| 8516 |
|
| 8517 |
$tax = usces_tax_rounding_off( $tax );
|
| 8518 |
$tax = apply_filters( 'usces_filter_getTax', $tax, $materials );
|
| 8519 |
}
|
| 8520 |
|
| 8521 |
return $tax;
|
| 8522 |
}
|
| 8523 |
|
| 8524 |
public function set_cart_fees( $member, $entries ) {
|
| 8525 |
global $usces_entries;
|
| 8526 |
|
| 8527 |
$carts = $this->cart->get_cart();
|
| 8528 |
$entries = $this->cart->get_entry();
|
| 8529 |
$total_items_price = $this->get_total_price();
|
| 8530 |
$entries['order']['total_items_price'] = $total_items_price;
|
| 8531 |
|
| 8532 |
if ( empty( $this->options['postage_privilege'] ) || $total_items_price < $this->options['postage_privilege'] ) {
|
| 8533 |
$shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'], $carts, $entries );
|
| 8534 |
} else {
|
| 8535 |
$shipping_charge = 0;
|
| 8536 |
}
|
| 8537 |
$shipping_charge = apply_filters( 'usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries );
|
| 8538 |
$entries['order']['shipping_charge'] = $shipping_charge;
|
| 8539 |
|
| 8540 |
$payments = $this->getPayments( $entries['order']['payment_name'] );
|
| 8541 |
$use_point = ( isset( $entries['order']['usedpoint'] ) ) ? (int) $entries['order']['usedpoint'] : 0;
|
| 8542 |
if ( $this->is_reduced_taxrate() ) {
|
| 8543 |
$usces_tax = Welcart_Tax::get_instance();
|
| 8544 |
$discount = $usces_tax->get_order_discount( $carts );
|
| 8545 |
$entries['order']['discount'] = $discount;
|
| 8546 |
$amount_by_cod = $total_items_price - $use_point + $discount;
|
| 8547 |
if ( 'all' == usces_is_fee_subject() ) {
|
| 8548 |
$amount_by_cod += $shipping_charge;
|
| 8549 |
}
|
| 8550 |
$amount_by_cod = apply_filters( 'usces_filter_set_cart_fees_amount_by_cod', $amount_by_cod, $entries, $total_items_price, $use_point, $discount, $shipping_charge );
|
| 8551 |
$cod_fee = $this->getCODFee( $entries['order']['payment_name'], $amount_by_cod, $entries );
|
| 8552 |
$cod_fee = apply_filters( 'usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod );
|
| 8553 |
$entries['order']['cod_fee'] = $cod_fee;
|
| 8554 |
|
| 8555 |
if ( 'include' == $this->options['tax_mode'] ) {
|
| 8556 |
$tax = 0;
|
| 8557 |
} else {
|
| 8558 |
$materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point' );
|
| 8559 |
$usces_tax->get_order_tax( $materials );
|
| 8560 |
$tax = apply_filters( 'usces_filter_getTax', $usces_tax->tax, $materials );
|
| 8561 |
}
|
| 8562 |
|
| 8563 |
$total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
|
| 8564 |
if ( $total_price < 0 ) {
|
| 8565 |
$total_price = 0;
|
| 8566 |
}
|
| 8567 |
$total_price = apply_filters( 'usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee );
|
| 8568 |
|
| 8569 |
} else {
|
| 8570 |
$discount = $this->get_order_discount( null, $carts );
|
| 8571 |
$entries['order']['discount'] = $discount;
|
| 8572 |
$amount_by_cod = $total_items_price - $use_point + $discount;
|
| 8573 |
if ( 'all' == usces_is_fee_subject() ) {
|
| 8574 |
$amount_by_cod += $shipping_charge;
|
| 8575 |
}
|
| 8576 |
$amount_by_cod = apply_filters( 'usces_filter_set_cart_fees_amount_by_cod', $amount_by_cod, $entries, $total_items_price, $use_point, $discount, $shipping_charge );
|
| 8577 |
$cod_fee = $this->getCODFee( $entries['order']['payment_name'], $amount_by_cod, $entries );
|
| 8578 |
$cod_fee = apply_filters( 'usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod );
|
| 8579 |
$entries['order']['cod_fee'] = $cod_fee;
|
| 8580 |
|
| 8581 |
$total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
|
| 8582 |
if ( $total_price < 0 ) {
|
| 8583 |
$total_price = 0;
|
| 8584 |
}
|
| 8585 |
$total_price = apply_filters( 'usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee );
|
| 8586 |
|
| 8587 |
$materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point' );
|
| 8588 |
$tax = $this->getTax( $total_price, $materials );
|
| 8589 |
}
|
| 8590 |
$entries['order']['total_price'] = $total_price;
|
| 8591 |
$entries['order']['tax'] = $tax;
|
| 8592 |
|
| 8593 |
if ( 'exclude' == $this->options['tax_mode'] ) {
|
| 8594 |
if ( 0 < $use_point ) {
|
| 8595 |
$total_full_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee + $tax;
|
| 8596 |
if ( $total_full_price < 0 ) {
|
| 8597 |
$total_full_price = 0;
|
| 8598 |
}
|
| 8599 |
} else {
|
| 8600 |
$total_full_price = $total_price + $tax;
|
| 8601 |
}
|
| 8602 |
} else {
|
| 8603 |
$total_full_price = $total_price;
|
| 8604 |
}
|
| 8605 |
|
| 8606 |
$total_full_price = apply_filters( 'usces_filter_set_cart_fees_total_full_price', $total_full_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee );
|
| 8607 |
$entries['order']['total_full_price'] = $total_full_price;
|
| 8608 |
|
| 8609 |
$mem_id = isset( $member['ID'] ) ? $member['ID'] : null;
|
| 8610 |
$get_point = $this->get_order_point( $mem_id );
|
| 8611 |
$get_point = apply_filters( 'usces_filter_set_get_point', $get_point, $entries, $carts );
|
| 8612 |
|
| 8613 |
$array = array(
|
| 8614 |
'total_items_price' => $total_items_price,
|
| 8615 |
'total_price' => $total_price,
|
| 8616 |
'total_full_price' => $total_full_price,
|
| 8617 |
'getpoint' => $get_point,
|
| 8618 |
'usedpoint' => $use_point,
|
| 8619 |
'discount' => $discount,
|
| 8620 |
'shipping_charge' => $shipping_charge,
|
| 8621 |
'cod_fee' => $cod_fee,
|
| 8622 |
'tax' => $tax,
|
| 8623 |
);
|
| 8624 |
$this->cart->set_order_entry( $array );
|
| 8625 |
$usces_entries = $this->cart->get_entry();
|
| 8626 |
}
|
| 8627 |
|
| 8628 |
public function getPayments( $payment_name ) {
|
| 8629 |
$init = array(
|
| 8630 |
'id' => null,
|
| 8631 |
'name' => null,
|
| 8632 |
'explanation' => null,
|
| 8633 |
'settlement' => null,
|
| 8634 |
'module' => null,
|
| 8635 |
'sort' => null,
|
| 8636 |
'use' => null,
|
| 8637 |
);
|
| 8638 |
|
| 8639 |
if ( '#none#' == $payment_name ) {
|
| 8640 |
return $init;
|
| 8641 |
}
|
| 8642 |
$payments = usces_get_system_option( 'usces_payment_method', 'name' );
|
| 8643 |
if ( isset( $payments[ $payment_name ] ) ) {
|
| 8644 |
return $payments[ $payment_name ];
|
| 8645 |
}
|
| 8646 |
return $init;
|
| 8647 |
}
|
| 8648 |
|
| 8649 |
public function is_maintenance() {
|
| 8650 |
if ( 'Maintenancemode' == $this->options['display_mode'] ) {
|
| 8651 |
return true;
|
| 8652 |
} else {
|
| 8653 |
return false;
|
| 8654 |
}
|
| 8655 |
}
|
| 8656 |
|
| 8657 |
public function get_member_history( $mem_id, $allow_filter = false ) {
|
| 8658 |
global $wpdb;
|
| 8659 |
$order_table = $wpdb->prefix . 'usces_order';
|
| 8660 |
|
| 8661 |
if ( is_user_logged_in() && is_admin() ) {
|
| 8662 |
|
| 8663 |
$query = $wpdb->prepare( "SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id );
|
| 8664 |
$query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id, $allow_filter );
|
| 8665 |
$results = $wpdb->get_results( $query );
|
| 8666 |
|
| 8667 |
} elseif ( ! is_admin() ) {
|
| 8668 |
|
| 8669 |
$cancel_query = '%cancel%';
|
| 8670 |
$estimate_query = '%estimate%';
|
| 8671 |
$exclude_cancel = $this->usces_get_member_cookies( 'ord_ex_cancel' );
|
| 8672 |
if ( $allow_filter && 'on' === (string) $exclude_cancel ) {
|
| 8673 |
$condition = ' ( order_status NOT LIKE %s AND order_status NOT LIKE %s ) ';
|
| 8674 |
} else {
|
| 8675 |
$condition = ' ( order_status LIKE %s OR order_status NOT LIKE %s ) ';
|
| 8676 |
}
|
| 8677 |
|
| 8678 |
$pur_date = $this->usces_get_member_cookies( 'pur-date' );
|
| 8679 |
if ( $allow_filter && $pur_date ) {
|
| 8680 |
$now = current_time( 'timestamp' );
|
| 8681 |
$type_filter = 'date';
|
| 8682 |
if ( false !== strpos( $pur_date, 'y_' ) ) {
|
| 8683 |
$type_filter = 'year';
|
| 8684 |
} elseif ( false !== strpos( $pur_date, 'm_' ) ) {
|
| 8685 |
$type_filter = 'month';
|
| 8686 |
}
|
| 8687 |
if ( 'year' === $type_filter ) {
|
| 8688 |
$purchase_year = (int) str_replace( 'y_', '', $pur_date );
|
| 8689 |
} elseif ( 'month' === $type_filter ) {
|
| 8690 |
$month_ago = (int) str_replace( 'm_', '', $pur_date );
|
| 8691 |
$first_day_of_previous_months = strtotime( "first day of -{$month_ago} months", $now );
|
| 8692 |
$last_day_of_previous_months = strtotime( "last day of -{$month_ago} months", $now );
|
| 8693 |
$purchase_date_from_string = date( 'Y-m-d 00:00:00', $first_day_of_previous_months );
|
| 8694 |
$purchase_date_to_string = date( 'Y-m-d 23:59:59', $last_day_of_previous_months );
|
| 8695 |
} else {
|
| 8696 |
$pur_date_val = (int) str_replace( 'd_', '', $pur_date );
|
| 8697 |
$previous_date = strtotime( "-{$pur_date_val} days", $now );
|
| 8698 |
$purchase_date_string = date( 'Y-m-d 00:00:00', $previous_date );
|
| 8699 |
}
|
| 8700 |
if ( 'year' === $type_filter ) {
|
| 8701 |
$query = $wpdb->prepare(
|
| 8702 |
"SELECT * FROM $order_table WHERE mem_id = %d AND YEAR(order_date) = %d AND {$condition} ORDER BY order_date DESC",
|
| 8703 |
$mem_id,
|
| 8704 |
$purchase_year,
|
| 8705 |
$cancel_query,
|
| 8706 |
$estimate_query
|
| 8707 |
);
|
| 8708 |
} elseif ( 'month' === $type_filter ) {
|
| 8709 |
$query = $wpdb->prepare(
|
| 8710 |
"SELECT * FROM $order_table WHERE mem_id = %d AND order_date >= %s AND order_date <= %s AND {$condition} ORDER BY order_date DESC",
|
| 8711 |
$mem_id,
|
| 8712 |
$purchase_date_from_string,
|
| 8713 |
$purchase_date_to_string,
|
| 8714 |
$cancel_query,
|
| 8715 |
$estimate_query
|
| 8716 |
);
|
| 8717 |
} else {
|
| 8718 |
$query = $wpdb->prepare(
|
| 8719 |
"SELECT * FROM $order_table WHERE mem_id = %d AND order_date >= %s AND {$condition} ORDER BY order_date DESC",
|
| 8720 |
$mem_id,
|
| 8721 |
$purchase_date_string,
|
| 8722 |
$cancel_query,
|
| 8723 |
$estimate_query
|
| 8724 |
);
|
| 8725 |
}
|
| 8726 |
} else {
|
| 8727 |
$query = $wpdb->prepare(
|
| 8728 |
"SELECT * FROM $order_table WHERE mem_id = %d AND {$condition} ORDER BY order_date DESC",
|
| 8729 |
$mem_id,
|
| 8730 |
$cancel_query,
|
| 8731 |
$estimate_query
|
| 8732 |
);
|
| 8733 |
}
|
| 8734 |
|
| 8735 |
$query = apply_filters( 'usces_filter_member_history_query_front', $query, $mem_id, $allow_filter );
|
| 8736 |
$results = $wpdb->get_results( $query );
|
| 8737 |
}
|
| 8738 |
|
| 8739 |
$i = 0;
|
| 8740 |
$res = array();
|
| 8741 |
|
| 8742 |
foreach ( $results as $value ) {
|
| 8743 |
$cart = usces_get_ordercartdata( $value->ID );
|
| 8744 |
$total_items_price = $this->get_total_price( $cart );
|
| 8745 |
|
| 8746 |
$data = array(
|
| 8747 |
'ID' => $value->ID,
|
| 8748 |
'cart' => $cart,
|
| 8749 |
'condition' => unserialize( $value->order_condition ),
|
| 8750 |
'getpoint' => $value->order_getpoint,
|
| 8751 |
'usedpoint' => $value->order_usedpoint,
|
| 8752 |
'discount' => $value->order_discount,
|
| 8753 |
'shipping_charge' => $value->order_shipping_charge,
|
| 8754 |
'payment_name' => $value->order_payment_name,
|
| 8755 |
'cod_fee' => $value->order_cod_fee,
|
| 8756 |
'tax' => $value->order_tax,
|
| 8757 |
'total_items_price' => $total_items_price,
|
| 8758 |
'order_status' => $value->order_status,
|
| 8759 |
'date' => mysql2date( __( 'Y/m/d' ), $value->order_date ),
|
| 8760 |
'order_date' => $value->order_date,
|
| 8761 |
'order_delidue_date' => $value->order_delidue_date,
|
| 8762 |
'order_delivery_method' => $value->order_delivery_method,
|
| 8763 |
'order_delivery_method_name' => usces_delivery_method_name( $value->order_delivery_method, 'return' ),
|
| 8764 |
'order_delivery_date' => $value->order_delivery_date,
|
| 8765 |
'order_modified' => $value->order_modified,
|
| 8766 |
);
|
| 8767 |
$res[] = apply_filters( 'usces_filter_member_history_data', $data, $mem_id, $value, $cart, $total_items_price );
|
| 8768 |
}
|
| 8769 |
|
| 8770 |
return $res;
|
| 8771 |
}
|
| 8772 |
|
| 8773 |
public function get_post_term_ids( $post_id, $taxonomy ) {
|
| 8774 |
global $wpdb;
|
| 8775 |
$query = $wpdb->prepare(
|
| 8776 |
"SELECT tt.term_id FROM $wpdb->term_relationships AS `tr`
|
| 8777 |
INNER JOIN $wpdb->term_taxonomy AS `tt` ON tt.term_taxonomy_id = tr.term_taxonomy_id
|
| 8778 |
WHERE tt.taxonomy = %s AND tr.object_id = %d",
|
| 8779 |
$taxonomy, $post_id
|
| 8780 |
);
|
| 8781 |
$ids = $wpdb->get_col( $query );
|
| 8782 |
|
| 8783 |
return $ids;
|
| 8784 |
}
|
| 8785 |
|
| 8786 |
public function get_tag_names( $post_id ) {
|
| 8787 |
global $wpdb;
|
| 8788 |
$tag = 'post_tag';
|
| 8789 |
$query = $wpdb->prepare(
|
| 8790 |
"SELECT t.name FROM $wpdb->term_relationships AS `tr`
|
| 8791 |
INNER JOIN $wpdb->term_taxonomy AS `tt` ON tt.term_taxonomy_id = tr.term_taxonomy_id
|
| 8792 |
INNER JOIN $wpdb->terms AS `t` ON t.term_id = tt.term_id
|
| 8793 |
WHERE tt.taxonomy = %s AND tr.object_id = %d",
|
| 8794 |
$tag, $post_id
|
| 8795 |
);
|
| 8796 |
$names = $wpdb->get_col( $query );
|
| 8797 |
|
| 8798 |
return apply_filters( 'usces_filter_get_tag_names', $names, $post_id );
|
| 8799 |
}
|
| 8800 |
|
| 8801 |
public function get_ID_byItemName( $item_code, $status = 'publish' ) {
|
| 8802 |
global $wpdb;
|
| 8803 |
|
| 8804 |
$table = usces_get_tablename( 'usces_item' );
|
| 8805 |
$id = $wpdb->get_var(
|
| 8806 |
$wpdb->prepare(
|
| 8807 |
"SELECT p.ID FROM {$wpdb->posts} AS `p`
|
| 8808 |
INNER JOIN {$table} AS `item` ON p.ID = item.post_id
|
| 8809 |
WHERE p.post_status = %s AND item.itemCode = %s",
|
| 8810 |
$status,
|
| 8811 |
$item_code
|
| 8812 |
)
|
| 8813 |
);
|
| 8814 |
|
| 8815 |
return $id;
|
| 8816 |
}
|
| 8817 |
|
| 8818 |
public function uscescv( $sessid, $flag ) {
|
| 8819 |
$chars = '';
|
| 8820 |
$i = 0;
|
| 8821 |
$h = 0;
|
| 8822 |
$usces_cookie = $this->get_cookie();
|
| 8823 |
if ( isset( $usces_cookie['id'] ) && ! empty( $usces_cookie['id'] ) ) {
|
| 8824 |
$cid = $usces_cookie['id'];
|
| 8825 |
} elseif ( isset( $_SESSION['usces_cookieid'] ) && ! empty( $_SESSION['usces_cookieid'] ) ) {
|
| 8826 |
$cid = $_SESSION['usces_cookieid'];
|
| 8827 |
} else {
|
| 8828 |
$cid = 0;
|
| 8829 |
}
|
| 8830 |
while ( $h < strlen( $sessid ) ) {
|
| 8831 |
if ( 0 == $i % 3 ) {
|
| 8832 |
$chars .= substr( $i, -1 );
|
| 8833 |
} else {
|
| 8834 |
$chars .= substr( $sessid, $h, 1 );
|
| 8835 |
$h++;
|
| 8836 |
}
|
| 8837 |
$i++;
|
| 8838 |
}
|
| 8839 |
if ( $flag ) {
|
| 8840 |
$postfix = ( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['REMOTE_ADDR'] ) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
|
| 8841 |
$postfix = apply_filters( 'usces_sessid_force', $postfix );
|
| 8842 |
$sessid = $chars . '_' . $postfix . '_' . $cid . '_A';
|
| 8843 |
} else {
|
| 8844 |
$sessid = $chars . '_' . apply_filters( 'usces_sessid_flag', 'acting' ) . '_' . $cid . '_A';
|
| 8845 |
}
|
| 8846 |
$sessid = urlencode( base64_encode( $sessid ) );
|
| 8847 |
|
| 8848 |
return $sessid;
|
| 8849 |
}
|
| 8850 |
|
| 8851 |
public function uscesdc( $sessid ) {
|
| 8852 |
$sessid = base64_decode( urldecode( $sessid ) );
|
| 8853 |
list( $sess, $addr, $cookieid, $none ) = explode( '_', $sessid, 4 );
|
| 8854 |
$postfix = ( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['REMOTE_ADDR'] ) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
|
| 8855 |
$postfix = apply_filters( 'usces_sessid_force', $postfix );
|
| 8856 |
if ( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
|
| 8857 |
$sessid = '';
|
| 8858 |
return null;
|
| 8859 |
}
|
| 8860 |
$chars = '';
|
| 8861 |
$h = 0;
|
| 8862 |
while ( $h < strlen( $sess ) ) {
|
| 8863 |
if ( 0 != $h % 3 ) {
|
| 8864 |
$chars .= substr( $sess, $h, 1 );
|
| 8865 |
}
|
| 8866 |
$h++;
|
| 8867 |
}
|
| 8868 |
$sessid = $chars;
|
| 8869 |
|
| 8870 |
return $sessid;
|
| 8871 |
}
|
| 8872 |
|
| 8873 |
public function get_visiter( $period ) {
|
| 8874 |
global $wpdb;
|
| 8875 |
$datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 );
|
| 8876 |
$yearstr = substr( $datestr, 0, 4 );
|
| 8877 |
$monthstr = substr( $datestr, 5, 2 );
|
| 8878 |
$daystr = substr( $datestr, 8, 2 );
|
| 8879 |
if ( 'today' == $period ) {
|
| 8880 |
$date = $datestr;
|
| 8881 |
$today = $datestr;
|
| 8882 |
} elseif ( 'thismonth' == $period ) {
|
| 8883 |
$date = date( 'Y-m-01' );
|
| 8884 |
$today = $datestr;
|
| 8885 |
} elseif ( 'lastyear' == $period ) {
|
| 8886 |
$date = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr-1 ) );
|
| 8887 |
$today = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, (int) $daystr, (int) $yearstr-1 ) );
|
| 8888 |
}
|
| 8889 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 8890 |
|
| 8891 |
$query = $wpdb->prepare( "SELECT SUM(acc_num1) AS `ct1`, SUM(acc_num2) AS `ct2` FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today );
|
| 8892 |
$res = $wpdb->get_row( $query, ARRAY_A );
|
| 8893 |
|
| 8894 |
if ( null == $res ) {
|
| 8895 |
return 0;
|
| 8896 |
} else {
|
| 8897 |
return $res['ct1'] + $res['ct2'];
|
| 8898 |
}
|
| 8899 |
}
|
| 8900 |
|
| 8901 |
public function get_fvisiter( $period ) {
|
| 8902 |
global $wpdb;
|
| 8903 |
$datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 );
|
| 8904 |
$yearstr = substr( $datestr, 0, 4 );
|
| 8905 |
$monthstr = substr( $datestr, 5, 2 );
|
| 8906 |
$daystr = substr( $datestr, 8, 2 );
|
| 8907 |
if ( 'today' == $period ) {
|
| 8908 |
$date = $datestr;
|
| 8909 |
$today = $datestr;
|
| 8910 |
} elseif ( 'thismonth' == $period ) {
|
| 8911 |
$date = date( 'Y-m-01' );
|
| 8912 |
$today = $datestr;
|
| 8913 |
} elseif ( 'lastyear' == $period ) {
|
| 8914 |
$date = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) );
|
| 8915 |
$today = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, (int) $daystr, (int) $yearstr - 1 ) );
|
| 8916 |
}
|
| 8917 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 8918 |
|
| 8919 |
$query = $wpdb->prepare( "SELECT SUM(acc_num2) AS `ct` FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today );
|
| 8920 |
$res = $wpdb->get_var( $query );
|
| 8921 |
|
| 8922 |
if ( null == $res ) {
|
| 8923 |
return 0;
|
| 8924 |
} else {
|
| 8925 |
return $res;
|
| 8926 |
}
|
| 8927 |
}
|
| 8928 |
|
| 8929 |
public function get_order_num( $period ) {
|
| 8930 |
global $wpdb;
|
| 8931 |
$datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 );
|
| 8932 |
$yearstr = substr( $datestr, 0, 4 );
|
| 8933 |
$monthstr = substr( $datestr, 5, 2 );
|
| 8934 |
$daystr = substr( $datestr, 8, 2 );
|
| 8935 |
if ( 'today' == $period ) {
|
| 8936 |
$date = date( 'Y-m-d 00:00:00', current_time( 'timestamp' ) );
|
| 8937 |
$today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
|
| 8938 |
} elseif ( 'thismonth' == $period ) {
|
| 8939 |
$date = date( 'Y-m-01 00:00:00', current_time( 'timestamp' ) );
|
| 8940 |
$today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
|
| 8941 |
} elseif ( 'lastyear' == $period ) {
|
| 8942 |
$date = date( 'Y-m-01 00:00:00', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) );
|
| 8943 |
$today = date( 'Y-m-d 23:59:59', mktime( 0, 0, 0, (int) $monthstr + 1, 0, (int) $yearstr - 1 ) );
|
| 8944 |
}
|
| 8945 |
$table_name = $wpdb->prefix . 'usces_order';
|
| 8946 |
|
| 8947 |
$query = $wpdb->prepare( "SELECT COUNT(ID) AS `ct` FROM $table_name WHERE order_date >= %s AND order_date <= %s AND 0 = LOCATE(%s, order_status) AND 0 = LOCATE(%s, order_status)", $date, $today, 'cancel', 'estimate' );
|
| 8948 |
$res = $wpdb->get_var( $query );
|
| 8949 |
|
| 8950 |
if ( null == $res ) {
|
| 8951 |
return 0;
|
| 8952 |
} else {
|
| 8953 |
return $res;
|
| 8954 |
}
|
| 8955 |
}
|
| 8956 |
|
| 8957 |
public function get_order_amount( $period ) {
|
| 8958 |
global $wpdb;
|
| 8959 |
|
| 8960 |
$cache_key = 'wel_order_amount_period_' . $period;
|
| 8961 |
|
| 8962 |
$res = wp_cache_get( $cache_key );
|
| 8963 |
if ( false === $res ) {
|
| 8964 |
|
| 8965 |
$datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 );
|
| 8966 |
$yearstr = substr( $datestr, 0, 4 );
|
| 8967 |
$monthstr = substr( $datestr, 5, 2 );
|
| 8968 |
$daystr = substr( $datestr, 8, 2 );
|
| 8969 |
if ( 'today' == $period ) {
|
| 8970 |
$date = date( 'Y-m-d 00:00:00', current_time( 'timestamp' ) );
|
| 8971 |
$today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
|
| 8972 |
} elseif ( 'thismonth' == $period ) {
|
| 8973 |
$date = date( 'Y-m-01 00:00:00', current_time( 'timestamp' ) );
|
| 8974 |
$today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
|
| 8975 |
} elseif ( 'lastyear' == $period ) {
|
| 8976 |
$date = date( 'Y-m-01 00:00:00', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) );
|
| 8977 |
$today = date( 'Y-m-d 23:59:59', mktime( 0, 0, 0, (int) $monthstr + 1, 0, (int) $yearstr - 1 ) );
|
| 8978 |
}
|
| 8979 |
$table_name = $wpdb->prefix . 'usces_order';
|
| 8980 |
|
| 8981 |
$query = $wpdb->prepare(
|
| 8982 |
"SELECT
|
| 8983 |
SUM(order_item_total_price) AS `price`,
|
| 8984 |
SUM(order_usedpoint) AS `point`,
|
| 8985 |
SUM(order_discount) AS `discount`,
|
| 8986 |
SUM(order_shipping_charge) AS `shipping`,
|
| 8987 |
SUM(order_cod_fee) AS `cod`,
|
| 8988 |
SUM(order_tax) AS `tax`
|
| 8989 |
FROM $table_name WHERE order_date >= %s AND order_date <= %s AND 0 = LOCATE(%s, order_status) AND 0 = LOCATE(%s, order_status)",
|
| 8990 |
$date, $today, 'cancel', 'estimate'
|
| 8991 |
);
|
| 8992 |
$res = $wpdb->get_row( $query, ARRAY_A );
|
| 8993 |
|
| 8994 |
if ( null !== $res ) {
|
| 8995 |
wp_cache_set( $cache_key, $res );
|
| 8996 |
}
|
| 8997 |
}
|
| 8998 |
|
| 8999 |
if ( null == $res ) {
|
| 9000 |
return 0;
|
| 9001 |
} else {
|
| 9002 |
return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
|
| 9003 |
}
|
| 9004 |
}
|
| 9005 |
|
| 9006 |
public function is_status( $need, $str ) {
|
| 9007 |
if ( ! is_string( $str ) || empty( $str ) ) {
|
| 9008 |
$array = array();
|
| 9009 |
} else {
|
| 9010 |
$array = explode( ',', $str );
|
| 9011 |
}
|
| 9012 |
return in_array( $need, $array );
|
| 9013 |
}
|
| 9014 |
|
| 9015 |
public function make_status( $taio = '', $receipt = '', $admin = '' ) {
|
| 9016 |
$str = '';
|
| 9017 |
if ( '' != $taio && '#none#' != $taio ) {
|
| 9018 |
$str .= $taio . ',';
|
| 9019 |
}
|
| 9020 |
if ( '' != $receipt && '#none#' != $receipt ) {
|
| 9021 |
$str .= $receipt . ',';
|
| 9022 |
}
|
| 9023 |
if ( '' != $admin && '#none#' != $admin ) {
|
| 9024 |
$str .= $admin . ',';
|
| 9025 |
}
|
| 9026 |
return $str;
|
| 9027 |
}
|
| 9028 |
|
| 9029 |
public function get_memberid_by_email( $email ) {
|
| 9030 |
global $wpdb;
|
| 9031 |
$table_name = usces_get_tablename( 'usces_member' );
|
| 9032 |
$query = $wpdb->prepare( "SELECT ID FROM $table_name WHERE mem_email = %s", $email );
|
| 9033 |
$res = $wpdb->get_var( $query );
|
| 9034 |
return $res;
|
| 9035 |
}
|
| 9036 |
|
| 9037 |
public function get_condition() {
|
| 9038 |
$order_conditions = array(
|
| 9039 |
'display_mode' => $this->options['display_mode'],
|
| 9040 |
'campaign_privilege' => $this->options['campaign_privilege'],
|
| 9041 |
'campaign_category' => $this->options['campaign_category'],
|
| 9042 |
'privilege_point' => $this->options['privilege_point'],
|
| 9043 |
'privilege_discount' => $this->options['privilege_discount'],
|
| 9044 |
'tax_display' => ( isset( $this->options['tax_display'] ) ) ? $this->options['tax_display'] : 'activate',
|
| 9045 |
'tax_mode' => $this->options['tax_mode'],
|
| 9046 |
'tax_target' => $this->options['tax_target'],
|
| 9047 |
'tax_rate' => $this->options['tax_rate'],
|
| 9048 |
'tax_method' => $this->options['tax_method'],
|
| 9049 |
'applicable_taxrate' => ( isset( $this->options['applicable_taxrate'] ) ) ? $this->options['applicable_taxrate'] : 'standard',
|
| 9050 |
'tax_rate_reduced' => ( isset( $this->options['tax_rate_reduced'] ) ) ? $this->options['tax_rate_reduced'] : $this->options['tax_rate'],
|
| 9051 |
'membersystem_state' => $this->options['membersystem_state'],
|
| 9052 |
'membersystem_point' => $this->options['membersystem_point'],
|
| 9053 |
'point_coverage' => $this->options['point_coverage'],
|
| 9054 |
);
|
| 9055 |
return $order_conditions;
|
| 9056 |
}
|
| 9057 |
|
| 9058 |
public function get_bestseller_ids( $days = '' ) {
|
| 9059 |
global $wpdb;
|
| 9060 |
|
| 9061 |
$datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 );
|
| 9062 |
$yearstr = substr( $datestr, 0, 4 );
|
| 9063 |
$monthstr = substr( $datestr, 5, 2 );
|
| 9064 |
$daystr = substr( $datestr, 8, 2 );
|
| 9065 |
|
| 9066 |
$res = array();
|
| 9067 |
$order_table_name = $wpdb->prefix . 'usces_order';
|
| 9068 |
$where = '';
|
| 9069 |
if ( empty( $days ) ) {
|
| 9070 |
$days = 30;
|
| 9071 |
}
|
| 9072 |
$order_date = date( 'Y-m-d H:i:s', mktime( 0, 0, 0, (int) $monthstr, ( (int) $daystr - $days), (int) $yearstr ) );
|
| 9073 |
$where = " WHERE order_date >= '{$order_date}'";
|
| 9074 |
$query = "SELECT order_cart FROM {$order_table_name}" . $where;
|
| 9075 |
$dbres = $wpdb->get_col( $query );
|
| 9076 |
if ( ! $dbres ) {
|
| 9077 |
return false;
|
| 9078 |
}
|
| 9079 |
|
| 9080 |
foreach ( (array) $dbres as $carts ) {
|
| 9081 |
$rows = unserialize( $carts );
|
| 9082 |
foreach ( (array) $rows as $carts ) {
|
| 9083 |
if ( 'publish' != get_post_status( $carts['post_id'] ) ) {
|
| 9084 |
continue;
|
| 9085 |
}
|
| 9086 |
$id = $carts['post_id'];
|
| 9087 |
$qu = $carts['quantity'];
|
| 9088 |
if ( array_key_exists( $id, $res ) ) {
|
| 9089 |
$res[ $id ] = $res[ $id ] + $qu;
|
| 9090 |
} else {
|
| 9091 |
$res[ $id ] = $qu;
|
| 9092 |
}
|
| 9093 |
}
|
| 9094 |
}
|
| 9095 |
arsort( $res );
|
| 9096 |
$results = array_keys( $res );
|
| 9097 |
return $results;
|
| 9098 |
}
|
| 9099 |
|
| 9100 |
public function get_items_num() {
|
| 9101 |
global $wpdb;
|
| 9102 |
$res = $wpdb->get_var(
|
| 9103 |
$wpdb->prepare(
|
| 9104 |
"SELECT COUNT(ID) AS `ct` FROM {$wpdb->posts}
|
| 9105 |
WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
|
| 9106 |
'item',
|
| 9107 |
'post',
|
| 9108 |
'trash'
|
| 9109 |
)
|
| 9110 |
);
|
| 9111 |
|
| 9112 |
return $res;
|
| 9113 |
}
|
| 9114 |
|
| 9115 |
public function is_gptekiyo( $post_id, $sku, $quant ) {
|
| 9116 |
$skus = $this->get_skus( $post_id, 'code' );
|
| 9117 |
if ( ! isset( $skus[ $sku ]['gp'] ) || ! $skus[ $sku ]['gp'] ) {
|
| 9118 |
return false;
|
| 9119 |
}
|
| 9120 |
|
| 9121 |
$GpN1 = $this->getItemGpNum1( $post_id );
|
| 9122 |
$GpN2 = $this->getItemGpNum2( $post_id );
|
| 9123 |
$GpN3 = $this->getItemGpNum3( $post_id );
|
| 9124 |
|
| 9125 |
if ( empty( $GpN1 ) ) {
|
| 9126 |
|
| 9127 |
return false;
|
| 9128 |
|
| 9129 |
} elseif ( ! empty( $GpN1 ) && empty( $GpN2 ) ) {
|
| 9130 |
|
| 9131 |
if ( $quant >= $GpN1 ) {
|
| 9132 |
return true;
|
| 9133 |
} else {
|
| 9134 |
return false;
|
| 9135 |
}
|
| 9136 |
|
| 9137 |
} elseif ( ! empty( $GpN1 ) && ! empty( $GpN2 ) && empty( $GpN3 ) ) {
|
| 9138 |
|
| 9139 |
if ( $quant >= $GpN2 ) {
|
| 9140 |
return true;
|
| 9141 |
} elseif ( $quant >= $GpN1 && $quant < $GpN2 ) {
|
| 9142 |
return true;
|
| 9143 |
} else {
|
| 9144 |
return false;
|
| 9145 |
}
|
| 9146 |
|
| 9147 |
} elseif ( ! empty( $GpN1 ) && ! empty( $GpN2 ) && ! empty( $GpN3 ) ) {
|
| 9148 |
|
| 9149 |
if ( $quant >= $GpN3 ) {
|
| 9150 |
return true;
|
| 9151 |
} elseif ( $quant >= $GpN2 && $quant < $GpN3 ) {
|
| 9152 |
return true;
|
| 9153 |
} elseif ( $quant >= $GpN1 && $quant < $GpN2 ) {
|
| 9154 |
return true;
|
| 9155 |
} else{
|
| 9156 |
return false;
|
| 9157 |
}
|
| 9158 |
}
|
| 9159 |
}
|
| 9160 |
|
| 9161 |
public function get_available_delivery_method() {
|
| 9162 |
if ( $this->cart->num_row() > 0 ) {
|
| 9163 |
$cart = $this->cart->get_cart();
|
| 9164 |
$before_deli = array();
|
| 9165 |
$intersect = array();
|
| 9166 |
$integration = array();
|
| 9167 |
$temp = array();
|
| 9168 |
$in = 0;
|
| 9169 |
foreach ( $cart as $key => $row ) {
|
| 9170 |
$deli = $this->getItemDeliveryMethod( $row['post_id'] );
|
| 9171 |
if ( empty( $deli ) ) {
|
| 9172 |
continue;
|
| 9173 |
}
|
| 9174 |
if ( 0 === $in ) {
|
| 9175 |
$intersect = $deli;
|
| 9176 |
}
|
| 9177 |
$intersect = array_intersect( $deli, $intersect );
|
| 9178 |
$before_deli = $deli;
|
| 9179 |
foreach ( $deli as $value ) {
|
| 9180 |
$integration[] = $value;
|
| 9181 |
}
|
| 9182 |
$in++;
|
| 9183 |
}
|
| 9184 |
$integration = array_unique( $integration );
|
| 9185 |
foreach ( $integration as $id ) {
|
| 9186 |
$index = $this->get_delivery_method_index( $id );
|
| 9187 |
if ( 0 <= $index ) {
|
| 9188 |
$temp[ $index ] = $id;
|
| 9189 |
}
|
| 9190 |
}
|
| 9191 |
ksort( $temp );
|
| 9192 |
$force = array( array_shift( $temp ) );
|
| 9193 |
|
| 9194 |
if ( empty( $intersect ) ) {
|
| 9195 |
return $force;
|
| 9196 |
} else {
|
| 9197 |
return $intersect;
|
| 9198 |
}
|
| 9199 |
}
|
| 9200 |
return array();
|
| 9201 |
}
|
| 9202 |
|
| 9203 |
public function get_delivery_method_index( $id ) {
|
| 9204 |
$index = false;
|
| 9205 |
$delivery_method_count = ( $this->options['delivery_method'] && is_array( $this->options['delivery_method'] ) ) ? count( $this->options['delivery_method'] ) : 0;
|
| 9206 |
for ( $i = 0; $i < $delivery_method_count; $i++ ) {
|
| 9207 |
if ( isset( $this->options['delivery_method'][ $i ]['id'] ) && $this->options['delivery_method'][ $i ]['id'] === (int) $id ) {
|
| 9208 |
$index = $i;
|
| 9209 |
}
|
| 9210 |
}
|
| 9211 |
if ( false === $index ) {
|
| 9212 |
return -1;
|
| 9213 |
} else {
|
| 9214 |
return $index;
|
| 9215 |
}
|
| 9216 |
}
|
| 9217 |
|
| 9218 |
public function get_shipping_charge_index( $id ) {
|
| 9219 |
$index = false;
|
| 9220 |
$shipping_charge_count = ( $this->options['shipping_charge'] && is_array( $this->options['shipping_charge'] ) ) ? count( $this->options['shipping_charge'] ) : 0;
|
| 9221 |
for ( $i = 0; $i < $shipping_charge_count; $i++ ) {
|
| 9222 |
if ( isset( $this->options['shipping_charge'][ $i ] ) && (int) $this->options['shipping_charge'][ $i ]['id'] == (int) $id ) {
|
| 9223 |
$index = $i;
|
| 9224 |
}
|
| 9225 |
}
|
| 9226 |
if ( false === $index ) {
|
| 9227 |
return -1;
|
| 9228 |
} else {
|
| 9229 |
return $index;
|
| 9230 |
}
|
| 9231 |
}
|
| 9232 |
|
| 9233 |
public function get_initial_data( $xml ) {
|
| 9234 |
$buf = file_get_contents( $xml );
|
| 9235 |
preg_match_all( '@<page>.*?<post_title>(.*?)</post_title>.*?<post_status>(.*?)</post_status>.*?<post_name>(.*?)</post_name>.*?<post_content>(.*?)</post_content>.*?</page>@s', $buf, $match, PREG_SET_ORDER );
|
| 9236 |
return $match;
|
| 9237 |
}
|
| 9238 |
|
| 9239 |
public function getCurrencySymbol() {
|
| 9240 |
global $usces_settings;
|
| 9241 |
$cr = $this->options['system']['currency'];
|
| 9242 |
list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ];
|
| 9243 |
return $symbol;
|
| 9244 |
}
|
| 9245 |
|
| 9246 |
public function getCartItemName( $post_id, $sku ) {
|
| 9247 |
$name_arr = array();
|
| 9248 |
$name_str = '';
|
| 9249 |
|
| 9250 |
foreach ( $this->options['indi_item_name'] as $key => $value ) {
|
| 9251 |
if ( $value ) {
|
| 9252 |
$pos = (int) $this->options['pos_item_name'][ $key ];
|
| 9253 |
$ind = ( 0 === $pos ) ? 'A' : $pos;
|
| 9254 |
switch ( $key ) {
|
| 9255 |
case 'item_name':
|
| 9256 |
$name_arr[ $ind ][ $key ] = $this->getItemName( $post_id );
|
| 9257 |
break;
|
| 9258 |
case 'item_code':
|
| 9259 |
$name_arr[ $ind ][ $key ] = $this->getItemCode( $post_id );
|
| 9260 |
break;
|
| 9261 |
case 'sku_name':
|
| 9262 |
$name_arr[ $ind ][ $key ] = $this->getItemSkuDisp( $post_id, $sku );
|
| 9263 |
break;
|
| 9264 |
case 'sku_code':
|
| 9265 |
$name_arr[ $ind ][ $key ] = $sku;
|
| 9266 |
break;
|
| 9267 |
}
|
| 9268 |
}
|
| 9269 |
}
|
| 9270 |
ksort( $name_arr );
|
| 9271 |
foreach ( $name_arr as $vals ) {
|
| 9272 |
foreach ( $vals as $key => $value ) {
|
| 9273 |
$name_str .= $value . ' ';
|
| 9274 |
}
|
| 9275 |
}
|
| 9276 |
|
| 9277 |
$name_str = apply_filters( 'usces_admin_order_item_name_filter', $name_str, $post_id, $sku );
|
| 9278 |
|
| 9279 |
return trim( $name_str );
|
| 9280 |
}
|
| 9281 |
|
| 9282 |
public function getCartItemName_byOrder( $cart_row ) {
|
| 9283 |
$name_arr = array();
|
| 9284 |
$name_str = '';
|
| 9285 |
|
| 9286 |
foreach ( $this->options['indi_item_name'] as $key => $value ) {
|
| 9287 |
if ( $value ) {
|
| 9288 |
$pos = (int) $this->options['pos_item_name'][ $key ];
|
| 9289 |
$ind = ( 0 === $pos ) ? 'A' : $pos;
|
| 9290 |
switch ( $key ) {
|
| 9291 |
case 'item_name':
|
| 9292 |
$name_arr[ $ind ][ $key ] = $cart_row['item_name'];
|
| 9293 |
break;
|
| 9294 |
case 'item_code':
|
| 9295 |
$name_arr[ $ind ][ $key ] = $cart_row['item_code'];
|
| 9296 |
break;
|
| 9297 |
case 'sku_name':
|
| 9298 |
$name_arr[ $ind ][ $key ] = $cart_row['sku_name'];
|
| 9299 |
break;
|
| 9300 |
case 'sku_code':
|
| 9301 |
$name_arr[ $ind ][ $key ] = $cart_row['sku_code'];
|
| 9302 |
break;
|
| 9303 |
}
|
| 9304 |
}
|
| 9305 |
}
|
| 9306 |
ksort( $name_arr );
|
| 9307 |
foreach ( $name_arr as $vals ) {
|
| 9308 |
foreach ( $vals as $key => $value ) {
|
| 9309 |
$name_str .= $value . ' ';
|
| 9310 |
}
|
| 9311 |
}
|
| 9312 |
|
| 9313 |
$name_str = apply_filters( 'usces_filter_item_mame_by_order', $name_str, $cart_row );
|
| 9314 |
|
| 9315 |
return trim( $name_str );
|
| 9316 |
}
|
| 9317 |
|
| 9318 |
public function set_reserve_pre_order_id() {
|
| 9319 |
$entry = $this->cart->get_entry();
|
| 9320 |
$id = ( isset( $entry['reserve']['pre_order_id'] ) && ! empty( $entry['reserve']['pre_order_id'] ) ) ? $entry['reserve']['pre_order_id'] : uniqid( '' );
|
| 9321 |
$this->cart->set_pre_order_id( $id );
|
| 9322 |
}
|
| 9323 |
|
| 9324 |
public function get_current_pre_order_id() {
|
| 9325 |
$entry = $this->cart->get_entry();
|
| 9326 |
$id = ( isset( $entry['reserve']['pre_order_id'] ) && ! empty( $entry['reserve']['pre_order_id'] ) ) ? $entry['reserve']['pre_order_id'] : null;
|
| 9327 |
return $id;
|
| 9328 |
}
|
| 9329 |
|
| 9330 |
public function get_order_id_by_pre_order_id( $pre_order_id ) {
|
| 9331 |
global $wpdb;
|
| 9332 |
$query = $wpdb->prepare( "SELECT order_id FROM {$wpdb->prefix}usces_order_meta WHERE meta_key = %s AND meta_value = %s", 'pre_order_id', $pre_order_id );
|
| 9333 |
$order_id = $wpdb->get_var( $query );
|
| 9334 |
return $order_id;
|
| 9335 |
}
|
| 9336 |
|
| 9337 |
public function get_reserve( $order_id, $key ) {
|
| 9338 |
global $wpdb;
|
| 9339 |
$order_meta_table_name = $wpdb->prefix . 'usces_order_meta';
|
| 9340 |
$query = $wpdb->prepare( "SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
|
| 9341 |
$res = $wpdb->get_var( $query );
|
| 9342 |
return $res;
|
| 9343 |
}
|
| 9344 |
|
| 9345 |
public function get_order_meta_value( $key, $order_id ) {
|
| 9346 |
global $wpdb;
|
| 9347 |
$order_meta_table_name = $wpdb->prefix . 'usces_order_meta';
|
| 9348 |
$query = $wpdb->prepare( "SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
|
| 9349 |
$res = $wpdb->get_var( $query );
|
| 9350 |
return $res;
|
| 9351 |
}
|
| 9352 |
|
| 9353 |
public function set_order_meta_value( $key, $meta_value, $order_id, $check = 1 ) {
|
| 9354 |
global $wpdb;
|
| 9355 |
|
| 9356 |
if ( empty( $order_id ) ) {
|
| 9357 |
return;
|
| 9358 |
}
|
| 9359 |
|
| 9360 |
$order_id = (int) $order_id;
|
| 9361 |
if ( $check ) {
|
| 9362 |
$order = $this->get_order_data( $order_id, 'direct' );
|
| 9363 |
if ( null === $order ) {
|
| 9364 |
return;
|
| 9365 |
}
|
| 9366 |
}
|
| 9367 |
|
| 9368 |
$table_name = $wpdb->prefix . 'usces_order_meta';
|
| 9369 |
$query = $wpdb->prepare(
|
| 9370 |
"SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
|
| 9371 |
$order_id, $key
|
| 9372 |
);
|
| 9373 |
$res = $wpdb->get_var( $query );
|
| 9374 |
if ( 0 < $res ) {
|
| 9375 |
$query = $wpdb->prepare(
|
| 9376 |
"UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
|
| 9377 |
$meta_value,
|
| 9378 |
$order_id,
|
| 9379 |
$key
|
| 9380 |
);
|
| 9381 |
$res2 = $wpdb->query( $query );
|
| 9382 |
} else {
|
| 9383 |
$query = $wpdb->prepare(
|
| 9384 |
"INSERT INTO $table_name (order_id, meta_key, meta_value)
|
| 9385 |
VALUES(%d, %s, %s)",
|
| 9386 |
$order_id,
|
| 9387 |
$key,
|
| 9388 |
$meta_value
|
| 9389 |
);
|
| 9390 |
$res2 = $wpdb->query( $query );
|
| 9391 |
}
|
| 9392 |
return $res2;
|
| 9393 |
}
|
| 9394 |
|
| 9395 |
public function del_order_meta( $key, $order_id ) {
|
| 9396 |
global $wpdb;
|
| 9397 |
$table_name = $wpdb->prefix . 'usces_order_meta';
|
| 9398 |
$query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
|
| 9399 |
$res = $wpdb->query( $query );
|
| 9400 |
return $res;
|
| 9401 |
}
|
| 9402 |
|
| 9403 |
public function set_session_custom_member( $member_id ) {
|
| 9404 |
unset( $_SESSION['usces_member']['custom_member'] );
|
| 9405 |
$meta = usces_has_custom_field_meta( 'member' );
|
| 9406 |
if ( is_array( $meta ) ) {
|
| 9407 |
$keys = array_keys( $meta );
|
| 9408 |
foreach ( $keys as $key ) {
|
| 9409 |
$csmb_key = 'csmb_' . $key;
|
| 9410 |
$_SESSION['usces_member']['custom_member'][ $key ] = maybe_unserialize( $this->get_member_meta_value( $csmb_key, $member_id ) );
|
| 9411 |
}
|
| 9412 |
}
|
| 9413 |
}
|
| 9414 |
|
| 9415 |
public function reg_custom_member( $member_id ) {
|
| 9416 |
$csmb_meta = usces_has_custom_field_meta( 'member' );
|
| 9417 |
if ( is_array( $csmb_meta ) ) {
|
| 9418 |
foreach ( $csmb_meta as $key => $entry ) {
|
| 9419 |
if ( '4' == $entry['means'] ) {
|
| 9420 |
$this->del_member_meta( 'csmb_' . $key, $member_id );
|
| 9421 |
}
|
| 9422 |
}
|
| 9423 |
}
|
| 9424 |
if ( ! empty( $_POST['custom_member'] ) ) {
|
| 9425 |
foreach ( $_POST['custom_member'] as $key => $value ) {
|
| 9426 |
$csmb_key = 'csmb_' . $key;
|
| 9427 |
$value = wel_safe_text_serialize( $value );
|
| 9428 |
if ( is_array( $value ) ) {
|
| 9429 |
$value = serialize( $value );
|
| 9430 |
}
|
| 9431 |
$res = $this->set_member_meta_value( $csmb_key, $value, $member_id );
|
| 9432 |
if ( false === $res ) {
|
| 9433 |
return false;
|
| 9434 |
}
|
| 9435 |
}
|
| 9436 |
} elseif ( isset( $_POST['custom_customer'] ) ) {
|
| 9437 |
foreach ( $_POST['custom_customer'] as $key => $value ) {
|
| 9438 |
$csmb_key = 'csmb_' . $key;
|
| 9439 |
$value = wel_safe_text_serialize( $value );
|
| 9440 |
if ( is_array( $value ) ) {
|
| 9441 |
$value = serialize( $value );
|
| 9442 |
}
|
| 9443 |
$res = $this->set_member_meta_value( $csmb_key, $value, $member_id );
|
| 9444 |
if ( false === $res ) {
|
| 9445 |
return false;
|
| 9446 |
}
|
| 9447 |
}
|
| 9448 |
}
|
| 9449 |
}
|
| 9450 |
|
| 9451 |
public function save_order_acting_data( $rand ) {
|
| 9452 |
global $wpdb;
|
| 9453 |
$data = serialize(
|
| 9454 |
array(
|
| 9455 |
'cart' => $this->cart->get_cart(),
|
| 9456 |
'entry' => $this->cart->get_entry(),
|
| 9457 |
)
|
| 9458 |
);
|
| 9459 |
$table_name = $wpdb->prefix . 'usces_access';
|
| 9460 |
$query = $wpdb->prepare(
|
| 9461 |
"INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
|
| 9462 |
VALUES(%s, %s, now(), %s, %s)",
|
| 9463 |
'acting_data',
|
| 9464 |
$this->get_uscesid(false),
|
| 9465 |
$rand,
|
| 9466 |
$data
|
| 9467 |
);
|
| 9468 |
$res = $wpdb->query( $query );
|
| 9469 |
return $res;
|
| 9470 |
}
|
| 9471 |
|
| 9472 |
public function set_member_meta_value( $key, $meta_value, $member_id = '' ) {
|
| 9473 |
global $wpdb;
|
| 9474 |
|
| 9475 |
if ( WCUtils::is_blank( $member_id ) ) {
|
| 9476 |
if ( ! $this->is_member_logged_in() ) {
|
| 9477 |
return;
|
| 9478 |
}
|
| 9479 |
$member = $this->get_member();
|
| 9480 |
$member_id = $member['ID'];
|
| 9481 |
}
|
| 9482 |
|
| 9483 |
$table_name = usces_get_tablename( 'usces_member_meta' );
|
| 9484 |
$query = $wpdb->prepare( "SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key );
|
| 9485 |
$res = $wpdb->get_var( $query );
|
| 9486 |
if ( 0 < $res ) {
|
| 9487 |
$query = $wpdb->prepare(
|
| 9488 |
"UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
|
| 9489 |
$meta_value,
|
| 9490 |
$member_id,
|
| 9491 |
$key
|
| 9492 |
);
|
| 9493 |
$res2 = $wpdb->query( $query );
|
| 9494 |
} else {
|
| 9495 |
$query = $wpdb->prepare(
|
| 9496 |
"INSERT INTO $table_name (member_id, meta_key, meta_value)
|
| 9497 |
VALUES(%d, %s, %s)",
|
| 9498 |
$member_id,
|
| 9499 |
$key,
|
| 9500 |
$meta_value
|
| 9501 |
);
|
| 9502 |
$res2 = $wpdb->query( $query );
|
| 9503 |
}
|
| 9504 |
return $res2;
|
| 9505 |
}
|
| 9506 |
|
| 9507 |
public function get_member_meta_value( $key, $member_id ) {
|
| 9508 |
global $wpdb;
|
| 9509 |
$table_name = usces_get_tablename( 'usces_member_meta' );
|
| 9510 |
$query = $wpdb->prepare( "SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key );
|
| 9511 |
$res = $wpdb->get_var( $query );
|
| 9512 |
return $res;
|
| 9513 |
}
|
| 9514 |
|
| 9515 |
public function del_member_meta( $key, $member_id ) {
|
| 9516 |
global $wpdb;
|
| 9517 |
$table_name = usces_get_tablename( 'usces_member_meta' );
|
| 9518 |
$query = $wpdb->prepare( "DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key );
|
| 9519 |
$res = $wpdb->query( $query );
|
| 9520 |
return $res;
|
| 9521 |
}
|
| 9522 |
|
| 9523 |
public function get_member_meta( $member_id ) {
|
| 9524 |
global $wpdb;
|
| 9525 |
$table_name = usces_get_tablename( 'usces_member_meta' );
|
| 9526 |
$query = $wpdb->prepare( "SELECT * FROM $table_name WHERE member_id = %d AND meta_key <> 'customer_country' AND meta_key NOT LIKE %s", $member_id, 'csmb_%' );
|
| 9527 |
$res = $wpdb->get_results( $query, ARRAY_A );
|
| 9528 |
return $res;
|
| 9529 |
}
|
| 9530 |
|
| 9531 |
public function get_settle_info_field( $order_id ) {
|
| 9532 |
global $wpdb;
|
| 9533 |
$fields = array();
|
| 9534 |
$table_name = $wpdb->prefix . 'usces_order_meta';
|
| 9535 |
$meta_keys = apply_filters( 'usces_filter_settle_info_field_meta_keys', array( 'settlement_id', 'order_number', 'res_tracking_id', 'SID', 'TransactionId' ) );
|
| 9536 |
$query = $wpdb->prepare( "SELECT meta_key, meta_value FROM $table_name WHERE order_id = %d AND ( meta_key LIKE %s OR meta_key IN( %s ) )", $order_id, 'acting_%', implode( "','", $meta_keys ) );
|
| 9537 |
$query = stripslashes( $query );
|
| 9538 |
$res = $wpdb->get_results( $query, ARRAY_A );
|
| 9539 |
if ( ! $res ) {
|
| 9540 |
return $fields;
|
| 9541 |
}
|
| 9542 |
foreach ( $res as $value ) {
|
| 9543 |
if ( in_array( $value['meta_key'], $meta_keys ) ) {
|
| 9544 |
$meta_key = $value['meta_key'];
|
| 9545 |
if ( 'settlement_id' == $meta_key ) {
|
| 9546 |
$meta_values = maybe_unserialize( $value['meta_value'] );
|
| 9547 |
if ( is_array( $meta_values ) ) {
|
| 9548 |
foreach ( $meta_values as $key => $meta_value ) {
|
| 9549 |
$fields[ $key ] = $meta_value;
|
| 9550 |
}
|
| 9551 |
} else {
|
| 9552 |
$fields['settlement_id'] = $meta_values;
|
| 9553 |
}
|
| 9554 |
} else {
|
| 9555 |
$fields[ $meta_key ] = $value['meta_value'];
|
| 9556 |
}
|
| 9557 |
} elseif ( 'acting_' == substr( $value['meta_key'], 0, 7 ) ) {
|
| 9558 |
$meta_values = usces_unserialize( $value['meta_value'] );
|
| 9559 |
if ( is_array( $meta_values ) ) {
|
| 9560 |
foreach ( $meta_values as $key => $meta_value ) {
|
| 9561 |
$fields[ $key ] = $meta_value;
|
| 9562 |
}
|
| 9563 |
} else {
|
| 9564 |
$meta_values = maybe_unserialize( $value['meta_value'] );
|
| 9565 |
if ( is_array( $meta_values ) ) {
|
| 9566 |
foreach ( $meta_values as $key => $meta_value ) {
|
| 9567 |
$fields[ $key ] = $meta_value;
|
| 9568 |
}
|
| 9569 |
}
|
| 9570 |
}
|
| 9571 |
}
|
| 9572 |
}
|
| 9573 |
return $fields;
|
| 9574 |
}
|
| 9575 |
|
| 9576 |
public function get_post_custom( $post_id, $orderby = 'meta_id', $order = 'ASC' ) {
|
| 9577 |
global $wpdb;
|
| 9578 |
$table = $wpdb->prefix . 'postmeta';
|
| 9579 |
$meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order", $post_id ), ARRAY_A );
|
| 9580 |
|
| 9581 |
if ( ! empty( $meta_list ) ) {
|
| 9582 |
foreach ( $meta_list as $metarow ) {
|
| 9583 |
$mkey = $metarow['meta_key'];
|
| 9584 |
$mval = $metarow['meta_value'];
|
| 9585 |
$res[ $mkey ][] = $mval;
|
| 9586 |
}
|
| 9587 |
}
|
| 9588 |
return $res;
|
| 9589 |
}
|
| 9590 |
|
| 9591 |
public function get_post_user_custom( $post_id, $orderby = 'meta_id', $order = 'ASC' ) {
|
| 9592 |
global $wpdb;
|
| 9593 |
$res = array();
|
| 9594 |
$table = $wpdb->prefix . 'postmeta';
|
| 9595 |
$meta_list = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order", $post_id ), ARRAY_A );
|
| 9596 |
|
| 9597 |
if ( ! empty( $meta_list ) ) {
|
| 9598 |
foreach ( $meta_list as $metarow ) {
|
| 9599 |
if ( 0 === strpos( $metarow['meta_key'], '_' ) ) {
|
| 9600 |
continue;
|
| 9601 |
}
|
| 9602 |
$mkey = $metarow['meta_key'];
|
| 9603 |
$mval = $metarow['meta_value'];
|
| 9604 |
if ( array_key_exists( $mkey, $res ) ) {
|
| 9605 |
$cval = $res[ $mkey ];
|
| 9606 |
$cval = (array) $cval;
|
| 9607 |
$cval[] = $mval;
|
| 9608 |
$res[ $mkey ] = $cval;
|
| 9609 |
} else {
|
| 9610 |
$res[ $mkey ] = $mval;
|
| 9611 |
}
|
| 9612 |
}
|
| 9613 |
}
|
| 9614 |
$res = apply_filters( 'usces_filter_get_post_user_custom', $res, $meta_list, $post_id, $orderby, $order );
|
| 9615 |
return $res;
|
| 9616 |
}
|
| 9617 |
|
| 9618 |
public function get_currency( $amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ) {
|
| 9619 |
global $usces_settings;
|
| 9620 |
$cr = $this->options['system']['currency'];
|
| 9621 |
list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ];
|
| 9622 |
if ( ! $seperator_flag ) {
|
| 9623 |
$seperator = '';
|
| 9624 |
}
|
| 9625 |
$price = number_format( (double) $amount, $decimal, $point, $seperator );
|
| 9626 |
|
| 9627 |
if ( $symbol_pre ) {
|
| 9628 |
$price = ( usces_is_entity( $symbol ) ? mb_convert_encoding( $symbol, 'UTF-8', 'HTML-ENTITIES' ) : $symbol ) . $price;
|
| 9629 |
}
|
| 9630 |
if ( $symbol_post ) {
|
| 9631 |
$price = $price . __( $code, 'usces' );
|
| 9632 |
}
|
| 9633 |
$price = apply_filters( 'usces_filter_get_currency', $price, $amount, $symbol_pre, $symbol_post, $seperator_flag );
|
| 9634 |
return $price;
|
| 9635 |
}
|
| 9636 |
|
| 9637 |
public function get_currency_code() {
|
| 9638 |
global $usces_settings;
|
| 9639 |
$cr = $this->options['system']['currency'];
|
| 9640 |
list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ];
|
| 9641 |
return $code;
|
| 9642 |
}
|
| 9643 |
|
| 9644 |
public function get_currency_decimal() {
|
| 9645 |
global $usces_settings;
|
| 9646 |
$cr = $this->options['system']['currency'];
|
| 9647 |
list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ];
|
| 9648 |
return $decimal;
|
| 9649 |
}
|
| 9650 |
|
| 9651 |
public function get_next_page_uri( $type, $current ) {
|
| 9652 |
global $wpdb;
|
| 9653 |
|
| 9654 |
$table = $wpdb->prefix . 'usces_' . $type;
|
| 9655 |
if ( ! isset( $_COOKIE[ $table ] ) ) {
|
| 9656 |
return false;
|
| 9657 |
}
|
| 9658 |
|
| 9659 |
$cookie = ( isset( $_COOKIE[ $table ] ) ) ? json_decode( str_replace( "\'", "'", str_replace( '\"', '"', $_COOKIE[ $table ] ) ), true ) : array();
|
| 9660 |
if ( ! isset( $cookie['currentPageIds'] ) ) {
|
| 9661 |
return false;
|
| 9662 |
}
|
| 9663 |
|
| 9664 |
$ids = $cookie['currentPageIds'];
|
| 9665 |
foreach ( $ids as $key => $id ) {
|
| 9666 |
if ( $id == $current ) {
|
| 9667 |
$next = isset( $ids[ ( $key + 1 ) ] ) ? $ids[ ( $key + 1 ) ] : '';
|
| 9668 |
break;
|
| 9669 |
}
|
| 9670 |
}
|
| 9671 |
|
| 9672 |
if ( empty( $next ) ) {
|
| 9673 |
$uri = '';
|
| 9674 |
} else {
|
| 9675 |
$uri = USCES_ADMIN_URL . "?page=usces_{$type}list&{$type}_action=edit&{$type}_id=" . $next;
|
| 9676 |
}
|
| 9677 |
|
| 9678 |
return esc_url( $uri );
|
| 9679 |
}
|
| 9680 |
|
| 9681 |
public function get_prev_page_uri( $type, $current ) {
|
| 9682 |
global $wpdb;
|
| 9683 |
|
| 9684 |
$table = $wpdb->prefix . 'usces_' . $type;
|
| 9685 |
if ( ! isset( $_COOKIE[ $table ] ) ) {
|
| 9686 |
return false;
|
| 9687 |
}
|
| 9688 |
|
| 9689 |
$cookie = ( isset( $_COOKIE[ $table ] ) ) ? json_decode( str_replace( "\'", "'", str_replace( '\"', '"', $_COOKIE[ $table ] ) ), true ) : array();
|
| 9690 |
if ( ! isset( $cookie['currentPageIds'] ) ) {
|
| 9691 |
return false;
|
| 9692 |
}
|
| 9693 |
|
| 9694 |
$ids = $cookie['currentPageIds'];
|
| 9695 |
foreach ( $ids as $key => $id ) {
|
| 9696 |
if ( $id == $current ) {
|
| 9697 |
$prev = isset( $ids[ ( $key - 1 ) ] ) ? $ids[ ( $key - 1 ) ] : '';
|
| 9698 |
break;
|
| 9699 |
}
|
| 9700 |
}
|
| 9701 |
|
| 9702 |
if ( empty( $prev ) ) {
|
| 9703 |
$uri = '';
|
| 9704 |
} else {
|
| 9705 |
$uri = USCES_ADMIN_URL . "?page=usces_{$type}list&{$type}_action=edit&{$type}_id=" . $prev;
|
| 9706 |
}
|
| 9707 |
|
| 9708 |
return esc_url( $uri );
|
| 9709 |
}
|
| 9710 |
|
| 9711 |
public function is_reduced_taxrate() {
|
| 9712 |
|
| 9713 |
$reduced = ( isset( $this->options['applicable_taxrate'] ) && 'reduced' == $this->options['applicable_taxrate'] ) ? true : false;
|
| 9714 |
return $reduced;
|
| 9715 |
}
|
| 9716 |
|
| 9717 |
public function sc_company_name() {
|
| 9718 |
return htmlspecialchars( $this->options['company_name'], ENT_COMPAT );
|
| 9719 |
}
|
| 9720 |
|
| 9721 |
public function sc_zip_code() {
|
| 9722 |
return htmlspecialchars( $this->options['zip_code'], ENT_COMPAT );
|
| 9723 |
}
|
| 9724 |
|
| 9725 |
public function sc_address1() {
|
| 9726 |
return htmlspecialchars( $this->options['address1'], ENT_COMPAT );
|
| 9727 |
}
|
| 9728 |
|
| 9729 |
public function sc_address2() {
|
| 9730 |
return htmlspecialchars( $this->options['address2'], ENT_COMPAT );
|
| 9731 |
}
|
| 9732 |
|
| 9733 |
public function sc_tel_number() {
|
| 9734 |
return htmlspecialchars( $this->options['tel_number'], ENT_COMPAT );
|
| 9735 |
}
|
| 9736 |
|
| 9737 |
public function sc_fax_number() {
|
| 9738 |
return htmlspecialchars( $this->options['fax_number'], ENT_COMPAT );
|
| 9739 |
}
|
| 9740 |
|
| 9741 |
public function sc_inquiry_mail() {
|
| 9742 |
return htmlspecialchars( $this->options['inquiry_mail'], ENT_COMPAT );
|
| 9743 |
}
|
| 9744 |
|
| 9745 |
public function sc_payment() {
|
| 9746 |
$payments = usces_get_system_option( 'usces_payment_method', 'sort' );
|
| 9747 |
$htm = "<ul>\n";
|
| 9748 |
foreach ( (array) $payments as $payment ) {
|
| 9749 |
$htm .= '<li>' . htmlspecialchars( $payment['name'], ENT_COMPAT ) . "<br />\n";
|
| 9750 |
$htm .= nl2br( htmlspecialchars( $payment['explanation'], ENT_COMPAT ) ) . "</li>\n";
|
| 9751 |
}
|
| 9752 |
$htm .= "</ul>\n";
|
| 9753 |
return $htm;
|
| 9754 |
}
|
| 9755 |
|
| 9756 |
public function sc_payment_title() {
|
| 9757 |
$payments = $this->options['payment_method'];
|
| 9758 |
$htm = "<ul>\n";
|
| 9759 |
foreach ( (array) $payments as $payment ) {
|
| 9760 |
$htm .= '<li>' . esc_html( $payment['name'] ) . "</li>\n";
|
| 9761 |
}
|
| 9762 |
$htm .= "</ul>\n";
|
| 9763 |
return $htm;
|
| 9764 |
}
|
| 9765 |
|
| 9766 |
public function sc_cod_fee() {
|
| 9767 |
return number_format( $this->options['cod_fee'] );
|
| 9768 |
}
|
| 9769 |
|
| 9770 |
public function sc_start_point() {
|
| 9771 |
return number_format( $this->options['start_point'] );
|
| 9772 |
}
|
| 9773 |
|
| 9774 |
public function sc_postage_privilege() {
|
| 9775 |
if ( empty( $this->options['postage_privilege'] ) ) {
|
| 9776 |
return;
|
| 9777 |
}
|
| 9778 |
return number_format( $this->options['postage_privilege'] );
|
| 9779 |
}
|
| 9780 |
|
| 9781 |
public function sc_shipping_charge() {
|
| 9782 |
$entry = $this->cart->get_entry();
|
| 9783 |
$country = ( isset( $entry['delivery']['country'] ) && ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : $entry['customer']['country'];
|
| 9784 |
$arr = array();
|
| 9785 |
foreach ( (array) $this->options['shipping_charge'] as $charges ) {
|
| 9786 |
foreach ( (array) $charges[ $country ] as $value ) {
|
| 9787 |
$arr[] = $value;
|
| 9788 |
}
|
| 9789 |
}
|
| 9790 |
sort( $arr );
|
| 9791 |
$min = $arr[0];
|
| 9792 |
rsort( $arr );
|
| 9793 |
$max = $arr[0];
|
| 9794 |
if ( $min == $max ) {
|
| 9795 |
$res = number_format( $min );
|
| 9796 |
} else {
|
| 9797 |
$res = number_format( $min ) . __( ' - ', 'usces' ) . number_format( $max );
|
| 9798 |
}
|
| 9799 |
return $res;
|
| 9800 |
}
|
| 9801 |
|
| 9802 |
public function sc_site_url() {
|
| 9803 |
return get_option( 'home' );
|
| 9804 |
}
|
| 9805 |
|
| 9806 |
public function sc_button_to_cart( $atts ) {
|
| 9807 |
extract(
|
| 9808 |
shortcode_atts(
|
| 9809 |
array(
|
| 9810 |
'item' => '',
|
| 9811 |
'sku' => '',
|
| 9812 |
'value' => __( 'to the cart', 'usces' ),
|
| 9813 |
'force' => 0,
|
| 9814 |
'quant' => 0,
|
| 9815 |
'opt' => 1,
|
| 9816 |
),
|
| 9817 |
$atts
|
| 9818 |
)
|
| 9819 |
);
|
| 9820 |
|
| 9821 |
$post_id = $this->get_ID_byItemName( $item );
|
| 9822 |
$datas = $this->get_skus( $post_id, 'code' );
|
| 9823 |
$zaikonum = ( isset( $datas[ $sku ]['stocknum'] ) ) ? $datas[ $sku ]['stocknum'] : null;
|
| 9824 |
$zaiko = ( isset( $datas[ $sku ]['stock'] ) ) ? $datas[ $sku ]['stock'] : 2;
|
| 9825 |
$gptekiyo = ( isset( $datas[ $sku ]['gp'] ) ) ? $datas[ $sku ]['gp'] : null;
|
| 9826 |
$skuPrice = ( isset( $datas[ $sku ]['price'] ) ) ? $datas[ $sku ]['price'] : 0;
|
| 9827 |
$sku_enc = urlencode( $sku );
|
| 9828 |
$options = usces_get_opts( $post_id, 'sort' );
|
| 9829 |
$mats = compact( 'item', 'sku', 'value', 'force', 'quant', 'post_id', 'datas', 'zaikonum', 'zaiko', 'gptekiyo', 'skuPrice', 'sku_enc' );
|
| 9830 |
if ( ! $this->is_item_zaiko( $post_id, $sku ) ) {
|
| 9831 |
return '<div class="button_status">' . esc_html( $this->zaiko_status[ $zaiko ] ) . '</div>';
|
| 9832 |
}
|
| 9833 |
|
| 9834 |
$html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
|
| 9835 |
$html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaikonum ) . "\" />\n";
|
| 9836 |
$html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaiko ) . "\" />\n";
|
| 9837 |
$html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $gptekiyo ) . "\" />\n";
|
| 9838 |
$html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $skuPrice ) . "\" />\n";
|
| 9839 |
if ( 1 == $opt ) {
|
| 9840 |
$html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
|
| 9841 |
} elseif ( 2 == $opt ) {
|
| 9842 |
$html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
|
| 9843 |
}
|
| 9844 |
if ( $quant ) {
|
| 9845 |
$quant_field = "<input name=\"quant[{$post_id}][" . $sku_enc . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku_enc . "]\" class=\"skuquantity\" value=\"\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
|
| 9846 |
$html .= apply_filters( 'usces_filter_sc_itemQuant', $quant_field, $mats );
|
| 9847 |
}
|
| 9848 |
$html .= "<input name=\"inCart[{$post_id}][{$sku_enc}]\" type=\"submit\" id=\"inCart[{$post_id}][{$sku_enc}]\" class=\"skubutton\" value=\"" . esc_attr( $value ) . "\" " . apply_filters( 'usces_filter_direct_intocart_button', null, $post_id, $sku, $force, $options ) . ' />';
|
| 9849 |
$html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . esc_url( $_SERVER['REQUEST_URI'] ) . "\" />\n";
|
| 9850 |
if ( $force ) {
|
| 9851 |
$html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
|
| 9852 |
}
|
| 9853 |
$html = apply_filters( 'usces_filter_single_item_inform', $html );
|
| 9854 |
$html .= '</form>';
|
| 9855 |
$html .= '<div class="error_message">' . usces_singleitem_error_message( $post_id, $sku, 'return' ) . '</div>' . "\n";
|
| 9856 |
|
| 9857 |
return $html;
|
| 9858 |
}
|
| 9859 |
|
| 9860 |
public function filter_itemPage( $content ) {
|
| 9861 |
global $post;
|
| 9862 |
$html = '';
|
| 9863 |
|
| 9864 |
if ( ( 'item' != $post->post_mime_type || ! is_single() ) ) {
|
| 9865 |
return $content;
|
| 9866 |
}
|
| 9867 |
if ( post_password_required( $post ) ) {
|
| 9868 |
return $content;
|
| 9869 |
}
|
| 9870 |
|
| 9871 |
$temp_path = apply_filters( 'usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php' );
|
| 9872 |
include $temp_path;
|
| 9873 |
|
| 9874 |
$content = apply_filters( 'usces_filter_itemPage', $html, $post->ID );
|
| 9875 |
|
| 9876 |
return $content;
|
| 9877 |
}
|
| 9878 |
|
| 9879 |
public function filter_cartContent( $content ) {
|
| 9880 |
global $post;
|
| 9881 |
$html = '';
|
| 9882 |
switch ( $this->page ) {
|
| 9883 |
case 'cart':
|
| 9884 |
$temp_path = apply_filters( 'usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php' );
|
| 9885 |
include $temp_path;
|
| 9886 |
break;
|
| 9887 |
case 'customer':
|
| 9888 |
$temp_path = apply_filters( 'usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php' );
|
| 9889 |
include $temp_path;
|
| 9890 |
break;
|
| 9891 |
case 'delivery':
|
| 9892 |
$temp_path = apply_filters( 'usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php' );
|
| 9893 |
include $temp_path;
|
| 9894 |
break;
|
| 9895 |
case 'confirm':
|
| 9896 |
$temp_path = apply_filters( 'usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php' );
|
| 9897 |
include $temp_path;
|
| 9898 |
break;
|
| 9899 |
case 'ordercompletion':
|
| 9900 |
$temp_path = apply_filters( 'usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php' );
|
| 9901 |
include $temp_path;
|
| 9902 |
break;
|
| 9903 |
case 'cartverifying':
|
| 9904 |
$temp_path = apply_filters( 'usces_template_path_cartverifying', USCES_PLUGIN_DIR . '/templates/cart/verifying.php' );
|
| 9905 |
include $temp_path;
|
| 9906 |
break;
|
| 9907 |
case 'cartverified':
|
| 9908 |
$temp_path = apply_filters( 'usces_template_path_cartverified', USCES_PLUGIN_DIR . '/templates/cart/verified.php' );
|
| 9909 |
include $temp_path;
|
| 9910 |
break;
|
| 9911 |
case 'error':
|
| 9912 |
$temp_path = apply_filters( 'usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php' );
|
| 9913 |
include $temp_path;
|
| 9914 |
break;
|
| 9915 |
case 'maintenance':
|
| 9916 |
$temp_path = apply_filters( 'usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php' );
|
| 9917 |
include $temp_path;
|
| 9918 |
break;
|
| 9919 |
case 'search_item':
|
| 9920 |
$temp_path = apply_filters( 'usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php' );
|
| 9921 |
include $temp_path;
|
| 9922 |
break;
|
| 9923 |
case 'wp_search':
|
| 9924 |
if ( 'item' == $post->post_mime_type ) {
|
| 9925 |
$temp_path = apply_filters( 'usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php' );
|
| 9926 |
include $temp_path;
|
| 9927 |
} else {
|
| 9928 |
$html = $content;
|
| 9929 |
}
|
| 9930 |
break;
|
| 9931 |
default:
|
| 9932 |
$html = $content;
|
| 9933 |
}
|
| 9934 |
|
| 9935 |
if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) {
|
| 9936 |
$html = str_replace( 'src="' . site_url(), 'src="' . USCES_SSL_URL_ADMIN, $html );
|
| 9937 |
}
|
| 9938 |
|
| 9939 |
$html = apply_filters( 'usces_filter_cartContent', $html );
|
| 9940 |
|
| 9941 |
$content = $html;
|
| 9942 |
|
| 9943 |
remove_filter( 'the_title', array( $this, 'filter_cartTitle' ) );
|
| 9944 |
|
| 9945 |
return $content;
|
| 9946 |
}
|
| 9947 |
|
| 9948 |
public function filter_cartTitle( $title ) {
|
| 9949 |
if ( is_admin() ) {
|
| 9950 |
return $title;
|
| 9951 |
}
|
| 9952 |
|
| 9953 |
if ( 'Cart' == $title || __( 'Cart', 'usces' ) == $title ) {
|
| 9954 |
switch ( $this->page ) {
|
| 9955 |
case 'cart':
|
| 9956 |
$newtitle = apply_filters( 'usces_filter_title_cart', __( 'In the cart', 'usces' ) );
|
| 9957 |
break;
|
| 9958 |
case 'customer':
|
| 9959 |
$newtitle = apply_filters( 'usces_filter_title_customer', __( 'Customer Information', 'usces' ) );
|
| 9960 |
break;
|
| 9961 |
case 'delivery':
|
| 9962 |
$newtitle = apply_filters( 'usces_filter_title_delivery', __( 'Shipping / Payment options', 'usces' ) );
|
| 9963 |
break;
|
| 9964 |
case 'confirm':
|
| 9965 |
$newtitle = apply_filters( 'usces_filter_title_confirm', __( 'Confirmation', 'usces' ) );
|
| 9966 |
break;
|
| 9967 |
case 'ordercompletion':
|
| 9968 |
$newtitle = apply_filters( 'usces_filter_title_ordercompletion', __( 'Completion', 'usces' ) );
|
| 9969 |
break;
|
| 9970 |
case 'error':
|
| 9971 |
$newtitle = apply_filters( 'usces_filter_title_carterror', __( 'Error', 'usces' ) );
|
| 9972 |
break;
|
| 9973 |
case 'cartverified':
|
| 9974 |
$newtitle = apply_filters( 'usces_filter_title_cartverified', __( 'Member registration complete', 'usces' ) );
|
| 9975 |
break;
|
| 9976 |
case 'search_item':
|
| 9977 |
$newtitle = apply_filters( 'usces_filter_title_search_item', __( "'AND' search by categories", 'usces' ) );
|
| 9978 |
break;
|
| 9979 |
case 'maintenance':
|
| 9980 |
$newtitle = apply_filters( 'usces_filter_title_maintenance', __( 'Under Maintenance', 'usces' ) );
|
| 9981 |
break;
|
| 9982 |
case 'login':
|
| 9983 |
$newtitle = apply_filters( 'usces_filter_title_login', __( 'Log-in for members', 'usces' ) );
|
| 9984 |
break;
|
| 9985 |
default:
|
| 9986 |
$newtitle = apply_filters( 'usces_filter_title_cart_default', $title );
|
| 9987 |
}
|
| 9988 |
} else {
|
| 9989 |
$newtitle = $title;
|
| 9990 |
}
|
| 9991 |
|
| 9992 |
$newtitle = apply_filters( 'usces_filter_cartTitle', $newtitle );
|
| 9993 |
return $newtitle;
|
| 9994 |
}
|
| 9995 |
|
| 9996 |
public function action_cartFilter() {
|
| 9997 |
add_filter( 'the_title', array( $this, 'filter_cartTitle' ), 20 );
|
| 9998 |
add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 );
|
| 9999 |
}
|
| 10000 |
|
| 10001 |
public function action_search_item() {
|
| 10002 |
include get_template_directory() . '/page.php';
|
| 10003 |
exit;
|
| 10004 |
}
|
| 10005 |
|
| 10006 |
public function filter_memberContent( $content ) {
|
| 10007 |
global $post;
|
| 10008 |
$html = '';
|
| 10009 |
|
| 10010 |
if ( 'activate' == $this->options['membersystem_state'] ) {
|
| 10011 |
|
| 10012 |
if ( $this->is_member_logged_in() ) {
|
| 10013 |
|
| 10014 |
$member_regmode = 'editmemberform';
|
| 10015 |
$temp_path = apply_filters( 'usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php' );
|
| 10016 |
include $temp_path;
|
| 10017 |
|
| 10018 |
} else {
|
| 10019 |
|
| 10020 |
switch ( $this->page ) {
|
| 10021 |
case 'login':
|
| 10022 |
$temp_path = apply_filters( 'usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php' );
|
| 10023 |
include $temp_path;
|
| 10024 |
break;
|
| 10025 |
case 'lostmemberpassword':
|
| 10026 |
$temp_path = apply_filters( 'usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php' );
|
| 10027 |
include $temp_path;
|
| 10028 |
break;
|
| 10029 |
case 'changepassword':
|
| 10030 |
$temp_path = apply_filters( 'usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php' );
|
| 10031 |
include $temp_path;
|
| 10032 |
break;
|
| 10033 |
case 'newcompletion':
|
| 10034 |
case 'editcompletion':
|
| 10035 |
case 'lostcompletion':
|
| 10036 |
case 'changepasscompletion':
|
| 10037 |
$temp_path = apply_filters( 'usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php' );
|
| 10038 |
include $temp_path;
|
| 10039 |
break;
|
| 10040 |
case 'memberverifying':
|
| 10041 |
$temp_path = apply_filters( 'usces_template_path_memberverifying', USCES_PLUGIN_DIR . '/templates/member/verifying.php' );
|
| 10042 |
include $temp_path;
|
| 10043 |
break;
|
| 10044 |
// case 'memberverified':
|
| 10045 |
// $temp_path = apply_filters('usces_template_path_memberverified', USCES_PLUGIN_DIR . '/templates/member/member_verified.php');
|
| 10046 |
// include $temp_path;
|
| 10047 |
// break;
|
| 10048 |
case 'newmemberform':
|
| 10049 |
$member_form_title = apply_filters( 'usces_filter_title_newmemberform', __( 'New enrollment form', 'usces' ) );
|
| 10050 |
$member_regmode = 'newmemberform';
|
| 10051 |
$temp_path = apply_filters( 'usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php' );
|
| 10052 |
include $temp_path;
|
| 10053 |
break;
|
| 10054 |
default:
|
| 10055 |
$temp_path = apply_filters( 'usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php' );
|
| 10056 |
include $temp_path;
|
| 10057 |
}
|
| 10058 |
}
|
| 10059 |
} else {
|
| 10060 |
$html .= '<p>' . __( 'Member Services is not running currently.', 'usces' ) . '</p>';
|
| 10061 |
}
|
| 10062 |
|
| 10063 |
$content = $html;
|
| 10064 |
|
| 10065 |
remove_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 );
|
| 10066 |
|
| 10067 |
return $content;
|
| 10068 |
}
|
| 10069 |
|
| 10070 |
public function filter_memberTitle( $title ) {
|
| 10071 |
if ( is_admin() ) {
|
| 10072 |
return $title;
|
| 10073 |
}
|
| 10074 |
|
| 10075 |
if ( 'activate' == $this->options['membersystem_state'] && $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) {
|
| 10076 |
switch ( $this->page ) {
|
| 10077 |
case 'login':
|
| 10078 |
$newtitle = apply_filters( 'usces_filter_title_login', __( 'Log-in for members', 'usces' ) );
|
| 10079 |
break;
|
| 10080 |
case 'newmemberform':
|
| 10081 |
$newtitle = apply_filters( 'usces_filter_title_newmemberform', __( 'New enrollment form', 'usces' ) );
|
| 10082 |
break;
|
| 10083 |
case 'lostmemberpassword':
|
| 10084 |
$newtitle = apply_filters( 'usces_filter_title_lostmemberpassword', __( 'The new password acquisition', 'usces' ) );
|
| 10085 |
break;
|
| 10086 |
case 'changepassword':
|
| 10087 |
$newtitle = apply_filters( 'usces_filter_title_changepassword', __( 'Change password', 'usces' ) );
|
| 10088 |
break;
|
| 10089 |
case 'newcompletion':
|
| 10090 |
case 'editcompletion':
|
| 10091 |
case 'lostcompletion':
|
| 10092 |
case 'changepasscompletion':
|
| 10093 |
$newtitle = apply_filters( 'usces_filter_title_changepasscompletion', __( 'Completion', 'usces' ) );
|
| 10094 |
break;
|
| 10095 |
case 'memberverifying':
|
| 10096 |
$newtitle = apply_filters( 'usces_filter_title_memberverifying', __( 'Verifying', 'usces' ) );
|
| 10097 |
break;
|
| 10098 |
case 'error':
|
| 10099 |
$newtitle = apply_filters( 'usces_filter_title_membererror', __( 'Error', 'usces' ) );
|
| 10100 |
break;
|
| 10101 |
default:
|
| 10102 |
$newtitle = apply_filters( 'usces_filter_title_member_default', $title );
|
| 10103 |
}
|
| 10104 |
} else {
|
| 10105 |
$newtitle = $title;
|
| 10106 |
}
|
| 10107 |
|
| 10108 |
$newtitle = apply_filters( 'usces_filter_memberTitle', $newtitle );
|
| 10109 |
return $newtitle;
|
| 10110 |
}
|
| 10111 |
|
| 10112 |
public function action_memberFilter() {
|
| 10113 |
add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 );
|
| 10114 |
add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 );
|
| 10115 |
}
|
| 10116 |
|
| 10117 |
public function filter_usces_cart_css() {
|
| 10118 |
$path = get_stylesheet_directory_uri() . '/usces_cart.css';
|
| 10119 |
return $path;
|
| 10120 |
}
|
| 10121 |
|
| 10122 |
public function filter_divide_item() {
|
| 10123 |
global $wp_query;
|
| 10124 |
|
| 10125 |
if ( ( $this->options['divide_item'] && ! is_category() && ! is_search() && ! is_singular() && ! is_admin() ) ) {
|
| 10126 |
$ids = $this->getItemIds( 'front' );
|
| 10127 |
if ( isset( $wp_query->query_vars['post__not_in'] ) ) {
|
| 10128 |
$wp_query->query_vars['post__not_in'] = $ids;
|
| 10129 |
}
|
| 10130 |
}
|
| 10131 |
if ( is_admin() ) {
|
| 10132 |
$ids = $this->getItemIds( 'back' );
|
| 10133 |
if ( isset( $wp_query->query_vars['post__not_in'] ) ) {
|
| 10134 |
$wp_query->query_vars['post__not_in'] = $ids;
|
| 10135 |
}
|
| 10136 |
}
|
| 10137 |
do_action( 'usces_action_divide_item' );
|
| 10138 |
}
|
| 10139 |
|
| 10140 |
public function load_upload_template() {
|
| 10141 |
$post_id = $_POST['post_id'];
|
| 10142 |
$file = 'upload_template01.php';
|
| 10143 |
include get_template_directory() . '/' . $file;
|
| 10144 |
exit;
|
| 10145 |
}
|
| 10146 |
|
| 10147 |
public function filter_itemimg_anchor_rel( $html ) {
|
| 10148 |
if ( is_single() ) {
|
| 10149 |
$str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
|
| 10150 |
} else {
|
| 10151 |
$str = '';
|
| 10152 |
}
|
| 10153 |
return $html . $str;
|
| 10154 |
}
|
| 10155 |
|
| 10156 |
public function filter_permalink( $link ) {
|
| 10157 |
if ( false !== strpos( '?page_id=4', $link ) || false !== strpos( '?page_id=3', $link ) || false !== strpos( 'usces-cart', $link ) || false !== strpos( 'usces-member', $link ) ) {
|
| 10158 |
$link = str_replace( 'http://', 'https://', $link );
|
| 10159 |
}
|
| 10160 |
return $link;
|
| 10161 |
}
|
| 10162 |
|
| 10163 |
public function filter_cart_page_header( $html ) {
|
| 10164 |
if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) {
|
| 10165 |
$html = $this->options['cart_page_data']['header']['cart'];
|
| 10166 |
}
|
| 10167 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10168 |
}
|
| 10169 |
|
| 10170 |
public function filter_cart_page_footer( $html ) {
|
| 10171 |
if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) {
|
| 10172 |
$html = $this->options['cart_page_data']['footer']['cart'];
|
| 10173 |
}
|
| 10174 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10175 |
}
|
| 10176 |
|
| 10177 |
public function filter_customer_page_header( $html ) {
|
| 10178 |
if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) {
|
| 10179 |
$html = $this->options['cart_page_data']['header']['customer'];
|
| 10180 |
}
|
| 10181 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10182 |
}
|
| 10183 |
|
| 10184 |
public function filter_customer_page_footer( $html ) {
|
| 10185 |
if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) {
|
| 10186 |
$html = $this->options['cart_page_data']['footer']['customer'];
|
| 10187 |
}
|
| 10188 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10189 |
}
|
| 10190 |
|
| 10191 |
public function filter_delivery_page_header( $html ) {
|
| 10192 |
if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) {
|
| 10193 |
$html = $this->options['cart_page_data']['header']['delivery'];
|
| 10194 |
}
|
| 10195 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10196 |
}
|
| 10197 |
|
| 10198 |
public function filter_delivery_page_footer( $html ) {
|
| 10199 |
if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) {
|
| 10200 |
$html = $this->options['cart_page_data']['footer']['delivery'];
|
| 10201 |
}
|
| 10202 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10203 |
}
|
| 10204 |
|
| 10205 |
public function filter_confirm_page_header( $html ) {
|
| 10206 |
if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) {
|
| 10207 |
$html = $this->options['cart_page_data']['header']['confirm'];
|
| 10208 |
}
|
| 10209 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10210 |
}
|
| 10211 |
|
| 10212 |
public function filter_confirm_page_footer( $html ) {
|
| 10213 |
if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) {
|
| 10214 |
$html = $this->options['cart_page_data']['footer']['confirm'];
|
| 10215 |
}
|
| 10216 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10217 |
}
|
| 10218 |
|
| 10219 |
public function filter_cartcompletion_page_header( $html ) {
|
| 10220 |
if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) {
|
| 10221 |
$html = $this->options['cart_page_data']['header']['completion'];
|
| 10222 |
}
|
| 10223 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10224 |
}
|
| 10225 |
|
| 10226 |
public function filter_cartcompletion_page_footer( $html ) {
|
| 10227 |
if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) {
|
| 10228 |
$html = $this->options['cart_page_data']['footer']['completion'];
|
| 10229 |
}
|
| 10230 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10231 |
}
|
| 10232 |
|
| 10233 |
public function filter_login_page_header( $html ) {
|
| 10234 |
if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) {
|
| 10235 |
$html = $this->options['member_page_data']['header']['login'];
|
| 10236 |
}
|
| 10237 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10238 |
}
|
| 10239 |
|
| 10240 |
public function filter_login_page_footer( $html ) {
|
| 10241 |
if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) {
|
| 10242 |
$html = $this->options['member_page_data']['footer']['login'];
|
| 10243 |
}
|
| 10244 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10245 |
}
|
| 10246 |
|
| 10247 |
public function filter_newmember_page_header( $html ) {
|
| 10248 |
if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) {
|
| 10249 |
$html = $this->options['member_page_data']['header']['newmember'];
|
| 10250 |
}
|
| 10251 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10252 |
}
|
| 10253 |
|
| 10254 |
public function filter_newmember_page_footer( $html ) {
|
| 10255 |
if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) {
|
| 10256 |
$html = $this->options['member_page_data']['footer']['newmember'];
|
| 10257 |
}
|
| 10258 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10259 |
}
|
| 10260 |
|
| 10261 |
public function filter_newpass_page_header( $html ) {
|
| 10262 |
if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) {
|
| 10263 |
$html = $this->options['member_page_data']['header']['newpass'];
|
| 10264 |
}
|
| 10265 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10266 |
}
|
| 10267 |
|
| 10268 |
public function filter_newpass_page_footer( $html ) {
|
| 10269 |
if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) {
|
| 10270 |
$html = $this->options['member_page_data']['footer']['newpass'];
|
| 10271 |
}
|
| 10272 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10273 |
}
|
| 10274 |
|
| 10275 |
public function filter_changepass_page_header( $html ) {
|
| 10276 |
if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) {
|
| 10277 |
$html = $this->options['member_page_data']['header']['changepass'];
|
| 10278 |
}
|
| 10279 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10280 |
}
|
| 10281 |
|
| 10282 |
public function filter_changepass_page_footer( $html ) {
|
| 10283 |
if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) {
|
| 10284 |
$html = $this->options['member_page_data']['footer']['changepass'];
|
| 10285 |
}
|
| 10286 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10287 |
}
|
| 10288 |
|
| 10289 |
public function filter_memberinfo_page_header( $html ) {
|
| 10290 |
if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) {
|
| 10291 |
$html = $this->options['member_page_data']['header']['memberinfo'];
|
| 10292 |
}
|
| 10293 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10294 |
}
|
| 10295 |
|
| 10296 |
public function filter_memberinfo_page_footer( $html ) {
|
| 10297 |
if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) {
|
| 10298 |
$html = $this->options['member_page_data']['footer']['memberinfo'];
|
| 10299 |
}
|
| 10300 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10301 |
}
|
| 10302 |
|
| 10303 |
public function filter_membercompletion_page_header( $html ) {
|
| 10304 |
if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) {
|
| 10305 |
$html = $this->options['member_page_data']['header']['completion'];
|
| 10306 |
}
|
| 10307 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10308 |
}
|
| 10309 |
|
| 10310 |
public function filter_membercompletion_page_footer( $html ) {
|
| 10311 |
if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) {
|
| 10312 |
$html = $this->options['member_page_data']['footer']['completion'];
|
| 10313 |
}
|
| 10314 |
return do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10315 |
}
|
| 10316 |
|
| 10317 |
public function action_cart_page_header() {
|
| 10318 |
if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) {
|
| 10319 |
$html = $this->options['cart_page_data']['header']['cart'];
|
| 10320 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10321 |
}
|
| 10322 |
}
|
| 10323 |
|
| 10324 |
public function action_cart_page_footer() {
|
| 10325 |
if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) {
|
| 10326 |
$html = $this->options['cart_page_data']['footer']['cart'];
|
| 10327 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10328 |
}
|
| 10329 |
}
|
| 10330 |
|
| 10331 |
public function action_customer_page_header() {
|
| 10332 |
if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) {
|
| 10333 |
$html = $this->options['cart_page_data']['header']['customer'];
|
| 10334 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10335 |
}
|
| 10336 |
}
|
| 10337 |
|
| 10338 |
public function action_customer_page_footer() {
|
| 10339 |
if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) {
|
| 10340 |
$html = $this->options['cart_page_data']['footer']['customer'];
|
| 10341 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10342 |
}
|
| 10343 |
}
|
| 10344 |
|
| 10345 |
public function action_delivery_page_header() {
|
| 10346 |
if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) {
|
| 10347 |
$html = $this->options['cart_page_data']['header']['delivery'];
|
| 10348 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10349 |
}
|
| 10350 |
}
|
| 10351 |
|
| 10352 |
public function action_delivery_page_footer() {
|
| 10353 |
if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) {
|
| 10354 |
$html = $this->options['cart_page_data']['footer']['delivery'];
|
| 10355 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10356 |
}
|
| 10357 |
}
|
| 10358 |
|
| 10359 |
public function action_confirm_page_header() {
|
| 10360 |
if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) {
|
| 10361 |
$html = $this->options['cart_page_data']['header']['confirm'];
|
| 10362 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10363 |
}
|
| 10364 |
}
|
| 10365 |
|
| 10366 |
public function action_confirm_page_footer() {
|
| 10367 |
if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) {
|
| 10368 |
$html = $this->options['cart_page_data']['footer']['confirm'];
|
| 10369 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10370 |
}
|
| 10371 |
}
|
| 10372 |
|
| 10373 |
public function action_cartcompletion_page_header() {
|
| 10374 |
if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) {
|
| 10375 |
$html = $this->options['cart_page_data']['header']['completion'];
|
| 10376 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10377 |
}
|
| 10378 |
}
|
| 10379 |
|
| 10380 |
public function action_cartcompletion_page_footer() {
|
| 10381 |
if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) {
|
| 10382 |
$html = $this->options['cart_page_data']['footer']['completion'];
|
| 10383 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10384 |
}
|
| 10385 |
}
|
| 10386 |
|
| 10387 |
public function action_login_page_header() {
|
| 10388 |
if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) {
|
| 10389 |
$html = $this->options['member_page_data']['header']['login'];
|
| 10390 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10391 |
}
|
| 10392 |
}
|
| 10393 |
|
| 10394 |
public function action_login_page_footer() {
|
| 10395 |
if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) {
|
| 10396 |
$html = $this->options['member_page_data']['footer']['login'];
|
| 10397 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10398 |
}
|
| 10399 |
}
|
| 10400 |
|
| 10401 |
public function action_newmember_page_header() {
|
| 10402 |
if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) {
|
| 10403 |
$html = $this->options['member_page_data']['header']['newmember'];
|
| 10404 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10405 |
}
|
| 10406 |
}
|
| 10407 |
|
| 10408 |
public function action_newmember_page_footer() {
|
| 10409 |
if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) {
|
| 10410 |
$html = $this->options['member_page_data']['footer']['newmember'];
|
| 10411 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10412 |
}
|
| 10413 |
}
|
| 10414 |
|
| 10415 |
public function action_newpass_page_header() {
|
| 10416 |
if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) {
|
| 10417 |
$html = $this->options['member_page_data']['header']['newpass'];
|
| 10418 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10419 |
}
|
| 10420 |
}
|
| 10421 |
|
| 10422 |
public function action_newpass_page_footer() {
|
| 10423 |
if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) {
|
| 10424 |
$html = $this->options['member_page_data']['footer']['newpass'];
|
| 10425 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10426 |
}
|
| 10427 |
}
|
| 10428 |
|
| 10429 |
public function action_changepass_page_header() {
|
| 10430 |
if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) {
|
| 10431 |
$html = $this->options['member_page_data']['header']['changepass'];
|
| 10432 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10433 |
}
|
| 10434 |
}
|
| 10435 |
|
| 10436 |
public function action_changepass_page_footer() {
|
| 10437 |
if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) {
|
| 10438 |
$html = $this->options['member_page_data']['footer']['changepass'];
|
| 10439 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10440 |
}
|
| 10441 |
}
|
| 10442 |
|
| 10443 |
public function action_memberinfo_page_header() {
|
| 10444 |
if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) {
|
| 10445 |
$html = $this->options['member_page_data']['header']['memberinfo'];
|
| 10446 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10447 |
}
|
| 10448 |
}
|
| 10449 |
|
| 10450 |
public function action_memberinfo_page_footer() {
|
| 10451 |
if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) {
|
| 10452 |
$html = $this->options['member_page_data']['footer']['memberinfo'];
|
| 10453 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10454 |
}
|
| 10455 |
}
|
| 10456 |
|
| 10457 |
public function action_membercompletion_page_header() {
|
| 10458 |
if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) {
|
| 10459 |
$html = $this->options['member_page_data']['header']['completion'];
|
| 10460 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10461 |
}
|
| 10462 |
}
|
| 10463 |
|
| 10464 |
public function action_membercompletion_page_footer() {
|
| 10465 |
if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) {
|
| 10466 |
$html = $this->options['member_page_data']['footer']['completion'];
|
| 10467 |
echo do_shortcode( stripslashes( nl2br( $html ) ) );
|
| 10468 |
}
|
| 10469 |
}
|
| 10470 |
|
| 10471 |
public function filter_confirm_page_notes( $html ) {
|
| 10472 |
if ( ! empty( $this->options['cart_page_data']['confirm_notes'] ) ) {
|
| 10473 |
$html = '<div class="wc_confirm_notes_area">' . $this->options['cart_page_data']['confirm_notes'] . '</div>';
|
| 10474 |
}
|
| 10475 |
return stripslashes( nl2br( $html ) );
|
| 10476 |
}
|
| 10477 |
|
| 10478 |
public function action_confirm_page_notes() {
|
| 10479 |
if ( ! empty( $this->options['cart_page_data']['confirm_notes'] ) ) {
|
| 10480 |
$html = '<div class="wc_confirm_notes_area">' . $this->options['cart_page_data']['confirm_notes'] . '</div>';
|
| 10481 |
echo stripslashes( nl2br( $html ) );
|
| 10482 |
}
|
| 10483 |
}
|
| 10484 |
|
| 10485 |
/**
|
| 10486 |
* Get member cookies.
|
| 10487 |
*
|
| 10488 |
* @param string $key string cookies key.
|
| 10489 |
*
|
| 10490 |
* @return string
|
| 10491 |
*/
|
| 10492 |
public function usces_get_member_cookies( $key ) {
|
| 10493 |
$result = '';
|
| 10494 |
switch ( $key ) {
|
| 10495 |
case 'ord_ex_cancel':
|
| 10496 |
$ex_cancel = filter_input( INPUT_GET, 'ord_ex_cancel' );
|
| 10497 |
if ( $ex_cancel ) {
|
| 10498 |
$result = ( 'on' === $ex_cancel ) ? 'on' : 'off';
|
| 10499 |
} else {
|
| 10500 |
$cookie = $this->get_cookie( 'usces_front' );
|
| 10501 |
$result = isset( $cookie['ord_ex_cancel'] ) ? $cookie['ord_ex_cancel'] : 'on';
|
| 10502 |
$result = apply_filters( 'usces_filter_ord_ex_cancel_init', $result );
|
| 10503 |
}
|
| 10504 |
break;
|
| 10505 |
case 'pur-date':
|
| 10506 |
$result = filter_input( INPUT_GET, 'pur-date' );
|
| 10507 |
if ( null === $result ) {
|
| 10508 |
$cookie = $this->get_cookie( 'usces_front' );
|
| 10509 |
$result = isset( $cookie['usces_purdate'] ) ? $cookie['usces_purdate'] : 'd_30';
|
| 10510 |
$result = apply_filters( 'usces_filter_ord_purdate_init', $result );
|
| 10511 |
}
|
| 10512 |
break;
|
| 10513 |
}
|
| 10514 |
return $result;
|
| 10515 |
}
|
| 10516 |
|
| 10517 |
}
|
| 10518 |
|