| @@ -1,7916 +1,10505 @@ | ||
| 1 | -<?php | |
| 2 | -class usc_e_shop | |
| 3 | -{ | |
| 4 | - | |
| 5 | - var $page; //page action | |
| 6 | - var $cart; //cart object | |
| 7 | - var $use_ssl; //ssl flag | |
| 8 | - var $action, $action_status, $error_status; | |
| 9 | - var $action_message, $error_message; | |
| 10 | - var $itemskus, $itemsku, $itemopts, $itemopt, $item; | |
| 11 | - var $zaiko_status, $payment_structure, $display_mode, $shipping_rule; | |
| 12 | - var $member_status; | |
| 13 | - var $options, $mail_para; | |
| 14 | - var $login_mail, $current_member, $member_form; | |
| 15 | - var $payment_results, $log_flg, $delim, $use_js; | |
| 16 | - | |
| 17 | - function usc_e_shop() | |
| 18 | - { | |
| 19 | -//20110331ysk start | |
| 20 | - //global $post, $usces_settings; | |
| 21 | - global $post, $usces_settings, $usces_states; | |
| 22 | -//20110331ysk end | |
| 23 | - do_action('usces_construct'); | |
| 24 | - add_action('after_setup_theme', array(&$this, 'usces_session_start')); | |
| 25 | - | |
| 26 | - if ( is_admin() ){ | |
| 27 | - clean_term_cache( get_option('usces_item_cat_parent_id'), 'category' ); | |
| 28 | - } | |
| 29 | - | |
| 30 | - $locales = usces_locales(); | |
| 31 | - foreach($locales as $l){ | |
| 32 | - $usces_settings['language'][$l] = $l; | |
| 33 | - } | |
| 34 | - $usces_settings['language']['others'] = __('Follow config.php', 'usces'); | |
| 35 | - | |
| 36 | - $this->options = get_option('usces'); | |
| 37 | - if(!isset($this->options['smtp_hostname']) || empty($this->options['smtp_hostname'])){ $this->options['smtp_hostname'] = 'localhost';} | |
| 38 | - if(!isset($this->options['delivery_method']) || !is_array($this->options['delivery_method'])) $this->options['delivery_method'] = array(); | |
| 39 | - if(!isset($this->options['shipping_charge']) || !is_array($this->options['shipping_charge'])) $this->options['shipping_charge'] = array(); | |
| 40 | - if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate'; | |
| 41 | - if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = 'activate'; | |
| 42 | - if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0; | |
| 43 | - if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 0; | |
| 44 | - if(!isset($this->options['use_javascript'])) $this->options['use_javascript'] = 1; | |
| 45 | - if(!isset($this->options['privilege_discount'])) $this->options['privilege_discount'] = ''; | |
| 46 | - if(!isset($this->options['privilege_point'])) $this->options['privilege_point'] = ''; | |
| 47 | - if(!isset($this->options['campaign_privilege'])) $this->options['campaign_privilege'] = ''; | |
| 48 | - if(!isset($this->options['campaign_category'])) $this->options['campaign_category'] = 0; | |
| 49 | - if(!isset($this->options['campaign_schedule']['start'])) $this->options['campaign_schedule']['start'] = array(); | |
| 50 | - if(!isset($this->options['campaign_schedule']['end'])) $this->options['campaign_schedule']['end'] = array(); | |
| 51 | - if(!isset($this->options['acting_settings']['paypal']['ec_activate'])) $this->options['acting_settings']['paypal']['ec_activate'] = ''; | |
| 52 | - if(!isset($this->options['purchase_limit'])) $this->options['purchase_limit'] = ''; | |
| 53 | - if(!isset($this->options['point_rate'])) $this->options['point_rate'] = ''; | |
| 54 | - if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = ''; | |
| 55 | - if(!isset($this->options['company_name'])) $this->options['company_name'] = ''; | |
| 56 | - if(!isset($this->options['address1'])) $this->options['address1'] = ''; | |
| 57 | - if(!isset($this->options['address2'])) $this->options['address2'] = ''; | |
| 58 | - if(!isset($this->options['zip_code'])) $this->options['zip_code'] = ''; | |
| 59 | - if(!isset($this->options['tel_number'])) $this->options['tel_number'] = ''; | |
| 60 | - if(!isset($this->options['fax_number'])) $this->options['fax_number'] = ''; | |
| 61 | - if(!isset($this->options['order_mail'])) $this->options['order_mail'] = ''; | |
| 62 | - if(!isset($this->options['inquiry_mail'])) $this->options['inquiry_mail'] = ''; | |
| 63 | - if(!isset($this->options['sender_mail'])) $this->options['sender_mail'] = ''; | |
| 64 | - if(!isset($this->options['error_mail'])) $this->options['error_mail'] = ''; | |
| 65 | - if(!isset($this->options['copyright'])) $this->options['copyright'] = ''; | |
| 66 | - if(!isset($this->options['postage_privilege'])) $this->options['postage_privilege'] = ''; | |
| 67 | - if(!isset($this->options['shipping_rule'])) $this->options['shipping_rule'] = ''; | |
| 68 | - if(!isset($this->options['tax_rate'])) $this->options['tax_rate'] = ''; | |
| 69 | - if(!isset($this->options['tax_method'])) $this->options['tax_method'] = 'cutting'; | |
| 70 | - if(!isset($this->options['transferee'])) $this->options['transferee'] = ''; | |
| 71 | - if(!isset($this->options['membersystem_state'])) $this->options['membersystem_state'] = 'activate'; | |
| 72 | - if(!isset($this->options['membersystem_point'])) $this->options['membersystem_point'] = ''; | |
| 73 | - if(!isset($this->options['point_rate'])) $this->options['point_rate'] = ''; | |
| 74 | - if(!isset($this->options['start_point'])) $this->options['start_point'] = ''; | |
| 75 | - if(!isset($this->options['point_coverage'])) $this->options['point_coverage'] = 1; | |
| 76 | - if(!isset($this->options['point_assign'])) $this->options['point_assign'] = 1;//20120919ysk 0000573 | |
| 77 | - if(!isset($this->options['cod_type'])) $this->options['cod_type'] = 'fix'; | |
| 78 | - if(!isset($this->options['newmem_admin_mail'])) $this->options['newmem_admin_mail'] = 0; | |
| 79 | - if(!isset($this->options['mail_data']['title'])) $this->options['mail_data']['title'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>''); | |
| 80 | - if(!isset($this->options['mail_data']['header'])) $this->options['mail_data']['header'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>''); | |
| 81 | - if(!isset($this->options['mail_data']['footer'])) $this->options['mail_data']['footer'] = array('thankyou'=>'','order'=>'','inquiry'=>'','returninq'=>'','membercomp'=>'','completionmail'=>'', 'ordermail'=>'','changemail'=>'','receiptmail'=>'','mitumorimail'=>'','cancelmail'=>'','othermail'=>''); | |
| 82 | - if(!isset($this->options['cart_page_data']['header'])) $this->options['cart_page_data']['header'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>''); | |
| 83 | - if(!isset($this->options['cart_page_data']['footer'])) $this->options['cart_page_data']['footer'] = array('cart'=>'','customer'=>'','delivery'=>'','confirm'=>'','completion'=>''); | |
| 84 | - if(!isset($this->options['member_page_data']['header'])) $this->options['member_page_data']['header'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>''); | |
| 85 | - if(!isset($this->options['member_page_data']['footer'])) $this->options['member_page_data']['footer'] = array('login'=>'','newmember'=>'','newpass'=>'','changepass'=>'','memberinfo'=>'','completion'=>''); | |
| 86 | - | |
| 87 | - if(!isset($this->options['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = '0'; | |
| 88 | - if(!isset($this->options['delivery_after_days'])) $this->options['delivery_after_days'] = 15; | |
| 89 | - if(!isset($this->options['delivery_days'])) $this->options['delivery_days'] = array(); | |
| 90 | - if(!isset($this->options['delivery_time_limit']['hour'])) $this->options['delivery_time_limit']['hour'] = '00'; | |
| 91 | - if(!isset($this->options['delivery_time_limit']['min'])) $this->options['delivery_time_limit']['min'] = '00'; | |
| 92 | - | |
| 93 | - if(!isset($this->options['divide_item'])) $this->options['divide_item'] = 0; | |
| 94 | - if(!isset($this->options['itemimg_anchor_rel'])) $this->options['itemimg_anchor_rel'] = ''; | |
| 95 | - if(!isset($this->options['fukugo_category_orderby'])) $this->options['fukugo_category_orderby'] = 'ID'; | |
| 96 | - if(!isset($this->options['fukugo_category_order'])) $this->options['fukugo_category_order'] = 'ASC'; | |
| 97 | - if(!isset($this->options['settlement_path'])) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/'; | |
| 98 | - if(!isset($this->options['use_ssl'])) $this->options['use_ssl'] = 0; | |
| 99 | - if(!isset($this->options['ssl_url'])) $this->options['ssl_url'] = ''; | |
| 100 | - if(!isset($this->options['ssl_url_admin'])) $this->options['ssl_url_admin'] = ''; | |
| 101 | - if(!isset($this->options['inquiry_id'])) $this->options['inquiry_id'] = ''; | |
| 102 | - if(!isset($this->options['system']['orderby_itemsku'])) $this->options['system']['orderby_itemsku'] = 0; | |
| 103 | - if(!isset($this->options['system']['orderby_itemopt'])) $this->options['system']['orderby_itemopt'] = 0; | |
| 104 | - if(!isset($this->options['system']['front_lang'])) $this->options['system']['front_lang'] = usces_get_local_language(); | |
| 105 | - if(!isset($this->options['system']['currency'])) $this->options['system']['currency'] = usces_get_base_country(); | |
| 106 | - if(!isset($this->options['system']['addressform'])) $this->options['system']['addressform'] = usces_get_local_addressform(); | |
| 107 | - if(!isset($this->options['system']['target_market'])) $this->options['system']['target_market'] = usces_get_local_target_market(); | |
| 108 | - if(!isset($this->options['system']['no_cart_css'])) $this->options['system']['no_cart_css'] = 0; | |
| 109 | - if(!isset($this->options['system']['dec_orderID_flag'])) $this->options['system']['dec_orderID_flag'] = 0; | |
| 110 | - if(!isset($this->options['system']['dec_orderID_prefix'])) $this->options['system']['dec_orderID_prefix'] = ''; | |
| 111 | - if(!isset($this->options['system']['dec_orderID_digit'])) $this->options['system']['dec_orderID_digit'] = 6; | |
| 112 | - if(!isset($this->options['system']['subimage_rule'])) $this->options['system']['subimage_rule'] = 0; | |
| 113 | - | |
| 114 | - if(!isset($this->options['acting_settings']['zeus'])) $this->options['acting_settings']['zeus'] = array('activate'=>'','card_activate'=>'','clientip'=>'','authkey'=>'','connection'=>'','3dsecure'=>'','security'=>'','quickcharge'=>'', 'howpay'=>'','bank_activate'=>'','clientip_bank'=>'','testid_bank'=>'','conv_activate'=>'','clientip_conv'=>'','testid_conv'=>'','test_type_conv'=>''); | |
| 115 | - if(!isset($this->options['acting_settings']['zeus']['connection'])) $this->options['acting_settings']['zeus']['connection'] = '1'; | |
| 116 | - if(!isset($this->options['acting_settings']['zeus']['3dsecur'])) $this->options['acting_settings']['zeus']['3dsecur'] = '2'; | |
| 117 | - if(!isset($this->options['acting_settings']['zeus']['security'])) $this->options['acting_settings']['zeus']['security'] = '2'; | |
| 118 | - if(!isset($this->options['acting_settings']['remise'])) $this->options['acting_settings']['remise'] = array('activate'=>'','plan'=>'','SHOPCO'=>'','HOSTID'=>'','card_activate'=>'','card_jb'=>'', 'payquick'=>'','howpay'=>'','continuation'=>'','card_pc_ope'=>'','send_url_pc'=>'','conv_activate'=>'','S_PAYDATE'=>'','conv_pc_ope'=>'','send_url_cvs_pc'=>''); | |
| 119 | - if(!isset($this->options['acting_settings']['jpayment'])) $this->options['acting_settings']['jpayment'] = array('activate'=>'','aid'=>'','card_activate'=>'','card_jb'=>'','conv_activate'=>'','webm_activate'=>'', 'bitc_activate'=>'','suica_activate'=>'','bank_activate'=>''); | |
| 120 | - if(!isset($this->options['acting_settings']['paypal'])) $this->options['acting_settings']['paypal'] = array('activate'=>'','ec_activate'=>'','sandbox'=>'','user'=>'','pwd'=>'','signature'=>'', 'continuation'=>''); | |
| 121 | - | |
| 122 | -//20010420ysk start | |
| 123 | - //if(!isset($this->options['system']['base_country'])) $this->options['system']['base_country'] = usces_get_base_country(); | |
| 124 | - $this->options['system']['base_country'] = usces_get_base_country(); | |
| 125 | -//20010420ysk end | |
| 126 | -//20110331ysk start | |
| 127 | - if(!isset($this->options['province'])) $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']]; | |
| 128 | -//20110331ysk end | |
| 129 | - if(!isset($this->options['system']['pointreduction'])) $this->options['system']['pointreduction'] = usces_get_pointreduction($this->options['system']['currency']); | |
| 130 | - if(!isset($this->options['indi_item_name'])){ | |
| 131 | - $this->options['indi_item_name']['item_name'] = 1; | |
| 132 | - $this->options['indi_item_name']['item_code'] = 1; | |
| 133 | - $this->options['indi_item_name']['sku_name'] = 1; | |
| 134 | - $this->options['indi_item_name']['sku_code'] = 1; | |
| 135 | - $this->options['pos_item_name']['item_name'] = 1; | |
| 136 | - $this->options['pos_item_name']['item_code'] = 2; | |
| 137 | - $this->options['pos_item_name']['sku_name'] = 3; | |
| 138 | - $this->options['pos_item_name']['sku_code'] = 4; | |
| 139 | - } | |
| 140 | - update_option('usces', $this->options); | |
| 141 | - | |
| 142 | - $this->check_display_mode(); | |
| 143 | - $this->error_message = ''; | |
| 144 | - $this->login_mail = ''; | |
| 145 | - $this->get_current_member(); | |
| 146 | - $this->page = ''; | |
| 147 | - $this->payment_results = array(); | |
| 148 | - $this->use_js = $this->options['use_javascript']; | |
| 149 | - | |
| 150 | - //admin_ssl options | |
| 151 | -// $this->use_ssl = get_option("admin_ssl_use_ssl") === "1" ? true : false; | |
| 152 | -// $use_shared = get_option("admin_ssl_use_shared") === "1" && $this->use_ssl ? true : false; | |
| 153 | -// $shared_url = get_option("admin_ssl_shared_url"); | |
| 154 | - | |
| 155 | - $this->use_ssl = $this->options['use_ssl']; | |
| 156 | -// if ( $use_shared ) { | |
| 157 | -// $ssl_url = str_replace('/wp-admin/', '', $shared_url); | |
| 158 | -// } else { | |
| 159 | -// $ssl_url = str_replace('http://', 'https://', get_option('home')); | |
| 160 | -// } | |
| 161 | - define('USCES_CART_NUMBER', get_option('usces_cart_number')); | |
| 162 | - define('USCES_MEMBER_NUMBER', get_option('usces_member_number')); | |
| 163 | - | |
| 164 | - if ( $this->use_ssl ) { | |
| 165 | - $ssl_url = $this->options['ssl_url']; | |
| 166 | - $ssl_url_admin = $this->options['ssl_url_admin']; | |
| 167 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 168 | - define('USCES_FRONT_PLUGIN_URL', $ssl_url_admin . '/wp-content/plugins/' . USCES_PLUGIN_FOLDER); | |
| 169 | - define('USCES_COOKIEPATH', preg_replace('|https?://[^/]+|i', '', $ssl_url . '/' ) ); | |
| 170 | - }else{ | |
| 171 | - define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER); | |
| 172 | - define('USCES_COOKIEPATH', COOKIEPATH); | |
| 173 | - } | |
| 174 | - define('USCES_SSL_URL', $ssl_url); | |
| 175 | - define('USCES_SSL_URL_ADMIN', $ssl_url_admin); | |
| 176 | - }else{ | |
| 177 | - define('USCES_FRONT_PLUGIN_URL', USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER); | |
| 178 | - define('USCES_SSL_URL', get_option('home')); | |
| 179 | - define('USCES_SSL_URL_ADMIN', get_option('siteurl')); | |
| 180 | - define('USCES_COOKIEPATH', COOKIEPATH); | |
| 181 | - } | |
| 182 | -// if($this->use_ssl) { | |
| 183 | -// define('USCES_CART_URL', $ssl_url . '/?page_id=' . USCES_CART_NUMBER . '&usces=' . $this->get_uscesid()); | |
| 184 | -// define('USCES_MEMBER_URL', $ssl_url . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces=' . $this->get_uscesid()); | |
| 185 | -// define('USCES_INQUIRY_URL', $ssl_url . '/?page_id=' . $this->options['inquiry_id'] . '&usces=' . $this->get_uscesid()); | |
| 186 | -// add_filter('home_url', array($this, 'usces_ssl_page_link')); | |
| 187 | -// add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link')); | |
| 188 | -// add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link')); | |
| 189 | -// add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link')); | |
| 190 | -// add_filter('script_loader_src', array($this, 'usces_ssl_script_link')); | |
| 191 | -// add_filter('style_loader_src', array($this, 'usces_ssl_script_link')); | |
| 192 | -// } else { | |
| 193 | -// define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER); | |
| 194 | -// define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER); | |
| 195 | -// define('USCES_INQUIRY_URL', get_option('home') . '/?page_id=' . $this->options['inquiry_id']); | |
| 196 | -// } | |
| 197 | - define('USCES_ITEM_CAT_PARENT_ID', get_option('usces_item_cat_parent_id')); | |
| 198 | - | |
| 199 | - $this->zaiko_status = get_option('usces_zaiko_status'); | |
| 200 | - $this->member_status = get_option('usces_customer_status'); | |
| 201 | - $this->payment_structure = get_option('usces_payment_structure'); | |
| 202 | - $this->display_mode = get_option('usces_display_mode'); | |
| 203 | - define('USCES_MYSQL_VERSION', (int)substr(mysql_get_server_info(), 0, 1)); | |
| 204 | - define('USCES_JP', ('ja' === get_locale() ? true : false)); | |
| 205 | - | |
| 206 | - } | |
| 207 | - | |
| 208 | - function get_default_post_to_edit30( $post_type = 'post', $create_in_db = false ) { | |
| 209 | - global $wpdb; | |
| 210 | - | |
| 211 | - $post_title = ''; | |
| 212 | - if ( !empty( $_REQUEST['post_title'] ) ) | |
| 213 | - $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); | |
| 214 | - | |
| 215 | - $post_content = ''; | |
| 216 | - if ( !empty( $_REQUEST['content'] ) ) | |
| 217 | - $post_content = esc_html( stripslashes( $_REQUEST['content'] )); | |
| 218 | - | |
| 219 | - $post_excerpt = ''; | |
| 220 | - if ( !empty( $_REQUEST['excerpt'] ) ) | |
| 221 | - $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); | |
| 222 | - | |
| 223 | - if ( $create_in_db ) { | |
| 224 | - // Cleanup old auto-drafts more than 7 days old | |
| 225 | - $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); | |
| 226 | - foreach ( (array) $old_posts as $delete ) | |
| 227 | - wp_delete_post( $delete, true ); // Force delete | |
| 228 | - $post = get_post( wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ) ); | |
| 229 | - } else { | |
| 230 | - $post->ID = 0; | |
| 231 | - $post->post_author = ''; | |
| 232 | - $post->post_date = ''; | |
| 233 | - $post->post_date_gmt = ''; | |
| 234 | - $post->post_password = ''; | |
| 235 | - $post->post_type = $post_type; | |
| 236 | - $post->post_status = 'draft'; | |
| 237 | - $post->to_ping = ''; | |
| 238 | - $post->pinged = ''; | |
| 239 | - $post->comment_status = get_option( 'default_comment_status' ); | |
| 240 | - $post->ping_status = get_option( 'default_ping_status' ); | |
| 241 | - $post->post_pingback = get_option( 'default_pingback_flag' ); | |
| 242 | - $post->post_category = get_option( 'default_category' ); | |
| 243 | - $post->page_template = 'default'; | |
| 244 | - $post->post_parent = 0; | |
| 245 | - $post->menu_order = 0; | |
| 246 | - } | |
| 247 | - | |
| 248 | - $post->post_content = apply_filters( 'default_content', $post_content, $post ); | |
| 249 | - $post->post_title = apply_filters( 'default_title', $post_title, $post ); | |
| 250 | - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); | |
| 251 | - $post->post_name = ''; | |
| 252 | - | |
| 253 | - return $post; | |
| 254 | - } | |
| 255 | - | |
| 256 | - function get_default_post_to_edit() { | |
| 257 | - global $post; | |
| 258 | - | |
| 259 | - $post_title = ''; | |
| 260 | - if ( !empty( $_REQUEST['post_title'] ) ) | |
| 261 | - $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); | |
| 262 | - | |
| 263 | - $post_content = ''; | |
| 264 | - if ( !empty( $_REQUEST['content'] ) ) | |
| 265 | - $post_content = esc_html( stripslashes( $_REQUEST['content'] )); | |
| 266 | - | |
| 267 | - $post_excerpt = ''; | |
| 268 | - if ( !empty( $_REQUEST['excerpt'] ) ) | |
| 269 | - $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); | |
| 270 | - | |
| 271 | - $post->ID = 0; | |
| 272 | - $post->post_name = ''; | |
| 273 | - $post->post_author = ''; | |
| 274 | - $post->post_date = ''; | |
| 275 | - $post->post_date_gmt = ''; | |
| 276 | - $post->post_password = ''; | |
| 277 | - $post->post_status = 'draft'; | |
| 278 | - $post->post_type = 'post'; | |
| 279 | - $post->to_ping = ''; | |
| 280 | - $post->pinged = ''; | |
| 281 | - $post->comment_status = get_option( 'default_comment_status' ); | |
| 282 | - $post->ping_status = get_option( 'default_ping_status' ); | |
| 283 | - $post->post_pingback = get_option( 'default_pingback_flag' ); | |
| 284 | - $post->post_category = get_option( 'default_category' ); | |
| 285 | - $post->post_content = apply_filters( 'default_content', $post_content); | |
| 286 | - $post->post_title = apply_filters( 'default_title', $post_title ); | |
| 287 | - $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt); | |
| 288 | - $post->page_template = 'default'; | |
| 289 | - $post->post_parent = 0; | |
| 290 | - $post->menu_order = 0; | |
| 291 | - | |
| 292 | - return $post; | |
| 293 | - } | |
| 294 | - function is_cart_or_member_page($link) | |
| 295 | - { | |
| 296 | - $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart', ('page_id='.USCES_MEMBER_NUMBER), '/usces-member'); | |
| 297 | - $flag = false; | |
| 298 | - foreach($search as $value){ | |
| 299 | - $parts = array(); | |
| 300 | - if( false !== strpos($link, $value) ){ | |
| 301 | - if( $value == ('page_id='.USCES_CART_NUMBER) || $value == ('page_id='.USCES_MEMBER_NUMBER) ){ | |
| 302 | - $parts = parse_url($link); | |
| 303 | - parse_str($parts['query'], $query); | |
| 304 | - if( $query['page_id'] == USCES_CART_NUMBER || $query['page_id'] == USCES_MEMBER_NUMBER ){ | |
| 305 | - $flag = true; | |
| 306 | - } | |
| 307 | - }else{ | |
| 308 | - $flag = true; | |
| 309 | - } | |
| 310 | - } | |
| 311 | - } | |
| 312 | - return $flag; | |
| 313 | - } | |
| 314 | - | |
| 315 | - function is_cart_page($link) | |
| 316 | - { | |
| 317 | - $search = array(('page_id='.USCES_CART_NUMBER), '/usces-cart' ); | |
| 318 | - $flag = false; | |
| 319 | - foreach($search as $value){ | |
| 320 | - if( false !== strpos($link, $value) ){ | |
| 321 | - if( $value == ('page_id='.USCES_CART_NUMBER) ){ | |
| 322 | - $parts = parse_url($link); | |
| 323 | - parse_str($parts['query'], $query); | |
| 324 | - if( $query['page_id'] == USCES_CART_NUMBER ){ | |
| 325 | - $flag = true; | |
| 326 | - } | |
| 327 | - }else{ | |
| 328 | - $flag = true; | |
| 329 | - } | |
| 330 | - } | |
| 331 | - } | |
| 332 | - return $flag; | |
| 333 | - } | |
| 334 | - | |
| 335 | - function is_member_page($link) | |
| 336 | - { | |
| 337 | - $search = array(('page_id='.USCES_MEMBER_NUMBER), '/usces-member' ); | |
| 338 | - $flag = false; | |
| 339 | - foreach($search as $value){ | |
| 340 | - if( false !== strpos($link, $value) ){ | |
| 341 | - if( $value == ('page_id='.USCES_MEMBER_NUMBER) ){ | |
| 342 | - $parts = parse_url($link); | |
| 343 | - parse_str($parts['query'], $query); | |
| 344 | - if( $query['page_id'] == USCES_MEMBER_NUMBER ){ | |
| 345 | - $flag = true; | |
| 346 | - } | |
| 347 | - }else{ | |
| 348 | - $flag = true; | |
| 349 | - } | |
| 350 | - } | |
| 351 | - } | |
| 352 | - return $flag; | |
| 353 | - } | |
| 354 | - | |
| 355 | - function is_inquiry_page($link) | |
| 356 | - { | |
| 357 | - if( empty($this->options['inquiry_id']) ) | |
| 358 | - return false; | |
| 359 | - | |
| 360 | - $search = array(('page_id='.$this->options['inquiry_id']), '/usces-inquiry' ); | |
| 361 | - $flag = false; | |
| 362 | - foreach($search as $value){ | |
| 363 | - if( false !== strpos($link, $value) ){ | |
| 364 | - if( $value == ('page_id='.$this->options['inquiry_id']) ){ | |
| 365 | - $parts = parse_url($link); | |
| 366 | - parse_str($parts['query'], $query); | |
| 367 | - if( $query['page_id'] == $this->options['inquiry_id'] ){ | |
| 368 | - $flag = true; | |
| 369 | - } | |
| 370 | - }else{ | |
| 371 | - $flag = true; | |
| 372 | - } | |
| 373 | - } | |
| 374 | - } | |
| 375 | - return $flag; | |
| 376 | - } | |
| 377 | - | |
| 378 | - function usces_ssl_page_link($link) | |
| 379 | - { | |
| 380 | - $parts = parse_url($link); | |
| 381 | - | |
| 382 | - if( isset($parts['query']) ){ | |
| 383 | - parse_str($parts['query'], $query); | |
| 384 | - } | |
| 385 | - | |
| 386 | - if( false !== strpos($link, '/usces-cart') || (isset( $query['page_id']) && $query['page_id'] == USCES_CART_NUMBER) ){ | |
| 387 | - $link = USCES_CART_URL; | |
| 388 | - | |
| 389 | - }elseif( false !== strpos($link, '/usces-member') || (isset( $query['page_id']) && $query['page_id'] == USCES_MEMBER_NUMBER) ){ | |
| 390 | - $link = USCES_MEMBER_URL; | |
| 391 | - | |
| 392 | - }elseif( !empty($this->options['inquiry_id']) && (false !== strpos($link, '/usces-inquiry') || (isset( $query['page_id']) && $query['page_id'] == $this->options['inquiry_id'])) ){ | |
| 393 | - $link = USCES_INQUIRY_URL; | |
| 394 | - | |
| 395 | - }else{ | |
| 396 | - $link = str_replace('https://', 'http://', $link); | |
| 397 | - $link = apply_filters('usces_ssl_page_link', $link); | |
| 398 | - } | |
| 399 | - | |
| 400 | - return $link; | |
| 401 | - } | |
| 402 | - function usces_ssl_contents_link($link) | |
| 403 | - { | |
| 404 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])){ | |
| 405 | - $req = explode('/wp-content/',$link); | |
| 406 | - $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1]; | |
| 407 | - }else{ | |
| 408 | - $link = apply_filters('usces_ssl_contents_link', $link); | |
| 409 | - } | |
| 410 | - return $link; | |
| 411 | - } | |
| 412 | - | |
| 413 | - function ssl_admin_ajax_url(){ | |
| 414 | - $path = '/wp-admin/admin-ajax.php'; | |
| 415 | - if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ){ | |
| 416 | - $link = USCES_SSL_URL_ADMIN . '/wp-admin/admin-ajax.php'; | |
| 417 | - }else{ | |
| 418 | - $link = site_url( $path ); | |
| 419 | - } | |
| 420 | - $link = apply_filters('ssl_admin_ajax_url', $link); | |
| 421 | - return $link; | |
| 422 | - } | |
| 423 | - | |
| 424 | - function usces_ssl_attachment_link($link) | |
| 425 | - { | |
| 426 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 427 | - $link = str_replace(get_option('siteurl'), USCES_SSL_URL_ADMIN, $link); | |
| 428 | - }else{ | |
| 429 | - $link = apply_filters('usces_ssl_attachment_link', $link); | |
| 430 | - } | |
| 431 | - return $link; | |
| 432 | - } | |
| 433 | - | |
| 434 | - function usces_ssl_icon_dir_uri($uri) | |
| 435 | - { | |
| 436 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 437 | - $uri = USCES_SSL_URL_ADMIN. '/' . WPINC . '/images/crystal'; | |
| 438 | - }else{ | |
| 439 | - $link = apply_filters('usces_ssl_icon_dir_uri', $uri); | |
| 440 | - } | |
| 441 | - return $uri; | |
| 442 | - } | |
| 443 | - | |
| 444 | - function usces_ssl_script_link($link) | |
| 445 | - { | |
| 446 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 447 | - if(strpos($link, '/wp-content/') !== false){ | |
| 448 | - $req = explode('/wp-content/',$link, 2); | |
| 449 | - $link = USCES_SSL_URL_ADMIN . '/wp-content/' . $req[1]; | |
| 450 | - }else if(strpos($link, '/wp-includes/') !== false){ | |
| 451 | - $req = explode('/wp-includes/',$link, 2); | |
| 452 | - $link = USCES_SSL_URL_ADMIN . '/wp-includes/' . $req[1]; | |
| 453 | - }else if(strpos($link, '/wp-admin/') !== false){ | |
| 454 | - $req = explode('/wp-admin/',$link, 2); | |
| 455 | - $link = USCES_SSL_URL_ADMIN . '/wp-admin/' . $req[1]; | |
| 456 | - } | |
| 457 | - }else{ | |
| 458 | - $link = apply_filters('usces_ssl_script_link', $link); | |
| 459 | - } | |
| 460 | - return $link; | |
| 461 | - } | |
| 462 | - | |
| 463 | - function set_action_status($status, $message) | |
| 464 | - { | |
| 465 | - $this->action_status = $status; | |
| 466 | - $this->action_message = $message; | |
| 467 | - } | |
| 468 | - | |
| 469 | - | |
| 470 | - /******************************************************************************/ | |
| 471 | - function add_pages() { | |
| 472 | - | |
| 473 | - | |
| 474 | - add_object_page('Welcart Shop', 'Welcart Shop', 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page')); | |
| 475 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Home','usces'), __('Home','usces'), 'level_6', USCES_PLUGIN_BASENAME, array($this, 'admin_top_page')); | |
| 476 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Master Items','usces'), __('Master Items','usces'), 'level_6', 'usces_itemedit', array($this, 'item_master_page')); | |
| 477 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Add New Item','usces'), __('Add New Item','usces'), 'level_6', 'usces_itemnew', array($this, 'item_master_page')); | |
| 478 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('General Setting','usces'), __('General Setting','usces'), 'level_6', 'usces_initial', array($this, 'admin_setup_page')); | |
| 479 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Business Days Setting','usces'), __('Business Days Setting','usces'), 'level_6', 'usces_schedule', array($this, 'admin_schedule_page')); | |
| 480 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Shipping Setting','usces'), __('Shipping Setting','usces'), 'level_6', 'usces_delivery', array($this, 'admin_delivery_page')); | |
| 481 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('E-mail Setting','usces'), __('E-mail Setting','usces'), 'level_6', 'usces_mail', array($this, 'admin_mail_page')); | |
| 482 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Cart Page Setting','usces'), __('Cart Page Setting','usces'), 'level_6', 'usces_cart', array($this, 'admin_cart_page')); | |
| 483 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Member Page Setting','usces'), __('Member Page Setting','usces'), 'level_6', 'usces_member', array($this, 'admin_member_page')); | |
| 484 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('System Setting','usces'), __('System Setting','usces'), 'administrator', 'usces_system', array($this, 'admin_system_page')); | |
| 485 | - add_submenu_page(USCES_PLUGIN_BASENAME, __('Settlement Setting','usces'), __('Settlement Setting','usces'), 'administrator', 'usces_settlement', array($this, 'admin_settlement_page')); | |
| 486 | - //add_submenu_page(USCES_PLUGIN_BASENAME, __('Backup','usces'), __('Backup','usces'), 'level_6', 'usces_backup', array($this, 'admin_backup_page')); | |
| 487 | - do_action('usces_action_shop_admin_menue'); | |
| 488 | - | |
| 489 | - add_object_page('Welcart Management', 'Welcart Management', 'level_6', 'usces_orderlist', array($this, 'order_list_page')); | |
| 490 | - add_submenu_page('usces_orderlist', __('Order List','usces'), __('Order List','usces'), 'level_6', 'usces_orderlist', array($this, 'order_list_page')); | |
| 491 | - add_submenu_page('usces_orderlist', __('New Order or Estimate','usces'), __('New Order or Estimate','usces'), 'level_6', 'usces_ordernew', array($this, 'order_list_page')); | |
| 492 | - add_submenu_page('usces_orderlist', __('List of Members','usces'), __('List of Members','usces'), 'level_6', 'usces_memberlist', array($this, 'member_list_page')); | |
| 493 | - //add_submenu_page('usces_orderlist', __('New Member','usces'), __('New Member','usces'), 'level_6', 'usces_membernew', array($this, 'member_list_page')); | |
| 494 | - do_action('usces_action_management_admin_menue'); | |
| 495 | - } | |
| 496 | - | |
| 497 | - | |
| 498 | - /* Item Master Page */ | |
| 499 | - function item_master_page() { | |
| 500 | - global $wpdb, $wp_locale; | |
| 501 | - global $wp_query; | |
| 502 | - | |
| 503 | - if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) { | |
| 504 | - $this->action_status = 'none'; | |
| 505 | - $this->action_message = ''; | |
| 506 | - } | |
| 507 | - | |
| 508 | - if($_REQUEST['page'] == 'usces_itemnew'){ | |
| 509 | - $action = 'new'; | |
| 510 | - }else{ | |
| 511 | - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; | |
| 512 | - } | |
| 513 | - do_action( 'usces_action_item_master_page', $action ); | |
| 514 | - switch ( $action ) { | |
| 515 | - case 'dlitemlist': | |
| 516 | - usces_download_item_list(); | |
| 517 | - break; | |
| 518 | - case 'upload_register': | |
| 519 | - require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_upload_register.php'); | |
| 520 | - break; | |
| 521 | - case 'delete': | |
| 522 | - case 'new': | |
| 523 | - case 'editpost': | |
| 524 | - case 'edit': | |
| 525 | - global $current_user; | |
| 526 | - require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_edit.php'); | |
| 527 | - break; | |
| 528 | - default: | |
| 529 | - require_once(USCES_PLUGIN_DIR . '/includes/usces_item_master_list.php'); | |
| 530 | - break; | |
| 531 | - } | |
| 532 | - } | |
| 533 | - | |
| 534 | - /* order list page */ | |
| 535 | - function order_list_page() { | |
| 536 | - | |
| 537 | - if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) { | |
| 538 | - $this->action_status = 'none'; | |
| 539 | - $this->action_message = ''; | |
| 540 | - } | |
| 541 | - if($_REQUEST['page'] == 'usces_ordernew'){ | |
| 542 | - $order_action = 'new'; | |
| 543 | - }else{ | |
| 544 | - $order_action = isset($_REQUEST['order_action']) ? $_REQUEST['order_action'] : ''; | |
| 545 | - } | |
| 546 | - do_action('usces_action_order_list_page', $order_action); | |
| 547 | - switch ($order_action) { | |
| 548 | -//20100908ysk start | |
| 549 | - case 'dlproductlist': | |
| 550 | - usces_download_product_list(); | |
| 551 | - break; | |
| 552 | - case 'dlorderlist': | |
| 553 | - usces_download_order_list(); | |
| 554 | - break; | |
| 555 | -//20100908ysk end | |
| 556 | -// case 'printpdf': | |
| 557 | -// require_once(USCES_PLUGIN_DIR . '/includes/order_print.php'); | |
| 558 | -// break; | |
| 559 | - case 'editpost': | |
| 560 | - do_action('usces_pre_update_orderdata', $_REQUEST['order_id']); | |
| 561 | - $res = usces_update_orderdata(); | |
| 562 | - if ( 1 === $res ) { | |
| 563 | - $this->set_action_status('success', __('order date is updated','usces').' <a href="'.stripslashes( $_POST['usces_referer'] ).'">'.__('back to the summary','usces').'</a>'); | |
| 564 | - } elseif ( 0 === $res ) { | |
| 565 | - $this->set_action_status('none', ''); | |
| 566 | - } else { | |
| 567 | - $this->set_action_status('error', 'ERROR : '.__('failure in update','usces')); | |
| 568 | - } | |
| 569 | - do_action('usces_after_update_orderdata', $_REQUEST['order_id'], $res); | |
| 570 | - require_once(USCES_PLUGIN_DIR . '/includes/order_edit_form.php'); | |
| 571 | - break; | |
| 572 | - case 'newpost': | |
| 573 | - do_action('usces_pre_new_orderdata'); | |
| 574 | - $res = usces_new_orderdata(); | |
| 575 | - if ( 1 === $res ) { | |
| 576 | - $this->set_action_status('success', __('New date is add','usces')); | |
| 577 | - } elseif ( 0 === $res ) { | |
| 578 | - $this->set_action_status('none', ''); | |
| 579 | - } else { | |
| 580 | - $this->set_action_status('error', 'ERROR : '.__('failure in addition','usces')); | |
| 581 | - } | |
| 582 | - do_action('usces_after_new_orderdata', $res); | |
| 583 | - $_REQUEST['order_action'] = 'edit'; | |
| 584 | - $order_action = $_REQUEST['order_action']; | |
| 585 | - require_once(USCES_PLUGIN_DIR . '/includes/order_edit_form.php'); | |
| 586 | - break; | |
| 587 | - case 'new': | |
| 588 | - case 'edit': | |
| 589 | - require_once(USCES_PLUGIN_DIR . '/includes/order_edit_form.php'); | |
| 590 | - break; | |
| 591 | - case 'delete': | |
| 592 | - do_action('usces_pre_delete_orderdata', $_REQUEST['order_id']); | |
| 593 | - $res = usces_delete_orderdata(); | |
| 594 | - if ( 1 === $res ) { | |
| 595 | - $this->set_action_status('success', __('the order date is deleted','usces')); | |
| 596 | - } elseif ( 0 === $res ) { | |
| 597 | - $this->set_action_status('none', ''); | |
| 598 | - } else { | |
| 599 | - $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces')); | |
| 600 | - } | |
| 601 | - do_action('usces_after_delete_orderdata', $_REQUEST['order_id'], $res); | |
| 602 | - default: | |
| 603 | - require_once(USCES_PLUGIN_DIR . '/includes/order_list.php'); | |
| 604 | - } | |
| 605 | - } | |
| 606 | - | |
| 607 | - /* member list page */ | |
| 608 | - function member_list_page() { | |
| 609 | - | |
| 610 | - if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) { | |
| 611 | - $this->action_status = 'none'; | |
| 612 | - $this->action_message = ''; | |
| 613 | - } | |
| 614 | - $member_action = isset($_REQUEST['member_action']) ? $_REQUEST['member_action'] : ''; | |
| 615 | - switch ($member_action) { | |
| 616 | -//20100908ysk start | |
| 617 | - case 'dlmemberlist': | |
| 618 | - usces_download_member_list(); | |
| 619 | - break; | |
| 620 | -//20100908ysk end | |
| 621 | - case 'editpost': | |
| 622 | - $this->error_message = $this->admin_member_check(); | |
| 623 | - if( WCUtils::is_blank($this->error_message) ){ | |
| 624 | - $res = usces_update_memberdata(); | |
| 625 | - if ( 1 === $res ) { | |
| 626 | - $this->set_action_status('success', __('Membership information is updated','usces')); | |
| 627 | - } elseif ( 0 === $res ) { | |
| 628 | - $this->set_action_status('none', ''); | |
| 629 | - } else { | |
| 630 | - $this->set_action_status('error', 'ERROR : '.__('failure in update','usces')); | |
| 631 | - } | |
| 632 | - } | |
| 633 | - require_once(USCES_PLUGIN_DIR . '/includes/member_edit_form.php'); | |
| 634 | - break; | |
| 635 | - case 'new': | |
| 636 | - case 'edit': | |
| 637 | - require_once(USCES_PLUGIN_DIR . '/includes/member_edit_form.php'); | |
| 638 | - break; | |
| 639 | - case 'delete': | |
| 640 | - $res = usces_delete_memberdata(); | |
| 641 | - if ( 1 === $res ) { | |
| 642 | - $this->set_action_status('success', __('The member data is deleted','usces')); | |
| 643 | - } elseif ( 0 === $res ) { | |
| 644 | - $this->set_action_status('none', ''); | |
| 645 | - } else { | |
| 646 | - $this->set_action_status('error', 'ERROR : '.__('failure in delete','usces')); | |
| 647 | - } | |
| 648 | - default: | |
| 649 | - require_once(USCES_PLUGIN_DIR . '/includes/member_list.php'); | |
| 650 | - } | |
| 651 | - | |
| 652 | - } | |
| 653 | - | |
| 654 | - /* admin backup page */ | |
| 655 | - function admin_backup_page() { | |
| 656 | - | |
| 657 | - if(empty($this->action_message) || WCUtils::is_blank($this->action_message) ) { | |
| 658 | - $this->action_status = 'none'; | |
| 659 | - $this->action_message = ''; | |
| 660 | - } | |
| 661 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php'); | |
| 662 | - | |
| 663 | - } | |
| 664 | - | |
| 665 | - /* Shop Top Page */ | |
| 666 | - function admin_top_page() { | |
| 667 | - | |
| 668 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_top.php'); | |
| 669 | - | |
| 670 | - } | |
| 671 | - | |
| 672 | - /* Shop Setup Page */ | |
| 673 | - function admin_setup_page() { | |
| 674 | - $this->options = get_option('usces'); | |
| 675 | - //$this->options = array(); | |
| 676 | - | |
| 677 | - | |
| 678 | - if(isset($_POST['usces_option_update'])) { | |
| 679 | - | |
| 680 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 681 | - $this->options['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : ''; | |
| 682 | - $this->options['campaign_category'] = empty($_POST['cat']) ? USCES_ITEM_CAT_PARENT_ID : $_POST['cat']; | |
| 683 | - $this->options['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : ''; | |
| 684 | - $this->options['privilege_point'] = isset($_POST['point_num']) ? (int)$_POST['point_num'] : ''; | |
| 685 | - $this->options['privilege_discount'] = isset($_POST['discount_num']) ? (int)$_POST['discount_num'] : ''; | |
| 686 | - $this->options['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : ''; | |
| 687 | - $this->options['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : ''; | |
| 688 | - $this->options['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : ''; | |
| 689 | - $this->options['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : ''; | |
| 690 | - $this->options['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : ''; | |
| 691 | - $this->options['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : ''; | |
| 692 | - $this->options['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : ''; | |
| 693 | - $this->options['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : ''; | |
| 694 | - $this->options['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : ''; | |
| 695 | - $this->options['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : ''; | |
| 696 | - $this->options['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : ''; | |
| 697 | - $this->options['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : ''; | |
| 698 | - $this->options['point_rate'] = isset($_POST['point_rate']) ? (int)$_POST['point_rate'] : ''; | |
| 699 | - $this->options['start_point'] = isset($_POST['start_point']) ? (int)$_POST['start_point'] : ''; | |
| 700 | - $this->options['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : ''; | |
| 701 | - $this->options['tax_rate'] = isset($_POST['tax_rate']) ? (int)$_POST['tax_rate'] : ''; | |
| 702 | - $this->options['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : ''; | |
| 703 | - $this->options['cod_type'] = isset($this->options['cod_type']) ? $this->options['cod_type'] : 'fix'; | |
| 704 | - $this->options['transferee'] = isset($_POST['transferee']) ? trim($_POST['transferee']) : ''; | |
| 705 | - $this->options['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : ''; | |
| 706 | - $this->options['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : ''; | |
| 707 | - $this->options['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : ''; | |
| 708 | - $this->options['point_coverage'] = isset($_POST['point_coverage']) ? (int)$_POST['point_coverage'] : 0; | |
| 709 | - $this->options['point_assign'] = isset($_POST['point_assign']) ? (int)$_POST['point_assign'] : 1;//20120919ysk 0000573 | |
| 710 | - | |
| 711 | - $this->options = apply_filters( 'usces_filter_admin_setup_options', $this->options ); | |
| 712 | - | |
| 713 | - update_option('usces', $this->options); | |
| 714 | - | |
| 715 | - $this->action_status = 'success'; | |
| 716 | - $this->action_message = __('options are updated','usces'); | |
| 717 | - | |
| 718 | - } else { | |
| 719 | - $this->action_status = 'none'; | |
| 720 | - $this->action_message = ''; | |
| 721 | - } | |
| 722 | - | |
| 723 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_setup.php'); | |
| 724 | - | |
| 725 | - } | |
| 726 | - | |
| 727 | - /* Shop Schedule Page */ | |
| 728 | - function admin_schedule_page() { | |
| 729 | - | |
| 730 | - $this->options = get_option('usces'); | |
| 731 | - | |
| 732 | - if(isset($_POST['usces_option_update'])) { | |
| 733 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 734 | - | |
| 735 | - $this->options['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0'; | |
| 736 | - if(isset($_POST['business_days'])) $this->options['business_days'] = $_POST['business_days']; | |
| 737 | - | |
| 738 | - | |
| 739 | - | |
| 740 | - update_option('usces', $this->options); | |
| 741 | - | |
| 742 | - $this->action_status = 'success'; | |
| 743 | - $this->action_message = __('options are updated','usces'); | |
| 744 | - } else { | |
| 745 | - $this->action_status = 'none'; | |
| 746 | - $this->action_message = ''; | |
| 747 | - } | |
| 748 | - | |
| 749 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_schedule.php'); | |
| 750 | - | |
| 751 | - } | |
| 752 | - | |
| 753 | - /* Shop Delivery Page */ | |
| 754 | - function admin_delivery_page() { | |
| 755 | - | |
| 756 | - $this->options = get_option('usces'); | |
| 757 | - | |
| 758 | - if(isset($_POST['usces_option_update'])) { | |
| 759 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 760 | - | |
| 761 | -//20101208ysk start | |
| 762 | - if(isset($_POST['delivery_time_limit'])) $this->options['delivery_time_limit'] = $_POST['delivery_time_limit']; | |
| 763 | - if(isset($_POST['shortest_delivery_time'])) $this->options['shortest_delivery_time'] = $_POST['shortest_delivery_time']; | |
| 764 | - if(isset($_POST['delivery_after_days'])) $this->options['delivery_after_days'] = $_POST['delivery_after_days']; | |
| 765 | -//20101208ysk end | |
| 766 | - | |
| 767 | - update_option('usces', $this->options); | |
| 768 | - | |
| 769 | - $this->action_status = 'success'; | |
| 770 | - $this->action_message = __('options are updated','usces'); | |
| 771 | - } else { | |
| 772 | - $this->action_status = 'none'; | |
| 773 | - $this->action_message = ''; | |
| 774 | - } | |
| 775 | - | |
| 776 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_delivery.php'); | |
| 777 | - | |
| 778 | - } | |
| 779 | - | |
| 780 | - /* Shop Mail Page */ | |
| 781 | - function admin_mail_page() { | |
| 782 | - global $allowedposttags; | |
| 783 | - | |
| 784 | - $this->options = get_option('usces'); | |
| 785 | - | |
| 786 | - if(isset($_POST['usces_option_update'])) { | |
| 787 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 788 | - | |
| 789 | - $this->options['smtp_hostname'] = trim($_POST['smtp_hostname']); | |
| 790 | - $this->options['newmem_admin_mail'] = (int)$_POST['newmem_admin_mail']; | |
| 791 | - | |
| 792 | - foreach ( $_POST['title'] as $key => $value ) { | |
| 793 | - if( WCUtils::is_blank($value) ) { | |
| 794 | - $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key]; | |
| 795 | - }else{ | |
| 796 | - $this->options['mail_data']['title'][$key] = trim($value); | |
| 797 | - } | |
| 798 | - } | |
| 799 | - foreach ( $_POST['header'] as $key => $value ) { | |
| 800 | - if( WCUtils::is_blank($value) ) { | |
| 801 | - $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key]; | |
| 802 | - }else{ | |
| 803 | - $this->options['mail_data']['header'][$key] = $value; | |
| 804 | - } | |
| 805 | - } | |
| 806 | - foreach ( $_POST['footer'] as $key => $value ) { | |
| 807 | - if( WCUtils::is_blank($value) ) { | |
| 808 | - $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key]; | |
| 809 | - }else{ | |
| 810 | - $this->options['mail_data']['footer'][$key] = $value; | |
| 811 | - } | |
| 812 | - } | |
| 813 | - | |
| 814 | - | |
| 815 | - $this->action_status = 'success'; | |
| 816 | - $this->action_message = __('options are updated','usces'); | |
| 817 | - | |
| 818 | - } else { | |
| 819 | - | |
| 820 | - foreach ( (array)$this->options['mail_data']['title'] as $key => $value ) { | |
| 821 | - if( WCUtils::is_blank($value) ) { | |
| 822 | - $this->options['mail_data']['title'][$key] = $this->options['mail_default']['title'][$key]; | |
| 823 | - } | |
| 824 | - } | |
| 825 | - foreach ( (array)$this->options['mail_data']['header'] as $key => $value ) { | |
| 826 | - if( WCUtils::is_blank($value) ) { | |
| 827 | - $this->options['mail_data']['header'][$key] = $this->options['mail_default']['header'][$key]; | |
| 828 | - } | |
| 829 | - } | |
| 830 | - foreach ( (array)$this->options['mail_data']['footer'] as $key => $value ) { | |
| 831 | - if( WCUtils::is_blank($value) ) { | |
| 832 | - $this->options['mail_data']['footer'][$key] = $this->options['mail_default']['footer'][$key]; | |
| 833 | - } | |
| 834 | - } | |
| 835 | - | |
| 836 | - $this->action_status = 'none'; | |
| 837 | - $this->action_message = ''; | |
| 838 | - | |
| 839 | - } | |
| 840 | - | |
| 841 | - update_option('usces', $this->options); | |
| 842 | - do_action( 'usces_action_admin_mail_page' ); | |
| 843 | - | |
| 844 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_mail.php'); | |
| 845 | - | |
| 846 | - } | |
| 847 | - | |
| 848 | - /* Admin Cart Page */ | |
| 849 | - function admin_cart_page() { | |
| 850 | - global $allowedposttags; | |
| 851 | - $this->options = get_option('usces'); | |
| 852 | - | |
| 853 | - if(isset($_POST['usces_option_update'])) { | |
| 854 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 855 | - | |
| 856 | - foreach ( $this->options['indi_item_name'] as $key => $value ) { | |
| 857 | - $this->options['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0; | |
| 858 | - } | |
| 859 | - foreach ( $_POST['position'] as $key => $value ) { | |
| 860 | - $this->options['pos_item_name'][$key] = $value; | |
| 861 | - } | |
| 862 | - foreach ( $_POST['header'] as $key => $value ) { | |
| 863 | - $this->options['cart_page_data']['header'][$key] = addslashes(wp_kses($value, $allowedposttags)); | |
| 864 | - } | |
| 865 | - foreach ( $_POST['footer'] as $key => $value ) { | |
| 866 | - $this->options['cart_page_data']['footer'][$key] = addslashes(wp_kses($value, $allowedposttags)); | |
| 867 | - } | |
| 868 | - | |
| 869 | - update_option('usces', $this->options); | |
| 870 | - | |
| 871 | - $this->action_status = 'success'; | |
| 872 | - $this->action_message = __('options are updated','usces'); | |
| 873 | - } else { | |
| 874 | - | |
| 875 | - $this->action_status = 'none'; | |
| 876 | - $this->action_message = ''; | |
| 877 | - } | |
| 878 | - | |
| 879 | - | |
| 880 | - | |
| 881 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_cart.php'); | |
| 882 | - | |
| 883 | - } | |
| 884 | - | |
| 885 | - /* Admin Member Page */ | |
| 886 | - function admin_member_page() { | |
| 887 | - | |
| 888 | - $this->options = get_option('usces'); | |
| 889 | - | |
| 890 | - if(isset($_POST['usces_option_update'])) { | |
| 891 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 892 | - | |
| 893 | - foreach ( $_POST['header'] as $key => $value ) { | |
| 894 | - $this->options['member_page_data']['header'][$key] = $value; | |
| 895 | - } | |
| 896 | - foreach ( $_POST['footer'] as $key => $value ) { | |
| 897 | - $this->options['member_page_data']['footer'][$key] = $value; | |
| 898 | - } | |
| 899 | - | |
| 900 | - update_option('usces', $this->options); | |
| 901 | - | |
| 902 | - $this->action_status = 'success'; | |
| 903 | - $this->action_message = __('options are updated','usces'); | |
| 904 | - } else { | |
| 905 | - | |
| 906 | - $this->action_status = 'none'; | |
| 907 | - $this->action_message = ''; | |
| 908 | - } | |
| 909 | - | |
| 910 | - | |
| 911 | - | |
| 912 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_member.php'); | |
| 913 | - | |
| 914 | - } | |
| 915 | - | |
| 916 | - | |
| 917 | - /* Admin System Page */ | |
| 918 | - function admin_system_page() { | |
| 919 | -//20110331ysk start | |
| 920 | - global $usces_states; | |
| 921 | -//20110331ysk end | |
| 922 | - $action_status = '';//20120511ysk 0000470 | |
| 923 | - | |
| 924 | - $this->options = get_option('usces'); | |
| 925 | - | |
| 926 | - if(isset($_POST['usces_option_update'])) { | |
| 927 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 928 | - | |
| 929 | -//20110331ysk start | |
| 930 | -/* if($_POST['province'] != ''){ | |
| 931 | - $temp_pref = explode("\n", $_POST['province']); | |
| 932 | - for($i=-1; $i<count($temp_pref); $i++){ | |
| 933 | - if($i == -1){ | |
| 934 | - $usces_pref[] = __('-- Select --','usces'); | |
| 935 | - }else{ | |
| 936 | - $usces_pref[] = trim($temp_pref[$i]); | |
| 937 | - } | |
| 938 | - } | |
| 939 | - }else{ | |
| 940 | - $usces_pref = get_option('usces_pref'); | |
| 941 | - } | |
| 942 | - | |
| 943 | - $this->options['province'] = $usces_pref;*/ | |
| 944 | -//20110331ysk end | |
| 945 | - $this->options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0; | |
| 946 | - $this->options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : ''; | |
| 947 | - $this->options['fukugo_category_orderby'] = isset($_POST['fukugo_category_orderby']) ? $_POST['fukugo_category_orderby'] : ''; | |
| 948 | - $this->options['fukugo_category_order'] = isset($_POST['fukugo_category_order']) ? $_POST['fukugo_category_order'] : ''; | |
| 949 | - $this->options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : ''; | |
| 950 | - if( WCUtils::is_blank($this->options['settlement_path']) ) $this->options['settlement_path'] = USCES_PLUGIN_DIR . '/settlement/'; | |
| 951 | - $sl = substr($this->options['settlement_path'], -1); | |
| 952 | - if($sl != '/' && $sl != '\\') $this->options['settlement_path'] .= '/'; | |
| 953 | - $this->options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0; | |
| 954 | - $this->options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : ''; | |
| 955 | - $this->options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : ''; | |
| 956 | - if( WCUtils::is_blank($this->options['ssl_url']) || WCUtils::is_blank($this->options['ssl_url_admin']) ) $this->options['use_ssl'] = 0; | |
| 957 | - $this->options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : ''; | |
| 958 | - $this->options['use_javascript'] = isset($_POST['use_javascript']) ? (int)$_POST['use_javascript'] : 1; | |
| 959 | - $this->options['system']['front_lang'] = (isset($_POST['front_lang']) && 'others' != $_POST['front_lang']) ? $_POST['front_lang'] : usces_get_local_language(); | |
| 960 | - $this->options['system']['currency'] = (isset($_POST['currency']) && 'others' != $_POST['currency']) ? $_POST['currency'] : usces_get_base_country(); | |
| 961 | - $this->options['system']['addressform'] = (isset($_POST['addressform']) ) ? $_POST['addressform'] : usces_get_local_addressform(); | |
| 962 | - $this->options['system']['target_market'] = (isset($_POST['target_market']) ) ? $_POST['target_market'] : usces_get_local_target_market(); | |
| 963 | - $this->options['system']['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0; | |
| 964 | - $this->options['system']['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int)$_POST['dec_orderID_flag'] : 0; | |
| 965 | - $this->options['system']['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : ''; | |
| 966 | - if( isset($_POST['dec_orderID_digit']) ){ | |
| 967 | - $dec_orderID_digit = (int)rtrim($_POST['dec_orderID_digit']); | |
| 968 | - if( 6 > $dec_orderID_digit ){ | |
| 969 | - $this->options['system']['dec_orderID_digit'] = 6; | |
| 970 | - }else{ | |
| 971 | - $this->options['system']['dec_orderID_digit'] = $dec_orderID_digit; | |
| 972 | - } | |
| 973 | - }else{ | |
| 974 | - $this->options['system']['dec_orderID_digit'] = 6; | |
| 975 | - } | |
| 976 | - $this->options['system']['subimage_rule'] = isset($_POST['subimage_rule']) ? (int)$_POST['subimage_rule'] : 0; | |
| 977 | -//20110331ysk start | |
| 978 | - unset($this->options['province']); | |
| 979 | - //$action_status = '';//20120511ysk 0000470 | |
| 980 | - foreach((array)$this->options['system']['target_market'] as $target_market) { | |
| 981 | - $province = array(); | |
| 982 | - if(!empty($_POST['province_'.$target_market])) { | |
| 983 | - $temp_pref = explode("\n", $_POST['province_'.$target_market]); | |
| 984 | -//20120123ysk start 0000386 | |
| 985 | - //$province[] = __('-- Select --', 'usces'); | |
| 986 | - $province[] = '-- Select --'; | |
| 987 | -//20120123ysk end | |
| 988 | -//20120725ysk start 0000537 | |
| 989 | - //for($i = 0; $i < count($temp_pref); $i++) { | |
| 990 | - //$province[] = trim($temp_pref[$i]); | |
| 991 | - foreach( $temp_pref as $pref ) { | |
| 992 | - if( !WCUtils::is_blank($pref) ) | |
| 993 | - $province[] = trim($pref); | |
| 994 | - } | |
| 995 | - if( 1 == count($province) ) | |
| 996 | - $action_status = 'error'; | |
| 997 | -//20120725ysk end | |
| 998 | - } else { | |
| 999 | - if(isset($usces_states[$target_market]) && is_array($usces_states[$target_market])) { | |
| 1000 | - $province = $usces_states[$target_market]; | |
| 1001 | - } else { | |
| 1002 | - $action_status = 'error'; | |
| 1003 | - } | |
| 1004 | - } | |
| 1005 | - $this->options['province'][$target_market] = $province; | |
| 1006 | - } | |
| 1007 | - | |
| 1008 | - if($action_status != '') { | |
| 1009 | - $this->action_status = 'error'; | |
| 1010 | - $this->action_message = __('Data have deficiency.','usces'); | |
| 1011 | - } else { | |
| 1012 | - $this->action_status = 'success'; | |
| 1013 | - $this->action_message = __('options are updated','usces'); | |
| 1014 | - } | |
| 1015 | -//20110331ysk end | |
| 1016 | - } else { | |
| 1017 | - | |
| 1018 | - if( !isset($this->options['province']) || !empty($this->options['province']) ){ | |
| 1019 | -//20110331ysk start | |
| 1020 | - //$this->options['province'] = get_option('usces_pref'); | |
| 1021 | - $this->options['province'][$this->options['system']['base_country']] = $usces_states[$this->options['system']['base_country']]; | |
| 1022 | -//20110331ysk end | |
| 1023 | - } | |
| 1024 | - $this->action_status = 'none'; | |
| 1025 | - $this->action_message = ''; | |
| 1026 | - } | |
| 1027 | - | |
| 1028 | - if($action_status != 'error') //20120511ysk 0000470 | |
| 1029 | - update_option('usces', $this->options); | |
| 1030 | - | |
| 1031 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_system.php'); | |
| 1032 | - | |
| 1033 | - } | |
| 1034 | - | |
| 1035 | - /* Settlement Setting Page */ | |
| 1036 | - function admin_settlement_page() { | |
| 1037 | - | |
| 1038 | - $this->action_status = 'none'; | |
| 1039 | - $this->action_message = ''; | |
| 1040 | - | |
| 1041 | - $options = get_option('usces'); | |
| 1042 | - | |
| 1043 | - | |
| 1044 | - if( isset($_POST['usces_option_update']) ) { | |
| 1045 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 1046 | - $mes = ''; | |
| 1047 | - | |
| 1048 | - switch( $_POST['acting'] ){ | |
| 1049 | - case 'zeus': | |
| 1050 | - unset( $options['acting_settings']['zeus'] ); | |
| 1051 | - $options['acting_settings']['zeus']['card_url'] = isset($_POST['card_url']) ? $_POST['card_url'] : ''; | |
| 1052 | - $options['acting_settings']['zeus']['card_secureurl'] = isset($_POST['card_secureurl']) ? $_POST['card_secureurl'] : ''; | |
| 1053 | - $options['acting_settings']['zeus']['ipaddrs'] = isset($_POST['ipaddrs']) ? $_POST['ipaddrs'] : ''; | |
| 1054 | - $options['acting_settings']['zeus']['pay_cvs'] = isset($_POST['pay_cvs']) ? $_POST['pay_cvs'] : ''; | |
| 1055 | - $options['acting_settings']['zeus']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1056 | - $options['acting_settings']['zeus']['connection'] = isset($_POST['connection']) ? $_POST['connection'] : 1; | |
| 1057 | - $options['acting_settings']['zeus']['3dsecur'] = isset($_POST['3dsecur']) ? $_POST['3dsecur'] : 2; | |
| 1058 | - $options['acting_settings']['zeus']['security'] = isset($_POST['security']) ? $_POST['security'] : 2; | |
| 1059 | - if( isset($_POST['authkey']) ){ | |
| 1060 | - $options['acting_settings']['zeus']['authkey'] = $_POST['authkey']; | |
| 1061 | - } | |
| 1062 | - if( 1 == $options['acting_settings']['zeus']['security'] ){ | |
| 1063 | - $options['acting_settings']['zeus']['quickcharge'] = '2'; | |
| 1064 | - }else{ | |
| 1065 | - $options['acting_settings']['zeus']['quickcharge'] = isset($_POST['quickcharge']) ? $_POST['quickcharge'] : ''; | |
| 1066 | - } | |
| 1067 | - $options['acting_settings']['zeus']['batch'] = isset($_POST['batch']) ? $_POST['batch'] : ''; | |
| 1068 | - $options['acting_settings']['zeus']['clientip'] = isset($_POST['clientip']) ? trim($_POST['clientip']) : ''; | |
| 1069 | - $options['acting_settings']['zeus']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : ''; | |
| 1070 | - $options['acting_settings']['zeus']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : ''; | |
| 1071 | - $options['acting_settings']['zeus']['clientip_bank'] = isset($_POST['clientip_bank']) ? trim($_POST['clientip_bank']) : ''; | |
| 1072 | - $options['acting_settings']['zeus']['testid_bank'] = isset($_POST['testid_bank']) ? trim($_POST['testid_bank']) : ''; | |
| 1073 | - $options['acting_settings']['zeus']['bank_url'] = isset($_POST['bank_url']) ? $_POST['bank_url'] : ''; | |
| 1074 | - $options['acting_settings']['zeus']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : ''; | |
| 1075 | - $options['acting_settings']['zeus']['clientip_conv'] = isset($_POST['clientip_conv']) ? trim($_POST['clientip_conv']) : ''; | |
| 1076 | - $options['acting_settings']['zeus']['testid_conv'] = isset($_POST['testid_conv']) ? trim($_POST['testid_conv']) : ''; | |
| 1077 | - $options['acting_settings']['zeus']['test_type_conv'] = ( (isset($_POST['testid_conv']) && WCUtils::is_blank($_POST['testid_conv'])) || !isset($_POST['test_type']) ) ? 0 : $_POST['test_type']; | |
| 1078 | - $options['acting_settings']['zeus']['conv_url'] = isset($_POST['conv_url']) ? $_POST['conv_url'] : ''; | |
| 1079 | - | |
| 1080 | - if( WCUtils::is_blank($_POST['clientip']) && isset($_POST['card_activate']) && 'on' == $_POST['card_activate']) | |
| 1081 | - $mes .= '※カード決済IPコードを入力して下さい<br />'; | |
| 1082 | - if( isset($_POST['authkey']) && WCUtils::is_blank($_POST['authkey']) && isset($_POST['security']) && 3 == $_POST['security']) | |
| 1083 | - $mes .= '※認証キーを入力して下さい<br />'; | |
| 1084 | - if( WCUtils::is_blank($_POST['clientip_bank']) && isset($_POST['bank_activate']) && 'on' == $_POST['bank_activate'] ) | |
| 1085 | - $mes .= '※入金お任せIPコードを入力して下さい<br />'; | |
| 1086 | - if( WCUtils::is_blank($_POST['clientip_conv']) && isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] ) | |
| 1087 | - $mes .= '※コンビニ決済IPコードを入力して下さい<br />'; | |
| 1088 | - if( isset($_POST['batch']) && 'on' == $_POST['batch'] ) { | |
| 1089 | - if( isset($_POST['quickcharge']) && 'on' == $_POST['quickcharge'] ) { | |
| 1090 | - } else { | |
| 1091 | - $mes .= '※バッチ処理を利用する場合は、クイックチャージを利用するにして下さい<br />'; | |
| 1092 | - } | |
| 1093 | - } | |
| 1094 | - if( !isset($_POST['card_url']) || empty($_POST['card_url']) || !isset($_POST['ipaddrs']) || empty($_POST['ipaddrs']) || !isset($_POST['bank_url']) || empty($_POST['bank_url']) || !isset($_POST['conv_url']) || empty($_POST['conv_url']) ) | |
| 1095 | - $mes .= '※設定が不正です!<br />'; | |
| 1096 | - | |
| 1097 | - if( WCUtils::is_blank($mes) ){ | |
| 1098 | - $this->action_status = 'success'; | |
| 1099 | - $this->action_message = __('options are updated','usces'); | |
| 1100 | - $options['acting_settings']['zeus']['activate'] = 'on'; | |
| 1101 | - if( 'on' == $options['acting_settings']['zeus']['card_activate'] ){ | |
| 1102 | - $this->payment_structure['acting_zeus_card'] = 'カード決済(ZEUS)'; | |
| 1103 | - }else{ | |
| 1104 | - unset($this->payment_structure['acting_zeus_card']); | |
| 1105 | - } | |
| 1106 | - if( 'on' == $options['acting_settings']['zeus']['bank_activate'] ){ | |
| 1107 | - $this->payment_structure['acting_zeus_bank'] = '入金お任せ(ZEUS)'; | |
| 1108 | - }else{ | |
| 1109 | - unset($this->payment_structure['acting_zeus_bank']); | |
| 1110 | - } | |
| 1111 | - if( 'on' == $options['acting_settings']['zeus']['conv_activate'] ){ | |
| 1112 | - $this->payment_structure['acting_zeus_conv'] = 'コンビニ決済(ZEUS)'; | |
| 1113 | - }else{ | |
| 1114 | - unset($this->payment_structure['acting_zeus_conv']); | |
| 1115 | - } | |
| 1116 | - }else{ | |
| 1117 | - $this->action_status = 'error'; | |
| 1118 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1119 | - $options['acting_settings']['zeus']['activate'] = 'off'; | |
| 1120 | - unset($this->payment_structure['acting_zeus_card'], $this->payment_structure['acting_zeus_bank'], $this->payment_structure['acting_zeus_conv']); | |
| 1121 | - } | |
| 1122 | - ksort($this->payment_structure); | |
| 1123 | - update_option('usces_payment_structure',$this->payment_structure); | |
| 1124 | - $options['acting_settings']['zeus']['vercheck'] = '115'; | |
| 1125 | - if( update_option('usces', $options) ){ | |
| 1126 | - usces_clear_quickcharge(); | |
| 1127 | - } | |
| 1128 | - break; | |
| 1129 | - | |
| 1130 | - case 'remise': | |
| 1131 | - unset( $options['acting_settings']['remise'] ); | |
| 1132 | - $options['acting_settings']['remise']['plan'] = isset($_POST['plan']) ? $_POST['plan'] : ''; | |
| 1133 | - $options['acting_settings']['remise']['SHOPCO'] = isset($_POST['SHOPCO']) ? $_POST['SHOPCO'] : ''; | |
| 1134 | - $options['acting_settings']['remise']['HOSTID'] = isset($_POST['HOSTID']) ? $_POST['HOSTID'] : ''; | |
| 1135 | - $options['acting_settings']['remise']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1136 | - $options['acting_settings']['remise']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : ''; | |
| 1137 | - $options['acting_settings']['remise']['card_pc_ope'] = isset($_POST['card_pc_ope']) ? $_POST['card_pc_ope'] : ''; | |
| 1138 | - $options['acting_settings']['remise']['payquick'] = isset($_POST['payquick']) ? $_POST['payquick'] : ''; | |
| 1139 | - $options['acting_settings']['remise']['howpay'] = isset($_POST['howpay']) ? $_POST['howpay'] : ''; | |
| 1140 | - $options['acting_settings']['remise']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : ''; | |
| 1141 | - $options['acting_settings']['remise']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : ''; | |
| 1142 | - $options['acting_settings']['remise']['conv_pc_ope'] = isset($_POST['conv_pc_ope']) ? $_POST['conv_pc_ope'] : ''; | |
| 1143 | - $options['acting_settings']['remise']['S_PAYDATE'] = isset($_POST['S_PAYDATE']) ? $_POST['S_PAYDATE'] : ''; | |
| 1144 | - $options['acting_settings']['remise']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : ''; | |
| 1145 | - $options['acting_settings']['remise']['send_url_pc'] = isset($_POST['send_url_pc']) ? $_POST['send_url_pc'] : ''; | |
| 1146 | - $options['acting_settings']['remise']['send_url_cvs_mbl'] = isset($_POST['send_url_cvs_mbl']) ? $_POST['send_url_cvs_mbl'] : ''; | |
| 1147 | - $options['acting_settings']['remise']['send_url_cvs_pc'] = isset($_POST['send_url_cvs_pc']) ? $_POST['send_url_cvs_pc'] : ''; | |
| 1148 | - $options['acting_settings']['remise']['send_url_mbl_test'] = isset($_POST['send_url_mbl_test']) ? $_POST['send_url_mbl_test'] : ''; | |
| 1149 | - $options['acting_settings']['remise']['send_url_pc_test'] = isset($_POST['send_url_pc_test']) ? $_POST['send_url_pc_test'] : ''; | |
| 1150 | - $options['acting_settings']['remise']['send_url_cvs_mbl_test'] = isset($_POST['send_url_cvs_mbl_test']) ? $_POST['send_url_cvs_mbl_test'] : ''; | |
| 1151 | - $options['acting_settings']['remise']['send_url_cvs_pc_test'] = isset($_POST['send_url_cvs_pc_test']) ? $_POST['send_url_cvs_pc_test'] : ''; | |
| 1152 | - $options['acting_settings']['remise']['REMARKS3'] = isset($_POST['REMARKS3']) ? $_POST['REMARKS3'] : ''; | |
| 1153 | - | |
| 1154 | - if( isset($_POST['plan_remise']) && WCUtils::is_zero($_POST['plan_remise']) ) | |
| 1155 | - $mes .= '※サービスプランを選択してください<br />'; | |
| 1156 | - if( WCUtils::is_blank($_POST['SHOPCO']) ) | |
| 1157 | - $mes .= '※加盟店コードを入力して下さい<br />'; | |
| 1158 | - if( WCUtils::is_blank($_POST['HOSTID']) ) | |
| 1159 | - $mes .= '※ホスト番号を入力して下さい<br />'; | |
| 1160 | - if( isset($_POST['conv_activate']) && 'on' == $_POST['conv_activate'] && empty($_POST['S_PAYDATE']) ) | |
| 1161 | - $mes .= '※支払期限を入力して下さい<br />'; | |
| 1162 | - if( isset($_POST['card_pc_ope']) && 'public' == $_POST['card_pc_ope'] && empty($_POST['send_url_pc']) ) | |
| 1163 | - $mes .= '※クレジットカード決済の本番URLを入力して下さい<br />'; | |
| 1164 | - if( isset($_POST['conv_pc_ope']) && 'public' == $_POST['conv_pc_ope'] && empty($_POST['send_url_cvs_pc']) ) | |
| 1165 | - $mes .= '※コンビニ・電子マネー決済の本番URLを入力して下さい<br />'; | |
| 1166 | - if( !isset($_POST['REMARKS3']) || empty($_POST['REMARKS3']) ) | |
| 1167 | - $mes .= '※設定が不正です!<br />'; | |
| 1168 | - | |
| 1169 | - if( WCUtils::is_blank($mes) ){ | |
| 1170 | - //$this->zaction_status = 'success'; | |
| 1171 | - $this->action_status = 'success'; | |
| 1172 | - $this->action_message = __('options are updated','usces'); | |
| 1173 | - $options['acting_settings']['remise']['activate'] = 'on'; | |
| 1174 | - if( 'on' == $options['acting_settings']['remise']['card_activate'] ){ | |
| 1175 | - $this->payment_structure['acting_remise_card'] = 'カード決済(ルミーズ)'; | |
| 1176 | - }else{ | |
| 1177 | - unset($this->payment_structure['acting_remise_card']); | |
| 1178 | - } | |
| 1179 | - if( 'on' == $options['acting_settings']['remise']['conv_activate'] ){ | |
| 1180 | - $this->payment_structure['acting_remise_conv'] = 'コンビニ決済(ルミーズ)'; | |
| 1181 | - }else{ | |
| 1182 | - unset($this->payment_structure['acting_remise_conv']); | |
| 1183 | - } | |
| 1184 | - | |
| 1185 | - }else{ | |
| 1186 | - $this->action_status = 'error'; | |
| 1187 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1188 | - $options['acting_settings']['remise']['activate'] = 'off'; | |
| 1189 | - unset($this->payment_structure['acting_remise_card']); | |
| 1190 | - unset($this->payment_structure['acting_remise_conv']); | |
| 1191 | - } | |
| 1192 | - ksort($this->payment_structure); | |
| 1193 | - update_option('usces_payment_structure',$this->payment_structure); | |
| 1194 | - update_option('usces', $options); | |
| 1195 | - break; | |
| 1196 | -//20101018ysk start | |
| 1197 | - case 'jpayment': | |
| 1198 | - unset( $options['acting_settings']['jpayment'] ); | |
| 1199 | - $options['acting_settings']['jpayment']['aid'] = isset($_POST['aid']) ? $_POST['aid'] : ''; | |
| 1200 | - $options['acting_settings']['jpayment']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1201 | - $options['acting_settings']['jpayment']['card_jb'] = isset($_POST['card_jb']) ? $_POST['card_jb'] : ''; | |
| 1202 | - $options['acting_settings']['jpayment']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : ''; | |
| 1203 | - //$options['acting_settings']['jpayment']['webm_activate'] = isset($_POST['webm_activate']) ? $_POST['webm_activate'] : ''; | |
| 1204 | - //$options['acting_settings']['jpayment']['bitc_activate'] = isset($_POST['bitc_activate']) ? $_POST['bitc_activate'] : ''; | |
| 1205 | - //$options['acting_settings']['jpayment']['suica_activate'] = isset($_POST['suica_activate']) ? $_POST['suica_activate'] : ''; | |
| 1206 | - $options['acting_settings']['jpayment']['bank_activate'] = isset($_POST['bank_activate']) ? $_POST['bank_activate'] : ''; | |
| 1207 | - $options['acting_settings']['jpayment']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : ''; | |
| 1208 | - | |
| 1209 | - if( WCUtils::is_blank($_POST['aid']) ) | |
| 1210 | - $mes .= '※店舗IDコードを入力して下さい<br />'; | |
| 1211 | - if( isset($_POST['card_activate']) && 'on' == $_POST['card_activate'] && empty($_POST['card_jb']) ) | |
| 1212 | - $mes .= '※ジョブタイプを指定して下さい<br />'; | |
| 1213 | - | |
| 1214 | - if( WCUtils::is_blank($mes) ){ | |
| 1215 | - $this->action_status = 'success'; | |
| 1216 | - $this->action_message = __('options are updated','usces'); | |
| 1217 | - $options['acting_settings']['jpayment']['activate'] = 'on'; | |
| 1218 | - if( 'on' == $options['acting_settings']['jpayment']['card_activate'] ){ | |
| 1219 | - $this->payment_structure['acting_jpayment_card'] = 'カード決済(J-Payment)'; | |
| 1220 | - }else{ | |
| 1221 | - unset($this->payment_structure['acting_jpayment_card']); | |
| 1222 | - } | |
| 1223 | - if( 'on' == $options['acting_settings']['jpayment']['conv_activate'] ){ | |
| 1224 | - $this->payment_structure['acting_jpayment_conv'] = 'コンビニ決済(J-Payment)'; | |
| 1225 | - }else{ | |
| 1226 | - unset($this->payment_structure['acting_jpayment_conv']); | |
| 1227 | - } | |
| 1228 | - //if( 'on' == $options['acting_settings']['jpayment']['webm_activate'] ){ | |
| 1229 | - // $this->payment_structure['acting_jpayment_webm'] = 'WebMoney決済(J-Payment)'; | |
| 1230 | - //}else{ | |
| 1231 | - // unset($this->payment_structure['acting_jpayment_webm']); | |
| 1232 | - //} | |
| 1233 | - //if( 'on' == $options['acting_settings']['jpayment']['bitc_activate'] ){ | |
| 1234 | - // $this->payment_structure['acting_jpayment_bitc'] = 'BitCash決済(J-Payment)'; | |
| 1235 | - //}else{ | |
| 1236 | - // unset($this->payment_structure['acting_jpayment_bitc']); | |
| 1237 | - //} | |
| 1238 | - //if( 'on' == $options['acting_settings']['jpayment']['suica_activate'] ){ | |
| 1239 | - // $this->payment_structure['acting_jpayment_suica'] = 'モバイルSuica決済(J-Payment)'; | |
| 1240 | - //}else{ | |
| 1241 | - // unset($this->payment_structure['acting_jpayment_suica']); | |
| 1242 | - //} | |
| 1243 | - if( 'on' == $options['acting_settings']['jpayment']['bank_activate'] ){ | |
| 1244 | - $this->payment_structure['acting_jpayment_bank'] = 'バンクチェック決済(J-Payment)'; | |
| 1245 | - }else{ | |
| 1246 | - unset($this->payment_structure['acting_jpayment_bank']); | |
| 1247 | - } | |
| 1248 | - | |
| 1249 | - }else{ | |
| 1250 | - $this->action_status = 'error'; | |
| 1251 | - $this->action_message = __('データに不備が有ります', 'usces'); | |
| 1252 | - $options['acting_settings']['jpayment']['activate'] = 'off'; | |
| 1253 | - unset($this->payment_structure['acting_jpayment_card']); | |
| 1254 | - unset($this->payment_structure['acting_jpayment_conv']); | |
| 1255 | - //unset($this->payment_structure['acting_jpayment_webm']); | |
| 1256 | - //unset($this->payment_structure['acting_jpayment_bitc']); | |
| 1257 | - //unset($this->payment_structure['acting_jpayment_suica']); | |
| 1258 | - unset($this->payment_structure['acting_jpayment_bank']); | |
| 1259 | - } | |
| 1260 | - ksort($this->payment_structure); | |
| 1261 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1262 | - update_option('usces', $options); | |
| 1263 | - break; | |
| 1264 | -//20101018ysk end | |
| 1265 | -//20110208ysk start | |
| 1266 | - case 'paypal': | |
| 1267 | - unset( $options['acting_settings']['paypal'] ); | |
| 1268 | - $options['acting_settings']['paypal']['ec_activate'] = isset($_POST['ec_activate']) ? $_POST['ec_activate'] : ''; | |
| 1269 | - $options['acting_settings']['paypal']['sandbox'] = isset($_POST['sandbox']) ? $_POST['sandbox'] : ''; | |
| 1270 | - $options['acting_settings']['paypal']['user'] = isset($_POST['user']) ? $_POST['user'] : ''; | |
| 1271 | - $options['acting_settings']['paypal']['pwd'] = isset($_POST['pwd']) ? $_POST['pwd'] : ''; | |
| 1272 | - $options['acting_settings']['paypal']['signature'] = isset($_POST['signature']) ? $_POST['signature'] : ''; | |
| 1273 | -//20110412ysk start | |
| 1274 | - $options['acting_settings']['paypal']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : ''; | |
| 1275 | -//20110412ysk end | |
| 1276 | - | |
| 1277 | - if( !isset($_POST['sandbox']) || empty($_POST['sandbox']) ) | |
| 1278 | - $mes .= '※PayPalサーバーが不正です<br />'; | |
| 1279 | - if( WCUtils::is_blank($_POST['user']) ) | |
| 1280 | - $mes .= '※APIユーザー名を入力して下さい<br />'; | |
| 1281 | - if( WCUtils::is_blank($_POST['pwd']) ) | |
| 1282 | - $mes .= '※APIパスワードを入力して下さい<br />'; | |
| 1283 | - if( WCUtils::is_blank($_POST['signature']) ) | |
| 1284 | - $mes .= '※署名を入力して下さい<br />'; | |
| 1285 | - | |
| 1286 | - if( WCUtils::is_blank($mes) ){ | |
| 1287 | - $this->action_status = 'success'; | |
| 1288 | - $this->action_message = __('options are updated','usces'); | |
| 1289 | - if($options['acting_settings']['paypal']['sandbox'] == 1) { | |
| 1290 | - $options['acting_settings']['paypal']['api_host'] = 'api-3t.sandbox.paypal.com'; | |
| 1291 | - $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.sandbox.paypal.com/nvp'; | |
| 1292 | - $options['acting_settings']['paypal']['paypal_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; | |
| 1293 | - } else { | |
| 1294 | - $options['acting_settings']['paypal']['api_host'] = 'api-3t.paypal.com'; | |
| 1295 | - $options['acting_settings']['paypal']['api_endpoint'] = 'https://api-3t.paypal.com/nvp'; | |
| 1296 | - $options['acting_settings']['paypal']['paypal_url'] = 'https://www.paypal.com/cgi-bin/webscr'; | |
| 1297 | - } | |
| 1298 | - $options['acting_settings']['paypal']['activate'] = 'on'; | |
| 1299 | - if( 'on' == $options['acting_settings']['paypal']['ec_activate'] ){ | |
| 1300 | - $this->payment_structure['acting_paypal_ec'] = 'PayPal決済'; | |
| 1301 | - }else{ | |
| 1302 | - unset($this->payment_structure['acting_paypal_ec']); | |
| 1303 | - } | |
| 1304 | - | |
| 1305 | - }else{ | |
| 1306 | - $this->action_status = 'error'; | |
| 1307 | - $this->action_message = __('データに不備が有ります', 'usces'); | |
| 1308 | - $options['acting_settings']['paypal']['activate'] = 'off'; | |
| 1309 | - unset($this->payment_structure['acting_paypal_ec']); | |
| 1310 | - } | |
| 1311 | - ksort($this->payment_structure); | |
| 1312 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1313 | - update_option('usces', $options); | |
| 1314 | - break; | |
| 1315 | -//20110208ysk end | |
| 1316 | -//20120413ysk start | |
| 1317 | - case 'sbps': | |
| 1318 | - unset( $options['acting_settings']['sbps'] ); | |
| 1319 | - $options['acting_settings']['sbps']['merchant_id'] = isset($_POST['merchant_id']) ? $_POST['merchant_id'] : ''; | |
| 1320 | - $options['acting_settings']['sbps']['service_id'] = isset($_POST['service_id']) ? $_POST['service_id'] : ''; | |
| 1321 | - $options['acting_settings']['sbps']['hash_key'] = isset($_POST['hash_key']) ? $_POST['hash_key'] : ''; | |
| 1322 | - $options['acting_settings']['sbps']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : ''; | |
| 1323 | - $options['acting_settings']['sbps']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : ''; | |
| 1324 | - $options['acting_settings']['sbps']['send_url_check'] = isset($_POST['send_url_check']) ? $_POST['send_url_check'] : ''; | |
| 1325 | - $options['acting_settings']['sbps']['send_url_test'] = isset($_POST['send_url_test']) ? $_POST['send_url_test'] : ''; | |
| 1326 | - $options['acting_settings']['sbps']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1327 | - $options['acting_settings']['sbps']['3d_secure'] = isset($_POST['3d_secure']) ? $_POST['3d_secure'] : ''; | |
| 1328 | - $options['acting_settings']['sbps']['cust'] = isset($_POST['cust']) ? $_POST['cust'] : ''; | |
| 1329 | - $options['acting_settings']['sbps']['continuation'] = isset($_POST['continuation']) ? $_POST['continuation'] : ''; | |
| 1330 | - $options['acting_settings']['sbps']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : ''; | |
| 1331 | - $options['acting_settings']['sbps']['payeasy_activate'] = isset($_POST['payeasy_activate']) ? $_POST['payeasy_activate'] : ''; | |
| 1332 | - $options['acting_settings']['sbps']['wallet_yahoowallet'] = isset($_POST['wallet_yahoowallet']) ? $_POST['wallet_yahoowallet'] : ''; | |
| 1333 | - $options['acting_settings']['sbps']['wallet_rakuten'] = isset($_POST['wallet_rakuten']) ? $_POST['wallet_rakuten'] : ''; | |
| 1334 | - $options['acting_settings']['sbps']['wallet_paypal'] = isset($_POST['wallet_paypal']) ? $_POST['wallet_paypal'] : ''; | |
| 1335 | - $options['acting_settings']['sbps']['wallet_netmile'] = isset($_POST['wallet_netmile']) ? $_POST['wallet_netmile'] : ''; | |
| 1336 | - $options['acting_settings']['sbps']['wallet_alipay'] = isset($_POST['wallet_alipay']) ? $_POST['wallet_alipay'] : ''; | |
| 1337 | - $options['acting_settings']['sbps']['mobile_docomo'] = isset($_POST['mobile_docomo']) ? $_POST['mobile_docomo'] : ''; | |
| 1338 | - $options['acting_settings']['sbps']['mobile_softbank'] = isset($_POST['mobile_softbank']) ? $_POST['mobile_softbank'] : ''; | |
| 1339 | - $options['acting_settings']['sbps']['mobile_auone'] = isset($_POST['mobile_auone']) ? $_POST['mobile_auone'] : ''; | |
| 1340 | - $options['acting_settings']['sbps']['mobile_mysoftbank'] = isset($_POST['mobile_mysoftbank']) ? $_POST['mobile_mysoftbank'] : ''; | |
| 1341 | - | |
| 1342 | - if( WCUtils::is_blank($_POST['merchant_id']) ) | |
| 1343 | - $mes .= '※マーチャントIDを入力して下さい<br />'; | |
| 1344 | - if( WCUtils::is_blank($_POST['service_id']) ) | |
| 1345 | - $mes .= '※サービスIDを入力して下さい<br />'; | |
| 1346 | - if( WCUtils::is_blank($_POST['hash_key']) ) | |
| 1347 | - $mes .= '※Hash KEYを入力して下さい<br />'; | |
| 1348 | - if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) ) | |
| 1349 | - $mes .= '※本番URLを入力して下さい<br />'; | |
| 1350 | - | |
| 1351 | - if( WCUtils::is_blank($mes) ){ | |
| 1352 | - $this->action_status = 'success'; | |
| 1353 | - $this->action_message = __('options are updated','usces'); | |
| 1354 | - $options['acting_settings']['sbps']['activate'] = 'on'; | |
| 1355 | - if( 'on' == $options['acting_settings']['sbps']['card_activate'] ){ | |
| 1356 | - $this->payment_structure['acting_sbps_card'] = 'カード決済(ソフトバンク・ペイメント)'; | |
| 1357 | - }else{ | |
| 1358 | - unset($this->payment_structure['acting_sbps_card']); | |
| 1359 | - } | |
| 1360 | - if( 'on' == $options['acting_settings']['sbps']['conv_activate'] ){ | |
| 1361 | - $this->payment_structure['acting_sbps_conv'] = 'コンビニ決済(ソフトバンク・ペイメント)'; | |
| 1362 | - }else{ | |
| 1363 | - unset($this->payment_structure['acting_sbps_conv']); | |
| 1364 | - } | |
| 1365 | - if( 'on' == $options['acting_settings']['sbps']['payeasy_activate'] ){ | |
| 1366 | - $this->payment_structure['acting_sbps_payeasy'] = 'ペイジー決済(ソフトバンク・ペイメント)'; | |
| 1367 | - }else{ | |
| 1368 | - unset($this->payment_structure['acting_sbps_payeasy']); | |
| 1369 | - } | |
| 1370 | - if( ( 'on' == $options['acting_settings']['sbps']['wallet_yahoowallet'] ) || | |
| 1371 | - ( 'on' == $options['acting_settings']['sbps']['wallet_rakuten'] ) || | |
| 1372 | - ( 'on' == $options['acting_settings']['sbps']['wallet_paypal'] ) || | |
| 1373 | - ( 'on' == $options['acting_settings']['sbps']['wallet_netmile'] ) || | |
| 1374 | - ( 'on' == $options['acting_settings']['sbps']['wallet_alipay'] ) ) { | |
| 1375 | - $options['acting_settings']['sbps']['wallet_activate'] = 'on'; | |
| 1376 | - } else { | |
| 1377 | - $options['acting_settings']['sbps']['wallet_activate'] = 'off'; | |
| 1378 | - } | |
| 1379 | - if( 'on' == $options['acting_settings']['sbps']['wallet_activate'] ){ | |
| 1380 | - $this->payment_structure['acting_sbps_wallet'] = 'ウォレット決済(ソフトバンク・ペイメント)'; | |
| 1381 | - }else{ | |
| 1382 | - unset($this->payment_structure['acting_sbps_wallet']); | |
| 1383 | - } | |
| 1384 | - if( ( 'on' == $options['acting_settings']['sbps']['mobile_docomo'] ) || | |
| 1385 | - ( 'on' == $options['acting_settings']['sbps']['mobile_softbank'] ) || | |
| 1386 | - ( 'on' == $options['acting_settings']['sbps']['mobile_auone'] ) || | |
| 1387 | - ( 'on' == $options['acting_settings']['sbps']['mobile_mysoftbank'] ) ) { | |
| 1388 | - $options['acting_settings']['sbps']['mobile_activate'] = 'on'; | |
| 1389 | - } else { | |
| 1390 | - $options['acting_settings']['sbps']['mobile_activate'] = 'off'; | |
| 1391 | - } | |
| 1392 | - if( 'on' == $options['acting_settings']['sbps']['mobile_activate'] ){ | |
| 1393 | - $this->payment_structure['acting_sbps_mobile'] = '携帯キャリア決済(ソフトバンク・ペイメント)'; | |
| 1394 | - }else{ | |
| 1395 | - unset($this->payment_structure['acting_sbps_mobile']); | |
| 1396 | - } | |
| 1397 | - | |
| 1398 | - }else{ | |
| 1399 | - $this->action_status = 'error'; | |
| 1400 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1401 | - $options['acting_settings']['sbps']['activate'] = 'off'; | |
| 1402 | - unset($this->payment_structure['acting_sbps_card']); | |
| 1403 | - unset($this->payment_structure['acting_sbps_conv']); | |
| 1404 | - unset($this->payment_structure['acting_sbps_payeasy']); | |
| 1405 | - unset($this->payment_structure['acting_sbps_wallet']); | |
| 1406 | - unset($this->payment_structure['acting_sbps_mobile']); | |
| 1407 | - } | |
| 1408 | - ksort($this->payment_structure); | |
| 1409 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1410 | - update_option('usces', $options); | |
| 1411 | - break; | |
| 1412 | -//20120413ysk end | |
| 1413 | -//20120618ysk start | |
| 1414 | - case 'telecom': | |
| 1415 | - unset( $options['acting_settings']['telecom'] ); | |
| 1416 | - $options['acting_settings']['telecom']['clientip'] = isset($_POST['clientip']) ? $_POST['clientip'] : ''; | |
| 1417 | - $options['acting_settings']['telecom']['stype'] = isset($_POST['stype']) ? $_POST['stype'] : ''; | |
| 1418 | - $options['acting_settings']['telecom']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1419 | - $options['acting_settings']['telecom']['edy_activate'] = isset($_POST['edy_activate']) ? $_POST['edy_activate'] : ''; | |
| 1420 | - | |
| 1421 | - if( WCUtils::is_blank($_POST['clientip']) ) | |
| 1422 | - $mes .= '※クライアントIPを入力して下さい<br />'; | |
| 1423 | - if( WCUtils::is_blank($_POST['stype']) ) | |
| 1424 | - $mes .= '※決済タイプを入力して下さい<br />'; | |
| 1425 | - | |
| 1426 | - if( WCUtils::is_blank($mes) ){ | |
| 1427 | - $this->action_status = 'success'; | |
| 1428 | - $this->action_message = __('options are updated','usces'); | |
| 1429 | - $options['acting_settings']['telecom']['activate'] = 'on'; | |
| 1430 | - if( 'on' == $options['acting_settings']['telecom']['card_activate'] ){ | |
| 1431 | - if( 'E' == $options['acting_settings']['telecom']['stype'][0] ) { | |
| 1432 | - $options['acting_settings']['telecom']['send_url'] = "https://www.credit-cgiserver.com/inetcredit/secure/order.pl"; | |
| 1433 | - } else { | |
| 1434 | - $options['acting_settings']['telecom']['send_url'] = "https://secure.telecomcredit.co.jp/inetcredit/secure/order.pl"; | |
| 1435 | - } | |
| 1436 | - $this->payment_structure['acting_telecom_card'] = 'カード決済(テレコムクレジット)'; | |
| 1437 | - }else{ | |
| 1438 | - unset($this->payment_structure['acting_telecom_card']); | |
| 1439 | - } | |
| 1440 | - if( 'on' == $options['acting_settings']['telecom']['edy_activate'] ){ | |
| 1441 | - $options['acting_settings']['telecom']['send_url_edy'] = "https://secure.telecomcredit.co.jp/payment/edy/order.pl"; | |
| 1442 | - $this->payment_structure['acting_telecom_edy'] = 'Edy決済(テレコムクレジット)'; | |
| 1443 | - }else{ | |
| 1444 | - unset($this->payment_structure['acting_telecom_edy']); | |
| 1445 | - } | |
| 1446 | - }else{ | |
| 1447 | - $this->action_status = 'error'; | |
| 1448 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1449 | - $options['acting_settings']['telecom']['activate'] = 'off'; | |
| 1450 | - unset($this->payment_structure['acting_telecom_card']); | |
| 1451 | - unset($this->payment_structure['acting_telecom_edy']); | |
| 1452 | - } | |
| 1453 | - ksort($this->payment_structure); | |
| 1454 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1455 | - update_option('usces', $options); | |
| 1456 | - break; | |
| 1457 | -//20120618ysk end | |
| 1458 | -//20121206ysk start | |
| 1459 | - case 'digitalcheck': | |
| 1460 | - unset( $options['acting_settings']['digitalcheck'] ); | |
| 1461 | - $options['acting_settings']['digitalcheck']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1462 | - $options['acting_settings']['digitalcheck']['card_ip'] = isset($_POST['card_ip']) ? $_POST['card_ip'] : ''; | |
| 1463 | - $options['acting_settings']['digitalcheck']['card_pass'] = isset($_POST['card_pass']) ? $_POST['card_pass'] : ''; | |
| 1464 | - $options['acting_settings']['digitalcheck']['card_kakutei'] = isset($_POST['card_kakutei']) ? $_POST['card_kakutei'] : ''; | |
| 1465 | - $options['acting_settings']['digitalcheck']['card_user_id'] = isset($_POST['card_user_id']) ? $_POST['card_user_id'] : ''; | |
| 1466 | - $options['acting_settings']['digitalcheck']['conv_activate'] = isset($_POST['conv_activate']) ? $_POST['conv_activate'] : ''; | |
| 1467 | - $options['acting_settings']['digitalcheck']['conv_ip'] = isset($_POST['conv_ip']) ? $_POST['conv_ip'] : ''; | |
| 1468 | - $options['acting_settings']['digitalcheck']['conv_store'] = isset($_POST['conv_store']) ? $_POST['conv_store'] : array(); | |
| 1469 | - $options['acting_settings']['digitalcheck']['conv_kigen'] = isset($_POST['conv_kigen']) ? $_POST['conv_kigen'] : '14'; | |
| 1470 | - | |
| 1471 | - if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ) { | |
| 1472 | - if( '' == trim($_POST['card_ip']) ) | |
| 1473 | - $mes .= '※加盟店コードを入力して下さい<br />'; | |
| 1474 | - if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) { | |
| 1475 | - if( '' == trim($_POST['card_pass']) ) | |
| 1476 | - $mes .= '※加盟店パスワードを入力して下さい<br />'; | |
| 1477 | - } | |
| 1478 | - } | |
| 1479 | - if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ) { | |
| 1480 | - if( '' == trim($_POST['conv_ip']) ) | |
| 1481 | - $mes .= '※加盟店コードを入力して下さい<br />'; | |
| 1482 | - if( empty($_POST['conv_store']) ) | |
| 1483 | - $mes .= '※利用コンビニを選択して下さい<br />'; | |
| 1484 | - } | |
| 1485 | - | |
| 1486 | - if( '' == $mes ){ | |
| 1487 | - $this->action_status = 'success'; | |
| 1488 | - $this->action_message = __('options are updated','usces'); | |
| 1489 | - $options['acting_settings']['digitalcheck']['activate'] = 'on'; | |
| 1490 | - if( 'on' == $options['acting_settings']['digitalcheck']['card_activate'] ){ | |
| 1491 | - $options['acting_settings']['digitalcheck']['send_url_card'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll"; | |
| 1492 | - if( 'on' == $options['acting_settings']['digitalcheck']['card_user_id'] ) { | |
| 1493 | - $options['acting_settings']['digitalcheck']['send_url_user_id'] = "https://www.digitalcheck.jp/settle/settlex/credit2.dll"; | |
| 1494 | - } else { | |
| 1495 | - $options['acting_settings']['digitalcheck']['send_url_user_id'] = ""; | |
| 1496 | - } | |
| 1497 | - $this->payment_structure['acting_digitalcheck_card'] = 'カード決済(デジタルチェック)'; | |
| 1498 | - }else{ | |
| 1499 | - unset($this->payment_structure['acting_digitalcheck_card']); | |
| 1500 | - } | |
| 1501 | - if( 'on' == $options['acting_settings']['digitalcheck']['conv_activate'] ){ | |
| 1502 | - //$options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle2/ubp3.dll"; | |
| 1503 | - $options['acting_settings']['digitalcheck']['send_url_conv'] = "https://www.digitalcheck.jp/settle/settle3/bp3.dll"; | |
| 1504 | - $this->payment_structure['acting_digitalcheck_conv'] = 'コンビニ決済(デジタルチェック)'; | |
| 1505 | - }else{ | |
| 1506 | - unset($this->payment_structure['acting_digitalcheck_conv']); | |
| 1507 | - } | |
| 1508 | - }else{ | |
| 1509 | - $this->action_status = 'error'; | |
| 1510 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1511 | - $options['acting_settings']['digitalcheck']['activate'] = 'off'; | |
| 1512 | - unset($this->payment_structure['acting_digitalcheck_card']); | |
| 1513 | - unset($this->payment_structure['acting_digitalcheck_conv']); | |
| 1514 | - } | |
| 1515 | - ksort($this->payment_structure); | |
| 1516 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1517 | - update_option('usces', $options); | |
| 1518 | - break; | |
| 1519 | -//20121206ysk end | |
| 1520 | -//20130225ysk start | |
| 1521 | - case 'mizuho': | |
| 1522 | - unset( $options['acting_settings']['mizuho'] ); | |
| 1523 | - $options['acting_settings']['mizuho']['shopid'] = isset($_POST['shopid']) ? $_POST['shopid'] : ''; | |
| 1524 | - $options['acting_settings']['mizuho']['cshopid'] = isset($_POST['cshopid']) ? $_POST['cshopid'] : ''; | |
| 1525 | - $options['acting_settings']['mizuho']['hash_pass'] = isset($_POST['hash_pass']) ? $_POST['hash_pass'] : ''; | |
| 1526 | - $options['acting_settings']['mizuho']['ope'] = isset($_POST['ope']) ? $_POST['ope'] : ''; | |
| 1527 | - $options['acting_settings']['mizuho']['send_url'] = isset($_POST['send_url']) ? $_POST['send_url'] : ''; | |
| 1528 | - $options['acting_settings']['mizuho']['send_url_mbl'] = isset($_POST['send_url_mbl']) ? $_POST['send_url_mbl'] : ''; | |
| 1529 | - $options['acting_settings']['mizuho']['card_activate'] = isset($_POST['card_activate']) ? $_POST['card_activate'] : ''; | |
| 1530 | - $options['acting_settings']['mizuho']['conv1_activate'] = isset($_POST['conv1_activate']) ? $_POST['conv1_activate'] : ''; | |
| 1531 | - $options['acting_settings']['mizuho']['conv2_activate'] = isset($_POST['conv2_activate']) ? $_POST['conv2_activate'] : ''; | |
| 1532 | - | |
| 1533 | - //if( 'on' == $options['acting_settings']['mizuho']['card_activate'] or 'on' == $options['acting_settings']['mizuho']['conv_activate'] ) { | |
| 1534 | - if( '' == trim($_POST['shopid']) ) | |
| 1535 | - $mes .= '※加盟店コードを入力して下さい<br />'; | |
| 1536 | - if( '' == trim($_POST['cshopid']) ) | |
| 1537 | - $mes .= '※加盟店サブコードを入力して下さい<br />'; | |
| 1538 | - if( '' == trim($_POST['hash_pass']) ) | |
| 1539 | - $mes .= '※ハッシュ用パスワードを入力して下さい<br />'; | |
| 1540 | - //} | |
| 1541 | - if( isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url']) ) | |
| 1542 | - $mes .= '※本番URLを入力して下さい<br />'; | |
| 1543 | - if( defined('WCEX_MOBILE') and isset($_POST['ope']) && 'public' == $_POST['ope'] && empty($_POST['send_url_mbl']) ) | |
| 1544 | - $mes .= '※本番URL(携帯)を入力して下さい<br />'; | |
| 1545 | - | |
| 1546 | - if( '' == $mes ) { | |
| 1547 | - $this->action_status = 'success'; | |
| 1548 | - $this->action_message = __('options are updated','usces'); | |
| 1549 | - $options['acting_settings']['mizuho']['activate'] = 'on'; | |
| 1550 | - $options['acting_settings']['mizuho']['send_url_test'] = "https://210.161.141.207/mltbank/MBWebFrontPayment"; | |
| 1551 | - if( defined('WCEX_MOBILE') ) $options['acting_settings']['mizuho']['send_url_mbl_test'] = "https://210.161.141.207/mltbank/iMBWebFrontPayment"; | |
| 1552 | - if( 'on' == $options['acting_settings']['mizuho']['card_activate'] ) { | |
| 1553 | - $this->payment_structure['acting_mizuho_card'] = 'カード決済(みずほファクター)'; | |
| 1554 | - } else { | |
| 1555 | - unset($this->payment_structure['acting_mizuho_card']); | |
| 1556 | - } | |
| 1557 | - if( 'on' == $options['acting_settings']['mizuho']['conv1_activate'] ) { | |
| 1558 | - $this->payment_structure['acting_mizuho_conv1'] = 'コンビニ・ウェルネット決済(みずほファクター)'; | |
| 1559 | - } else { | |
| 1560 | - unset($this->payment_structure['acting_mizuho_conv1']); | |
| 1561 | - } | |
| 1562 | - if( 'on' == $options['acting_settings']['mizuho']['conv2_activate'] ) { | |
| 1563 | - $this->payment_structure['acting_mizuho_conv2'] = 'コンビニ・セブンイレブン決済(みずほファクター)'; | |
| 1564 | - } else { | |
| 1565 | - unset($this->payment_structure['acting_mizuho_conv2']); | |
| 1566 | - } | |
| 1567 | - } else { | |
| 1568 | - $this->action_status = 'error'; | |
| 1569 | - $this->action_message = __('データに不備が有ります','usces'); | |
| 1570 | - $options['acting_settings']['mizuho']['activate'] = 'off'; | |
| 1571 | - unset($this->payment_structure['acting_mizuho_card']); | |
| 1572 | - unset($this->payment_structure['acting_mizuho_conv1']); | |
| 1573 | - unset($this->payment_structure['acting_mizuho_conv2']); | |
| 1574 | - } | |
| 1575 | - ksort($this->payment_structure); | |
| 1576 | - update_option('usces_payment_structure', $this->payment_structure); | |
| 1577 | - update_option('usces', $options); | |
| 1578 | - break; | |
| 1579 | -//20130225ysk end | |
| 1580 | - } | |
| 1581 | - | |
| 1582 | - | |
| 1583 | - } | |
| 1584 | - | |
| 1585 | - | |
| 1586 | - $this->options = get_option('usces'); | |
| 1587 | - | |
| 1588 | - require_once(USCES_PLUGIN_DIR . '/includes/admin_settlement.php'); | |
| 1589 | - } | |
| 1590 | - | |
| 1591 | - /********************************************************************************/ | |
| 1592 | - function selected( $selected, $current) { | |
| 1593 | - if ( $selected == $current) | |
| 1594 | - echo ' selected="selected"'; | |
| 1595 | - } | |
| 1596 | - /********************************************************************************/ | |
| 1597 | - | |
| 1598 | - function usces_session_start() { | |
| 1599 | - $options = get_option('usces'); | |
| 1600 | - if( !isset($options['usces_key']) || empty($options['usces_key']) ){ | |
| 1601 | - $options['usces_key'] = uniqid('uk'); | |
| 1602 | - update_option('usces', $options); | |
| 1603 | - } | |
| 1604 | - | |
| 1605 | - if(defined( 'USCES_KEY' )){ | |
| 1606 | - if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){ | |
| 1607 | - session_name( 'adm'.USCES_KEY ); | |
| 1608 | - }else{ | |
| 1609 | - session_name( USCES_KEY ); | |
| 1610 | - } | |
| 1611 | - }else{ | |
| 1612 | - if( is_admin() || preg_match('/\/wp-login\.php/', $_SERVER['REQUEST_URI']) ){ | |
| 1613 | - session_name( 'adm'.$options['usces_key'] ); | |
| 1614 | - }else{ | |
| 1615 | - session_name( $options['usces_key'] ); | |
| 1616 | - } | |
| 1617 | - } | |
| 1618 | - if(isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid'])) { | |
| 1619 | - $sessid = $_GET['uscesid']; | |
| 1620 | - $sessid = $this->uscesdc($sessid); | |
| 1621 | - session_id($sessid); | |
| 1622 | - } | |
| 1623 | - | |
| 1624 | - @session_start(); | |
| 1625 | - | |
| 1626 | -//20111222ysk start 0000367 | |
| 1627 | - //if ( !isset($_SESSION['usces_member']) ){ | |
| 1628 | - if ( !isset($_SESSION['usces_member']) || $options['membersystem_state'] != 'activate' ){ | |
| 1629 | -//20111222ysk end | |
| 1630 | - $_SESSION['usces_member'] = array(); | |
| 1631 | - } | |
| 1632 | - | |
| 1633 | - if(!isset($_SESSION['usces_checked_business_days'])) | |
| 1634 | - $this->update_business_days(); | |
| 1635 | - } | |
| 1636 | - | |
| 1637 | - function usces_cookie() { | |
| 1638 | - if(is_admin()) return; | |
| 1639 | - | |
| 1640 | - $actionflag = false; | |
| 1641 | - $sess = NULL; | |
| 1642 | - $addr = NULL; | |
| 1643 | - $rckid = NULL; | |
| 1644 | - $none = NULL; | |
| 1645 | - $cookie = $this->get_cookie(); | |
| 1646 | - | |
| 1647 | - if( isset($_GET['uscesid']) && !WCUtils::is_blank($_GET['uscesid']) ){ | |
| 1648 | - $sessid = base64_decode(urldecode($_GET['uscesid'])); | |
| 1649 | - list($sess, $addr, $rckid, $none) = explode('_', $sessid, 4); | |
| 1650 | - } | |
| 1651 | - if('acting' == $addr) return; | |
| 1652 | - | |
| 1653 | - if( apply_filters( 'usces_filter_cookie', false) ) return; | |
| 1654 | - | |
| 1655 | - //There is a need to consider. | |
| 1656 | - return; | |
| 1657 | - | |
| 1658 | - if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){ | |
| 1659 | - | |
| 1660 | - $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL; | |
| 1661 | - $sslid = isset($cookie['sslid']) ? $cookie['sslid'] : NULL; | |
| 1662 | - $option = get_option('usces'); | |
| 1663 | - $parsed = parse_url(get_option('home')); | |
| 1664 | - $home = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : ''); | |
| 1665 | - $parsed = parse_url($option['ssl_url']); | |
| 1666 | - $sslhome = $parsed['host'] . (isset($parsed['path']) ? $parsed['path'] : ''); | |
| 1667 | - | |
| 1668 | -//usces_log('refer : '.$refer, 'acting_transaction.log'); | |
| 1669 | -// usces_log('sslid : '.$sslid, 'acting_transaction.log'); | |
| 1670 | -// usces_log('rckid : '.$rckid, 'acting_transaction.log'); | |
| 1671 | -// usces_log('usces_cookieid : '.$_SESSION['usces_cookieid'], 'acting_transaction.log'); | |
| 1672 | -// usces_log('request : '.print_r($_SERVER['REQUEST_URI'],true), 'acting_transaction.log'); | |
| 1673 | - | |
| 1674 | - if( empty($refer) || (false === strpos($refer, $home) && false === strpos($refer, $sslhome)) ){ | |
| 1675 | - if( !empty($sslid) && !empty($rckid) && $sslid === $rckid ){ | |
| 1676 | - $actionflag = true; | |
| 1677 | - }else{ | |
| 1678 | - $actionflag = false; | |
| 1679 | - } | |
| 1680 | - }else{ | |
| 1681 | - if( !empty($sslid) && $sslid !== $rckid ){ | |
| 1682 | - $actionflag = false; | |
| 1683 | - }else{ | |
| 1684 | - $actionflag = true; | |
| 1685 | - } | |
| 1686 | - } | |
| 1687 | - | |
| 1688 | - | |
| 1689 | - if( $actionflag ){ | |
| 1690 | - $values = array( | |
| 1691 | - 'id' => $rckid, | |
| 1692 | - 'sslid' => $rckid, | |
| 1693 | - 'name' => '', | |
| 1694 | - 'rme' => '' | |
| 1695 | - ); | |
| 1696 | - if( 'acting' !== $rckid ){ | |
| 1697 | - $this->set_cookie($values); | |
| 1698 | - } | |
| 1699 | - }else{ | |
| 1700 | - if( 'acting' !== $rckid ){ | |
| 1701 | - unset($_SESSION['usces_member'], $_SESSION['usces_cart'], $_SESSION['usces_entry'] ); | |
| 1702 | - wp_redirect( 'http://'.$home ); | |
| 1703 | - } | |
| 1704 | - } | |
| 1705 | - }else{ | |
| 1706 | - if( !isset($cookie['id']) || WCUtils::is_blank($cookie['id']) ) { | |
| 1707 | - $values = array( | |
| 1708 | - 'id' => md5(uniqid(rand(), true)), | |
| 1709 | - 'name' => '', | |
| 1710 | - 'rme' => '' | |
| 1711 | - ); | |
| 1712 | - $this->set_cookie($values); | |
| 1713 | - $_SESSION['usces_cookieid'] = $values['id']; | |
| 1714 | - } else { | |
| 1715 | - if( !isset($_SESSION['usces_cookieid']) || $_SESSION['usces_cookieid'] != $cookie['id']) | |
| 1716 | - $_SESSION['usces_cookieid'] = $cookie['id']; | |
| 1717 | - } | |
| 1718 | - | |
| 1719 | - $actionflag = true; | |
| 1720 | - } | |
| 1721 | - | |
| 1722 | - } | |
| 1723 | - | |
| 1724 | - function set_cookie($values){ | |
| 1725 | - $value = serialize($values); | |
| 1726 | - $timeout = time()+7*86400; | |
| 1727 | - $domain = $_SERVER['SERVER_NAME']; | |
| 1728 | - $res = setcookie('usces_cookie', $value, $timeout, USCES_COOKIEPATH, $domain); | |
| 1729 | - } | |
| 1730 | - | |
| 1731 | - function get_cookie() { | |
| 1732 | - $values = isset($_COOKIE['usces_cookie']) ? unserialize(stripslashes($_COOKIE['usces_cookie'])) : NULL; | |
| 1733 | - return $values; | |
| 1734 | - } | |
| 1735 | - | |
| 1736 | - function get_access( $key, $type, $date ) { | |
| 1737 | - global $wpdb; | |
| 1738 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 1739 | - | |
| 1740 | - $query = $wpdb->prepare("SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date); | |
| 1741 | - $value = $wpdb->get_var( $query ); | |
| 1742 | - if( !$value ){ | |
| 1743 | - $res = NULL; | |
| 1744 | - }else{ | |
| 1745 | - $res = unserialize($value); | |
| 1746 | - } | |
| 1747 | - | |
| 1748 | - return $res; | |
| 1749 | - } | |
| 1750 | - | |
| 1751 | - function get_access_piriod( $key, $type, $startday, $endday ) { | |
| 1752 | - global $wpdb; | |
| 1753 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 1754 | - //$wpdb->show_errors(); | |
| 1755 | - $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); | |
| 1756 | - $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 1757 | - | |
| 1758 | - return $res; | |
| 1759 | - } | |
| 1760 | - | |
| 1761 | - function update_access( $array ) { | |
| 1762 | - global $wpdb; | |
| 1763 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 1764 | - | |
| 1765 | - $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']); | |
| 1766 | - $res = $wpdb->get_var( $query ); | |
| 1767 | - //$wpdb->show_errors(); | |
| 1768 | - if(empty($res)){ | |
| 1769 | - $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']); | |
| 1770 | - $wpdb->query( $query ); | |
| 1771 | - }else{ | |
| 1772 | - $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']); | |
| 1773 | - $wpdb->query( $query ); | |
| 1774 | - } | |
| 1775 | - } | |
| 1776 | - | |
| 1777 | - function get_uscesid( $flag = true) { | |
| 1778 | - | |
| 1779 | - $sessname = session_name(); | |
| 1780 | - $sessid = session_id(); | |
| 1781 | - $sessid = $this->uscescv($sessid, $flag); | |
| 1782 | - return $sessid; | |
| 1783 | - } | |
| 1784 | - | |
| 1785 | - function shop_head() { | |
| 1786 | - global $post; | |
| 1787 | - $this->item = $post; | |
| 1788 | - $no_cart_css = isset($this->options['system']['no_cart_css']) ? $this->options['system']['no_cart_css'] : 0; | |
| 1789 | - | |
| 1790 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 1791 | - $css_url = USCES_FRONT_PLUGIN_URL . '/css/usces_cart.css'; | |
| 1792 | - }else{ | |
| 1793 | - $css_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/css/usces_cart.css'; | |
| 1794 | - } | |
| 1795 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) ){ | |
| 1796 | - echo " <meta name='robots' content='noindex,nofollow' />\n"; | |
| 1797 | - wp_print_scripts( array( 'sack' )); | |
| 1798 | - } | |
| 1799 | - if( !$no_cart_css ){ | |
| 1800 | - echo '<link href="' . $css_url . '" rel="stylesheet" type="text/css" />'; | |
| 1801 | - } | |
| 1802 | - if( file_exists(get_stylesheet_directory() . '/usces_cart.css') ){ | |
| 1803 | - echo '<link href="' . get_stylesheet_directory_uri() . '/usces_cart.css" rel="stylesheet" type="text/css" />'; | |
| 1804 | - } | |
| 1805 | - } | |
| 1806 | - | |
| 1807 | - function shop_foot() { | |
| 1808 | - global $current_user; | |
| 1809 | - $item = $this->item; | |
| 1810 | - if( empty($item) ){ | |
| 1811 | - $item->ID = 0; | |
| 1812 | - $item->post_mime_type = ''; | |
| 1813 | - } | |
| 1814 | - get_currentuserinfo(); | |
| 1815 | - if( $this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 1816 | - $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js'; | |
| 1817 | - }else{ | |
| 1818 | - $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js'; | |
| 1819 | - } | |
| 1820 | - $this->member_name = ( is_user_logged_in() ) ? esc_js(get_user_meta($current_user->ID,'first_name').get_user_meta($current_user->ID,'last_name')) : ''; | |
| 1821 | - $this->previous_url = isset($_SESSION['usces_previous_url']) ? $_SESSION['usces_previous_url'] : get_home_url(); | |
| 1822 | - | |
| 1823 | -// usces_log('post_type : '.$item->post_mime_type, 'test.log'); | |
| 1824 | -// usces_log('is_single : '.(is_single() ? 'true' : 'false'), 'test.log'); | |
| 1825 | - | |
| 1826 | - if( $this->use_js && empty($this->item) && !is_admin() ) : | |
| 1827 | - ?> | |
| 1828 | - <script type='text/javascript'> | |
| 1829 | - /* <![CDATA[ */ | |
| 1830 | - uscesL10n = { | |
| 1831 | - <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?> | |
| 1832 | - 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>" | |
| 1833 | - } | |
| 1834 | - /* ]]> */ | |
| 1835 | - </script> | |
| 1836 | - <?php elseif( $this->use_js && !empty($this->item) ) : | |
| 1837 | - | |
| 1838 | - $ioptkeys = $this->get_itemOptionKey( $item->ID ); | |
| 1839 | - $mes_opts_str = ""; | |
| 1840 | - $key_opts_str = ""; | |
| 1841 | - $opt_means = ""; | |
| 1842 | - $opt_esse = ""; | |
| 1843 | - if($ioptkeys){ | |
| 1844 | - foreach($ioptkeys as $key => $value){ | |
| 1845 | - $optValues = $this->get_itemOptions( $value, $item->ID ); | |
| 1846 | - if($optValues['means'] < 2){ | |
| 1847 | - $mes_opts_str .= "'" . sprintf(__("Chose the %s", 'usces'), esc_js($value)) . "',"; | |
| 1848 | - }else{ | |
| 1849 | - $mes_opts_str .= "'" . sprintf(__("Input the %s", 'usces'), esc_js($value)) . "',"; | |
| 1850 | - } | |
| 1851 | - $key_opts_str .= "'" . urlencode(esc_js($value)) . "',"; | |
| 1852 | - $opt_means .= "'" . esc_js($optValues['means']) . "',"; | |
| 1853 | - $opt_esse .= "'" . esc_js($optValues['essential']) . "',"; | |
| 1854 | - } | |
| 1855 | - $mes_opts_str = rtrim($mes_opts_str, ','); | |
| 1856 | - $key_opts_str = rtrim($key_opts_str, ','); | |
| 1857 | - $opt_means = rtrim($opt_means, ','); | |
| 1858 | - $opt_esse = rtrim($opt_esse, ','); | |
| 1859 | - } | |
| 1860 | - //$itemRestriction = get_post_custom_values('_itemRestriction', $item->ID); | |
| 1861 | - $itemRestriction = get_post_meta($item->ID, '_itemRestriction', true); | |
| 1862 | - | |
| 1863 | - ?> | |
| 1864 | - <script type='text/javascript'> | |
| 1865 | - /* <![CDATA[ */ | |
| 1866 | - uscesL10n = { | |
| 1867 | - <?php echo apply_filters('usces_filter_uscesL10n', NULL, $item->ID); ?> | |
| 1868 | - 'ajaxurl': "<?php echo $this->ssl_admin_ajax_url(); ?>", | |
| 1869 | - 'post_id': "<?php echo $item->ID; ?>", | |
| 1870 | - 'cart_number': "<?php echo get_option('usces_cart_number'); ?>", | |
| 1871 | - 'is_cart_row': <?php echo ( (0 < $this->cart->num_row()) ? 'true' : 'false'); ?>, | |
| 1872 | - 'opt_esse': new Array( <?php echo $opt_esse; ?> ), | |
| 1873 | - 'opt_means': new Array( <?php echo $opt_means; ?> ), | |
| 1874 | - 'mes_opts': new Array( <?php echo $mes_opts_str; ?> ), | |
| 1875 | - 'key_opts': new Array( <?php echo $key_opts_str; ?> ), | |
| 1876 | - 'previous_url': "<?php echo $this->previous_url; ?>", | |
| 1877 | - 'itemRestriction': "<?php echo $itemRestriction; ?>" | |
| 1878 | - } | |
| 1879 | - /* ]]> */ | |
| 1880 | - </script> | |
| 1881 | - <script type='text/javascript' src='<?php echo $javascript_url; ?>'></script> | |
| 1882 | - <?php endif; ?> | |
| 1883 | - <?php //if( !is_home() && !is_front_page() && $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || ('item' == $item->post_mime_type)) ) : ?> | |
| 1884 | - <?php if( $this->use_js && (is_page(USCES_CART_NUMBER) || $this->is_cart_page($_SERVER['REQUEST_URI']) || (is_singular() && 'item' == $item->post_mime_type)) ) : ?> | |
| 1885 | - <script type='text/javascript'> | |
| 1886 | - (function($) { | |
| 1887 | - uscesCart = { | |
| 1888 | - intoCart : function (post_id, sku) { | |
| 1889 | - | |
| 1890 | - var zaikonum = document.getElementById("zaikonum["+post_id+"]["+sku+"]").value; | |
| 1891 | - var zaiko = document.getElementById("zaiko["+post_id+"]["+sku+"]").value; | |
| 1892 | - if( (zaiko != '0' && zaiko != '1') || parseInt(zaikonum) == 0 ){ | |
| 1893 | - alert('<?php _e('temporaly out of stock now', 'usces'); ?>'); | |
| 1894 | - return false; | |
| 1895 | - } | |
| 1896 | - | |
| 1897 | - var mes = ''; | |
| 1898 | - if(document.getElementById("quant["+post_id+"]["+sku+"]")){ | |
| 1899 | - var quant = document.getElementById("quant["+post_id+"]["+sku+"]").value; | |
| 1900 | - if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 1901 | - mes += "<?php _e('enter the correct amount', 'usces'); ?>\n"; | |
| 1902 | - } | |
| 1903 | - var checknum = ''; | |
| 1904 | - var checkmode = ''; | |
| 1905 | - if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) { | |
| 1906 | - checknum = uscesL10n.itemRestriction; | |
| 1907 | - checkmode ='rest'; | |
| 1908 | - } else if( parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) { | |
| 1909 | - checknum = zaikonum; | |
| 1910 | - checkmode ='zaiko'; | |
| 1911 | - } else if( (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) { | |
| 1912 | - checknum = zaikonum; | |
| 1913 | - checkmode ='zaiko'; | |
| 1914 | - } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum == '' ) { | |
| 1915 | - checknum = uscesL10n.itemRestriction; | |
| 1916 | - checkmode ='rest'; | |
| 1917 | - } | |
| 1918 | - | |
| 1919 | - | |
| 1920 | - if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 1921 | - if(checkmode == 'rest'){ | |
| 1922 | - mes += <?php _e("'This article is limited by '+checknum+' at a time.'", 'usces'); ?>+"\n"; | |
| 1923 | - }else{ | |
| 1924 | - mes += <?php _e("'Stock is remainder '+checknum+'.'", 'usces'); ?>+"\n"; | |
| 1925 | - } | |
| 1926 | - } | |
| 1927 | - } | |
| 1928 | - for(i=0; i<uscesL10n.key_opts.length; i++){ | |
| 1929 | - var skuob = document.getElementById("itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]"); | |
| 1930 | - if( uscesL10n.opt_esse[i] == '1' ){ | |
| 1931 | - | |
| 1932 | - if( uscesL10n.opt_means[i] < 2 && skuob.value == '#NONE#' ){ | |
| 1933 | - mes += uscesL10n.mes_opts[i]+"\n"; | |
| 1934 | - }else if( uscesL10n.opt_means[i] >= 2 && skuob.value == '' ){ | |
| 1935 | - mes += uscesL10n.mes_opts[i]+"\n"; | |
| 1936 | - } | |
| 1937 | - } | |
| 1938 | - } | |
| 1939 | - | |
| 1940 | - <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); //Unavailable ?> | |
| 1941 | - <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?> | |
| 1942 | - | |
| 1943 | - if( mes != '' ){ | |
| 1944 | - alert( mes ); | |
| 1945 | - return false; | |
| 1946 | - }else{ | |
| 1947 | - <?php echo apply_filters('usces_filter_js_intoCart', "return true;\n", $item->ID, NULL); ?> | |
| 1948 | - } | |
| 1949 | - }, | |
| 1950 | - | |
| 1951 | - upCart : function () { | |
| 1952 | - | |
| 1953 | - var zaikoob = $("input[name*='zaikonum']"); | |
| 1954 | - var quantob = $("input[name*='quant']"); | |
| 1955 | - var postidob = $("input[name*='itempostid']"); | |
| 1956 | - var skuob = $("input[name*='itemsku']"); | |
| 1957 | - | |
| 1958 | - var zaikonum = ''; | |
| 1959 | - var zaiko = ''; | |
| 1960 | - var quant = ''; | |
| 1961 | - var mes = ''; | |
| 1962 | - var checknum = ''; | |
| 1963 | - var post_id = ''; | |
| 1964 | - var sku = ''; | |
| 1965 | - var itemRestriction = ''; | |
| 1966 | - | |
| 1967 | - var ct = zaikoob.length; | |
| 1968 | - for(var i=0; i< ct; i++){ | |
| 1969 | - post_id = postidob[i].value; | |
| 1970 | - sku = skuob[i].value; | |
| 1971 | - itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val(); | |
| 1972 | - zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 1973 | - | |
| 1974 | - quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 1975 | - if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){ | |
| 1976 | - if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 1977 | - mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n"; | |
| 1978 | - } | |
| 1979 | - var checknum = ''; | |
| 1980 | - var checkmode = ''; | |
| 1981 | - if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 1982 | - checknum = itemRestriction; | |
| 1983 | - checkmode ='rest'; | |
| 1984 | - } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 1985 | - checknum = zaikonum; | |
| 1986 | - checkmode ='zaiko'; | |
| 1987 | - } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) { | |
| 1988 | - checknum = zaikonum; | |
| 1989 | - checkmode ='zaiko'; | |
| 1990 | - } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) { | |
| 1991 | - checknum = itemRestriction; | |
| 1992 | - checkmode ='rest'; | |
| 1993 | - } | |
| 1994 | - if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 1995 | - if(checkmode == 'rest'){ | |
| 1996 | - mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n"; | |
| 1997 | - }else{ | |
| 1998 | - mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n"; | |
| 1999 | - } | |
| 2000 | - } | |
| 2001 | - } | |
| 2002 | - } | |
| 2003 | - | |
| 2004 | - <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); //Unavailable ?> | |
| 2005 | - <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?> | |
| 2006 | - | |
| 2007 | - if( mes != '' ){ | |
| 2008 | - alert( mes ); | |
| 2009 | - return false; | |
| 2010 | - }else{ | |
| 2011 | - <?php echo apply_filters('usces_filter_js_upCart', "return true;\n", $item->ID, NULL); ?> | |
| 2012 | - } | |
| 2013 | - }, | |
| 2014 | - | |
| 2015 | - cartNext : function () { | |
| 2016 | - | |
| 2017 | - var zaikoob = $("input[name*='zaikonum']"); | |
| 2018 | - var quantob = $("input[name*='quant']"); | |
| 2019 | - var postidob = $("input[name*='itempostid']"); | |
| 2020 | - var skuob = $("input[name*='itemsku']"); | |
| 2021 | - | |
| 2022 | - var zaikonum = ''; | |
| 2023 | - var zaiko = ''; | |
| 2024 | - var quant = ''; | |
| 2025 | - var mes = ''; | |
| 2026 | - var checknum = ''; | |
| 2027 | - var post_id = ''; | |
| 2028 | - var sku = ''; | |
| 2029 | - var itemRestriction = ''; | |
| 2030 | - | |
| 2031 | - var ct = zaikoob.length; | |
| 2032 | - for(var i=0; i< ct; i++){ | |
| 2033 | - post_id = postidob[i].value; | |
| 2034 | - sku = skuob[i].value; | |
| 2035 | - itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val(); | |
| 2036 | - zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2037 | - | |
| 2038 | - quant = $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2039 | - if( $("input[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']") ){ | |
| 2040 | - if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 2041 | - mes += <?php _e("'enter the correct amount for the No.' + (i+1) + ' item'", 'usces'); ?>+"\n"; | |
| 2042 | - } | |
| 2043 | - var checknum = ''; | |
| 2044 | - var checkmode = ''; | |
| 2045 | - if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2046 | - checknum = itemRestriction; | |
| 2047 | - checkmode ='rest'; | |
| 2048 | - } else if( parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2049 | - checknum = zaikonum; | |
| 2050 | - checkmode ='zaiko'; | |
| 2051 | - } else if( (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) { | |
| 2052 | - checknum = zaikonum; | |
| 2053 | - checkmode ='zaiko'; | |
| 2054 | - } else if( itemRestriction != '' && itemRestriction != '0' && zaikonum == '' ) { | |
| 2055 | - checknum = itemRestriction; | |
| 2056 | - checkmode ='rest'; | |
| 2057 | - } | |
| 2058 | - | |
| 2059 | - if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 2060 | - if(checkmode == 'rest'){ | |
| 2061 | - mes += <?php _e("'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces'); ?>+"\n"; | |
| 2062 | - }else{ | |
| 2063 | - mes += <?php _e("'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces'); ?>+"\n"; | |
| 2064 | - } | |
| 2065 | - } | |
| 2066 | - } | |
| 2067 | - } | |
| 2068 | - if( mes != '' ){ | |
| 2069 | - alert( mes ); | |
| 2070 | - return false; | |
| 2071 | - }else{ | |
| 2072 | - return true; | |
| 2073 | - } | |
| 2074 | - }, | |
| 2075 | - | |
| 2076 | - previousCart : function () { | |
| 2077 | - location.href = uscesL10n.previous_url; | |
| 2078 | - }, | |
| 2079 | - | |
| 2080 | - settings: { | |
| 2081 | - url: uscesL10n.ajaxurl, | |
| 2082 | - type: 'POST', | |
| 2083 | - cache: false, | |
| 2084 | - success: function(data, dataType){ | |
| 2085 | - //$("tbody#item-opt-list").html( data ); | |
| 2086 | - }, | |
| 2087 | - error: function(msg){ | |
| 2088 | - //$("#ajax-response").html(msg); | |
| 2089 | - } | |
| 2090 | - }, | |
| 2091 | - | |
| 2092 | - changeStates : function( country ) { | |
| 2093 | - var s = this.settings; | |
| 2094 | - s.data = "action=change_states_ajax&country=" + country; | |
| 2095 | - s.success = function(data, dataType){ | |
| 2096 | - if( 'error' == data ){ | |
| 2097 | - alert('error'); | |
| 2098 | - }else{ | |
| 2099 | - $("select#pref").html( data ); | |
| 2100 | - } | |
| 2101 | - }; | |
| 2102 | - s.error = function(msg){ | |
| 2103 | - alert("error"); | |
| 2104 | - }; | |
| 2105 | - $.ajax( s ); | |
| 2106 | - return false; | |
| 2107 | - }, | |
| 2108 | - | |
| 2109 | - isNum : function (num) { | |
| 2110 | - if (num.match(/[^0-9]/g)) { | |
| 2111 | - return false; | |
| 2112 | - } | |
| 2113 | - return true; | |
| 2114 | - }, | |
| 2115 | - purchase : 0 | |
| 2116 | - }; | |
| 2117 | - $("#country").change(function () { | |
| 2118 | - var country = $("#country option:selected").val(); | |
| 2119 | - $("#newcharging_type option:selected").val() | |
| 2120 | - uscesCart.changeStates( country ); | |
| 2121 | - }); | |
| 2122 | - $("#purchase_form").submit(function () { | |
| 2123 | - if( 0 == uscesCart.purchase ){ | |
| 2124 | - uscesCart.purchase = 1; | |
| 2125 | - return true; | |
| 2126 | - }else{ | |
| 2127 | - $("#purchase_button").attr("disabled", "disabled"); | |
| 2128 | - $("#back_button").attr("disabled", "disabled"); | |
| 2129 | - return false; | |
| 2130 | - } | |
| 2131 | - }); | |
| 2132 | - | |
| 2133 | - })(jQuery); | |
| 2134 | - </script> | |
| 2135 | - <?php endif; ?> | |
| 2136 | -<?php | |
| 2137 | - usces_states_form_js(); | |
| 2138 | - } | |
| 2139 | - | |
| 2140 | - function admin_head() { | |
| 2141 | - global $wp_version; | |
| 2142 | - $payments_str = ''; | |
| 2143 | - $payments = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 2144 | - foreach ( (array)$payments as $id => $array ) { | |
| 2145 | - $payments_str .= "'" . esc_js($array['name']) . "': '" . esc_js($array['settlement']) . "', "; | |
| 2146 | - } | |
| 2147 | - $payments_str .= "'" . __('Transfer (prepayment)', 'usces') . "': 'transferAdvance', "; | |
| 2148 | - $payments_str .= "'" . __('Transfer (postpay)', 'usces') . "': 'transferDeferred', "; | |
| 2149 | - $payments_str .= "'" . __('COD', 'usces') . "': 'COD', "; | |
| 2150 | - $payments_str = rtrim($payments_str, ', '); | |
| 2151 | - $wcex_str = ''; | |
| 2152 | - $wcex = usces_get_wcex(); | |
| 2153 | - foreach ( (array)$wcex as $key => $values ) { | |
| 2154 | - $wcex_str .= "'" . esc_js($key) . "-" . esc_js($values['version']) . "', "; | |
| 2155 | - } | |
| 2156 | - $wcex_str = rtrim($wcex_str, ', '); | |
| 2157 | - if ( version_compare($wp_version, '3.4', '>=') ){ | |
| 2158 | - $theme_ob = wp_get_theme(); | |
| 2159 | - $theme['Name'] = esc_js($theme_ob->get('Name')); | |
| 2160 | - $theme['Version'] = esc_js($theme_ob->get('Version')); | |
| 2161 | - }else{ | |
| 2162 | - $theme = get_theme_data( get_stylesheet_directory().'/style.css' );//20120618ysk | |
| 2163 | - } | |
| 2164 | -?> | |
| 2165 | - | |
| 2166 | - <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" /> | |
| 2167 | - <script type='text/javascript'> | |
| 2168 | - /* <![CDATA[ */ | |
| 2169 | - uscesL10n = { | |
| 2170 | - 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php", | |
| 2171 | - 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>", | |
| 2172 | - 'version': "<?php echo USCES_VERSION; ?>", | |
| 2173 | - 'wcid': "<?php echo get_option('usces_wcid'); ?>", | |
| 2174 | - 'locale': '<?php echo get_locale(); ?>', | |
| 2175 | - 'cart_number': "<?php echo get_option('usces_cart_number'); ?>", | |
| 2176 | - 'purchase_limit': "<?php echo $this->options['purchase_limit']; ?>", | |
| 2177 | - 'point_rate': "<?php echo $this->options['point_rate']; ?>", | |
| 2178 | - 'shipping_rule': "<?php echo $this->options['shipping_rule']; ?>", | |
| 2179 | - 'theme': "<?php echo $theme['Name'] . '-' . $theme['Version']; ?>", | |
| 2180 | - 'wcex': new Array( <?php echo $wcex_str; ?> ), | |
| 2181 | - 'now_loading': "<?php _e('now loading', 'usces'); ?>" | |
| 2182 | - }; | |
| 2183 | - uscesPayments = {<?php echo $payments_str; ?>}; | |
| 2184 | - /* ]]> */ | |
| 2185 | - </script> | |
| 2186 | - <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js'></script> | |
| 2187 | -<?php | |
| 2188 | - if($this->action_status == 'edit' || $this->action_status == 'editpost'){ | |
| 2189 | -?> | |
| 2190 | - <link rel='stylesheet' href='<?php echo get_option('siteurl'); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' /> | |
| 2191 | -<?php | |
| 2192 | - } | |
| 2193 | - if( isset($_REQUEST['page']) ){ | |
| 2194 | - switch( $_REQUEST['page'] ){ | |
| 2195 | - case 'usces_initial': | |
| 2196 | -?> | |
| 2197 | - <script type='text/javascript'> | |
| 2198 | - /* <![CDATA[ */ | |
| 2199 | - usces_ini = { | |
| 2200 | - 'cod_type': "<?php if( 'change' == $this->options['cod_type'] ) {echo 'change';}else{echo 'fix';} ?>", | |
| 2201 | - 'cod_type_fix': "<?php echo esc_js(__('Fixation C.O.D.', 'usces')); ?>", | |
| 2202 | - 'cod_type_change': "<?php echo esc_js(__('Variable C.O.D.', 'usces')); ?>", | |
| 2203 | - 'cod_unit': "<?php echo esc_js(__('dollars', 'usces')); ?>", | |
| 2204 | - 'cod_failure': "<?php echo esc_js(__('failure in update', 'usces')); ?>", | |
| 2205 | - 'cod_updated': "<?php echo esc_js(__('options are updated', 'usces')); ?>", | |
| 2206 | - 'cod_limit': "<?php echo esc_js(__('A value of the amount of upper limit is dirty.', 'usces')); ?>" | |
| 2207 | - }; | |
| 2208 | -/* ]]> */ | |
| 2209 | - </script> | |
| 2210 | -<?php | |
| 2211 | - break; | |
| 2212 | - case 'usces_itemnew': | |
| 2213 | - case 'usces_itemedit': | |
| 2214 | -?> | |
| 2215 | - <style type="text/css"> | |
| 2216 | - <!-- | |
| 2217 | - #usces_mess { | |
| 2218 | - color: #FF0000; | |
| 2219 | - font-weight: bold; | |
| 2220 | - } | |
| 2221 | - --> | |
| 2222 | - </style> | |
| 2223 | -<?php | |
| 2224 | - break; | |
| 2225 | - } | |
| 2226 | - } | |
| 2227 | -?> | |
| 2228 | -<?php | |
| 2229 | - if( is_admin() && ( (isset($_GET['order_action']) && 'newpost' == $_GET['order_action']) | |
| 2230 | - || (isset($_GET['page']) && 'usces_ordernew' == $_GET['page']) | |
| 2231 | - || (isset($_GET['order_action']) && 'edit' == $_GET['order_action']) | |
| 2232 | - || (isset($_GET['order_action']) && 'editpost' == $_GET['order_action']) | |
| 2233 | - || (isset($_GET['member_action']) && 'edit' == $_GET['member_action']) | |
| 2234 | - || (isset($_GET['member_action']) && 'editpost' == $_GET['member_action'])) ) : | |
| 2235 | - switch( $_GET['page'] ){ | |
| 2236 | - case 'usces_ordernew': | |
| 2237 | - case 'usces_orderlist': | |
| 2238 | - $admin_page = 'order'; | |
| 2239 | - break; | |
| 2240 | - case 'usces_memberlist': | |
| 2241 | - $admin_page = 'member'; | |
| 2242 | - break; | |
| 2243 | - } | |
| 2244 | -?> | |
| 2245 | - <script type='text/javascript'> | |
| 2246 | - jQuery(function($) { | |
| 2247 | - uscesForm = { | |
| 2248 | - settings: { | |
| 2249 | - url: uscesL10n.requestFile, | |
| 2250 | - type: 'POST', | |
| 2251 | - cache: false, | |
| 2252 | - success: function(data, dataType){ | |
| 2253 | - //$("tbody#item-opt-list").html( data ); | |
| 2254 | - }, | |
| 2255 | - error: function(msg){ | |
| 2256 | - //$("#ajax-response").html(msg); | |
| 2257 | - } | |
| 2258 | - }, | |
| 2259 | - | |
| 2260 | - changeStates : function( country, type ) { | |
| 2261 | - var s = this.settings; | |
| 2262 | - s.data = "action=change_states_ajax&country=" + country; | |
| 2263 | - s.success = function(data, dataType){ | |
| 2264 | - if( 'error' == data ){ | |
| 2265 | - alert('error'); | |
| 2266 | - }else{ | |
| 2267 | - $("select#" + type + "_pref").html( data ); | |
| 2268 | - if( customercountry == country && 'customer' == type ){ | |
| 2269 | - $("#" + type + "_pref").attr({selectedIndex:customerstate}); | |
| 2270 | - }else if( deliverycountry == country && 'delivery' == type ){ | |
| 2271 | - $("#" + type + "_pref").attr({selectedIndex:deliverystate}); | |
| 2272 | - }else if( customercountry == country && 'member' == type ){ | |
| 2273 | - $("#" + type + "_pref").attr({selectedIndex:customerstate}); | |
| 2274 | - } | |
| 2275 | - } | |
| 2276 | - }; | |
| 2277 | - s.error = function(msg){ | |
| 2278 | - alert("error"); | |
| 2279 | - }; | |
| 2280 | - $.ajax( s ); | |
| 2281 | - return false; | |
| 2282 | - }, | |
| 2283 | - | |
| 2284 | - isNum : function (num) { | |
| 2285 | - if (num.match(/[^0-9]/g)) { | |
| 2286 | - return false; | |
| 2287 | - } | |
| 2288 | - return true; | |
| 2289 | - } | |
| 2290 | - }; | |
| 2291 | -<?php | |
| 2292 | - if( 'order' == $admin_page ){ | |
| 2293 | -?> | |
| 2294 | - if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) { | |
| 2295 | - var customerstate = $("#customer_pref").get(0).selectedIndex; | |
| 2296 | - var customercountry = $("#customer_country").val(); | |
| 2297 | - var deliverystate = $("#delivery_pref").get(0).selectedIndex; | |
| 2298 | - var deliverycountry = $("#delivery_country").val(); | |
| 2299 | - | |
| 2300 | - $("#customer_country").change(function () { | |
| 2301 | - var country = $("#customer_country option:selected").val(); | |
| 2302 | - uscesForm.changeStates( country, 'customer' ); | |
| 2303 | - }); | |
| 2304 | - $("#delivery_country").change(function () { | |
| 2305 | - var country = $("#delivery_country option:selected").val(); | |
| 2306 | - uscesForm.changeStates( country, 'delivery' ); | |
| 2307 | - }); | |
| 2308 | - } | |
| 2309 | -<?php | |
| 2310 | - }else if( 'member' == $admin_page ){ | |
| 2311 | -?> | |
| 2312 | - if( undefined != $("#member_pref").get(0) ) { | |
| 2313 | - var customerstate = $("#member_pref").get(0).selectedIndex; | |
| 2314 | - var customercountry = $("#member_country").val(); | |
| 2315 | - var deliverystate = ''; | |
| 2316 | - var deliverycountry = ''; | |
| 2317 | - | |
| 2318 | - $("#member_country").change(function () { | |
| 2319 | - var country = $("#member_country option:selected").val(); | |
| 2320 | - uscesForm.changeStates( country, 'member' ); | |
| 2321 | - }); | |
| 2322 | - } | |
| 2323 | -<?php | |
| 2324 | - } | |
| 2325 | -?> | |
| 2326 | - }); | |
| 2327 | - </script> | |
| 2328 | -<?php | |
| 2329 | - endif; | |
| 2330 | -} | |
| 2331 | - | |
| 2332 | - function main() { | |
| 2333 | - global $wpdb, $wp_locale, $wp_version, $post_ID; | |
| 2334 | - global $wp_query, $usces_action, $post, $action, $editing; | |
| 2335 | - | |
| 2336 | - update_option('usces_shipping_rule', apply_filters('usces_filter_shipping_rule', get_option('usces_shipping_rule'))); | |
| 2337 | - $this->shipping_rule = get_option('usces_shipping_rule'); | |
| 2338 | - | |
| 2339 | -// $_wp_http_referer = isset($_POST['_wp_http_referer']) ? $_POST['_wp_http_referer'] : 'a'; | |
| 2340 | -// if( isset($_POST) && 1 !== preg_match('/(?:plugin|theme)-editor\.php/', $_wp_http_referer) ){ | |
| 2341 | -// $_POST = $this->stripslashes_deep_post($_POST); | |
| 2342 | -// } | |
| 2343 | - | |
| 2344 | - if( !is_admin() ){ | |
| 2345 | - $this->usces_cookie(); | |
| 2346 | - } | |
| 2347 | - $this->make_url(); | |
| 2348 | - | |
| 2349 | -//usces_log('HTTP_REFERER : '.$_SERVER['HTTP_REFERER'], 'acting_transaction.log'); | |
| 2350 | -//usces_log('REQUEST_URI : '.$_SERVER['REQUEST_URI'], 'acting_transaction.log'); | |
| 2351 | - | |
| 2352 | - do_action('usces_main'); | |
| 2353 | - $this->update_table(); | |
| 2354 | - | |
| 2355 | - | |
| 2356 | -// if( 'customer' == $this->page ){ | |
| 2357 | -// header("Pragma: private"); | |
| 2358 | -// header("Cache-Control: private"); | |
| 2359 | -// }else{ | |
| 2360 | -// header("Pragma: no-cache"); | |
| 2361 | -// header("Cache-Control: no-cache"); | |
| 2362 | -// } | |
| 2363 | - | |
| 2364 | - | |
| 2365 | - //var_dump($_REQUEST); | |
| 2366 | - require_once(USCES_PLUGIN_DIR . '/classes/cart.class.php'); | |
| 2367 | - $this->cart = new usces_cart(); | |
| 2368 | - | |
| 2369 | - do_action('usces_after_cart_instant'); | |
| 2370 | - | |
| 2371 | - if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate' ){ | |
| 2372 | - $post_id = (int)$_GET['post']; | |
| 2373 | - $new_id = usces_item_dupricate($post_id); | |
| 2374 | - $ref = isset($_REQUEST['usces_referer']) ? urlencode($_REQUEST['usces_referer']) : ''; | |
| 2375 | - $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref; | |
| 2376 | - wp_redirect($url); | |
| 2377 | - exit; | |
| 2378 | - }else if( isset($_REQUEST['page']) && $_REQUEST['page'] == 'usces_itemedit' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'itemcsv' ){ | |
| 2379 | - $filename = usces_item_uploadcsv(); | |
| 2380 | - $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register®file='.$filename; | |
| 2381 | - wp_redirect($url); | |
| 2382 | - exit; | |
| 2383 | - } | |
| 2384 | -//20110208ysk start | |
| 2385 | - if('on' == $this->options['acting_settings']['paypal']['ec_activate']) { | |
| 2386 | - require_once(USCES_PLUGIN_DIR . '/classes/paymentPaypal.class.php'); | |
| 2387 | - $this->paypal = new usces_paypal(); | |
| 2388 | - } | |
| 2389 | -//20110208ysk end | |
| 2390 | - | |
| 2391 | - $this->ad_controller(); | |
| 2392 | - //$this->controller(); | |
| 2393 | - | |
| 2394 | - | |
| 2395 | - | |
| 2396 | - if( isset($_GET['page']) && $_GET['page'] == 'usces_itemnew'){ | |
| 2397 | - $itemnew = 'new'; | |
| 2398 | - }else{ | |
| 2399 | - $itemnew = ''; | |
| 2400 | - } | |
| 2401 | - | |
| 2402 | - wp_enqueue_script('jquery'); | |
| 2403 | - | |
| 2404 | - if( is_admin() && isset($_REQUEST['page']) && ((isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') || $itemnew == 'new' || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'editpost'))) { | |
| 2405 | - | |
| 2406 | - if(isset($_REQUEST['action']) && $_REQUEST['action'] != 'editpost' && $itemnew == 'new'){ | |
| 2407 | - if ( version_compare($wp_version, '3.0-beta', '>') ){ | |
| 2408 | - if ( !isset($_GET['post_type']) ) | |
| 2409 | - $post_type = 'post'; | |
| 2410 | - elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) | |
| 2411 | - $post_type = $_GET['post_type']; | |
| 2412 | - else | |
| 2413 | - wp_die( __('Invalid post type') ); | |
| 2414 | - $post_type_object = get_post_type_object($post_type); | |
| 2415 | - $editing = true; | |
| 2416 | -// if ( current_user_can($post_type_object->edit_type_cap) ) { | |
| 2417 | - $post = $this->get_default_post_to_edit30( $post_type, true ); | |
| 2418 | - $post_ID = $post->ID; | |
| 2419 | -// } | |
| 2420 | - | |
| 2421 | - }else{ | |
| 2422 | - $post = $this->get_default_post_to_edit(); | |
| 2423 | - } | |
| 2424 | - }else{ | |
| 2425 | - if ( version_compare($wp_version, '3.0-beta', '>') ){ | |
| 2426 | - if ( isset($_GET['post']) ) | |
| 2427 | - $post_id = (int) $_GET['post']; | |
| 2428 | - elseif ( isset($_POST['post_ID']) ) | |
| 2429 | - $post_id = (int) $_POST['post_ID']; | |
| 2430 | - else | |
| 2431 | - $post_id = 0; | |
| 2432 | - $post_ID = $post_id; | |
| 2433 | - $post = null; | |
| 2434 | - $post_type_object = null; | |
| 2435 | - $post_type = null; | |
| 2436 | - if ( $post_id ) { | |
| 2437 | - $post = get_post($post_id); | |
| 2438 | - if ( $post ) { | |
| 2439 | - $post_type_object = get_post_type_object($post->post_type); | |
| 2440 | - if ( $post_type_object ) { | |
| 2441 | - $post_type = $post->post_type; | |
| 2442 | - $current_screen->post_type = $post->post_type; | |
| 2443 | - $current_screen->id = $current_screen->post_type; | |
| 2444 | - } | |
| 2445 | - } | |
| 2446 | - } elseif ( isset($_POST['post_type']) ) { | |
| 2447 | - $post_type_object = get_post_type_object($_POST['post_type']); | |
| 2448 | - if ( $post_type_object ) { | |
| 2449 | - $post_type = $post_type_object->name; | |
| 2450 | - $current_screen->post_type = $post_type; | |
| 2451 | - $current_screen->id = $current_screen->post_type; | |
| 2452 | - } | |
| 2453 | - } | |
| 2454 | - | |
| 2455 | - | |
| 2456 | -// $post = get_post( $post_id, OBJECT, 'edit' ); | |
| 2457 | -// if ( $post->post_type == 'page' ) | |
| 2458 | -// $post->page_template = get_post_meta( $id, '_wp_page_template', true ); | |
| 2459 | - | |
| 2460 | - }else{ | |
| 2461 | - if(isset($_GET['post'])){ | |
| 2462 | - $post_ID = (int) $_GET['post']; | |
| 2463 | - $post = get_post($post_ID); | |
| 2464 | - }else{ | |
| 2465 | - $post_ID = isset($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : 0; | |
| 2466 | - if(!empty($post_ID)) | |
| 2467 | - $post = get_post($post_ID); | |
| 2468 | - } | |
| 2469 | - } | |
| 2470 | -// global $wp_query, $usces_action, $post; | |
| 2471 | - | |
| 2472 | - } | |
| 2473 | - $editing = true; | |
| 2474 | - wp_enqueue_script('autosave'); | |
| 2475 | - wp_enqueue_script('post'); | |
| 2476 | - //if ( user_can_richedit() ) | |
| 2477 | - //wp_enqueue_script('editor'); | |
| 2478 | - add_thickbox(); | |
| 2479 | - wp_enqueue_script('media-upload'); | |
| 2480 | - wp_enqueue_script('word-count'); | |
| 2481 | - wp_enqueue_script( 'admin-comments' ); | |
| 2482 | - | |
| 2483 | - if ( version_compare($wp_version, '3.3', '<') ) | |
| 2484 | - add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); | |
| 2485 | - wp_enqueue_script('quicktags'); | |
| 2486 | - | |
| 2487 | - } | |
| 2488 | - | |
| 2489 | - | |
| 2490 | - if( is_admin() && isset($_REQUEST['page']) ){ | |
| 2491 | - | |
| 2492 | - wp_enqueue_script('jquery-color'); | |
| 2493 | - | |
| 2494 | - switch( $_REQUEST['page'] ){ | |
| 2495 | - | |
| 2496 | - case 'usces_initial': | |
| 2497 | - $js = USCES_FRONT_PLUGIN_URL.'/js/usces_initial.js'; | |
| 2498 | - wp_enqueue_script('usces_initial.js', $js, array('jquery-ui-dialog', 'jquery-ui-sortable')); | |
| 2499 | - //wp_enqueue_script('jquery-ui-sortable'); | |
| 2500 | - break; | |
| 2501 | - | |
| 2502 | - case 'usces_settlement': | |
| 2503 | - wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core')); | |
| 2504 | - $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js'; | |
| 2505 | - wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0' ); | |
| 2506 | -// $item_list_layoutUrl = USCES_FRONT_PLUGIN_URL.'/js/usces_dumy.js'; | |
| 2507 | -// wp_enqueue_script('usces_dumy', $item_list_layoutUrl, array('jquery-ui-tabs'), '1.0' ); | |
| 2508 | - break; | |
| 2509 | -//20100809ysk start | |
| 2510 | - case 'usces_cart': | |
| 2511 | - wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core')); | |
| 2512 | - $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js'; | |
| 2513 | - wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0'); | |
| 2514 | - break; | |
| 2515 | -//20100809ysk end | |
| 2516 | -//20100818ysk start | |
| 2517 | - case 'usces_member': | |
| 2518 | - wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core')); | |
| 2519 | - $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js'; | |
| 2520 | - wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0'); | |
| 2521 | - break; | |
| 2522 | -//20100818ysk end | |
| 2523 | -//20100908ysk start | |
| 2524 | - case 'usces_orderlist': | |
| 2525 | - case 'usces_ordernew': | |
| 2526 | - wp_enqueue_script('jquery-ui-dialog'); | |
| 2527 | - break; | |
| 2528 | - case 'usces_memberlist': | |
| 2529 | - wp_enqueue_script('jquery-ui-dialog'); | |
| 2530 | - break; | |
| 2531 | -//20100908ysk end | |
| 2532 | -//20101111ysk start | |
| 2533 | - case 'usces_itemnew': | |
| 2534 | - wp_enqueue_script('jquery-ui-sortable'); | |
| 2535 | - break; | |
| 2536 | - case 'usces_itemedit': | |
| 2537 | - if( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ){ | |
| 2538 | - ob_end_clean(); | |
| 2539 | - ob_start(); | |
| 2540 | - }else{ | |
| 2541 | - wp_enqueue_script('jquery-ui-sortable'); | |
| 2542 | - wp_enqueue_script('jquery-ui-dialog'); | |
| 2543 | - } | |
| 2544 | - break; | |
| 2545 | -//20101111ysk end | |
| 2546 | -//20101208ysk start | |
| 2547 | - case 'usces_delivery': | |
| 2548 | - wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core')); | |
| 2549 | - $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js'; | |
| 2550 | - wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0'); | |
| 2551 | - break; | |
| 2552 | -//20101208ysk end | |
| 2553 | -//20110331ysk start | |
| 2554 | - case 'usces_system': | |
| 2555 | - wp_enqueue_script('jquery-ui-tabs', array('jquery-ui-core')); | |
| 2556 | - $jquery_cookieUrl = USCES_FRONT_PLUGIN_URL.'/js/jquery.cookie.js'; | |
| 2557 | - wp_enqueue_script('jquery-cookie', $jquery_cookieUrl, array('jquery'), '1.0'); | |
| 2558 | - break; | |
| 2559 | -//20110331ysk end | |
| 2560 | - } | |
| 2561 | - } | |
| 2562 | - | |
| 2563 | - if( isset($_REQUEST['order_action']) && $_REQUEST['order_action'] == 'pdfout' ){ | |
| 2564 | - $this->get_current_member(); | |
| 2565 | - $mid = $this->current_member['id']; | |
| 2566 | - $oid = $_GET['order_id']; | |
| 2567 | - if( !is_user_logged_in() && !$this->is_order($mid, $oid) ) | |
| 2568 | - die('No permission'); | |
| 2569 | - require_once( apply_filters('usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php') ); | |
| 2570 | - } | |
| 2571 | - | |
| 2572 | - do_action( 'usces_after_main' ); | |
| 2573 | - } | |
| 2574 | - | |
| 2575 | - function stripslashes_deep_post( $array ){ | |
| 2576 | - $res = array(); | |
| 2577 | - foreach( $array as $key => $value ){ | |
| 2578 | - $key = stripslashes($key); | |
| 2579 | - if( is_array($value) ){ | |
| 2580 | - $value = $this->stripslashes_deep_post( $value ); | |
| 2581 | - }else{ | |
| 2582 | - $value = stripslashes($value); | |
| 2583 | - } | |
| 2584 | - $res[$key] = $value; | |
| 2585 | - } | |
| 2586 | - return $res; | |
| 2587 | - } | |
| 2588 | - | |
| 2589 | - function make_url(){ | |
| 2590 | - | |
| 2591 | - $permalink_structure = get_option('permalink_structure'); | |
| 2592 | -//usces_log('use_ssl : '.$this->use_ssl, 'acting_transaction.log'); | |
| 2593 | - if($this->use_ssl) { | |
| 2594 | - if( $permalink_structure ){ | |
| 2595 | - $this->delim = '&'; | |
| 2596 | - $home_perse = parse_url(get_option('home')); | |
| 2597 | - $home_perse_path = isset($home_perse['path']) ? $home_perse['path'] : ''; | |
| 2598 | - $home_path = $home_perse['host'].$home_perse_path; | |
| 2599 | - $ssl_perse = parse_url($this->options['ssl_url']); | |
| 2600 | - $ssl_perse_path = isset($ssl_perse['path']) ? $ssl_perse['path'] : ''; | |
| 2601 | - $ssl_path = $ssl_perse['host'].$ssl_perse_path; | |
| 2602 | - if( $home_perse_path != $ssl_perse_path ){ | |
| 2603 | - if( ! defined('USCES_CUSTOMER_URL') ) | |
| 2604 | - define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid()); | |
| 2605 | - if( ! defined('USCES_CART_URL') ) | |
| 2606 | - define('USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid()); | |
| 2607 | - if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') ) | |
| 2608 | - define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword'); | |
| 2609 | - if( ! defined('USCES_NEWMEMBER_URL') ) | |
| 2610 | - define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember'); | |
| 2611 | - if( ! defined('USCES_LOGIN_URL') ) | |
| 2612 | - define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login'); | |
| 2613 | - if( ! defined('USCES_LOGOUT_URL') ) | |
| 2614 | - define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout'); | |
| 2615 | - if( ! defined('USCES_MEMBER_URL') ) | |
| 2616 | - define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid()); | |
| 2617 | - $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid(); | |
| 2618 | - if( ! defined('USCES_INQUIRY_URL') ) | |
| 2619 | - define('USCES_INQUIRY_URL', $inquiry_url); | |
| 2620 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2621 | - define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER); | |
| 2622 | -//20110208ysk start | |
| 2623 | - //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2624 | - if( ! defined('USCES_PAYPAL_NOTIFY_URL') ) | |
| 2625 | - define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2626 | -//20110208ysk end | |
| 2627 | - }else{ | |
| 2628 | - $ssl_plink_cart = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_CART_NUMBER) )); | |
| 2629 | - $ssl_plink_member = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link(USCES_MEMBER_NUMBER) )); | |
| 2630 | - if( ! defined('USCES_CUSTOMER_URL') ) | |
| 2631 | - define('USCES_CUSTOMER_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid() . '&customerinfo=1'); | |
| 2632 | - if( ! defined('USCES_CART_URL') ) | |
| 2633 | - define('USCES_CART_URL', $ssl_plink_cart . '?uscesid=' . $this->get_uscesid()); | |
| 2634 | - if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') ) | |
| 2635 | - define('USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword'); | |
| 2636 | - if( ! defined('USCES_NEWMEMBER_URL') ) | |
| 2637 | - define('USCES_NEWMEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid(). '&page=newmember'); | |
| 2638 | - if( ! defined('USCES_LOGIN_URL') ) | |
| 2639 | - define('USCES_LOGIN_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=login'); | |
| 2640 | - if( ! defined('USCES_LOGOUT_URL') ) | |
| 2641 | - define('USCES_LOGOUT_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid() . '&page=logout'); | |
| 2642 | - if( ! defined('USCES_MEMBER_URL') ) | |
| 2643 | - define('USCES_MEMBER_URL', $ssl_plink_member . '?uscesid=' . $this->get_uscesid()); | |
| 2644 | - if( !isset($this->options['inquiry_id']) || !( (int)$this->options['inquiry_id'] ) ){ | |
| 2645 | - $inquiry_url = get_home_url(); | |
| 2646 | - }else{ | |
| 2647 | - $ssl_plink_inquiry = str_replace('http://','https://', str_replace( $home_path, $ssl_path, get_page_link($this->options['inquiry_id']) )); | |
| 2648 | - $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry . '?uscesid=' . $this->get_uscesid(); | |
| 2649 | - } | |
| 2650 | - if( ! defined('USCES_INQUIRY_URL') ) | |
| 2651 | - define('USCES_INQUIRY_URL', $inquiry_url); | |
| 2652 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2653 | - define('USCES_CART_NONSESSION_URL', $ssl_plink_cart); | |
| 2654 | -//20110208ysk start | |
| 2655 | - //define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2656 | - if( ! defined('USCES_PAYPAL_NOTIFY_URL') ) | |
| 2657 | - define('USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2658 | -//20110208ysk end | |
| 2659 | - } | |
| 2660 | - }else{ | |
| 2661 | - $this->delim = '&'; | |
| 2662 | - if( ! defined('USCES_CUSTOMER_URL') ) | |
| 2663 | - define('USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1&uscesid=' . $this->get_uscesid()); | |
| 2664 | - if( ! defined('USCES_CART_URL') ) | |
| 2665 | - define('USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&uscesid=' . $this->get_uscesid()); | |
| 2666 | - if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') ) | |
| 2667 | - define('USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=lostmemberpassword'); | |
| 2668 | - if( ! defined('USCES_NEWMEMBER_URL') ) | |
| 2669 | - define('USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=newmember'); | |
| 2670 | - if( ! defined('USCES_LOGIN_URL') ) | |
| 2671 | - define('USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=login'); | |
| 2672 | - if( ! defined('USCES_LOGOUT_URL') ) | |
| 2673 | - define('USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid() . '&page=logout'); | |
| 2674 | - if( ! defined('USCES_MEMBER_URL') ) | |
| 2675 | - define('USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&uscesid=' . $this->get_uscesid()); | |
| 2676 | - $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id'] . '&uscesid=' . $this->get_uscesid(); | |
| 2677 | - if( ! defined('USCES_INQUIRY_URL') ) | |
| 2678 | - define('USCES_INQUIRY_URL', $inquiry_url); | |
| 2679 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2680 | - define('USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER); | |
| 2681 | -//20110208ysk start | |
| 2682 | - //define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2683 | - if( ! defined('USCES_PAYPAL_NOTIFY_URL') ) | |
| 2684 | - define('USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2685 | -//20110208ysk end | |
| 2686 | - } | |
| 2687 | - if( !is_admin() ){ | |
| 2688 | - add_filter('home_url', array($this, 'usces_ssl_page_link')); | |
| 2689 | - add_filter('wp_get_attachment_url', array($this, 'usces_ssl_attachment_link')); | |
| 2690 | - add_filter('icon_dir_uri', array($this, 'usces_ssl_icon_dir_uri')); | |
| 2691 | - add_filter('stylesheet_directory_uri', array($this, 'usces_ssl_contents_link')); | |
| 2692 | - add_filter('template_directory_uri', array($this, 'usces_ssl_contents_link')); | |
| 2693 | - add_filter('script_loader_src', array($this, 'usces_ssl_script_link')); | |
| 2694 | - add_filter('style_loader_src', array($this, 'usces_ssl_script_link')); | |
| 2695 | - } | |
| 2696 | - } else { | |
| 2697 | - if( $permalink_structure ){ | |
| 2698 | - $this->delim = '?'; | |
| 2699 | - if( ! defined('USCES_CUSTOMER_URL') ) | |
| 2700 | - define('USCES_CUSTOMER_URL', get_page_link(USCES_CART_NUMBER) . '?customerinfo=1'); | |
| 2701 | - if( ! defined('USCES_CART_URL') ) | |
| 2702 | - define('USCES_CART_URL', get_page_link(USCES_CART_NUMBER)); | |
| 2703 | - if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') ) | |
| 2704 | - define('USCES_LOSTMEMBERPASSWORD_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=lostmemberpassword'); | |
| 2705 | - if( ! defined('USCES_NEWMEMBER_URL') ) | |
| 2706 | - define('USCES_NEWMEMBER_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=newmember'); | |
| 2707 | - if( ! defined('USCES_LOGIN_URL') ) | |
| 2708 | - define('USCES_LOGIN_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=login'); | |
| 2709 | - if( ! defined('USCES_LOGOUT_URL') ) | |
| 2710 | - define('USCES_LOGOUT_URL', get_page_link(USCES_MEMBER_NUMBER) . '?page=logout'); | |
| 2711 | - if( ! defined('USCES_MEMBER_URL') ) | |
| 2712 | - define('USCES_MEMBER_URL', get_page_link(USCES_MEMBER_NUMBER)); | |
| 2713 | - $inquiry_url = ( !isset( $this->options['inquiry_id'] ) || !( (int)$this->options['inquiry_id'] )) ? get_home_url() : get_page_link($this->options['inquiry_id']); | |
| 2714 | - if( ! defined('USCES_INQUIRY_URL') ) | |
| 2715 | - define('USCES_INQUIRY_URL', $inquiry_url); | |
| 2716 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2717 | - define('USCES_CART_NONSESSION_URL', get_page_link(USCES_CART_NUMBER)); | |
| 2718 | -//20110208ysk start | |
| 2719 | - //define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2720 | - if( ! defined('USCES_PAYPAL_NOTIFY_URL') ) | |
| 2721 | - define('USCES_PAYPAL_NOTIFY_URL', get_page_link(USCES_CART_NUMBER) . '?acting=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2722 | -//20110208ysk end | |
| 2723 | - }else{ | |
| 2724 | - $this->delim = '&'; | |
| 2725 | - if( ! defined('USCES_CUSTOMER_URL') ) | |
| 2726 | - define('USCES_CUSTOMER_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1'); | |
| 2727 | - if( ! defined('USCES_CART_URL') ) | |
| 2728 | - define('USCES_CART_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER); | |
| 2729 | - if( ! defined('USCES_LOSTMEMBERPASSWORD_URL') ) | |
| 2730 | - define('USCES_LOSTMEMBERPASSWORD_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=lostmemberpassword'); | |
| 2731 | - if( ! defined('USCES_NEWMEMBER_URL') ) | |
| 2732 | - define('USCES_NEWMEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=newmember'); | |
| 2733 | - if( ! defined('USCES_LOGIN_URL') ) | |
| 2734 | - define('USCES_LOGIN_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=login'); | |
| 2735 | - if( ! defined('USCES_LOGOUT_URL') ) | |
| 2736 | - define('USCES_LOGOUT_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout'); | |
| 2737 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2738 | - define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER . '&page=logout'); | |
| 2739 | - if( ! defined('USCES_MEMBER_URL') ) | |
| 2740 | - define('USCES_MEMBER_URL', get_option('home') . '/?page_id=' . USCES_MEMBER_NUMBER); | |
| 2741 | - $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option('home') . '/?page_id=' . $this->options['inquiry_id']; | |
| 2742 | - if( ! defined('USCES_INQUIRY_URL') ) | |
| 2743 | - define('USCES_INQUIRY_URL', $inquiry_url); | |
| 2744 | - if( ! defined('USCES_CART_NONSESSION_URL') ) | |
| 2745 | - define('USCES_CART_NONSESSION_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER); | |
| 2746 | -//20110208ysk start | |
| 2747 | - //define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting_return=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2748 | - if( ! defined('USCES_PAYPAL_NOTIFY_URL') ) | |
| 2749 | - define('USCES_PAYPAL_NOTIFY_URL', get_option('home') . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn&uscesid=' . $this->get_uscesid(false)); | |
| 2750 | -//20110208ysk end | |
| 2751 | - } | |
| 2752 | - } | |
| 2753 | - } | |
| 2754 | - | |
| 2755 | - function regist_action(){ | |
| 2756 | - usces_register_action('inCart', 'post', 'inCart', NULL, 'inCart'); | |
| 2757 | - usces_register_action('upButton', 'post', 'upButton', NULL, 'upButton'); | |
| 2758 | - usces_register_action('delButton', 'post', 'delButton', NULL, 'delButton'); | |
| 2759 | - usces_register_action('backCart', 'post', 'backCart', NULL, 'backCart'); | |
| 2760 | - usces_register_action('customerinfo', 'request', 'customerinfo', NULL, 'customerinfo'); | |
| 2761 | - usces_register_action('backCustomer', 'post', 'backCustomer', NULL, 'backCustomer'); | |
| 2762 | - usces_register_action('customerlogin', 'post', 'customerlogin', NULL, 'customerlogin'); | |
| 2763 | - usces_register_action('reganddeliveryinfo', 'post', 'reganddeliveryinfo', NULL, 'reganddeliveryinfo'); | |
| 2764 | - usces_register_action('deliveryinfo', 'post', 'deliveryinfo', NULL, 'deliveryinfo'); | |
| 2765 | - usces_register_action('backDelivery', 'post', 'backDelivery', NULL, 'backDelivery'); | |
| 2766 | - usces_register_action('confirm', 'request', 'confirm', NULL, 'confirm'); | |
| 2767 | - usces_register_action('use_point', 'post', 'use_point', NULL, 'use_point'); | |
| 2768 | - usces_register_action('backConfirm', 'post', 'backConfirm', NULL, 'backConfirm'); | |
| 2769 | - usces_register_action('purchase', 'request', 'purchase', NULL, 'purchase'); | |
| 2770 | - usces_register_action('acting_return', 'request', 'acting_return', NULL, 'acting_return'); | |
| 2771 | - usces_register_action('settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon'); | |
| 2772 | - usces_register_action('inquiry_button', 'post', 'inquiry_button', NULL, 'inquiry_button'); | |
| 2773 | - usces_register_action('member_login', 'request', 'member_login', NULL, 'member_login_page'); | |
| 2774 | - usces_register_action('regmember', 'request', 'regmember', NULL, 'regmember'); | |
| 2775 | - usces_register_action('editmember', 'request', 'editmember', NULL, 'editmember'); | |
| 2776 | - usces_register_action('deletemember', 'request', 'deletemember', NULL, 'deletemember'); | |
| 2777 | - usces_register_action('page_login', 'get', 'page', 'login', 'member_login_page'); | |
| 2778 | - usces_register_action('page_logout', 'get', 'page', 'logout', 'page_logout'); | |
| 2779 | - usces_register_action('page_lostmemberpassword', 'get', 'page', 'lostmemberpassword', 'page_lostmemberpassword'); | |
| 2780 | - usces_register_action('lostpassword', 'request', 'lostpassword', NULL, 'lostpassword'); | |
| 2781 | - usces_register_action('uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword'); | |
| 2782 | - usces_register_action('changepassword', 'request', 'changepassword', NULL, 'changepassword_page'); | |
| 2783 | - usces_register_action('page_newmember', 'get', 'page', 'newmember', 'page_newmember'); | |
| 2784 | - usces_register_action('usces_export', 'post', 'usces_export', NULL, 'usces_export'); | |
| 2785 | - usces_register_action('usces_import', 'post', 'usces_import', NULL, 'usces_import'); | |
| 2786 | - usces_register_action('page_search_item', 'get', 'page', 'search_item', 'page_search_item'); | |
| 2787 | - usces_register_action('front_ajax', 'post', 'usces_ajax_action', NULL, 'front_ajax'); | |
| 2788 | - } | |
| 2789 | - | |
| 2790 | - function ad_controller(){ | |
| 2791 | - global $usces_action; | |
| 2792 | - ksort($usces_action); | |
| 2793 | - //if($this->is_maintenance()){ | |
| 2794 | - if($this->is_maintenance() and !is_user_logged_in()){//0000651 | |
| 2795 | - $this->maintenance(); | |
| 2796 | - }else{ | |
| 2797 | - $action_array = array('inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer', | |
| 2798 | - 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point', | |
| 2799 | - 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login', | |
| 2800 | - 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword', | |
| 2801 | - 'uscesmode_changepassword', 'changepassword', 'page_newmember', 'usces_export', 'usces_import', | |
| 2802 | - 'page_search_item', 'front_ajax'); | |
| 2803 | - $flg = 0; | |
| 2804 | - $res = true; | |
| 2805 | - foreach( $usces_action as $handle => $action ){ | |
| 2806 | - extract($action); | |
| 2807 | - switch($type){ | |
| 2808 | - case 'post': | |
| 2809 | - if( empty($value) ){ | |
| 2810 | - if( isset($_POST[$key]) ){ | |
| 2811 | - if(in_array($handle, $action_array)){ | |
| 2812 | - $res = call_user_func(array($this, $function)); | |
| 2813 | - }else{ | |
| 2814 | - $res = call_user_func($function); | |
| 2815 | - } | |
| 2816 | - $flg = 1; | |
| 2817 | - } | |
| 2818 | - }else{ | |
| 2819 | - if( isset($_POST[$key]) && $_POST[$key] == $value ){ | |
| 2820 | - if(in_array($handle, $action_array)){ | |
| 2821 | - $res = call_user_func(array($this, $function)); | |
| 2822 | - }else{ | |
| 2823 | - $res = call_user_func($function); | |
| 2824 | - } | |
| 2825 | - $flg = 1; | |
| 2826 | - } | |
| 2827 | - } | |
| 2828 | - break; | |
| 2829 | - case 'get': | |
| 2830 | - if( empty($value) ){ | |
| 2831 | - if( isset($_GET[$key]) ){ | |
| 2832 | - if(in_array($handle, $action_array)){ | |
| 2833 | - $res = call_user_func(array($this, $function)); | |
| 2834 | - }else{ | |
| 2835 | - $res = call_user_func($function); | |
| 2836 | - } | |
| 2837 | - $flg = 1; | |
| 2838 | - } | |
| 2839 | - }else{ | |
| 2840 | - if( isset($_GET[$key]) && $_GET[$key] == $value ){ | |
| 2841 | - if(in_array($handle, $action_array)){ | |
| 2842 | - $res = call_user_func(array($this, $function)); | |
| 2843 | - }else{ | |
| 2844 | - $res = call_user_func($function); | |
| 2845 | - } | |
| 2846 | - $flg = 1; | |
| 2847 | - } | |
| 2848 | - } | |
| 2849 | - break; | |
| 2850 | - case 'request': | |
| 2851 | - if( empty($value) ){ | |
| 2852 | - if( isset($_REQUEST[$key]) ){ | |
| 2853 | - if(in_array($handle, $action_array)){ | |
| 2854 | - $res = call_user_func(array($this, $function)); | |
| 2855 | - }else{ | |
| 2856 | - $res = call_user_func($function); | |
| 2857 | - } | |
| 2858 | - $flg = 1; | |
| 2859 | - } | |
| 2860 | - }else{ | |
| 2861 | - if( isset($_REQUEST[$key]) && $_REQUEST[$key] == $value ){ | |
| 2862 | - if(in_array($handle, $action_array)){ | |
| 2863 | - $res = call_user_func(array($this, $function)); | |
| 2864 | - }else{ | |
| 2865 | - $res = call_user_func($function); | |
| 2866 | - } | |
| 2867 | - $flg = 1; | |
| 2868 | - } | |
| 2869 | - } | |
| 2870 | - break; | |
| 2871 | - } | |
| 2872 | - if( ! $res ) break; | |
| 2873 | - } | |
| 2874 | - if( !$flg ) $this->default_page(); | |
| 2875 | - } | |
| 2876 | - } | |
| 2877 | - | |
| 2878 | - //action function------------------------------------------------------------ | |
| 2879 | - function front_ajax(){ | |
| 2880 | - switch ($_POST['usces_ajax_action']){ | |
| 2881 | - case 'change_states': | |
| 2882 | - change_states_ajax(); | |
| 2883 | - break; | |
| 2884 | - } | |
| 2885 | - do_action('usces_front_ajax'); | |
| 2886 | - } | |
| 2887 | - | |
| 2888 | - function maintenance(){ | |
| 2889 | - $this->page = 'maintenance'; | |
| 2890 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2891 | - } | |
| 2892 | - | |
| 2893 | - function inCart(){ | |
| 2894 | - global $wp_query; | |
| 2895 | - $this->page = 'cart'; | |
| 2896 | - $this->incart_check(); | |
| 2897 | - $this->cart->inCart(); | |
| 2898 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2899 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 2900 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2901 | - } | |
| 2902 | - | |
| 2903 | - function upButton(){ | |
| 2904 | - global $wp_query; | |
| 2905 | - $this->page = 'cart'; | |
| 2906 | - $this->cart->upCart(); | |
| 2907 | - $this->error_message = $this->zaiko_check(); | |
| 2908 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2909 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 2910 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2911 | - } | |
| 2912 | - | |
| 2913 | - function delButton(){ | |
| 2914 | - global $wp_query; | |
| 2915 | - $this->page = 'cart'; | |
| 2916 | - $this->cart->del_row(); | |
| 2917 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2918 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 2919 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2920 | - } | |
| 2921 | - | |
| 2922 | - function backCart(){ | |
| 2923 | - global $wp_query; | |
| 2924 | - $this->page = 'cart'; | |
| 2925 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2926 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 2927 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2928 | - } | |
| 2929 | - | |
| 2930 | - function customerinfo(){ | |
| 2931 | - global $wp_query; | |
| 2932 | - if( false === $this->cart->num_row() ){ | |
| 2933 | - header('location: ' . get_option('home')); | |
| 2934 | - exit; | |
| 2935 | - } | |
| 2936 | - $this->cart->entry(); | |
| 2937 | - $this->error_message = $this->zaiko_check(); | |
| 2938 | - $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message ); | |
| 2939 | - if( WCUtils::is_blank($this->error_message) ){ | |
| 2940 | - if($this->is_member_logged_in()){ | |
| 2941 | -//20100818ysk start | |
| 2942 | - //$this->page = 'delivery'; | |
| 2943 | - $this->error_message = has_custom_customer_field_essential(); | |
| 2944 | - $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'delivery' : 'customer'; | |
| 2945 | -//20100818ysk end | |
| 2946 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 2947 | - }else{ | |
| 2948 | - $this->page = 'customer'; | |
| 2949 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 2950 | - } | |
| 2951 | - }else{ | |
| 2952 | - $this->page = 'cart'; | |
| 2953 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 2954 | - } | |
| 2955 | - if ( !$this->cart->is_order_condition() ) { | |
| 2956 | - $order_conditions = $this->get_condition(); | |
| 2957 | - $this->cart->set_order_condition($order_conditions); | |
| 2958 | - } | |
| 2959 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2960 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2961 | - } | |
| 2962 | - | |
| 2963 | - function backCustomer(){ | |
| 2964 | - global $wp_query; | |
| 2965 | - if( false === $this->cart->num_row() ){ | |
| 2966 | - header('location: ' . get_option('home')); | |
| 2967 | - exit; | |
| 2968 | - } | |
| 2969 | - $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' ); | |
| 2970 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 2971 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 2972 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 2973 | -// $this->cart->entry(); | |
| 2974 | -// $this->error_message = $this->delivery_check(); | |
| 2975 | -// $this->page = ($this->error_message == '') ? 'customer' : 'delivery'; | |
| 2976 | - } | |
| 2977 | - | |
| 2978 | - function customerlogin(){ | |
| 2979 | - global $wp_query; | |
| 2980 | - if( false === $this->cart->num_row() ){ | |
| 2981 | - header('location: ' . get_option('home')); | |
| 2982 | - exit; | |
| 2983 | - } | |
| 2984 | -//20100818ysk start | |
| 2985 | - //$this->cart->entry(); | |
| 2986 | - //$this->page = ($this->member_login() == 'member') ? 'delivery' : 'customer'; | |
| 2987 | - if($this->member_login() == 'member') { | |
| 2988 | - $this->cart->entry(); | |
| 2989 | - $this->error_message = has_custom_customer_field_essential(); | |
| 2990 | - if( WCUtils::is_blank($this->error_message) ){ | |
| 2991 | - $this->page = 'delivery'; | |
| 2992 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 2993 | - }else{ | |
| 2994 | - $this->page = 'customer'; | |
| 2995 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 2996 | - } | |
| 2997 | - } else { | |
| 2998 | - $this->cart->entry(); | |
| 2999 | - $this->page = 'customer'; | |
| 3000 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 3001 | - } | |
| 3002 | -//20100818ysk end | |
| 3003 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3004 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3005 | - } | |
| 3006 | - | |
| 3007 | - function reganddeliveryinfo(){ | |
| 3008 | - global $wp_query; | |
| 3009 | - if( false === $this->cart->num_row() ){ | |
| 3010 | - header('location: ' . get_option('home')); | |
| 3011 | - exit; | |
| 3012 | - } | |
| 3013 | - $this->cart->entry(); | |
| 3014 | -//20110715ysk start 0000203 | |
| 3015 | - //$_POST['member_regmode'] = 'newmemberfromcart'; | |
| 3016 | - if(empty($_POST['member_regmode']) or $_POST['member_regmode'] != 'editmemberfromcart') $_POST['member_regmode'] = 'newmemberfromcart'; | |
| 3017 | -//20110715ysk end | |
| 3018 | - | |
| 3019 | - if( $this->regist_member() == 'newcompletion' ){ | |
| 3020 | - $this->page = 'delivery'; | |
| 3021 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 3022 | - }else{ | |
| 3023 | - $this->page = 'customer'; | |
| 3024 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 3025 | - } | |
| 3026 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3027 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3028 | - } | |
| 3029 | - | |
| 3030 | - function deliveryinfo(){ | |
| 3031 | - global $wp_query; | |
| 3032 | - if( false === $this->cart->num_row() ){ | |
| 3033 | - header('location: ' . get_option('home')); | |
| 3034 | - exit; | |
| 3035 | - } | |
| 3036 | - $this->cart->entry(); | |
| 3037 | - $this->error_message = $this->customer_check(); | |
| 3038 | - | |
| 3039 | - if( WCUtils::is_blank($this->error_message) ){ | |
| 3040 | - $this->page = 'delivery'; | |
| 3041 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 3042 | - }else{ | |
| 3043 | - $this->page = 'customer'; | |
| 3044 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_customer'); | |
| 3045 | - } | |
| 3046 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3047 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3048 | - } | |
| 3049 | - | |
| 3050 | - function backDelivery(){ | |
| 3051 | - global $wp_query; | |
| 3052 | - if( false === $this->cart->num_row() ){ | |
| 3053 | - header('location: ' . get_option('home')); | |
| 3054 | - exit; | |
| 3055 | - } | |
| 3056 | - $this->page = 'delivery'; | |
| 3057 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 3058 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3059 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3060 | - } | |
| 3061 | - | |
| 3062 | - function confirm(){ | |
| 3063 | - global $wpdb, $wp_query; | |
| 3064 | - if( false === $this->cart->num_row() ){ | |
| 3065 | - header('location: ' . get_option('home')); | |
| 3066 | - exit; | |
| 3067 | - } | |
| 3068 | - | |
| 3069 | - $this->cart->entry(); | |
| 3070 | - $this->error_message = $this->zaiko_check(); | |
| 3071 | - if( $this->error_message != '' ){ | |
| 3072 | - $this->page = 'cart'; | |
| 3073 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 3074 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3075 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3076 | - return; | |
| 3077 | - } | |
| 3078 | - | |
| 3079 | - $this->set_reserve_pre_order_id(); | |
| 3080 | - if(isset($_POST['confirm'])){ | |
| 3081 | - $this->error_message = $this->delivery_check(); | |
| 3082 | - } | |
| 3083 | - $this->page = ( WCUtils::is_blank($this->error_message) ) ? 'confirm' : 'delivery'; | |
| 3084 | - if( WCUtils::is_blank($this->error_message) ){ | |
| 3085 | -//20120919ysk start 0000573 | |
| 3086 | - if( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) { | |
| 3087 | - unset( $_SESSION['usces_entry']['order']['usedpoint'] );//20120914ysk 0000566 | |
| 3088 | - $member_table = $wpdb->prefix."usces_member"; | |
| 3089 | - $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID']); | |
| 3090 | - $mem_point = $wpdb->get_var( $query ); | |
| 3091 | - $_SESSION['usces_member']['point'] = $mem_point; | |
| 3092 | - } | |
| 3093 | -//20120919ysk end | |
| 3094 | - $this->page = 'confirm'; | |
| 3095 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm'); | |
| 3096 | - }else{ | |
| 3097 | - $this->page = 'delivery'; | |
| 3098 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_delivery'); | |
| 3099 | - } | |
| 3100 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3101 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3102 | - } | |
| 3103 | - | |
| 3104 | - function use_point(){ | |
| 3105 | - global $wp_query; | |
| 3106 | - $this->cart->entry(); | |
| 3107 | - $this->error_message = $this->point_check( $this->cart->get_entry() ); | |
| 3108 | - $this->page = 'confirm'; | |
| 3109 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm'); | |
| 3110 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3111 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3112 | - } | |
| 3113 | - | |
| 3114 | - function backConfirm(){ | |
| 3115 | - global $wp_query; | |
| 3116 | - if( false === $this->cart->num_row() ){ | |
| 3117 | - header('location: ' . get_option('home')); | |
| 3118 | - exit; | |
| 3119 | - } | |
| 3120 | - $this->page = 'confirm'; | |
| 3121 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_confirm'); | |
| 3122 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3123 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3124 | - } | |
| 3125 | - | |
| 3126 | - function purchase(){ | |
| 3127 | - global $wp_query; | |
| 3128 | - if( false === $this->cart->num_row() ){ | |
| 3129 | - header('location: ' . get_option('home')); | |
| 3130 | - exit; | |
| 3131 | - } | |
| 3132 | - | |
| 3133 | - if( !apply_filters('usces_purchase_check', true) ) return; | |
| 3134 | - | |
| 3135 | - do_action('usces_purchase_validate'); | |
| 3136 | - $entry = $this->cart->get_entry(); | |
| 3137 | - $this->error_message = $this->zaiko_check(); | |
| 3138 | - if( WCUtils::is_blank($this->error_message) && 0 < $this->cart->num_row()){ | |
| 3139 | - $actinc_status = ''; | |
| 3140 | - $payments = $this->getPayments( $entry['order']['payment_name'] ); | |
| 3141 | - if( substr($payments['settlement'], 0, 6) == 'acting' && $entry['order']['total_full_price'] > 0 ){ | |
| 3142 | - $acting_flg = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; | |
| 3143 | - $query = ''; | |
| 3144 | - foreach($_POST as $key => $value){ | |
| 3145 | - if($key != 'purchase') | |
| 3146 | - $query .= '&' . $key . '=' . urlencode(maybe_serialize($value)); | |
| 3147 | - } | |
| 3148 | - $actinc_status = $this->acting_processing($acting_flg, $query); | |
| 3149 | - } | |
| 3150 | - | |
| 3151 | - if($actinc_status == 'error'){ | |
| 3152 | - $this->page = 'error'; | |
| 3153 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error'); | |
| 3154 | - }else{ | |
| 3155 | - $res = $this->order_processing(); | |
| 3156 | - if( 'ordercompletion' == $res ){ | |
| 3157 | - $this->page = 'ordercompletion'; | |
| 3158 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion'); | |
| 3159 | - }else{ | |
| 3160 | - $this->page = 'error'; | |
| 3161 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error'); | |
| 3162 | - } | |
| 3163 | - } | |
| 3164 | - }else{ | |
| 3165 | - $this->page = 'cart'; | |
| 3166 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_cart'); | |
| 3167 | - } | |
| 3168 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3169 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3170 | - } | |
| 3171 | - | |
| 3172 | - function acting_return(){ | |
| 3173 | - global $wp_query; | |
| 3174 | - $entry = $this->cart->get_entry(); | |
| 3175 | - | |
| 3176 | -//20110208ysk start | |
| 3177 | -/* if( 'paypal_ipn' == $_REQUEST['acting_return'] ){ | |
| 3178 | - usces_log('paypal_ipn in ', 'acting_transaction.log'); | |
| 3179 | - require_once($this->options['settlement_path'] . 'paypal.php'); | |
| 3180 | - $ipn_res = paypal_ipn_check($usces_paypal_url); | |
| 3181 | - if( $ipn_res[0] === true ){ | |
| 3182 | - $res = $this->order_processing( $ipn_res ); | |
| 3183 | - if( 'ordercompletion' == $res ){ | |
| 3184 | - $this->cart->crear_cart(); | |
| 3185 | - }else{ | |
| 3186 | - usces_log('paypal_ipn regorder error (acting_return) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 3187 | - } | |
| 3188 | - } | |
| 3189 | - exit; | |
| 3190 | - }*/ | |
| 3191 | -//20110208ysk end | |
| 3192 | - if( false === $this->cart->num_row() && ('paypal' != $_GET['acting'] && 1 !== (int)$_GET['acting_return']) ){ | |
| 3193 | - header('location: ' . get_option('home')); | |
| 3194 | - exit; | |
| 3195 | - } | |
| 3196 | - | |
| 3197 | - $this->payment_results = usces_check_acting_return(); | |
| 3198 | - | |
| 3199 | - if( isset($this->payment_results[0]) && $this->payment_results[0] === 'duplicate' ){ | |
| 3200 | - | |
| 3201 | - header('location: ' . get_option('home')); | |
| 3202 | - exit; | |
| 3203 | - | |
| 3204 | - }else if( isset($this->payment_results[0]) && $this->payment_results[0] ){//result OK | |
| 3205 | - | |
| 3206 | - if( ! $this->payment_results['reg_order'] ){//without Registration Order | |
| 3207 | - $this->page = 'ordercompletion'; | |
| 3208 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion'); | |
| 3209 | - | |
| 3210 | - }else{ | |
| 3211 | - $res = $this->order_processing( $this->payment_results ); | |
| 3212 | - | |
| 3213 | - if( 'ordercompletion' == $res ){ | |
| 3214 | - $this->page = 'ordercompletion'; | |
| 3215 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion'); | |
| 3216 | - }else{ | |
| 3217 | - $this->page = 'error'; | |
| 3218 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error'); | |
| 3219 | - } | |
| 3220 | - } | |
| 3221 | - | |
| 3222 | - }else{//result NG | |
| 3223 | - $this->page = 'error'; | |
| 3224 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error'); | |
| 3225 | - } | |
| 3226 | - | |
| 3227 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3228 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3229 | - } | |
| 3230 | - | |
| 3231 | - function settlement_epsilon(){ | |
| 3232 | - global $wp_query; | |
| 3233 | - require_once($this->options['settlement_path'] . 'epsilon.php'); | |
| 3234 | - } | |
| 3235 | - | |
| 3236 | - function inquiry_button(){ | |
| 3237 | - if( 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']) ){ | |
| 3238 | - $res = $this->inquiry_processing(); | |
| 3239 | - }else{ | |
| 3240 | - $res = 'deficiency'; | |
| 3241 | - } | |
| 3242 | - | |
| 3243 | - $this->page = $res; | |
| 3244 | - } | |
| 3245 | - | |
| 3246 | - function member_login_page(){ | |
| 3247 | - global $wp_query; | |
| 3248 | - $res = $this->member_login(); | |
| 3249 | - if( 'member' == $res ){ | |
| 3250 | - $this->page = 'member'; | |
| 3251 | - do_action('usces_action_member_logined'); | |
| 3252 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_member'); | |
| 3253 | - }elseif( 'login' == $res ){ | |
| 3254 | - $this->page = 'login'; | |
| 3255 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_login'); | |
| 3256 | - } | |
| 3257 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3258 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3259 | - } | |
| 3260 | - | |
| 3261 | - function regmember(){ | |
| 3262 | - global $wp_query; | |
| 3263 | - $res = $this->regist_member(); | |
| 3264 | - if( 'editmemberform' == $res ){ | |
| 3265 | - $this->page = 'editmemberform'; | |
| 3266 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform'); | |
| 3267 | - }elseif( 'newcompletion' == $res ){ | |
| 3268 | - $this->page = 'newcompletion'; | |
| 3269 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion'); | |
| 3270 | - }else{ | |
| 3271 | - $this->page = $res; | |
| 3272 | - } | |
| 3273 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3274 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3275 | - } | |
| 3276 | - | |
| 3277 | - function editmember(){ | |
| 3278 | - global $wp_query; | |
| 3279 | - $res = $this->regist_member(); | |
| 3280 | - if( 'editmemberform' == $res ){ | |
| 3281 | - $this->page = 'editmemberform'; | |
| 3282 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform'); | |
| 3283 | - }elseif( 'newcompletion' == $res ){ | |
| 3284 | - $this->page = 'newcompletion'; | |
| 3285 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion'); | |
| 3286 | - }else{ | |
| 3287 | - $this->page = $res; | |
| 3288 | - } | |
| 3289 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3290 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3291 | - } | |
| 3292 | - | |
| 3293 | - function deletemember(){ | |
| 3294 | - $res = $this->delete_member(); | |
| 3295 | - if( $res ){ | |
| 3296 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember'); | |
| 3297 | - $this->member_logout(); | |
| 3298 | - }else{ | |
| 3299 | - $this->page = 'editmemberform'; | |
| 3300 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3301 | - } | |
| 3302 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3303 | - } | |
| 3304 | - | |
| 3305 | - function page_logout(){ | |
| 3306 | - global $wp_query; | |
| 3307 | - $this->member_logout(); | |
| 3308 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3309 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3310 | - } | |
| 3311 | - | |
| 3312 | - function page_lostmemberpassword(){ | |
| 3313 | - global $wp_query; | |
| 3314 | - $this->page = 'lostmemberpassword'; | |
| 3315 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3316 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3317 | - } | |
| 3318 | - | |
| 3319 | - function lostpassword(){ | |
| 3320 | - global $wp_query; | |
| 3321 | - $this->error_message = $this->lostpass_mailaddcheck(); | |
| 3322 | - if ( $this->error_message != '' ) { | |
| 3323 | - $this->page = 'lostmemberpassword'; | |
| 3324 | - } else { | |
| 3325 | - $res = $this->lostmail(); | |
| 3326 | - $this->page = $res;//'lostcompletion'; | |
| 3327 | - } | |
| 3328 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3329 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3330 | - } | |
| 3331 | - | |
| 3332 | - function uscesmode_changepassword(){ | |
| 3333 | - global $wp_query; | |
| 3334 | - $this->page = 'changepassword'; | |
| 3335 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3336 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3337 | - } | |
| 3338 | - | |
| 3339 | - function changepassword_page(){ | |
| 3340 | - global $wp_query; | |
| 3341 | - $this->error_message = $this->changepass_check(); | |
| 3342 | - if ( $this->error_message != '' ) { | |
| 3343 | - $this->page = 'changepassword'; | |
| 3344 | - } else { | |
| 3345 | - $res = $this->changepassword(); | |
| 3346 | - $this->page = $res;//'changepasscompletion'; | |
| 3347 | - } | |
| 3348 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3349 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3350 | - } | |
| 3351 | - | |
| 3352 | - function page_newmember(){ | |
| 3353 | - | |
| 3354 | - global $wp_query; | |
| 3355 | - $this->page = 'newmemberform'; | |
| 3356 | - add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform'); | |
| 3357 | - add_action('the_post', array($this, 'action_memberFilter')); | |
| 3358 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3359 | - } | |
| 3360 | - | |
| 3361 | - function usces_export(){ | |
| 3362 | - $this->export(); | |
| 3363 | - } | |
| 3364 | - | |
| 3365 | - function usces_import(){ | |
| 3366 | - $this->import(); | |
| 3367 | - } | |
| 3368 | - | |
| 3369 | - function page_search_item(){ | |
| 3370 | - global $wp_query; | |
| 3371 | - $this->page = 'search_item'; | |
| 3372 | - //add_action('template_redirect', array($this, 'action_search_item')); | |
| 3373 | - add_action('the_post', array($this, 'action_cartFilter')); | |
| 3374 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3375 | - } | |
| 3376 | - | |
| 3377 | - function default_page(){ | |
| 3378 | - global $wp_query; | |
| 3379 | - add_action('the_post', array($this, 'goDefaultPage')); | |
| 3380 | - add_action('template_redirect', array($this, 'template_redirect')); | |
| 3381 | - } | |
| 3382 | - //-------------------------------------------------------------------------------------- | |
| 3383 | - | |
| 3384 | - | |
| 3385 | - function goDefaultPage(){ | |
| 3386 | - global $post; | |
| 3387 | - | |
| 3388 | - if( $post->ID == USCES_CART_NUMBER ) { | |
| 3389 | - | |
| 3390 | - $this->page = 'cart'; | |
| 3391 | - add_filter('the_content', array($this, 'filter_cartContent'),20); | |
| 3392 | - | |
| 3393 | - }else if( $post->ID == USCES_MEMBER_NUMBER ) { | |
| 3394 | - | |
| 3395 | - $this->page = 'member'; | |
| 3396 | - add_filter('the_content', array($this, 'filter_memberContent'),20); | |
| 3397 | - | |
| 3398 | - }else if( !is_singular() ) { | |
| 3399 | - $this->page = 'wp_search'; | |
| 3400 | - add_filter('the_excerpt', array($this, 'filter_cartContent'),20); | |
| 3401 | - add_filter('the_content', array($this, 'filter_cartContent'),20); | |
| 3402 | - | |
| 3403 | - }else{ | |
| 3404 | - add_filter('the_content', array(&$this, 'filter_itemPage')); | |
| 3405 | - | |
| 3406 | - } | |
| 3407 | - } | |
| 3408 | - | |
| 3409 | - function template_redirect () { | |
| 3410 | - global $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode; | |
| 3411 | - | |
| 3412 | - if( apply_filters('usces_action_template_redirect', false) ) return;//Deprecated | |
| 3413 | - if( apply_filters('usces_filter_template_redirect', false) ) return; | |
| 3414 | - | |
| 3415 | - if( is_single() && 'item' == $post->post_mime_type ) { | |
| 3416 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_item_single.php') ){ | |
| 3417 | - include(get_stylesheet_directory() . '/wc_templates/wc_item_single.php'); | |
| 3418 | - exit; | |
| 3419 | - } | |
| 3420 | - }elseif( isset($_REQUEST['page']) && ('search_item' == $_REQUEST['page'] || 'usces_search' == $_REQUEST['page']) && $this->is_cart_page($_SERVER['REQUEST_URI']) ){ | |
| 3421 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/wc_search_page.php') ){ | |
| 3422 | - include(get_stylesheet_directory() . '/wc_templates/wc_search_page.php'); | |
| 3423 | - exit; | |
| 3424 | - } | |
| 3425 | - | |
| 3426 | - }else if( $this->is_cart_page($_SERVER['REQUEST_URI']) ){ | |
| 3427 | - switch( $this->page ){ | |
| 3428 | - case 'customer': | |
| 3429 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php') ){ | |
| 3430 | - usces_get_entries(); | |
| 3431 | - usces_get_member_regmode(); | |
| 3432 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_customer_page.php'); | |
| 3433 | - exit; | |
| 3434 | - } | |
| 3435 | - break; | |
| 3436 | - case 'delivery': | |
| 3437 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php') ){ | |
| 3438 | - usces_get_entries(); | |
| 3439 | - usces_get_carts(); | |
| 3440 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_delivery_page.php'); | |
| 3441 | - exit; | |
| 3442 | - } | |
| 3443 | - break; | |
| 3444 | - case 'confirm': | |
| 3445 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php') ){ | |
| 3446 | - usces_get_entries(); | |
| 3447 | - usces_get_carts(); | |
| 3448 | - usces_get_members(); | |
| 3449 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_confirm_page.php'); | |
| 3450 | - exit; | |
| 3451 | - } | |
| 3452 | - break; | |
| 3453 | - case 'ordercompletion': | |
| 3454 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php') ){ | |
| 3455 | - usces_get_entries(); | |
| 3456 | - usces_get_carts(); | |
| 3457 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_completion_page.php'); | |
| 3458 | - exit; | |
| 3459 | - } | |
| 3460 | - break; | |
| 3461 | - case 'error': | |
| 3462 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php') ){ | |
| 3463 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_error_page.php'); | |
| 3464 | - exit; | |
| 3465 | - } | |
| 3466 | - break; | |
| 3467 | - case 'cart': | |
| 3468 | - default: | |
| 3469 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php') ){ | |
| 3470 | - include(get_stylesheet_directory() . '/wc_templates/cart/wc_cart_page.php'); | |
| 3471 | - exit; | |
| 3472 | - } | |
| 3473 | - | |
| 3474 | - } | |
| 3475 | - }else if($this->is_inquiry_page($_SERVER['REQUEST_URI']) ){ | |
| 3476 | - | |
| 3477 | - }else if( $this->is_member_page($_SERVER['REQUEST_URI']) ){ | |
| 3478 | - if($this->options['membersystem_state'] != 'activate') return; | |
| 3479 | - | |
| 3480 | - if( $this->is_member_logged_in() ) { | |
| 3481 | - $member_regmode = 'editmemberform'; | |
| 3482 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php') ){ | |
| 3483 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_member_page.php'); | |
| 3484 | - exit; | |
| 3485 | - } | |
| 3486 | - | |
| 3487 | - } else { | |
| 3488 | - | |
| 3489 | - switch( $this->page ){ | |
| 3490 | - case 'login': | |
| 3491 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){ | |
| 3492 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php'); | |
| 3493 | - exit; | |
| 3494 | - } | |
| 3495 | - break; | |
| 3496 | - case 'newmemberform': | |
| 3497 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php') ){ | |
| 3498 | - $member_regmode = 'newmemberform'; | |
| 3499 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_new_member_page.php'); | |
| 3500 | - exit; | |
| 3501 | - } | |
| 3502 | - break; | |
| 3503 | - case 'lostmemberpassword': | |
| 3504 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php') ){ | |
| 3505 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_lostpassword_page.php'); | |
| 3506 | - exit; | |
| 3507 | - } | |
| 3508 | - break; | |
| 3509 | - case 'changepassword': | |
| 3510 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php') ){ | |
| 3511 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_changepassword_page.php'); | |
| 3512 | - exit; | |
| 3513 | - } | |
| 3514 | - break; | |
| 3515 | - case 'newcompletion': | |
| 3516 | - case 'editcompletion': | |
| 3517 | - case 'lostcompletion': | |
| 3518 | - case 'changepasscompletion': | |
| 3519 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php') ){ | |
| 3520 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_member_completion_page.php'); | |
| 3521 | - exit; | |
| 3522 | - } | |
| 3523 | - break; | |
| 3524 | - default: | |
| 3525 | - if( file_exists(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php') ){ | |
| 3526 | - include(get_stylesheet_directory() . '/wc_templates/member/wc_login_page.php'); | |
| 3527 | - exit; | |
| 3528 | - } | |
| 3529 | - } | |
| 3530 | - } | |
| 3531 | - | |
| 3532 | - }else{ | |
| 3533 | -// remove_action('the_post', array(&$this, 'goDefaultPage')); | |
| 3534 | - } | |
| 3535 | - } | |
| 3536 | - | |
| 3537 | - function import() { | |
| 3538 | - $res = usces_import_xml(); | |
| 3539 | - if ( $res === false ) : | |
| 3540 | - $this->action_status = 'error'; | |
| 3541 | - //$this->action_message = __('Import was not completed.', 'usces'); | |
| 3542 | - else : | |
| 3543 | - $this->action_status = 'success'; | |
| 3544 | - $this->action_message = __('Import is cmpleted', 'usces'); | |
| 3545 | - endif; | |
| 3546 | - | |
| 3547 | -// require_once(USCES_PLUGIN_DIR . '/includes/admin_backup.php'); | |
| 3548 | - } | |
| 3549 | - | |
| 3550 | - function export() { | |
| 3551 | - $filename = 'usces.' . substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10) . '.xml'; | |
| 3552 | - | |
| 3553 | - header('Content-Description: File Transfer'); | |
| 3554 | - header("Content-Disposition: attachment; filename=$filename"); | |
| 3555 | - header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); | |
| 3556 | - | |
| 3557 | - usces_export_xml(); | |
| 3558 | - die(); | |
| 3559 | - | |
| 3560 | - } | |
| 3561 | - | |
| 3562 | - | |
| 3563 | - function changepassword() { | |
| 3564 | - global $wpdb; | |
| 3565 | - | |
| 3566 | - if ( !isset($_SESSION['usces_lostmail']) ) : | |
| 3567 | - $this->error_message = __('Failed in update due to time-out', 'usces'); | |
| 3568 | - return 'login'; | |
| 3569 | - else : | |
| 3570 | - | |
| 3571 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 3572 | - | |
| 3573 | - $query = $wpdb->prepare("UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s", | |
| 3574 | - md5(trim($_POST['loginpass1'])), $_SESSION['usces_lostmail']); | |
| 3575 | - $res = $wpdb->query( $query ); | |
| 3576 | - //$res = $wpdb->last_results; | |
| 3577 | - | |
| 3578 | - if ( $res === false ) : | |
| 3579 | - $this->error_message = __('Error: failure in updating password', 'usces'); | |
| 3580 | - return 'login'; | |
| 3581 | - else : | |
| 3582 | - return 'changepasscompletion'; | |
| 3583 | - endif; | |
| 3584 | - | |
| 3585 | - endif; | |
| 3586 | - } | |
| 3587 | - | |
| 3588 | - function lostmail() { | |
| 3589 | - $delim = apply_filters( 'usces_filter_delim', $this->delim ); | |
| 3590 | - | |
| 3591 | - $_SESSION['usces_lostmail'] = trim($_POST['loginmail']); | |
| 3592 | - $id = session_id(); | |
| 3593 | - $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword'; | |
| 3594 | - $res = usces_lostmail($uri); | |
| 3595 | - return $res; | |
| 3596 | - | |
| 3597 | - } | |
| 3598 | - | |
| 3599 | - function regist_member() { | |
| 3600 | - global $wpdb; | |
| 3601 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 3602 | - | |
| 3603 | - $member = $this->get_member(); | |
| 3604 | - $mode = $_POST['member_regmode']; | |
| 3605 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 3606 | - $member_meta_table = $wpdb->prefix . "usces_member_meta"; | |
| 3607 | - | |
| 3608 | -//20110715ysk start 0000203 | |
| 3609 | - //$error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check(); | |
| 3610 | - $error_mes = ( $_POST['member_regmode'] == 'newmemberfromcart' or $_POST['member_regmode'] == 'editmemberfromcart' ) ? $this->member_check_fromcart() : $this->member_check(); | |
| 3611 | -//20110715ysk end | |
| 3612 | - | |
| 3613 | - if ( $error_mes != '' ) { | |
| 3614 | - | |
| 3615 | - $this->error_message = $error_mes; | |
| 3616 | - return $mode; | |
| 3617 | - | |
| 3618 | - } elseif ( $_POST['member_regmode'] == 'editmemberform' ) { | |
| 3619 | - | |
| 3620 | - do_action('usces_action_pre_edit_memberdata', $_POST['member'], $_POST['member_id']); | |
| 3621 | - | |
| 3622 | - $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $_POST['member_id']); | |
| 3623 | - $pass = $wpdb->get_var( $query ); | |
| 3624 | - | |
| 3625 | - $password = ( !empty($_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? md5(trim($_POST['member']['password1'])) : $pass; | |
| 3626 | - $query = $wpdb->prepare("UPDATE $member_table SET | |
| 3627 | - mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s, | |
| 3628 | - mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s, | |
| 3629 | - mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d", | |
| 3630 | - $password, | |
| 3631 | - trim($_POST['member']['name1']), | |
| 3632 | - trim($_POST['member']['name2']), | |
| 3633 | - trim($_POST['member']['name3']), | |
| 3634 | - trim($_POST['member']['name4']), | |
| 3635 | - trim($_POST['member']['zipcode']), | |
| 3636 | - trim($_POST['member']['pref']), | |
| 3637 | - trim($_POST['member']['address1']), | |
| 3638 | - trim($_POST['member']['address2']), | |
| 3639 | - trim($_POST['member']['address3']), | |
| 3640 | - trim($_POST['member']['tel']), | |
| 3641 | - trim($_POST['member']['fax']), | |
| 3642 | - trim($_POST['member']['mailaddress1']), | |
| 3643 | - $_POST['member_id'] | |
| 3644 | - ); | |
| 3645 | - $res = $wpdb->query( $query ); | |
| 3646 | - | |
| 3647 | - if( $res !== false ){ | |
| 3648 | - $this->set_member_meta_value('customer_country', $_POST['member']['country'], $_POST['member_id']); | |
| 3649 | -//20100818ysk start | |
| 3650 | - $res = $this->reg_custom_member($_POST['member_id']); | |
| 3651 | -//20100818ysk end | |
| 3652 | - do_action('usces_action_edit_memberdata', $_POST['member'], $_POST['member_id']); | |
| 3653 | - $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'zeus_pcid', 'remise_pcid', 'digitalcheck_ip_user_id'" ); | |
| 3654 | - $query = $wpdb->prepare("DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )", | |
| 3655 | - $_POST['member_id'] | |
| 3656 | - ); | |
| 3657 | - $res = $wpdb->query( $query ); | |
| 3658 | - | |
| 3659 | - $this->get_current_member(); | |
| 3660 | - return 'editmemberform'; | |
| 3661 | - | |
| 3662 | - } else { | |
| 3663 | - $this->error_message = __('Error:failure in update', 'usces'); | |
| 3664 | - return $mode; | |
| 3665 | - } | |
| 3666 | - | |
| 3667 | - } elseif ( $_POST['member_regmode'] == 'newmemberform' ) { | |
| 3668 | - | |
| 3669 | - $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1'])); | |
| 3670 | - $id = $wpdb->get_var( $query ); | |
| 3671 | - if ( !empty($id) ) { | |
| 3672 | - $this->error_message = __('This e-mail address has been already registered.', 'usces'); | |
| 3673 | - return $mode; | |
| 3674 | - } else { | |
| 3675 | - | |
| 3676 | - $point = $this->options['start_point']; | |
| 3677 | - $pass = md5(trim($_POST['member']['password1'])); | |
| 3678 | - $query = $wpdb->prepare("INSERT INTO $member_table | |
| 3679 | - (mem_email, mem_pass, mem_status, mem_cookie, mem_point, | |
| 3680 | - mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref, | |
| 3681 | - mem_address1, mem_address2, mem_address3, mem_tel, mem_fax, | |
| 3682 | - mem_delivery_flag, mem_delivery, mem_registered, mem_nicename) | |
| 3683 | - VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 3684 | - trim($_POST['member']['mailaddress1']), | |
| 3685 | - $pass, | |
| 3686 | - 0, | |
| 3687 | - "", | |
| 3688 | - $point, | |
| 3689 | - trim($_POST['member']['name1']), | |
| 3690 | - trim($_POST['member']['name2']), | |
| 3691 | - trim($_POST['member']['name3']), | |
| 3692 | - trim($_POST['member']['name4']), | |
| 3693 | - trim($_POST['member']['zipcode']), | |
| 3694 | - trim($_POST['member']['pref']), | |
| 3695 | - trim($_POST['member']['address1']), | |
| 3696 | - trim($_POST['member']['address2']), | |
| 3697 | - trim($_POST['member']['address3']), | |
| 3698 | - trim($_POST['member']['tel']), | |
| 3699 | - trim($_POST['member']['fax']), | |
| 3700 | - '', | |
| 3701 | - '', | |
| 3702 | - get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), | |
| 3703 | - ''); | |
| 3704 | - $res = $wpdb->query( $query ); | |
| 3705 | - | |
| 3706 | - //$_SESSION['usces_member']['ID'] = $wpdb->insert_id; | |
| 3707 | - //$this->get_current_member(); | |
| 3708 | - if($res !== false) { | |
| 3709 | - $user = $_POST['member']; | |
| 3710 | - $user['ID'] = $wpdb->insert_id; | |
| 3711 | - $this->set_member_meta_value('customer_country', $_POST['member']['country'], $user['ID']); | |
| 3712 | -//20110714ysk start 0000207 | |
| 3713 | -//20100818ysk start | |
| 3714 | - //$res = $this->reg_custom_member($wpdb->insert_id); | |
| 3715 | - $res = $this->reg_custom_member($user['ID']); | |
| 3716 | -//20100818ysk end | |
| 3717 | -//20110714ysk end | |
| 3718 | - $mser = usces_send_regmembermail($user); | |
| 3719 | - | |
| 3720 | - do_action('usces_action_member_registered', $_POST['member'], $user['ID']); | |
| 3721 | - | |
| 3722 | - return 'newcompletion'; | |
| 3723 | - | |
| 3724 | - } else { | |
| 3725 | - $this->error_message = __('Error:failure in update', 'usces'); | |
| 3726 | - return $mode; | |
| 3727 | - } | |
| 3728 | - } | |
| 3729 | - | |
| 3730 | - } elseif ( $_POST['member_regmode'] == 'newmemberfromcart' ) { | |
| 3731 | - | |
| 3732 | - $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1'])); | |
| 3733 | - $id = $wpdb->get_var( $query ); | |
| 3734 | - if ( !empty($id) ) { | |
| 3735 | - $this->error_message = __('This e-mail address has been already registered.', 'usces'); | |
| 3736 | - return $mode; | |
| 3737 | - } else { | |
| 3738 | - | |
| 3739 | - $point = $this->options['start_point']; | |
| 3740 | - $pass = md5(trim($_POST['customer']['password1'])); | |
| 3741 | - $query = $wpdb->prepare("INSERT INTO $member_table | |
| 3742 | - (mem_email, mem_pass, mem_status, mem_cookie, mem_point, | |
| 3743 | - mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref, | |
| 3744 | - mem_address1, mem_address2, mem_address3, mem_tel, mem_fax, | |
| 3745 | - mem_delivery_flag, mem_delivery, mem_registered, mem_nicename) | |
| 3746 | - VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 3747 | - trim($_POST['customer']['mailaddress1']), | |
| 3748 | - $pass, | |
| 3749 | - 0, | |
| 3750 | - "", | |
| 3751 | - $point, | |
| 3752 | - trim($_POST['customer']['name1']), | |
| 3753 | - trim($_POST['customer']['name2']), | |
| 3754 | - trim($_POST['customer']['name3']), | |
| 3755 | - trim($_POST['customer']['name4']), | |
| 3756 | - trim($_POST['customer']['zipcode']), | |
| 3757 | - trim($_POST['customer']['pref']), | |
| 3758 | - trim($_POST['customer']['address1']), | |
| 3759 | - trim($_POST['customer']['address2']), | |
| 3760 | - trim($_POST['customer']['address3']), | |
| 3761 | - trim($_POST['customer']['tel']), | |
| 3762 | - trim($_POST['customer']['fax']), | |
| 3763 | - '', | |
| 3764 | - '', | |
| 3765 | - get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), | |
| 3766 | - ''); | |
| 3767 | - $res = $wpdb->query( $query ); | |
| 3768 | - | |
| 3769 | - //$_SESSION['usces_member']['ID'] = $wpdb->insert_id; | |
| 3770 | - //$this->get_current_member(); | |
| 3771 | - if($res !== false) { | |
| 3772 | -//20110714ysk start 0000207 | |
| 3773 | - $member_id = $wpdb->insert_id; | |
| 3774 | - //$this->set_member_meta_value('customer_country', $_POST['member']['country'], $wpdb->insert_id); | |
| 3775 | - $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $member_id); | |
| 3776 | -//20100818ysk start | |
| 3777 | - //$res = $this->reg_custom_member($wpdb->insert_id); | |
| 3778 | - $res = $this->reg_custom_member($member_id); | |
| 3779 | -//20100818ysk end | |
| 3780 | -//20110714ysk end | |
| 3781 | - //usces_send_regmembermail(); | |
| 3782 | - do_action('usces_action_member_registered', $_POST['customer'], $member_id); | |
| 3783 | - $user = $_POST['customer']; | |
| 3784 | - $user['ID'] = $member_id; | |
| 3785 | - $mser = usces_send_regmembermail($user); | |
| 3786 | - $_POST['loginmail'] = trim($_POST['customer']['mailaddress1']); | |
| 3787 | - $_POST['loginpass'] = trim($_POST['customer']['password1']); | |
| 3788 | - if( $this->member_login() == 'member' ){ | |
| 3789 | - $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart'; | |
| 3790 | - return 'newcompletion'; | |
| 3791 | - } | |
| 3792 | - | |
| 3793 | - } else { | |
| 3794 | - $this->error_message = __('Error:failure in update', 'usces'); | |
| 3795 | - return $mode; | |
| 3796 | - } | |
| 3797 | - } | |
| 3798 | - | |
| 3799 | -//20110715ysk start 0000203 | |
| 3800 | - } elseif ( $_POST['member_regmode'] == 'editmemberfromcart' ) { | |
| 3801 | - | |
| 3802 | - do_action('usces_action_pre_edit_memberdata', $_POST['customer'], $_POST['member_id']); | |
| 3803 | - | |
| 3804 | - $query = $wpdb->prepare("SELECT mem_pass FROM $member_table WHERE ID = %d", $_POST['member_id']); | |
| 3805 | - $pass = $wpdb->get_var( $query ); | |
| 3806 | - | |
| 3807 | - $password = ( !empty($_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? md5(trim($_POST['customer']['password1'])) : $pass; | |
| 3808 | - $query = $wpdb->prepare("UPDATE $member_table SET | |
| 3809 | - mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s, | |
| 3810 | - mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s, | |
| 3811 | - mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d", | |
| 3812 | - $password, | |
| 3813 | - trim($_POST['customer']['name1']), | |
| 3814 | - trim($_POST['customer']['name2']), | |
| 3815 | - trim($_POST['customer']['name3']), | |
| 3816 | - trim($_POST['customer']['name4']), | |
| 3817 | - trim($_POST['customer']['zipcode']), | |
| 3818 | - trim($_POST['customer']['pref']), | |
| 3819 | - trim($_POST['customer']['address1']), | |
| 3820 | - trim($_POST['customer']['address2']), | |
| 3821 | - trim($_POST['customer']['address3']), | |
| 3822 | - trim($_POST['customer']['tel']), | |
| 3823 | - trim($_POST['customer']['fax']), | |
| 3824 | - trim($_POST['customer']['mailaddress1']), | |
| 3825 | - $_POST['member_id'] | |
| 3826 | - ); | |
| 3827 | - $res = $wpdb->query( $query ); | |
| 3828 | - if( $res !== false ){ | |
| 3829 | - $this->set_member_meta_value('customer_country', $_POST['customer']['country'], $_POST['member_id']); | |
| 3830 | - $res = $this->reg_custom_member($_POST['member_id']); | |
| 3831 | - do_action('usces_action_edit_memberdata', $_POST['customer'], $_POST['member_id']); | |
| 3832 | - unset($_SESSION['usces_member']); | |
| 3833 | - $this->member_just_login(trim($_POST['customer']['mailaddress1']), trim($_POST['customer']['password1'])); | |
| 3834 | - return 'newcompletion'; | |
| 3835 | - | |
| 3836 | - } else { | |
| 3837 | - $this->error_message = __('Error:failure in update', 'usces'); | |
| 3838 | - return $mode; | |
| 3839 | - } | |
| 3840 | -//20110715ysk end | |
| 3841 | - } | |
| 3842 | - } | |
| 3843 | - | |
| 3844 | - function delete_member() { | |
| 3845 | - if( ! $this->is_member_logged_in() ) | |
| 3846 | - return false; | |
| 3847 | - $mem = $this->get_member(); | |
| 3848 | - if( ! $mem['ID'] ) | |
| 3849 | - return false; | |
| 3850 | - | |
| 3851 | - $res = usces_delete_memberdata( $mem['ID'] ); | |
| 3852 | - | |
| 3853 | - return $res; | |
| 3854 | - } | |
| 3855 | - | |
| 3856 | - function is_member_logged_in( $id = false ) { | |
| 3857 | - if( $id === false ){ | |
| 3858 | - if( !empty($_SESSION['usces_member']['ID']) ) | |
| 3859 | - return true; | |
| 3860 | - else | |
| 3861 | - return false; | |
| 3862 | - }else{ | |
| 3863 | - if( !empty($_SESSION['usces_member']['ID']) && $_SESSION['usces_member']['ID'] == $id ) | |
| 3864 | - return true; | |
| 3865 | - else | |
| 3866 | - return false; | |
| 3867 | - } | |
| 3868 | - } | |
| 3869 | - | |
| 3870 | - function is_member($email) { | |
| 3871 | - global $wpdb; | |
| 3872 | - | |
| 3873 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 3874 | - $query = $wpdb->prepare("SELECT mem_email FROM $member_table WHERE mem_email = %s", $email); | |
| 3875 | - $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 3876 | - if ( empty($member) ) { | |
| 3877 | - return false; | |
| 3878 | - }else{ | |
| 3879 | - return true; | |
| 3880 | - } | |
| 3881 | - } | |
| 3882 | - | |
| 3883 | - function member_login() { | |
| 3884 | - global $wpdb; | |
| 3885 | - $_POST = $this->stripslashes_deep_post($_POST); | |
| 3886 | - | |
| 3887 | - $cookie = $this->get_cookie(); | |
| 3888 | - | |
| 3889 | - | |
| 3890 | - if ( isset($cookie['rme']) && $cookie['rme'] == 'forever' && !isset($_POST['rememberme']) && !isset($_POST['loginmail'])) { | |
| 3891 | - $email = $cookie['name']; | |
| 3892 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 3893 | - | |
| 3894 | - $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email); | |
| 3895 | - $id = $wpdb->get_var( $query ); | |
| 3896 | - | |
| 3897 | - if ( !$id ) { | |
| 3898 | - $this->current_member['email'] = htmlspecialchars($email); | |
| 3899 | - $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces'); | |
| 3900 | - return 'login'; | |
| 3901 | - } else { | |
| 3902 | - $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s", $email); | |
| 3903 | - $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 3904 | - if ( empty($member) ) { | |
| 3905 | - $this->current_member['email'] = htmlspecialchars($email); | |
| 3906 | - $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces'); | |
| 3907 | - return 'login'; | |
| 3908 | - } else { | |
| 3909 | - $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 3910 | - $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 3911 | - $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 3912 | - $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 3913 | - $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 3914 | - $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 3915 | - $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 3916 | - $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 3917 | - $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 3918 | - $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 3919 | - $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 3920 | - $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 3921 | - $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 3922 | - $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 3923 | - $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 3924 | - $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 3925 | - $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : ''; | |
| 3926 | - $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 3927 | - $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 3928 | - $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']); | |
| 3929 | - $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 3930 | -//20100818ysk start | |
| 3931 | - $this->set_session_custom_member($member['ID']); | |
| 3932 | -//20100818ysk end | |
| 3933 | - $this->get_current_member(); | |
| 3934 | - | |
| 3935 | - do_action( 'usces_action_after_login' ); | |
| 3936 | - return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 3937 | - } | |
| 3938 | - } | |
| 3939 | - } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginmail']) && isset($_POST['loginpass']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) { | |
| 3940 | - return 'login'; | |
| 3941 | - } else if ( isset($_POST['loginmail']) && WCUtils::is_blank($_POST['loginpass']) && isset($cookie['rme']) && $cookie['rme'] != 'forever' ) { | |
| 3942 | - $this->current_member['email'] = trim($_POST['loginmail']); | |
| 3943 | - $this->error_message = __('<b>Error:</b> Enter the password.', 'usces'); | |
| 3944 | - return 'login'; | |
| 3945 | - } else if ( !isset($_POST['loginmail']) ){ | |
| 3946 | - return 'login'; | |
| 3947 | - } else { | |
| 3948 | - $email = isset($_POST['loginmail']) ? trim($_POST['loginmail']) : ''; | |
| 3949 | - $pass = isset($_POST['loginpass']) ? md5(trim($_POST['loginpass'])) : ''; | |
| 3950 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 3951 | - | |
| 3952 | - $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email); | |
| 3953 | - $id = $wpdb->get_var( $query ); | |
| 3954 | - | |
| 3955 | - if ( !$id ) { | |
| 3956 | - $this->current_member['email'] = htmlspecialchars($email); | |
| 3957 | - $this->error_message = __('<b>Error:</b> E-mail address is not correct.', 'usces'); | |
| 3958 | - return 'login'; | |
| 3959 | - } else { | |
| 3960 | - $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass); | |
| 3961 | - $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 3962 | - if ( empty($member) ) { | |
| 3963 | - $this->current_member['email'] = htmlspecialchars($email); | |
| 3964 | - $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces'); | |
| 3965 | - return 'login'; | |
| 3966 | - } else { | |
| 3967 | - $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 3968 | - $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 3969 | - $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 3970 | - $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 3971 | - $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 3972 | - $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 3973 | - $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 3974 | - $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 3975 | - $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 3976 | - $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 3977 | - $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 3978 | - $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 3979 | - $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 3980 | - $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 3981 | - $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 3982 | - $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 3983 | - $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : ''; | |
| 3984 | - $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 3985 | - $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 3986 | - $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']); | |
| 3987 | - $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 3988 | -//20100818ysk start | |
| 3989 | - $this->set_session_custom_member($member['ID']); | |
| 3990 | -//20100818ysk end | |
| 3991 | - $this->get_current_member(); | |
| 3992 | - | |
| 3993 | - if( isset($_POST['rememberme']) ){ | |
| 3994 | - $cookie['name'] = $email; | |
| 3995 | - $cookie['rme'] = 'forever'; | |
| 3996 | - $this->set_cookie($cookie); | |
| 3997 | - }else{ | |
| 3998 | - $cookie['name'] = ''; | |
| 3999 | - $cookie['rme'] = ''; | |
| 4000 | - $this->set_cookie($cookie); | |
| 4001 | - } | |
| 4002 | - | |
| 4003 | - do_action( 'usces_action_after_login' ); | |
| 4004 | - return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 4005 | - } | |
| 4006 | - } | |
| 4007 | - } | |
| 4008 | - } | |
| 4009 | - | |
| 4010 | - function member_just_login($email, $pass) { | |
| 4011 | - global $wpdb; | |
| 4012 | - $pass = md5($pass); | |
| 4013 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 4014 | - | |
| 4015 | - $query = $wpdb->prepare("SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass); | |
| 4016 | - $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 4017 | - if ( empty($member) ) { | |
| 4018 | - $this->current_member['email'] = htmlspecialchars($email); | |
| 4019 | - $this->error_message = __('<b>Error:</b> Password is not correct.', 'usces'); | |
| 4020 | - return 'login'; | |
| 4021 | - } else { | |
| 4022 | - $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 4023 | - $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 4024 | - $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 4025 | - $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 4026 | - $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 4027 | - $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 4028 | - $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 4029 | - $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 4030 | - $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 4031 | - $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 4032 | - $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 4033 | - $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 4034 | - $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 4035 | - $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 4036 | - $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 4037 | - $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 4038 | - $_SESSION['usces_member']['delivery'] = !empty($member['mem_delivery']) ? unserialize($member['mem_delivery']) : ''; | |
| 4039 | - $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 4040 | - $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 4041 | - $_SESSION['usces_member']['country'] = $this->get_member_meta_value('customer_country', $member['ID']); | |
| 4042 | - $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 4043 | -//20100818ysk start | |
| 4044 | - $this->set_session_custom_member($member['ID']); | |
| 4045 | -//20100818ysk end | |
| 4046 | - $this->get_current_member(); | |
| 4047 | - | |
| 4048 | -// $cookie = $this->get_cookie(); | |
| 4049 | -// if(isset($_POST['rememberme']) && $cookie){ | |
| 4050 | -// $cookie['name'] = $email; | |
| 4051 | -// $cookie['pass'] = trim($_POST['loginpass']); | |
| 4052 | -// $this->set_cookie($cookie); | |
| 4053 | -// }else{ | |
| 4054 | -// $cookie['name'] = ''; | |
| 4055 | -// $cookie['pass'] = ''; | |
| 4056 | -// $this->set_cookie($cookie); | |
| 4057 | -// } | |
| 4058 | - | |
| 4059 | - do_action( 'usces_action_after_login' ); | |
| 4060 | - return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 4061 | - } | |
| 4062 | - } | |
| 4063 | - | |
| 4064 | - function member_logout() { | |
| 4065 | - unset($_SESSION['usces_member'], $_SESSION['usces_entry']); | |
| 4066 | - do_action('usces_action_member_logout'); | |
| 4067 | - wp_redirect(get_option('home')); | |
| 4068 | - exit; | |
| 4069 | - } | |
| 4070 | - | |
| 4071 | - function get_current_member() { | |
| 4072 | - | |
| 4073 | - if ( isset($_SESSION['usces_member']['ID']) ) { | |
| 4074 | - $this->current_member['id'] = $_SESSION['usces_member']['ID']; | |
| 4075 | - $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return'); | |
| 4076 | - } else { | |
| 4077 | - $this->current_member['id'] = 0; | |
| 4078 | - $this->current_member['name'] = __('guest', 'usces'); | |
| 4079 | - } | |
| 4080 | - } | |
| 4081 | - | |
| 4082 | - function get_member() { | |
| 4083 | - $res = array( | |
| 4084 | - 'ID' => '', | |
| 4085 | - 'registered' => '', | |
| 4086 | - 'mailaddress1' => '', | |
| 4087 | - 'mailaddress2' => '', | |
| 4088 | - 'password1' => '', | |
| 4089 | - 'password2' => '', | |
| 4090 | - 'point' => '', | |
| 4091 | - 'name1' => '', | |
| 4092 | - 'name2' => '', | |
| 4093 | - 'name3' => '', | |
| 4094 | - 'name4' => '', | |
| 4095 | - 'zipcode' => '', | |
| 4096 | - 'address1' => '', | |
| 4097 | - 'address2' => '', | |
| 4098 | - 'address3' => '', | |
| 4099 | - 'tel' => '', | |
| 4100 | - 'fax' => '', | |
| 4101 | - 'country' => '', | |
| 4102 | - 'pref' => '', | |
| 4103 | - 'status' => '' | |
| 4104 | - ); | |
| 4105 | - if(!empty($_SESSION['usces_member'])) { | |
| 4106 | - foreach ( $_SESSION['usces_member'] as $key => $value ) { | |
| 4107 | - //20100818ysk start | |
| 4108 | - if(is_array($_SESSION['usces_member'][$key])) | |
| 4109 | - $res[$key] = stripslashes_deep($value); | |
| 4110 | - else | |
| 4111 | - //20100818ysk end | |
| 4112 | - $res[$key] = stripslashes($value); | |
| 4113 | - } | |
| 4114 | - } | |
| 4115 | - return $res; | |
| 4116 | - } | |
| 4117 | - | |
| 4118 | - function get_member_info( $mid ) { | |
| 4119 | - global $wpdb; | |
| 4120 | - $infos = array(); | |
| 4121 | - | |
| 4122 | - //if( !current_user_can('activate_plugins') ) return array(); | |
| 4123 | - | |
| 4124 | - $table = $wpdb->prefix . "usces_member"; | |
| 4125 | - $query = $wpdb->prepare("SELECT * FROM $table WHERE ID = %d", $mid); | |
| 4126 | - $datas = $wpdb->get_results( $query, ARRAY_A ); | |
| 4127 | - if( $datas ) { | |
| 4128 | - $infos = $datas[0]; | |
| 4129 | - | |
| 4130 | - $table = $wpdb->prefix . "usces_member_meta"; | |
| 4131 | - $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid); | |
| 4132 | - $metas = $wpdb->get_results( $query, ARRAY_A ); | |
| 4133 | - | |
| 4134 | - foreach( $metas as $meta ){ | |
| 4135 | - $infos[$meta['meta_key']] = maybe_unserialize($meta['meta_value']); | |
| 4136 | - } | |
| 4137 | - } | |
| 4138 | - return $infos; | |
| 4139 | - } | |
| 4140 | - | |
| 4141 | - function is_order($mid, $oid) { | |
| 4142 | - global $wpdb; | |
| 4143 | - | |
| 4144 | - $table = $wpdb->prefix . "usces_order"; | |
| 4145 | - $query = $wpdb->prepare("SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid); | |
| 4146 | - $mem_id = $wpdb->get_var( $query ); | |
| 4147 | - if ( empty($mem_id) ) { | |
| 4148 | - return false; | |
| 4149 | - }else{ | |
| 4150 | - return true; | |
| 4151 | - } | |
| 4152 | - } | |
| 4153 | - | |
| 4154 | - function is_purchased_item($mid, $post_id, $sku = NULL) { | |
| 4155 | - global $wpdb; | |
| 4156 | - $res = false; | |
| 4157 | - | |
| 4158 | - $history = $this->get_member_history($mid); | |
| 4159 | - foreach ( $history as $umhs ) { | |
| 4160 | - $cart = $umhs['cart']; | |
| 4161 | - $status = $umhs['order_status']; | |
| 4162 | - for($i=0; $i<count($cart); $i++) { | |
| 4163 | - $cart_row = $cart[$i]; | |
| 4164 | - $sku_code = urldecode($cart_row['sku']); | |
| 4165 | - if( empty($sku) ){ | |
| 4166 | - if( $cart_row['post_id'] == $post_id && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){ | |
| 4167 | - $res = true; | |
| 4168 | - break 2; | |
| 4169 | - }elseif( $cart_row['post_id'] == $post_id && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){ | |
| 4170 | - $res = 'noreceipt'; | |
| 4171 | - break 2; | |
| 4172 | - } | |
| 4173 | - }else{ | |
| 4174 | - if( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false === strpos($status, 'noreceipt') && false === strpos($status, 'pending')) ){ | |
| 4175 | - $res = true; | |
| 4176 | - break 2; | |
| 4177 | - }elseif( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos($status, 'noreceipt') || false !== strpos($status, 'pending')) ){ | |
| 4178 | - $res = 'noreceipt'; | |
| 4179 | - break 2; | |
| 4180 | - } | |
| 4181 | - } | |
| 4182 | - } | |
| 4183 | - | |
| 4184 | - } | |
| 4185 | - return $res; | |
| 4186 | - } | |
| 4187 | - | |
| 4188 | - function get_order_data($order_id, $mode = '' ) { | |
| 4189 | - global $wpdb, $usces; | |
| 4190 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 4191 | - | |
| 4192 | - $query = $wpdb->prepare("SELECT * FROM $order_table WHERE ID = %d", $order_id); | |
| 4193 | - | |
| 4194 | - if( 'direct' == $mode ){ | |
| 4195 | - $value = $wpdb->get_row( $query, ARRAY_A ); | |
| 4196 | - return $value; | |
| 4197 | - } | |
| 4198 | - | |
| 4199 | - $value = $wpdb->get_row( $query ); | |
| 4200 | - | |
| 4201 | - if( $value == NULL ) { | |
| 4202 | - return false; | |
| 4203 | - }else{ | |
| 4204 | - $res =array(); | |
| 4205 | - } | |
| 4206 | - if(strpos($value->order_status, 'cancel') !== false || strpos($value->order_status, 'estimate') !== false){ | |
| 4207 | - return false; | |
| 4208 | - } | |
| 4209 | - | |
| 4210 | - $res = array( | |
| 4211 | - 'ID' => $value->ID, | |
| 4212 | - 'mem_id' => $value->mem_id, | |
| 4213 | - 'cart' => unserialize($value->order_cart), | |
| 4214 | - 'condition' => unserialize($value->order_condition), | |
| 4215 | - 'getpoint' => $value->order_getpoint, | |
| 4216 | - 'usedpoint' => $value->order_usedpoint, | |
| 4217 | - 'discount' => $value->order_discount, | |
| 4218 | - 'payment_name' => $value->order_payment_name, | |
| 4219 | - 'shipping_charge' => $value->order_shipping_charge, | |
| 4220 | - 'cod_fee' => $value->order_cod_fee, | |
| 4221 | - 'tax' => $value->order_tax, | |
| 4222 | - 'end_price' => $value->order_item_total_price - ($value->order_getpoint*$usces->options['system']['pointreduction']) + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax, | |
| 4223 | - 'status' => $value->order_status, | |
| 4224 | - 'date' => mysql2date(__('Y/m/d'), $value->order_date), | |
| 4225 | - 'modified' => mysql2date(__('Y/m/d'), $value->order_modified) | |
| 4226 | - ); | |
| 4227 | - | |
| 4228 | - return $res; | |
| 4229 | - } | |
| 4230 | - | |
| 4231 | - function get_orderIDs_by_postID($mem_id, $post_id) { | |
| 4232 | - global $wpdb; | |
| 4233 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 4234 | - | |
| 4235 | - $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); | |
| 4236 | - $rows = $wpdb->get_query( $query, ARRAY_A ); | |
| 4237 | - | |
| 4238 | - if( $value == NULL ) { | |
| 4239 | - return false; | |
| 4240 | - }else{ | |
| 4241 | - foreach($rows as $row){ | |
| 4242 | - if(strpos($row['order_status'], 'cancel') !== false || strpos($row['order_status'], 'estimate') !== false){ | |
| 4243 | - continue; | |
| 4244 | - }else{ | |
| 4245 | - $carts = unserialize($row['order_cart']); | |
| 4246 | - foreach($carts as $cart){ | |
| 4247 | - if( $post_id == $cart['post_id'] ){ | |
| 4248 | - $res[] = $row['ID']; | |
| 4249 | - break; | |
| 4250 | - } | |
| 4251 | - } | |
| 4252 | - } | |
| 4253 | - } | |
| 4254 | - } | |
| 4255 | - return $res; | |
| 4256 | - } | |
| 4257 | - | |
| 4258 | - function incart_check() { | |
| 4259 | - //$_POST = $this->stripslashes_deep_post($_POST); | |
| 4260 | - $mes = array(); | |
| 4261 | - | |
| 4262 | - $ids = array_keys($_POST['inCart']); | |
| 4263 | - $post_id = $ids[0]; | |
| 4264 | - $skus = array_keys($_POST['inCart'][$post_id]); | |
| 4265 | - $sku = $skus[0]; | |
| 4266 | - $quant = isset($_POST['quant'][$post_id][$sku]) ? (int)$_POST['quant'][$post_id][$sku] : 1; | |
| 4267 | - $stock = $this->getItemZaikoNum($post_id, $sku); | |
| 4268 | - $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku); | |
| 4269 | - $itemRestriction = get_post_meta($post_id, '_itemRestriction',true ); | |
| 4270 | - | |
| 4271 | - if( 1 > $quant ){ | |
| 4272 | - $mes[$post_id][$sku] = __('enter the correct amount', 'usces') . "<br />"; | |
| 4273 | - }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){ | |
| 4274 | - $mes[$post_id][$sku] = sprintf(__("This article is limited by %d at a time.", 'usces'), $itemRestriction) . "<br />"; | |
| 4275 | - }else if( $quant > (int)$stock && !WCUtils::is_blank($stock) ){ | |
| 4276 | - $mes[$post_id][$sku] = __('Sorry, stock is insufficient.', 'usces') . ' ' . __('Current stock', 'usces') . $stock . "<br />"; | |
| 4277 | - }else if( 1 < $zaiko_id ){ | |
| 4278 | - $mes[$post_id][$sku] = __('Sorry, this item is sold out.', 'usces') . "<br />"; | |
| 4279 | - } | |
| 4280 | - | |
| 4281 | - $ioptkeys = $this->get_itemOptionKey( $post_id, true ); | |
| 4282 | - if($ioptkeys){ | |
| 4283 | - foreach($ioptkeys as $key => $value){ | |
| 4284 | - $optValues = $this->get_itemOptions( urldecode($value), $post_id ); | |
| 4285 | - if( 0 == $optValues['means'] ){ //case of select | |
| 4286 | - if( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][$post_id][$sku][$value] ){ | |
| 4287 | - $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />"; | |
| 4288 | - } | |
| 4289 | - }elseif( 1 == $optValues['means'] ){ //case of multiselect | |
| 4290 | - if( $optValues['essential'] ){ | |
| 4291 | - $mselect = 0; | |
| 4292 | - foreach((array)$_POST['itemOption'][$post_id][$sku][$value] as $mvalue){ | |
| 4293 | - if(!empty($mvalue) and '#NONE#' != $mvalue) $mselect++; | |
| 4294 | - } | |
| 4295 | - if( $mselect == 0 ){ | |
| 4296 | - $mes[$post_id][$sku] .= sprintf(__("Chose the %s", 'usces'), urldecode($value)) . "<br />"; | |
| 4297 | - } | |
| 4298 | - } | |
| 4299 | - }else{ //case of text | |
| 4300 | - if( $optValues['essential'] && WCUtils::is_blank($_POST['itemOption'][$post_id][$sku][$value]) ){ | |
| 4301 | - $mes[$post_id][$sku] .= sprintf(__("Input the %s", 'usces'), urldecode($value)) . "<br />"; | |
| 4302 | - } | |
| 4303 | - } | |
| 4304 | - } | |
| 4305 | - } | |
| 4306 | - | |
| 4307 | - $mes = apply_filters('usces_filter_incart_check', $mes, $post_id, $sku); | |
| 4308 | - | |
| 4309 | - if( isset($mes[$post_id]) && is_array($mes[$post_id]) ){ | |
| 4310 | - foreach( $mes[$post_id] as $skukey => $skuvalue ){ | |
| 4311 | - $mes[$post_id][$skukey] = rtrim($skuvalue, "<br />"); | |
| 4312 | - } | |
| 4313 | - } | |
| 4314 | - | |
| 4315 | - if( !empty($mes) ){ | |
| 4316 | - $_SESSION['usces_singleitem']['itemOption'] = $_POST['itemOption']; | |
| 4317 | - $_SESSION['usces_singleitem']['quant'] = $_POST['quant']; | |
| 4318 | - $_SESSION['usces_singleitem']['error_message'] = $mes; | |
| 4319 | - $parse_url = parse_url(get_home_url()); | |
| 4320 | - header('location: ' . $parse_url['scheme'] . '://' . $parse_url['host'] . $_POST['usces_referer'] . '#cart_button'); | |
| 4321 | - exit; | |
| 4322 | - } | |
| 4323 | - | |
| 4324 | - do_action('usces_action_incart_checked', $mes, $post_id, $sku); | |
| 4325 | - } | |
| 4326 | - | |
| 4327 | - function zaiko_check() { | |
| 4328 | - $mes = ''; | |
| 4329 | - $cart = $this->cart->get_cart(); | |
| 4330 | - $stocks = array(); | |
| 4331 | - | |
| 4332 | - for($i=0; $i<count($cart); $i++) { | |
| 4333 | - $cart_row = $cart[$i]; | |
| 4334 | - $post_id = $cart_row['post_id']; | |
| 4335 | - $sku = $cart_row['sku']; | |
| 4336 | - $sku_code = urldecode($cart_row['sku']); | |
| 4337 | - | |
| 4338 | - $quant = ( isset($_POST['quant']) ) ? trim($_POST['quant'][$i][$post_id][$sku]) : $cart_row['quantity']; | |
| 4339 | - //$zaiko_status = $this->getItemZaiko($post_id, $sku); | |
| 4340 | - $zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code); | |
| 4341 | - $stock = $this->getItemZaikoNum($post_id, $sku_code); | |
| 4342 | - if( !isset($stocks[$post_id][$sku]) ){ | |
| 4343 | - if( !WCUtils::is_blank($stock) ){ | |
| 4344 | - $stocks[$post_id][$sku] = $stock; | |
| 4345 | - }else{ | |
| 4346 | - $stocks[$post_id][$sku] = NULL; | |
| 4347 | - } | |
| 4348 | - } | |
| 4349 | - $checkstock = $stocks[$post_id][$sku]; | |
| 4350 | - $stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant; | |
| 4351 | - $itemRestriction = get_post_meta($post_id, '_itemRestriction', true); | |
| 4352 | - | |
| 4353 | - //$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : ''; | |
| 4354 | - | |
| 4355 | - if( 1 > (int)$quant ){ | |
| 4356 | - $mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "<br />"; | |
| 4357 | - }else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){ | |
| 4358 | - $mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "<br />"; | |
| 4359 | - }else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){ | |
| 4360 | - $mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "<br />"; | |
| 4361 | - }else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){ | |
| 4362 | - $mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "<br />"; | |
| 4363 | - } | |
| 4364 | - } | |
| 4365 | - $mes = apply_filters('usces_filter_zaiko_check', $mes, $cart); | |
| 4366 | - return $mes; | |
| 4367 | - } | |
| 4368 | - | |
| 4369 | - function member_check() { | |
| 4370 | - $mes = ''; | |
| 4371 | - foreach ( $_POST['member'] as $key => $vlue ) { | |
| 4372 | - $_SESSION['usces_member'][$key] = trim($vlue); | |
| 4373 | - } | |
| 4374 | - if ( $_POST['member_regmode'] == 'editmemberform' ) { | |
| 4375 | - if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) ) | |
| 4376 | - $mes .= __('Password is not correct.', 'usces') . "<br />"; | |
| 4377 | - if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) ) | |
| 4378 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4379 | - | |
| 4380 | - } else { | |
| 4381 | - if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) ) | |
| 4382 | - $mes .= __('Password is not correct.', 'usces') . "<br />"; | |
| 4383 | - 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']) ) | |
| 4384 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4385 | - | |
| 4386 | - } | |
| 4387 | - if ( WCUtils::is_blank($_POST["member"]["name1"]) ) | |
| 4388 | - $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299 | |
| 4389 | -// if ( trim($_POST["member"]["name3"]) == "" && USCES_JP ) | |
| 4390 | -// $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; | |
| 4391 | - if ( WCUtils::is_blank($_POST["member"]["zipcode"]) ) | |
| 4392 | - $mes .= __('postal code is not correct', 'usces') . "<br />"; | |
| 4393 | - if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') ) | |
| 4394 | - $mes .= __('enter the prefecture', 'usces') . "<br />"; | |
| 4395 | - if ( WCUtils::is_blank($_POST["member"]["address1"]) ) | |
| 4396 | - $mes .= __('enter the city name', 'usces') . "<br />"; | |
| 4397 | - if ( WCUtils::is_blank($_POST["member"]["address2"]) ) | |
| 4398 | - $mes .= __('enter house numbers', 'usces') . "<br />"; | |
| 4399 | - if ( WCUtils::is_blank($_POST["member"]["tel"]) ) | |
| 4400 | - $mes .= __('enter phone numbers', 'usces') . "<br />"; | |
| 4401 | - if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) ) | |
| 4402 | - $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />"; | |
| 4403 | - | |
| 4404 | - $mes = apply_filters('usces_filter_member_check', $mes); | |
| 4405 | - | |
| 4406 | - return $mes; | |
| 4407 | - } | |
| 4408 | - | |
| 4409 | - function member_check_fromcart() { | |
| 4410 | - $mes = ''; | |
| 4411 | - if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) ) | |
| 4412 | - $mes .= __('Password is not correct.', 'usces') . "<br />"; | |
| 4413 | - 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']) ) | |
| 4414 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4415 | - if ( WCUtils::is_blank($_POST["customer"]["name1"]) ) | |
| 4416 | - $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299 | |
| 4417 | -// if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP ) | |
| 4418 | -// $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; | |
| 4419 | - if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) ) | |
| 4420 | - $mes .= __('postal code is not correct', 'usces') . "<br />"; | |
| 4421 | - if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') ) | |
| 4422 | - $mes .= __('enter the prefecture', 'usces') . "<br />"; | |
| 4423 | - if ( WCUtils::is_blank($_POST["customer"]["address1"]) ) | |
| 4424 | - $mes .= __('enter the city name', 'usces') . "<br />"; | |
| 4425 | - if ( WCUtils::is_blank($_POST["customer"]["address2"]) ) | |
| 4426 | - $mes .= __('enter house numbers', 'usces') . "<br />"; | |
| 4427 | - if ( WCUtils::is_blank($_POST["customer"]["tel"]) ) | |
| 4428 | - $mes .= __('enter phone numbers', 'usces') . "<br />"; | |
| 4429 | - if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) ) | |
| 4430 | - $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />"; | |
| 4431 | - | |
| 4432 | - $mes = apply_filters('usces_filter_member_check_fromcart', $mes); | |
| 4433 | - | |
| 4434 | - return $mes; | |
| 4435 | - } | |
| 4436 | - | |
| 4437 | - function admin_member_check() { | |
| 4438 | - global $wpdb; | |
| 4439 | - $mes = ''; | |
| 4440 | - if ( !is_email( trim($_POST['member']["email"]) ) ){ | |
| 4441 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4442 | - }else{ | |
| 4443 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 4444 | - $mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) ); | |
| 4445 | - if( trim($_POST['member']["email"]) != $mem_email ){ | |
| 4446 | - $mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) ); | |
| 4447 | - if( !empty($mem_ID) ) | |
| 4448 | - $mes .= __('This e-mail address has been already registered.', 'usces') . "<br />"; | |
| 4449 | - } | |
| 4450 | - } | |
| 4451 | - if ( WCUtils::is_blank($_POST['member']["name1"]) ) | |
| 4452 | - $mes .= __('Name is not correct', 'usces') . "<br />"; | |
| 4453 | -// if ( trim($_POST["mem_name3"]) == "" && USCES_JP ) | |
| 4454 | -// $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; | |
| 4455 | -// if ( trim($_POST['member']["zipcode"]) == "" ) | |
| 4456 | -// $mes .= __('postal code is not correct', 'usces') . "<br />"; | |
| 4457 | -// if ( $_POST['member']["pref"] == __('-- Select --', 'usces') ) | |
| 4458 | -// $mes .= __('enter the prefecture', 'usces') . "<br />"; | |
| 4459 | -// if ( trim($_POST['member']["address1"]) == "" ) | |
| 4460 | -// $mes .= __('enter the city name', 'usces') . "<br />"; | |
| 4461 | -// if ( trim($_POST['member']["address2"]) == "" ) | |
| 4462 | -// $mes .= __('enter house numbers', 'usces') . "<br />"; | |
| 4463 | -// if ( trim($_POST['member']["tel"]) == "" ) | |
| 4464 | -// $mes .= __('enter phone numbers', 'usces') . "<br />"; | |
| 4465 | - if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) ) | |
| 4466 | - $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />"; | |
| 4467 | - | |
| 4468 | - $mes = apply_filters('usces_filter_admin_member_check', $mes); | |
| 4469 | - | |
| 4470 | - return $mes; | |
| 4471 | - } | |
| 4472 | - | |
| 4473 | - function customer_check() { | |
| 4474 | - $mes = ''; | |
| 4475 | - 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']) ) | |
| 4476 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4477 | - if ( WCUtils::is_blank($_POST["customer"]["name1"]) ) | |
| 4478 | - $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299 | |
| 4479 | -// if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP ) | |
| 4480 | -// $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; | |
| 4481 | - if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) ) | |
| 4482 | - $mes .= __('postal code is not correct', 'usces') . "<br />"; | |
| 4483 | - if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') ) | |
| 4484 | - $mes .= __('enter the prefecture', 'usces') . "<br />"; | |
| 4485 | - if ( WCUtils::is_blank($_POST["customer"]["address1"]) ) | |
| 4486 | - $mes .= __('enter the city name', 'usces') . "<br />"; | |
| 4487 | - if ( WCUtils::is_blank($_POST["customer"]["address2"]) ) | |
| 4488 | - $mes .= __('enter house numbers', 'usces') . "<br />"; | |
| 4489 | - if ( WCUtils::is_blank($_POST["customer"]["tel"]) ) | |
| 4490 | - $mes .= __('enter phone numbers', 'usces') . "<br />"; | |
| 4491 | - if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) ) | |
| 4492 | - $mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />"; | |
| 4493 | - | |
| 4494 | - $mes = apply_filters('usces_filter_customer_check', $mes); | |
| 4495 | - | |
| 4496 | - return $mes; | |
| 4497 | - } | |
| 4498 | - | |
| 4499 | - function delivery_check() { | |
| 4500 | - $mes = ''; | |
| 4501 | - if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { | |
| 4502 | - if ( WCUtils::is_blank($_POST["delivery"]["name1"]) ) | |
| 4503 | - $mes .= __('Name is not correct', 'usces') . "<br />";//20111116ysk 0000299 | |
| 4504 | -// if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP ) | |
| 4505 | -// $mes .= __('Invalid CANNAT pretend.', 'usces') . "<br />"; | |
| 4506 | - if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) ) | |
| 4507 | - $mes .= __('postal code is not correct', 'usces') . "<br />"; | |
| 4508 | - if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') ) | |
| 4509 | - $mes .= __('enter the prefecture', 'usces') . "<br />"; | |
| 4510 | - if ( WCUtils::is_blank($_POST["delivery"]["address1"]) ) | |
| 4511 | - $mes .= __('enter the city name', 'usces') . "<br />"; | |
| 4512 | - if ( WCUtils::is_blank($_POST["delivery"]["address2"]) ) | |
| 4513 | - $mes .= __('enter house numbers', 'usces') . "<br />"; | |
| 4514 | - if ( WCUtils::is_blank($_POST["delivery"]["tel"]) ) | |
| 4515 | - $mes .= __('enter phone numbers', 'usces') . "<br />"; | |
| 4516 | - } | |
| 4517 | - if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) ) | |
| 4518 | - $mes .= __('chose one from delivery method.', 'usces') . "<br />"; | |
| 4519 | - if ( !isset($_POST['offer']['payment_name']) ){ | |
| 4520 | - $mes .= __('chose one from payment options.', 'usces') . "<br />"; | |
| 4521 | - }else{ | |
| 4522 | - $payments = $this->getPayments($_POST['offer']['payment_name']); | |
| 4523 | - if('COD' == $payments['settlement']){ | |
| 4524 | - $total_items_price = $this->get_total_price(); | |
| 4525 | - $tax = $this->getTax( $total_items_price ); | |
| 4526 | - $total_items_price = $total_items_price + $tax; | |
| 4527 | - $cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0; | |
| 4528 | - if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount ) | |
| 4529 | - $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 />"; | |
| 4530 | - } | |
| 4531 | - | |
| 4532 | - } | |
| 4533 | -//20101119ysk start | |
| 4534 | - if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) { | |
| 4535 | - $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']); | |
| 4536 | - if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) { | |
| 4537 | - $payments = $this->getPayments($_POST['offer']['payment_name']); | |
| 4538 | - if('COD' == $payments['settlement']) | |
| 4539 | - $mes .= __('COD is not available.', 'usces') . "<br />"; | |
| 4540 | - } | |
| 4541 | - } | |
| 4542 | -//20101119ysk end | |
| 4543 | -//20110317ysk start | |
| 4544 | - if(isset($_POST['offer']['delivery_method'])) { | |
| 4545 | - $d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']); | |
| 4546 | - $country = $_SESSION['usces_entry']["delivery"]["country"]; | |
| 4547 | - $local_country = usces_get_base_country(); | |
| 4548 | - if($country == $local_country) { | |
| 4549 | - if($this->options['delivery_method'][$d_method_index]['intl'] == 1) { | |
| 4550 | - $mes .= __('配送方法が誤っています。国際便は指定できません。', 'usces') . "<br />"; | |
| 4551 | - } | |
| 4552 | - } else { | |
| 4553 | - if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) { | |
| 4554 | - $mes .= __('配送方法が誤っています。国際便を指定してください。', 'usces') . "<br />"; | |
| 4555 | - } | |
| 4556 | - } | |
| 4557 | - } | |
| 4558 | -//20110317ysk end | |
| 4559 | - | |
| 4560 | - $mes = apply_filters('usces_filter_delivery_check', $mes); | |
| 4561 | - | |
| 4562 | - return $mes; | |
| 4563 | - } | |
| 4564 | - | |
| 4565 | - function point_check( $entries ) { | |
| 4566 | - $member = $this->get_member(); | |
| 4567 | - $this->set_cart_fees( $member, $entries ); | |
| 4568 | - $mes = ''; | |
| 4569 | - if( isset($_POST['offer']["usedpoint"]) ) { | |
| 4570 | - if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) { | |
| 4571 | - $mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "<br />"; | |
| 4572 | - } else { | |
| 4573 | -/* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){ | |
| 4574 | - $mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt<br />"; | |
| 4575 | - $_POST['offer']["usedpoint"] = 0; | |
| 4576 | - $array = array( | |
| 4577 | - 'usedpoint' => 0 | |
| 4578 | - ); | |
| 4579 | - $this->cart->set_order_entry( $array ); | |
| 4580 | - }elseif($this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])){ | |
| 4581 | - $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])."pt<br />"; | |
| 4582 | - $_POST['offer']["usedpoint"] = 0; | |
| 4583 | - $array = array( | |
| 4584 | - 'usedpoint' => 0 | |
| 4585 | - ); | |
| 4586 | - $this->cart->set_order_entry( $array ); | |
| 4587 | - }elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){ | |
| 4588 | - $mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />"; | |
| 4589 | - $_POST['offer']["usedpoint"] = 0; | |
| 4590 | - $array = array( | |
| 4591 | - 'usedpoint' => 0 | |
| 4592 | - ); | |
| 4593 | - $this->cart->set_order_entry( $array ); | |
| 4594 | - } | |
| 4595 | -*/ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) { | |
| 4596 | - $mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt<br />"; | |
| 4597 | - } elseif( $this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee']) ) { | |
| 4598 | - $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'])."pt<br />"; | |
| 4599 | - } elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) { | |
| 4600 | - $mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt<br />"; | |
| 4601 | - } | |
| 4602 | - $mes = apply_filters( 'usces_filter_point_check', $mes ); | |
| 4603 | - if( '' != $mes ) { | |
| 4604 | - $_POST['offer']["usedpoint"] = 0; | |
| 4605 | - $array = array( | |
| 4606 | - 'usedpoint' => 0 | |
| 4607 | - ); | |
| 4608 | - $this->cart->set_order_entry( $array ); | |
| 4609 | - } | |
| 4610 | - } | |
| 4611 | - } | |
| 4612 | - return $mes; | |
| 4613 | - } | |
| 4614 | - | |
| 4615 | - function lostpass_mailaddcheck() { | |
| 4616 | - $mes = ''; | |
| 4617 | - if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) { | |
| 4618 | - $mes .= __('e-mail address is not correct', 'usces') . "<br />"; | |
| 4619 | - }elseif( !$this->is_member($_POST['loginmail']) ){ | |
| 4620 | - $mes .= __('It is the e-mail address that there is not.', 'usces') . "<br />"; | |
| 4621 | - } | |
| 4622 | - | |
| 4623 | - return $mes; | |
| 4624 | - } | |
| 4625 | - | |
| 4626 | - function changepass_check() { | |
| 4627 | - $mes = ''; | |
| 4628 | - if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2']))) | |
| 4629 | - $mes .= __('Password is not correct.', 'usces') . "<br />"; | |
| 4630 | - | |
| 4631 | - return $mes; | |
| 4632 | - } | |
| 4633 | - | |
| 4634 | - function get_page() { | |
| 4635 | - return $this->page; | |
| 4636 | - } | |
| 4637 | - | |
| 4638 | - function check_display_mode() { | |
| 4639 | - $options = get_option('usces'); | |
| 4640 | - if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return; | |
| 4641 | - | |
| 4642 | - $start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour']; | |
| 4643 | - $start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min']; | |
| 4644 | - $start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month']; | |
| 4645 | - $start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day']; | |
| 4646 | - $start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year']; | |
| 4647 | - $end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour']; | |
| 4648 | - $end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min']; | |
| 4649 | - $end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month']; | |
| 4650 | - $end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day']; | |
| 4651 | - $end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year']; | |
| 4652 | - $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']); | |
| 4653 | - $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']); | |
| 4654 | - $current_time = current_time('timestamp'); | |
| 4655 | - | |
| 4656 | - if( ($current_time >= $starttime) && ($current_time <= $endtime) ) | |
| 4657 | - $options['display_mode'] = 'Promotionsale'; | |
| 4658 | - else | |
| 4659 | - $options['display_mode'] = 'Usualsale'; | |
| 4660 | - | |
| 4661 | - update_option('usces', $options); | |
| 4662 | - | |
| 4663 | - } | |
| 4664 | - | |
| 4665 | - function update_business_days() { | |
| 4666 | - $options = get_option('usces'); | |
| 4667 | - $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 4668 | - $dhour = (int)substr($datetimestr, 11, 2); | |
| 4669 | - $dminute = (int)substr($datetimestr, 14, 2); | |
| 4670 | - $dsecond = (int)substr($datetimestr, 17, 2); | |
| 4671 | - $dmonth = (int)substr($datetimestr, 5, 2); | |
| 4672 | - $dday = (int)substr($datetimestr, 8, 2); | |
| 4673 | - $dyear = (int)substr($datetimestr, 0, 4); | |
| 4674 | - $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear); | |
| 4675 | - $datenow = getdate($dtimestamp); | |
| 4676 | - //list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1); | |
| 4677 | - list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1); | |
| 4678 | - | |
| 4679 | - if(isset($options['business_days'][$year][$mon][1])) | |
| 4680 | - unset($options['business_days'][$year][$mon]); | |
| 4681 | - | |
| 4682 | - for($i=0; $i<3; $i++){ | |
| 4683 | - //list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i); | |
| 4684 | - list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i); | |
| 4685 | - $last = getLastDay($year, $mon); | |
| 4686 | - for($j=1; $j<=$last; $j++){ | |
| 4687 | - if(!isset($options['business_days'][$year][$mon][$j])) | |
| 4688 | - $options['business_days'][$year][$mon][$j] = 1; | |
| 4689 | - } | |
| 4690 | - } | |
| 4691 | - | |
| 4692 | - update_option('usces', $options); | |
| 4693 | - | |
| 4694 | - $_SESSION['usces_checked_business_days'] = ''; | |
| 4695 | - } | |
| 4696 | - | |
| 4697 | - function display_cart() { | |
| 4698 | - if($this->cart->num_row() > 0) { | |
| 4699 | - include (USCES_PLUGIN_DIR . '/includes/cart_table.php'); | |
| 4700 | - } else { | |
| 4701 | - echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n"; | |
| 4702 | - } | |
| 4703 | - } | |
| 4704 | - | |
| 4705 | - function display_cart_confirm() { | |
| 4706 | - if($this->cart->num_row() > 0) { | |
| 4707 | - include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php'); | |
| 4708 | - } else { | |
| 4709 | - echo "<div class='no_cart'>" . __('There are no items in your cart.', 'usces') . "</div>\n"; | |
| 4710 | - } | |
| 4711 | - } | |
| 4712 | - | |
| 4713 | - function set_initial() { | |
| 4714 | - | |
| 4715 | - usces_log('set_initial : OK', 'database_error.log'); | |
| 4716 | - $rets07 = usces_upgrade_07(); | |
| 4717 | - $rets11 = usces_upgrade_11(); | |
| 4718 | - usces_log('rets11 : ' . print_r($rets11,true), 'database_error.log'); | |
| 4719 | - $this->set_default_theme(); | |
| 4720 | - $this->set_default_page(); | |
| 4721 | - $this->set_default_categories(); | |
| 4722 | - $this->create_table(); | |
| 4723 | - $this->update_table(); | |
| 4724 | - $this->update_options();//20120710ysk 0000472 | |
| 4725 | - } | |
| 4726 | - | |
| 4727 | - function create_table() { | |
| 4728 | - global $wpdb; | |
| 4729 | - | |
| 4730 | - if ( ! empty($wpdb->charset) ) | |
| 4731 | - $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; | |
| 4732 | - if ( ! empty($wpdb->collate) ) | |
| 4733 | - $charset_collate .= " COLLATE $wpdb->collate"; | |
| 4734 | - | |
| 4735 | - $access_table = $wpdb->prefix . "usces_access"; | |
| 4736 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 4737 | - $member_meta_table = $wpdb->prefix . "usces_member_meta"; | |
| 4738 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 4739 | - $order_meta_table = $wpdb->prefix . "usces_order_meta"; | |
| 4740 | - | |
| 4741 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 4742 | - | |
| 4743 | - if($wpdb->get_var("show tables like '$member_table'") != $member_table) { | |
| 4744 | - | |
| 4745 | - $sql = "CREATE TABLE " . $access_table . " ( | |
| 4746 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4747 | - acc_key VARCHAR( 50 ) NOT NULL , | |
| 4748 | - acc_type VARCHAR( 50 ) NULL , | |
| 4749 | - acc_value LONGTEXT NULL , | |
| 4750 | - acc_date DATE NOT NULL DEFAULT '0000-00-00', | |
| 4751 | - acc_num1 INT( 11 ) NOT NULL DEFAULT 0, | |
| 4752 | - acc_num2 INT( 11 ) NOT NULL DEFAULT 0, | |
| 4753 | - acc_str1 VARCHAR( 200 ) NULL , | |
| 4754 | - acc_str2 VARCHAR( 200 ) NULL , | |
| 4755 | - KEY acc_key ( acc_key ), | |
| 4756 | - KEY acc_type ( acc_type ), | |
| 4757 | - KEY acc_date ( acc_date ), | |
| 4758 | - KEY acc_num1 ( acc_num1 ), | |
| 4759 | - KEY acc_num2 ( acc_num2 ) | |
| 4760 | - ) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;"; | |
| 4761 | - | |
| 4762 | - dbDelta($sql); | |
| 4763 | - add_option("usces_db_access", USCES_DB_ACCESS); | |
| 4764 | - } | |
| 4765 | - if($wpdb->get_var("show tables like '$member_table'") != $member_table) { | |
| 4766 | - | |
| 4767 | - $sql = "CREATE TABLE " . $member_table . " ( | |
| 4768 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4769 | - mem_email VARCHAR( 100 ) NOT NULL , | |
| 4770 | - mem_pass VARCHAR( 64 ) NOT NULL , | |
| 4771 | - mem_status INT( 11 ) NOT NULL DEFAULT '0', | |
| 4772 | - mem_cookie VARCHAR( 13 ) NULL , | |
| 4773 | - mem_point INT( 11 ) NOT NULL DEFAULT '0', | |
| 4774 | - mem_name1 VARCHAR( 100 ) NOT NULL , | |
| 4775 | - mem_name2 VARCHAR( 100 ) NULL , | |
| 4776 | - mem_name3 VARCHAR( 100 ) NULL , | |
| 4777 | - mem_name4 VARCHAR( 100 ) NULL , | |
| 4778 | - mem_zip VARCHAR( 50 ) NULL , | |
| 4779 | - mem_pref VARCHAR( 100 ) NOT NULL , | |
| 4780 | - mem_address1 VARCHAR( 100 ) NOT NULL , | |
| 4781 | - mem_address2 VARCHAR( 100 ) NULL , | |
| 4782 | - mem_address3 VARCHAR( 100 ) NULL , | |
| 4783 | - mem_tel VARCHAR( 100 ) NOT NULL , | |
| 4784 | - mem_fax VARCHAR( 100 ) NULL , | |
| 4785 | - mem_delivery_flag TINYINT ( 1 ) NULL , | |
| 4786 | - mem_delivery LONGTEXT, | |
| 4787 | - mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 4788 | - mem_nicename VARCHAR( 50 ) NULL , | |
| 4789 | - KEY mem_email ( mem_email ) , | |
| 4790 | - KEY mem_pass ( mem_pass ) | |
| 4791 | - ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;"; | |
| 4792 | - | |
| 4793 | - dbDelta($sql); | |
| 4794 | - add_option("usces_db_member", USCES_DB_MEMBER); | |
| 4795 | - } | |
| 4796 | - if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) { | |
| 4797 | - | |
| 4798 | - $sql = "CREATE TABLE " . $member_meta_table . " ( | |
| 4799 | - mmeta_id bigint(20) NOT NULL auto_increment, | |
| 4800 | - member_id bigint(20) NOT NULL default '0', | |
| 4801 | - meta_key varchar(255) default NULL, | |
| 4802 | - meta_value longtext, | |
| 4803 | - PRIMARY KEY (mmeta_id), | |
| 4804 | - KEY order_id (member_id), | |
| 4805 | - KEY meta_key (meta_key) | |
| 4806 | - ) ENGINE = MYISAM $charset_collate;"; | |
| 4807 | - | |
| 4808 | - dbDelta($sql); | |
| 4809 | - add_option("usces_db_member_meta", USCES_DB_MEMBER_META); | |
| 4810 | - } | |
| 4811 | - if($wpdb->get_var("show tables like '$order_table'") != $order_table) { | |
| 4812 | - | |
| 4813 | - $sql = "CREATE TABLE " . $order_table . " ( | |
| 4814 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4815 | - mem_id BIGINT( 20 ) UNSIGNED NULL , | |
| 4816 | - order_email VARCHAR( 100 ) NOT NULL , | |
| 4817 | - order_name1 VARCHAR( 100 ) NOT NULL , | |
| 4818 | - order_name2 VARCHAR( 100 ) NULL , | |
| 4819 | - order_name3 VARCHAR( 100 ) NULL , | |
| 4820 | - order_name4 VARCHAR( 100 ) NULL , | |
| 4821 | - order_zip VARCHAR( 50 ) NULL , | |
| 4822 | - order_pref VARCHAR( 100 ) NOT NULL , | |
| 4823 | - order_address1 VARCHAR( 100 ) NOT NULL , | |
| 4824 | - order_address2 VARCHAR( 100 ) NULL , | |
| 4825 | - order_address3 VARCHAR( 100 ) NULL , | |
| 4826 | - order_tel VARCHAR( 100 ) NOT NULL , | |
| 4827 | - order_fax VARCHAR( 100 ) NULL , | |
| 4828 | - order_delivery LONGTEXT, | |
| 4829 | - order_cart LONGTEXT, | |
| 4830 | - order_note TEXT, | |
| 4831 | - order_delivery_time VARCHAR( 100 ) NOT NULL , | |
| 4832 | - order_payment_name VARCHAR( 100 ) NOT NULL , | |
| 4833 | - order_condition TEXT, | |
| 4834 | - order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4835 | - order_getpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 4836 | - order_usedpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 4837 | - order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4838 | - order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4839 | - order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4840 | - order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4841 | - order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 4842 | - order_modified VARCHAR( 20 ) NULL , | |
| 4843 | - order_status VARCHAR( 255 ) NULL , | |
| 4844 | - order_check VARCHAR( 255 ) NULL , | |
| 4845 | - order_delidue_date VARCHAR( 30 ) NULL , | |
| 4846 | - order_delivery_method INT( 10 ) NOT NULL DEFAULT -1, | |
| 4847 | - order_delivery_date VARCHAR( 100 ) NULL, | |
| 4848 | - KEY order_email ( order_email ) , | |
| 4849 | - KEY order_name1 ( order_name1 ) , | |
| 4850 | - KEY order_name2 ( order_name2 ) , | |
| 4851 | - KEY order_pref ( order_pref ) , | |
| 4852 | - KEY order_address1 ( order_address1 ) , | |
| 4853 | - KEY order_tel ( order_tel ) , | |
| 4854 | - KEY order_date ( order_date ) | |
| 4855 | - ) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;"; | |
| 4856 | - | |
| 4857 | - dbDelta($sql); | |
| 4858 | - add_option("usces_db_order", USCES_DB_ORDER); | |
| 4859 | - } | |
| 4860 | - if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) { | |
| 4861 | - | |
| 4862 | - $sql = "CREATE TABLE " . $order_meta_table . " ( | |
| 4863 | - ometa_id bigint(20) NOT NULL auto_increment, | |
| 4864 | - order_id bigint(20) NOT NULL default '0', | |
| 4865 | - meta_key varchar(255) default NULL, | |
| 4866 | - meta_value longtext, | |
| 4867 | - PRIMARY KEY (ometa_id), | |
| 4868 | - KEY order_id (order_id), | |
| 4869 | - KEY meta_key (meta_key) | |
| 4870 | - ) ENGINE = MYISAM $charset_collate;"; | |
| 4871 | - | |
| 4872 | - dbDelta($sql); | |
| 4873 | - add_option("usces_db_order_meta", USCES_DB_ORDER_META); | |
| 4874 | - } | |
| 4875 | - | |
| 4876 | - } | |
| 4877 | - | |
| 4878 | - function update_table() | |
| 4879 | - { | |
| 4880 | - global $wpdb; | |
| 4881 | - $access_table = $wpdb->prefix . "usces_access"; | |
| 4882 | - $member_table = $wpdb->prefix . "usces_member"; | |
| 4883 | - $member_meta_table = $wpdb->prefix . "usces_member_meta"; | |
| 4884 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 4885 | - $order_meta_table = $wpdb->prefix . "usces_order_meta"; | |
| 4886 | - | |
| 4887 | - $access_ver = get_option( "usces_db_access" ); | |
| 4888 | - $member_ver = get_option( "usces_db_member" ); | |
| 4889 | - $member_meta_ver = get_option( "usces_db_member_meta" ); | |
| 4890 | - $order_ver = get_option( "usces_db_order" ); | |
| 4891 | - $order_meta_ver = get_option( "usces_db_order_meta" ); | |
| 4892 | - | |
| 4893 | - if( $access_ver != USCES_DB_ACCESS ) { | |
| 4894 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 4895 | - $sql = "CREATE TABLE " . $access_table . " ( | |
| 4896 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4897 | - acc_key VARCHAR( 50 ) NOT NULL , | |
| 4898 | - acc_type VARCHAR( 50 ) NULL , | |
| 4899 | - acc_value LONGTEXT NULL , | |
| 4900 | - acc_date DATE NOT NULL DEFAULT '0000-00-00', | |
| 4901 | - acc_num1 INT( 11 ) NOT NULL DEFAULT 0, | |
| 4902 | - acc_num2 INT( 11 ) NOT NULL DEFAULT 0, | |
| 4903 | - acc_str1 VARCHAR( 200 ) NULL , | |
| 4904 | - acc_str2 VARCHAR( 200 ) NULL , | |
| 4905 | - KEY acc_key ( acc_key ), | |
| 4906 | - KEY acc_type ( acc_type ), | |
| 4907 | - KEY acc_date ( acc_date ), | |
| 4908 | - KEY acc_num1 ( acc_num1 ), | |
| 4909 | - KEY acc_num2 ( acc_num2 ) | |
| 4910 | - ) ENGINE = MYISAM;"; | |
| 4911 | - | |
| 4912 | - dbDelta($sql); | |
| 4913 | - update_option( "usces_db_access", USCES_DB_ACCESS ); | |
| 4914 | - } | |
| 4915 | - if( $member_ver != USCES_DB_MEMBER ) { | |
| 4916 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 4917 | - $sql = "CREATE TABLE " . $member_table . " ( | |
| 4918 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4919 | - mem_email VARCHAR( 100 ) NOT NULL , | |
| 4920 | - mem_pass VARCHAR( 64 ) NOT NULL , | |
| 4921 | - mem_status INT( 11 ) NOT NULL DEFAULT '0', | |
| 4922 | - mem_cookie VARCHAR( 13 ) NULL , | |
| 4923 | - mem_point INT( 11 ) NOT NULL DEFAULT '0', | |
| 4924 | - mem_name1 VARCHAR( 100 ) NOT NULL , | |
| 4925 | - mem_name2 VARCHAR( 100 ) NULL , | |
| 4926 | - mem_name3 VARCHAR( 100 ) NULL , | |
| 4927 | - mem_name4 VARCHAR( 100 ) NULL , | |
| 4928 | - mem_zip VARCHAR( 50 ) NULL , | |
| 4929 | - mem_pref VARCHAR( 100 ) NOT NULL , | |
| 4930 | - mem_address1 VARCHAR( 100 ) NOT NULL , | |
| 4931 | - mem_address2 VARCHAR( 100 ) NULL , | |
| 4932 | - mem_address3 VARCHAR( 100 ) NULL , | |
| 4933 | - mem_tel VARCHAR( 100 ) NOT NULL , | |
| 4934 | - mem_fax VARCHAR( 100 ) NULL , | |
| 4935 | - mem_delivery_flag TINYINT ( 1 ) NULL , | |
| 4936 | - mem_delivery LONGTEXT, | |
| 4937 | - mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 4938 | - mem_nicename VARCHAR( 50 ) NULL , | |
| 4939 | - KEY mem_email ( mem_email ) , | |
| 4940 | - KEY mem_pass ( mem_pass ) | |
| 4941 | - ) ENGINE = MYISAM;"; | |
| 4942 | - | |
| 4943 | - dbDelta($sql); | |
| 4944 | - update_option( "usces_db_member", USCES_DB_MEMBER ); | |
| 4945 | - } | |
| 4946 | - if( $member_meta_ver != USCES_DB_MEMBER_META ) { | |
| 4947 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 4948 | - $sql = "CREATE TABLE " . $member_meta_table . " ( | |
| 4949 | - mmeta_id bigint(20) NOT NULL auto_increment, | |
| 4950 | - member_id bigint(20) NOT NULL default '0', | |
| 4951 | - meta_key varchar(255) default NULL, | |
| 4952 | - meta_value longtext, | |
| 4953 | - PRIMARY KEY (mmeta_id), | |
| 4954 | - KEY order_id (member_id), | |
| 4955 | - KEY meta_key (meta_key) | |
| 4956 | - ) ENGINE = MYISAM;"; | |
| 4957 | - | |
| 4958 | - dbDelta($sql); | |
| 4959 | - update_option("usces_db_member_meta", USCES_DB_MEMBER_META); | |
| 4960 | - } | |
| 4961 | - if( $order_ver != USCES_DB_ORDER ) { | |
| 4962 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 4963 | - $sql = "CREATE TABLE " . $order_table . " ( | |
| 4964 | - ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , | |
| 4965 | - mem_id BIGINT( 20 ) UNSIGNED NULL , | |
| 4966 | - order_email VARCHAR( 100 ) NOT NULL , | |
| 4967 | - order_name1 VARCHAR( 100 ) NOT NULL , | |
| 4968 | - order_name2 VARCHAR( 100 ) NULL , | |
| 4969 | - order_name3 VARCHAR( 100 ) NULL , | |
| 4970 | - order_name4 VARCHAR( 100 ) NULL , | |
| 4971 | - order_zip VARCHAR( 50 ) NULL , | |
| 4972 | - order_pref VARCHAR( 100 ) NOT NULL , | |
| 4973 | - order_address1 VARCHAR( 100 ) NOT NULL , | |
| 4974 | - order_address2 VARCHAR( 100 ) NULL , | |
| 4975 | - order_address3 VARCHAR( 100 ) NULL , | |
| 4976 | - order_tel VARCHAR( 100 ) NOT NULL , | |
| 4977 | - order_fax VARCHAR( 100 ) NULL , | |
| 4978 | - order_delivery LONGTEXT, | |
| 4979 | - order_cart LONGTEXT, | |
| 4980 | - order_note TEXT, | |
| 4981 | - order_delivery_time VARCHAR( 100 ) NOT NULL , | |
| 4982 | - order_payment_name VARCHAR( 100 ) NOT NULL , | |
| 4983 | - order_condition TEXT, | |
| 4984 | - order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4985 | - order_getpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 4986 | - order_usedpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 4987 | - order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4988 | - order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4989 | - order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4990 | - order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 4991 | - order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 4992 | - order_modified VARCHAR( 20 ) NULL , | |
| 4993 | - order_status VARCHAR( 255 ) NULL , | |
| 4994 | - order_check VARCHAR( 255 ) NULL , | |
| 4995 | - order_delidue_date VARCHAR( 30 ) NULL , | |
| 4996 | - order_delivery_method INT( 10 ) NOT NULL DEFAULT -1, | |
| 4997 | - order_delivery_date VARCHAR( 100 ) NULL, | |
| 4998 | - KEY order_email ( order_email ) , | |
| 4999 | - KEY order_name1 ( order_name1 ) , | |
| 5000 | - KEY order_name2 ( order_name2 ) , | |
| 5001 | - KEY order_pref ( order_pref ) , | |
| 5002 | - KEY order_address1 ( order_address1 ) , | |
| 5003 | - KEY order_tel ( order_tel ) , | |
| 5004 | - KEY order_date ( order_date ) | |
| 5005 | - ) ENGINE = MYISAM;"; | |
| 5006 | - | |
| 5007 | - dbDelta($sql); | |
| 5008 | - update_option("usces_db_order", USCES_DB_ORDER); | |
| 5009 | - } | |
| 5010 | - if( $order_meta_ver != USCES_DB_ORDER_META ) { | |
| 5011 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); | |
| 5012 | - $sql = "CREATE TABLE " . $order_meta_table . " ( | |
| 5013 | - ometa_id bigint(20) NOT NULL auto_increment, | |
| 5014 | - order_id bigint(20) NOT NULL default '0', | |
| 5015 | - meta_key varchar(255) default NULL, | |
| 5016 | - meta_value longtext, | |
| 5017 | - PRIMARY KEY (ometa_id), | |
| 5018 | - KEY order_id (order_id), | |
| 5019 | - KEY meta_key (meta_key) | |
| 5020 | - ) ENGINE = MYISAM;"; | |
| 5021 | - | |
| 5022 | - dbDelta($sql); | |
| 5023 | - update_option("usces_db_order_meta", USCES_DB_ORDER_META); | |
| 5024 | - } | |
| 5025 | - } | |
| 5026 | - | |
| 5027 | - function set_default_theme() | |
| 5028 | - { | |
| 5029 | - $themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default'; | |
| 5030 | - $resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default'; | |
| 5031 | - if( file_exists($themepath) ) return false; | |
| 5032 | - if(!file_exists($resourcepath) ) return false; | |
| 5033 | - | |
| 5034 | - mkdir($themepath, 0775); | |
| 5035 | - $this->dir_copy($resourcepath, $themepath); | |
| 5036 | - | |
| 5037 | - } | |
| 5038 | - | |
| 5039 | - function dir_copy($source, $dest){ | |
| 5040 | - if ($res = opendir($source)) { | |
| 5041 | - while (($file = readdir($res)) !== false) { | |
| 5042 | - $sorce_path = $source . '/' . $file; | |
| 5043 | - $dest_path = $dest . '/' . $file; | |
| 5044 | - $filetype = @filetype($sorce_path); | |
| 5045 | - if( $filetype == 'file' ) { | |
| 5046 | - copy($sorce_path, $dest_path); | |
| 5047 | - }elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){ | |
| 5048 | - mkdir($dest_path); | |
| 5049 | - $this->dir_copy($sorce_path, $dest_path); | |
| 5050 | - } | |
| 5051 | - } | |
| 5052 | - closedir($res); | |
| 5053 | - } | |
| 5054 | - } | |
| 5055 | - | |
| 5056 | - function set_default_page() | |
| 5057 | - { | |
| 5058 | - global $wpdb; | |
| 5059 | - $datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); | |
| 5060 | - $datetime_gmt = gmdate('Y-m-d H:i:s', time()); | |
| 5061 | - | |
| 5062 | - //cart_page | |
| 5063 | - $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER); | |
| 5064 | - $cart_number = $wpdb->get_var( $query ); | |
| 5065 | - if( $cart_number === NULL ) { | |
| 5066 | - $query = $wpdb->prepare("INSERT INTO $wpdb->posts | |
| 5067 | - (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, | |
| 5068 | - comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, | |
| 5069 | - post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) | |
| 5070 | - VALUES (%d, %s, %s, %s, %s, %s, %s, | |
| 5071 | - %s, %s, %s, %s, %s, %s, %s, %s, | |
| 5072 | - %s, %d, %s, %d, %s, %s, %d)", | |
| 5073 | - 1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish', | |
| 5074 | - 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt, | |
| 5075 | - '', 0, '', 0, 'page', '', 0); | |
| 5076 | - $wpdb->query($query); | |
| 5077 | - $cart_number = $wpdb->insert_id; | |
| 5078 | - if( $cart_number !== NULL ) { | |
| 5079 | - $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)", | |
| 5080 | - $cart_number, '_wp_page_template', 'uscescart.php'); | |
| 5081 | - $wpdb->query($query); | |
| 5082 | - } | |
| 5083 | - } | |
| 5084 | - update_option('usces_cart_number', $cart_number); | |
| 5085 | - | |
| 5086 | - //member_page | |
| 5087 | - $query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER); | |
| 5088 | - $member_number = $wpdb->get_var( $query ); | |
| 5089 | - if( $member_number === NULL ) { | |
| 5090 | - $query = $wpdb->prepare("INSERT INTO $wpdb->posts | |
| 5091 | - (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, | |
| 5092 | - comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, | |
| 5093 | - post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) | |
| 5094 | - VALUES (%d, %s, %s, %s, %s, %s, %s, | |
| 5095 | - %s, %s, %s, %s, %s, %s, %s, %s, | |
| 5096 | - %s, %d, %s, %d, %s, %s, %d)", | |
| 5097 | - 1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish', | |
| 5098 | - 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt, | |
| 5099 | - '', 0, '', 0, 'page', '', 0); | |
| 5100 | - $wpdb->query($query); | |
| 5101 | - $member_number = $wpdb->insert_id; | |
| 5102 | - if( $member_number !== NULL ) { | |
| 5103 | - $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)", | |
| 5104 | - $member_number, '_wp_page_template', 'uscesmember.php'); | |
| 5105 | - $wpdb->query($query); | |
| 5106 | - } | |
| 5107 | - } | |
| 5108 | - update_option('usces_member_number', $member_number); | |
| 5109 | - | |
| 5110 | - } | |
| 5111 | - | |
| 5112 | - function set_default_categories() | |
| 5113 | - { | |
| 5114 | - global $wpdb; | |
| 5115 | - | |
| 5116 | - $idObj = get_category_by_slug('item'); | |
| 5117 | - if( empty($idObj) ) { | |
| 5118 | - $item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0); | |
| 5119 | - $item_cat_id = wp_insert_category($item_cat); | |
| 5120 | - update_option('usces_item_cat_parent_id', $item_cat_id); | |
| 5121 | - } | |
| 5122 | - | |
| 5123 | - $idObj = get_category_by_slug('itemreco'); | |
| 5124 | - if( empty($idObj) && isset($item_cat_id) ) { | |
| 5125 | - $itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id); | |
| 5126 | - $itemreco_cat_id = wp_insert_category($itemreco_cat); | |
| 5127 | - } | |
| 5128 | - | |
| 5129 | - $idObj = get_category_by_slug('itemnew'); | |
| 5130 | - if( empty($idObj) && isset($item_cat_id) ) { | |
| 5131 | - $itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id); | |
| 5132 | - $itemnew_cat_id = wp_insert_category($itemnew_cat); | |
| 5133 | - } | |
| 5134 | - | |
| 5135 | - $idObj = get_category_by_slug('itemgenre'); | |
| 5136 | - if( empty($idObj) && isset($item_cat_id) ) { | |
| 5137 | - $itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id); | |
| 5138 | - $itemgenre_cat_id = wp_insert_category($itemgenre_cat); | |
| 5139 | - } | |
| 5140 | - } | |
| 5141 | -//20120710ysk start 0000472 | |
| 5142 | - function update_options() { | |
| 5143 | - $target_market = $this->options['system']['target_market']; | |
| 5144 | - | |
| 5145 | - $update_shipping_charge = false; | |
| 5146 | - $shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array(); | |
| 5147 | - foreach( (array)$target_market as $tm ) { | |
| 5148 | - for( $i = 0; $i < count($shipping_charge); $i++ ) { | |
| 5149 | - if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) { | |
| 5150 | - foreach( $shipping_charge[$i]['value'] as $pref => $value ) { | |
| 5151 | - $shipping_charge[$i][$tm][$pref] = $value; | |
| 5152 | - } | |
| 5153 | - unset($shipping_charge[$i]['country']); | |
| 5154 | - unset($shipping_charge[$i]['value']); | |
| 5155 | - $update_shipping_charge = true; | |
| 5156 | - } | |
| 5157 | - } | |
| 5158 | - } | |
| 5159 | - if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge; | |
| 5160 | - | |
| 5161 | - $update_delivery_days = false; | |
| 5162 | - $delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array(); | |
| 5163 | - foreach( (array)$target_market as $tm ) { | |
| 5164 | - for( $i = 0; $i < count($delivery_days); $i++ ) { | |
| 5165 | - if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) { | |
| 5166 | - foreach( $delivery_days[$i]['value'] as $pref => $value ) { | |
| 5167 | - $delivery_days[$i][$tm][$pref] = $value; | |
| 5168 | - } | |
| 5169 | - unset($delivery_days[$i]['country']); | |
| 5170 | - unset($delivery_days[$i]['value']); | |
| 5171 | - $update_delivery_days = true; | |
| 5172 | - } | |
| 5173 | - } | |
| 5174 | - } | |
| 5175 | - if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days; | |
| 5176 | - | |
| 5177 | - if( $update_shipping_charge or $update_delivery_days ) | |
| 5178 | - update_option('usces', $this->options); | |
| 5179 | - } | |
| 5180 | -//20120710ysk end | |
| 5181 | - function get_item_cat_ids(){ | |
| 5182 | - $args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0); | |
| 5183 | - $categories = get_categories( $args ); | |
| 5184 | - foreach($categories as $category){ | |
| 5185 | - $ids[] = $category->term_id; | |
| 5186 | - } | |
| 5187 | - return $ids; | |
| 5188 | - } | |
| 5189 | - | |
| 5190 | - function get_item_post_ids(){ | |
| 5191 | - global $wpdb; | |
| 5192 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item'); | |
| 5193 | - $ids = $wpdb->get_col( $query ); | |
| 5194 | - | |
| 5195 | - return $ids; | |
| 5196 | - } | |
| 5197 | - | |
| 5198 | - function get_item_cat_genre_ids( $post_id ){ | |
| 5199 | - $ids = array(); | |
| 5200 | - $all_ids = array(); | |
| 5201 | - $genre = get_category_by_slug( 'itemgenre' ); | |
| 5202 | - $genre_id = $genre->term_id; | |
| 5203 | - $args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0); | |
| 5204 | - $categories = get_categories( $args ); | |
| 5205 | - foreach($categories as $category){ | |
| 5206 | - $ids[] = $category->term_id; | |
| 5207 | - } | |
| 5208 | - $allcats = get_the_category( $post_id ); | |
| 5209 | - foreach($allcats as $cat){ | |
| 5210 | - $all_ids[] = $cat->term_id; | |
| 5211 | - } | |
| 5212 | - //$all_ids = | |
| 5213 | - $results = array_intersect($ids, $all_ids); | |
| 5214 | - | |
| 5215 | - return $results; | |
| 5216 | - } | |
| 5217 | - | |
| 5218 | - function set_item_mime($post_id, $str) | |
| 5219 | - { | |
| 5220 | - global $wpdb; | |
| 5221 | - if( WCUtils::is_blank($str) ) return; | |
| 5222 | - | |
| 5223 | - $query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id); | |
| 5224 | - $results = $wpdb->query( $query ); | |
| 5225 | - return $results; | |
| 5226 | - } | |
| 5227 | - | |
| 5228 | - function isAdnminSSL() | |
| 5229 | - { | |
| 5230 | - $plugins = get_option('active_plugins'); | |
| 5231 | - foreach($plugins as $plugin) { | |
| 5232 | - if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) ) | |
| 5233 | - return true; | |
| 5234 | - } | |
| 5235 | - return false; | |
| 5236 | - } | |
| 5237 | - | |
| 5238 | - function getGuidTax() { | |
| 5239 | - $tax_rate = (int)$this->options['tax_rate']; | |
| 5240 | - if ( 0 < $tax_rate ) | |
| 5241 | - $str = '<em class="tax">'.__('(Excl. Tax)', 'usces').'</em>'; | |
| 5242 | - else | |
| 5243 | - $str = '<em class="tax">'.__('(Incl. Tax)', 'usces').'</em>'; | |
| 5244 | - | |
| 5245 | - return apply_filters('usces_filter_tax_guid', $str, $tax_rate); | |
| 5246 | - } | |
| 5247 | - | |
| 5248 | - function getItemCode($post_id) { | |
| 5249 | - $str = get_post_meta($post_id, '_itemCode', true); | |
| 5250 | - return $str; | |
| 5251 | - } | |
| 5252 | - | |
| 5253 | - function getItemName($post_id) { | |
| 5254 | - $str = get_post_meta($post_id, '_itemName', true); | |
| 5255 | - return $str; | |
| 5256 | - } | |
| 5257 | - | |
| 5258 | - function getItemRestriction($post_id) { | |
| 5259 | - $str = get_post_meta($post_id, '_itemRestriction', true); | |
| 5260 | - return $str; | |
| 5261 | - } | |
| 5262 | - | |
| 5263 | - function getItemPointrate($post_id) { | |
| 5264 | - $str = get_post_meta($post_id, '_itemPointrate', true); | |
| 5265 | - return $str; | |
| 5266 | - } | |
| 5267 | - | |
| 5268 | - function getItemShipping($post_id) { | |
| 5269 | - $str = get_post_meta($post_id, '_itemShipping', true); | |
| 5270 | - return $str; | |
| 5271 | - } | |
| 5272 | - | |
| 5273 | - function getItemShippingCharge($post_id) { | |
| 5274 | - $str = get_post_meta($post_id, '_itemShippingCharge', true); | |
| 5275 | - return (float)$str; | |
| 5276 | - } | |
| 5277 | - | |
| 5278 | - function getItemDeliveryMethod($post_id) { | |
| 5279 | - $str = get_post_meta($post_id, '_itemDeliveryMethod', true); | |
| 5280 | - if( empty($str) ) | |
| 5281 | - return array(); | |
| 5282 | - else | |
| 5283 | - return $str; | |
| 5284 | - } | |
| 5285 | - | |
| 5286 | - function getItemIndividualSCharge($post_id) { | |
| 5287 | - $str = get_post_meta($post_id, '_itemIndividualSCharge', true); | |
| 5288 | - return $str; | |
| 5289 | - } | |
| 5290 | - | |
| 5291 | - function getItemGpNum1($post_id) { | |
| 5292 | - $str = get_post_meta($post_id, '_itemGpNum1', true); | |
| 5293 | - return $str; | |
| 5294 | - } | |
| 5295 | - | |
| 5296 | - function getItemGpNum2($post_id) { | |
| 5297 | - $str = get_post_meta($post_id, '_itemGpNum2', true); | |
| 5298 | - return $str; | |
| 5299 | - } | |
| 5300 | - | |
| 5301 | - function getItemGpNum3($post_id) { | |
| 5302 | - $str = get_post_meta($post_id, '_itemGpNum3', true); | |
| 5303 | - return $str; | |
| 5304 | - } | |
| 5305 | - | |
| 5306 | - function getItemGpDis1($post_id) { | |
| 5307 | - $str = get_post_meta($post_id, '_itemGpDis1', true); | |
| 5308 | - return $str; | |
| 5309 | - } | |
| 5310 | - | |
| 5311 | - function getItemGpDis2($post_id) { | |
| 5312 | - $str = get_post_meta($post_id, '_itemGpDis2', true); | |
| 5313 | - return $str; | |
| 5314 | - } | |
| 5315 | - | |
| 5316 | - function getItemGpDis3($post_id) { | |
| 5317 | - $str = get_post_meta($post_id, '_itemGpDis3', true); | |
| 5318 | - return $str; | |
| 5319 | - } | |
| 5320 | - | |
| 5321 | - function getItemSku($post_id, $index = '') { | |
| 5322 | - $array = array(); | |
| 5323 | - $skus = $this->get_skus($post_id, 'sort'); | |
| 5324 | - foreach((array)$skus as $sku){ | |
| 5325 | - $array[] = $sku['code']; | |
| 5326 | - } | |
| 5327 | - if(!$array) return false; | |
| 5328 | - if($index == ''){ | |
| 5329 | - return $array; | |
| 5330 | - }else if(isset($array[$index])){ | |
| 5331 | - return $array[$index]; | |
| 5332 | - }else{ | |
| 5333 | - return false; | |
| 5334 | - } | |
| 5335 | - } | |
| 5336 | - | |
| 5337 | - function getItemPrice($post_id, $skukey = '') { | |
| 5338 | - $array = array(); | |
| 5339 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5340 | - foreach((array)$skus as $key => $sku){ | |
| 5341 | - $array[$key] = (float)str_replace('.', '', $sku['price']); | |
| 5342 | - } | |
| 5343 | - if(!$array) return false; | |
| 5344 | - if($skukey == ''){ | |
| 5345 | - return $array; | |
| 5346 | - }else if(isset($array[$skukey])){ | |
| 5347 | - return $array[$skukey]; | |
| 5348 | - }else{ | |
| 5349 | - return false; | |
| 5350 | - } | |
| 5351 | - } | |
| 5352 | - | |
| 5353 | - function getItemDiscount($post_id, $skukey = '') { | |
| 5354 | - $display_mode = $this->options['display_mode']; | |
| 5355 | - $array = array(); | |
| 5356 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5357 | - foreach((array)$skus as $key => $sku){ | |
| 5358 | - $price = (float)str_replace(',', '', $sku['price']); | |
| 5359 | - if ( $display_mode == 'Promotionsale' ) { | |
| 5360 | - if ( $this->options['campaign_privilege'] == 'discount' ){ | |
| 5361 | - if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){ | |
| 5362 | - $discount = $price * $this->options['privilege_discount'] / 100; | |
| 5363 | - }else{ | |
| 5364 | - $discount = 0; | |
| 5365 | - } | |
| 5366 | - }else if ( $this->options['campaign_privilege'] == 'point' ){ | |
| 5367 | - $discount = 0; | |
| 5368 | - } | |
| 5369 | - } | |
| 5370 | - | |
| 5371 | - $discount = ceil($discount); | |
| 5372 | - $array[$key] = $discount; | |
| 5373 | - } | |
| 5374 | - if(!$array) return false; | |
| 5375 | - if($skukey == ''){ | |
| 5376 | - return $array; | |
| 5377 | - }else if(isset($array[$skukey])){ | |
| 5378 | - return $array[$skukey]; | |
| 5379 | - }else{ | |
| 5380 | - return false; | |
| 5381 | - } | |
| 5382 | - } | |
| 5383 | - | |
| 5384 | - function getItemZaiko($post_id, $skukey = '') { | |
| 5385 | - $array = array(); | |
| 5386 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5387 | - foreach((array)$skus as $key => $sku){ | |
| 5388 | - $num = $sku['stock']; | |
| 5389 | - $array[$key] = $this->zaiko_status[$num]; | |
| 5390 | - } | |
| 5391 | - if(!$array) return false; | |
| 5392 | - if($skukey == ''){ | |
| 5393 | - return $array; | |
| 5394 | - }else if(isset($array[$skukey])){ | |
| 5395 | - return $array[$skukey]; | |
| 5396 | - }else{ | |
| 5397 | - return false; | |
| 5398 | - } | |
| 5399 | - } | |
| 5400 | - | |
| 5401 | - function getItemZaikoStatusId($post_id, $skukey = '') { | |
| 5402 | - $array = array(); | |
| 5403 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5404 | - foreach((array)$skus as $key => $sku){ | |
| 5405 | - $num = $sku['stock']; | |
| 5406 | - $array[$key] = $num; | |
| 5407 | - } | |
| 5408 | - if(!$array) return false; | |
| 5409 | - if($skukey == ''){ | |
| 5410 | - return $array; | |
| 5411 | - }else if(isset($array[$skukey])){ | |
| 5412 | - return $array[$skukey]; | |
| 5413 | - }else{ | |
| 5414 | - return false; | |
| 5415 | - } | |
| 5416 | - } | |
| 5417 | - | |
| 5418 | - function updateItemZaiko($post_id, $skucode, $value) { | |
| 5419 | - $res = usces_update_sku( $post_id, $skucode, 'stock', $value ); | |
| 5420 | - if( !$res ){ | |
| 5421 | - return false; | |
| 5422 | - }else{ | |
| 5423 | - return true; | |
| 5424 | - } | |
| 5425 | - } | |
| 5426 | - | |
| 5427 | - function getItemZaikoNum($post_id, $skukey = '') { | |
| 5428 | - $array = array(); | |
| 5429 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5430 | - foreach((array)$skus as $key => $sku){ | |
| 5431 | - $array[$key] = $sku['stocknum']; | |
| 5432 | - } | |
| 5433 | - if(!$array) return false; | |
| 5434 | - if($skukey == ''){ | |
| 5435 | - return $array; | |
| 5436 | - }else if(isset($array[$skukey])){ | |
| 5437 | - return $array[$skukey]; | |
| 5438 | - }else{ | |
| 5439 | - return false; | |
| 5440 | - } | |
| 5441 | - } | |
| 5442 | - | |
| 5443 | - function updateItemZaikoNum($post_id, $skucode, $value) { | |
| 5444 | - $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value ); | |
| 5445 | - if( !$res ){ | |
| 5446 | - return false; | |
| 5447 | - }else{ | |
| 5448 | - return true; | |
| 5449 | - } | |
| 5450 | - } | |
| 5451 | -//20120629ysk start 0000520 | |
| 5452 | - function getItemDivision( $post_id ){ | |
| 5453 | - if( usces_is_item($post_id) ){ | |
| 5454 | - $item_division = get_post_meta($post_id, '_item_division', true); | |
| 5455 | - $division = empty($item_division) ? 'shipped' : $item_division; | |
| 5456 | - }else{ | |
| 5457 | - $division = NULL; | |
| 5458 | - } | |
| 5459 | - return $division; | |
| 5460 | - } | |
| 5461 | -//20120629ysk end | |
| 5462 | - function getItemChargingType( $post_id, $cart = array() ){ | |
| 5463 | - if( usces_is_item($post_id) ){ | |
| 5464 | - $charging = get_post_meta($post_id, '_item_charging_type', true); | |
| 5465 | - //if( !defined('WCEX_DLSELLER') ) | |
| 5466 | - if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') ) | |
| 5467 | - $charging = NULL; | |
| 5468 | - }else{ | |
| 5469 | - $charging = NULL; | |
| 5470 | - } | |
| 5471 | - switch( $charging ){ | |
| 5472 | - case 0: | |
| 5473 | - $type = 'once'; | |
| 5474 | - break; | |
| 5475 | - case 1: | |
| 5476 | - $type = 'continue'; | |
| 5477 | - break; | |
| 5478 | - case 2: | |
| 5479 | - $type = 'regular'; | |
| 5480 | - if( !empty($cart) ) { | |
| 5481 | - if( empty($cart['advance']) ) { | |
| 5482 | - $type = 'once'; | |
| 5483 | - } else { | |
| 5484 | - $advance = $this->cart->wc_unserialize( $cart['advance'] ); | |
| 5485 | - $sku = urldecode( $cart['sku'] ); | |
| 5486 | - $regular = $advance[$post_id][$sku]['regular']; | |
| 5487 | - $unit = isset( $regular['unit'] ) ? $regular['unit'] : ''; | |
| 5488 | - $interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0; | |
| 5489 | - if( empty($unit) or 1 > $interval ) //通常課金扱い | |
| 5490 | - $type = 'once'; | |
| 5491 | - } | |
| 5492 | - } | |
| 5493 | - break; | |
| 5494 | - default: | |
| 5495 | - $type = NULL; | |
| 5496 | - } | |
| 5497 | - return $type; | |
| 5498 | - } | |
| 5499 | - | |
| 5500 | - function getItemFrequency( $post_id ){ | |
| 5501 | - $frequency = get_post_meta($post_id, '_item_frequency',true ); | |
| 5502 | - return $frequency; | |
| 5503 | - } | |
| 5504 | - | |
| 5505 | - function getItemChargingDay( $post_id ){ | |
| 5506 | - $array = get_post_meta($post_id, '_item_chargingday',true ); | |
| 5507 | - $day = (int)$array; | |
| 5508 | - $chargingday = empty($day) ? 1 : $day; | |
| 5509 | - return $chargingday; | |
| 5510 | - } | |
| 5511 | - | |
| 5512 | - function getItemSkuDisp($post_id, $skukey = '') { | |
| 5513 | - $array = array(); | |
| 5514 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5515 | - foreach((array)$skus as $key => $sku){ | |
| 5516 | - $array[$key] = $sku['name']; | |
| 5517 | - } | |
| 5518 | - if(!$array) return false; | |
| 5519 | - if($skukey == ''){ | |
| 5520 | - return $array; | |
| 5521 | - }else if(isset($array[$skukey])){ | |
| 5522 | - return $array[$skukey]; | |
| 5523 | - }else{ | |
| 5524 | - return false; | |
| 5525 | - } | |
| 5526 | - } | |
| 5527 | - | |
| 5528 | -// function getItemSkuChargingType($post_id, $skukey = '') { | |
| 5529 | -// $fields = get_post_custom($post_id); | |
| 5530 | -// $skus = array(); | |
| 5531 | -// foreach((array)$fields as $key => $value){ | |
| 5532 | -// if( preg_match('/^_isku_/', $key, $match) ){ | |
| 5533 | -// $key = substr($key, 6); | |
| 5534 | -// $values = maybe_unserialize($value[0]); | |
| 5535 | -// if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){ | |
| 5536 | -// $skus[$key] = $values['charging_type']; | |
| 5537 | -// }else{ | |
| 5538 | -// continue; | |
| 5539 | -// } | |
| 5540 | -// } | |
| 5541 | -// } | |
| 5542 | -// if( empty($skus) ) return false; | |
| 5543 | -// if($skukey == ''){ | |
| 5544 | -// return $skus; | |
| 5545 | -// }elseif( isset($skus[$skukey]) ){ | |
| 5546 | -// return $skus[$skukey]; | |
| 5547 | -// }else{ | |
| 5548 | -// return false; | |
| 5549 | -// } | |
| 5550 | -// } | |
| 5551 | - | |
| 5552 | - function getItemSkuUnit($post_id, $skukey = '') { | |
| 5553 | - $array = array(); | |
| 5554 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5555 | - foreach((array)$skus as $key => $sku){ | |
| 5556 | - $array[$key] = $sku['unit']; | |
| 5557 | - } | |
| 5558 | - if(!$array) return false; | |
| 5559 | - if($skukey == ''){ | |
| 5560 | - return $array; | |
| 5561 | - }else if(isset($array[$skukey])){ | |
| 5562 | - return $array[$skukey]; | |
| 5563 | - }else{ | |
| 5564 | - return false; | |
| 5565 | - } | |
| 5566 | - } | |
| 5567 | - | |
| 5568 | - function get_item( $post_id ) { | |
| 5569 | - $usces_item['post_id'] = $post_id; | |
| 5570 | - $usces_item['itemCode'] = $this->getItemCode($post_id); | |
| 5571 | - $usces_item['itemName'] = $this->getItemName($post_id); | |
| 5572 | - | |
| 5573 | - $skus = $this->get_skus($post_id, 'code'); | |
| 5574 | - foreach((array)$skus as $key => $sku){ | |
| 5575 | - $usces_item['skuCodes'][] = $key; | |
| 5576 | - $usces_item['skuValues'][] = $sku; | |
| 5577 | - } | |
| 5578 | - | |
| 5579 | - $usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id); | |
| 5580 | - | |
| 5581 | - return $usces_item; | |
| 5582 | - } | |
| 5583 | - | |
| 5584 | - function get_itemOptionKey( $post_id, $enc = false ) { | |
| 5585 | - $opts = usces_get_opts( $post_id ); | |
| 5586 | - if(empty($opts)) return; | |
| 5587 | - | |
| 5588 | - $res = array(); | |
| 5589 | - foreach ( (array)$opts as $opt ) { | |
| 5590 | - if( $enc ) | |
| 5591 | - $res[] = urlencode($opt['name']); | |
| 5592 | - else | |
| 5593 | - $res[] = $opt['name']; | |
| 5594 | - } | |
| 5595 | - return $res; | |
| 5596 | - } | |
| 5597 | - | |
| 5598 | - function get_itemOptions( $key, $post_id ) { | |
| 5599 | - $opts = usces_get_opts( $post_id, 'name' ); | |
| 5600 | - if(empty($opts[$key])) | |
| 5601 | - return; | |
| 5602 | - else | |
| 5603 | - return $opts[$key]; | |
| 5604 | - } | |
| 5605 | - | |
| 5606 | - function get_postIDbyCode( $itemcode ) { | |
| 5607 | - global $wpdb; | |
| 5608 | - | |
| 5609 | - $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode); | |
| 5610 | - $res = $wpdb->get_var( $query ); | |
| 5611 | - return $res; | |
| 5612 | - } | |
| 5613 | - | |
| 5614 | - function get_pictids($item_code) { | |
| 5615 | - global $wpdb, $usces; | |
| 5616 | - | |
| 5617 | - if( empty($item_code) ) | |
| 5618 | - return false; | |
| 5619 | - | |
| 5620 | - if( !$usces->options['system']['subimage_rule'] ){ | |
| 5621 | - $codestr = $item_code.'%'; | |
| 5622 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_title <> %s AND post_type = 'attachment' ORDER BY post_title", $codestr, $item_code); | |
| 5623 | - }else{ | |
| 5624 | - $codestr = $item_code.'--%'; | |
| 5625 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr); | |
| 5626 | - } | |
| 5627 | - $results = $wpdb->get_col( $query ); | |
| 5628 | - return $results; | |
| 5629 | - } | |
| 5630 | - | |
| 5631 | - function get_mainpictid($item_code) { | |
| 5632 | - global $wpdb; | |
| 5633 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code); | |
| 5634 | - $id = $wpdb->get_var( $query ); | |
| 5635 | - $id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code ); | |
| 5636 | - return $id; | |
| 5637 | - } | |
| 5638 | - | |
| 5639 | - function get_skus( $post_id, $keyflag = 'sort' ) { | |
| 5640 | - if( !$post_id ) | |
| 5641 | - return array(); | |
| 5642 | - | |
| 5643 | - $skus = array(); | |
| 5644 | - $metas = usces_get_post_meta($post_id, '_isku_'); | |
| 5645 | - if( empty($metas) ) return $skus; | |
| 5646 | - | |
| 5647 | - foreach( $metas as $rows ){ | |
| 5648 | - $values = unserialize($rows['meta_value']); | |
| 5649 | - $key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort']; | |
| 5650 | - $skus[$key] = array( | |
| 5651 | - 'meta_id' => $rows['meta_id'], | |
| 5652 | - 'code' => $values['code'], | |
| 5653 | - 'name' => $values['name'], | |
| 5654 | - 'cprice' => $values['cprice'], | |
| 5655 | - 'price' => $values['price'], | |
| 5656 | - 'unit' => $values['unit'], | |
| 5657 | - 'stocknum' => $values['stocknum'], | |
| 5658 | - 'stock' => $values['stock'], | |
| 5659 | - 'gp' => $values['gp'], | |
| 5660 | - 'sort' => $values['sort'], | |
| 5661 | - 'advance' => isset($values['advance']) ? $values['advance'] : '' | |
| 5662 | - ); | |
| 5663 | - } | |
| 5664 | - $skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag ); | |
| 5665 | - ksort($skus); | |
| 5666 | - | |
| 5667 | - return $skus; | |
| 5668 | - } | |
| 5669 | - | |
| 5670 | - function is_item( $post ) { | |
| 5671 | - | |
| 5672 | - if( $post->post_mime_type == 'item' ) | |
| 5673 | - return true; | |
| 5674 | - else | |
| 5675 | - return false; | |
| 5676 | - } | |
| 5677 | - | |
| 5678 | - function getItemIds( $end_type ) { | |
| 5679 | - global $wpdb; | |
| 5680 | - if( 'front' == $end_type ) | |
| 5681 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item'); | |
| 5682 | - if( 'back' == $end_type ) | |
| 5683 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item'); | |
| 5684 | - $ids = $wpdb->get_col( $query ); | |
| 5685 | - if( empty($ids) ) $ids = array(); | |
| 5686 | - return $ids; | |
| 5687 | - } | |
| 5688 | - | |
| 5689 | - function getNotItemIds() { | |
| 5690 | - global $wpdb; | |
| 5691 | - $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item'); | |
| 5692 | - $ids = $wpdb->get_col( $query ); | |
| 5693 | - if( empty($ids) ) $ids = array(); | |
| 5694 | - return $ids; | |
| 5695 | - } | |
| 5696 | - | |
| 5697 | - function getPaymentMethod( $name ) { | |
| 5698 | - $res = array(); | |
| 5699 | - $payments = $this->options['payment_method']; | |
| 5700 | - foreach ( (array)$payments as $payment ) { | |
| 5701 | - if($name = $payment['name']) { | |
| 5702 | - $res = $payment; | |
| 5703 | - break; | |
| 5704 | - } | |
| 5705 | - } | |
| 5706 | - return $res; | |
| 5707 | - } | |
| 5708 | - | |
| 5709 | - function order_processing( $results = array() ) { | |
| 5710 | - do_action('usces_pre_reg_orderdata'); | |
| 5711 | - //db(function.php) | |
| 5712 | -//20110203ysk start | |
| 5713 | - $res = usces_check_acting_return_duplicate( $results ); | |
| 5714 | - if($res != NULL) { | |
| 5715 | - usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log'); | |
| 5716 | - return 'ordercompletion'; | |
| 5717 | - } | |
| 5718 | - if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) { | |
| 5719 | - usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK | |
| 5720 | - } | |
| 5721 | -//20110203ysk end | |
| 5722 | -//20110621ysk start 0000184 | |
| 5723 | - if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) { | |
| 5724 | - if( !usces_paypal_doecp( $results ) ) | |
| 5725 | - return 'error'; | |
| 5726 | - } | |
| 5727 | -//20110621ysk end | |
| 5728 | - $order_id = usces_reg_orderdata( $results ); | |
| 5729 | - do_action('usces_post_reg_orderdata', $order_id, $results); | |
| 5730 | - | |
| 5731 | - if ( $order_id ) { | |
| 5732 | - //mail(function.php) | |
| 5733 | - $mail_res = usces_send_ordermail( $order_id ); | |
| 5734 | - return 'ordercompletion'; | |
| 5735 | - | |
| 5736 | - } else { | |
| 5737 | - return 'error'; | |
| 5738 | - } | |
| 5739 | - | |
| 5740 | - } | |
| 5741 | - | |
| 5742 | - function acting_processing($acting_flg, $query) { | |
| 5743 | - global $wpdb; | |
| 5744 | - $entry = $this->cart->get_entry(); | |
| 5745 | - $delim = apply_filters( 'usces_filter_delim', $this->delim ); | |
| 5746 | - $acting_flg = trim($acting_flg); | |
| 5747 | - //$usces_entries = $this->cart->get_entry(); | |
| 5748 | - | |
| 5749 | - if( empty($acting_flg) ) return 'error'; | |
| 5750 | - | |
| 5751 | - | |
| 5752 | - //include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg); | |
| 5753 | - if($acting_flg == 'paypal.php'){ | |
| 5754 | -// if( !file_exists($this->options['settlement_path'] . $acting_flg) ) | |
| 5755 | -// return 'error'; | |
| 5756 | -// | |
| 5757 | -// require_once($this->options['settlement_path'] . "paypal.php"); | |
| 5758 | -// paypal_submit(); | |
| 5759 | - | |
| 5760 | - }else if($acting_flg == 'epsilon.php'){ | |
| 5761 | - if( !file_exists($this->options['settlement_path'] . $acting_flg) ) | |
| 5762 | - return 'error'; | |
| 5763 | - | |
| 5764 | - if ( $this->use_ssl ) { | |
| 5765 | - $redirect = str_replace('http://', 'https://', USCES_CART_URL); | |
| 5766 | - }else{ | |
| 5767 | - $redirect = USCES_CART_URL; | |
| 5768 | - } | |
| 5769 | - usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 5770 | - $query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect); | |
| 5771 | - $query = $delim . ltrim($query, '&'); | |
| 5772 | - header("location: " . $redirect . $query); | |
| 5773 | - exit; | |
| 5774 | - | |
| 5775 | - }else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){ | |
| 5776 | - if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){ | |
| 5777 | - if( !isset($_REQUEST['PaRes'])){ | |
| 5778 | - | |
| 5779 | - usces_log('zeus card entry data2 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 5780 | - usces_zeus_3dsecure_enrol(); | |
| 5781 | - | |
| 5782 | - }else if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] && isset($_REQUEST['PaRes'])){ | |
| 5783 | - | |
| 5784 | - usces_zeus_3dsecure_auth(); | |
| 5785 | - } | |
| 5786 | - }else{ | |
| 5787 | - $res = usces_zeus_secure_payreq(); | |
| 5788 | - return $res; | |
| 5789 | - } | |
| 5790 | - }else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){ | |
| 5791 | - | |
| 5792 | - $acting_opts = $this->options['acting_settings']['zeus']; | |
| 5793 | - $interface = parse_url($acting_opts['card_url']); | |
| 5794 | - | |
| 5795 | - //usces_log('zeus card ***** : '.print_r($entry, true), 'acting_transaction.log'); | |
| 5796 | - | |
| 5797 | - $vars = 'send=mall'; | |
| 5798 | - $vars .= '&clientip=' . $acting_opts['clientip']; | |
| 5799 | - $vars .= '&cardnumber=' . $_POST['cardnumber']; | |
| 5800 | - if( 1 == $this->options['acting_settings']['zeus']['security'] ){ | |
| 5801 | - $vars .= '&seccode=' . $_POST['securecode']; | |
| 5802 | - } | |
| 5803 | - $vars .= '&expyy=' . substr($_POST['expyy'], 2); | |
| 5804 | - $vars .= '&expmm=' . $_POST['expmm']; | |
| 5805 | - $vars .= '&telno=' . str_replace('-', '', $_POST['telno']); | |
| 5806 | - $vars .= '&email=' . $_POST['email']; | |
| 5807 | - $vars .= '&sendid=' . $_POST['sendid']; | |
| 5808 | - $vars .= '&username=' . $_POST['username']; | |
| 5809 | - $vars .= '&money=' . $_POST['money']; | |
| 5810 | - $vars .= '&sendpoint=' . $_POST['sendpoint']; | |
| 5811 | - $vars .= '&printord=' . $_POST['printord']; | |
| 5812 | - if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){ | |
| 5813 | - $vars .= '&div=' . $_POST['div']; | |
| 5814 | - } | |
| 5815 | - | |
| 5816 | - //usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log'); | |
| 5817 | - | |
| 5818 | - $header = "POST " . $interface['path'] . " HTTP/1.1\r\n"; | |
| 5819 | - $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n"; | |
| 5820 | - //$header .= "Host: usctest.securesites.com\r\n"; | |
| 5821 | - $header .= "User-Agent: PHP Script\r\n"; | |
| 5822 | - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| 5823 | - $header .= "Content-Length: " . strlen($vars) . "\r\n"; | |
| 5824 | - $header .= "Connection: close\r\n\r\n"; | |
| 5825 | - $header .= $vars; | |
| 5826 | - $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30); | |
| 5827 | - | |
| 5828 | - if ($fp){ | |
| 5829 | - fwrite($fp, $header); | |
| 5830 | - while ( !feof($fp) ) { | |
| 5831 | - $scr = fgets($fp, 1024); | |
| 5832 | - $page .= $scr; | |
| 5833 | - } | |
| 5834 | - fclose($fp); | |
| 5835 | - | |
| 5836 | - //usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log'); | |
| 5837 | - if( false !== strpos( $page, 'Success_order') ){ | |
| 5838 | - usces_log('zeus card entry data1 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 5839 | - $ordd = usces_get_order_number( $page ); | |
| 5840 | -//20120904ysk start 0000541 | |
| 5841 | - if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) { | |
| 5842 | - $args = ''; | |
| 5843 | - } else { | |
| 5844 | - $div = 'div_'.$_POST['cbrand']; | |
| 5845 | - $args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div]; | |
| 5846 | - } | |
| 5847 | - $args .= '&order_number='.$ordd; | |
| 5848 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args); | |
| 5849 | -//20120904ysk end | |
| 5850 | - exit; | |
| 5851 | - }else{ | |
| 5852 | - usces_log('zeus card : Certification Error', 'acting_transaction.log'); | |
| 5853 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0'); | |
| 5854 | - exit; | |
| 5855 | - } | |
| 5856 | - }else{ | |
| 5857 | - usces_log('zeus card : Socket Error', 'acting_transaction.log'); | |
| 5858 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0'); | |
| 5859 | - } | |
| 5860 | - exit; | |
| 5861 | - | |
| 5862 | - }else if($acting_flg == 'acting_zeus_conv'){ | |
| 5863 | - | |
| 5864 | - $acting_opts = $this->options['acting_settings']['zeus']; | |
| 5865 | - $interface = parse_url($acting_opts['conv_url']); | |
| 5866 | - | |
| 5867 | - | |
| 5868 | - $vars .= 'clientip=' . $acting_opts['clientip_conv']; | |
| 5869 | - $vars .= '&act=' . $_POST['act']; | |
| 5870 | - $vars .= '&money=' . $_POST['money']; | |
| 5871 | - $vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8'); | |
| 5872 | - $vars .= '&telno=' . str_replace('-', '', $_POST['telno']); | |
| 5873 | - $vars .= '&email=' . $_POST['email']; | |
| 5874 | - $vars .= '&pay_cvs=' . $_POST['pay_cvs']; | |
| 5875 | - $vars .= '&sendid=' . $_POST['sendid']; | |
| 5876 | - $vars .= '&sendpoint=' . $_POST['sendpoint']; | |
| 5877 | - if( !WCUtils::is_blank($acting_opts['testid_conv']) ){ | |
| 5878 | - $vars .= '&testid=' . $acting_opts['testid_conv']; | |
| 5879 | - $vars .= '&test_type=' . $acting_opts['test_type_conv']; | |
| 5880 | - } | |
| 5881 | - | |
| 5882 | - | |
| 5883 | - $header = "POST " . $interface['path'] . " HTTP/1.1\r\n"; | |
| 5884 | - $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n"; | |
| 5885 | - $header .= "User-Agent: PHP Script\r\n"; | |
| 5886 | - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| 5887 | - $header .= "Content-Length: " . strlen($vars) . "\r\n"; | |
| 5888 | - $header .= "Connection: close\r\n\r\n"; | |
| 5889 | - $header .= $vars; | |
| 5890 | - $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30); | |
| 5891 | - | |
| 5892 | - if ($fp){ | |
| 5893 | - fwrite($fp, $header); | |
| 5894 | - while ( !feof($fp) ) { | |
| 5895 | - $scr = fgets($fp, 1024); | |
| 5896 | - $page .= $scr; | |
| 5897 | - if( false !== strpos( $scr, 'order_no') ) | |
| 5898 | - $qstr .= trim($scr) . '&'; | |
| 5899 | - if( false !== strpos( $scr, 'pay_no1') ) | |
| 5900 | - $qstr .= trim($scr) . '&'; | |
| 5901 | - if( false !== strpos( $scr, 'pay_no2') ) | |
| 5902 | - $qstr .= trim($scr) . '&'; | |
| 5903 | - if( false !== strpos( $scr, 'pay_limit') ) | |
| 5904 | - $qstr .= trim($scr) . '&'; | |
| 5905 | - if( false !== strpos( $scr, 'pay_url') ) | |
| 5906 | - $qstr .= trim($scr) . '&'; | |
| 5907 | - if( false !== strpos( $scr, 'error_code') ) | |
| 5908 | - $qstr .= trim($scr) . '&'; | |
| 5909 | - if( false !== strpos( $scr, 'sendpoint') ) | |
| 5910 | - $qstr .= trim($scr) . '&'; | |
| 5911 | - } | |
| 5912 | - $qstr .= 'pay_cvs=' . $_POST['pay_cvs']; | |
| 5913 | - fclose($fp); | |
| 5914 | - //usces_log('zeus page : '.$page, 'acting_transaction.log'); | |
| 5915 | - | |
| 5916 | - if( false !== strpos( $page, 'Success_order') ){ | |
| 5917 | - usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 5918 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr); | |
| 5919 | - exit; | |
| 5920 | - }else{ | |
| 5921 | - usces_log('zeus data NG : '.$page, 'acting_transaction.log'); | |
| 5922 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0'); | |
| 5923 | - exit; | |
| 5924 | - } | |
| 5925 | - }else{ | |
| 5926 | - usces_log('zeus : sockopen NG', 'acting_transaction.log'); | |
| 5927 | - header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0'); | |
| 5928 | - } | |
| 5929 | - exit; | |
| 5930 | - | |
| 5931 | -//20110208ysk start | |
| 5932 | - }else if($acting_flg == 'acting_paypal_ec') { | |
| 5933 | - $acting_opts = $this->options['acting_settings']['paypal']; | |
| 5934 | - | |
| 5935 | - $nvpstr = $query; | |
| 5936 | - $nvpstr .= '&CURRENCYCODE='.$this->get_currency_code(); | |
| 5937 | - //$nvpstr .= '&ADDROVERRIDE=1'; | |
| 5938 | - $nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale'); | |
| 5939 | - | |
| 5940 | - //The returnURL is the location where buyers return to when a payment has been succesfully authorized. | |
| 5941 | - $nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1'); | |
| 5942 | - | |
| 5943 | - //The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow | |
| 5944 | - $nvpstr .= '&CANCELURL='.urlencode(USCES_CART_URL.$delim.'confirm=1'); | |
| 5945 | - | |
| 5946 | - $nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL); | |
| 5947 | - | |
| 5948 | - $this->paypal->setMethod('SetExpressCheckout'); | |
| 5949 | - $this->paypal->setData($nvpstr); | |
| 5950 | - $res = $this->paypal->doExpressCheckout(); | |
| 5951 | - $resArray = $this->paypal->getResponse(); | |
| 5952 | - $ack = strtoupper($resArray["ACK"]); | |
| 5953 | - if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { | |
| 5954 | - $token = urldecode($resArray["TOKEN"]); | |
| 5955 | - $payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit'; | |
| 5956 | - header("Location: ".$payPalURL); | |
| 5957 | - | |
| 5958 | - } else { | |
| 5959 | - //Display a user friendly Error on the page using any of the following error information returned by PayPal | |
| 5960 | - $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); | |
| 5961 | - $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); | |
| 5962 | - $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); | |
| 5963 | - $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); | |
| 5964 | - 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'); | |
| 5965 | - header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0'); | |
| 5966 | - } | |
| 5967 | - exit; | |
| 5968 | -//20110208ysk end | |
| 5969 | -//20121030ysk start | |
| 5970 | - } elseif( $acting_flg == 'acting_telecom_edy' ) { | |
| 5971 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 5972 | - $value = array(); | |
| 5973 | - $value['usces_cart'] = $_SESSION['usces_cart']; | |
| 5974 | - $value['usces_entry'] = $_SESSION['usces_entry']; | |
| 5975 | - $value['usces_member'] = $_SESSION['usces_member']; | |
| 5976 | - $mvalue = serialize( $value ); | |
| 5977 | - $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue ); | |
| 5978 | - $res = $wpdb->query( $mquery ); | |
| 5979 | - | |
| 5980 | - unset( $_SESSION['usces_cart'] ); | |
| 5981 | - unset( $_SESSION['usces_entry'] ); | |
| 5982 | - | |
| 5983 | - $acting_opts = $this->options['acting_settings']['telecom']; | |
| 5984 | - header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query ); | |
| 5985 | - exit; | |
| 5986 | -//20121030ysk end | |
| 5987 | -//20121206ysk start | |
| 5988 | - } else if( $acting_flg == 'acting_digitalcheck_card' ) { | |
| 5989 | - $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 5990 | - $interface = parse_url($acting_opts['send_url_user_id']); | |
| 5991 | - $kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei']; | |
| 5992 | - | |
| 5993 | - $vars = 'IP='.$acting_opts['card_ip']; | |
| 5994 | - $vars .= '&PASS='.$acting_opts['card_pass']; | |
| 5995 | - $vars .= '&IP_USER_ID='.$_POST['IP_USER_ID']; | |
| 5996 | - $vars .= '&SID='.$_POST['SID']; | |
| 5997 | - $vars .= '&STORE=51'; | |
| 5998 | - $vars .= '&N1='.$_POST['N1']; | |
| 5999 | - $vars .= '&K1='.$_POST['K1']; | |
| 6000 | - $vars .= '&KAKUTEI='.$kakutei; | |
| 6001 | - $vars .= '&FUKA='.$acting_flg; | |
| 6002 | - | |
| 6003 | - $header = "POST ".$interface['path']." HTTP/1.1\r\n"; | |
| 6004 | - $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n"; | |
| 6005 | - $header .= "User-Agent: PHP Script\r\n"; | |
| 6006 | - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| 6007 | - $header .= "Content-Length: ".strlen($vars)."\r\n"; | |
| 6008 | - $header .= "Connection: close\r\n\r\n"; | |
| 6009 | - $header .= $vars; | |
| 6010 | - $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30); | |
| 6011 | - | |
| 6012 | - if( $fp ) { | |
| 6013 | - fwrite( $fp, $header ); | |
| 6014 | - $page = ''; | |
| 6015 | - while( !feof($fp) ) { | |
| 6016 | - $line = fgets( $fp, 1024 ); | |
| 6017 | - if( strcmp($line, "\r\n") == 0 ) { | |
| 6018 | - $headerdone = true; | |
| 6019 | - } elseif( $headerdone ) { | |
| 6020 | - $page .= $line; | |
| 6021 | - } | |
| 6022 | - } | |
| 6023 | - fclose($fp); | |
| 6024 | - $lines = explode("\n", $page); | |
| 6025 | - if( false !== strpos( $lines[0], 'OK') ) { | |
| 6026 | - usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log'); | |
| 6027 | - //$args = '&SID='.$lines[1]; | |
| 6028 | - $args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg; | |
| 6029 | - header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args ); | |
| 6030 | - } else { | |
| 6031 | - usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log'); | |
| 6032 | - header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' ); | |
| 6033 | - } | |
| 6034 | - } else { | |
| 6035 | - usces_log('digitalcheck card : Socket Error', 'acting_transaction.log'); | |
| 6036 | - header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' ); | |
| 6037 | - } | |
| 6038 | - exit; | |
| 6039 | - } else if( $acting_flg == 'acting_digitalcheck_conv' ) { | |
| 6040 | - if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) { | |
| 6041 | - $res = $this->order_processing(); | |
| 6042 | - if( 'ordercompletion' == $res ) { | |
| 6043 | - $table_meta_name = $wpdb->prefix."usces_order_meta"; | |
| 6044 | - $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] ); | |
| 6045 | - $order_id = $wpdb->get_var($mquery); | |
| 6046 | - if( $order_id ) { | |
| 6047 | - $data = array( "settltment_status" => "未決済", "settltment_errmsg" => "決済が完了していません" ); | |
| 6048 | - $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); | |
| 6049 | - } | |
| 6050 | - $this->cart->crear_cart(); | |
| 6051 | - $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 6052 | - header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query ); | |
| 6053 | - exit; | |
| 6054 | - } else { | |
| 6055 | - usces_log('digitalcheck conv : order processing error', 'acting_transaction.log'); | |
| 6056 | - header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' ); | |
| 6057 | - } | |
| 6058 | - } else { | |
| 6059 | - $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 6060 | - header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query ); | |
| 6061 | - exit; | |
| 6062 | - } | |
| 6063 | -//20121206ysk end | |
| 6064 | - } | |
| 6065 | - do_action('usces_action_acting_processing', $acting_flg, $query); | |
| 6066 | - } | |
| 6067 | - | |
| 6068 | - function inquiry_processing() { | |
| 6069 | - | |
| 6070 | - $mail_res = usces_send_inquirymail(); | |
| 6071 | - | |
| 6072 | - if ( $mail_res ) | |
| 6073 | - return 'inquiry_comp'; | |
| 6074 | - else | |
| 6075 | - return 'inquiry_error'; | |
| 6076 | - } | |
| 6077 | - | |
| 6078 | - function lastprocessing() { | |
| 6079 | - | |
| 6080 | - if ( $this->page == 'ordercompletion' ) | |
| 6081 | - $this->cart->crear_cart(); | |
| 6082 | - | |
| 6083 | - unset($_SESSION['usces_singleitem']); | |
| 6084 | - | |
| 6085 | - } | |
| 6086 | - | |
| 6087 | - function is_item_zaiko( $post_id, $sku ){ | |
| 6088 | - $status_num = (int)$this->getItemZaikoStatusId($post_id, $sku); | |
| 6089 | - $zaiko_num = trim($this->getItemZaikoNum($post_id, $sku)); | |
| 6090 | - | |
| 6091 | - if( false !== $zaiko_num | |
| 6092 | - && ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) ) | |
| 6093 | - && false !== $status_num | |
| 6094 | - && 2 > $status_num | |
| 6095 | - ){ | |
| 6096 | - return true; | |
| 6097 | - }else{ | |
| 6098 | - return false; | |
| 6099 | - } | |
| 6100 | - } | |
| 6101 | - | |
| 6102 | - // function for the cart *********************************************************** | |
| 6103 | - function get_total_price( $cart = array() ) { | |
| 6104 | - if( empty($cart) ) | |
| 6105 | - $cart = $this->cart->get_cart(); | |
| 6106 | - | |
| 6107 | - $total_price = 0; | |
| 6108 | - | |
| 6109 | - if( !empty($cart) ) { | |
| 6110 | - for($i=0; $i<count($cart); $i++) { | |
| 6111 | - $quantity = $cart[$i]['quantity']; | |
| 6112 | - $skuPrice = $cart[$i]['price']; | |
| 6113 | - | |
| 6114 | - $total_price += ($skuPrice * $quantity); | |
| 6115 | - } | |
| 6116 | - } | |
| 6117 | - return apply_filters( 'usces_filter_get_total_price', $total_price, $cart); | |
| 6118 | - } | |
| 6119 | - | |
| 6120 | - function get_total_quantity( $cart = array() ) { | |
| 6121 | - if( empty($cart) ) | |
| 6122 | - $cart = $this->cart->get_cart(); | |
| 6123 | - | |
| 6124 | - $total_quantity = 0; | |
| 6125 | - | |
| 6126 | - if( !empty($cart) ) { | |
| 6127 | - for($i=0; $i<count($cart); $i++) { | |
| 6128 | - $total_quantity += $cart[$i]['quantity']; | |
| 6129 | - } | |
| 6130 | - } | |
| 6131 | - return $total_quantity; | |
| 6132 | - } | |
| 6133 | - | |
| 6134 | - function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) { | |
| 6135 | - if( $mem_id == '' || $this->options['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0; | |
| 6136 | - | |
| 6137 | - if ( empty($cart) ) | |
| 6138 | - $cart = $this->cart->get_cart(); | |
| 6139 | - | |
| 6140 | - if ( empty($display_mode) ) | |
| 6141 | - $display_mode = $this->options['display_mode']; | |
| 6142 | - | |
| 6143 | - $point = 0; | |
| 6144 | - $total = $this->get_total_price( $cart ); | |
| 6145 | - if ( $display_mode == 'Promotionsale' ) { | |
| 6146 | - if ( $this->options['campaign_privilege'] == 'discount' ) { | |
| 6147 | - foreach ( $cart as $rows ) { | |
| 6148 | - $cats = $this->get_post_term_ids($rows['post_id'], 'category'); | |
| 6149 | - if ( !in_array($this->options['campaign_category'], $cats) ){ | |
| 6150 | - $rate = get_post_meta($rows['post_id'], '_itemPointrate', true); | |
| 6151 | - $price = $rows['price'] * $rows['quantity']; | |
| 6152 | - $point += $price * $rate / 100; | |
| 6153 | - } | |
| 6154 | - } | |
| 6155 | - } elseif ( $this->options['campaign_privilege'] == 'point' ) { | |
| 6156 | - foreach ( $cart as $rows ) { | |
| 6157 | - $rate = get_post_meta($rows['post_id'], '_itemPointrate', true); | |
| 6158 | - //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity']; | |
| 6159 | - $price = $rows['price'] * $rows['quantity']; | |
| 6160 | - $cats = $this->get_post_term_ids($rows['post_id'], 'category'); | |
| 6161 | - if ( in_array($this->options['campaign_category'], $cats) ) | |
| 6162 | - $point += $price * $rate / 100 * $this->options['privilege_point']; | |
| 6163 | - else | |
| 6164 | - $point += $price * $rate / 100; | |
| 6165 | - } | |
| 6166 | - } | |
| 6167 | - } else { | |
| 6168 | - foreach ( $cart as $rows ) { | |
| 6169 | - $rate = get_post_meta($rows['post_id'], '_itemPointrate', true); | |
| 6170 | - //$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity']; | |
| 6171 | - $price = $rows['price'] * $rows['quantity']; | |
| 6172 | - $point += $price * $rate / 100; | |
| 6173 | - } | |
| 6174 | - } | |
| 6175 | - | |
| 6176 | -//20130425ysk start 0000699 | |
| 6177 | - if( 0 < $point ) ceil( $point ); | |
| 6178 | - | |
| 6179 | - $entry = $this->cart->get_entry(); | |
| 6180 | - $use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0; | |
| 6181 | - if( 0 < $use_point ) { | |
| 6182 | - $point = ceil( $point - ( $point * $use_point / $total ) ); | |
| 6183 | - if( 0 > $point ) | |
| 6184 | - $point = 0; | |
| 6185 | - } | |
| 6186 | - | |
| 6187 | - return apply_filters( 'usces_filter_get_order_point', $point ); | |
| 6188 | -//20130425ysk end | |
| 6189 | - } | |
| 6190 | - | |
| 6191 | - function get_order_discount( $display_mode = '', $cart = array() ) { | |
| 6192 | - if ( empty($cart) ) | |
| 6193 | - $cart = $this->cart->get_cart(); | |
| 6194 | - | |
| 6195 | - if ( empty($display_mode) ) | |
| 6196 | - $display_mode = $this->options['display_mode']; | |
| 6197 | - | |
| 6198 | - $discount = 0; | |
| 6199 | - $total = $this->get_total_price( $cart ); | |
| 6200 | - if ( $display_mode == 'Promotionsale' ) { | |
| 6201 | - if ( $this->options['campaign_privilege'] == 'discount' ){ | |
| 6202 | - if( 0 === (int)$this->options['campaign_category'] ){ | |
| 6203 | - $discount = $total * $this->options['privilege_discount'] / 100; | |
| 6204 | - }else{ | |
| 6205 | - foreach($cart as $cart_row){ | |
| 6206 | - if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){ | |
| 6207 | - $discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100; | |
| 6208 | - } | |
| 6209 | - } | |
| 6210 | - } | |
| 6211 | - }else if ( $this->options['campaign_privilege'] == 'point' ){ | |
| 6212 | - $discount = 0; | |
| 6213 | - } | |
| 6214 | - } | |
| 6215 | - | |
| 6216 | - $discount = ceil($discount * -1); | |
| 6217 | - $discount = apply_filters('usces_order_discount', $discount, $cart); | |
| 6218 | - return $discount; | |
| 6219 | - } | |
| 6220 | - | |
| 6221 | - function getShippingCharge( $pref, $cart = array(), $entry = array() ) { | |
| 6222 | - if( empty($cart) ) | |
| 6223 | - $cart = $this->cart->get_cart(); | |
| 6224 | - if( empty($entry) ) | |
| 6225 | - $entry = $this->cart->get_entry(); | |
| 6226 | - | |
| 6227 | - //配送方法ID | |
| 6228 | - $d_method_id = $entry['order']['delivery_method']; | |
| 6229 | - //配送方法index | |
| 6230 | - $d_method_index = $this->get_delivery_method_index($d_method_id); | |
| 6231 | - //送料ID | |
| 6232 | - $fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1; | |
| 6233 | - $individual_quant = 0; | |
| 6234 | - $total_quant = 0; | |
| 6235 | - $charges = array(); | |
| 6236 | - $individual_charges = array(); | |
| 6237 | - $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472 | |
| 6238 | - | |
| 6239 | - foreach ( $cart as $rows ) { | |
| 6240 | - | |
| 6241 | - if( -1 == $fixed_charge_id ){ | |
| 6242 | - //商品送料ID | |
| 6243 | - $s_charge_id = $this->getItemShippingCharge($rows['post_id']); | |
| 6244 | - //商品送料index | |
| 6245 | - $s_charge_index = $this->get_shipping_charge_index($s_charge_id); | |
| 6246 | -//20120710ysk start 0000472 | |
| 6247 | - //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0; | |
| 6248 | - $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0; | |
| 6249 | -//20120710ysk end | |
| 6250 | - }else{ | |
| 6251 | - | |
| 6252 | - $s_charge_index = $this->get_shipping_charge_index($fixed_charge_id); | |
| 6253 | -//20120710ysk start 0000472 | |
| 6254 | - //$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0; | |
| 6255 | - $charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0; | |
| 6256 | -//20120710ysk end | |
| 6257 | - } | |
| 6258 | - | |
| 6259 | - if($this->getItemIndividualSCharge($rows['post_id'])){ | |
| 6260 | - $individual_quant += $rows['quantity']; | |
| 6261 | - $individual_charges[] = $rows['quantity'] * $charge; | |
| 6262 | - }else{ | |
| 6263 | - $charges[] = $charge; | |
| 6264 | - } | |
| 6265 | - $total_quant += $rows['quantity']; | |
| 6266 | - } | |
| 6267 | - | |
| 6268 | - if( count($charges) > 0 ){ | |
| 6269 | - rsort($charges); | |
| 6270 | - $max_charge = $charges[0]; | |
| 6271 | - $charge = $max_charge + array_sum($individual_charges); | |
| 6272 | - }else{ | |
| 6273 | - $charge = array_sum($individual_charges); | |
| 6274 | - } | |
| 6275 | - | |
| 6276 | - $charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry); | |
| 6277 | - | |
| 6278 | - return $charge; | |
| 6279 | - } | |
| 6280 | - | |
| 6281 | - function getCODFee($payment_name, $amount_by_cod) { | |
| 6282 | - $payments = $this->getPayments($payment_name); | |
| 6283 | - if( 'COD' != $payments['settlement'] ){ | |
| 6284 | - $fee = 0; | |
| 6285 | - | |
| 6286 | - }else if( 'change' != $this->options['cod_type'] ){ | |
| 6287 | - //$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : ''; | |
| 6288 | - $fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0; | |
| 6289 | - | |
| 6290 | - }else{ | |
| 6291 | - $price = $amount_by_cod + $this->getTax( $amount_by_cod ); | |
| 6292 | - if( $price <= $this->options['cod_first_amount'] ){ | |
| 6293 | - $fee = $this->options['cod_first_fee']; | |
| 6294 | - | |
| 6295 | - }else if( isset($this->options['cod_amounts']) ){ | |
| 6296 | - $last = count( $this->options['cod_amounts'] ) - 1; | |
| 6297 | - if( $price > $this->options['cod_amounts'][$last] ){ | |
| 6298 | - $fee = $this->options['cod_end_fee']; | |
| 6299 | - | |
| 6300 | - }else{ | |
| 6301 | - $fee = 0; | |
| 6302 | - foreach( $this->options['cod_amounts'] as $key => $value ){ | |
| 6303 | - if( $price <= $value ){ | |
| 6304 | - $fee = $this->options['cod_fees'][$key]; | |
| 6305 | - break; | |
| 6306 | - } | |
| 6307 | - } | |
| 6308 | - } | |
| 6309 | - }else{ | |
| 6310 | - $fee = $this->options['cod_end_fee']; | |
| 6311 | - } | |
| 6312 | - } | |
| 6313 | - $fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod); | |
| 6314 | - return $fee; | |
| 6315 | - } | |
| 6316 | - | |
| 6317 | - function getTax( $total ) { | |
| 6318 | - if( empty($this->options['tax_rate']) ) | |
| 6319 | - return 0; | |
| 6320 | - | |
| 6321 | - if( $this->options['tax_method'] == 'cutting' ) | |
| 6322 | - $tax = floor($total * $this->options['tax_rate'] / 100); | |
| 6323 | - elseif($this->options['tax_method'] == 'bring') | |
| 6324 | - $tax = ceil($total * $this->options['tax_rate'] / 100); | |
| 6325 | - elseif($this->options['tax_method'] == 'rounding') | |
| 6326 | - $tax = round($total * $this->options['tax_rate'] / 100); | |
| 6327 | - | |
| 6328 | - return $tax; | |
| 6329 | - } | |
| 6330 | - | |
| 6331 | - function set_cart_fees( $member, &$entries ) { | |
| 6332 | - $carts = $this->cart->get_cart(); | |
| 6333 | - $total_items_price = $this->get_total_price(); | |
| 6334 | - if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) { | |
| 6335 | - $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] ); | |
| 6336 | - } else { | |
| 6337 | - $shipping_charge = 0; | |
| 6338 | - } | |
| 6339 | - $shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries); | |
| 6340 | - $payments = $this->getPayments( $entries['order']['payment_name'] ); | |
| 6341 | - $discount = $this->get_order_discount(); | |
| 6342 | - $use_point = $entries['order']['usedpoint']; | |
| 6343 | - $amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge; | |
| 6344 | - $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); | |
| 6345 | - $cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod); | |
| 6346 | - $cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge); | |
| 6347 | - $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee; | |
| 6348 | - $total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee); | |
| 6349 | - $tax = $this->getTax( $total_price ); | |
| 6350 | - $total_full_price = $total_price + $tax; | |
| 6351 | - $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); | |
| 6352 | - $get_point = $this->get_order_point( $member['ID'] ); | |
| 6353 | -//20130425ysk start 0000699 | |
| 6354 | - //if(0 < (int)$use_point){ | |
| 6355 | - // $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) ); | |
| 6356 | - // if(0 > $get_point) | |
| 6357 | - // $get_point = 0; | |
| 6358 | - //} | |
| 6359 | -//20130425ysk end | |
| 6360 | - | |
| 6361 | - $array = array( | |
| 6362 | - 'total_items_price' => $total_items_price, | |
| 6363 | - 'total_price' => $total_price, | |
| 6364 | - 'total_full_price' => $total_full_price, | |
| 6365 | - 'getpoint' => $get_point, | |
| 6366 | - 'usedpoint' => $use_point, | |
| 6367 | - 'discount' => $discount, | |
| 6368 | - 'shipping_charge' => $shipping_charge, | |
| 6369 | - 'cod_fee' => $cod_fee, | |
| 6370 | - 'tax' => $tax | |
| 6371 | - ); | |
| 6372 | - $this->cart->set_order_entry( $array ); | |
| 6373 | - //$entries = $this->cart->get_entry(); | |
| 6374 | -//var_dump($entries); | |
| 6375 | - } | |
| 6376 | - | |
| 6377 | - function getPayments( $payment_name ) { | |
| 6378 | - if( '#none#' == $payment_name ) | |
| 6379 | - return NULL; | |
| 6380 | - | |
| 6381 | - $payments = usces_get_system_option( 'usces_payment_method', 'name' ); | |
| 6382 | - if( isset($payments[$payment_name]) ) | |
| 6383 | - return $payments[$payment_name]; | |
| 6384 | - return NULL; | |
| 6385 | - } | |
| 6386 | - | |
| 6387 | - function is_maintenance() { | |
| 6388 | - if ( $this->options['display_mode'] == 'Maintenancemode' ) | |
| 6389 | - return true; | |
| 6390 | - else | |
| 6391 | - return false; | |
| 6392 | - } | |
| 6393 | - | |
| 6394 | -// function maintenance_mode() { | |
| 6395 | -// if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) { | |
| 6396 | -// include ( TEMPLATEPATH . '/maintenance.php '); | |
| 6397 | -// exit; | |
| 6398 | -// } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) { | |
| 6399 | -// $error = isset($_GET['error']) ? '?error='.$_GET['error'] : ''; | |
| 6400 | -// include ( TEMPLATEPATH . '/member/changepassword.php '); | |
| 6401 | -// exit; | |
| 6402 | -// } | |
| 6403 | -// } | |
| 6404 | - | |
| 6405 | - function get_member_history($mem_id) { | |
| 6406 | - global $wpdb; | |
| 6407 | - $order_table = $wpdb->prefix . "usces_order"; | |
| 6408 | - | |
| 6409 | - $query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id); | |
| 6410 | -// $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint, | |
| 6411 | -// order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status | |
| 6412 | -// FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id); | |
| 6413 | - $results = $wpdb->get_results( $query ); | |
| 6414 | - | |
| 6415 | - $i=0; | |
| 6416 | - $res = array(); | |
| 6417 | - foreach ( $results as $value ) { | |
| 6418 | - if(strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false){ | |
| 6419 | - | |
| 6420 | - $res[] = array( | |
| 6421 | - 'ID' => $value->ID, | |
| 6422 | - 'cart' => unserialize($value->order_cart), | |
| 6423 | - 'condition' => unserialize($value->order_condition), | |
| 6424 | - 'getpoint' => $value->order_getpoint, | |
| 6425 | - 'usedpoint' => $value->order_usedpoint, | |
| 6426 | - 'discount' => $value->order_discount, | |
| 6427 | - 'shipping_charge' => $value->order_shipping_charge, | |
| 6428 | - 'payment_name' => $value->order_payment_name, | |
| 6429 | - 'cod_fee' => $value->order_cod_fee, | |
| 6430 | - 'tax' => $value->order_tax, | |
| 6431 | - 'order_status' => $value->order_status, | |
| 6432 | - 'date' => mysql2date(__('Y/m/d'), $value->order_date), | |
| 6433 | - 'order_date' => $value->order_date | |
| 6434 | - ); | |
| 6435 | - $i++; | |
| 6436 | - | |
| 6437 | - } | |
| 6438 | - } | |
| 6439 | - | |
| 6440 | - return $res; | |
| 6441 | - | |
| 6442 | - } | |
| 6443 | - | |
| 6444 | - function get_post_term_ids( $post_id, $taxonomy ){ | |
| 6445 | - global $wpdb; | |
| 6446 | - $query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr | |
| 6447 | - INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id | |
| 6448 | - WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id); | |
| 6449 | - $ids = $wpdb->get_col( $query ); | |
| 6450 | - | |
| 6451 | - return $ids; | |
| 6452 | - | |
| 6453 | - } | |
| 6454 | - | |
| 6455 | - function get_tag_names($post_id) { | |
| 6456 | - global $wpdb; | |
| 6457 | - $tag = 'post_tag'; | |
| 6458 | - $query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr | |
| 6459 | - INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id | |
| 6460 | - INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id | |
| 6461 | - WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id); | |
| 6462 | - $names = $wpdb->get_col( $query ); | |
| 6463 | - | |
| 6464 | - return apply_filters('usces_filter_get_tag_names', $names, $post_id); | |
| 6465 | - | |
| 6466 | - } | |
| 6467 | - | |
| 6468 | - function get_ID_byItemName($itemname, $status = 'publish') { | |
| 6469 | - global $wpdb; | |
| 6470 | - $meta_key = '_itemCode'; | |
| 6471 | - $query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p | |
| 6472 | - INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id | |
| 6473 | - WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname); | |
| 6474 | - $id = $wpdb->get_var( $query ); | |
| 6475 | - | |
| 6476 | -// $wpdb->show_errors(); | |
| 6477 | -// $wpdb->print_error(); | |
| 6478 | - | |
| 6479 | - return $id; | |
| 6480 | - | |
| 6481 | - } | |
| 6482 | - | |
| 6483 | - function uscescv( $sessid, $flag ) { | |
| 6484 | - | |
| 6485 | - $chars = ''; | |
| 6486 | - $i=0; | |
| 6487 | - $h=0; | |
| 6488 | - $usces_cookie = $this->get_cookie(); | |
| 6489 | - if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){ | |
| 6490 | - $cid = $usces_cookie['id']; | |
| 6491 | - }elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){ | |
| 6492 | - $cid = $_SESSION['usces_cookieid']; | |
| 6493 | - }else{ | |
| 6494 | - $cid = 0; | |
| 6495 | - } | |
| 6496 | - while($h<strlen($sessid)){ | |
| 6497 | - if(0 == $i % 3){ | |
| 6498 | - $chars .= substr($i, -1); | |
| 6499 | - }else{ | |
| 6500 | - $chars .= substr($sessid, $h, 1); | |
| 6501 | - $h++; | |
| 6502 | - } | |
| 6503 | - $i++; | |
| 6504 | - } | |
| 6505 | - if( $flag ){ | |
| 6506 | - $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR'; | |
| 6507 | - $postfix = apply_filters('usces_sessid_force', $postfix); | |
| 6508 | - $sessid = $chars . '_' . $postfix . '_' . $cid . '_A'; | |
| 6509 | - }else{ | |
| 6510 | - $sessid = $chars . '_' . apply_filters('usces_sessid_flag', 'acting') . '_' . $cid . '_A'; | |
| 6511 | - } | |
| 6512 | - $sessid = urlencode(base64_encode($sessid)); | |
| 6513 | -//usces_log('sessid2 : '.$sessid, 'acting_transaction.log'); | |
| 6514 | - | |
| 6515 | - return $sessid; | |
| 6516 | - } | |
| 6517 | - | |
| 6518 | - function uscesdc( $sessid ) { | |
| 6519 | -// $usces_cookie = $this->get_cookie(); | |
| 6520 | -// if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){ | |
| 6521 | -// if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){ | |
| 6522 | -// $cid = $usces_cookie['sslid']; | |
| 6523 | -// }else{ | |
| 6524 | -// $cid = 0; | |
| 6525 | -// } | |
| 6526 | -// }else{ | |
| 6527 | -// if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){ | |
| 6528 | -// $cid = $usces_cookie['id']; | |
| 6529 | -// }else{ | |
| 6530 | -// $cid = 0; | |
| 6531 | -// } | |
| 6532 | -// } | |
| 6533 | - $sessid = base64_decode(urldecode($sessid)); | |
| 6534 | - list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4); | |
| 6535 | - $postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR'; | |
| 6536 | - $postfix = apply_filters('usces_sessid_force', $postfix); | |
| 6537 | -//usces_log('cid : '.$cid, 'acting_transaction.log'); | |
| 6538 | -//usces_log('cookieid : '.$cookieid, 'acting_transaction.log'); | |
| 6539 | -//usces_log('postfix : '.$postfix, 'acting_transaction.log'); | |
| 6540 | -//usces_log('addr : '.$addr, 'acting_transaction.log'); | |
| 6541 | - if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) { | |
| 6542 | - $sessid = ''; | |
| 6543 | - return NULL; | |
| 6544 | - } | |
| 6545 | - $chars = ''; | |
| 6546 | - $h=0; | |
| 6547 | - while($h<strlen($sess)){ | |
| 6548 | - if(0 != $h % 3){ | |
| 6549 | - $chars .= substr($sess, $h, 1); | |
| 6550 | - } | |
| 6551 | - $h++; | |
| 6552 | - } | |
| 6553 | - $sessid = $chars; | |
| 6554 | - | |
| 6555 | - return $sessid; | |
| 6556 | - | |
| 6557 | - } | |
| 6558 | - | |
| 6559 | - function get_visiter( $period ) { | |
| 6560 | - global $wpdb; | |
| 6561 | - $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 6562 | - $yearstr = substr($datestr, 0, 4); | |
| 6563 | - $monthstr = substr($datestr, 5, 2); | |
| 6564 | - $daystr = substr($datestr, 8, 2); | |
| 6565 | - if($period == 'today') { | |
| 6566 | - $date = $datestr; | |
| 6567 | - $today = $datestr; | |
| 6568 | - }else if($period == 'thismonth') { | |
| 6569 | - $date = date('Y-m-01'); | |
| 6570 | - $today = $datestr; | |
| 6571 | - }else if($period == 'lastyear') { | |
| 6572 | - $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1)); | |
| 6573 | - $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1)); | |
| 6574 | - } | |
| 6575 | - $table_name = $wpdb->prefix . 'usces_access'; | |
| 6576 | - | |
| 6577 | - $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); | |
| 6578 | - $res = $wpdb->get_row($query, ARRAY_A); | |
| 6579 | - | |
| 6580 | - if( $res == NULL ) | |
| 6581 | - return 0; | |
| 6582 | - else | |
| 6583 | - return $res['ct1']+$res['ct2']; | |
| 6584 | - } | |
| 6585 | - | |
| 6586 | - function get_fvisiter( $period ) { | |
| 6587 | - global $wpdb; | |
| 6588 | - $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 6589 | - $yearstr = substr($datestr, 0, 4); | |
| 6590 | - $monthstr = substr($datestr, 5, 2); | |
| 6591 | - $daystr = substr($datestr, 8, 2); | |
| 6592 | - if($period == 'today') { | |
| 6593 | - $date = $datestr; | |
| 6594 | - $today = $datestr; | |
| 6595 | - }else if($period == 'thismonth') { | |
| 6596 | - $date = date('Y-m-01'); | |
| 6597 | - $today = $datestr; | |
| 6598 | - }else if($period == 'lastyear') { | |
| 6599 | - $date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1)); | |
| 6600 | - $today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1)); | |
| 6601 | - } | |
| 6602 | - $table_name = $wpdb->prefix . 'usces_access'; | |
| 6603 | - | |
| 6604 | - $query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today); | |
| 6605 | - $res = $wpdb->get_var($query); | |
| 6606 | - | |
| 6607 | - if( $res == NULL ) | |
| 6608 | - return 0; | |
| 6609 | - else | |
| 6610 | - return $res; | |
| 6611 | - } | |
| 6612 | - | |
| 6613 | - function get_order_num( $period ) { | |
| 6614 | - global $wpdb; | |
| 6615 | - $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 6616 | - $yearstr = substr($datestr, 0, 4); | |
| 6617 | - $monthstr = substr($datestr, 5, 2); | |
| 6618 | - $daystr = substr($datestr, 8, 2); | |
| 6619 | - if($period == 'today') { | |
| 6620 | - $date = date('Y-m-d 00:00:00', current_time('timestamp')); | |
| 6621 | - $today = date('Y-m-d 23:59:59', current_time('timestamp')); | |
| 6622 | - }else if($period == 'thismonth') { | |
| 6623 | - $date = date('Y-m-01 00:00:00', current_time('timestamp')); | |
| 6624 | - $today = date('Y-m-d 23:59:59', current_time('timestamp')); | |
| 6625 | - }else if($period == 'lastyear') { | |
| 6626 | - $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1)); | |
| 6627 | - $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1)); | |
| 6628 | - } | |
| 6629 | - $table_name = $wpdb->prefix . 'usces_order'; | |
| 6630 | - | |
| 6631 | - $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'); | |
| 6632 | - $res = $wpdb->get_var($query); | |
| 6633 | - | |
| 6634 | - if( $res == NULL ) | |
| 6635 | - return 0; | |
| 6636 | - else | |
| 6637 | - return $res; | |
| 6638 | - } | |
| 6639 | - | |
| 6640 | - function get_order_amount( $period ) { | |
| 6641 | - global $wpdb; | |
| 6642 | - $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 6643 | - $yearstr = substr($datestr, 0, 4); | |
| 6644 | - $monthstr = substr($datestr, 5, 2); | |
| 6645 | - $daystr = substr($datestr, 8, 2); | |
| 6646 | - if($period == 'today') { | |
| 6647 | - $date = date('Y-m-d 00:00:00', current_time('timestamp')); | |
| 6648 | - $today = date('Y-m-d 23:59:59', current_time('timestamp')); | |
| 6649 | - }else if($period == 'thismonth') { | |
| 6650 | - $date = date('Y-m-01 00:00:00', current_time('timestamp')); | |
| 6651 | - $today = date('Y-m-d 23:59:59', current_time('timestamp')); | |
| 6652 | - }else if($period == 'lastyear') { | |
| 6653 | - $date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1)); | |
| 6654 | - $today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1)); | |
| 6655 | - } | |
| 6656 | - $table_name = $wpdb->prefix . 'usces_order'; | |
| 6657 | - | |
| 6658 | - $query = $wpdb->prepare("SELECT | |
| 6659 | - SUM(order_item_total_price) AS price, | |
| 6660 | - SUM(order_usedpoint) AS point, | |
| 6661 | - SUM(order_discount) AS discount, | |
| 6662 | - SUM(order_shipping_charge) AS shipping, | |
| 6663 | - SUM(order_cod_fee) AS cod, | |
| 6664 | - SUM(order_tax) AS tax | |
| 6665 | - 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'); | |
| 6666 | - $res = $wpdb->get_row($query, ARRAY_A); | |
| 6667 | - | |
| 6668 | - if( $res == NULL ) | |
| 6669 | - return 0; | |
| 6670 | - else | |
| 6671 | - return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax']; | |
| 6672 | - } | |
| 6673 | - | |
| 6674 | - function is_status($need, $str){ | |
| 6675 | - $array = explode(',', $str); | |
| 6676 | - return in_array($need, $array); | |
| 6677 | - } | |
| 6678 | - | |
| 6679 | - function make_status( $taio='', $receipt='', $admin='' ){ | |
| 6680 | - $str = ''; | |
| 6681 | - if($taio != '' && $taio != '#none#') | |
| 6682 | - $str .= $taio . ','; | |
| 6683 | - if($receipt != '' && $receipt != '#none#') | |
| 6684 | - $str .= $receipt . ','; | |
| 6685 | - if($admin != '' && $admin != '#none#') | |
| 6686 | - $str .= $admin . ','; | |
| 6687 | - return $str; | |
| 6688 | - } | |
| 6689 | - | |
| 6690 | - function get_memberid_by_email($email){ | |
| 6691 | - global $wpdb; | |
| 6692 | - $table_name = $wpdb->prefix . "usces_member"; | |
| 6693 | - $query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email); | |
| 6694 | - $res = $wpdb->get_var($query); | |
| 6695 | - return $res; | |
| 6696 | - } | |
| 6697 | - | |
| 6698 | - function get_condition(){ | |
| 6699 | -//20120807ysk start 0000544 | |
| 6700 | - $order_conditions = array( | |
| 6701 | - 'display_mode' => $this->options['display_mode'], | |
| 6702 | - 'campaign_privilege' => $this->options['campaign_privilege'], | |
| 6703 | - 'campaign_category' => $this->options['campaign_category'], | |
| 6704 | - 'privilege_point' => $this->options['privilege_point'], | |
| 6705 | - 'privilege_discount' => $this->options['privilege_discount']); | |
| 6706 | - return $order_conditions; | |
| 6707 | -//20120807ysk end | |
| 6708 | - } | |
| 6709 | - | |
| 6710 | - function get_bestseller_ids( $days = "" ){ | |
| 6711 | - global $wpdb; | |
| 6712 | - $datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10); | |
| 6713 | - $yearstr = substr($datestr, 0, 4); | |
| 6714 | - $monthstr = substr($datestr, 5, 2); | |
| 6715 | - $daystr = substr($datestr, 8, 2); | |
| 6716 | - $res = array(); | |
| 6717 | - $order_table_name = $wpdb->prefix . "usces_order"; | |
| 6718 | - $where = ""; | |
| 6719 | - if($days != ''){ | |
| 6720 | - $order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr)); | |
| 6721 | - $where = " WHERE order_date >= '{$order_date}'"; | |
| 6722 | - } | |
| 6723 | - $query = "SELECT order_cart FROM {$order_table_name}" . $where; | |
| 6724 | - $dbres = $wpdb->get_col($query); | |
| 6725 | - if(!$dbres) return false; | |
| 6726 | - | |
| 6727 | - foreach((array)$dbres as $carts){ | |
| 6728 | - $rows = unserialize($carts); | |
| 6729 | - foreach((array)$rows as $carts){ | |
| 6730 | - if( 'publish' != get_post_status($carts['post_id']) ) | |
| 6731 | - continue; | |
| 6732 | - | |
| 6733 | - $id = $carts['post_id']; | |
| 6734 | - $qu = $carts['quantity']; | |
| 6735 | - if(array_key_exists($id, $res)){ | |
| 6736 | - $res[$id] = $res[$id] + $qu; | |
| 6737 | - }else{ | |
| 6738 | - $res[$id] = $qu; | |
| 6739 | - } | |
| 6740 | - } | |
| 6741 | - } | |
| 6742 | - arsort($res); | |
| 6743 | - $results = array_keys($res); | |
| 6744 | - return $results; | |
| 6745 | - } | |
| 6746 | - | |
| 6747 | - function get_items_num(){ | |
| 6748 | - global $wpdb; | |
| 6749 | - $query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts} | |
| 6750 | - WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s", | |
| 6751 | - 'item', 'post', 'trush'); | |
| 6752 | - $res = $wpdb->get_var($query); | |
| 6753 | - | |
| 6754 | - return $res; | |
| 6755 | - } | |
| 6756 | - | |
| 6757 | - function is_gptekiyo( $post_id, $sku, $quant ) { | |
| 6758 | - $skus = $this->get_skus( $post_id, 'code' ); | |
| 6759 | - if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false; | |
| 6760 | - | |
| 6761 | - $GpN1 = $this->getItemGpNum1($post_id); | |
| 6762 | - $GpN2 = $this->getItemGpNum2($post_id); | |
| 6763 | - $GpN3 = $this->getItemGpNum3($post_id); | |
| 6764 | - | |
| 6765 | - if( empty($GpN1) ) { | |
| 6766 | - | |
| 6767 | - return false; | |
| 6768 | - | |
| 6769 | - }else if( !empty($GpN1) && empty($GpN2) ) { | |
| 6770 | - | |
| 6771 | - if( $quant >= $GpN1 ) { | |
| 6772 | - return true; | |
| 6773 | - }else{ | |
| 6774 | - return false; | |
| 6775 | - } | |
| 6776 | - | |
| 6777 | - }else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) { | |
| 6778 | - | |
| 6779 | - if( $quant >= $GpN2 ) { | |
| 6780 | - return true; | |
| 6781 | - }else if( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 6782 | - return true; | |
| 6783 | - }else{ | |
| 6784 | - return false; | |
| 6785 | - } | |
| 6786 | - | |
| 6787 | - }else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) { | |
| 6788 | - | |
| 6789 | - if( $quant >= $GpN3 ) { | |
| 6790 | - return true; | |
| 6791 | - }else if( $quant >= $GpN2 && $quant < $GpN3 ) { | |
| 6792 | - return true; | |
| 6793 | - }else if( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 6794 | - return true; | |
| 6795 | - }else{ | |
| 6796 | - return false; | |
| 6797 | - } | |
| 6798 | - } | |
| 6799 | - } | |
| 6800 | - | |
| 6801 | - function get_available_delivery_method() { | |
| 6802 | - if($this->cart->num_row() > 0) { | |
| 6803 | - $cart = $this->cart->get_cart(); | |
| 6804 | - $before_deli = array(); | |
| 6805 | - $intersect = array(); | |
| 6806 | - $integration = array(); | |
| 6807 | - $temp = array(); | |
| 6808 | - $in = 0; | |
| 6809 | - foreach($cart as $key => $row){ | |
| 6810 | - $deli = $this->getItemDeliveryMethod($row['post_id']); | |
| 6811 | - //usces_p($deli); | |
| 6812 | - if( empty($deli)) | |
| 6813 | - continue; | |
| 6814 | - | |
| 6815 | - //usces_log('deli : '.print_r($deli, true), 'acting_transaction.log'); | |
| 6816 | - if( 0 === $in ){ | |
| 6817 | - $intersect = $deli; | |
| 6818 | - } | |
| 6819 | - $intersect = array_intersect($deli, $intersect); | |
| 6820 | - $before_deli = $deli; | |
| 6821 | - foreach($deli as $value){ | |
| 6822 | - $integration[] = $value; | |
| 6823 | - } | |
| 6824 | - $in++; | |
| 6825 | - } | |
| 6826 | - $integration = array_unique($integration); | |
| 6827 | - foreach($integration as $id){ | |
| 6828 | - $index = $this->get_delivery_method_index($id); | |
| 6829 | - $temp[$index] = $id; | |
| 6830 | - } | |
| 6831 | - ksort($temp); | |
| 6832 | -//20120820ysk start 0000546 | |
| 6833 | - //$force = array($temp[0]); | |
| 6834 | - $force = array(array_shift($temp)); | |
| 6835 | -//20120820ysk end | |
| 6836 | - | |
| 6837 | - if( empty($intersect) ){ | |
| 6838 | - return $force; | |
| 6839 | - }else{ | |
| 6840 | - return $intersect; | |
| 6841 | - } | |
| 6842 | - } | |
| 6843 | - return array(); | |
| 6844 | - } | |
| 6845 | - | |
| 6846 | - function get_delivery_method_index($id) { | |
| 6847 | - $index = false; | |
| 6848 | - for($i=0; $i<count($this->options['delivery_method']); $i++){ | |
| 6849 | - if( $this->options['delivery_method'][$i]['id'] === (int)$id ){ | |
| 6850 | - $index = $i; | |
| 6851 | - } | |
| 6852 | - } | |
| 6853 | - if($index === false) | |
| 6854 | - return -1; | |
| 6855 | - else | |
| 6856 | - return $index; | |
| 6857 | - } | |
| 6858 | - | |
| 6859 | - function get_shipping_charge_index($id) { | |
| 6860 | - $index = false; | |
| 6861 | - for($i=0; $i<count($this->options['shipping_charge']); $i++){ | |
| 6862 | -//20120710ysk start 0000472 | |
| 6863 | - //if( $this->options['shipping_charge'][$i]['id'] === $id ){ | |
| 6864 | - if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){ | |
| 6865 | -//20120710ysk end | |
| 6866 | - $index = $i; | |
| 6867 | - } | |
| 6868 | - } | |
| 6869 | - if($index === false) | |
| 6870 | - return -1; | |
| 6871 | - else | |
| 6872 | - return $index; | |
| 6873 | - } | |
| 6874 | - | |
| 6875 | - function get_initial_data($xml){ | |
| 6876 | - $buf = file_get_contents($xml); | |
| 6877 | - 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); | |
| 6878 | - return $match; | |
| 6879 | - } | |
| 6880 | - | |
| 6881 | - function getCurrencySymbol(){ | |
| 6882 | - global $usces_settings; | |
| 6883 | - $cr = $this->options['system']['currency']; | |
| 6884 | - list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr]; | |
| 6885 | - return $symbol; | |
| 6886 | - } | |
| 6887 | - | |
| 6888 | - function getCartItemName($post_id, $sku){ | |
| 6889 | - $name_arr = array(); | |
| 6890 | - $name_str = ''; | |
| 6891 | - | |
| 6892 | - foreach($this->options['indi_item_name'] as $key => $value){ | |
| 6893 | - if($value){ | |
| 6894 | - $pos = (int)$this->options['pos_item_name'][$key]; | |
| 6895 | - $ind = ($pos === 0) ? 'A' : $pos; | |
| 6896 | - switch($key){ | |
| 6897 | - case 'item_name': | |
| 6898 | - $name_arr[$ind][$key] = $this->getItemName($post_id); | |
| 6899 | - break; | |
| 6900 | - case 'item_code': | |
| 6901 | - $name_arr[$ind][$key] = $this->getItemCode($post_id); | |
| 6902 | - break; | |
| 6903 | - case 'sku_name': | |
| 6904 | - $name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku); | |
| 6905 | - break; | |
| 6906 | - case 'sku_code': | |
| 6907 | - $name_arr[$ind][$key] = $sku; | |
| 6908 | - break; | |
| 6909 | - } | |
| 6910 | - } | |
| 6911 | - | |
| 6912 | - } | |
| 6913 | - ksort($name_arr); | |
| 6914 | - foreach($name_arr as $vals){ | |
| 6915 | - foreach($vals as $key => $value){ | |
| 6916 | - | |
| 6917 | - $name_str .= $value . ' '; | |
| 6918 | - } | |
| 6919 | - } | |
| 6920 | - | |
| 6921 | - $name_str = apply_filters('usces_admin_order_item_name_filter', $name_str); | |
| 6922 | - | |
| 6923 | - return trim($name_str); | |
| 6924 | - } | |
| 6925 | - | |
| 6926 | - function set_reserve_pre_order_id(){ | |
| 6927 | - $entry = $this->cart->get_entry(); | |
| 6928 | - $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid(''); | |
| 6929 | - $this->cart->set_pre_order_id($id); | |
| 6930 | - } | |
| 6931 | - | |
| 6932 | - function get_current_pre_order_id(){ | |
| 6933 | - $entry = $this->cart->get_entry(); | |
| 6934 | - $id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL; | |
| 6935 | - return $id; | |
| 6936 | - } | |
| 6937 | - | |
| 6938 | - function get_reserve($order_id, $key){ | |
| 6939 | - global $wpdb; | |
| 6940 | - $order_meta_table_name = $wpdb->prefix . "usces_order_meta"; | |
| 6941 | - $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", | |
| 6942 | - $order_id, $key); | |
| 6943 | - $res = $wpdb->get_var($query); | |
| 6944 | - return $res; | |
| 6945 | - } | |
| 6946 | - | |
| 6947 | -//20100818ysk start | |
| 6948 | -//20100816ysk start | |
| 6949 | - //function get_order_meta($order_id, $key) { | |
| 6950 | - function get_order_meta_value($key, $order_id) { | |
| 6951 | - global $wpdb; | |
| 6952 | - $order_meta_table_name = $wpdb->prefix . "usces_order_meta"; | |
| 6953 | - $query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", | |
| 6954 | - $order_id, $key); | |
| 6955 | - $res = $wpdb->get_var($query); | |
| 6956 | - return $res; | |
| 6957 | - } | |
| 6958 | -//20100816ysk end | |
| 6959 | - function set_order_meta_value($key, $meta_value, $order_id) { | |
| 6960 | - global $wpdb; | |
| 6961 | - | |
| 6962 | - //if( empty($meta_value) ) return; | |
| 6963 | - if( empty($order_id) ) return; | |
| 6964 | - | |
| 6965 | - $table_name = $wpdb->prefix . "usces_order_meta"; | |
| 6966 | - $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s", | |
| 6967 | - $order_id, $key); | |
| 6968 | - $res = $wpdb->get_var($query); | |
| 6969 | - if(0 < $res) { | |
| 6970 | - $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", | |
| 6971 | - $meta_value, | |
| 6972 | - $order_id, | |
| 6973 | - $key | |
| 6974 | - ); | |
| 6975 | - $res2 = $wpdb->query($query); | |
| 6976 | - } else { | |
| 6977 | - $query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value) | |
| 6978 | - VALUES(%d, %s, %s)", | |
| 6979 | - $order_id, | |
| 6980 | - $key, | |
| 6981 | - $meta_value | |
| 6982 | - ); | |
| 6983 | - $res2 = $wpdb->query($query); | |
| 6984 | - } | |
| 6985 | - return $res2; | |
| 6986 | - } | |
| 6987 | - | |
| 6988 | - function set_session_custom_member($member_id) { | |
| 6989 | - unset($_SESSION['usces_member']['custom_member']); | |
| 6990 | - $meta = usces_has_custom_field_meta('member'); | |
| 6991 | - if(is_array($meta)) { | |
| 6992 | - $keys = array_keys($meta); | |
| 6993 | - foreach($keys as $key) { | |
| 6994 | - $csmb_key = 'csmb_'.$key; | |
| 6995 | - $_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id)); | |
| 6996 | - } | |
| 6997 | - } | |
| 6998 | - } | |
| 6999 | - | |
| 7000 | - function reg_custom_member($member_id) { | |
| 7001 | - if( !empty($_POST['custom_member']) ) { | |
| 7002 | - foreach( $_POST['custom_member'] as $key => $value ) { | |
| 7003 | - $csmb_key = 'csmb_'.$key; | |
| 7004 | - if( is_array($value) ) | |
| 7005 | - $value = serialize($value); | |
| 7006 | - $res = $this->set_member_meta_value($csmb_key, $value, $member_id); | |
| 7007 | - if(false === $res) | |
| 7008 | - return false; | |
| 7009 | - } | |
| 7010 | - }elseif( isset($_POST['custom_customer']) ){ | |
| 7011 | - foreach( $_POST['custom_customer'] as $key => $value ) { | |
| 7012 | - $csmb_key = 'csmb_'.$key; | |
| 7013 | - if( is_array($value) ) | |
| 7014 | - $value = serialize($value); | |
| 7015 | - $res = $this->set_member_meta_value($csmb_key, $value, $member_id); | |
| 7016 | - if(false === $res) | |
| 7017 | - return false; | |
| 7018 | - } | |
| 7019 | - } | |
| 7020 | - } | |
| 7021 | -//20100818ysk end | |
| 7022 | - | |
| 7023 | - function save_order_acting_data($rand){ | |
| 7024 | - global $wpdb; | |
| 7025 | - $data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() )); | |
| 7026 | - $table_name = $wpdb->prefix . "usces_access"; | |
| 7027 | - $query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value) | |
| 7028 | - VALUES(%s, %s, now(), %s, %s)", | |
| 7029 | - 'acting_data', | |
| 7030 | - $this->get_uscesid(false), | |
| 7031 | - $rand, | |
| 7032 | - $data | |
| 7033 | - ); | |
| 7034 | - $res = $wpdb->query($query); | |
| 7035 | - return $res; | |
| 7036 | - } | |
| 7037 | - | |
| 7038 | -//20100818ysk start | |
| 7039 | - function set_member_meta_value($key, $meta_value, $member_id = ''){ | |
| 7040 | - global $wpdb; | |
| 7041 | - | |
| 7042 | - //if( empty($meta_value) ) return; | |
| 7043 | - if( WCUtils::is_blank($member_id) ) { | |
| 7044 | - if( !$this->is_member_logged_in() ) return; | |
| 7045 | - $member = $this->get_member(); | |
| 7046 | - $member_id = $member['ID']; | |
| 7047 | - } | |
| 7048 | - | |
| 7049 | - $table_name = $wpdb->prefix . "usces_member_meta"; | |
| 7050 | - //$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s", | |
| 7051 | - $query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s", | |
| 7052 | - $member_id, $key); | |
| 7053 | - $res = $wpdb->get_var($query); | |
| 7054 | - //if($res != NULL){ | |
| 7055 | - if(0 < $res){ | |
| 7056 | - $query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s", | |
| 7057 | - $meta_value, | |
| 7058 | - $member_id, | |
| 7059 | - $key | |
| 7060 | - ); | |
| 7061 | - $res2 = $wpdb->query($query); | |
| 7062 | - }else{ | |
| 7063 | - $query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value) | |
| 7064 | - VALUES(%d, %s, %s)", | |
| 7065 | - $member_id, | |
| 7066 | - $key, | |
| 7067 | - $meta_value | |
| 7068 | - ); | |
| 7069 | - $res2 = $wpdb->query($query); | |
| 7070 | - } | |
| 7071 | - return $res2; | |
| 7072 | - } | |
| 7073 | -//20100818ysk end | |
| 7074 | - | |
| 7075 | - function get_member_meta_value($key, $member_id){ | |
| 7076 | - global $wpdb; | |
| 7077 | - $table_name = $wpdb->prefix . "usces_member_meta"; | |
| 7078 | - $query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s", | |
| 7079 | - $member_id, $key); | |
| 7080 | - $res = $wpdb->get_var($query); | |
| 7081 | - return $res; | |
| 7082 | - } | |
| 7083 | - | |
| 7084 | - function del_member_meta($key, $member_id){ | |
| 7085 | - global $wpdb; | |
| 7086 | - $table_name = $wpdb->prefix . "usces_member_meta"; | |
| 7087 | - $query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s", | |
| 7088 | - $member_id, $key); | |
| 7089 | - $res = $wpdb->query($query); | |
| 7090 | - return $res; | |
| 7091 | - } | |
| 7092 | - | |
| 7093 | - function get_member_meta($member_id){ | |
| 7094 | - global $wpdb; | |
| 7095 | - $table_name = $wpdb->prefix . "usces_member_meta"; | |
| 7096 | - $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_%'); | |
| 7097 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 7098 | - return $res; | |
| 7099 | - } | |
| 7100 | - | |
| 7101 | - function get_settle_info_field( $order_id ){ | |
| 7102 | - global $wpdb; | |
| 7103 | - $fields = array(); | |
| 7104 | - $table_name = $wpdb->prefix . "usces_order_meta"; | |
| 7105 | - $query = $wpdb->prepare("SELECT meta_key, meta_value FROM $table_name WHERE order_id = %d AND (meta_key LIKE %s OR meta_key = %s OR meta_key = %s OR meta_key = %s)", | |
| 7106 | - $order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID'); | |
| 7107 | - $res = $wpdb->get_results($query, ARRAY_A); | |
| 7108 | - if( !$res ) | |
| 7109 | - return $fields; | |
| 7110 | - | |
| 7111 | - foreach( $res as $value ){ | |
| 7112 | - if( 'settlement_id' == $value['meta_key'] ){ | |
| 7113 | - $meta_values = maybe_unserialize($value['meta_value']); | |
| 7114 | - if( is_array($meta_values) ){ | |
| 7115 | - foreach( $meta_values as $key => $meta_value ){ | |
| 7116 | - $fields[$key] = $meta_value; | |
| 7117 | - } | |
| 7118 | - }else{ | |
| 7119 | - $fields['settlement_id'] = $meta_values; | |
| 7120 | - } | |
| 7121 | - }elseif( 'order_number' == $value['meta_key'] ){ | |
| 7122 | - $fields['order_number'] = $value['meta_value']; | |
| 7123 | - }elseif( 'res_tracking_id' == $value['meta_key'] ){ | |
| 7124 | - $fields['res_tracking_id'] = $value['meta_value']; | |
| 7125 | - }elseif( 'SID' == $value['meta_key'] ){ | |
| 7126 | - $fields['SID'] = $value['meta_value']; | |
| 7127 | - }elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){ | |
| 7128 | - $meta_values = unserialize($value['meta_value']); | |
| 7129 | - if(is_array($meta_values)){ | |
| 7130 | - foreach( $meta_values as $key => $meta_value ){ | |
| 7131 | - $fields[$key] = $meta_value; | |
| 7132 | - } | |
| 7133 | - } | |
| 7134 | - } | |
| 7135 | - } | |
| 7136 | - return $fields; | |
| 7137 | - } | |
| 7138 | - | |
| 7139 | - function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){ | |
| 7140 | - global $wpdb; | |
| 7141 | - $table = $wpdb->prefix . "postmeta"; | |
| 7142 | - $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order", | |
| 7143 | - $post_id), ARRAY_A ); | |
| 7144 | - | |
| 7145 | - if ( !empty($meta_list) ) { | |
| 7146 | - foreach ( $meta_list as $metarow) { | |
| 7147 | - $mkey = $metarow['meta_key']; | |
| 7148 | - $mval = $metarow['meta_value']; | |
| 7149 | - $res[$mkey][] = $mval; | |
| 7150 | - } | |
| 7151 | - } | |
| 7152 | - return $res; | |
| 7153 | - } | |
| 7154 | - | |
| 7155 | - function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){ | |
| 7156 | - global $wpdb; | |
| 7157 | - $res = array(); | |
| 7158 | - $table = $wpdb->prefix . "postmeta"; | |
| 7159 | - $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $table WHERE post_id = %d ORDER BY $orderby $order", | |
| 7160 | - $post_id), ARRAY_A ); | |
| 7161 | - | |
| 7162 | - if ( !empty($meta_list) ) { | |
| 7163 | - foreach ( $meta_list as $metarow) { | |
| 7164 | - if( 0 === strpos($metarow['meta_key'], '_') ) | |
| 7165 | - continue; | |
| 7166 | - | |
| 7167 | - $mkey = $metarow['meta_key']; | |
| 7168 | - $mval = $metarow['meta_value']; | |
| 7169 | - if( array_key_exists($mkey, $res) ){ | |
| 7170 | - $cval = $res[$mkey]; | |
| 7171 | - $cval = (array)$cval; | |
| 7172 | - $cval[] = $mval; | |
| 7173 | - $res[$mkey] = $cval; | |
| 7174 | - }else{ | |
| 7175 | - $res[$mkey] = $mval; | |
| 7176 | - } | |
| 7177 | - } | |
| 7178 | - } | |
| 7179 | - return $res; | |
| 7180 | - } | |
| 7181 | - | |
| 7182 | - function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){ | |
| 7183 | - global $usces_settings; | |
| 7184 | - $cr = $this->options['system']['currency']; | |
| 7185 | - list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr]; | |
| 7186 | - if( !$seperator_flag ){ | |
| 7187 | - $seperator = ''; | |
| 7188 | - } | |
| 7189 | - $price = number_format((double)$amount, $decimal, $point, $seperator);//0000652 | |
| 7190 | - | |
| 7191 | - if( $symbol_pre ) | |
| 7192 | - $price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price; | |
| 7193 | - | |
| 7194 | - if( $symbol_post ) | |
| 7195 | - $price = $price . __($code, 'usces'); | |
| 7196 | - | |
| 7197 | - return $price; | |
| 7198 | - } | |
| 7199 | - | |
| 7200 | - function get_currency_code(){ | |
| 7201 | - global $usces_settings; | |
| 7202 | - $cr = $this->options['system']['currency']; | |
| 7203 | - list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr]; | |
| 7204 | - return $code; | |
| 7205 | - } | |
| 7206 | - | |
| 7207 | - //shortcode----------------------------------------------------------------------------- | |
| 7208 | - function sc_company_name() { | |
| 7209 | - return htmlspecialchars($this->options['company_name']); | |
| 7210 | - } | |
| 7211 | - function sc_zip_code() { | |
| 7212 | - return htmlspecialchars($this->options['zip_code']); | |
| 7213 | - } | |
| 7214 | - function sc_address1() { | |
| 7215 | - return htmlspecialchars($this->options['address1']); | |
| 7216 | - } | |
| 7217 | - function sc_address2() { | |
| 7218 | - return htmlspecialchars($this->options['address2']); | |
| 7219 | - } | |
| 7220 | - function sc_tel_number() { | |
| 7221 | - return htmlspecialchars($this->options['tel_number']); | |
| 7222 | - } | |
| 7223 | - function sc_fax_number() { | |
| 7224 | - return htmlspecialchars($this->options['fax_number']); | |
| 7225 | - } | |
| 7226 | - function sc_inquiry_mail() { | |
| 7227 | - return htmlspecialchars($this->options['inquiry_mail']); | |
| 7228 | - } | |
| 7229 | - function sc_payment() { | |
| 7230 | - $payments = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 7231 | - $htm = "<ul>\n"; | |
| 7232 | - foreach ( (array)$payments as $payment ) { | |
| 7233 | - $htm .= "<li>" . htmlspecialchars($payment['name']) . "<br />\n"; | |
| 7234 | - $htm .= nl2br(htmlspecialchars($payment['explanation'])) . "</li>\n"; | |
| 7235 | - } | |
| 7236 | - $htm .= "</ul>\n"; | |
| 7237 | - return $htm; | |
| 7238 | - } | |
| 7239 | - function sc_payment_title() { | |
| 7240 | - $payments = $this->options['payment_method']; | |
| 7241 | - $htm = "<ul>\n"; | |
| 7242 | - foreach ( (array)$payments as $payment ) { | |
| 7243 | - $htm .= "<li>" . esc_html($payment['name']) . "</li>\n"; | |
| 7244 | - } | |
| 7245 | - $htm .= "</ul>\n"; | |
| 7246 | - return $htm; | |
| 7247 | - } | |
| 7248 | - function sc_cod_fee() { | |
| 7249 | - return number_format($this->options['cod_fee']); | |
| 7250 | - } | |
| 7251 | - function sc_start_point() { | |
| 7252 | - return number_format($this->options['start_point']); | |
| 7253 | - } | |
| 7254 | - function sc_postage_privilege() { | |
| 7255 | - if(empty($this->options['postage_privilege'])) | |
| 7256 | - return; | |
| 7257 | - return number_format($this->options['postage_privilege']); | |
| 7258 | - } | |
| 7259 | - function sc_shipping_charge() { | |
| 7260 | -//20120710ysk start 0000472 | |
| 7261 | - $entry = $this->cart->get_entry(); | |
| 7262 | - $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472 | |
| 7263 | -//20120710ysk end | |
| 7264 | - $arr = array(); | |
| 7265 | - foreach ( (array)$this->options['shipping_charge'] as $charges ) { | |
| 7266 | -//20120710ysk start 0000472 | |
| 7267 | - //foreach ( (array)$charges['value'] as $value ) { | |
| 7268 | - foreach ( (array)$charges[$country] as $value ) { | |
| 7269 | -//20120710ysk end | |
| 7270 | - $arr[] = $value; | |
| 7271 | - } | |
| 7272 | - } | |
| 7273 | - sort($arr); | |
| 7274 | - $min = $arr[0]; | |
| 7275 | - rsort($arr); | |
| 7276 | - $max = $arr[0]; | |
| 7277 | - if($min == $max){ | |
| 7278 | - $res = number_format($min); | |
| 7279 | - }else{ | |
| 7280 | - $res = number_format($min) . __(' - ', 'usces') . number_format($max); | |
| 7281 | - } | |
| 7282 | - return $res; | |
| 7283 | - } | |
| 7284 | - function sc_site_url() { | |
| 7285 | - return get_option('home'); | |
| 7286 | - } | |
| 7287 | - function sc_button_to_cart($atts) { | |
| 7288 | - extract(shortcode_atts(array( | |
| 7289 | - 'item' => '', | |
| 7290 | - 'sku' => '', | |
| 7291 | - 'value' => __('to the cart', 'usces'), | |
| 7292 | - 'force' => 0, | |
| 7293 | - 'quant' => 0, | |
| 7294 | - 'opt' => 1, | |
| 7295 | - ), $atts)); | |
| 7296 | - | |
| 7297 | - $post_id = $this->get_ID_byItemName($item); | |
| 7298 | - $datas = $this->get_skus( $post_id, 'code' ); | |
| 7299 | - $zaikonum = $datas[$sku]['stocknum']; | |
| 7300 | - $zaiko = $datas[$sku]['stock']; | |
| 7301 | - $gptekiyo = $datas[$sku]['gp']; | |
| 7302 | - $skuPrice = $datas[$sku]['price']; | |
| 7303 | - $sku_enc = urlencode($sku); | |
| 7304 | - $mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc'); | |
| 7305 | - if( ! $this->is_item_zaiko( $post_id, $sku ) ){ | |
| 7306 | - return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>'; | |
| 7307 | - } | |
| 7308 | - | |
| 7309 | - $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n"; | |
| 7310 | - $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"{$zaikonum}\" />\n"; | |
| 7311 | - $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"{$zaiko}\" />\n"; | |
| 7312 | - $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"{$gptekiyo}\" />\n"; | |
| 7313 | - $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"{$skuPrice}\" />\n"; | |
| 7314 | - if( 1 == $opt ){ | |
| 7315 | - $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' ); | |
| 7316 | - }elseif( 2 == $opt ){ | |
| 7317 | - $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' ); | |
| 7318 | - } | |
| 7319 | - if( $quant ){ | |
| 7320 | - $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;}\" />"; | |
| 7321 | - $html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats); | |
| 7322 | - } | |
| 7323 | - $html .= "<input name=\"inCart[{$post_id}][{$sku_enc}]\" type=\"submit\" id=\"inCart[{$post_id}][{$sku_enc}]\" class=\"skubutton\" value=\"{$value}\" " . apply_filters('usces_filter_direct_intocart_button', NULL, $post_id, $sku, $force, $options) . " />"; | |
| 7324 | - $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n"; | |
| 7325 | - if( $force ) | |
| 7326 | - $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n"; | |
| 7327 | - $html = apply_filters('usces_filter_single_item_inform', $html); | |
| 7328 | - $html .= "</form>"; | |
| 7329 | - $html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n"; | |
| 7330 | - | |
| 7331 | - return $html; | |
| 7332 | - } | |
| 7333 | - | |
| 7334 | - function filter_itemPage($content){ | |
| 7335 | - global $post; | |
| 7336 | - $html = ''; | |
| 7337 | - | |
| 7338 | - if( ($post->post_mime_type != 'item' || !is_single()) ) return $content; | |
| 7339 | - if( post_password_required($post) ) return $content; | |
| 7340 | - | |
| 7341 | - $temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php'); | |
| 7342 | - include( $temp_path ); | |
| 7343 | - | |
| 7344 | - $content = apply_filters('usces_filter_itemPage', $html, $post->ID); | |
| 7345 | - | |
| 7346 | - return $content; | |
| 7347 | - } | |
| 7348 | - | |
| 7349 | - function filter_cartContent($content) { | |
| 7350 | - global $post; | |
| 7351 | - $html = ''; | |
| 7352 | - | |
| 7353 | - switch($this->page){ | |
| 7354 | - case 'cart': | |
| 7355 | - $temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php'); | |
| 7356 | - include( $temp_path ); | |
| 7357 | - break; | |
| 7358 | - case 'customer': | |
| 7359 | - $temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php'); | |
| 7360 | - include( $temp_path ); | |
| 7361 | - break; | |
| 7362 | - case 'delivery': | |
| 7363 | - $temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php'); | |
| 7364 | - include( $temp_path ); | |
| 7365 | - break; | |
| 7366 | - case 'confirm': | |
| 7367 | - $temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php'); | |
| 7368 | - include( $temp_path ); | |
| 7369 | - break; | |
| 7370 | - case 'ordercompletion': | |
| 7371 | - $temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php'); | |
| 7372 | - include( $temp_path ); | |
| 7373 | - break; | |
| 7374 | - case 'error': | |
| 7375 | - $temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php'); | |
| 7376 | - include( $temp_path ); | |
| 7377 | - break; | |
| 7378 | - case 'maintenance': | |
| 7379 | - $temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php'); | |
| 7380 | - include( $temp_path ); | |
| 7381 | - break; | |
| 7382 | - case 'search_item': | |
| 7383 | - $temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php'); | |
| 7384 | - include( $temp_path ); | |
| 7385 | - break; | |
| 7386 | - case 'wp_search': | |
| 7387 | - if($post->post_mime_type == 'item'){ | |
| 7388 | - $temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php'); | |
| 7389 | - include( $temp_path ); | |
| 7390 | - }else{ | |
| 7391 | - $html = $content; | |
| 7392 | - } | |
| 7393 | - break; | |
| 7394 | - default: | |
| 7395 | - $html = $content; | |
| 7396 | - } | |
| 7397 | - | |
| 7398 | - if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) ) | |
| 7399 | - $html = str_replace('src="'.get_option('siteurl'), 'src="'.USCES_SSL_URL_ADMIN, $html); | |
| 7400 | - | |
| 7401 | - $html = apply_filters('usces_filter_cartContent', $html); | |
| 7402 | - | |
| 7403 | - $content = $html; | |
| 7404 | - | |
| 7405 | - remove_filter('the_title', array($this, 'filter_cartTitle')); | |
| 7406 | - | |
| 7407 | - return $content; | |
| 7408 | - } | |
| 7409 | - | |
| 7410 | - function filter_cartTitle($title) { | |
| 7411 | - | |
| 7412 | - if( $title == 'Cart' || $title == __('Cart', 'usces') ){ | |
| 7413 | - switch($this->page){ | |
| 7414 | - case 'cart': | |
| 7415 | - $newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces')); | |
| 7416 | - break; | |
| 7417 | - case 'customer': | |
| 7418 | - $newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces')); | |
| 7419 | - break; | |
| 7420 | - case 'delivery': | |
| 7421 | - $newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces')); | |
| 7422 | - break; | |
| 7423 | - case 'confirm': | |
| 7424 | - $newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces')); | |
| 7425 | - break; | |
| 7426 | - case 'ordercompletion': | |
| 7427 | - $newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces')); | |
| 7428 | - break; | |
| 7429 | - case 'error': | |
| 7430 | - $newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces')); | |
| 7431 | - break; | |
| 7432 | - case 'search_item': | |
| 7433 | - $newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces')); | |
| 7434 | - break; | |
| 7435 | - case 'maintenance': | |
| 7436 | - $newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces')); | |
| 7437 | - break; | |
| 7438 | - case 'login': | |
| 7439 | - $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces')); | |
| 7440 | - break; | |
| 7441 | - default: | |
| 7442 | - $newtitle = apply_filters('usces_filter_title_cart_default', $title); | |
| 7443 | - } | |
| 7444 | - }else{ | |
| 7445 | - $newtitle = $title; | |
| 7446 | - } | |
| 7447 | - | |
| 7448 | - $newtitle = apply_filters('usces_filter_cartTitle', $newtitle); | |
| 7449 | - return $newtitle; | |
| 7450 | - } | |
| 7451 | - | |
| 7452 | - function action_cartFilter(){ | |
| 7453 | - add_filter('the_title', array($this, 'filter_cartTitle'),20); | |
| 7454 | - add_filter('the_content', array($this, 'filter_cartContent'),20); | |
| 7455 | - } | |
| 7456 | - | |
| 7457 | - function action_search_item(){ | |
| 7458 | - include(TEMPLATEPATH . '/page.php'); | |
| 7459 | - exit; | |
| 7460 | - } | |
| 7461 | - | |
| 7462 | - function filter_memberContent($content) { | |
| 7463 | - global $post; | |
| 7464 | - $html = ''; | |
| 7465 | - | |
| 7466 | - if($this->options['membersystem_state'] == 'activate'){ | |
| 7467 | - | |
| 7468 | - if( $this->is_member_logged_in() ) { | |
| 7469 | - | |
| 7470 | - $member_regmode = 'editmemberform'; | |
| 7471 | - $temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php'); | |
| 7472 | - include( $temp_path ); | |
| 7473 | - | |
| 7474 | - } else { | |
| 7475 | - | |
| 7476 | - switch($this->page){ | |
| 7477 | - case 'login': | |
| 7478 | - $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php'); | |
| 7479 | - include( $temp_path ); | |
| 7480 | - break; | |
| 7481 | - case 'lostmemberpassword': | |
| 7482 | - $temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php'); | |
| 7483 | - include( $temp_path ); | |
| 7484 | - break; | |
| 7485 | - case 'changepassword': | |
| 7486 | - $temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php'); | |
| 7487 | - include( $temp_path ); | |
| 7488 | - break; | |
| 7489 | - case 'newcompletion': | |
| 7490 | - case 'editcompletion': | |
| 7491 | - case 'lostcompletion': | |
| 7492 | - case 'changepasscompletion': | |
| 7493 | - $temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php'); | |
| 7494 | - include( $temp_path ); | |
| 7495 | - break; | |
| 7496 | - case 'newmemberform': | |
| 7497 | - $member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces')); | |
| 7498 | - $member_regmode = 'newmemberform'; | |
| 7499 | - $temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php'); | |
| 7500 | - include( $temp_path ); | |
| 7501 | - break; | |
| 7502 | - default: | |
| 7503 | - $temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php'); | |
| 7504 | - include( $temp_path ); | |
| 7505 | - } | |
| 7506 | - | |
| 7507 | - } | |
| 7508 | - }else{ | |
| 7509 | - $html .= "<p>只今会員サービスは提供いたしておりません。</p>"; | |
| 7510 | - } | |
| 7511 | - | |
| 7512 | - $content = $html; | |
| 7513 | - | |
| 7514 | - remove_filter('the_title', array($this, 'filter_memberTitle')); | |
| 7515 | - | |
| 7516 | - return $content; | |
| 7517 | - } | |
| 7518 | - | |
| 7519 | - function filter_memberTitle($title) { | |
| 7520 | - | |
| 7521 | - if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){ | |
| 7522 | - switch($this->page){ | |
| 7523 | - case 'login': | |
| 7524 | - $newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces')); | |
| 7525 | - break; | |
| 7526 | - case 'newmemberform': | |
| 7527 | - $newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces')); | |
| 7528 | - break; | |
| 7529 | - case 'lostmemberpassword': | |
| 7530 | - $newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces')); | |
| 7531 | - break; | |
| 7532 | - case 'changepassword': | |
| 7533 | - $newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces')); | |
| 7534 | - break; | |
| 7535 | - case 'newcompletion': | |
| 7536 | - case 'editcompletion': | |
| 7537 | - case 'lostcompletion': | |
| 7538 | - case 'changepasscompletion': | |
| 7539 | - $newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces')); | |
| 7540 | - break; | |
| 7541 | - case 'error': | |
| 7542 | - $newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces')); | |
| 7543 | - break; | |
| 7544 | - default: | |
| 7545 | - $newtitle = apply_filters('usces_filter_title_member_default', $title); | |
| 7546 | - } | |
| 7547 | - }else{ | |
| 7548 | - $newtitle = $title; | |
| 7549 | - } | |
| 7550 | - | |
| 7551 | - $newtitle = apply_filters('usces_filter_memberTitle', $newtitle); | |
| 7552 | - return $newtitle; | |
| 7553 | - } | |
| 7554 | - | |
| 7555 | - function action_memberFilter(){ | |
| 7556 | - add_filter('the_title', array($this, 'filter_memberTitle'),20); | |
| 7557 | - add_filter('the_content', array($this, 'filter_memberContent'),20); | |
| 7558 | - } | |
| 7559 | - | |
| 7560 | - function filter_usces_cart_css(){ | |
| 7561 | - $path = get_stylesheet_directory_uri() . '/usces_cart.css'; | |
| 7562 | - return $path; | |
| 7563 | - } | |
| 7564 | - | |
| 7565 | - function filter_divide_item(){ | |
| 7566 | - global $wp_query; | |
| 7567 | - | |
| 7568 | - | |
| 7569 | - if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){ | |
| 7570 | - $ids = $this->getItemIds( 'front' ); | |
| 7571 | - $wp_query->query_vars['post__not_in'] = $ids; | |
| 7572 | - | |
| 7573 | - } | |
| 7574 | - if( is_admin() ){ | |
| 7575 | - $ids = $this->getItemIds( 'back' ); | |
| 7576 | - //$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID); | |
| 7577 | - $wp_query->query_vars['post__not_in'] = $ids; | |
| 7578 | - } | |
| 7579 | - do_action( 'usces_action_divide_item'); | |
| 7580 | - } | |
| 7581 | - | |
| 7582 | - function load_upload_template(){ | |
| 7583 | - $post_id = $_POST['post_id']; | |
| 7584 | - $file = 'upload_template01.php'; | |
| 7585 | - include(TEMPLATEPATH . '/' . $file); | |
| 7586 | - exit; | |
| 7587 | - } | |
| 7588 | - | |
| 7589 | - function filter_itemimg_anchor_rel($html){ | |
| 7590 | - | |
| 7591 | - if( is_single() ){ | |
| 7592 | - $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"'; | |
| 7593 | - }else{ | |
| 7594 | - $str = ''; | |
| 7595 | - } | |
| 7596 | - return $html . $str; | |
| 7597 | - } | |
| 7598 | - | |
| 7599 | - function filter_permalink( $link ) { | |
| 7600 | - | |
| 7601 | - if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) ) | |
| 7602 | - $link = str_replace('http://', 'https://', $link); | |
| 7603 | - | |
| 7604 | - return $link; | |
| 7605 | - } | |
| 7606 | - | |
| 7607 | - function filter_cart_page_header($html){ | |
| 7608 | - if( !empty($this->options['cart_page_data']['header']['cart']) ){ | |
| 7609 | - $html = $this->options['cart_page_data']['header']['cart']; | |
| 7610 | - } | |
| 7611 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7612 | - } | |
| 7613 | - | |
| 7614 | - function filter_cart_page_footer($html){ | |
| 7615 | - if( !empty($this->options['cart_page_data']['footer']['cart']) ){ | |
| 7616 | - $html = $this->options['cart_page_data']['footer']['cart']; | |
| 7617 | - } | |
| 7618 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7619 | - } | |
| 7620 | - | |
| 7621 | - function filter_customer_page_header($html){ | |
| 7622 | - if( !empty($this->options['cart_page_data']['header']['customer']) ){ | |
| 7623 | - $html = $this->options['cart_page_data']['header']['customer']; | |
| 7624 | - } | |
| 7625 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7626 | - } | |
| 7627 | - | |
| 7628 | - function filter_customer_page_footer($html){ | |
| 7629 | - if( !empty($this->options['cart_page_data']['footer']['customer']) ){ | |
| 7630 | - $html = $this->options['cart_page_data']['footer']['customer']; | |
| 7631 | - } | |
| 7632 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7633 | - } | |
| 7634 | - | |
| 7635 | - function filter_delivery_page_header($html){ | |
| 7636 | - if( !empty($this->options['cart_page_data']['header']['delivery']) ){ | |
| 7637 | - $html = $this->options['cart_page_data']['header']['delivery']; | |
| 7638 | - } | |
| 7639 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7640 | - } | |
| 7641 | - | |
| 7642 | - function filter_delivery_page_footer($html){ | |
| 7643 | - if( !empty($this->options['cart_page_data']['footer']['delivery']) ){ | |
| 7644 | - $html = $this->options['cart_page_data']['footer']['delivery']; | |
| 7645 | - } | |
| 7646 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7647 | - } | |
| 7648 | - | |
| 7649 | - function filter_confirm_page_header($html){ | |
| 7650 | - if( !empty($this->options['cart_page_data']['header']['confirm']) ){ | |
| 7651 | - $html = $this->options['cart_page_data']['header']['confirm']; | |
| 7652 | - } | |
| 7653 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7654 | - } | |
| 7655 | - | |
| 7656 | - function filter_confirm_page_footer($html){ | |
| 7657 | - if( !empty($this->options['cart_page_data']['footer']['confirm']) ){ | |
| 7658 | - $html = $this->options['cart_page_data']['footer']['confirm']; | |
| 7659 | - } | |
| 7660 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7661 | - } | |
| 7662 | - | |
| 7663 | - function filter_cartcompletion_page_header($html){ | |
| 7664 | - if( !empty($this->options['cart_page_data']['header']['completion']) ){ | |
| 7665 | - $html = $this->options['cart_page_data']['header']['completion']; | |
| 7666 | - } | |
| 7667 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7668 | - } | |
| 7669 | - | |
| 7670 | - function filter_cartcompletion_page_footer($html){ | |
| 7671 | - if( !empty($this->options['cart_page_data']['footer']['completion']) ){ | |
| 7672 | - $html = $this->options['cart_page_data']['footer']['completion']; | |
| 7673 | - } | |
| 7674 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7675 | - } | |
| 7676 | - | |
| 7677 | - function filter_login_page_header($html){ | |
| 7678 | - if( !empty($this->options['member_page_data']['header']['login']) ){ | |
| 7679 | - $html = $this->options['member_page_data']['header']['login']; | |
| 7680 | - } | |
| 7681 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7682 | - } | |
| 7683 | - | |
| 7684 | - function filter_login_page_footer($html){ | |
| 7685 | - if( !empty($this->options['member_page_data']['footer']['login']) ){ | |
| 7686 | - $html = $this->options['member_page_data']['footer']['login']; | |
| 7687 | - } | |
| 7688 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7689 | - } | |
| 7690 | - | |
| 7691 | - function filter_newmember_page_header($html){ | |
| 7692 | - if( !empty($this->options['member_page_data']['header']['newmember']) ){ | |
| 7693 | - $html = $this->options['member_page_data']['header']['newmember']; | |
| 7694 | - } | |
| 7695 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7696 | - } | |
| 7697 | - | |
| 7698 | - function filter_newmember_page_footer($html){ | |
| 7699 | - if( !empty($this->options['member_page_data']['footer']['newmember']) ){ | |
| 7700 | - $html = $this->options['member_page_data']['footer']['newmember']; | |
| 7701 | - } | |
| 7702 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7703 | - } | |
| 7704 | - | |
| 7705 | - function filter_newpass_page_header($html){ | |
| 7706 | - if( !empty($this->options['member_page_data']['header']['newpass']) ){ | |
| 7707 | - $html = $this->options['member_page_data']['header']['newpass']; | |
| 7708 | - } | |
| 7709 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7710 | - } | |
| 7711 | - | |
| 7712 | - function filter_newpass_page_footer($html){ | |
| 7713 | - if( !empty($this->options['member_page_data']['footer']['newpass']) ){ | |
| 7714 | - $html = $this->options['member_page_data']['footer']['newpass']; | |
| 7715 | - } | |
| 7716 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7717 | - } | |
| 7718 | - | |
| 7719 | - function filter_changepass_page_header($html){ | |
| 7720 | - if( !empty($this->options['member_page_data']['header']['changepass']) ){ | |
| 7721 | - $html = $this->options['member_page_data']['header']['changepass']; | |
| 7722 | - } | |
| 7723 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7724 | - } | |
| 7725 | - | |
| 7726 | - function filter_changepass_page_footer($html){ | |
| 7727 | - if( !empty($this->options['member_page_data']['footer']['changepass']) ){ | |
| 7728 | - $html = $this->options['member_page_data']['footer']['changepass']; | |
| 7729 | - } | |
| 7730 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7731 | - } | |
| 7732 | - | |
| 7733 | - function filter_memberinfo_page_header($html){ | |
| 7734 | - if( !empty($this->options['member_page_data']['header']['memberinfo']) ){ | |
| 7735 | - $html = $this->options['member_page_data']['header']['memberinfo']; | |
| 7736 | - } | |
| 7737 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7738 | - } | |
| 7739 | - | |
| 7740 | - function filter_memberinfo_page_footer($html){ | |
| 7741 | - if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){ | |
| 7742 | - $html = $this->options['member_page_data']['footer']['memberinfo']; | |
| 7743 | - } | |
| 7744 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7745 | - } | |
| 7746 | - | |
| 7747 | - function filter_membercompletion_page_header($html){ | |
| 7748 | - if( !empty($this->options['member_page_data']['header']['completion']) ){ | |
| 7749 | - $html = $this->options['member_page_data']['header']['completion']; | |
| 7750 | - } | |
| 7751 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7752 | - } | |
| 7753 | - | |
| 7754 | - function filter_membercompletion_page_footer($html){ | |
| 7755 | - if( !empty($this->options['member_page_data']['footer']['completion']) ){ | |
| 7756 | - $html = $this->options['member_page_data']['footer']['completion']; | |
| 7757 | - } | |
| 7758 | - return do_shortcode( stripslashes(nl2br($html)) ); | |
| 7759 | - } | |
| 7760 | - | |
| 7761 | - function action_cart_page_header(){ | |
| 7762 | - if( !empty($this->options['cart_page_data']['header']['cart']) ){ | |
| 7763 | - $html = $this->options['cart_page_data']['header']['cart']; | |
| 7764 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7765 | - } | |
| 7766 | - } | |
| 7767 | - | |
| 7768 | - function action_cart_page_footer(){ | |
| 7769 | - if( !empty($this->options['cart_page_data']['footer']['cart']) ){ | |
| 7770 | - $html = $this->options['cart_page_data']['footer']['cart']; | |
| 7771 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7772 | - } | |
| 7773 | - } | |
| 7774 | - | |
| 7775 | - function action_customer_page_header(){ | |
| 7776 | - if( !empty($this->options['cart_page_data']['header']['customer']) ){ | |
| 7777 | - $html = $this->options['cart_page_data']['header']['customer']; | |
| 7778 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7779 | - } | |
| 7780 | - } | |
| 7781 | - | |
| 7782 | - function action_customer_page_footer(){ | |
| 7783 | - if( !empty($this->options['cart_page_data']['footer']['customer']) ){ | |
| 7784 | - $html = $this->options['cart_page_data']['footer']['customer']; | |
| 7785 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7786 | - } | |
| 7787 | - } | |
| 7788 | - | |
| 7789 | - function action_delivery_page_header(){ | |
| 7790 | - if( !empty($this->options['cart_page_data']['header']['delivery']) ){ | |
| 7791 | - $html = $this->options['cart_page_data']['header']['delivery']; | |
| 7792 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7793 | - } | |
| 7794 | - } | |
| 7795 | - | |
| 7796 | - function action_delivery_page_footer(){ | |
| 7797 | - if( !empty($this->options['cart_page_data']['footer']['delivery']) ){ | |
| 7798 | - $html = $this->options['cart_page_data']['footer']['delivery']; | |
| 7799 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7800 | - } | |
| 7801 | - } | |
| 7802 | - | |
| 7803 | - function action_confirm_page_header(){ | |
| 7804 | - if( !empty($this->options['cart_page_data']['header']['confirm']) ){ | |
| 7805 | - $html = $this->options['cart_page_data']['header']['confirm']; | |
| 7806 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7807 | - } | |
| 7808 | - } | |
| 7809 | - | |
| 7810 | - function action_confirm_page_footer(){ | |
| 7811 | - if( !empty($this->options['cart_page_data']['footer']['confirm']) ){ | |
| 7812 | - $html = $this->options['cart_page_data']['footer']['confirm']; | |
| 7813 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7814 | - } | |
| 7815 | - } | |
| 7816 | - | |
| 7817 | - function action_cartcompletion_page_header(){ | |
| 7818 | - if( !empty($this->options['cart_page_data']['header']['completion']) ){ | |
| 7819 | - $html = $this->options['cart_page_data']['header']['completion']; | |
| 7820 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7821 | - } | |
| 7822 | - } | |
| 7823 | - | |
| 7824 | - function action_cartcompletion_page_footer(){ | |
| 7825 | - if( !empty($this->options['cart_page_data']['footer']['completion']) ){ | |
| 7826 | - $html = $this->options['cart_page_data']['footer']['completion']; | |
| 7827 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7828 | - } | |
| 7829 | - } | |
| 7830 | - | |
| 7831 | - function action_login_page_header(){ | |
| 7832 | - if( !empty($this->options['member_page_data']['header']['login']) ){ | |
| 7833 | - $html = $this->options['member_page_data']['header']['login']; | |
| 7834 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7835 | - } | |
| 7836 | - } | |
| 7837 | - | |
| 7838 | - function action_login_page_footer(){ | |
| 7839 | - if( !empty($this->options['member_page_data']['footer']['login']) ){ | |
| 7840 | - $html = $this->options['member_page_data']['footer']['login']; | |
| 7841 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7842 | - } | |
| 7843 | - } | |
| 7844 | - | |
| 7845 | - function action_newmember_page_header(){ | |
| 7846 | - if( !empty($this->options['member_page_data']['header']['newmember']) ){ | |
| 7847 | - $html = $this->options['member_page_data']['header']['newmember']; | |
| 7848 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7849 | - } | |
| 7850 | - } | |
| 7851 | - | |
| 7852 | - function action_newmember_page_footer(){ | |
| 7853 | - if( !empty($this->options['member_page_data']['footer']['newmember']) ){ | |
| 7854 | - $html = $this->options['member_page_data']['footer']['newmember']; | |
| 7855 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7856 | - } | |
| 7857 | - } | |
| 7858 | - | |
| 7859 | - function action_newpass_page_header(){ | |
| 7860 | - if( !empty($this->options['member_page_data']['header']['newpass']) ){ | |
| 7861 | - $html = $this->options['member_page_data']['header']['newpass']; | |
| 7862 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7863 | - } | |
| 7864 | - } | |
| 7865 | - | |
| 7866 | - function action_newpass_page_footer(){ | |
| 7867 | - if( !empty($this->options['member_page_data']['footer']['newpass']) ){ | |
| 7868 | - $html = $this->options['member_page_data']['footer']['newpass']; | |
| 7869 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7870 | - } | |
| 7871 | - } | |
| 7872 | - | |
| 7873 | - function action_changepass_page_header(){ | |
| 7874 | - if( !empty($this->options['member_page_data']['header']['changepass']) ){ | |
| 7875 | - $html = $this->options['member_page_data']['header']['changepass']; | |
| 7876 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7877 | - } | |
| 7878 | - } | |
| 7879 | - | |
| 7880 | - function action_changepass_page_footer(){ | |
| 7881 | - if( !empty($this->options['member_page_data']['footer']['changepass']) ){ | |
| 7882 | - $html = $this->options['member_page_data']['footer']['changepass']; | |
| 7883 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7884 | - } | |
| 7885 | - } | |
| 7886 | - | |
| 7887 | - function action_memberinfo_page_header(){ | |
| 7888 | - if( !empty($this->options['member_page_data']['header']['memberinfo']) ){ | |
| 7889 | - $html = $this->options['member_page_data']['header']['memberinfo']; | |
| 7890 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7891 | - } | |
| 7892 | - } | |
| 7893 | - | |
| 7894 | - function action_memberinfo_page_footer(){ | |
| 7895 | - if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){ | |
| 7896 | - $html = $this->options['member_page_data']['footer']['memberinfo']; | |
| 7897 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7898 | - } | |
| 7899 | - } | |
| 7900 | - | |
| 7901 | - function action_membercompletion_page_header(){ | |
| 7902 | - if( !empty($this->options['member_page_data']['header']['completion']) ){ | |
| 7903 | - $html = $this->options['member_page_data']['header']['completion']; | |
| 7904 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7905 | - } | |
| 7906 | - } | |
| 7907 | - | |
| 7908 | - function action_membercompletion_page_footer(){ | |
| 7909 | - if( !empty($this->options['member_page_data']['footer']['completion']) ){ | |
| 7910 | - $html = $this->options['member_page_data']['footer']['completion']; | |
| 7911 | - echo do_shortcode( stripslashes(nl2br($html)) ); | |
| 7912 | - } | |
| 7913 | - } | |
| 7914 | - | |
| 7915 | -} | |
| 7916 | -?> | |
| 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 | + // A1 (Layer 3 / uscesid removal): uscesid によるセッションID設定を撤廃。 | |
| 2026 | + // かつては GET uscesid を uscesdc() で復号し session_id() に渡していたが、これがセッション | |
| 2027 | + // 固定の温床だった(会員乗っ取り・Mantis #0005562)。決済通知のセッション復元は取引キーの | |
| 2028 | + // DBストア(A3)/同一オリジンの uk cookie 再開(A2/A5/A6)へ移行済みのため撤廃する。 | |
| 2029 | + // See .docs/welcart2.x/security-remediation_uscesid-layer3-a1c-teardown-design.md . | |
| 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 | + // A1/C (Layer 3 / uscesid removal): 旧「GET uscesid を復号して addr='acting' を判定」ブロックを撤廃。 | |
| 2075 | + // uscesid 機構撤廃に伴い addr 判定は成立しない。以降は旧SSL同期デッドコード(A7 で撤去済)で return. | |
| 2076 | + if ( apply_filters( 'usces_filter_cookie', false ) ) { | |
| 2077 | + return; | |
| 2078 | + } | |
| 2079 | + | |
| 2080 | + // NOTE (Layer 3 / uscesid removal, A7): the legacy "common domain + separate SSL domain" | |
| 2081 | + // cookie-sync block that used to follow here was already unreachable (an unconditional | |
| 2082 | + // return above) and relied on the old SSL/uscesid scheme. Removed during the uscesid | |
| 2083 | + // mechanism teardown. See .docs/welcart2.x/security-remediation_uscesid-session-fixation.md 4.3.A A7. | |
| 2084 | + return; | |
| 2085 | + } | |
| 2086 | + | |
| 2087 | + public function set_cookie( $values, $key = 'usces_cookie' ) { | |
| 2088 | + // A1/C (Layer 3 / uscesid removal): 旧実装は uscesid 付きリクエストで再生成をスキップしていたが、 | |
| 2089 | + // uscesid 機構を撤廃したため常に再生成する(=uscesid 以前のオーガニック挙動に一致)。 | |
| 2090 | + // 決済のセッション継続は取引キーDBストア(A3)/uk cookie(A2/A5/A6)で担保. | |
| 2091 | + session_regenerate_id( true ); | |
| 2092 | + $value = usces_serialize( $values ); | |
| 2093 | + $timeout = time()+7*86400; | |
| 2094 | + $timeout = apply_filters( 'usces_filter_set_cookie_timeout', $timeout, $values, $key ); | |
| 2095 | + $domain = $_SERVER['SERVER_NAME']; | |
| 2096 | + | |
| 2097 | + $httponly = true; | |
| 2098 | + $sitescheme = substr( get_option( 'siteurl' ), 0, 5 ); | |
| 2099 | + $homescheme = substr( get_option( 'home' ), 0, 5 ); | |
| 2100 | + if ( 'https' == $sitescheme && 'https' == $homescheme ) { | |
| 2101 | + $sslonly = true; | |
| 2102 | + $samesite = 'None'; | |
| 2103 | + } else { | |
| 2104 | + $sslonly = false; | |
| 2105 | + $samesite = ''; | |
| 2106 | + } | |
| 2107 | + | |
| 2108 | + if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) { | |
| 2109 | + $cookie_options = array( | |
| 2110 | + 'expires' => $timeout, | |
| 2111 | + 'path' => USCES_COOKIEPATH, | |
| 2112 | + 'domain' => $domain, | |
| 2113 | + 'secure' => $sslonly, | |
| 2114 | + 'httponly' => $httponly, | |
| 2115 | + 'samesite' => $samesite, | |
| 2116 | + ); | |
| 2117 | + $res = setcookie( $key, $value, $cookie_options ); | |
| 2118 | + } else { | |
| 2119 | + $res = setcookie( $key, $value, $timeout, USCES_COOKIEPATH, $domain, true, true ); | |
| 2120 | + } | |
| 2121 | + } | |
| 2122 | + | |
| 2123 | + public function get_cookie( $key = 'usces_cookie' ) { | |
| 2124 | + $values = isset( $_COOKIE[ $key ] ) ? usces_unserialize( stripslashes( $_COOKIE[ $key ] ) ) : null; | |
| 2125 | + return $values; | |
| 2126 | + } | |
| 2127 | + | |
| 2128 | + public function get_access( $key, $type, $date ) { | |
| 2129 | + global $wpdb; | |
| 2130 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2131 | + | |
| 2132 | + $query = $wpdb->prepare( "SELECT acc_value FROM $table_name WHERE acc_key = %s AND acc_type = %s AND acc_date = %s", $key, $type, $date ); | |
| 2133 | + $value = $wpdb->get_var( $query ); | |
| 2134 | + if ( ! $value ) { | |
| 2135 | + $res = null; | |
| 2136 | + } else { | |
| 2137 | + $res = wel_safe_unserialize( $value ); | |
| 2138 | + } | |
| 2139 | + | |
| 2140 | + return $res; | |
| 2141 | + } | |
| 2142 | + | |
| 2143 | + public function get_access_piriod( $key, $type, $startday, $endday ) { | |
| 2144 | + global $wpdb; | |
| 2145 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2146 | + $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 ); | |
| 2147 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 2148 | + | |
| 2149 | + return $res; | |
| 2150 | + } | |
| 2151 | + | |
| 2152 | + public function update_access( $array ) { | |
| 2153 | + global $wpdb; | |
| 2154 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 2155 | + | |
| 2156 | + $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'] ); | |
| 2157 | + $res = $wpdb->get_var( $query ); | |
| 2158 | + if ( empty( $res ) ) { | |
| 2159 | + $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'] ); | |
| 2160 | + $wpdb->query( $query ); | |
| 2161 | + } else { | |
| 2162 | + $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'] ); | |
| 2163 | + $wpdb->query( $query ); | |
| 2164 | + } | |
| 2165 | + } | |
| 2166 | + | |
| 2167 | + /** | |
| 2168 | + * @deprecated A1/C (Layer 3 / uscesid removal). uscesid 機構は撤廃済み(A1)。本体はこの関数を | |
| 2169 | + * セッション設定にもURL/nonce生成にも使わない。現状 acting_data の acc_str1 マーカー(save_order_acting_data) | |
| 2170 | + * と、未移行の拡張・クライアントの後方互換のためだけに残置している。**全拡張・全クライアント移行後に | |
| 2171 | + * uscescv()/uscesdc() ともども削除する**(最終クリーンアップ)。 | |
| 2172 | + */ | |
| 2173 | + public function get_uscesid( $flag = true ) { | |
| 2174 | + $sessname = session_name(); | |
| 2175 | + $sessid = session_id(); | |
| 2176 | + $sessid = $this->uscescv( $sessid, $flag ); | |
| 2177 | + return $sessid; | |
| 2178 | + } | |
| 2179 | + | |
| 2180 | + /** | |
| 2181 | + * Session-bound nonce action key for shop-member forms (uscesid-free). | |
| 2182 | + * | |
| 2183 | + * Welcart shop members are not WordPress users (uid=0, empty WP session token), so a | |
| 2184 | + * per-session component is mixed into the nonce action string to keep nonces scoped to | |
| 2185 | + * the individual shop session. This replaces the legacy `$action . get_uscesid(false)` | |
| 2186 | + * (which encoded the same session id via the uscesid obfuscation). The session id is | |
| 2187 | + * used only as a server-side hash input — it is never output to the client or a URL. | |
| 2188 | + * | |
| 2189 | + * @param string $action Base action (e.g. 'post_member' / 'use_point' / 'wc_purchase_nonce'). | |
| 2190 | + * @return string | |
| 2191 | + */ | |
| 2192 | + public function member_nonce_key( $action ) { | |
| 2193 | + return $action . session_id(); | |
| 2194 | + } | |
| 2195 | + | |
| 2196 | + /** | |
| 2197 | + * Create a shop-member nonce bound to the current session. | |
| 2198 | + * | |
| 2199 | + * @param string $action Base action. | |
| 2200 | + * @return string | |
| 2201 | + */ | |
| 2202 | + public function create_member_nonce( $action ) { | |
| 2203 | + return wp_create_nonce( $this->member_nonce_key( $action ) ); | |
| 2204 | + } | |
| 2205 | + | |
| 2206 | + /** | |
| 2207 | + * Verify a shop-member nonce. | |
| 2208 | + * | |
| 2209 | + * A1/C (Layer 3 / uscesid removal): 移行期の後方互換だった「旧 uscesid ベースキーの二重受理」を撤廃。 | |
| 2210 | + * 以降はセッション束縛の新方式キー(member_nonce_key)のみ受理する。未移行の拡張・テーマの | |
| 2211 | + * フォーム(旧キー生成)は新方式へ移行するまで nonce 不一致になる(協調リリースで同時展開)。 | |
| 2212 | + * | |
| 2213 | + * @param string $nonce Nonce value from the request. | |
| 2214 | + * @param string $action Base action. | |
| 2215 | + * @return int|false 1|2 on success, false on failure. | |
| 2216 | + */ | |
| 2217 | + public function verify_member_nonce( $nonce, $action ) { | |
| 2218 | + return wp_verify_nonce( $nonce, $this->member_nonce_key( $action ) ); | |
| 2219 | + } | |
| 2220 | + | |
| 2221 | + public function shop_head() { | |
| 2222 | + global $post; | |
| 2223 | + $this->item = $post; | |
| 2224 | + if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2225 | + echo "<meta name='robots' content='noindex,nofollow' />\n"; | |
| 2226 | + } | |
| 2227 | + } | |
| 2228 | + | |
| 2229 | + /** | |
| 2230 | + * Caught by wp_footer action hook | |
| 2231 | + */ | |
| 2232 | + public function shop_foot() { | |
| 2233 | + global $current_user; | |
| 2234 | + | |
| 2235 | + $item = $this->item; | |
| 2236 | + if ( empty( $item ) ) { | |
| 2237 | + $item = new stdClass; | |
| 2238 | + $item->ID = 0; | |
| 2239 | + $item->post_mime_type = ''; | |
| 2240 | + } | |
| 2241 | + | |
| 2242 | + wp_get_current_user(); | |
| 2243 | + | |
| 2244 | + // usces_cart.js is not used. | |
| 2245 | + if ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 2246 | + $javascript_url = USCES_FRONT_PLUGIN_URL . '/js/usces_cart.js'; | |
| 2247 | + } else { | |
| 2248 | + $javascript_url = USCES_WP_CONTENT_URL . '/plugins/' . USCES_PLUGIN_FOLDER . '/js/usces_cart.js'; | |
| 2249 | + } | |
| 2250 | + | |
| 2251 | + $this->previous_url = isset( $_SESSION['usces_previous_url'] ) ? $_SESSION['usces_previous_url'] : get_home_url(); | |
| 2252 | + | |
| 2253 | + // If the product object does't exists. | |
| 2254 | + if ( $this->use_js && empty( $this->item ) ) { | |
| 2255 | + ?> | |
| 2256 | + <script type='text/javascript'> | |
| 2257 | + uscesL10n = { | |
| 2258 | + <?php echo apply_filters( 'usces_filter_uscesL10n', null, $item->ID ); ?> | |
| 2259 | + | |
| 2260 | + 'ajaxurl': "<?php echo esc_url( $this->ssl_admin_ajax_url() ); ?>" | |
| 2261 | + } | |
| 2262 | + </script> | |
| 2263 | + <?php | |
| 2264 | + | |
| 2265 | + // If the product object exists. | |
| 2266 | + } elseif ( $this->use_js && ! empty( $this->item ) ) { | |
| 2267 | + | |
| 2268 | + $ioptkeys = $this->get_itemOptionKey( $item->ID ); | |
| 2269 | + $mes_opts_str = ''; | |
| 2270 | + $key_opts_str = ''; | |
| 2271 | + $opt_means = ''; | |
| 2272 | + $opt_esse = ''; | |
| 2273 | + if ( $ioptkeys ) { | |
| 2274 | + foreach ( $ioptkeys as $key => $value ) { | |
| 2275 | + $optValues = $this->get_itemOptions( $value, $item->ID ); | |
| 2276 | + if ( false === $optValues ) { | |
| 2277 | + continue; | |
| 2278 | + } | |
| 2279 | + if ( $optValues['means'] < 2 || 3 == $optValues['means'] || 4 == $optValues['means'] ) { | |
| 2280 | + $mes_opts_str .= "'" . sprintf( __( 'Chose the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',"; | |
| 2281 | + } else { | |
| 2282 | + $mes_opts_str .= "'" . sprintf( __( 'Input the %s', 'usces' ), esc_js( apply_filters( 'usces_filter_uscesL10n_option_name', $value, $optValues ) ) ) . "',"; | |
| 2283 | + } | |
| 2284 | + $key_opts_str .= "'" . urlencode( esc_js( $value ) ) . "',"; | |
| 2285 | + $opt_means .= "'" . esc_js( $optValues['means'] ) . "',"; | |
| 2286 | + $opt_esse .= "'" . esc_js( $optValues['essential'] ) . "',"; | |
| 2287 | + } | |
| 2288 | + $mes_opts_str = rtrim( $mes_opts_str, ',' ); | |
| 2289 | + $key_opts_str = rtrim( $key_opts_str, ',' ); | |
| 2290 | + $opt_means = rtrim( $opt_means, ',' ); | |
| 2291 | + $opt_esse = rtrim( $opt_esse, ',' ); | |
| 2292 | + } | |
| 2293 | + | |
| 2294 | + $product = wel_get_product( $item->ID ); | |
| 2295 | + $itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : ''; | |
| 2296 | + $wcpage = usces_page_name( 'return' ); | |
| 2297 | + $nonce_action = 'wc_confirm'; | |
| 2298 | + $itemOrderAcceptable = $this->getItemOrderAcceptable( $item->ID ); | |
| 2299 | + ?> | |
| 2300 | + <script type='text/javascript'> | |
| 2301 | + uscesL10n = { | |
| 2302 | + <?php echo apply_filters( 'usces_filter_uscesL10n', null, $item->ID ); ?> | |
| 2303 | + | |
| 2304 | + 'ajaxurl': "<?php echo esc_url( $this->ssl_admin_ajax_url() ); ?>", | |
| 2305 | + 'loaderurl': "<?php echo USCES_PLUGIN_URL . 'images/loading.gif'; ?>", | |
| 2306 | + 'post_id': "<?php echo esc_js( $item->ID ); ?>", | |
| 2307 | + 'cart_number': "<?php echo get_option( 'usces_cart_number' ); ?>", | |
| 2308 | + 'is_cart_row': <?php echo ( ( 0 < $this->cart->num_row() ) ? 'true' : 'false' ); ?>, | |
| 2309 | + 'opt_esse': new Array( <?php wel_esc_script_e( $opt_esse ); ?> ), | |
| 2310 | + 'opt_means': new Array( <?php wel_esc_script_e( $opt_means ); ?> ), | |
| 2311 | + 'mes_opts': new Array( <?php wel_esc_script_e( $mes_opts_str ); ?> ), | |
| 2312 | + 'key_opts': new Array( <?php wel_esc_script_e( $key_opts_str ); ?> ), | |
| 2313 | + 'previous_url': "<?php echo esc_url( $this->previous_url ); ?>", | |
| 2314 | + 'itemRestriction': "<?php echo esc_js( $itemRestriction ); ?>", | |
| 2315 | + 'itemOrderAcceptable': "<?php echo esc_js( $itemOrderAcceptable ); ?>", | |
| 2316 | + 'uscespage': "<?php echo esc_js( $wcpage ); ?>", | |
| 2317 | + <?php // A1/C (Layer 3 / uscesid removal): JS グローバル uscesL10n.uscesid の供給を撤廃。消費側は uk cookie 依存へ移行. ?> | |
| 2318 | + 'wc_nonce': "<?php echo wp_create_nonce( $nonce_action ); ?>" | |
| 2319 | + } | |
| 2320 | + </script> | |
| 2321 | + <script type='text/javascript' src='<?php echo esc_url( $javascript_url ); ?>'></script> | |
| 2322 | + <?php | |
| 2323 | + } | |
| 2324 | + | |
| 2325 | + ob_start(); | |
| 2326 | + | |
| 2327 | + // If it's Product Details page. | |
| 2328 | + if ( $this->use_js && ( is_singular() && 'item' == $item->post_mime_type ) ) { | |
| 2329 | + ?> | |
| 2330 | + <script type='text/javascript'> | |
| 2331 | + (function($) { | |
| 2332 | + uscesCart = { | |
| 2333 | + intoCart : function (post_id, sku) { | |
| 2334 | + var zaikonum = $("[id='zaikonum["+post_id+"]["+sku+"]']").val(); | |
| 2335 | + var zaiko = $("[id='zaiko["+post_id+"]["+sku+"]']").val(); | |
| 2336 | + if( <?php echo apply_filters( 'usces_intoCart_zaiko_check_js', "( uscesL10n.itemOrderAcceptable != '1' && zaiko != '0' && zaiko != '1' ) || ( uscesL10n.itemOrderAcceptable != '1' && parseInt(zaikonum) == 0 )" ); ?> ){ | |
| 2337 | + alert('<?php _e( 'temporaly out of stock now', 'usces' ); ?>'); | |
| 2338 | + return false; | |
| 2339 | + } | |
| 2340 | + | |
| 2341 | + var mes = ''; | |
| 2342 | + if( $("[id='quant["+post_id+"]["+sku+"]']").length ){ | |
| 2343 | + var quant = $("[id='quant["+post_id+"]["+sku+"]']").val(); | |
| 2344 | + if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 2345 | + mes += "<?php _e( 'enter the correct amount', 'usces' ); ?>\n"; | |
| 2346 | + } | |
| 2347 | + var checknum = ''; | |
| 2348 | + var checkmode = ''; | |
| 2349 | + if( parseInt(uscesL10n.itemRestriction) <= parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) { | |
| 2350 | + checknum = uscesL10n.itemRestriction; | |
| 2351 | + checkmode ='rest'; | |
| 2352 | + } else if( uscesL10n.itemOrderAcceptable != '1' && parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) && uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && zaikonum != '' ) { | |
| 2353 | + checknum = zaikonum; | |
| 2354 | + checkmode ='zaiko'; | |
| 2355 | + } else if( uscesL10n.itemOrderAcceptable != '1' && (uscesL10n.itemRestriction == '' || uscesL10n.itemRestriction == '0') && zaikonum != '' ) { | |
| 2356 | + checknum = zaikonum; | |
| 2357 | + checkmode ='zaiko'; | |
| 2358 | + } else if( uscesL10n.itemRestriction != '' && uscesL10n.itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(uscesL10n.itemRestriction) > parseInt(zaikonum) ) ) { | |
| 2359 | + checknum = uscesL10n.itemRestriction; | |
| 2360 | + checkmode ='rest'; | |
| 2361 | + } | |
| 2362 | + | |
| 2363 | + if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 2364 | + if(checkmode == 'rest'){ | |
| 2365 | + mes += <?php _e( "'This article is limited by '+checknum+' at a time.'", 'usces' ); ?>+"\n"; | |
| 2366 | + }else{ | |
| 2367 | + mes += <?php _e( "'Stock is remainder '+checknum+'.'", 'usces' ); ?>+"\n"; | |
| 2368 | + } | |
| 2369 | + } | |
| 2370 | + } | |
| 2371 | + for(i=0; i<uscesL10n.key_opts.length; i++){ | |
| 2372 | + if( uscesL10n.opt_esse[i] == '1' ){ | |
| 2373 | + var skuob = $("[id='itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]']"); | |
| 2374 | + var itemOption = "itemOption["+post_id+"]["+sku+"]["+uscesL10n.key_opts[i]+"]"; | |
| 2375 | + var opt_obj_radio = $(":radio[name*='"+itemOption+"']"); | |
| 2376 | + var opt_obj_checkbox = $(":checkbox[name*='"+itemOption+"']:checked"); | |
| 2377 | + | |
| 2378 | + if( uscesL10n.opt_means[i] == '3' ){ | |
| 2379 | + | |
| 2380 | + if( !opt_obj_radio.is(':checked') ){ | |
| 2381 | + mes += uscesL10n.mes_opts[i]+"\n"; | |
| 2382 | + } | |
| 2383 | + | |
| 2384 | + }else if( uscesL10n.opt_means[i] == '4' ){ | |
| 2385 | + | |
| 2386 | + if( !opt_obj_checkbox.length ){ | |
| 2387 | + mes += uscesL10n.mes_opts[i]+"\n"; | |
| 2388 | + } | |
| 2389 | + | |
| 2390 | + }else{ | |
| 2391 | + | |
| 2392 | + if( skuob.length ){ | |
| 2393 | + if( uscesL10n.opt_means[i] == 0 && skuob.val() == '#NONE#' ){ | |
| 2394 | + mes += uscesL10n.mes_opts[i]+"\n"; | |
| 2395 | + }else if( uscesL10n.opt_means[i] == 1 && ( skuob.val() == '' || skuob.val() == '#NONE#' ) ){ | |
| 2396 | + mes += uscesL10n.mes_opts[i]+"\n"; | |
| 2397 | + }else if( uscesL10n.opt_means[i] >= 2 && skuob.val() == '' ){ | |
| 2398 | + mes += uscesL10n.mes_opts[i]+"\n"; | |
| 2399 | + } | |
| 2400 | + } | |
| 2401 | + } | |
| 2402 | + } | |
| 2403 | + } | |
| 2404 | + | |
| 2405 | + <?php apply_filters( 'usces_filter_inCart_js_check', $item->ID ); // Unavailable. ?> | |
| 2406 | + <?php do_action( 'usces_action_inCart_js_check', $item->ID ); ?> | |
| 2407 | + | |
| 2408 | + if( mes != '' ){ | |
| 2409 | + alert( mes ); | |
| 2410 | + return false; | |
| 2411 | + }else{ | |
| 2412 | + <?php echo apply_filters( 'usces_filter_js_intoCart', "return true;\n", $item->ID, null ); ?> | |
| 2413 | + } | |
| 2414 | + }, | |
| 2415 | + | |
| 2416 | + isNum : function (num) { | |
| 2417 | + if (num.match(/[^0-9]/g)) { | |
| 2418 | + return false; | |
| 2419 | + } | |
| 2420 | + return true; | |
| 2421 | + } | |
| 2422 | + }; | |
| 2423 | + })(jQuery); | |
| 2424 | + </script> | |
| 2425 | + <?php | |
| 2426 | + // If it's Product Details page. | |
| 2427 | + } elseif ( $this->use_js && ( is_page( USCES_CART_NUMBER ) || $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) ) { | |
| 2428 | + ?> | |
| 2429 | + <script type='text/javascript'> | |
| 2430 | + (function($) { | |
| 2431 | + uscesCart = { | |
| 2432 | + upCart : function () { | |
| 2433 | + | |
| 2434 | + var zaikoob = $("input[name*='zaikonum']"); | |
| 2435 | + var quantob = $("input[name*='quant']"); | |
| 2436 | + var postidob = $("input[name*='itempostid']"); | |
| 2437 | + var skuob = $("input[name*='itemsku']"); | |
| 2438 | + | |
| 2439 | + var zaikonum = ''; | |
| 2440 | + var zaiko = ''; | |
| 2441 | + var quant = ''; | |
| 2442 | + var mes = ''; | |
| 2443 | + var checknum = ''; | |
| 2444 | + var post_id = ''; | |
| 2445 | + var sku = ''; | |
| 2446 | + var itemRestriction = ''; | |
| 2447 | + var itemOrderAcceptable = ''; | |
| 2448 | + | |
| 2449 | + var ct = zaikoob.length; | |
| 2450 | + for(var i=0; i< ct; i++){ | |
| 2451 | + post_id = postidob[i].value; | |
| 2452 | + sku = skuob[i].value; | |
| 2453 | + itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val(); | |
| 2454 | + itemOrderAcceptable = $("input[name='itemOrderAcceptable\[" + i + "\]']").val(); | |
| 2455 | + zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2456 | + | |
| 2457 | + quant = $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2458 | + if( $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").length ){ | |
| 2459 | + if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 2460 | + mes += <?php _e( "'enter the correct amount for the No.' + (i+1) + ' item'", 'usces' ); ?>+"\n"; | |
| 2461 | + } | |
| 2462 | + var checknum = ''; | |
| 2463 | + var checkmode = ''; | |
| 2464 | + if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2465 | + checknum = itemRestriction; | |
| 2466 | + checkmode ='rest'; | |
| 2467 | + } else if( itemOrderAcceptable != '1' && parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2468 | + checknum = zaikonum; | |
| 2469 | + checkmode ='zaiko'; | |
| 2470 | + } else if( itemOrderAcceptable != '1' && (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) { | |
| 2471 | + checknum = zaikonum; | |
| 2472 | + checkmode ='zaiko'; | |
| 2473 | + } else if( itemRestriction != '' && itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(itemRestriction) > parseInt(zaikonum) ) ) { | |
| 2474 | + checknum = itemRestriction; | |
| 2475 | + checkmode ='rest'; | |
| 2476 | + } | |
| 2477 | + if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 2478 | + if(checkmode == 'rest'){ | |
| 2479 | + mes += <?php _e( "'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces' ); ?>+"\n"; | |
| 2480 | + }else{ | |
| 2481 | + mes += <?php _e( "'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces' ); ?>+"\n"; | |
| 2482 | + } | |
| 2483 | + } | |
| 2484 | + } | |
| 2485 | + } | |
| 2486 | + | |
| 2487 | + <?php apply_filters( 'usces_filter_upCart_js_check', $item->ID ); // Unavailable. ?> | |
| 2488 | + <?php do_action( 'usces_action_upCart_js_check', $item->ID ); ?> | |
| 2489 | + | |
| 2490 | + if( mes != '' ){ | |
| 2491 | + alert( mes ); | |
| 2492 | + return false; | |
| 2493 | + }else{ | |
| 2494 | + <?php echo apply_filters( 'usces_filter_js_upCart', "return true;\n", $item->ID, null ); ?> | |
| 2495 | + } | |
| 2496 | + }, | |
| 2497 | + | |
| 2498 | + cartNext : function () { | |
| 2499 | + | |
| 2500 | + var zaikoob = $("input[name*='zaikonum']"); | |
| 2501 | + var quantob = $("input[name*='quant']"); | |
| 2502 | + var postidob = $("input[name*='itempostid']"); | |
| 2503 | + var skuob = $("input[name*='itemsku']"); | |
| 2504 | + | |
| 2505 | + var zaikonum = ''; | |
| 2506 | + var zaiko = ''; | |
| 2507 | + var quant = ''; | |
| 2508 | + var mes = ''; | |
| 2509 | + var checknum = ''; | |
| 2510 | + var post_id = ''; | |
| 2511 | + var sku = ''; | |
| 2512 | + var itemRestriction = ''; | |
| 2513 | + var itemOrderAcceptable = ''; | |
| 2514 | + | |
| 2515 | + var ct = zaikoob.length; | |
| 2516 | + for(var i=0; i< ct; i++){ | |
| 2517 | + post_id = postidob[i].value; | |
| 2518 | + sku = skuob[i].value; | |
| 2519 | + itemRestriction = $("input[name='itemRestriction\[" + i + "\]']").val(); | |
| 2520 | + itemOrderAcceptable = $("input[name='itemOrderAcceptable\[" + i + "\]']").val(); | |
| 2521 | + zaikonum = $("input[name='zaikonum\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2522 | + | |
| 2523 | + quant = $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").val(); | |
| 2524 | + if( $("*[name='quant\[" + i + "\]\[" + post_id + "\]\[" + sku + "\]']").length ){ | |
| 2525 | + if( quant == '0' || quant == '' || !(uscesCart.isNum(quant))){ | |
| 2526 | + mes += <?php _e( "'enter the correct amount for the No.' + (i+1) + ' item'", 'usces' ); ?>+"\n"; | |
| 2527 | + } | |
| 2528 | + var checknum = ''; | |
| 2529 | + var checkmode = ''; | |
| 2530 | + if( parseInt(itemRestriction) <= parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2531 | + checknum = itemRestriction; | |
| 2532 | + checkmode ='rest'; | |
| 2533 | + } else if( itemOrderAcceptable != '1' && parseInt(itemRestriction) > parseInt(zaikonum) && itemRestriction != '' && itemRestriction != '0' && zaikonum != '' ) { | |
| 2534 | + checknum = zaikonum; | |
| 2535 | + checkmode ='zaiko'; | |
| 2536 | + } else if( itemOrderAcceptable != '1' && (itemRestriction == '' || itemRestriction == '0') && zaikonum != '' ) { | |
| 2537 | + checknum = zaikonum; | |
| 2538 | + checkmode ='zaiko'; | |
| 2539 | + } else if( itemRestriction != '' && itemRestriction != '0' && ( zaikonum == '' || zaikonum == '0' || parseInt(itemRestriction) > parseInt(zaikonum) ) ) { | |
| 2540 | + checknum = itemRestriction; | |
| 2541 | + checkmode ='rest'; | |
| 2542 | + } | |
| 2543 | + | |
| 2544 | + if( parseInt(quant) > parseInt(checknum) && checknum != '' ){ | |
| 2545 | + if(checkmode == 'rest'){ | |
| 2546 | + mes += <?php _e( "'This article is limited by '+checknum+' at a time for the No.' + (i+1) + ' item.'", 'usces' ); ?>+"\n"; | |
| 2547 | + }else{ | |
| 2548 | + mes += <?php _e( "'Stock of No.' + (i+1) + ' item is remainder '+checknum+'.'", 'usces' ); ?>+"\n"; | |
| 2549 | + } | |
| 2550 | + } | |
| 2551 | + } | |
| 2552 | + } | |
| 2553 | + | |
| 2554 | + <?php do_action( 'usces_action_nextCart_js_check', $item->ID ); ?> | |
| 2555 | + | |
| 2556 | + if( mes != '' ){ | |
| 2557 | + alert( mes ); | |
| 2558 | + return false; | |
| 2559 | + }else{ | |
| 2560 | + return true; | |
| 2561 | + } | |
| 2562 | + }, | |
| 2563 | + | |
| 2564 | + customerNext : function () { | |
| 2565 | + <?php do_action( 'usces_action_customerNext_js_check', $item->ID ); ?> | |
| 2566 | + }, | |
| 2567 | + | |
| 2568 | + customerPre : function () { | |
| 2569 | + <?php do_action( 'usces_action_customerPre_js_check', $item->ID ); ?> | |
| 2570 | + }, | |
| 2571 | + | |
| 2572 | + previousCart : function () { | |
| 2573 | + location.href = uscesL10n.previous_url; | |
| 2574 | + }, | |
| 2575 | + | |
| 2576 | + settings: { | |
| 2577 | + url: uscesL10n.ajaxurl, | |
| 2578 | + type: 'POST', | |
| 2579 | + cache: false | |
| 2580 | + }, | |
| 2581 | + | |
| 2582 | + changeStates : function( country ) { | |
| 2583 | + var s = this.settings; | |
| 2584 | + s.data = "action=change_states_ajax&country=" + country; | |
| 2585 | + $.ajax( s ).done(function(data, dataType){ | |
| 2586 | + | |
| 2587 | + if( 'error' == data ){ | |
| 2588 | + alert('error'); | |
| 2589 | + }else{ | |
| 2590 | + $("select#pref").html( data ); | |
| 2591 | + } | |
| 2592 | + }).fail(function(msg){ | |
| 2593 | + alert("error"); | |
| 2594 | + }); | |
| 2595 | + return false; | |
| 2596 | + }, | |
| 2597 | + | |
| 2598 | + isNum : function (num) { | |
| 2599 | + if (num.match(/[^0-9]/g)) { | |
| 2600 | + return false; | |
| 2601 | + } | |
| 2602 | + return true; | |
| 2603 | + }, | |
| 2604 | + purchase : 0 | |
| 2605 | + }; | |
| 2606 | + $("#country").change(function () { | |
| 2607 | + var country = $("#country option:selected").val(); | |
| 2608 | + $("#newcharging_type option:selected").val() | |
| 2609 | + uscesCart.changeStates( country ); | |
| 2610 | + }); | |
| 2611 | + $("#purchase_form").submit(function () { | |
| 2612 | + if( 0 == uscesCart.purchase ){ | |
| 2613 | + uscesCart.purchase = 1; | |
| 2614 | + return true; | |
| 2615 | + }else{ | |
| 2616 | + $("#purchase_button").prop("disabled", true); | |
| 2617 | + $("#back_button").prop("disabled", true); | |
| 2618 | + return false; | |
| 2619 | + } | |
| 2620 | + }); | |
| 2621 | + | |
| 2622 | + })(jQuery); | |
| 2623 | + </script> | |
| 2624 | + <?php | |
| 2625 | + } | |
| 2626 | + | |
| 2627 | + usces_states_form_js(); | |
| 2628 | + $js = apply_filters( 'usces_filter_shop_foot_js', ob_get_contents() ); | |
| 2629 | + ob_end_clean(); | |
| 2630 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2631 | + echo $js; | |
| 2632 | + } | |
| 2633 | + | |
| 2634 | + public function admin_head() { | |
| 2635 | + global $wp_version; | |
| 2636 | + $wcex_str = ''; | |
| 2637 | + $wcex = usces_get_wcex(); | |
| 2638 | + foreach ( (array) $wcex as $key => $values ) { | |
| 2639 | + $wcex_str .= "'" . esc_js( $key ) . '-' . esc_js( $values['version'] ) . "', "; | |
| 2640 | + } | |
| 2641 | + $wcex_str = rtrim( $wcex_str, ', ' ); | |
| 2642 | + $theme_ob = wp_get_theme(); | |
| 2643 | + if ( $theme_ob ) { | |
| 2644 | + $theme = array( | |
| 2645 | + 'Name' => esc_js( $theme_ob->get( 'Name' ) ), | |
| 2646 | + 'Version' => esc_js( $theme_ob->get( 'Version' ) ), | |
| 2647 | + ); | |
| 2648 | + } else { | |
| 2649 | + $theme = array( 'Name' => '', 'Version' => '' ); | |
| 2650 | + } | |
| 2651 | + $message = usces_get_admin_script_message(); | |
| 2652 | + ?> | |
| 2653 | + <link href="<?php echo USCES_PLUGIN_URL; ?>/css/admin_style.css" rel="stylesheet" type="text/css" media="all" /> | |
| 2654 | + <script type='text/javascript'> | |
| 2655 | + /* <![CDATA[ */ | |
| 2656 | + uscesL10n = { | |
| 2657 | + <?php echo apply_filters( 'usces_filter_admin_uscesL10n', null ); ?> | |
| 2658 | + 'requestFile': "<?php echo site_url(); ?>/wp-admin/admin-ajax.php", | |
| 2659 | + 'USCES_PLUGIN_URL': "<?php echo USCES_PLUGIN_URL; ?>", | |
| 2660 | + 'version': "<?php echo USCES_VERSION; ?>", | |
| 2661 | + 'locale': '<?php echo get_locale(); ?>', | |
| 2662 | + 'cart_number': "<?php echo get_option( 'usces_cart_number' ); ?>", | |
| 2663 | + 'purchase_limit': "<?php echo esc_js( $this->options['purchase_limit'] ); ?>", | |
| 2664 | + 'point_rate': "<?php echo esc_js( $this->options['point_rate'] ); ?>", | |
| 2665 | + 'shipping_rule': "<?php echo esc_js( $this->options['shipping_rule'] ); ?>", | |
| 2666 | + 'theme': "<?php echo esc_html( $theme['Name'] . '-' . $theme['Version'] ); ?>", | |
| 2667 | + 'wcex': new Array( <?php wel_esc_script_e( $wcex_str ); ?> ), | |
| 2668 | + 'message': new Array( <?php wel_esc_script_e( $message ); ?> ), | |
| 2669 | + 'now_loading': "<?php _e( 'now loading', 'usces' ); ?>" | |
| 2670 | + }; | |
| 2671 | + /* ]]> */ | |
| 2672 | + </script> | |
| 2673 | + <script type='text/javascript' src='<?php echo USCES_PLUGIN_URL; ?>/js/usces_admin.js?ver=<?php echo USCES_VERSION; ?>'></script> | |
| 2674 | + <?php | |
| 2675 | + if ( 'edit' == $this->action_status || 'editpost' == $this->action_status ) { | |
| 2676 | + ?> | |
| 2677 | + <link rel='stylesheet' href='<?php echo site_url(); ?>/wp-includes/js/thickbox/thickbox.css' type='text/css' media='all' /> | |
| 2678 | + <?php | |
| 2679 | + } | |
| 2680 | + if ( isset( $_REQUEST['page'] ) ) { | |
| 2681 | + switch ( $_REQUEST['page'] ) { | |
| 2682 | + case 'usces_initial': | |
| 2683 | + $cod_type = ( 'change' == $this->options['cod_type'] ) ? 'change' : 'fix'; | |
| 2684 | + ?> | |
| 2685 | + <script type='text/javascript'> | |
| 2686 | + /* <![CDATA[ */ | |
| 2687 | + usces_ini = { | |
| 2688 | + 'cod_type': "<?php echo esc_js( $cod_type ); ?>", | |
| 2689 | + 'cod_type_fix': "<?php echo esc_js( __( 'Fixation C.O.D.', 'usces' ) ); ?>", | |
| 2690 | + 'cod_type_change': "<?php echo esc_js( __( 'Variable C.O.D.', 'usces' ) ); ?>", | |
| 2691 | + 'cod_unit': "<?php echo esc_js( __( 'dollars', 'usces' ) ); ?>", | |
| 2692 | + 'cod_failure': "<?php echo esc_js( __( 'failure in update', 'usces' ) ); ?>", | |
| 2693 | + 'cod_updated': "<?php echo esc_js( __( 'options are updated', 'usces' ) ); ?>", | |
| 2694 | + 'cod_limit': "<?php echo esc_js( __( 'A value of the amount of upper limit is incorrect.', 'usces' ) ); ?>", | |
| 2695 | + 'cod_label_close': "<?php echo esc_js( __( 'Close', 'usces' ) ); ?>", | |
| 2696 | + 'cod_label_update': "<?php echo esc_js( __( 'Update', 'usces' ) ); ?>" | |
| 2697 | + }; | |
| 2698 | + /* ]]> */ | |
| 2699 | + </script> | |
| 2700 | + <?php | |
| 2701 | + break; | |
| 2702 | + case 'usces_itemnew': | |
| 2703 | + case 'usces_itemedit': | |
| 2704 | + ?> | |
| 2705 | + <style type="text/css"> | |
| 2706 | + <!-- | |
| 2707 | + #usces_mess { | |
| 2708 | + color: #FF0000; | |
| 2709 | + font-weight: bold; | |
| 2710 | + } | |
| 2711 | + --> | |
| 2712 | + </style> | |
| 2713 | + <?php | |
| 2714 | + break; | |
| 2715 | + } | |
| 2716 | + } | |
| 2717 | + | |
| 2718 | + if ( is_admin() && ( ( isset( $_GET['order_action'] ) && 'newpost' == $_GET['order_action'] ) | |
| 2719 | + || ( isset( $_GET['page'] ) && 'usces_ordernew' == $_GET['page'] ) | |
| 2720 | + || ( isset( $_GET['order_action'] ) && 'edit' == $_GET['order_action'] ) | |
| 2721 | + || ( isset( $_GET['order_action'] ) && 'editpost' == $_GET['order_action'] ) | |
| 2722 | + || ( isset( $_GET['page'] ) && 'usces_membernew' == $_GET['page'] ) | |
| 2723 | + || ( isset( $_GET['member_action'] ) && 'edit' == $_GET['member_action'] ) | |
| 2724 | + || ( isset( $_GET['member_action'] ) && 'editpost' == $_GET['member_action'] ) ) ) : | |
| 2725 | + switch ( $_GET['page'] ) { | |
| 2726 | + case 'usces_ordernew': | |
| 2727 | + case 'usces_orderlist': | |
| 2728 | + $admin_page = 'order'; | |
| 2729 | + break; | |
| 2730 | + case 'usces_membernew': | |
| 2731 | + case 'usces_memberlist': | |
| 2732 | + $admin_page = 'member'; | |
| 2733 | + break; | |
| 2734 | + } | |
| 2735 | + ?> | |
| 2736 | + <script type='text/javascript'> | |
| 2737 | + jQuery(function($) { | |
| 2738 | + uscesForm = { | |
| 2739 | + settings: { | |
| 2740 | + url: uscesL10n.requestFile, | |
| 2741 | + type: 'POST', | |
| 2742 | + cache: false | |
| 2743 | + }, | |
| 2744 | + | |
| 2745 | + changeStates : function( country, type ) { | |
| 2746 | + var s = this.settings; | |
| 2747 | + s.data = "action=change_states_ajax&country=" + country; | |
| 2748 | + $.ajax( s ).done(function(data, dataType){ | |
| 2749 | + if( 'error' == data ){ | |
| 2750 | + alert('error'); | |
| 2751 | + }else{ | |
| 2752 | + $("select#" + type + "_pref").html( data ); | |
| 2753 | + if( customercountry == country && 'customer' == type ){ | |
| 2754 | + $("#" + type + "_pref").prop({selectedIndex:customerstate}); | |
| 2755 | + }else if( deliverycountry == country && 'delivery' == type ){ | |
| 2756 | + $("#" + type + "_pref").prop({selectedIndex:deliverystate}); | |
| 2757 | + }else if( customercountry == country && 'member' == type ){ | |
| 2758 | + $("#" + type + "_pref").prop({selectedIndex:customerstate}); | |
| 2759 | + } | |
| 2760 | + } | |
| 2761 | + }).fail(function(msg){ | |
| 2762 | + alert("error"); | |
| 2763 | + }); | |
| 2764 | + return false; | |
| 2765 | + }, | |
| 2766 | + | |
| 2767 | + isNum : function (num) { | |
| 2768 | + if (num.match(/[^0-9]/g)) { | |
| 2769 | + return false; | |
| 2770 | + } | |
| 2771 | + return true; | |
| 2772 | + } | |
| 2773 | + }; | |
| 2774 | + <?php | |
| 2775 | + if ( 'order' == $admin_page ) { | |
| 2776 | + ?> | |
| 2777 | + if( undefined != $("#customer_pref").get(0) && undefined != $("#delivery_country").get(0) ) { | |
| 2778 | + var customerstate = $("#customer_pref").get(0).selectedIndex; | |
| 2779 | + var customercountry = $("#customer_country").val(); | |
| 2780 | + var deliverystate = $("#delivery_pref").get(0).selectedIndex; | |
| 2781 | + var deliverycountry = $("#delivery_country").val(); | |
| 2782 | + | |
| 2783 | + $("#customer_country").change(function () { | |
| 2784 | + var country = $("#customer_country option:selected").val(); | |
| 2785 | + uscesForm.changeStates( country, 'customer' ); | |
| 2786 | + }); | |
| 2787 | + $("#delivery_country").change(function () { | |
| 2788 | + var country = $("#delivery_country option:selected").val(); | |
| 2789 | + uscesForm.changeStates( country, 'delivery' ); | |
| 2790 | + }); | |
| 2791 | + } | |
| 2792 | + <?php | |
| 2793 | + } elseif ( 'member' == $admin_page ) { | |
| 2794 | + ?> | |
| 2795 | + if( undefined != $("#member_pref").get(0) ) { | |
| 2796 | + var customerstate = $("#member_pref").get(0).selectedIndex; | |
| 2797 | + var customercountry = $("#member_country").val(); | |
| 2798 | + var deliverystate = ''; | |
| 2799 | + var deliverycountry = ''; | |
| 2800 | + | |
| 2801 | + $("#member_country").change(function () { | |
| 2802 | + var country = $("#member_country option:selected").val(); | |
| 2803 | + uscesForm.changeStates( country, 'member' ); | |
| 2804 | + }); | |
| 2805 | + } | |
| 2806 | + <?php | |
| 2807 | + } | |
| 2808 | + ?> | |
| 2809 | + }); | |
| 2810 | + </script> | |
| 2811 | + <?php | |
| 2812 | + endif; | |
| 2813 | + } | |
| 2814 | + | |
| 2815 | + /** | |
| 2816 | + * Main Process. | |
| 2817 | + */ | |
| 2818 | + public function main() { | |
| 2819 | + global $wpdb, $wp_locale, $wp_version, $post_ID; | |
| 2820 | + global $wp_query, $usces_action, $post, $action, $editing; | |
| 2821 | + | |
| 2822 | + update_option( 'usces_shipping_rule', apply_filters( 'usces_filter_shipping_rule', get_option( 'usces_shipping_rule' ) ) ); | |
| 2823 | + $this->shipping_rule = get_option( 'usces_shipping_rule' ); | |
| 2824 | + | |
| 2825 | + if ( ! is_admin() ) { | |
| 2826 | + $this->usces_cookie(); | |
| 2827 | + } else { | |
| 2828 | + $this->user_level = usces_get_admin_user_level(); | |
| 2829 | + } | |
| 2830 | + $this->make_url(); | |
| 2831 | + | |
| 2832 | + add_filter( 'cron_schedules', 'usces_schedules_intervals' ); | |
| 2833 | + add_action( 'wp', 'usces_wevent' ); | |
| 2834 | + do_action( 'usces_main' ); | |
| 2835 | + $this->update_table(); | |
| 2836 | + | |
| 2837 | + require_once USCES_PLUGIN_DIR . '/classes/cart.class.php'; | |
| 2838 | + $this->cart = new usces_cart(); | |
| 2839 | + | |
| 2840 | + do_action( 'usces_after_cart_instant' ); | |
| 2841 | + | |
| 2842 | + if ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'duplicate' == $_REQUEST['action'] ) { | |
| 2843 | + $post_id = (int) $_GET['post']; | |
| 2844 | + $new_id = usces_item_duplicate( $post_id ); | |
| 2845 | + $ref = isset( $_REQUEST['usces_referer'] ) ? urlencode( esc_url( $_REQUEST['usces_referer'] ) ) : ''; | |
| 2846 | + $url = USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $new_id . '&usces_referer=' . $ref; | |
| 2847 | + wp_redirect( $url ); | |
| 2848 | + exit; | |
| 2849 | + } elseif ( isset( $_REQUEST['page'] ) && 'usces_itemedit' == $_REQUEST['page'] && isset( $_REQUEST['action'] ) && 'itemcsv' == $_REQUEST['action'] ) { | |
| 2850 | + // $filename = usces_item_uploadcsv(); | |
| 2851 | + // $mode = ( isset( $_REQUEST['upload_mode'] ) ) ? $_REQUEST['upload_mode'] : 'all'; | |
| 2852 | + // $url = USCES_ADMIN_URL . '?page=usces_itemedit&usces_status=none&usces_message=&action=upload_register&mode=' . $mode . '®file=' . $filename; | |
| 2853 | + // wp_redirect( $url ); | |
| 2854 | + // exit; | |
| 2855 | + } | |
| 2856 | + | |
| 2857 | + $this->ad_controller(); | |
| 2858 | + | |
| 2859 | + if ( isset( $_GET['page'] ) && 'usces_itemnew' == $_GET['page'] ) { | |
| 2860 | + $itemnew = 'new'; | |
| 2861 | + } else { | |
| 2862 | + $itemnew = ''; | |
| 2863 | + } | |
| 2864 | + | |
| 2865 | + wp_enqueue_script( 'jquery' ); | |
| 2866 | + | |
| 2867 | + if ( is_admin() && isset( $_REQUEST['page'] ) && ( ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) || 'new' == $itemnew || ( isset( $_REQUEST['action'] ) && 'editpost' == $_REQUEST['action'] ) ) ) { | |
| 2868 | + | |
| 2869 | + if ( isset( $_REQUEST['action'] ) && 'editpost' != $_REQUEST['action'] && 'new' == $itemnew ) { | |
| 2870 | + if ( version_compare( $wp_version, '3.0-beta', '>' ) ) { | |
| 2871 | + if ( ! isset( $_GET['post_type'] ) ) { | |
| 2872 | + $post_type = 'post'; | |
| 2873 | + } elseif ( in_array( $_GET['post_type'], get_post_types( array( 'public' => true ) ) ) ) { | |
| 2874 | + $post_type = $_GET['post_type']; | |
| 2875 | + } else { | |
| 2876 | + wp_die( __( 'Invalid post type' ) ); | |
| 2877 | + } | |
| 2878 | + $post_type_object = get_post_type_object( $post_type ); | |
| 2879 | + $editing = true; | |
| 2880 | + $post = $this->get_default_post_to_edit30( $post_type, true ); | |
| 2881 | + $post_ID = $post->ID; | |
| 2882 | + } else { | |
| 2883 | + $post = $this->get_default_post_to_edit(); | |
| 2884 | + } | |
| 2885 | + } else { | |
| 2886 | + if ( version_compare( $wp_version, '3.0-beta', '>' ) ) { | |
| 2887 | + if ( isset( $_GET['post'] ) ) { | |
| 2888 | + $post_id = (int) $_GET['post']; | |
| 2889 | + } elseif ( isset( $_POST['post_ID'] ) ) { | |
| 2890 | + $post_id = (int) $_POST['post_ID']; | |
| 2891 | + } else { | |
| 2892 | + $post_id = 0; | |
| 2893 | + } | |
| 2894 | + $post_ID = $post_id; | |
| 2895 | + $post = null; | |
| 2896 | + $post_type_object = null; | |
| 2897 | + $post_type = null; | |
| 2898 | + if ( $post_id ) { | |
| 2899 | + $product = wel_get_product( $post_id ); | |
| 2900 | + $post = $product['_pst']; | |
| 2901 | + if ( $post ) { | |
| 2902 | + $post_type_object = get_post_type_object( $post->post_type ); | |
| 2903 | + if ( $post_type_object ) { | |
| 2904 | + $post_type = $post->post_type; | |
| 2905 | + if ( ! isset( $current_screen ) ) { | |
| 2906 | + $current_screen = new stdClass(); | |
| 2907 | + } | |
| 2908 | + $current_screen->post_type = $post->post_type; | |
| 2909 | + $current_screen->id = $current_screen->post_type; | |
| 2910 | + } | |
| 2911 | + } | |
| 2912 | + } elseif ( isset( $_POST['post_type'] ) ) { | |
| 2913 | + $post_type_object = get_post_type_object( $_POST['post_type'] ); | |
| 2914 | + if ( $post_type_object ) { | |
| 2915 | + $post_type = $post_type_object->name; | |
| 2916 | + $current_screen->post_type = $post_type; | |
| 2917 | + $current_screen->id = $current_screen->post_type; | |
| 2918 | + } | |
| 2919 | + } | |
| 2920 | + } else { | |
| 2921 | + if ( isset( $_GET['post'] ) ) { | |
| 2922 | + $post_ID = (int) $_GET['post']; | |
| 2923 | + $product = wel_get_product( $post_ID ); | |
| 2924 | + $post = $product['_pst']; | |
| 2925 | + } else { | |
| 2926 | + $post_ID = isset( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0; | |
| 2927 | + if ( ! empty( $post_ID ) ) { | |
| 2928 | + $product = wel_get_product( $post_ID ); | |
| 2929 | + $post = $product['_pst']; | |
| 2930 | + } | |
| 2931 | + } | |
| 2932 | + } | |
| 2933 | + } | |
| 2934 | + | |
| 2935 | + $editing = true; | |
| 2936 | + wp_enqueue_script( 'autosave' ); | |
| 2937 | + wp_enqueue_script( 'post' ); | |
| 2938 | + add_thickbox(); | |
| 2939 | + wp_enqueue_script( 'media-upload' ); | |
| 2940 | + wp_enqueue_script( 'word-count' ); | |
| 2941 | + wp_enqueue_script( 'admin-comments' ); | |
| 2942 | + | |
| 2943 | + if ( version_compare( $wp_version, '3.3', '<' ) ) { | |
| 2944 | + add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); | |
| 2945 | + } | |
| 2946 | + wp_enqueue_script( 'quicktags' ); | |
| 2947 | + } | |
| 2948 | + | |
| 2949 | + if ( is_admin() && isset( $_REQUEST['page'] ) ) { | |
| 2950 | + | |
| 2951 | + wp_enqueue_script( 'jquery-color' ); | |
| 2952 | + | |
| 2953 | + switch ( $_REQUEST['page'] ) { | |
| 2954 | + case 'usces_initial': | |
| 2955 | + $js = USCES_FRONT_PLUGIN_URL . '/js/usces_initial.js'; | |
| 2956 | + wp_enqueue_script( 'usces_initial.js', $js, array( 'jquery-ui-dialog', 'jquery-ui-sortable' ) ); | |
| 2957 | + break; | |
| 2958 | + case 'usces_settlement': | |
| 2959 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 2960 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 2961 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 2962 | + $jquery_color_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/color/jscolor.js'; | |
| 2963 | + wp_enqueue_script( 'jquery-jscolor', $jquery_color_url, array( 'jquery-color' ) ); | |
| 2964 | + wp_enqueue_script( 'jquery-ui-sortable' ); | |
| 2965 | + wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 2966 | + break; | |
| 2967 | + case 'usces_cart': | |
| 2968 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 2969 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 2970 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 2971 | + break; | |
| 2972 | + case 'usces_member': | |
| 2973 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 2974 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 2975 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 2976 | + break; | |
| 2977 | + case 'usces_orderlist': | |
| 2978 | + case 'usces_ordernew': | |
| 2979 | + wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 2980 | + wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 2981 | + break; | |
| 2982 | + case 'usces_memberlist': | |
| 2983 | + wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 2984 | + break; | |
| 2985 | + case 'usces_itemnew': | |
| 2986 | + wp_enqueue_script( 'jquery-ui-sortable' ); | |
| 2987 | + break; | |
| 2988 | + case 'usces_itemedit': | |
| 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 | + if ( isset( $_REQUEST['action'] ) && 'upload_register' == $_REQUEST['action'] ) { | |
| 2992 | + // $upload_registerUrl = USCES_FRONT_PLUGIN_URL . '/js/usces-item-upload.js'; | |
| 2993 | + // wp_enqueue_script( 'upload_register', $upload_registerUrl, array( 'jquery' ), USCES_VERSION, true ); | |
| 2994 | + // @ob_end_clean(); | |
| 2995 | + // ob_start(); | |
| 2996 | + } else { | |
| 2997 | + wp_enqueue_script( 'jquery-ui-sortable' ); | |
| 2998 | + wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 2999 | + } | |
| 3000 | + break; | |
| 3001 | + case 'usces_delivery': | |
| 3002 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 3003 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 3004 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 3005 | + break; | |
| 3006 | + case 'usces_system': | |
| 3007 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 3008 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 3009 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 3010 | + break; | |
| 3011 | + case 'usces_mail': | |
| 3012 | + wp_enqueue_script( 'jquery-ui-tabs', array( 'jquery-ui-core' ) ); | |
| 3013 | + $jquery_cookie_url = USCES_FRONT_PLUGIN_URL . '/js/jquery/jquery-cookie.js'; | |
| 3014 | + wp_enqueue_script( 'jquery-cookie', $jquery_cookie_url, array( 'jquery' ) ); | |
| 3015 | + break; | |
| 3016 | + } | |
| 3017 | + } | |
| 3018 | + | |
| 3019 | + if ( isset( $_REQUEST['order_action'] ) && 'pdfout' == $_REQUEST['order_action'] ) { | |
| 3020 | + check_admin_referer( 'order_edit', 'wc_nonce' ); | |
| 3021 | + | |
| 3022 | + $oid = filter_input( INPUT_GET, 'order_id' ); | |
| 3023 | + if ( ! is_user_logged_in() ) { | |
| 3024 | + $this->get_current_member(); | |
| 3025 | + $mid = $this->current_member['id']; | |
| 3026 | + if ( 0 === (int) $mid || ! $this->is_order( $mid, $oid ) ) { | |
| 3027 | + die( 'No permission' ); | |
| 3028 | + } | |
| 3029 | + } | |
| 3030 | + if ( ( isset( $this->options['tax_display'] ) && 'activate' == $this->options['tax_display'] ) && usces_is_reduced_taxrate( $oid ) ) { | |
| 3031 | + require_once( apply_filters( 'usces_filter_orderpdf_path_ex', USCES_PLUGIN_DIR . '/includes/order_print_ex.php' ) ); | |
| 3032 | + } else { | |
| 3033 | + require_once( apply_filters( 'usces_filter_orderpdf_path', USCES_PLUGIN_DIR . '/includes/order_print.php' ) ); | |
| 3034 | + } | |
| 3035 | + } | |
| 3036 | + | |
| 3037 | + if ( ! empty( $this->settlement_notice ) && | |
| 3038 | + ( 1 === (int) $this->options['system']['settlement_notice'] || defined( 'WCEX_DLSELLER' ) || defined( 'WCEX_AUTO_DELIVERY' ) ) ) { | |
| 3039 | + add_action( 'admin_notices', 'usces_display_settlement_notice' ); | |
| 3040 | + } | |
| 3041 | + | |
| 3042 | + do_action( 'usces_after_main' ); | |
| 3043 | + } | |
| 3044 | + | |
| 3045 | + public function stripslashes_deep_post( $array ) { | |
| 3046 | + $res = array(); | |
| 3047 | + foreach ( $array as $key => $value ) { | |
| 3048 | + $key = stripslashes( $key ); | |
| 3049 | + if ( is_array( $value ) ) { | |
| 3050 | + $value = $this->stripslashes_deep_post( $value ); | |
| 3051 | + } else { | |
| 3052 | + $value = is_null( $value ) ? $value : usces_erase_emoji( stripslashes( $value ) ); | |
| 3053 | + } | |
| 3054 | + $res[ $key ] = $value; | |
| 3055 | + } | |
| 3056 | + return $res; | |
| 3057 | + } | |
| 3058 | + | |
| 3059 | + public function make_url() { | |
| 3060 | + $permalink_structure = get_option( 'permalink_structure' ); | |
| 3061 | + if ( $this->use_ssl ) { | |
| 3062 | + if ( $permalink_structure ) { | |
| 3063 | + $this->delim = '&'; | |
| 3064 | + $home_perse = parse_url( get_option( 'home' ) ); | |
| 3065 | + $home_perse_path = isset( $home_perse['path'] ) ? $home_perse['path'] : ''; | |
| 3066 | + $home_path = $home_perse['host'] . $home_perse_path; | |
| 3067 | + $ssl_perse = parse_url( $this->options['ssl_url'] ); | |
| 3068 | + $ssl_perse_path = isset( $ssl_perse['path'] ) ? $ssl_perse['path'] : ''; | |
| 3069 | + $ssl_path = $ssl_perse['host'] . $ssl_perse_path; | |
| 3070 | + if ( $home_perse_path != $ssl_perse_path ) { | |
| 3071 | + if ( ! defined( 'USCES_CUSTOMER_URL' ) ) { | |
| 3072 | + define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&customerinfo=1' ); | |
| 3073 | + } | |
| 3074 | + if ( ! defined( 'USCES_CART_URL' ) ) { | |
| 3075 | + define( 'USCES_CART_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER ); | |
| 3076 | + } | |
| 3077 | + if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) { | |
| 3078 | + define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=lostmemberpassword' ); | |
| 3079 | + } | |
| 3080 | + if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) { | |
| 3081 | + define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=newmember' ); | |
| 3082 | + } | |
| 3083 | + if ( ! defined( 'USCES_LOGIN_URL' ) ) { | |
| 3084 | + define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=login' ); | |
| 3085 | + } | |
| 3086 | + if ( ! defined( 'USCES_LOGOUT_URL' ) ) { | |
| 3087 | + define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' ); | |
| 3088 | + } | |
| 3089 | + if ( ! defined( 'USCES_MEMBER_URL' ) ) { | |
| 3090 | + define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_MEMBER_NUMBER ); | |
| 3091 | + } | |
| 3092 | + $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/index.php?page_id=' . $this->options['inquiry_id']; | |
| 3093 | + if ( ! defined( 'USCES_INQUIRY_URL' ) ) { | |
| 3094 | + define( 'USCES_INQUIRY_URL', $inquiry_url ); | |
| 3095 | + } | |
| 3096 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3097 | + define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER ); | |
| 3098 | + } | |
| 3099 | + if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) { | |
| 3100 | + define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/index.php?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn' ); | |
| 3101 | + } | |
| 3102 | + } else { | |
| 3103 | + $ssl_plink_cart = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_CART_NUMBER ) ) ); | |
| 3104 | + $ssl_plink_member = str_replace( 'http://','https://', str_replace( $home_path, $ssl_path, get_page_link( USCES_MEMBER_NUMBER ) ) ); | |
| 3105 | + if ( ! defined( 'USCES_CUSTOMER_URL' ) ) { | |
| 3106 | + define( 'USCES_CUSTOMER_URL', $ssl_plink_cart . '?customerinfo=1' ); | |
| 3107 | + } | |
| 3108 | + if ( ! defined( 'USCES_CART_URL' ) ) { | |
| 3109 | + define( 'USCES_CART_URL', $ssl_plink_cart ); | |
| 3110 | + } | |
| 3111 | + if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) { | |
| 3112 | + define( 'USCES_LOSTMEMBERPASSWORD_URL', $ssl_plink_member . '?usces_page=lostmemberpassword' ); | |
| 3113 | + } | |
| 3114 | + if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) { | |
| 3115 | + define( 'USCES_NEWMEMBER_URL', $ssl_plink_member . '?usces_page=newmember' ); | |
| 3116 | + } | |
| 3117 | + if ( ! defined( 'USCES_LOGIN_URL' ) ) { | |
| 3118 | + define( 'USCES_LOGIN_URL', $ssl_plink_member . '?usces_page=login' ); | |
| 3119 | + } | |
| 3120 | + if ( ! defined( 'USCES_LOGOUT_URL' ) ) { | |
| 3121 | + define( 'USCES_LOGOUT_URL', $ssl_plink_member . '?usces_page=logout' ); | |
| 3122 | + } | |
| 3123 | + if ( ! defined( 'USCES_MEMBER_URL' ) ) { | |
| 3124 | + define( 'USCES_MEMBER_URL', $ssl_plink_member ); | |
| 3125 | + } | |
| 3126 | + if ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) { | |
| 3127 | + $inquiry_url = get_home_url(); | |
| 3128 | + } else { | |
| 3129 | + $ssl_plink_inquiry = str_replace( 'http://', 'https://', str_replace( $home_path, $ssl_path, get_page_link( $this->options['inquiry_id'] ) ) ); | |
| 3130 | + $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $ssl_plink_inquiry; | |
| 3131 | + } | |
| 3132 | + if ( ! defined( 'USCES_INQUIRY_URL' ) ) { | |
| 3133 | + define( 'USCES_INQUIRY_URL', $inquiry_url ); | |
| 3134 | + } | |
| 3135 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3136 | + define( 'USCES_CART_NONSESSION_URL', $ssl_plink_cart ); | |
| 3137 | + } | |
| 3138 | + if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) { | |
| 3139 | + define( 'USCES_PAYPAL_NOTIFY_URL', $ssl_plink_cart . '?acting=paypal_ipn' ); | |
| 3140 | + } | |
| 3141 | + } | |
| 3142 | + } else { | |
| 3143 | + $this->delim = '&'; | |
| 3144 | + if ( ! defined( 'USCES_CUSTOMER_URL' ) ) { | |
| 3145 | + define( 'USCES_CUSTOMER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1' ); | |
| 3146 | + } | |
| 3147 | + if ( ! defined( 'USCES_CART_URL' ) ) { | |
| 3148 | + define( 'USCES_CART_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER ); | |
| 3149 | + } | |
| 3150 | + if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) { | |
| 3151 | + define( 'USCES_LOSTMEMBERPASSWORD_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=lostmemberpassword' ); | |
| 3152 | + } | |
| 3153 | + if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) { | |
| 3154 | + define( 'USCES_NEWMEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=newmember' ); | |
| 3155 | + } | |
| 3156 | + if ( ! defined( 'USCES_LOGIN_URL' ) ) { | |
| 3157 | + define( 'USCES_LOGIN_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=login' ); | |
| 3158 | + } | |
| 3159 | + if ( ! defined( 'USCES_LOGOUT_URL' ) ) { | |
| 3160 | + define( 'USCES_LOGOUT_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' ); | |
| 3161 | + } | |
| 3162 | + if ( ! defined( 'USCES_MEMBER_URL' ) ) { | |
| 3163 | + define( 'USCES_MEMBER_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_MEMBER_NUMBER ); | |
| 3164 | + } | |
| 3165 | + $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : $this->options['ssl_url'] . '/?page_id=' . $this->options['inquiry_id']; | |
| 3166 | + if ( ! defined( 'USCES_INQUIRY_URL' ) ) { | |
| 3167 | + define( 'USCES_INQUIRY_URL', $inquiry_url ); | |
| 3168 | + } | |
| 3169 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3170 | + define( 'USCES_CART_NONSESSION_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER ); | |
| 3171 | + } | |
| 3172 | + if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) { | |
| 3173 | + define( 'USCES_PAYPAL_NOTIFY_URL', $this->options['ssl_url'] . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn' ); | |
| 3174 | + } | |
| 3175 | + } | |
| 3176 | + if ( ! is_admin() ) { | |
| 3177 | + add_filter( 'home_url', array( $this, 'usces_ssl_page_link' ) ); | |
| 3178 | + add_filter( 'wp_get_attachment_url', array( $this, 'usces_ssl_attachment_link' ) ); | |
| 3179 | + add_filter( 'icon_dir_uri', array( $this, 'usces_ssl_icon_dir_uri' ) ); | |
| 3180 | + add_filter( 'stylesheet_directory_uri', array( $this, 'usces_ssl_contents_link' ) ); | |
| 3181 | + add_filter( 'template_directory_uri', array( $this, 'usces_ssl_contents_link' ) ); | |
| 3182 | + add_filter( 'script_loader_src', array( $this, 'usces_ssl_script_link' ) ); | |
| 3183 | + add_filter( 'style_loader_src', array( $this, 'usces_ssl_script_link' ) ); | |
| 3184 | + } | |
| 3185 | + } else { | |
| 3186 | + if ( $permalink_structure ) { | |
| 3187 | + $this->delim = '?'; | |
| 3188 | + if ( ! defined( 'USCES_CUSTOMER_URL' ) ) { | |
| 3189 | + define( 'USCES_CUSTOMER_URL', get_page_link( USCES_CART_NUMBER ) . '?customerinfo=1' ); | |
| 3190 | + } | |
| 3191 | + if ( ! defined( 'USCES_CART_URL' ) ) { | |
| 3192 | + define( 'USCES_CART_URL', get_page_link( USCES_CART_NUMBER ) ); | |
| 3193 | + } | |
| 3194 | + if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) { | |
| 3195 | + define( 'USCES_LOSTMEMBERPASSWORD_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=lostmemberpassword' ); | |
| 3196 | + } | |
| 3197 | + if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) { | |
| 3198 | + define( 'USCES_NEWMEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=newmember' ); | |
| 3199 | + } | |
| 3200 | + if ( ! defined( 'USCES_LOGIN_URL' ) ) { | |
| 3201 | + define( 'USCES_LOGIN_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=login' ); | |
| 3202 | + } | |
| 3203 | + if ( ! defined( 'USCES_LOGOUT_URL' ) ) { | |
| 3204 | + define( 'USCES_LOGOUT_URL', get_page_link( USCES_MEMBER_NUMBER ) . '?usces_page=logout' ); | |
| 3205 | + } | |
| 3206 | + if ( ! defined( 'USCES_MEMBER_URL' ) ) { | |
| 3207 | + define( 'USCES_MEMBER_URL', get_page_link( USCES_MEMBER_NUMBER ) ); | |
| 3208 | + } | |
| 3209 | + $inquiry_url = ( ! isset( $this->options['inquiry_id'] ) || ! ( (int) $this->options['inquiry_id'] ) ) ? get_home_url() : get_page_link( $this->options['inquiry_id'] ); | |
| 3210 | + if ( ! defined( 'USCES_INQUIRY_URL' ) ) { | |
| 3211 | + define( 'USCES_INQUIRY_URL', $inquiry_url ); | |
| 3212 | + } | |
| 3213 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3214 | + define( 'USCES_CART_NONSESSION_URL', get_page_link( USCES_CART_NUMBER ) ); | |
| 3215 | + } | |
| 3216 | + if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) { | |
| 3217 | + define( 'USCES_PAYPAL_NOTIFY_URL', get_page_link( USCES_CART_NUMBER ) . '?acting=paypal_ipn' ); | |
| 3218 | + } | |
| 3219 | + } else { | |
| 3220 | + $this->delim = '&'; | |
| 3221 | + if ( ! defined( 'USCES_CUSTOMER_URL' ) ) { | |
| 3222 | + define( 'USCES_CUSTOMER_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&customerinfo=1' ); | |
| 3223 | + } | |
| 3224 | + if ( ! defined( 'USCES_CART_URL' ) ) { | |
| 3225 | + define( 'USCES_CART_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER ); | |
| 3226 | + } | |
| 3227 | + if ( ! defined( 'USCES_LOSTMEMBERPASSWORD_URL' ) ) { | |
| 3228 | + define( 'USCES_LOSTMEMBERPASSWORD_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=lostmemberpassword' ); | |
| 3229 | + } | |
| 3230 | + if ( ! defined( 'USCES_NEWMEMBER_URL' ) ) { | |
| 3231 | + define( 'USCES_NEWMEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=newmember' ); | |
| 3232 | + } | |
| 3233 | + if ( ! defined( 'USCES_LOGIN_URL' ) ) { | |
| 3234 | + define( 'USCES_LOGIN_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=login' ); | |
| 3235 | + } | |
| 3236 | + if ( ! defined( 'USCES_LOGOUT_URL' ) ) { | |
| 3237 | + define( 'USCES_LOGOUT_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' ); | |
| 3238 | + } | |
| 3239 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3240 | + define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER . '&usces_page=logout' ); | |
| 3241 | + } | |
| 3242 | + if ( ! defined( 'USCES_MEMBER_URL' ) ) { | |
| 3243 | + define( 'USCES_MEMBER_URL', get_option( 'home' ) . '/?page_id=' . USCES_MEMBER_NUMBER ); | |
| 3244 | + } | |
| 3245 | + $inquiry_url = empty( $this->options['inquiry_id'] ) ? '' : get_option( 'home' ) . '/?page_id=' . $this->options['inquiry_id']; | |
| 3246 | + if ( ! defined( 'USCES_INQUIRY_URL' ) ) { | |
| 3247 | + define( 'USCES_INQUIRY_URL', $inquiry_url ); | |
| 3248 | + } | |
| 3249 | + if ( ! defined( 'USCES_CART_NONSESSION_URL' ) ) { | |
| 3250 | + define( 'USCES_CART_NONSESSION_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER ); | |
| 3251 | + } | |
| 3252 | + if ( ! defined( 'USCES_PAYPAL_NOTIFY_URL' ) ) { | |
| 3253 | + define( 'USCES_PAYPAL_NOTIFY_URL', get_option( 'home' ) . '/?page_id=' . USCES_CART_NUMBER . '&acting=paypal_ipn' ); | |
| 3254 | + } | |
| 3255 | + } | |
| 3256 | + } | |
| 3257 | + } | |
| 3258 | + | |
| 3259 | + public function regist_action() { | |
| 3260 | + usces_register_action( 'inCart', 'post', 'inCart', null, 'inCart' ); | |
| 3261 | + usces_register_action( 'upButton', 'post', 'upButton', null, 'upButton' ); | |
| 3262 | + usces_register_action( 'delButton', 'post', 'delButton', null, 'delButton' ); | |
| 3263 | + usces_register_action( 'backCart', 'post', 'backCart', null, 'backCart' ); | |
| 3264 | + usces_register_action( 'customerinfo', 'request', 'customerinfo', null, 'customerinfo' ); | |
| 3265 | + usces_register_action( 'backCustomer', 'post', 'backCustomer', null, 'backCustomer' ); | |
| 3266 | + usces_register_action( 'customerlogin', 'post', 'customerlogin', null, 'customerlogin' ); | |
| 3267 | + usces_register_action( 'reganddeliveryinfo', 'post', 'reganddeliveryinfo', null, 'reganddeliveryinfo' ); | |
| 3268 | + usces_register_action( 'deliveryinfo', 'post', 'deliveryinfo', null, 'deliveryinfo' ); | |
| 3269 | + usces_register_action( 'backDelivery', 'request', 'backDelivery', null, 'backDelivery' ); | |
| 3270 | + usces_register_action( 'confirm', 'request', 'confirm', null, 'confirm' ); | |
| 3271 | + usces_register_action( 'use_point', 'post', 'use_point', null, 'use_point' ); | |
| 3272 | + usces_register_action( 'backConfirm', 'post', 'backConfirm', null, 'backConfirm' ); | |
| 3273 | + usces_register_action( 'purchase', 'request', 'purchase', null, 'purchase' ); | |
| 3274 | + usces_register_action( 'acting_return', 'request', 'acting_return', null, 'acting_return' ); | |
| 3275 | + usces_register_action( 'settlement_epsilon', 'request', 'settlement', 'epsilon', 'settlement_epsilon' ); | |
| 3276 | + usces_register_action( 'inquiry_button', 'post', 'inquiry_button', null, 'inquiry_button' ); | |
| 3277 | + usces_register_action( 'member_login', 'request', 'member_login', null, 'member_login_page' ); | |
| 3278 | + usces_register_action( 'regmember', 'request', 'regmember', null, 'regmember' ); | |
| 3279 | + usces_register_action( 'editmember', 'request', 'editmember', null, 'editmember' ); | |
| 3280 | + usces_register_action( 'deletemember', 'request', 'deletemember', null, 'deletemember' ); | |
| 3281 | + usces_register_action( 'page_login', 'get', 'usces_page', 'login', 'member_login_page' ); | |
| 3282 | + usces_register_action( 'page_logout', 'get', 'usces_page', 'logout', 'page_logout' ); | |
| 3283 | + usces_register_action( 'page_lostmemberpassword', 'get', 'usces_page', 'lostmemberpassword', 'page_lostmemberpassword' ); | |
| 3284 | + usces_register_action( 'lostpassword', 'request', 'lostpassword', null, 'lostpassword' ); | |
| 3285 | + usces_register_action( 'uscesmode_changepassword', 'request', 'uscesmode', 'changepassword', 'uscesmode_changepassword' ); | |
| 3286 | + usces_register_action( 'changepassword', 'request', 'changepassword', null, 'changepassword_page' ); | |
| 3287 | + usces_register_action( 'page_newmember', 'get', 'usces_page', 'newmember', 'page_newmember' ); | |
| 3288 | + usces_register_action( 'page_search_item', 'get', 'usces_page', 'search_item', 'page_search_item' ); | |
| 3289 | + usces_register_action( 'front_ajax', 'post', 'usces_ajax_action', null, 'front_ajax' ); | |
| 3290 | + } | |
| 3291 | + | |
| 3292 | + public function ad_controller() { | |
| 3293 | + global $usces_action; | |
| 3294 | + ksort( $usces_action ); | |
| 3295 | + if ( $this->is_maintenance() && ! is_user_logged_in() ) { | |
| 3296 | + $this->maintenance(); | |
| 3297 | + } else { | |
| 3298 | + $action_array = array( | |
| 3299 | + 'inCart', 'upButton', 'delButton', 'backCart', 'customerinfo', 'backCustomer', | |
| 3300 | + 'customerlogin', 'reganddeliveryinfo', 'deliveryinfo', 'backDelivery', 'confirm', 'use_point', | |
| 3301 | + 'backConfirm', 'purchase', 'acting_return', 'settlement_epsilon', 'inquiry_button', 'member_login', | |
| 3302 | + 'regmember', 'editmember', 'deletemember', 'page_login', 'page_logout', 'page_lostmemberpassword', 'lostpassword', | |
| 3303 | + 'uscesmode_changepassword', 'changepassword', 'page_newmember', | |
| 3304 | + 'page_search_item', 'front_ajax', | |
| 3305 | + ); | |
| 3306 | + | |
| 3307 | + $action_array = apply_filters( 'usces_filter_action_array', $action_array ); | |
| 3308 | + | |
| 3309 | + $flg = 0; | |
| 3310 | + $res = true; | |
| 3311 | + foreach ( $usces_action as $handle => $action ) { | |
| 3312 | + extract( $action ); | |
| 3313 | + switch ( $type ) { | |
| 3314 | + case 'post': | |
| 3315 | + if ( empty( $value ) ) { | |
| 3316 | + if ( isset( $_POST[ $key ] ) ) { | |
| 3317 | + if ( in_array( $handle, $action_array ) ) { | |
| 3318 | + $res = call_user_func( array( $this, $function ) ); | |
| 3319 | + } else { | |
| 3320 | + $res = call_user_func( $function ); | |
| 3321 | + } | |
| 3322 | + $flg = 1; | |
| 3323 | + } | |
| 3324 | + } else { | |
| 3325 | + if ( isset( $_POST[ $key ] ) && $_POST[ $key ] == $value ) { | |
| 3326 | + if ( in_array( $handle, $action_array ) ) { | |
| 3327 | + $res = call_user_func( array( $this, $function ) ); | |
| 3328 | + } else { | |
| 3329 | + $res = call_user_func( $function ); | |
| 3330 | + } | |
| 3331 | + $flg = 1; | |
| 3332 | + } | |
| 3333 | + } | |
| 3334 | + break; | |
| 3335 | + case 'get': | |
| 3336 | + if ( empty( $value ) ) { | |
| 3337 | + if ( isset( $_GET[ $key ] ) ) { | |
| 3338 | + if ( in_array( $handle, $action_array ) ) { | |
| 3339 | + $res = call_user_func( array( $this, $function ) ); | |
| 3340 | + } else { | |
| 3341 | + $res = call_user_func( $function ); | |
| 3342 | + } | |
| 3343 | + $flg = 1; | |
| 3344 | + } | |
| 3345 | + } else { | |
| 3346 | + if ( isset( $_GET[ $key ] ) && $_GET[ $key ] == $value ) { | |
| 3347 | + if ( in_array( $handle, $action_array ) ) { | |
| 3348 | + $res = call_user_func( array( $this, $function ) ); | |
| 3349 | + } else { | |
| 3350 | + $res = call_user_func( $function ); | |
| 3351 | + } | |
| 3352 | + $flg = 1; | |
| 3353 | + } | |
| 3354 | + } | |
| 3355 | + break; | |
| 3356 | + case 'request': | |
| 3357 | + if ( empty( $value ) ) { | |
| 3358 | + if ( isset( $_REQUEST[ $key ] ) ) { | |
| 3359 | + if ( in_array( $handle, $action_array ) ) { | |
| 3360 | + $res = call_user_func( array( $this, $function ) ); | |
| 3361 | + } else { | |
| 3362 | + $res = call_user_func( $function ); | |
| 3363 | + } | |
| 3364 | + $flg = 1; | |
| 3365 | + } | |
| 3366 | + } else { | |
| 3367 | + if ( isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] == $value ) { | |
| 3368 | + if ( in_array( $handle, $action_array ) ) { | |
| 3369 | + $res = call_user_func( array( $this, $function ) ); | |
| 3370 | + } else { | |
| 3371 | + $res = call_user_func( $function ); | |
| 3372 | + } | |
| 3373 | + $flg = 1; | |
| 3374 | + } | |
| 3375 | + } | |
| 3376 | + break; | |
| 3377 | + } | |
| 3378 | + if ( ! $res ) { | |
| 3379 | + break; | |
| 3380 | + } | |
| 3381 | + } | |
| 3382 | + if ( ! $flg ) { | |
| 3383 | + $this->default_page(); | |
| 3384 | + } | |
| 3385 | + } | |
| 3386 | + } | |
| 3387 | + | |
| 3388 | + /** | |
| 3389 | + * Action function. | |
| 3390 | + */ | |
| 3391 | + public function front_ajax() { | |
| 3392 | + switch ( $_POST['usces_ajax_action'] ) { | |
| 3393 | + case 'change_states': | |
| 3394 | + change_states_ajax(); | |
| 3395 | + break; | |
| 3396 | + } | |
| 3397 | + do_action( 'usces_front_ajax' ); | |
| 3398 | + } | |
| 3399 | + | |
| 3400 | + public function maintenance() { | |
| 3401 | + $this->page = 'maintenance'; | |
| 3402 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3403 | + } | |
| 3404 | + | |
| 3405 | + public function inCart() { | |
| 3406 | + global $wp_query; | |
| 3407 | + $this->page = 'cart'; | |
| 3408 | + $this->incart_check(); | |
| 3409 | + $this->cart->inCart(); | |
| 3410 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3411 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3412 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3413 | + } | |
| 3414 | + | |
| 3415 | + public function upButton() { | |
| 3416 | + global $wp_query; | |
| 3417 | + $this->page = 'cart'; | |
| 3418 | + $this->error_message = $this->cart->upCart(); | |
| 3419 | + if ( empty( $this->error_message ) ) { | |
| 3420 | + $this->error_message = $this->zaiko_check(); | |
| 3421 | + } | |
| 3422 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3423 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3424 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3425 | + } | |
| 3426 | + | |
| 3427 | + public function delButton() { | |
| 3428 | + global $wp_query; | |
| 3429 | + $this->page = 'cart'; | |
| 3430 | + $this->cart->del_row(); | |
| 3431 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3432 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3433 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3434 | + } | |
| 3435 | + | |
| 3436 | + public function backCart() { | |
| 3437 | + global $wp_query; | |
| 3438 | + $this->page = 'cart'; | |
| 3439 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3440 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3441 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3442 | + } | |
| 3443 | + | |
| 3444 | + public function customerinfo() { | |
| 3445 | + global $wp_query; | |
| 3446 | + if ( false === $this->cart->num_row() ) { | |
| 3447 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3448 | + exit; | |
| 3449 | + } | |
| 3450 | + do_action( 'usces_action_customerinfo' ); | |
| 3451 | + $this->cart->entry(); | |
| 3452 | + $this->error_message = $this->zaiko_check(); | |
| 3453 | + $this->error_message = apply_filters( 'usces_filter_cart_check', $this->error_message ); | |
| 3454 | + if ( WCUtils::is_blank( $this->error_message ) ) { | |
| 3455 | + if ( $this->is_member_logged_in() ) { | |
| 3456 | + $this->error_message = has_custom_customer_field_essential(); | |
| 3457 | + $this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'delivery' : 'customer'; | |
| 3458 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3459 | + } else { | |
| 3460 | + $this->page = 'customer'; | |
| 3461 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3462 | + } | |
| 3463 | + } else { | |
| 3464 | + $this->page = 'cart'; | |
| 3465 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3466 | + } | |
| 3467 | + if ( ! $this->cart->is_order_condition() ) { | |
| 3468 | + $order_conditions = $this->get_condition(); | |
| 3469 | + $this->cart->set_order_condition( $order_conditions ); | |
| 3470 | + } | |
| 3471 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3472 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3473 | + } | |
| 3474 | + | |
| 3475 | + public function backCustomer() { | |
| 3476 | + global $wp_query; | |
| 3477 | + if ( false === $this->cart->num_row() ) { | |
| 3478 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3479 | + exit; | |
| 3480 | + } | |
| 3481 | + $this->page = apply_filters( 'usces_filter_backCustomer_page', 'customer' ); | |
| 3482 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3483 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3484 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3485 | + } | |
| 3486 | + | |
| 3487 | + public function customerlogin() { | |
| 3488 | + global $wp_query; | |
| 3489 | + if ( false === $this->cart->num_row() ) { | |
| 3490 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3491 | + exit; | |
| 3492 | + } | |
| 3493 | + if ( 'member' == $this->member_login() ) { | |
| 3494 | + do_action( 'usces_action_member_customer_logined' ); | |
| 3495 | + $this->cart->entry(); | |
| 3496 | + // $this->error_message = has_custom_customer_field_essential(); | |
| 3497 | + if ( WCUtils::is_blank( $this->error_message ) ) { | |
| 3498 | + $this->page = 'delivery'; | |
| 3499 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3500 | + } else { | |
| 3501 | + $this->page = 'customer'; | |
| 3502 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3503 | + } | |
| 3504 | + } else { | |
| 3505 | + $this->cart->entry(); | |
| 3506 | + $this->page = 'customer'; | |
| 3507 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3508 | + } | |
| 3509 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3510 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3511 | + } | |
| 3512 | + | |
| 3513 | + public function reganddeliveryinfo() { | |
| 3514 | + global $wp_query; | |
| 3515 | + if ( false === $this->cart->num_row() ) { | |
| 3516 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3517 | + exit; | |
| 3518 | + } | |
| 3519 | + | |
| 3520 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3521 | + if ( ! $this->verify_member_nonce( $nonce, 'post_member' ) && ! $this->is_member_logged_in() ) { | |
| 3522 | + die( 'Security check2' ); | |
| 3523 | + } | |
| 3524 | + $check_verify_recaptcha = $this->verifyGoogleRecapcha(); | |
| 3525 | + if ( $check_verify_recaptcha ) { | |
| 3526 | + $this->cart->entry(); | |
| 3527 | + if ( empty( $_POST['member_regmode'] ) || 'editmemberfromcart' != $_POST['member_regmode'] ) { | |
| 3528 | + $_POST['member_regmode'] = 'newmemberfromcart'; | |
| 3529 | + } | |
| 3530 | + $res = $this->regist_member(); | |
| 3531 | + } else { | |
| 3532 | + // return back page register and show message. | |
| 3533 | + $this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'reganddeliveryinfo' ); | |
| 3534 | + $res = trim( $_POST['member_regmode'] ); | |
| 3535 | + } | |
| 3536 | + | |
| 3537 | + if ( 'newcompletion' == $res ) { | |
| 3538 | + $this->page = 'delivery'; | |
| 3539 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3540 | + } elseif ( 'cartverifying' == $res ) { | |
| 3541 | + $this->page = 'cartverifying'; | |
| 3542 | + } else { | |
| 3543 | + $this->page = 'customer'; | |
| 3544 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3545 | + } | |
| 3546 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3547 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3548 | + } | |
| 3549 | + | |
| 3550 | + public function deliveryinfo() { | |
| 3551 | + global $wp_query; | |
| 3552 | + if ( false === $this->cart->num_row() ) { | |
| 3553 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3554 | + exit; | |
| 3555 | + } | |
| 3556 | + $check_verify_recaptcha = $this->verifyGoogleRecapcha(); | |
| 3557 | + if ( $check_verify_recaptcha ) { | |
| 3558 | + // continue process. | |
| 3559 | + $this->cart->entry(); | |
| 3560 | + $this->error_message = $this->customer_check(); | |
| 3561 | + } else { | |
| 3562 | + // return back page register and show message. | |
| 3563 | + $this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'deliveryinfo' ); | |
| 3564 | + } | |
| 3565 | + | |
| 3566 | + if ( WCUtils::is_blank( $this->error_message ) ) { | |
| 3567 | + $this->page = 'delivery'; | |
| 3568 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3569 | + } else { | |
| 3570 | + $this->page = 'customer'; | |
| 3571 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_customer' ); | |
| 3572 | + } | |
| 3573 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3574 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3575 | + } | |
| 3576 | + | |
| 3577 | + public function backDelivery() { | |
| 3578 | + global $wp_query; | |
| 3579 | + if ( false === $this->cart->num_row() ) { | |
| 3580 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3581 | + exit; | |
| 3582 | + } | |
| 3583 | + $this->page = 'delivery'; | |
| 3584 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3585 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3586 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3587 | + } | |
| 3588 | + | |
| 3589 | + public function confirm() { | |
| 3590 | + global $wpdb, $wp_query; | |
| 3591 | + if ( false === $this->cart->num_row() ) { | |
| 3592 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3593 | + exit; | |
| 3594 | + } | |
| 3595 | + | |
| 3596 | + $check_verify_recaptcha = $this->verifyGoogleRecapcha(); | |
| 3597 | + if ( $check_verify_recaptcha ) { | |
| 3598 | + // continue process. | |
| 3599 | + $this->cart->entry(); | |
| 3600 | + $this->error_message = $this->zaiko_check(); | |
| 3601 | + } else { | |
| 3602 | + // return back page register and show message. | |
| 3603 | + $this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Could not send successfully. Please try again.', 'usces' ), 'confirm' ); | |
| 3604 | + } | |
| 3605 | + | |
| 3606 | + if ( '' != $this->error_message ) { | |
| 3607 | + $this->page = 'cart'; | |
| 3608 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3609 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3610 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3611 | + return; | |
| 3612 | + } | |
| 3613 | +/* | |
| 3614 | + $referrer = wp_get_referer(); | |
| 3615 | + $site_url = parse_url( home_url(), PHP_URL_HOST ); | |
| 3616 | + $referrer_host = parse_url( $referrer, PHP_URL_HOST ); | |
| 3617 | + if ( false === $referrer || $referrer_host !== $site_url ) { | |
| 3618 | + $this->page = 'cart'; | |
| 3619 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3620 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3621 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3622 | + return; | |
| 3623 | + } | |
| 3624 | +*/ | |
| 3625 | + $this->set_reserve_pre_order_id(); | |
| 3626 | + if ( isset( $_POST['confirm'] ) ) { | |
| 3627 | + $this->error_message = $this->delivery_check(); | |
| 3628 | + } | |
| 3629 | + $this->page = ( WCUtils::is_blank( $this->error_message ) ) ? 'confirm' : 'delivery'; | |
| 3630 | + if ( WCUtils::is_blank( $this->error_message ) ) { | |
| 3631 | + if ( usces_is_member_system() && usces_is_member_system_point() && $this->is_member_logged_in() ) { | |
| 3632 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 3633 | + $query = $wpdb->prepare( "SELECT mem_point FROM $member_table WHERE ID = %d", $_SESSION['usces_member']['ID'] ); | |
| 3634 | + $mem_point = $wpdb->get_var( $query ); | |
| 3635 | + $_SESSION['usces_member']['point'] = $mem_point; | |
| 3636 | + } | |
| 3637 | + $this->page = 'confirm'; | |
| 3638 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' ); | |
| 3639 | + } else { | |
| 3640 | + $this->page = apply_filters( 'usces_filter_delivery_check_error_page', 'delivery', $this->error_message ); | |
| 3641 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_delivery' ); | |
| 3642 | + } | |
| 3643 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3644 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3645 | + } | |
| 3646 | + | |
| 3647 | + public function use_point() { | |
| 3648 | + global $wp_query, $usces; | |
| 3649 | + if ( ! isset( $_REQUEST['wc_nonce'] ) || ! $usces->verify_member_nonce( $_REQUEST['wc_nonce'], 'use_point' ) ) { | |
| 3650 | + die( 'Security check1' ); | |
| 3651 | + } | |
| 3652 | + | |
| 3653 | + $this->error_message = $this->point_check( $this->cart->get_entry() ); | |
| 3654 | + if ( empty( $this->error_message ) ) { | |
| 3655 | + $this->cart->entry(); | |
| 3656 | + } | |
| 3657 | + $this->page = 'confirm'; | |
| 3658 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' ); | |
| 3659 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3660 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3661 | + } | |
| 3662 | + | |
| 3663 | + public function backConfirm() { | |
| 3664 | + global $wp_query; | |
| 3665 | + if ( false === $this->cart->num_row() ) { | |
| 3666 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3667 | + exit; | |
| 3668 | + } | |
| 3669 | + $this->page = 'confirm'; | |
| 3670 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_confirm' ); | |
| 3671 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3672 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3673 | + } | |
| 3674 | + | |
| 3675 | + /** | |
| 3676 | + * Purchase | |
| 3677 | + */ | |
| 3678 | + public function purchase() { | |
| 3679 | + global $wp_query; | |
| 3680 | + do_action( 'usces_pre_purchase' ); | |
| 3681 | + if ( false === $this->cart->num_row() ) { | |
| 3682 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3683 | + exit; | |
| 3684 | + } | |
| 3685 | + | |
| 3686 | + if ( isset( $_POST['wc_purchase_nonce'] ) ) { | |
| 3687 | + if ( ! wp_verify_nonce( $_POST['wc_purchase_nonce'], 'wc_purchase_nonce' ) ) { | |
| 3688 | + $this->error_message = __( 'Security check failed. Please try again.', 'usces' ); | |
| 3689 | + $this->page = 'confirm'; | |
| 3690 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3691 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3692 | + return; | |
| 3693 | + } | |
| 3694 | + } | |
| 3695 | + | |
| 3696 | + if ( ! apply_filters( 'usces_purchase_check', true ) ) { | |
| 3697 | + return; | |
| 3698 | + } | |
| 3699 | + | |
| 3700 | + do_action( 'usces_purchase_validate' ); | |
| 3701 | + | |
| 3702 | + $entry = $this->cart->get_entry(); | |
| 3703 | + $this->error_message = $this->zaiko_check(); | |
| 3704 | + if ( WCUtils::is_blank( $this->error_message ) && 0 < $this->cart->num_row() ) { | |
| 3705 | + $acting_status = ''; | |
| 3706 | + $payments = $this->getPayments( $entry['order']['payment_name'] ); | |
| 3707 | + if ( null === $payments['id'] && 0 < $entry['order']['total_full_price'] ) { | |
| 3708 | + header( 'HTTP/1.0 400 Bad request' ); | |
| 3709 | + die(); | |
| 3710 | + } | |
| 3711 | + $payment_settlement = $payments['settlement'] ?? ''; | |
| 3712 | + if ( substr( $payment_settlement, 0, 6 ) == 'acting' && $entry['order']['total_full_price'] > 0 ) { | |
| 3713 | + $acting_flg = ( 'acting' == $payment_settlement ) ? $payments['module'] : $payment_settlement; | |
| 3714 | + unset( $_POST['purchase'] ); | |
| 3715 | + $post_query = '&' . http_build_query( $_POST ); | |
| 3716 | + $acting_status = $this->acting_processing( $acting_flg, $post_query, $acting_status ); | |
| 3717 | + } | |
| 3718 | + | |
| 3719 | + if ( 'error' == $acting_status ) { | |
| 3720 | + $this->page = 'error'; | |
| 3721 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' ); | |
| 3722 | + } else { | |
| 3723 | + $res = $this->order_processing(); | |
| 3724 | + if ( 'ordercompletion' == $res ) { | |
| 3725 | + $this->page = 'ordercompletion'; | |
| 3726 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' ); | |
| 3727 | + } else { | |
| 3728 | + $this->page = 'error'; | |
| 3729 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' ); | |
| 3730 | + } | |
| 3731 | + } | |
| 3732 | + } else { | |
| 3733 | + $this->page = 'cart'; | |
| 3734 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_cart' ); | |
| 3735 | + if ( ! $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 3736 | + wp_redirect( USCES_CART_URL ); | |
| 3737 | + exit; | |
| 3738 | + } | |
| 3739 | + } | |
| 3740 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3741 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3742 | + } | |
| 3743 | + | |
| 3744 | + public function acting_return() { | |
| 3745 | + global $wp_query; | |
| 3746 | + | |
| 3747 | + do_action( 'usces_pre_acting_return' ); | |
| 3748 | + | |
| 3749 | + $entry = $this->cart->get_entry(); | |
| 3750 | + if ( isset( $_GET['acting'] ) && 'anotherlane_card' != $_GET['acting'] ) { | |
| 3751 | + if ( false === $this->cart->num_row() && ( 'paypal' != $_GET['acting'] && 1 !== (int) $_GET['acting_return'] ) ) { | |
| 3752 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3753 | + exit; | |
| 3754 | + } | |
| 3755 | + } | |
| 3756 | + | |
| 3757 | + $this->payment_results = usces_check_acting_return(); | |
| 3758 | + | |
| 3759 | + if ( isset( $this->payment_results[0] ) && 'duplicate' === $this->payment_results[0] ) { | |
| 3760 | + | |
| 3761 | + header( 'location: ' . get_option( 'home' ) ); | |
| 3762 | + exit; | |
| 3763 | + | |
| 3764 | + } elseif ( isset( $this->payment_results[0] ) && $this->payment_results[0] ) { // result OK. | |
| 3765 | + | |
| 3766 | + if ( ! $this->payment_results['reg_order'] ) { // without Registration Order. | |
| 3767 | + $this->page = 'ordercompletion'; | |
| 3768 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' ); | |
| 3769 | + | |
| 3770 | + } else { | |
| 3771 | + $res = $this->order_processing( $this->payment_results ); | |
| 3772 | + | |
| 3773 | + if ( 'ordercompletion' == $res ) { | |
| 3774 | + $this->page = 'ordercompletion'; | |
| 3775 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion' ); | |
| 3776 | + } else { | |
| 3777 | + $this->page = 'error'; | |
| 3778 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' ); | |
| 3779 | + } | |
| 3780 | + } | |
| 3781 | + | |
| 3782 | + } else { // result NG. | |
| 3783 | + $this->page = 'error'; | |
| 3784 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_error' ); | |
| 3785 | + } | |
| 3786 | + | |
| 3787 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 3788 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3789 | + } | |
| 3790 | + | |
| 3791 | + public function settlement_epsilon() { | |
| 3792 | + global $wp_query; | |
| 3793 | + require_once $this->options['settlement_path'] . 'epsilon.php'; | |
| 3794 | + } | |
| 3795 | + | |
| 3796 | + public function inquiry_button() { | |
| 3797 | + 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'] ) ) { | |
| 3798 | + $res = $this->inquiry_processing(); | |
| 3799 | + } else { | |
| 3800 | + $res = 'deficiency'; | |
| 3801 | + } | |
| 3802 | + | |
| 3803 | + $this->page = $res; | |
| 3804 | + } | |
| 3805 | + | |
| 3806 | + public function member_login_page() { | |
| 3807 | + global $wp_query; | |
| 3808 | + if ( ! class_exists( 'RateLimiter' ) ) { | |
| 3809 | + require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php'; | |
| 3810 | + } | |
| 3811 | + $rateLimiter = new RateLimiter(); | |
| 3812 | + if ( $rateLimiter->checkBlockIP() ) { | |
| 3813 | + $wp_query->set_403(); | |
| 3814 | + status_header( 403 ); | |
| 3815 | + exit(); | |
| 3816 | + } | |
| 3817 | + | |
| 3818 | + if ( isset( $_GET['redirect_to'] ) ) { | |
| 3819 | + $_SESSION['redirect_to'] = $_GET['redirect_to']; | |
| 3820 | + } | |
| 3821 | + | |
| 3822 | + $res = $this->member_login(); | |
| 3823 | + if ( 'member' == $res ) { | |
| 3824 | + $this->page = 'member'; | |
| 3825 | + do_action( 'usces_action_member_logined' ); | |
| 3826 | + | |
| 3827 | + if ( isset( $_SESSION['redirect_to'] ) ) { | |
| 3828 | + if ( wp_safe_redirect( esc_url( $_SESSION['redirect_to'] ) ) ) { | |
| 3829 | + unset( $_SESSION['redirect_to'] ); | |
| 3830 | + exit; | |
| 3831 | + } | |
| 3832 | + } | |
| 3833 | + | |
| 3834 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_member' ); | |
| 3835 | + } elseif ( 'login' == $res ) { | |
| 3836 | + $this->page = 'login'; | |
| 3837 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_login' ); | |
| 3838 | + } | |
| 3839 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3840 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3841 | + } | |
| 3842 | + | |
| 3843 | + public function regmember() { | |
| 3844 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3845 | + if ( ! $this->verify_member_nonce( $nonce, 'post_member' ) ) { | |
| 3846 | + die( 'Security check2' ); | |
| 3847 | + } | |
| 3848 | + | |
| 3849 | + $check_verify_recaptcha = $this->verifyGoogleRecapcha(); | |
| 3850 | + if ( $check_verify_recaptcha ) { | |
| 3851 | + // continue register form. | |
| 3852 | + global $wp_query; | |
| 3853 | + $res = $this->regist_member(); | |
| 3854 | + } else { | |
| 3855 | + // return back page register and show message. | |
| 3856 | + $this->error_message = apply_filters( 'usces_filter_check_verify_recaptcha_message', __( 'Failed to register member. Please try again.', 'usces' ), 'regmember' ); | |
| 3857 | + $res = trim( $_POST['member_regmode'] ); | |
| 3858 | + } | |
| 3859 | + | |
| 3860 | + if ( 'editmemberform' == $res ) { | |
| 3861 | + $this->page = 'editmemberform'; | |
| 3862 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' ); | |
| 3863 | + } elseif ( 'newcompletion' == $res ) { | |
| 3864 | + $this->page = 'newcompletion'; | |
| 3865 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' ); | |
| 3866 | + } else { | |
| 3867 | + $this->page = $res; | |
| 3868 | + } | |
| 3869 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3870 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3871 | + } | |
| 3872 | + | |
| 3873 | + public function editmember() { | |
| 3874 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3875 | + if ( ! $this->verify_member_nonce( $nonce, 'post_member' ) ) { | |
| 3876 | + die( 'Security check3' ); | |
| 3877 | + } | |
| 3878 | + | |
| 3879 | + global $wp_query; | |
| 3880 | + $res = $this->regist_member(); | |
| 3881 | + if ( 'editmemberform' == $res ) { | |
| 3882 | + $this->page = 'editmemberform'; | |
| 3883 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_editmemberform' ); | |
| 3884 | + } elseif ( 'newcompletion' == $res ) { | |
| 3885 | + $this->page = 'newcompletion'; | |
| 3886 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newcompletion' ); | |
| 3887 | + } elseif ( 'updatememberform' == $res ) { | |
| 3888 | + $this->page = 'member_edit'; | |
| 3889 | + } else { | |
| 3890 | + $this->page = $res; | |
| 3891 | + } | |
| 3892 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3893 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3894 | + } | |
| 3895 | + | |
| 3896 | + public function deletemember() { | |
| 3897 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3898 | + if ( ! $this->verify_member_nonce( $nonce, 'post_member' ) ) { | |
| 3899 | + die( 'Security check4' ); | |
| 3900 | + } | |
| 3901 | + | |
| 3902 | + $res = $this->delete_member(); | |
| 3903 | + if ( $res ) { | |
| 3904 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_deletemember' ); | |
| 3905 | + $this->member_logout(); | |
| 3906 | + } else { | |
| 3907 | + $this->page = 'editmemberform'; | |
| 3908 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3909 | + } | |
| 3910 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3911 | + } | |
| 3912 | + | |
| 3913 | + public function page_logout() { | |
| 3914 | + global $wp_query; | |
| 3915 | + $this->member_logout(); | |
| 3916 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3917 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3918 | + } | |
| 3919 | + | |
| 3920 | + public function page_lostmemberpassword() { | |
| 3921 | + global $wp_query; | |
| 3922 | + $this->page = 'lostmemberpassword'; | |
| 3923 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3924 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3925 | + } | |
| 3926 | + | |
| 3927 | + public function lostpassword() { | |
| 3928 | + global $usces, $wp_query; | |
| 3929 | + | |
| 3930 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3931 | + if ( ! $usces->verify_member_nonce( $nonce, 'post_member' ) ) { | |
| 3932 | + $wp_query->set_403(); | |
| 3933 | + status_header( 403 ); | |
| 3934 | + exit(); | |
| 3935 | + } | |
| 3936 | + | |
| 3937 | + $this->error_message = $this->lostpass_mailaddcheck(); | |
| 3938 | + if ( '' != $this->error_message ) { | |
| 3939 | + $this->page = 'lostmemberpassword'; | |
| 3940 | + } else { | |
| 3941 | + $res = $this->lostmail(); | |
| 3942 | + $this->page = $res; // 'lostcompletion';. | |
| 3943 | + } | |
| 3944 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3945 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3946 | + } | |
| 3947 | + | |
| 3948 | + public function uscesmode_changepassword() { | |
| 3949 | + global $wp_query; | |
| 3950 | + | |
| 3951 | + if ( ! isset( $_REQUEST['mem'] ) || ! isset( $_REQUEST['key'] ) ) { | |
| 3952 | + die( 'Invalid request 1' ); | |
| 3953 | + } | |
| 3954 | + | |
| 3955 | + $mem_mail = $_REQUEST['mem']; | |
| 3956 | + $lostkey = $_REQUEST['key']; | |
| 3957 | + $res = usces_check_lostkey( $mem_mail, $lostkey ); | |
| 3958 | + if ( empty( $res ) ) { | |
| 3959 | + die( 'Invalid request 2' ); | |
| 3960 | + } | |
| 3961 | + | |
| 3962 | + $this->page = 'changepassword'; | |
| 3963 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3964 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3965 | + } | |
| 3966 | + | |
| 3967 | + public function changepassword_page() { | |
| 3968 | + global $usces; | |
| 3969 | + | |
| 3970 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 3971 | + if ( ! $usces->verify_member_nonce( $nonce, 'post_member' ) ) { | |
| 3972 | + die( 'Security check6' ); | |
| 3973 | + } | |
| 3974 | + | |
| 3975 | + $lostmail = $_POST['mem']; | |
| 3976 | + $lostkey = $_POST['key']; | |
| 3977 | + $res = usces_check_lostkey( $lostmail, $lostkey ); | |
| 3978 | + if ( empty( $res ) ) { | |
| 3979 | + die( 'Invalid request 7' ); | |
| 3980 | + } | |
| 3981 | + | |
| 3982 | + global $wp_query; | |
| 3983 | + $this->error_message = $this->changepass_check(); | |
| 3984 | + if ( '' != $this->error_message ) { | |
| 3985 | + $this->page = 'changepassword'; | |
| 3986 | + } else { | |
| 3987 | + $res = $this->changepassword(); | |
| 3988 | + $this->page = $res; // 'changepasscompletion';. | |
| 3989 | + } | |
| 3990 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3991 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 3992 | + } | |
| 3993 | + | |
| 3994 | + public function page_newmember() { | |
| 3995 | + global $wp_query; | |
| 3996 | + $this->page = 'newmemberform'; | |
| 3997 | + add_filter( 'yoast-ga-push-after-pageview', 'usces_trackPageview_newmemberform' ); | |
| 3998 | + add_action( 'the_post', array( $this, 'action_memberFilter' ) ); | |
| 3999 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 4000 | + } | |
| 4001 | + | |
| 4002 | + public function page_search_item() { | |
| 4003 | + global $wp_query; | |
| 4004 | + $this->page = 'search_item'; | |
| 4005 | + add_action( 'the_post', array( $this, 'action_cartFilter' ) ); | |
| 4006 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 4007 | + } | |
| 4008 | + | |
| 4009 | + public function default_page() { | |
| 4010 | + global $wp_query; | |
| 4011 | + add_action( 'the_post', array( $this, 'goDefaultPage' ) ); | |
| 4012 | + add_action( 'template_redirect', array( $this, 'template_redirect' ) ); | |
| 4013 | + } | |
| 4014 | + | |
| 4015 | + public function verifyGoogleRecapcha() { | |
| 4016 | + // check google re-captcha v3. | |
| 4017 | + $option = get_option( 'usces_ex' ); | |
| 4018 | + $is_human = true; | |
| 4019 | + 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'] ) ) ) { | |
| 4020 | + if ( isset( $_POST['recaptcha_response'] ) ) { | |
| 4021 | + $secret = isset( $option['system']['google_recaptcha']['secret_key'] ) ? $option['system']['google_recaptcha']['secret_key'] : ''; | |
| 4022 | + $token = trim( $_POST['recaptcha_response'] ); | |
| 4023 | + $is_human = $this->google_recaptcha_v3_response( $token, $secret ); | |
| 4024 | + } | |
| 4025 | + } | |
| 4026 | + return $is_human; | |
| 4027 | + } | |
| 4028 | + | |
| 4029 | + /** | |
| 4030 | + * Handle check google recaptcha v3 response. | |
| 4031 | + * | |
| 4032 | + * @param string $token string token. | |
| 4033 | + * @param string $secret string secret key config. | |
| 4034 | + * | |
| 4035 | + * @return boolean $is_human. | |
| 4036 | + */ | |
| 4037 | + public function google_recaptcha_v3_response( $token, $secret ) { | |
| 4038 | + $is_human = true; | |
| 4039 | + if ( empty( $token ) || empty( $secret ) ) { | |
| 4040 | + return $is_human; | |
| 4041 | + } | |
| 4042 | + $option = get_option( 'usces_ex' ); | |
| 4043 | + $threshold = isset( $option['system']['google_recaptcha']['score'] ) ? $option['system']['google_recaptcha']['score'] : 0.5; | |
| 4044 | + | |
| 4045 | + $endpoint = 'https://www.google.com/recaptcha/api/siteverify'; | |
| 4046 | + $request = array( | |
| 4047 | + 'body' => array( | |
| 4048 | + 'secret' => $secret, | |
| 4049 | + 'response' => $token, | |
| 4050 | + ), | |
| 4051 | + ); | |
| 4052 | + | |
| 4053 | + $response = wp_remote_post( esc_url_raw( $endpoint ), $request ); | |
| 4054 | + | |
| 4055 | + if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { | |
| 4056 | + update_option( 'usces_recaptcha_condition', 'response_NG' ); | |
| 4057 | + return $is_human; | |
| 4058 | + } else { | |
| 4059 | + update_option( 'usces_recaptcha_condition', 'response_OK' ); | |
| 4060 | + } | |
| 4061 | + | |
| 4062 | + $response_body = wp_remote_retrieve_body( $response ); | |
| 4063 | + $response_body = json_decode( $response_body, true ); | |
| 4064 | + | |
| 4065 | + $action = isset( $response_body['action'] ) ? $response_body['action'] : ''; | |
| 4066 | + $actions = array( | |
| 4067 | + 'create_new_member', | |
| 4068 | + 'customer_order_page', | |
| 4069 | + 'delivery_order_page', | |
| 4070 | + 'member_register_settlement', | |
| 4071 | + 'member_update_settlement', | |
| 4072 | + ); | |
| 4073 | + if ( ! $response_body['success'] || ! in_array( $action, $actions ) ) { | |
| 4074 | + update_option( 'usces_recaptcha_condition', 'response_ERROR' ); | |
| 4075 | + return $is_human; | |
| 4076 | + } else { | |
| 4077 | + update_option( 'usces_recaptcha_condition', 'response_OK' ); | |
| 4078 | + } | |
| 4079 | + $score = isset( $response_body['score'] ) ? $response_body['score'] : 0; | |
| 4080 | + $is_human = $threshold <= $score; | |
| 4081 | + return $is_human; | |
| 4082 | + } | |
| 4083 | + | |
| 4084 | + public function goDefaultPage() { | |
| 4085 | + global $post; | |
| 4086 | + | |
| 4087 | + if ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_CART_NUMBER ) { | |
| 4088 | + | |
| 4089 | + $this->page = 'cart'; | |
| 4090 | + add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 ); | |
| 4091 | + | |
| 4092 | + } elseif ( is_object( $post ) && null !== $post && (int) $post->ID === (int) USCES_MEMBER_NUMBER ) { | |
| 4093 | + | |
| 4094 | + $this->page = 'member'; | |
| 4095 | + | |
| 4096 | + if ( $this->is_member_logged_in() ) { | |
| 4097 | + $this->get_current_member(); | |
| 4098 | + $this->set_member_session_data( $this->current_member['id'] ); | |
| 4099 | + $this->page = 'member'; | |
| 4100 | + } else { | |
| 4101 | + $this->page = 'login'; | |
| 4102 | + } | |
| 4103 | + add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 ); | |
| 4104 | + add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 ); | |
| 4105 | + | |
| 4106 | + } elseif ( ! is_singular() ) { | |
| 4107 | + $this->page = 'wp_search'; | |
| 4108 | + add_filter( 'the_excerpt', array( $this, 'filter_cartContent' ), 20 ); | |
| 4109 | + add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 ); | |
| 4110 | + | |
| 4111 | + } else { | |
| 4112 | + add_filter( 'the_content', array( &$this, 'filter_itemPage' ) ); | |
| 4113 | + } | |
| 4114 | + } | |
| 4115 | + | |
| 4116 | + public function template_redirect() { | |
| 4117 | + global $wpdb, $wp_version, $post, $usces_entries, $usces_carts, $usces_members, $usces_gp, $member_regmode; | |
| 4118 | + | |
| 4119 | + if ( version_compare( $wp_version, '4.4-beta', '>' ) && is_embed() ) { | |
| 4120 | + return; | |
| 4121 | + } | |
| 4122 | + | |
| 4123 | + if ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 4124 | + if ( '' == $this->page && empty( $this->error_message ) ) { | |
| 4125 | + $this->error_message = $this->zaiko_check(); | |
| 4126 | + if ( $this->error_message ) { | |
| 4127 | + $this->page = 'cart'; | |
| 4128 | + } | |
| 4129 | + } | |
| 4130 | + } | |
| 4131 | + | |
| 4132 | + if ( apply_filters( 'usces_action_template_redirect', false ) ) { | |
| 4133 | + return; // Deprecated. | |
| 4134 | + } | |
| 4135 | + if ( apply_filters( 'usces_filter_template_redirect', false ) ) { | |
| 4136 | + return; | |
| 4137 | + } | |
| 4138 | + | |
| 4139 | + $parent_path = get_template_directory() . '/wc_templates'; | |
| 4140 | + $child_path = get_stylesheet_directory() . '/wc_templates'; | |
| 4141 | + | |
| 4142 | + if ( is_single() && is_object( $post ) && 'item' === $post->post_mime_type ) { | |
| 4143 | + | |
| 4144 | + if ( file_exists( $child_path . '/wc_item_single.php' ) ) { | |
| 4145 | + if ( ! post_password_required( $post ) ) { | |
| 4146 | + include $child_path . '/wc_item_single.php'; | |
| 4147 | + exit; | |
| 4148 | + } | |
| 4149 | + } elseif ( file_exists( $parent_path . '/wc_item_single.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4150 | + if ( ! post_password_required( $post ) ) { | |
| 4151 | + include $parent_path . '/wc_item_single.php'; | |
| 4152 | + exit; | |
| 4153 | + } | |
| 4154 | + } | |
| 4155 | + | |
| 4156 | + } elseif ( isset( $_REQUEST['usces_page'] ) && ( 'search_item' == $_REQUEST['usces_page'] || 'usces_search' == $_REQUEST['usces_page'] ) && $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 4157 | + | |
| 4158 | + if ( file_exists( $child_path . '/wc_search_page.php' ) ) { | |
| 4159 | + include $child_path . '/wc_search_page.php'; | |
| 4160 | + exit; | |
| 4161 | + } elseif ( file_exists( $parent_path . '/wc_search_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4162 | + include $parent_path . '/wc_search_page.php'; | |
| 4163 | + exit; | |
| 4164 | + } | |
| 4165 | + | |
| 4166 | + } elseif ( $this->is_cart_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 4167 | + | |
| 4168 | + switch ( $this->page ) { | |
| 4169 | + | |
| 4170 | + case 'customer': | |
| 4171 | + if ( file_exists( $child_path . '/cart/wc_customer_page.php' ) ) { | |
| 4172 | + usces_get_entries(); | |
| 4173 | + usces_get_member_regmode(); | |
| 4174 | + include $child_path . '/cart/wc_customer_page.php'; | |
| 4175 | + exit; | |
| 4176 | + } elseif ( file_exists( $parent_path . '/cart/wc_customer_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4177 | + usces_get_entries(); | |
| 4178 | + usces_get_member_regmode(); | |
| 4179 | + include $parent_path . '/cart/wc_customer_page.php'; | |
| 4180 | + exit; | |
| 4181 | + } | |
| 4182 | + break; | |
| 4183 | + | |
| 4184 | + case 'delivery': | |
| 4185 | + if ( file_exists( $child_path . '/cart/wc_delivery_page.php' ) ) { | |
| 4186 | + usces_get_entries(); | |
| 4187 | + usces_get_carts(); | |
| 4188 | + include $child_path . '/cart/wc_delivery_page.php'; | |
| 4189 | + exit; | |
| 4190 | + } elseif ( file_exists( $parent_path . '/cart/wc_delivery_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4191 | + usces_get_entries(); | |
| 4192 | + usces_get_carts(); | |
| 4193 | + include $parent_path . '/cart/wc_delivery_page.php'; | |
| 4194 | + exit; | |
| 4195 | + } | |
| 4196 | + break; | |
| 4197 | + | |
| 4198 | + case 'confirm': | |
| 4199 | + if ( file_exists( $child_path . '/cart/wc_confirm_page.php' ) ) { | |
| 4200 | + usces_get_entries(); | |
| 4201 | + usces_get_carts(); | |
| 4202 | + usces_get_members(); | |
| 4203 | + include $child_path . '/cart/wc_confirm_page.php'; | |
| 4204 | + exit; | |
| 4205 | + } elseif ( file_exists( $parent_path . '/cart/wc_confirm_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4206 | + usces_get_entries(); | |
| 4207 | + usces_get_carts(); | |
| 4208 | + usces_get_members(); | |
| 4209 | + include $parent_path . '/cart/wc_confirm_page.php'; | |
| 4210 | + exit; | |
| 4211 | + } | |
| 4212 | + break; | |
| 4213 | + | |
| 4214 | + case 'ordercompletion': | |
| 4215 | + if ( file_exists( $child_path . '/cart/wc_completion_page.php' ) ) { | |
| 4216 | + usces_get_entries(); | |
| 4217 | + usces_get_carts(); | |
| 4218 | + include $child_path . '/cart/wc_completion_page.php'; | |
| 4219 | + exit; | |
| 4220 | + } elseif ( file_exists( $parent_path . '/cart/wc_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4221 | + usces_get_entries(); | |
| 4222 | + usces_get_carts(); | |
| 4223 | + include $parent_path . '/cart/wc_completion_page.php'; | |
| 4224 | + exit; | |
| 4225 | + } | |
| 4226 | + break; | |
| 4227 | + | |
| 4228 | + case 'error': | |
| 4229 | + if ( file_exists( $child_path . '/cart/wc_cart_error_page.php' ) ) { | |
| 4230 | + include $child_path . '/cart/wc_cart_error_page.php'; | |
| 4231 | + exit; | |
| 4232 | + } elseif ( file_exists( $parent_path . '/cart/wc_cart_error_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4233 | + include $parent_path . '/cart/wc_cart_error_page.php'; | |
| 4234 | + exit; | |
| 4235 | + } | |
| 4236 | + break; | |
| 4237 | + | |
| 4238 | + case 'cart': | |
| 4239 | + default: | |
| 4240 | + $this->page = 'cart'; | |
| 4241 | + if ( file_exists( $child_path . '/cart/wc_cart_page.php' ) ) { | |
| 4242 | + include $child_path . '/cart/wc_cart_page.php'; | |
| 4243 | + exit; | |
| 4244 | + } elseif ( file_exists( $parent_path . '/cart/wc_cart_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4245 | + include $parent_path . '/cart/wc_cart_page.php'; | |
| 4246 | + exit; | |
| 4247 | + } | |
| 4248 | + } | |
| 4249 | + | |
| 4250 | + } elseif ( $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 4251 | + | |
| 4252 | + } elseif ( $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 4253 | + if ( 'activate' != $this->options['membersystem_state'] ) { | |
| 4254 | + return; | |
| 4255 | + } | |
| 4256 | + | |
| 4257 | + if ( $this->is_member_logged_in() ) { | |
| 4258 | + | |
| 4259 | + if ( isset( $_SESSION['usces_member'] ) ) { | |
| 4260 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 4261 | + $this->get_current_member(); | |
| 4262 | + $query = $wpdb->prepare( "SELECT mem_point FROM $member_table_name WHERE ID = %d", $this->current_member['id'] ); | |
| 4263 | + $point = $wpdb->get_var( $query ); | |
| 4264 | + $_SESSION['usces_member']['point'] = $point; | |
| 4265 | + } | |
| 4266 | + | |
| 4267 | + $member_regmode = 'editmemberform'; | |
| 4268 | + if ( file_exists( $child_path . '/member/wc_member_page.php' ) ) { | |
| 4269 | + include $child_path . '/member/wc_member_page.php'; | |
| 4270 | + exit; | |
| 4271 | + } elseif ( file_exists( $parent_path . '/member/wc_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4272 | + include $parent_path . '/member/wc_member_page.php'; | |
| 4273 | + exit; | |
| 4274 | + } | |
| 4275 | + | |
| 4276 | + } else { | |
| 4277 | + | |
| 4278 | + switch ( $this->page ) { | |
| 4279 | + | |
| 4280 | + case 'login': | |
| 4281 | + if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) { | |
| 4282 | + include $child_path . '/member/wc_login_page.php'; | |
| 4283 | + exit; | |
| 4284 | + } elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4285 | + include $parent_path . '/member/wc_login_page.php'; | |
| 4286 | + exit; | |
| 4287 | + } | |
| 4288 | + break; | |
| 4289 | + | |
| 4290 | + case 'newmemberform': | |
| 4291 | + if ( file_exists( $child_path . '/member/wc_new_member_page.php' ) ) { | |
| 4292 | + $member_regmode = 'newmemberform'; | |
| 4293 | + include $child_path . '/member/wc_new_member_page.php'; | |
| 4294 | + exit; | |
| 4295 | + } elseif ( file_exists( $parent_path . '/member/wc_new_member_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4296 | + $member_regmode = 'newmemberform'; | |
| 4297 | + include $parent_path . '/member/wc_new_member_page.php'; | |
| 4298 | + exit; | |
| 4299 | + } | |
| 4300 | + break; | |
| 4301 | + | |
| 4302 | + case 'lostmemberpassword': | |
| 4303 | + if ( file_exists( $child_path . '/member/wc_lostpassword_page.php' ) ) { | |
| 4304 | + include $child_path . '/member/wc_lostpassword_page.php'; | |
| 4305 | + exit; | |
| 4306 | + } elseif ( file_exists( $parent_path . '/member/wc_lostpassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4307 | + include $parent_path . '/member/wc_lostpassword_page.php'; | |
| 4308 | + exit; | |
| 4309 | + } | |
| 4310 | + break; | |
| 4311 | + | |
| 4312 | + case 'changepassword': | |
| 4313 | + if ( file_exists( $child_path . '/member/wc_changepassword_page.php' ) ) { | |
| 4314 | + include $child_path . '/member/wc_changepassword_page.php'; | |
| 4315 | + exit; | |
| 4316 | + } elseif ( file_exists( $parent_path . '/member/wc_changepassword_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4317 | + include $parent_path . '/member/wc_changepassword_page.php'; | |
| 4318 | + exit; | |
| 4319 | + } | |
| 4320 | + break; | |
| 4321 | + | |
| 4322 | + case 'newcompletion': | |
| 4323 | + case 'editcompletion': | |
| 4324 | + case 'lostcompletion': | |
| 4325 | + case 'changepasscompletion': | |
| 4326 | + if ( file_exists( $child_path . '/member/wc_member_completion_page.php' ) ) { | |
| 4327 | + include $child_path . '/member/wc_member_completion_page.php'; | |
| 4328 | + exit; | |
| 4329 | + } elseif ( file_exists( $parent_path . '/member/wc_member_completion_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4330 | + include $parent_path . '/member/wc_member_completion_page.php'; | |
| 4331 | + exit; | |
| 4332 | + } | |
| 4333 | + break; | |
| 4334 | + | |
| 4335 | + default: | |
| 4336 | + $this->page = 'login'; | |
| 4337 | + if ( file_exists( $child_path . '/member/wc_login_page.php' ) ) { | |
| 4338 | + include $child_path . '/member/wc_login_page.php'; | |
| 4339 | + exit; | |
| 4340 | + } elseif ( file_exists( $parent_path . '/member/wc_login_page.php' ) && ! defined( 'USCES_PARENT_LOAD' ) ) { | |
| 4341 | + include $parent_path . '/member/wc_login_page.php'; | |
| 4342 | + exit; | |
| 4343 | + } | |
| 4344 | + } | |
| 4345 | + } | |
| 4346 | + } | |
| 4347 | + } | |
| 4348 | + | |
| 4349 | + public function changepassword() { | |
| 4350 | + global $wpdb; | |
| 4351 | + | |
| 4352 | + $lostmail = $_POST['mem']; | |
| 4353 | + $lost_key = $_POST['key']; | |
| 4354 | + | |
| 4355 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4356 | + // $hash = usces_get_hash(trim($_POST['loginpass1'])); | |
| 4357 | + $salt = usces_get_salt( $lostmail ); | |
| 4358 | + $hash = usces_get_hash( trim( $_POST['loginpass1'] ), $salt ); | |
| 4359 | + $query = $wpdb->prepare( "UPDATE $member_table SET mem_pass = %s WHERE mem_email = %s", | |
| 4360 | + $hash, $lostmail | |
| 4361 | + ); | |
| 4362 | + $res = $wpdb->query( $query ); | |
| 4363 | + | |
| 4364 | + if ( $res === false ) { | |
| 4365 | + $this->error_message = __( 'Error: failure in updating password', 'usces' ); | |
| 4366 | + return 'login'; | |
| 4367 | + } else { | |
| 4368 | + usces_remove_lostmail_key( $lostmail, $lost_key ); | |
| 4369 | + return 'changepasscompletion'; | |
| 4370 | + } | |
| 4371 | + } | |
| 4372 | + | |
| 4373 | + public function lostmail() { | |
| 4374 | + $delim = apply_filters( 'usces_filter_delim', $this->delim ); | |
| 4375 | + | |
| 4376 | + $lostmail = trim( $_POST['loginmail'] ); | |
| 4377 | + if ( ! $this->is_member( $lostmail ) ) { | |
| 4378 | + return 'lostcompletion'; | |
| 4379 | + } | |
| 4380 | + | |
| 4381 | + $lost_key = usces_make_lost_key(); | |
| 4382 | + usces_store_lostmail_key( $lostmail, $lost_key ); | |
| 4383 | + | |
| 4384 | + $uri = USCES_MEMBER_URL . $delim . 'uscesmode=changepassword&mem=' . urlencode( $lostmail ) . '&key=' . urlencode( $lost_key ); | |
| 4385 | + | |
| 4386 | + $res = usces_lostmail( $uri ); | |
| 4387 | + return $res; | |
| 4388 | + } | |
| 4389 | + | |
| 4390 | + public function regist_member() { | |
| 4391 | + global $wpdb; | |
| 4392 | + | |
| 4393 | + $_POST = $this->stripslashes_deep_post( $_POST ); | |
| 4394 | + | |
| 4395 | + $member = $this->get_member(); | |
| 4396 | + $mode = $_POST['member_regmode']; | |
| 4397 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4398 | + $member_meta_table = usces_get_tablename( 'usces_member_meta' ); | |
| 4399 | + | |
| 4400 | + $error_mes = ( 'newmemberfromcart' == $_POST['member_regmode'] || 'editmemberfromcart' == $_POST['member_regmode'] ) ? $this->member_check_fromcart() : $this->member_check(); | |
| 4401 | + | |
| 4402 | + if ( '' != $error_mes ) { | |
| 4403 | + | |
| 4404 | + $this->error_message = $error_mes; | |
| 4405 | + return $mode; | |
| 4406 | + | |
| 4407 | + } elseif ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) { | |
| 4408 | + | |
| 4409 | + $this->get_current_member(); | |
| 4410 | + $mem_id = $this->current_member['id']; | |
| 4411 | + | |
| 4412 | + // $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['member']['mailaddress1'])); | |
| 4413 | + // $id = $wpdb->get_var( $query ); | |
| 4414 | + $id = $this->check_member_email( $_POST['member']['mailaddress1'] ); | |
| 4415 | + if ( ! empty( $id ) && $id != $mem_id ) { | |
| 4416 | + // $this->error_message = __( 'This e-mail address has been already registered.', 'usces' ); | |
| 4417 | + $this->error_message = __( 'This e-mail address can not be registered.', 'usces' ); | |
| 4418 | + return $mode; | |
| 4419 | + } | |
| 4420 | + | |
| 4421 | + do_action( 'usces_action_pre_edit_memberdata', $_POST['member'], $mem_id ); | |
| 4422 | + | |
| 4423 | + $query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id ); | |
| 4424 | + $pass = $wpdb->get_var( $query ); | |
| 4425 | + // $password = ( !empty( $_POST['member']['password1']) && trim($_POST['member']['password1']) == trim($_POST['member']['password2']) ) ? usces_get_hash(trim($_POST['member']['password1'])) : $pass; | |
| 4426 | + if ( ! empty( $_POST['member']['password1'] ) && trim( $_POST['member']['password1'] ) == trim( $_POST['member']['password2'] ) ) { | |
| 4427 | + $salt = usces_get_salt( $mem_id ); | |
| 4428 | + $password = usces_get_hash( trim( $_POST['member']['password1'] ), $salt ); | |
| 4429 | + } else { | |
| 4430 | + $password = $pass; | |
| 4431 | + } | |
| 4432 | + $name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : ''; | |
| 4433 | + $name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : ''; | |
| 4434 | + $name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : ''; | |
| 4435 | + $name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : ''; | |
| 4436 | + $zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : ''; | |
| 4437 | + $pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : ''; | |
| 4438 | + $address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : ''; | |
| 4439 | + $address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : ''; | |
| 4440 | + $address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : ''; | |
| 4441 | + $tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : ''; | |
| 4442 | + $fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : ''; | |
| 4443 | + $country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : ''; | |
| 4444 | + | |
| 4445 | + $query = $wpdb->prepare( | |
| 4446 | + "UPDATE $member_table SET | |
| 4447 | + mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s, | |
| 4448 | + mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s, | |
| 4449 | + mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d", | |
| 4450 | + $password, | |
| 4451 | + $name1, | |
| 4452 | + $name2, | |
| 4453 | + $name3, | |
| 4454 | + $name4, | |
| 4455 | + $zipcode, | |
| 4456 | + $pref, | |
| 4457 | + $address1, | |
| 4458 | + $address2, | |
| 4459 | + $address3, | |
| 4460 | + $tel, | |
| 4461 | + $fax, | |
| 4462 | + trim( $_POST['member']['mailaddress1'] ), | |
| 4463 | + $mem_id | |
| 4464 | + ); | |
| 4465 | + $res = $wpdb->query( $query ); | |
| 4466 | + | |
| 4467 | + if ( false !== $res ) { | |
| 4468 | + $this->set_member_meta_value( 'customer_country', $country, $mem_id ); | |
| 4469 | + $res = $this->reg_custom_member( $mem_id ); | |
| 4470 | + unset( $_SESSION['usces_entry']['custom_customer'] ); | |
| 4471 | + $this->cart->entry(); | |
| 4472 | + do_action( 'usces_action_edit_memberdata', $_POST['member'], $mem_id ); | |
| 4473 | + $meta_keys = apply_filters( 'usces_filter_delete_member_pcid', "'remise_pcid', 'digitalcheck_ip_user_id'" ); | |
| 4474 | + $query = $wpdb->prepare( "DELETE FROM $member_meta_table WHERE member_id = %d AND meta_key IN( $meta_keys )", | |
| 4475 | + $mem_id | |
| 4476 | + ); | |
| 4477 | + $res = $wpdb->query( $query ); | |
| 4478 | + | |
| 4479 | + $user = $_POST['member']; | |
| 4480 | + $user['ID'] = $mem_id; | |
| 4481 | + usces_send_updmembermail( $user ); | |
| 4482 | + | |
| 4483 | + $this->get_current_member(); | |
| 4484 | + // return 'editmemberform'; | |
| 4485 | + return $mode; | |
| 4486 | + | |
| 4487 | + } else { | |
| 4488 | + $this->error_message = __( 'Error:failure in update', 'usces' ); | |
| 4489 | + return $mode; | |
| 4490 | + } | |
| 4491 | + | |
| 4492 | + } elseif ( 'newmemberform' == $_POST['member_regmode'] ) { | |
| 4493 | + // $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['member']['mailaddress1'])); | |
| 4494 | + // $id = $wpdb->get_var( $query ); | |
| 4495 | + $id = $this->check_member_email( $_POST['member']['mailaddress1'] ); | |
| 4496 | + if ( ! empty( $id ) ) { | |
| 4497 | + // $this->error_message = __( 'This e-mail address has been already registered.', 'usces' ); | |
| 4498 | + $this->error_message = __( 'This e-mail address can not be registered.', 'usces' ); | |
| 4499 | + return $mode; | |
| 4500 | + } else { | |
| 4501 | + $point = $this->options['start_point']; | |
| 4502 | + // $pass = usces_get_hash(trim($_POST['member']['password1'])); | |
| 4503 | + $salt = usces_get_salt( '', 1 ); | |
| 4504 | + $pass = usces_get_hash( trim( $_POST['member']['password1'] ), $salt ); | |
| 4505 | + $name1 = ( isset( $_POST['member']['name1'] ) ) ? trim( $_POST['member']['name1'] ) : ''; | |
| 4506 | + $name2 = ( isset( $_POST['member']['name2'] ) ) ? trim( $_POST['member']['name2'] ) : ''; | |
| 4507 | + $name3 = ( isset( $_POST['member']['name3'] ) ) ? trim( $_POST['member']['name3'] ) : ''; | |
| 4508 | + $name4 = ( isset( $_POST['member']['name4'] ) ) ? trim( $_POST['member']['name4'] ) : ''; | |
| 4509 | + $zipcode = ( isset( $_POST['member']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['member']['zipcode'] ) ) : ''; | |
| 4510 | + $pref = ( isset( $_POST['member']['pref'] ) ) ? trim( $_POST['member']['pref'] ) : ''; | |
| 4511 | + $address1 = ( isset( $_POST['member']['address1'] ) ) ? trim( $_POST['member']['address1'] ) : ''; | |
| 4512 | + $address2 = ( isset( $_POST['member']['address2'] ) ) ? trim( $_POST['member']['address2'] ) : ''; | |
| 4513 | + $address3 = ( isset( $_POST['member']['address3'] ) ) ? trim( $_POST['member']['address3'] ) : ''; | |
| 4514 | + $tel = ( isset( $_POST['member']['tel'] ) ) ? trim( $_POST['member']['tel'] ) : ''; | |
| 4515 | + $fax = ( isset( $_POST['member']['fax'] ) ) ? trim( $_POST['member']['fax'] ) : ''; | |
| 4516 | + $country = ( isset( $_POST['member']['country'] ) ) ? trim( $_POST['member']['country'] ) : ''; | |
| 4517 | + | |
| 4518 | + $query = $wpdb->prepare( | |
| 4519 | + "INSERT INTO $member_table | |
| 4520 | + (mem_email, mem_pass, mem_status, mem_cookie, mem_point, | |
| 4521 | + mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref, | |
| 4522 | + mem_address1, mem_address2, mem_address3, mem_tel, mem_fax, | |
| 4523 | + mem_delivery_flag, mem_delivery, mem_registered, mem_nicename) | |
| 4524 | + VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 4525 | + trim( $_POST['member']['mailaddress1'] ), | |
| 4526 | + $pass, | |
| 4527 | + 0, | |
| 4528 | + '', | |
| 4529 | + $point, | |
| 4530 | + $name1, | |
| 4531 | + $name2, | |
| 4532 | + $name3, | |
| 4533 | + $name4, | |
| 4534 | + $zipcode, | |
| 4535 | + $pref, | |
| 4536 | + $address1, | |
| 4537 | + $address2, | |
| 4538 | + $address3, | |
| 4539 | + $tel, | |
| 4540 | + $fax, | |
| 4541 | + '', | |
| 4542 | + '', | |
| 4543 | + get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), | |
| 4544 | + '' | |
| 4545 | + ); | |
| 4546 | + $res = $wpdb->query( $query ); | |
| 4547 | + | |
| 4548 | + if ( false !== $res ) { | |
| 4549 | + $user = $_POST['member']; | |
| 4550 | + $user['ID'] = $wpdb->insert_id; | |
| 4551 | + $this->set_member_meta_value( 'customer_country', $country, $user['ID'] ); | |
| 4552 | + | |
| 4553 | + if ( ! empty( $salt ) ) { | |
| 4554 | + $this->set_member_meta_value( 'mem_salt', $salt, $user['ID'] ); | |
| 4555 | + } | |
| 4556 | + | |
| 4557 | + $res = $this->reg_custom_member( $user['ID'] ); | |
| 4558 | + | |
| 4559 | + if ( apply_filters( 'usces_filter_veirfyemail_newmemberform', false, $user ) ) { | |
| 4560 | + return 'memberverifying'; | |
| 4561 | + } | |
| 4562 | + | |
| 4563 | + do_action( 'usces_action_member_registered', $_POST['member'], $user['ID'] ); | |
| 4564 | + unset( $_SESSION['usces_member'] ); | |
| 4565 | + usces_send_regmembermail( $user ); | |
| 4566 | + return 'newcompletion'; | |
| 4567 | + | |
| 4568 | + } else { | |
| 4569 | + $this->error_message = __( 'Error:failure in update', 'usces' ); | |
| 4570 | + return $mode; | |
| 4571 | + } | |
| 4572 | + } | |
| 4573 | + | |
| 4574 | + } elseif ( 'newmemberfromcart' == $_POST['member_regmode'] ) { | |
| 4575 | + | |
| 4576 | + // $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim($_POST['customer']['mailaddress1'])); | |
| 4577 | + // $id = $wpdb->get_var( $query ); | |
| 4578 | + $id = $this->check_member_email( $_POST['customer']['mailaddress1'] ); | |
| 4579 | + if ( ! empty( $id ) ) { | |
| 4580 | + // $this->error_message = __( 'This e-mail address has been already registered.', 'usces' ); | |
| 4581 | + $this->error_message = __( 'This e-mail address can not be registered.', 'usces' ); | |
| 4582 | + return $mode; | |
| 4583 | + } else { | |
| 4584 | + $point = $this->options['start_point']; | |
| 4585 | + // $pass = usces_get_hash(trim( $_POST['customer']['password1'])); | |
| 4586 | + $salt = usces_get_salt( '', 1 ); | |
| 4587 | + $pass = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt ); | |
| 4588 | + $name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : ''; | |
| 4589 | + $name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : ''; | |
| 4590 | + $name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : ''; | |
| 4591 | + $name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : ''; | |
| 4592 | + $zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : ''; | |
| 4593 | + $pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : ''; | |
| 4594 | + $address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : ''; | |
| 4595 | + $address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : ''; | |
| 4596 | + $address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : ''; | |
| 4597 | + $tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : ''; | |
| 4598 | + $fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : ''; | |
| 4599 | + $country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : ''; | |
| 4600 | + | |
| 4601 | + $query = $wpdb->prepare( | |
| 4602 | + "INSERT INTO $member_table | |
| 4603 | + (mem_email, mem_pass, mem_status, mem_cookie, mem_point, | |
| 4604 | + mem_name1, mem_name2, mem_name3, mem_name4, mem_zip, mem_pref, | |
| 4605 | + mem_address1, mem_address2, mem_address3, mem_tel, mem_fax, | |
| 4606 | + mem_delivery_flag, mem_delivery, mem_registered, mem_nicename) | |
| 4607 | + VALUES (%s, %s, %d, %s, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s)", | |
| 4608 | + trim( $_POST['customer']['mailaddress1'] ), | |
| 4609 | + $pass, | |
| 4610 | + 0, | |
| 4611 | + '', | |
| 4612 | + $point, | |
| 4613 | + $name1, | |
| 4614 | + $name2, | |
| 4615 | + $name3, | |
| 4616 | + $name4, | |
| 4617 | + $zipcode, | |
| 4618 | + $pref, | |
| 4619 | + $address1, | |
| 4620 | + $address2, | |
| 4621 | + $address3, | |
| 4622 | + $tel, | |
| 4623 | + $fax, | |
| 4624 | + '', | |
| 4625 | + '', | |
| 4626 | + get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), | |
| 4627 | + '' | |
| 4628 | + ); | |
| 4629 | + $res = $wpdb->query( $query ); | |
| 4630 | + | |
| 4631 | + if ( false !== $res ) { | |
| 4632 | + $member_id = $wpdb->insert_id; | |
| 4633 | + $user = $_POST['customer']; | |
| 4634 | + $user['ID'] = $member_id; | |
| 4635 | + $this->set_member_meta_value( 'customer_country', $country, $member_id ); | |
| 4636 | + | |
| 4637 | + if ( ! empty( $salt ) ) { | |
| 4638 | + $this->set_member_meta_value( 'mem_salt', $salt, $member_id ); | |
| 4639 | + } | |
| 4640 | + | |
| 4641 | + $res = $this->reg_custom_member( $member_id ); | |
| 4642 | + | |
| 4643 | + if ( apply_filters( 'usces_filter_veirfyemail_newmemberfromcart', false, $user ) ) { | |
| 4644 | + return 'cartverifying'; | |
| 4645 | + } | |
| 4646 | + | |
| 4647 | + do_action( 'usces_action_member_registered', $_POST['customer'], $member_id ); | |
| 4648 | + usces_send_regmembermail( $user ); | |
| 4649 | + $_POST['loginmail'] = trim( $_POST['customer']['mailaddress1'] ); | |
| 4650 | + $_POST['loginpass'] = trim( $_POST['customer']['password1'] ); | |
| 4651 | + if ( 'member' == $this->member_login() ) { | |
| 4652 | + $_SESSION['usces_entry']['member_regmode'] = 'editmemberfromcart'; | |
| 4653 | + return 'newcompletion'; | |
| 4654 | + } | |
| 4655 | + | |
| 4656 | + } else { | |
| 4657 | + $this->error_message = __( 'Error:failure in update', 'usces' ); | |
| 4658 | + return $mode; | |
| 4659 | + } | |
| 4660 | + } | |
| 4661 | + | |
| 4662 | + } elseif ( 'editmemberfromcart' == $_POST['member_regmode'] ) { | |
| 4663 | + | |
| 4664 | + $this->get_current_member(); | |
| 4665 | + $mem_id = $this->current_member['id']; | |
| 4666 | + | |
| 4667 | + // $query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", trim( $_POST['customer']['mailaddress1'])); | |
| 4668 | + // $id = $wpdb->get_var( $query ); | |
| 4669 | + $id = $this->check_member_email( $_POST['customer']['mailaddress1'] ); | |
| 4670 | + if ( ! empty( $id ) && $id != $mem_id ) { | |
| 4671 | + // $this->error_message = __( 'This e-mail address has been already registered.', 'usces' ); | |
| 4672 | + $this->error_message = __( 'This e-mail address can not be registered.', 'usces' ); | |
| 4673 | + return $mode; | |
| 4674 | + } | |
| 4675 | + | |
| 4676 | + do_action( 'usces_action_pre_edit_memberdata', $_POST['customer'], $mem_id ); | |
| 4677 | + | |
| 4678 | + $query = $wpdb->prepare( "SELECT mem_pass FROM $member_table WHERE ID = %d", $mem_id ); | |
| 4679 | + $pass = $wpdb->get_var( $query ); | |
| 4680 | + // $password = ( !empty( $_POST['customer']['password1']) && trim($_POST['customer']['password1']) == trim($_POST['customer']['password2']) ) ? usces_get_hash(trim($_POST['customer']['password1'])) : $pass; | |
| 4681 | + if ( ! empty( $_POST['customer']['password1'] ) && trim( $_POST['customer']['password1'] ) == trim( $_POST['customer']['password2'] ) ) { | |
| 4682 | + $salt = usces_get_salt( $mem_id ); | |
| 4683 | + $password = usces_get_hash( trim( $_POST['customer']['password1'] ), $salt ); | |
| 4684 | + } else { | |
| 4685 | + $password = $pass; | |
| 4686 | + } | |
| 4687 | + $name1 = ( isset( $_POST['customer']['name1'] ) ) ? trim( $_POST['customer']['name1'] ) : ''; | |
| 4688 | + $name2 = ( isset( $_POST['customer']['name2'] ) ) ? trim( $_POST['customer']['name2'] ) : ''; | |
| 4689 | + $name3 = ( isset( $_POST['customer']['name3'] ) ) ? trim( $_POST['customer']['name3'] ) : ''; | |
| 4690 | + $name4 = ( isset( $_POST['customer']['name4'] ) ) ? trim( $_POST['customer']['name4'] ) : ''; | |
| 4691 | + $zipcode = ( isset( $_POST['customer']['zipcode'] ) ) ? usces_convert_zipcode( trim( $_POST['customer']['zipcode'] ) ) : ''; | |
| 4692 | + $pref = ( isset( $_POST['customer']['pref'] ) ) ? trim( $_POST['customer']['pref'] ) : ''; | |
| 4693 | + $address1 = ( isset( $_POST['customer']['address1'] ) ) ? trim( $_POST['customer']['address1'] ) : ''; | |
| 4694 | + $address2 = ( isset( $_POST['customer']['address2'] ) ) ? trim( $_POST['customer']['address2'] ) : ''; | |
| 4695 | + $address3 = ( isset( $_POST['customer']['address3'] ) ) ? trim( $_POST['customer']['address3'] ) : ''; | |
| 4696 | + $tel = ( isset( $_POST['customer']['tel'] ) ) ? trim( $_POST['customer']['tel'] ) : ''; | |
| 4697 | + $fax = ( isset( $_POST['customer']['fax'] ) ) ? trim( $_POST['customer']['fax'] ) : ''; | |
| 4698 | + $country = ( isset( $_POST['customer']['country'] ) ) ? trim( $_POST['customer']['country'] ) : ''; | |
| 4699 | + | |
| 4700 | + $query = $wpdb->prepare( | |
| 4701 | + "UPDATE $member_table SET | |
| 4702 | + mem_pass = %s, mem_name1 = %s, mem_name2 = %s, mem_name3 = %s, mem_name4 = %s, | |
| 4703 | + mem_zip = %s, mem_pref = %s, mem_address1 = %s, mem_address2 = %s, | |
| 4704 | + mem_address3 = %s, mem_tel = %s, mem_fax = %s, mem_email = %s WHERE ID = %d", | |
| 4705 | + $password, | |
| 4706 | + $name1, | |
| 4707 | + $name2, | |
| 4708 | + $name3, | |
| 4709 | + $name4, | |
| 4710 | + $zipcode, | |
| 4711 | + $pref, | |
| 4712 | + $address1, | |
| 4713 | + $address2, | |
| 4714 | + $address3, | |
| 4715 | + $tel, | |
| 4716 | + $fax, | |
| 4717 | + trim( $_POST['customer']['mailaddress1'] ), | |
| 4718 | + $mem_id | |
| 4719 | + ); | |
| 4720 | + $res = $wpdb->query( $query ); | |
| 4721 | + if ( false !== $res ) { | |
| 4722 | + $this->set_member_meta_value( 'customer_country', $country, $mem_id ); | |
| 4723 | + $res = $this->reg_custom_member( $mem_id ); | |
| 4724 | + do_action( 'usces_action_edit_memberdata', $_POST['customer'], $mem_id ); | |
| 4725 | + unset( $_SESSION['usces_member'] ); | |
| 4726 | + $this->member_just_login( trim( $_POST['customer']['mailaddress1'] ), trim( $_POST['customer']['password1'] ) ); | |
| 4727 | + return 'newcompletion'; | |
| 4728 | + | |
| 4729 | + } else { | |
| 4730 | + $this->error_message = __( 'Error:failure in update', 'usces' ); | |
| 4731 | + return $mode; | |
| 4732 | + } | |
| 4733 | + } | |
| 4734 | + } | |
| 4735 | + | |
| 4736 | + public function delete_member() { | |
| 4737 | + $res = false; | |
| 4738 | + | |
| 4739 | + if ( ! $this->is_member_logged_in() ) { | |
| 4740 | + return $res; | |
| 4741 | + } | |
| 4742 | + $mem = $this->get_member(); | |
| 4743 | + if ( ! $mem['ID'] ) { | |
| 4744 | + return $res; | |
| 4745 | + } | |
| 4746 | + | |
| 4747 | + $del = usces_delete_member_check_front( $mem['ID'] ); | |
| 4748 | + if ( $del ) { | |
| 4749 | + $res = usces_delete_memberdata( $mem['ID'] ); | |
| 4750 | + if ( $res ) { | |
| 4751 | + usces_send_delmembermail( $mem ); | |
| 4752 | + } | |
| 4753 | + } | |
| 4754 | + | |
| 4755 | + return $res; | |
| 4756 | + } | |
| 4757 | + | |
| 4758 | + public function is_member_logged_in( $id = false ) { | |
| 4759 | + if ( false === $id ) { | |
| 4760 | + if ( ! empty( $_SESSION['usces_member']['ID'] ) ) { | |
| 4761 | + return true; | |
| 4762 | + } else { | |
| 4763 | + return false; | |
| 4764 | + } | |
| 4765 | + } else { | |
| 4766 | + if ( ! empty( $_SESSION['usces_member']['ID'] ) && $_SESSION['usces_member']['ID'] == $id ) { | |
| 4767 | + return true; | |
| 4768 | + } else { | |
| 4769 | + return false; | |
| 4770 | + } | |
| 4771 | + } | |
| 4772 | + } | |
| 4773 | + | |
| 4774 | + public function is_member( $email ) { | |
| 4775 | + global $wpdb; | |
| 4776 | + | |
| 4777 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4778 | + $query = $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE mem_email = %s", $email ); | |
| 4779 | + $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 4780 | + if ( empty( $member ) ) { | |
| 4781 | + return false; | |
| 4782 | + } else { | |
| 4783 | + return true; | |
| 4784 | + } | |
| 4785 | + } | |
| 4786 | + | |
| 4787 | + public function member_login() { | |
| 4788 | + global $wpdb; | |
| 4789 | + $_POST = $this->stripslashes_deep_post( $_POST ); | |
| 4790 | + | |
| 4791 | + $cookie = $this->get_cookie(); | |
| 4792 | + $metatable_name = usces_get_tablename( 'usces_member_meta' ); | |
| 4793 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4794 | + if ( ! class_exists( 'RateLimiter' ) ) { | |
| 4795 | + require USCES_PLUGIN_DIR . '/classes/rateLimiter.class.php'; | |
| 4796 | + } | |
| 4797 | + $rateLimiter = new RateLimiter(); | |
| 4798 | + | |
| 4799 | + if ( isset( $cookie['rme'] ) && 'forever' == $cookie['rme'] && ! isset( $_POST['rememberme'] ) && ! isset( $_POST['loginmail'] ) ) { | |
| 4800 | + | |
| 4801 | + $_forever = isset( $cookie['name'] ) ? $cookie['name'] : ''; | |
| 4802 | + if ( $_forever ) { | |
| 4803 | + $query = $wpdb->prepare( "SELECT member_id FROM $metatable_name WHERE meta_value = %s AND meta_key = %s", | |
| 4804 | + $_forever, '_forever' | |
| 4805 | + ); | |
| 4806 | + $id = $wpdb->get_var( $query ); | |
| 4807 | + } else { | |
| 4808 | + $id = ''; | |
| 4809 | + } | |
| 4810 | + | |
| 4811 | + if ( ! $id ) { | |
| 4812 | + $cookie['name'] = ''; | |
| 4813 | + $cookie['rme'] = ''; | |
| 4814 | + $this->set_cookie( $cookie ); | |
| 4815 | + $rateLimiter->saveLoginFailed(); | |
| 4816 | + do_action( 'usces_action_member_login_failed', '', 'auto_login' ); | |
| 4817 | + return 'login'; | |
| 4818 | + } else { | |
| 4819 | + $query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $id ); | |
| 4820 | + $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 4821 | + if ( empty( $member ) ) { | |
| 4822 | + $rateLimiter->saveLoginFailed(); | |
| 4823 | + do_action( 'usces_action_member_login_failed', '', 'auto_login' ); | |
| 4824 | + $this->error_message = __( '<b>Error:</b> Your E-mail or password is incorrect.', 'usces' ); | |
| 4825 | + return 'login'; | |
| 4826 | + } else { | |
| 4827 | + $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 4828 | + $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 4829 | + $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 4830 | + $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 4831 | + $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 4832 | + $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 4833 | + $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 4834 | + $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 4835 | + $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 4836 | + $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 4837 | + $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 4838 | + $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 4839 | + $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 4840 | + $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 4841 | + $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 4842 | + $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 4843 | + $_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? wel_safe_unserialize( $member['mem_delivery'] ) : ''; | |
| 4844 | + $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 4845 | + $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 4846 | + $_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] ); | |
| 4847 | + $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 4848 | + $this->set_session_custom_member( $member['ID'] ); | |
| 4849 | + $this->get_current_member(); | |
| 4850 | + | |
| 4851 | + do_action( 'usces_action_after_login' ); | |
| 4852 | + $this->set_cookie( $cookie ); | |
| 4853 | + return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 4854 | + } | |
| 4855 | + } | |
| 4856 | + } elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginmail'] ) && isset( $_POST['loginpass'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) { | |
| 4857 | + $rateLimiter->saveLoginFailed(); | |
| 4858 | + do_action( 'usces_action_member_login_failed', '', 'empty_credentials' ); | |
| 4859 | + return 'login'; | |
| 4860 | + } elseif ( isset( $_POST['loginmail'] ) && WCUtils::is_blank( $_POST['loginpass'] ) && isset( $cookie['rme'] ) && 'forever' != $cookie['rme'] ) { | |
| 4861 | + $rateLimiter->saveLoginFailed(); | |
| 4862 | + do_action( 'usces_action_member_login_failed', trim( $_POST['loginmail'] ), 'empty_password' ); | |
| 4863 | + $this->error_message = __( '<b>Error:</b> Enter the password.', 'usces' ); | |
| 4864 | + return 'login'; | |
| 4865 | + } elseif ( ! isset( $_POST['loginmail'] ) ) { | |
| 4866 | + if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { | |
| 4867 | + $rateLimiter->saveLoginFailed(); | |
| 4868 | + do_action( 'usces_action_member_login_failed', '', 'no_login_id' ); | |
| 4869 | + } | |
| 4870 | + return 'login'; | |
| 4871 | + } else { | |
| 4872 | + | |
| 4873 | + if ( isset( $_POST['loginmail'] ) ) { | |
| 4874 | + $nonce = isset( $_REQUEST['wel_nonce'] ) ? $_REQUEST['wel_nonce'] : ''; | |
| 4875 | + if ( ! $nonce ) { | |
| 4876 | + $nonce = isset( $_REQUEST['wc_nonce'] ) ? $_REQUEST['wc_nonce'] : ''; | |
| 4877 | + } | |
| 4878 | + if ( ! $this->verify_member_nonce( $nonce, 'post_member' ) && ! $this->is_member_logged_in() ) { | |
| 4879 | + $rateLimiter->saveLoginFailed(); | |
| 4880 | + do_action( 'usces_action_member_login_failed', trim( $_POST['loginmail'] ), 'invalid_nonce' ); | |
| 4881 | + die( 'Security check4' ); | |
| 4882 | + } | |
| 4883 | + } | |
| 4884 | + | |
| 4885 | + $email = isset( $_POST['loginmail'] ) ? trim( $_POST['loginmail'] ) : ''; | |
| 4886 | + // $pass = isset( $_POST['loginpass']) ? usces_get_hash(trim( $_POST['loginpass'])) : ''; | |
| 4887 | + $salt = usces_get_salt( $email ); | |
| 4888 | + $pass = usces_get_hash( trim( $_POST['loginpass'] ), $salt ); | |
| 4889 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4890 | + | |
| 4891 | + $query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass ); | |
| 4892 | + $query = apply_filters( 'usces_filter_member_login_query', $query, $email, $pass ); | |
| 4893 | + $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 4894 | + | |
| 4895 | + if ( empty( $member ) ) { | |
| 4896 | + $rateLimiter->saveLoginFailed(); | |
| 4897 | + do_action( 'usces_action_member_login_failed', $email, 'invalid_credentials' ); | |
| 4898 | + $this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT ); | |
| 4899 | + $this->error_message = __( '<b>Error:</b> Your E-mail or password is incorrect.', 'usces' ); | |
| 4900 | + return 'login'; | |
| 4901 | + } else { | |
| 4902 | + | |
| 4903 | + if ( USCES_VERIFY_MEMBERS_EMAIL::$opts['switch_flag'] ) { | |
| 4904 | + $verify_flag = $this->get_member_meta_value( '_verifying', $member['ID'] ); | |
| 4905 | + } else { | |
| 4906 | + $verify_flag = ''; | |
| 4907 | + } | |
| 4908 | + if ( ! empty( $verify_flag ) ) { | |
| 4909 | + $rateLimiter->saveLoginFailed(); | |
| 4910 | + do_action( 'usces_action_member_login_failed', $email, 'unverified_email' ); | |
| 4911 | + $this->error_message = __( '<b>Error:</b> Membership registration is not complete.', 'usces' ); | |
| 4912 | + return 'login'; | |
| 4913 | + } | |
| 4914 | + | |
| 4915 | + $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 4916 | + $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 4917 | + $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 4918 | + $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 4919 | + $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 4920 | + $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 4921 | + $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 4922 | + $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 4923 | + $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 4924 | + $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 4925 | + $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 4926 | + $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 4927 | + $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 4928 | + $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 4929 | + $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 4930 | + $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 4931 | + $_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? wel_safe_unserialize( $member['mem_delivery'] ) : ''; | |
| 4932 | + $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 4933 | + $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 4934 | + $_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] ); | |
| 4935 | + $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 4936 | + $this->set_session_custom_member( $member['ID'] ); | |
| 4937 | + $this->get_current_member(); | |
| 4938 | + $rateLimiter->clear_login_failed(); | |
| 4939 | + | |
| 4940 | + if ( isset( $_POST['rememberme'] ) ) { | |
| 4941 | + $_forever = $this->set_login_forever( $member['ID'] ); | |
| 4942 | + $cookie['name'] = $_forever; | |
| 4943 | + $cookie['rme'] = 'forever'; | |
| 4944 | + $this->set_cookie( $cookie ); | |
| 4945 | + } else { | |
| 4946 | + $cookie['name'] = ''; | |
| 4947 | + $cookie['rme'] = ''; | |
| 4948 | + $this->set_cookie( $cookie ); | |
| 4949 | + } | |
| 4950 | + | |
| 4951 | + do_action( 'usces_action_after_login' ); | |
| 4952 | + return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 4953 | + } | |
| 4954 | + } | |
| 4955 | + } | |
| 4956 | + | |
| 4957 | + public function set_login_forever( $member_id ) { | |
| 4958 | + if ( ! $member_id ) { | |
| 4959 | + return false; | |
| 4960 | + } | |
| 4961 | + | |
| 4962 | + $_forever = wp_generate_password( 32, false, false ); | |
| 4963 | + $this->set_member_meta_value( '_forever', $_forever, $member_id ); | |
| 4964 | + return $_forever; | |
| 4965 | + } | |
| 4966 | + | |
| 4967 | + public function set_member_session_data( $member_id ) { | |
| 4968 | + global $wpdb; | |
| 4969 | + | |
| 4970 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 4971 | + $query = $wpdb->prepare( "SELECT * FROM $member_table WHERE ID = %s", $member_id ); | |
| 4972 | + $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 4973 | + if ( ! empty( $member ) ) { | |
| 4974 | + $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 4975 | + $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 4976 | + $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 4977 | + $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 4978 | + $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 4979 | + $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 4980 | + $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 4981 | + $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 4982 | + $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 4983 | + $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 4984 | + $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 4985 | + $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 4986 | + $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 4987 | + $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 4988 | + $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 4989 | + $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 4990 | + $_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? wel_safe_unserialize( $member['mem_delivery'] ) : ''; | |
| 4991 | + $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 4992 | + $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 4993 | + $_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] ); | |
| 4994 | + $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 4995 | + $this->set_session_custom_member( $member['ID'] ); | |
| 4996 | + $this->get_current_member(); | |
| 4997 | + } | |
| 4998 | + return; | |
| 4999 | + } | |
| 5000 | + | |
| 5001 | + public function member_just_login( $email, $pass ) { | |
| 5002 | + global $wpdb; | |
| 5003 | + // $pass = usces_get_hash($pass); | |
| 5004 | + $salt = usces_get_salt( $email ); | |
| 5005 | + $pass = usces_get_hash( $pass, $salt ); | |
| 5006 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 5007 | + | |
| 5008 | + $query = $wpdb->prepare( "SELECT * FROM $member_table WHERE mem_email = %s AND mem_pass = %s", $email, $pass ); | |
| 5009 | + $member = $wpdb->get_row( $query, ARRAY_A ); | |
| 5010 | + if ( empty( $member ) ) { | |
| 5011 | + $this->current_member['email'] = htmlspecialchars( $email, ENT_COMPAT ); | |
| 5012 | + $this->error_message = __( '<b>Error:</b> Password is not correct.', 'usces' ); | |
| 5013 | + return 'login'; | |
| 5014 | + } else { | |
| 5015 | + $_SESSION['usces_member']['ID'] = $member['ID']; | |
| 5016 | + $_SESSION['usces_member']['mailaddress1'] = $member['mem_email']; | |
| 5017 | + $_SESSION['usces_member']['mailaddress2'] = $member['mem_email']; | |
| 5018 | + $_SESSION['usces_member']['point'] = $member['mem_point']; | |
| 5019 | + $_SESSION['usces_member']['name1'] = $member['mem_name1']; | |
| 5020 | + $_SESSION['usces_member']['name2'] = $member['mem_name2']; | |
| 5021 | + $_SESSION['usces_member']['name3'] = $member['mem_name3']; | |
| 5022 | + $_SESSION['usces_member']['name4'] = $member['mem_name4']; | |
| 5023 | + $_SESSION['usces_member']['zipcode'] = $member['mem_zip']; | |
| 5024 | + $_SESSION['usces_member']['pref'] = $member['mem_pref']; | |
| 5025 | + $_SESSION['usces_member']['address1'] = $member['mem_address1']; | |
| 5026 | + $_SESSION['usces_member']['address2'] = $member['mem_address2']; | |
| 5027 | + $_SESSION['usces_member']['address3'] = $member['mem_address3']; | |
| 5028 | + $_SESSION['usces_member']['tel'] = $member['mem_tel']; | |
| 5029 | + $_SESSION['usces_member']['fax'] = $member['mem_fax']; | |
| 5030 | + $_SESSION['usces_member']['delivery_flag'] = $member['mem_delivery_flag']; | |
| 5031 | + $_SESSION['usces_member']['delivery'] = ! empty( $member['mem_delivery'] ) ? wel_safe_unserialize( $member['mem_delivery'] ) : ''; | |
| 5032 | + $_SESSION['usces_member']['registered'] = $member['mem_registered']; | |
| 5033 | + $_SESSION['usces_member']['nicename'] = $member['mem_nicename']; | |
| 5034 | + $_SESSION['usces_member']['country'] = $this->get_member_meta_value( 'customer_country', $member['ID'] ); | |
| 5035 | + $_SESSION['usces_member']['status'] = $member['mem_status']; | |
| 5036 | + $this->set_session_custom_member( $member['ID'] ); | |
| 5037 | + $this->get_current_member(); | |
| 5038 | + | |
| 5039 | + do_action( 'usces_action_after_login' ); | |
| 5040 | + return apply_filters( 'usces_filter_member_login', 'member', $member ); | |
| 5041 | + } | |
| 5042 | + } | |
| 5043 | + | |
| 5044 | + public function member_logout() { | |
| 5045 | + do_action( 'usces_action_before_logout' ); | |
| 5046 | + $cookie = $this->get_cookie(); | |
| 5047 | + $cookie['name'] = ''; | |
| 5048 | + $cookie['rme'] = ''; | |
| 5049 | + $options = get_option( 'usces' ); | |
| 5050 | + | |
| 5051 | + $this->set_cookie( $cookie ); | |
| 5052 | + | |
| 5053 | + $fcookie = $this->get_cookie( $options['usces_key'] ); | |
| 5054 | + | |
| 5055 | + unset( $_SESSION['usces_member'], $_SESSION['usces_entry'] ); | |
| 5056 | + do_action( 'usces_action_member_logout' ); | |
| 5057 | + } | |
| 5058 | + | |
| 5059 | + public function get_current_member() { | |
| 5060 | + if ( isset( $_SESSION['usces_member']['ID'] ) ) { | |
| 5061 | + $this->current_member['id'] = $_SESSION['usces_member']['ID']; | |
| 5062 | + $this->current_member['name'] = usces_localized_name( $_SESSION['usces_member']['name1'], $_SESSION['usces_member']['name2'], 'return' ); | |
| 5063 | + } else { | |
| 5064 | + $this->current_member['id'] = 0; | |
| 5065 | + $this->current_member['name'] = __( 'guest', 'usces' ); | |
| 5066 | + } | |
| 5067 | + } | |
| 5068 | + | |
| 5069 | + public function get_member() { | |
| 5070 | + $res = array( | |
| 5071 | + 'ID' => '', | |
| 5072 | + 'registered' => '', | |
| 5073 | + 'mailaddress1' => '', | |
| 5074 | + 'mailaddress2' => '', | |
| 5075 | + 'password1' => '', | |
| 5076 | + 'password2' => '', | |
| 5077 | + 'point' => '', | |
| 5078 | + 'name1' => '', | |
| 5079 | + 'name2' => '', | |
| 5080 | + 'name3' => '', | |
| 5081 | + 'name4' => '', | |
| 5082 | + 'zipcode' => '', | |
| 5083 | + 'address1' => '', | |
| 5084 | + 'address2' => '', | |
| 5085 | + 'address3' => '', | |
| 5086 | + 'tel' => '', | |
| 5087 | + 'fax' => '', | |
| 5088 | + 'country' => '', | |
| 5089 | + 'pref' => '', | |
| 5090 | + 'status' => '', | |
| 5091 | + ); | |
| 5092 | + if ( ! empty( $_SESSION['usces_member'] ) ) { | |
| 5093 | + foreach ( $_SESSION['usces_member'] as $key => $value ) { | |
| 5094 | + if ( is_array( $_SESSION['usces_member'][ $key ] ) ) { | |
| 5095 | + $res[ $key ] = stripslashes_deep( $value ); | |
| 5096 | + } else { | |
| 5097 | + $res[ $key ] = null !== $value ? stripslashes( $value ) : ''; | |
| 5098 | + } | |
| 5099 | + } | |
| 5100 | + } | |
| 5101 | + return $res; | |
| 5102 | + } | |
| 5103 | + | |
| 5104 | + public function get_member_info( $mid ) { | |
| 5105 | + global $wpdb; | |
| 5106 | + $infos = array(); | |
| 5107 | + $table = usces_get_tablename( 'usces_member' ); | |
| 5108 | + $query = $wpdb->prepare( "SELECT * FROM $table WHERE ID = %d", $mid ); | |
| 5109 | + $datas = $wpdb->get_results( $query, ARRAY_A ); | |
| 5110 | + if ( $datas ) { | |
| 5111 | + $infos = $datas[0]; | |
| 5112 | + | |
| 5113 | + $table = usces_get_tablename( 'usces_member_meta' ); | |
| 5114 | + $query = $wpdb->prepare( "SELECT meta_key, meta_value FROM $table WHERE member_id = %d", $mid ); | |
| 5115 | + $metas = $wpdb->get_results( $query, ARRAY_A ); | |
| 5116 | + | |
| 5117 | + foreach ( $metas as $meta ) { | |
| 5118 | + $infos[ $meta['meta_key'] ] = wel_safe_maybe_unserialize( $meta['meta_value'] ); | |
| 5119 | + } | |
| 5120 | + } | |
| 5121 | + return $infos; | |
| 5122 | + } | |
| 5123 | + | |
| 5124 | + public function set_member_info( $data = array(), $mid = '' ) { | |
| 5125 | + global $wpdb; | |
| 5126 | + | |
| 5127 | + $table = usces_get_tablename( 'usces_member' ); | |
| 5128 | + $res = $wpdb->update( $table, $data, array( 'ID' => $mid ), null, array( '%d' ) ); | |
| 5129 | + return $res; | |
| 5130 | + } | |
| 5131 | + | |
| 5132 | + public function check_member_email( $email ) { | |
| 5133 | + global $wpdb; | |
| 5134 | + | |
| 5135 | + $member_table_name = usces_get_tablename( 'usces_member' ); | |
| 5136 | + $query = $wpdb->prepare( "SELECT ID FROM $member_table_name WHERE mem_email = %s", trim( $email ) ); | |
| 5137 | + $id = $wpdb->get_var( $query ); | |
| 5138 | + return $id; | |
| 5139 | + } | |
| 5140 | + | |
| 5141 | + public function is_order( $mid, $oid ) { | |
| 5142 | + global $wpdb; | |
| 5143 | + | |
| 5144 | + $mid = (int) $mid; | |
| 5145 | + $oid = (int) $oid; | |
| 5146 | + | |
| 5147 | + $table = $wpdb->prefix . 'usces_order'; | |
| 5148 | + $query = $wpdb->prepare( "SELECT ID FROM $table WHERE ID = %d AND mem_id = %d", $oid, $mid ); | |
| 5149 | + $mem_id = $wpdb->get_var( $query ); | |
| 5150 | + if ( empty( $mem_id ) ) { | |
| 5151 | + return false; | |
| 5152 | + } else { | |
| 5153 | + return true; | |
| 5154 | + } | |
| 5155 | + } | |
| 5156 | + | |
| 5157 | + public function is_purchased_item( $mid, $post_id, $sku = null, $order_id = null ) { | |
| 5158 | + global $wpdb; | |
| 5159 | + $res = false; | |
| 5160 | + | |
| 5161 | + if ( empty( $order_id ) ) { | |
| 5162 | + $history = $this->get_member_history( $mid, true ); | |
| 5163 | + foreach ( $history as $umhs ) { | |
| 5164 | + $cart = $umhs['cart']; | |
| 5165 | + $status = $umhs['order_status']; | |
| 5166 | + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0; | |
| 5167 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 5168 | + $cart_row = $cart[ $i ]; | |
| 5169 | + $sku_code = urldecode( $cart_row['sku'] ); | |
| 5170 | + if ( empty( $sku ) ) { | |
| 5171 | + if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) { | |
| 5172 | + $res = true; | |
| 5173 | + break 2; | |
| 5174 | + } elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) { | |
| 5175 | + $res = 'noreceipt'; | |
| 5176 | + break 2; | |
| 5177 | + } | |
| 5178 | + } else { | |
| 5179 | + if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) ) ) { | |
| 5180 | + $res = true; | |
| 5181 | + break 2; | |
| 5182 | + } elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && (false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) ) ) { | |
| 5183 | + $res = 'noreceipt'; | |
| 5184 | + break 2; | |
| 5185 | + } | |
| 5186 | + } | |
| 5187 | + } | |
| 5188 | + } | |
| 5189 | + } else { | |
| 5190 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 5191 | + $query = $wpdb->prepare( "SELECT order_status FROM $order_table_name WHERE ID = %d AND mem_id = %d", | |
| 5192 | + $order_id, $mid | |
| 5193 | + ); | |
| 5194 | + $order = $wpdb->get_row( $query ); | |
| 5195 | + if ( is_null( $order ) ) { // 該当の受注データが一件も見つからなかった場合、購入していないと判断する. | |
| 5196 | + $res = false; | |
| 5197 | + } else { // 該当の受注データが見つかった場合には受注ステータスを確認する処理を行う. | |
| 5198 | + $status = $order->order_status; | |
| 5199 | + $cart = usces_get_ordercartdata( $order_id ); | |
| 5200 | + foreach ( $cart as $cart_row ) { | |
| 5201 | + $sku_code = urldecode( $cart_row['sku'] ); | |
| 5202 | + if ( empty( $sku ) ) { | |
| 5203 | + if ( $cart_row['post_id'] == $post_id && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) { | |
| 5204 | + $res = true; | |
| 5205 | + break; | |
| 5206 | + } elseif ( $cart_row['post_id'] == $post_id && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) { | |
| 5207 | + $res = 'noreceipt'; | |
| 5208 | + break; | |
| 5209 | + } | |
| 5210 | + } else { | |
| 5211 | + if ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false === strpos( $status, 'noreceipt' ) && false === strpos( $status, 'pending' ) && false === strpos( $status, 'cancel' ) ) ) { | |
| 5212 | + $res = true; | |
| 5213 | + break; | |
| 5214 | + } elseif ( $cart_row['post_id'] == $post_id && $sku_code == $sku && ( false !== strpos( $status, 'noreceipt' ) || false !== strpos( $status, 'pending' ) || false !== strpos( $status, 'cancel' ) ) ) { | |
| 5215 | + $res = 'noreceipt'; | |
| 5216 | + break; | |
| 5217 | + } | |
| 5218 | + } | |
| 5219 | + } | |
| 5220 | + } | |
| 5221 | + } | |
| 5222 | + | |
| 5223 | + return apply_filters( 'usces_filter_is_purchased_item', $res, $mid, $post_id, $sku, $order_id ); | |
| 5224 | + } | |
| 5225 | + | |
| 5226 | + public function get_order_data( $order_id, $mode = '' ) { | |
| 5227 | + global $wpdb; | |
| 5228 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 5229 | + | |
| 5230 | + $query = $wpdb->prepare( "SELECT * FROM $order_table WHERE ID = %d", $order_id ); | |
| 5231 | + | |
| 5232 | + if ( 'direct' == $mode ) { | |
| 5233 | + $value = $wpdb->get_row( $query, ARRAY_A ); | |
| 5234 | + return $value; | |
| 5235 | + } | |
| 5236 | + | |
| 5237 | + $value = $wpdb->get_row( $query ); | |
| 5238 | + | |
| 5239 | + if ( null == $value ) { | |
| 5240 | + return false; | |
| 5241 | + } else { | |
| 5242 | + $res = array(); | |
| 5243 | + } | |
| 5244 | + if ( strpos( $value->order_status, 'cancel' ) !== false || strpos( $value->order_status, 'estimate' ) !== false ) { | |
| 5245 | + return false; | |
| 5246 | + } | |
| 5247 | + | |
| 5248 | + $total_price = $value->order_item_total_price - $value->order_usedpoint + $value->order_discount + $value->order_shipping_charge + $value->order_cod_fee + $value->order_tax; | |
| 5249 | + if ( $total_price < 0 ) { | |
| 5250 | + $total_price = 0; | |
| 5251 | + } | |
| 5252 | + $res = array( | |
| 5253 | + 'ID' => $value->ID, | |
| 5254 | + 'mem_id' => $value->mem_id, | |
| 5255 | + 'cart' => wel_safe_unserialize( $value->order_cart ), | |
| 5256 | + 'condition' => wel_safe_unserialize( $value->order_condition ), | |
| 5257 | + 'getpoint' => $value->order_getpoint, | |
| 5258 | + 'usedpoint' => $value->order_usedpoint, | |
| 5259 | + 'discount' => $value->order_discount, | |
| 5260 | + 'payment_name' => $value->order_payment_name, | |
| 5261 | + 'shipping_charge' => $value->order_shipping_charge, | |
| 5262 | + 'cod_fee' => $value->order_cod_fee, | |
| 5263 | + 'tax' => $value->order_tax, | |
| 5264 | + 'end_price' => $total_price, | |
| 5265 | + 'status' => $value->order_status, | |
| 5266 | + 'date' => mysql2date( __( 'Y/m/d' ), $value->order_date ), | |
| 5267 | + 'modified' => mysql2date( __( 'Y/m/d' ), $value->order_modified ), | |
| 5268 | + ); | |
| 5269 | + | |
| 5270 | + return $res; | |
| 5271 | + } | |
| 5272 | + | |
| 5273 | + public function get_orderIDs_by_postID( $mem_id, $post_id ) { | |
| 5274 | + global $wpdb; | |
| 5275 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 5276 | + | |
| 5277 | + $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 ); | |
| 5278 | + $rows = $wpdb->get_query( $query, ARRAY_A ); | |
| 5279 | + | |
| 5280 | + if ( null == $value ) { | |
| 5281 | + return false; | |
| 5282 | + } else { | |
| 5283 | + foreach ( $rows as $row ) { | |
| 5284 | + if ( strpos( $row['order_status'], 'cancel' ) !== false || strpos( $row['order_status'], 'estimate' ) !== false ) { | |
| 5285 | + continue; | |
| 5286 | + } else { | |
| 5287 | + $carts = wel_safe_unserialize( $row['order_cart'] ); | |
| 5288 | + foreach ( $carts as $cart ) { | |
| 5289 | + if ( $post_id == $cart['post_id'] ) { | |
| 5290 | + $res[] = $row['ID']; | |
| 5291 | + break; | |
| 5292 | + } | |
| 5293 | + } | |
| 5294 | + } | |
| 5295 | + } | |
| 5296 | + } | |
| 5297 | + return $res; | |
| 5298 | + } | |
| 5299 | + | |
| 5300 | + public function incart_check() { | |
| 5301 | + $mes = array(); | |
| 5302 | + | |
| 5303 | + $ids = array_keys( $_POST['inCart'] ); | |
| 5304 | + $post_id = $ids[0]; | |
| 5305 | + $skus = array_keys( $_POST['inCart'][ $post_id ] ); | |
| 5306 | + $sku = $skus[0]; | |
| 5307 | + $sku_code = urldecode( $sku ); | |
| 5308 | + $quant = isset( $_POST['quant'][ $post_id ][ $sku ] ) ? (int) $_POST['quant'][ $post_id ][ $sku ] : 1; | |
| 5309 | + $stock = $this->getItemZaikoNum( $post_id, $sku ); | |
| 5310 | + $zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku ); | |
| 5311 | + $product = wel_get_product( $post_id ); | |
| 5312 | + $itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : ''; | |
| 5313 | + $itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id ); | |
| 5314 | + | |
| 5315 | + if ( 1 > $quant ) { | |
| 5316 | + $mes[ $post_id ][ $sku ] = __( 'enter the correct amount', 'usces' ) . '<br />'; | |
| 5317 | + } elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) { | |
| 5318 | + $mes[ $post_id ][ $sku ] = sprintf( __( 'This article is limited by %d at a time.', 'usces' ), $itemRestriction ) . '<br />'; | |
| 5319 | + } elseif ( 1 != $itemOrderAcceptable && $quant > (int) $stock && ! WCUtils::is_blank( $stock ) ) { | |
| 5320 | + $mes[ $post_id ][ $sku ] = __( 'Sorry, stock is insufficient.', 'usces' ) . ' ' . __( 'Current stock', 'usces' ) . $stock . '<br />'; | |
| 5321 | + } elseif ( 1 != $itemOrderAcceptable && !$this->is_item_zaiko( $post_id, $sku_code ) ) { | |
| 5322 | + $mes[ $post_id ][ $sku ] = __( 'Sorry, this item is sold out.', 'usces' ) . '<br />'; | |
| 5323 | + } else { | |
| 5324 | + $mes[ $post_id ][ $sku ] = ''; | |
| 5325 | + } | |
| 5326 | + | |
| 5327 | + $ioptkeys = $this->get_itemOptionKey( $post_id, true ); | |
| 5328 | + if ( $ioptkeys ) { | |
| 5329 | + foreach ( $ioptkeys as $key => $value ) { | |
| 5330 | + $optValues = $this->get_itemOptions( urldecode( $value ), $post_id ); | |
| 5331 | + if ( 0 == $optValues['means'] ) { // case of select. | |
| 5332 | + if ( $optValues['essential'] && '#NONE#' == $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) { | |
| 5333 | + $mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />'; | |
| 5334 | + } | |
| 5335 | + } elseif ( 1 == $optValues['means'] ) { // case of multiselect. | |
| 5336 | + if ( $optValues['essential'] ) { | |
| 5337 | + $mselect = 0; | |
| 5338 | + foreach ( (array) $_POST['itemOption'][ $post_id ][ $sku ][ $value ] as $mvalue ) { | |
| 5339 | + if ( ! empty( $mvalue ) && '#NONE#' != $mvalue ) { | |
| 5340 | + $mselect++; | |
| 5341 | + } | |
| 5342 | + } | |
| 5343 | + if ( $mselect == 0 ) { | |
| 5344 | + $mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />'; | |
| 5345 | + } | |
| 5346 | + } | |
| 5347 | + } elseif ( in_array( $optValues['means'], array( 3, 4 ) ) ) { // case of radio & checkbox. | |
| 5348 | + if ( $optValues['essential'] ) { | |
| 5349 | + if ( ! isset( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) { | |
| 5350 | + $mes[ $post_id ][ $sku ] .= sprintf( __( 'Chose the %s', 'usces' ), urldecode( $value ) ) . '<br />'; | |
| 5351 | + } | |
| 5352 | + } | |
| 5353 | + } else { // case of text. | |
| 5354 | + if ( $optValues['essential'] && WCUtils::is_blank( $_POST['itemOption'][ $post_id ][ $sku ][ $value ] ) ) { | |
| 5355 | + $mes[ $post_id ][ $sku ] .= sprintf( __( 'Input the %s', 'usces' ), urldecode( $value ) ) . '<br />'; | |
| 5356 | + } | |
| 5357 | + } | |
| 5358 | + } | |
| 5359 | + } | |
| 5360 | + | |
| 5361 | + $mes = apply_filters( 'usces_filter_incart_check', $mes, $post_id, $sku ); | |
| 5362 | + | |
| 5363 | + if ( isset( $mes[ $post_id ] ) && is_array( $mes[ $post_id ] ) ) { | |
| 5364 | + $rembr = array(); | |
| 5365 | + foreach ( $mes[ $post_id ] as $skukey => $skuvalue ) { | |
| 5366 | + if ( ! empty( $skuvalue ) ) { | |
| 5367 | + $rembr[ $post_id ][ $skukey ] = preg_replace( '/<br\s*\/?>\s*$/', '', $skuvalue ); | |
| 5368 | + } | |
| 5369 | + } | |
| 5370 | + $mes = $rembr; | |
| 5371 | + } | |
| 5372 | + | |
| 5373 | + if ( ! empty( $mes ) ) { | |
| 5374 | + $_SESSION['usces_singleitem']['itemOption'] = isset( $_POST['itemOption'] ) ? $_POST['itemOption'] : array(); | |
| 5375 | + $_SESSION['usces_singleitem']['quant'] = isset( $_POST['quant'] ) ? (int) $_POST['quant'] : 1; | |
| 5376 | + $_SESSION['usces_singleitem']['error_message'] = $mes; | |
| 5377 | + if ( false === strpos( $_POST['usces_referer'], 'http' ) ) { | |
| 5378 | + $parse_url = parse_url( get_home_url() ); | |
| 5379 | + $port = ''; | |
| 5380 | + if ( isset( $parse_url['port'] ) && ! empty( $parse_url['port'] ) ) { | |
| 5381 | + $port = ':' . $parse_url['port']; | |
| 5382 | + } | |
| 5383 | + 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 ) ); | |
| 5384 | + } else { | |
| 5385 | + header( 'location: ' . esc_url( $_POST['usces_referer'] ) . apply_filters( 'usces_filter_incart_redirect', '#cart_button', $post_id, $sku ) ); | |
| 5386 | + } | |
| 5387 | + exit; | |
| 5388 | + } | |
| 5389 | + | |
| 5390 | + do_action( 'usces_action_incart_checked', $mes, $post_id, $sku ); | |
| 5391 | + } | |
| 5392 | + | |
| 5393 | + public function zaiko_check() { | |
| 5394 | + | |
| 5395 | + $logged_in_member = $this->get_member(); | |
| 5396 | + if ( ! empty( $logged_in_member['ID'] ) ) { | |
| 5397 | + if ( ! $this->member_exists( $logged_in_member['ID'] ) ) { | |
| 5398 | + $mes = __( 'Your membership information could not be verified.', 'usces' ); | |
| 5399 | + $this->error_message = $mes; | |
| 5400 | + $this->member_logout(); | |
| 5401 | + return $mes; | |
| 5402 | + } | |
| 5403 | + } | |
| 5404 | + | |
| 5405 | + $mes = ''; | |
| 5406 | + $cart = $this->cart->get_cart(); | |
| 5407 | + $stocks = array(); | |
| 5408 | + | |
| 5409 | + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0; | |
| 5410 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 5411 | + $cart_row = $cart[ $i ]; | |
| 5412 | + $post_id = $cart_row['post_id']; | |
| 5413 | + $sku = $cart_row['sku']; | |
| 5414 | + $sku_code = urldecode( $cart_row['sku'] ); | |
| 5415 | + | |
| 5416 | + $quant = ( isset( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) ) ? trim( $_POST['quant'][ $i ][ $post_id ][ $sku ] ) : $cart_row['quantity']; | |
| 5417 | + $zaiko_id = (int) $this->getItemZaikoStatusId( $post_id, $sku_code ); | |
| 5418 | + $stock = $this->getItemZaikoNum( $post_id, $sku_code ); | |
| 5419 | + if ( ! isset( $stocks[ $post_id ][ $sku ] ) ) { | |
| 5420 | + if ( ! WCUtils::is_blank( $stock ) ) { | |
| 5421 | + $stocks[ $post_id ][ $sku ] = $stock; | |
| 5422 | + } else { | |
| 5423 | + $stocks[ $post_id ][ $sku ] = null; | |
| 5424 | + } | |
| 5425 | + } | |
| 5426 | + $checkstock = $stocks[ $post_id ][ $sku ]; | |
| 5427 | + $stocks[ $post_id ][ $sku ] = $stocks[ $post_id ][ $sku ] - $quant; | |
| 5428 | + $product = wel_get_product( $post_id ); | |
| 5429 | + $itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : ''; | |
| 5430 | + $itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id ); | |
| 5431 | + $post_status = get_post_status( $post_id ); | |
| 5432 | + | |
| 5433 | + if ( 1 > (int) $quant ) { | |
| 5434 | + $mes .= sprintf( __( 'Enter the correct amount for the No.%d item.', 'usces' ), ( $i + 1 ) ) . '<br />'; | |
| 5435 | + } elseif ( ! $this->is_item_zaiko( $post_id, $sku_code ) || ( 1 != $itemOrderAcceptable && WCUtils::is_zero( $stock ) ) || 'publish' != $post_status ) { | |
| 5436 | + $mes .= sprintf( __( 'Sorry, No.%d item is sold out.', 'usces' ), ( $i + 1 ) ) . '<br />'; | |
| 5437 | + } elseif ( $quant > (int) $itemRestriction && ! WCUtils::is_blank( $itemRestriction ) && ! WCUtils::is_zero( $itemRestriction ) ) { | |
| 5438 | + $mes .= sprintf( __( 'This article is limited by %1$d at a time for the No.%2$d item.', 'usces' ), $itemRestriction, ( $i + 1 ) ) . '<br />'; | |
| 5439 | + } elseif ( 1 != $itemOrderAcceptable && 0 > $stocks[ $post_id ][ $sku ] && ! WCUtils::is_blank( $stock ) ) { | |
| 5440 | + $mes .= sprintf( __( 'Stock of No.%1$d item is remainder %2$d.', 'usces' ), ( $i + 1 ), $checkstock ) . '<br />'; | |
| 5441 | + } | |
| 5442 | + } | |
| 5443 | + $mes = apply_filters( 'usces_filter_zaiko_check', $mes, $cart); | |
| 5444 | + return $mes; | |
| 5445 | + } | |
| 5446 | + | |
| 5447 | + /** | |
| 5448 | + * Check if the member exists in the database or not. | |
| 5449 | + * | |
| 5450 | + * @param integer $member_id The id of the member. | |
| 5451 | + * @return boolean true/false | |
| 5452 | + */ | |
| 5453 | + public function member_exists( $member_id ) { | |
| 5454 | + $member_info = $this->get_member_info( $member_id ); | |
| 5455 | + if ( empty( $member_info ) ) { | |
| 5456 | + return false; | |
| 5457 | + } else { | |
| 5458 | + return true; | |
| 5459 | + } | |
| 5460 | + } | |
| 5461 | + | |
| 5462 | + public function get_pwd_errors( $password ) { | |
| 5463 | + if ( WCUtils::is_blank( $password ) ) { | |
| 5464 | + return __( 'Please enter a password.', 'usces' ) . '<br />'; | |
| 5465 | + } | |
| 5466 | + | |
| 5467 | + $ret = ''; | |
| 5468 | + $system_option = $this->options['system']; | |
| 5469 | + $pwd_rule_min = $system_option['member_pass_rule_min']; | |
| 5470 | + $pwd_rule_max = empty( $system_option['member_pass_rule_max'] ) ? 30 : $system_option['member_pass_rule_max']; | |
| 5471 | + if ( strlen( $password ) < $pwd_rule_min || strlen( $password ) > $pwd_rule_max ) { | |
| 5472 | + if ( $pwd_rule_min === $pwd_rule_max ) { | |
| 5473 | + $rule = sprintf( __( '%s characters long', 'usces' ), $pwd_rule_min ); | |
| 5474 | + } else { | |
| 5475 | + $rule = sprintf( __( '%1$s characters and no more than %2$s characters', 'usces' ), $pwd_rule_min, $pwd_rule_max ); | |
| 5476 | + } | |
| 5477 | + $ret .= sprintf( __( 'Password must be at least %s.', 'usces' ), $rule ) . '<br />'; | |
| 5478 | + } | |
| 5479 | + if ( ! empty( $system_option['member_pass_rule_upercase'] ) && ! preg_match( '@[A-Z]@', $password ) ) { | |
| 5480 | + $ret .= __( 'Password must contain at least one upper-case alphabetics character.', 'usces' ) . '<br />'; | |
| 5481 | + } | |
| 5482 | + if ( ! empty( $system_option['member_pass_rule_lowercase'] ) && ! preg_match( '@[a-z]@', $password ) ) { | |
| 5483 | + $ret .= __( 'Password must contain at least one lower-case alphabetics character.', 'usces' ) . '<br />'; | |
| 5484 | + } | |
| 5485 | + if ( ! empty( $system_option['member_pass_rule_digit'] ) && ! preg_match( '@[0-9]@', $password ) ) { | |
| 5486 | + $ret .= __( 'Password must contain at least one numeric character.', 'usces' ) . '<br />'; | |
| 5487 | + } | |
| 5488 | + if ( ! empty( $system_option['member_pass_rule_symbol'] ) && ! preg_match( '@[\W]@', $password ) ) { | |
| 5489 | + $ret .= __( 'Password must contain at least one symbolic character.', 'usces' ) . '<br />'; | |
| 5490 | + } | |
| 5491 | + | |
| 5492 | + return $ret; | |
| 5493 | + } | |
| 5494 | + | |
| 5495 | + public function member_check() { | |
| 5496 | + do_action( 'usces_action_before_member_check' ); | |
| 5497 | + | |
| 5498 | + $mes = ''; | |
| 5499 | + $usces_member_old = $_SESSION['usces_member']; | |
| 5500 | + foreach ( $_POST['member'] as $key => $vlue ) { | |
| 5501 | + if ( 'password1' !== $key && 'password2' !== $key && 'mailaddress2' !== $key ) { | |
| 5502 | + $_SESSION['usces_member'][ $key ] = trim( $vlue ); | |
| 5503 | + } | |
| 5504 | + } | |
| 5505 | + | |
| 5506 | + if ( 'newmemberform' == $_POST['member_regmode'] || | |
| 5507 | + ( 'editmemberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) || | |
| 5508 | + ( 'updatememberform' === $_POST['member_regmode'] && ! ( WCUtils::is_blank( $_POST['member']['password1'] ) && WCUtils::is_blank( $_POST['member']['password2'] ) ) ) ) { | |
| 5509 | + $mes = $this->get_pwd_errors( $_POST['member']['password1'] ); | |
| 5510 | + } | |
| 5511 | + | |
| 5512 | + if ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) { | |
| 5513 | + if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) { | |
| 5514 | + $mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />'; | |
| 5515 | + } | |
| 5516 | + if ( ! is_email( $_POST['member']['mailaddress1'] ) || WCUtils::is_blank( $_POST['member']['mailaddress1'] ) ) { | |
| 5517 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5518 | + } else { | |
| 5519 | + $this->get_current_member(); | |
| 5520 | + $mem_id = $this->current_member['id']; | |
| 5521 | + $id = $this->check_member_email( $_POST['member']['mailaddress1'] ); | |
| 5522 | + if ( ! empty( $id ) && $id != $mem_id ) { | |
| 5523 | + $mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '<br />'; | |
| 5524 | + } else { | |
| 5525 | + if ( isset( $_POST['member']['mailaddress2'] ) ) { | |
| 5526 | + if ( WCUtils::is_blank( $_POST['member']['mailaddress2'] ) ) { | |
| 5527 | + if ( $usces_member_old['mailaddress1'] !== $_POST['member']['mailaddress1'] ) { | |
| 5528 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5529 | + } | |
| 5530 | + } else { | |
| 5531 | + if ( trim( $_POST['member']['mailaddress1'] ) != trim( $_POST['member']['mailaddress2'] ) ) { | |
| 5532 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5533 | + } | |
| 5534 | + } | |
| 5535 | + } | |
| 5536 | + } | |
| 5537 | + } | |
| 5538 | + } elseif ( 'newmemberform' == $_POST['member_regmode'] ) { | |
| 5539 | + if ( trim( $_POST['member']['password1'] ) != trim( $_POST['member']['password2'] ) ) { | |
| 5540 | + $mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />'; | |
| 5541 | + } | |
| 5542 | + 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'] ) ) { | |
| 5543 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5544 | + } else { | |
| 5545 | + $id = $this->check_member_email( $_POST['member']['mailaddress1'] ); | |
| 5546 | + if ( ! empty( $id ) ) { | |
| 5547 | + $mes .= __( 'This e-mail address can not be registered.', 'usces' ) . '<br />'; | |
| 5548 | + } | |
| 5549 | + } | |
| 5550 | + } else { | |
| 5551 | + $mes .= __( 'ERROR: I was not able to complete collective operation', 'usces' ) . '<br />'; | |
| 5552 | + } | |
| 5553 | + if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) { | |
| 5554 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5555 | + } | |
| 5556 | + | |
| 5557 | + $zip_check = false; | |
| 5558 | + $addressform = $this->options['system']['addressform']; | |
| 5559 | + $applyform = usces_get_apply_addressform( $addressform ); | |
| 5560 | + if ( 'JP' === $applyform ) { | |
| 5561 | + if ( isset( $_POST['member']['country'] ) ) { | |
| 5562 | + if ( 'JP' === $_POST['member']['country'] ) { | |
| 5563 | + $zip_check = true; | |
| 5564 | + } | |
| 5565 | + } else { | |
| 5566 | + $base = usces_get_base_country(); | |
| 5567 | + if ( 'JP' === $base ) { | |
| 5568 | + $zip_check = true; | |
| 5569 | + } | |
| 5570 | + } | |
| 5571 | + } | |
| 5572 | + $zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check ); | |
| 5573 | + if ( WCUtils::is_blank( $_POST['member']['zipcode'] ) ) { | |
| 5574 | + if ( usces_is_required_field('zipcode') ) { | |
| 5575 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5576 | + } | |
| 5577 | + } else { | |
| 5578 | + if ( $zip_check ) { | |
| 5579 | + if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['member']['zipcode'] ) ) { | |
| 5580 | + $_SESSION['usces_member']['zipcode'] = usces_convert_zipcode( $_POST['member']['zipcode'] ); | |
| 5581 | + } | |
| 5582 | + if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_member']['zipcode'] ) ) { | |
| 5583 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5584 | + } | |
| 5585 | + } | |
| 5586 | + } | |
| 5587 | + if ( __( '-- Select --', 'usces_dual' ) == $_POST['member']['pref'] && usces_is_required_field( 'states' ) ) { | |
| 5588 | + $mes .= __( 'enter the prefecture', 'usces' ) . '<br />'; | |
| 5589 | + } | |
| 5590 | + if ( WCUtils::is_blank( $_POST['member']['address1'] ) && usces_is_required_field( 'address1' ) ) { | |
| 5591 | + $mes .= __( 'enter the city name', 'usces' ) . '<br />'; | |
| 5592 | + } | |
| 5593 | + if ( WCUtils::is_blank( $_POST['member']['address2'] ) && usces_is_required_field( 'address2' ) ) { | |
| 5594 | + $mes .= __( 'enter house numbers', 'usces' ) . '<br />'; | |
| 5595 | + } | |
| 5596 | + if ( WCUtils::is_blank( $_POST['member']['tel'] ) && usces_is_required_field( 'tel' ) ) { | |
| 5597 | + $mes .= __( 'enter phone numbers', 'usces' ) . '<br />'; | |
| 5598 | + } | |
| 5599 | + if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) && usces_is_required_field( 'tel' ) ) { | |
| 5600 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5601 | + } | |
| 5602 | + | |
| 5603 | + if ( 'editmemberform' !== $_POST['member_regmode'] && 'updatememberform' !== $_POST['member_regmode'] && isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) { | |
| 5604 | + if ( ! isset( $_POST['agree_member_check'] ) ) { | |
| 5605 | + $mes .= __( 'Please accept the membership agreement.', 'usces' ) . '<br />'; | |
| 5606 | + } | |
| 5607 | + } | |
| 5608 | + | |
| 5609 | + $mes = apply_filters( 'usces_filter_member_check', $mes ); | |
| 5610 | + | |
| 5611 | + if ( ( 'editmemberform' == $_POST['member_regmode'] || 'updatememberform' == $_POST['member_regmode'] ) && '' != $mes ) { | |
| 5612 | + $_SESSION['usces_member'] = $usces_member_old; | |
| 5613 | + } | |
| 5614 | + | |
| 5615 | + return $mes; | |
| 5616 | + } | |
| 5617 | + | |
| 5618 | + public function member_check_fromcart() { | |
| 5619 | + | |
| 5620 | + do_action( 'usces_action_before_member_check_fromcart' ); | |
| 5621 | + | |
| 5622 | + $mes = $this->get_pwd_errors( $_POST['customer']['password1'] ); | |
| 5623 | + | |
| 5624 | + if ( trim( $_POST['customer']['password1'] ) != trim( $_POST['customer']['password2'] ) ) { | |
| 5625 | + $mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />'; | |
| 5626 | + } | |
| 5627 | + 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'] ) ) { | |
| 5628 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5629 | + } | |
| 5630 | + if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) { | |
| 5631 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5632 | + } | |
| 5633 | + $zip_check = false; | |
| 5634 | + $addressform = $this->options['system']['addressform']; | |
| 5635 | + $applyform = usces_get_apply_addressform( $addressform ); | |
| 5636 | + if ( 'JP' === $applyform ) { | |
| 5637 | + if ( isset( $_POST['customer']['country'] ) ) { | |
| 5638 | + if ( 'JP' === $_POST['customer']['country'] ) { | |
| 5639 | + $zip_check = true; | |
| 5640 | + } | |
| 5641 | + } else { | |
| 5642 | + $base = usces_get_base_country(); | |
| 5643 | + if ( 'JP' === $base ) { | |
| 5644 | + $zip_check = true; | |
| 5645 | + } | |
| 5646 | + } | |
| 5647 | + } | |
| 5648 | + $zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check ); | |
| 5649 | + if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) { | |
| 5650 | + if ( usces_is_required_field( 'zipcode' ) ) { | |
| 5651 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5652 | + } | |
| 5653 | + } else { | |
| 5654 | + if ( $zip_check ) { | |
| 5655 | + if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) { | |
| 5656 | + $_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] ); | |
| 5657 | + } | |
| 5658 | + if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) { | |
| 5659 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5660 | + } | |
| 5661 | + } | |
| 5662 | + } | |
| 5663 | + if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) { | |
| 5664 | + $mes .= __( 'enter the prefecture', 'usces' ) . '<br />'; | |
| 5665 | + } | |
| 5666 | + if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) { | |
| 5667 | + $mes .= __( 'enter the city name', 'usces' ) . '<br />'; | |
| 5668 | + } | |
| 5669 | + if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) { | |
| 5670 | + $mes .= __( 'enter house numbers', 'usces' ) . '<br />'; | |
| 5671 | + } | |
| 5672 | + if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) { | |
| 5673 | + $mes .= __( 'enter phone numbers', 'usces' ) . '<br />'; | |
| 5674 | + } | |
| 5675 | + if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) { | |
| 5676 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5677 | + } | |
| 5678 | + | |
| 5679 | + if ( isset( $this->options['agree_member'] ) && 'activate' === $this->options['agree_member'] ) { | |
| 5680 | + if ( ! isset( $_POST['agree_member_check'] ) ) { | |
| 5681 | + $mes .= __( 'Please accept the membership agreement.', 'usces' ) . '<br />'; | |
| 5682 | + } | |
| 5683 | + } | |
| 5684 | + | |
| 5685 | + $mes = apply_filters( 'usces_filter_member_check_fromcart', $mes ); | |
| 5686 | + | |
| 5687 | + return $mes; | |
| 5688 | + } | |
| 5689 | + | |
| 5690 | + public function admin_member_check() { | |
| 5691 | + global $wpdb; | |
| 5692 | + $mes = ''; | |
| 5693 | + if ( ! is_email( trim( $_POST['member']['email'] ) ) ) { | |
| 5694 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5695 | + } else { | |
| 5696 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 5697 | + $mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) ); | |
| 5698 | + if ( trim( $_POST['member']['email'] ) != $mem_email ) { | |
| 5699 | + $mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) ); | |
| 5700 | + if ( ! empty( $mem_ID ) ) { | |
| 5701 | + $mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '<br />'; | |
| 5702 | + } | |
| 5703 | + } | |
| 5704 | + } | |
| 5705 | + if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) { | |
| 5706 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5707 | + } | |
| 5708 | + if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) { | |
| 5709 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5710 | + } | |
| 5711 | + $mes = apply_filters( 'usces_filter_admin_member_check', $mes ); | |
| 5712 | + | |
| 5713 | + return $mes; | |
| 5714 | + } | |
| 5715 | + | |
| 5716 | + public function customer_check() { | |
| 5717 | + | |
| 5718 | + do_action( 'usces_action_before_customer_check' ); | |
| 5719 | + | |
| 5720 | + $mes = ''; | |
| 5721 | + 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'] ) ) { | |
| 5722 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5723 | + } | |
| 5724 | + if ( WCUtils::is_blank( $_POST['customer']['name1'] ) ) { | |
| 5725 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5726 | + } | |
| 5727 | + $zip_check = false; | |
| 5728 | + $addressform = $this->options['system']['addressform']; | |
| 5729 | + $applyform = usces_get_apply_addressform( $addressform ); | |
| 5730 | + if ( 'JP' === $applyform ) { | |
| 5731 | + if ( isset( $_POST['customer']['country'] ) ) { | |
| 5732 | + if ( 'JP' === $_POST['customer']['country'] ) { | |
| 5733 | + $zip_check = true; | |
| 5734 | + } | |
| 5735 | + } else { | |
| 5736 | + $base = usces_get_base_country(); | |
| 5737 | + if ( 'JP' === $base ) { | |
| 5738 | + $zip_check = true; | |
| 5739 | + } | |
| 5740 | + } | |
| 5741 | + } | |
| 5742 | + $zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check ); | |
| 5743 | + if ( WCUtils::is_blank( $_POST['customer']['zipcode'] ) ) { | |
| 5744 | + if ( usces_is_required_field( 'zipcode' ) ) { | |
| 5745 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5746 | + } | |
| 5747 | + } else { | |
| 5748 | + if ( $zip_check ) { | |
| 5749 | + if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'] ) ) { | |
| 5750 | + $_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode( $_POST['customer']['zipcode'] ); | |
| 5751 | + } | |
| 5752 | + if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'] ) ) { | |
| 5753 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5754 | + } | |
| 5755 | + } | |
| 5756 | + } | |
| 5757 | + if ( ( __( '-- Select --', 'usces' ) == $_POST['customer']['pref'] || '-- Select --' == $_POST['customer']['pref'] ) && usces_is_required_field( 'states' ) ) { | |
| 5758 | + $mes .= __( 'enter the prefecture', 'usces' ) . '<br />'; | |
| 5759 | + } | |
| 5760 | + if ( WCUtils::is_blank( $_POST['customer']['address1'] ) && usces_is_required_field( 'address1' ) ) { | |
| 5761 | + $mes .= __( 'enter the city name', 'usces' ) . '<br />'; | |
| 5762 | + } | |
| 5763 | + if ( WCUtils::is_blank( $_POST['customer']['address2'] ) && usces_is_required_field( 'address2' ) ) { | |
| 5764 | + $mes .= __( 'enter house numbers', 'usces' ) . '<br />'; | |
| 5765 | + } | |
| 5766 | + if ( WCUtils::is_blank( $_POST['customer']['tel'] ) && usces_is_required_field( 'tel' ) ) { | |
| 5767 | + $mes .= __( 'enter phone numbers', 'usces' ) . '<br />'; | |
| 5768 | + } | |
| 5769 | + if ( ! WCUtils::is_blank( $_POST['customer']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['customer']['tel'] ) ) && usces_is_required_field( 'tel' ) ) { | |
| 5770 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5771 | + } | |
| 5772 | + | |
| 5773 | + $mes = apply_filters( 'usces_filter_customer_check', $mes ); | |
| 5774 | + | |
| 5775 | + return $mes; | |
| 5776 | + } | |
| 5777 | + | |
| 5778 | + public function admin_new_member_check() { | |
| 5779 | + global $wpdb; | |
| 5780 | + | |
| 5781 | + $mes = $this->get_pwd_errors( $_POST['member']['password'] ); | |
| 5782 | + | |
| 5783 | + if ( ! is_email( trim( $_POST['member']['email'] ) ) ) { | |
| 5784 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 5785 | + } else { | |
| 5786 | + $member_table = usces_get_tablename( 'usces_member' ); | |
| 5787 | + $mem_email = $wpdb->get_var( $wpdb->prepare( "SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim( $_POST['member_id'] ) ) ); | |
| 5788 | + if ( trim( $_POST['member']['email'] ) != $mem_email ) { | |
| 5789 | + $mem_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim( $_POST['member']['email'] ) ) ); | |
| 5790 | + if ( ! empty( $mem_ID ) ) { | |
| 5791 | + $mes .= __( 'This e-mail address has been already registered.', 'usces' ) . '<br />'; | |
| 5792 | + } | |
| 5793 | + } | |
| 5794 | + } | |
| 5795 | + | |
| 5796 | + if ( WCUtils::is_blank( $_POST['member']['name1'] ) ) { | |
| 5797 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5798 | + } | |
| 5799 | + if ( ! WCUtils::is_blank( $_POST['member']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['member']['tel'] ) ) ) { | |
| 5800 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5801 | + } | |
| 5802 | + $mes = apply_filters( 'usces_filter_admin_member_check', $mes ); | |
| 5803 | + | |
| 5804 | + return $mes; | |
| 5805 | + } | |
| 5806 | + | |
| 5807 | + public function delivery_check() { | |
| 5808 | + global $usces_settings; | |
| 5809 | + | |
| 5810 | + do_action( 'usces_action_before_delivery_check' ); | |
| 5811 | + | |
| 5812 | + $mes = ''; | |
| 5813 | + if ( isset( $_POST['delivery']['delivery_flag'] ) && 1 === (int) $_POST['delivery']['delivery_flag'] ) { | |
| 5814 | + if ( WCUtils::is_blank( $_POST['delivery']['name1'] ) ) { | |
| 5815 | + $mes .= __( 'Name is not correct', 'usces' ) . '<br />'; | |
| 5816 | + } | |
| 5817 | + $zip_check = false; | |
| 5818 | + $addressform = $this->options['system']['addressform']; | |
| 5819 | + $applyform = usces_get_apply_addressform( $addressform ); | |
| 5820 | + if ( 'JP' === $applyform ) { | |
| 5821 | + if ( isset( $_POST['delivery']['country'] ) ) { | |
| 5822 | + if ( 'JP' === $_POST['delivery']['country'] ) { | |
| 5823 | + $zip_check = true; | |
| 5824 | + } | |
| 5825 | + } else { | |
| 5826 | + $base = usces_get_base_country(); | |
| 5827 | + if ( 'JP' === $base ) { | |
| 5828 | + $zip_check = true; | |
| 5829 | + } | |
| 5830 | + } | |
| 5831 | + } | |
| 5832 | + $zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check ); | |
| 5833 | + if ( WCUtils::is_blank( $_POST['delivery']['zipcode'] ) ) { | |
| 5834 | + if ( usces_is_required_field( 'zipcode' ) ) { | |
| 5835 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5836 | + } | |
| 5837 | + } else { | |
| 5838 | + if ( $zip_check ) { | |
| 5839 | + if ( ! preg_match( '/^[a-zA-Z0-9]+$/', $_POST['delivery']['zipcode'] ) ) { | |
| 5840 | + $_SESSION['usces_entry']['delivery']['zipcode'] = usces_convert_zipcode( $_POST['delivery']['zipcode'] ); | |
| 5841 | + } | |
| 5842 | + if ( ! preg_match( '/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['delivery']['zipcode'] ) ) { | |
| 5843 | + $mes .= __( 'postal code is not correct', 'usces' ) . '<br />'; | |
| 5844 | + } | |
| 5845 | + } | |
| 5846 | + } | |
| 5847 | + if ( ( __( '-- Select --', 'usces' ) == $_POST['delivery']['pref'] || '-- Select --' == $_POST['delivery']['pref'] ) && usces_is_required_field( 'states' ) ) { | |
| 5848 | + $mes .= __( 'enter the prefecture', 'usces' ) . '<br />'; | |
| 5849 | + } | |
| 5850 | + if ( WCUtils::is_blank( $_POST['delivery']['address1'] ) && usces_is_required_field( 'address1' ) ) { | |
| 5851 | + $mes .= __( 'enter the city name', 'usces' ) . '<br />'; | |
| 5852 | + } | |
| 5853 | + if ( WCUtils::is_blank( $_POST['delivery']['address2'] ) && usces_is_required_field( 'address2' ) ) { | |
| 5854 | + $mes .= __( 'enter house numbers', 'usces' ) . '<br />'; | |
| 5855 | + } | |
| 5856 | + if ( WCUtils::is_blank( $_POST['delivery']['tel'] ) && usces_is_required_field( 'tel' ) ) { | |
| 5857 | + $mes .= __( 'enter phone numbers', 'usces' ) . '<br />'; | |
| 5858 | + } | |
| 5859 | + if ( ! WCUtils::is_blank( $_POST['delivery']['tel'] ) && preg_match( '/[^\d\-+]/', trim( $_POST['delivery']['tel'] ) ) && usces_is_required_field( 'tel' ) ) { | |
| 5860 | + $mes .= __( 'Please input a phone number with a half size number.', 'usces' ) . '<br />'; | |
| 5861 | + } | |
| 5862 | + $post_offer = filter_input( INPUT_POST, 'offer', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); | |
| 5863 | + if ( ! empty( $post_offer['delivery_date'] ) && usces_is_date( $post_offer['delivery_date'] ) && isset( $post_offer['delivery_method'] ) ) { | |
| 5864 | + $post_delivery = filter_input( INPUT_POST, 'delivery', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); | |
| 5865 | + $deli_method_index = $this->get_delivery_method_index( $post_offer['delivery_method'] ); | |
| 5866 | + $delivery_days_id = isset( $this->options['delivery_method'][ $deli_method_index ]['days'] ) ? $this->options['delivery_method'][ $deli_method_index ]['days'] : -1; | |
| 5867 | + if ( 0 <= $delivery_days_id ) { | |
| 5868 | + $delivery_days_list = $this->options['delivery_days']; | |
| 5869 | + $delivery_days = 0; | |
| 5870 | + foreach ( (array) $delivery_days_list as $delivery_days_value ) { | |
| 5871 | + if ( (int) $delivery_days_value['id'] === (int) $delivery_days_id ) { | |
| 5872 | + $delivery_days = (int) $delivery_days_value[ $applyform ][ $post_delivery['pref'] ]; | |
| 5873 | + } | |
| 5874 | + } | |
| 5875 | + $sendout = usces_get_send_out_date(); | |
| 5876 | + $sendout_date = implode( '-', $sendout['sendout_date'] ); | |
| 5877 | + $arrival_date = new DateTime( $sendout_date ); | |
| 5878 | + $arrival_date->modify( '+' . $delivery_days . ' days' ); | |
| 5879 | + $offer_deli_date = new DateTime( $post_offer['delivery_date'] ); | |
| 5880 | + if ( $offer_deli_date < $arrival_date ) { | |
| 5881 | + $mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '<br />'; | |
| 5882 | + } | |
| 5883 | + } else { | |
| 5884 | + $mes .= __( 'Please re-specify the desired arrival date.', 'usces' ) . '<br />'; | |
| 5885 | + } | |
| 5886 | + } | |
| 5887 | + } | |
| 5888 | + if ( ! isset( $_POST['offer']['delivery_method'] ) || ( empty( $_POST['offer']['delivery_method'] ) && ! WCUtils::is_zero( $_POST['offer']['delivery_method'] ) ) ) { | |
| 5889 | + $mes .= __( 'chose one from delivery method.', 'usces' ) . '<br />'; | |
| 5890 | + } else { | |
| 5891 | + $d_method_index = $this->get_delivery_method_index( (int) $_POST['offer']['delivery_method'] ); | |
| 5892 | + if ( 0 > $d_method_index ) { | |
| 5893 | + $mes .= __( 'chose one from delivery method.', 'usces' ) . '<br />'; | |
| 5894 | + } elseif ( isset( $_SESSION['usces_entry']['delivery']['country'] ) ) { | |
| 5895 | + $country = $_SESSION['usces_entry']['delivery']['country']; | |
| 5896 | + $current_locate = get_locale(); | |
| 5897 | + $wplang = get_option( 'WPLANG', $current_locate ); | |
| 5898 | + $local_country = $usces_settings['lungage2country'][ $wplang ]; | |
| 5899 | + | |
| 5900 | + if ( $country == $local_country ) { | |
| 5901 | + if ( 1 == $this->options['delivery_method'][ $d_method_index ]['intl'] ) { | |
| 5902 | + $mes .= __( 'Delivery method is incorrect. Can not specify an international flight.', 'usces' ) . '<br />'; | |
| 5903 | + } | |
| 5904 | + } else { | |
| 5905 | + if ( WCUtils::is_zero( $this->options['delivery_method'][ $d_method_index ]['intl'] ) ) { | |
| 5906 | + $mes .= __( 'Delivery method is incorrect. Specify the international flights.', 'usces' ) . '<br />'; | |
| 5907 | + } | |
| 5908 | + } | |
| 5909 | + } | |
| 5910 | + } | |
| 5911 | + if ( ! isset( $_POST['offer']['payment_name'] ) ) { | |
| 5912 | + $mes .= __( 'chose one from payment options.', 'usces' ) . '<br />'; | |
| 5913 | + } else { | |
| 5914 | + $payments = $this->getPayments( $_POST['offer']['payment_name'] ); | |
| 5915 | + if ( 'COD' == $payments['settlement'] ) { | |
| 5916 | + $total_items_price = $this->get_total_price(); | |
| 5917 | + $usces_entries = $this->cart->get_entry(); | |
| 5918 | + $materials = array( | |
| 5919 | + 'total_items_price' => $usces_entries['order']['total_items_price'], | |
| 5920 | + 'discount' => ( isset( $usces_entries['order']['discount'] ) ) ? $usces_entries['order']['discount'] : 0, | |
| 5921 | + 'shipping_charge' => $usces_entries['order']['shipping_charge'], | |
| 5922 | + 'cod_fee' => $usces_entries['order']['cod_fee'], | |
| 5923 | + 'use_point' => ( isset( $usces_entries['order']['use_point'] ) ) ? $usces_entries['order']['use_point'] : 0, | |
| 5924 | + ); | |
| 5925 | + $tax = $this->getTax( $total_items_price, $materials ); | |
| 5926 | + $total_items_price = $total_items_price + $tax; | |
| 5927 | + $cod_limit_amount = ( isset( $this->options['cod_limit_amount'] ) && 0 < (int) $this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0; | |
| 5928 | + if ( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount ) { | |
| 5929 | + $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 />'; | |
| 5930 | + } | |
| 5931 | + } | |
| 5932 | + } | |
| 5933 | + if ( isset( $d_method_index ) && isset( $payments ) ) { | |
| 5934 | + if ( 1 == $this->options['delivery_method'][ $d_method_index ]['nocod'] ) { | |
| 5935 | + if ( 'COD' == $payments['settlement'] ) { | |
| 5936 | + $mes .= __( 'COD is not available.', 'usces' ) . '<br />'; | |
| 5937 | + } | |
| 5938 | + } | |
| 5939 | + } | |
| 5940 | + $mes = apply_filters( 'usces_filter_delivery_check', $mes ); | |
| 5941 | + return $mes; | |
| 5942 | + } | |
| 5943 | + | |
| 5944 | + public function point_check( $entries ) { | |
| 5945 | + $member = $this->get_member(); | |
| 5946 | + $this->set_cart_fees( $member, $entries ); | |
| 5947 | + | |
| 5948 | + $mes = ''; | |
| 5949 | + if ( isset( $_POST['offer']['usedpoint'] ) ) { | |
| 5950 | + if ( WCUtils::is_blank( $_POST['offer']['usedpoint'] ) || ! preg_match( '/^[0-9]+$/', $_POST['offer']['usedpoint'] ) || (int) $_POST['offer']['usedpoint'] < 0 ) { | |
| 5951 | + $mes .= __( 'Invalid value. Please enter in the numbers.', 'usces' ) . '<br />'; | |
| 5952 | + | |
| 5953 | + } else { | |
| 5954 | + $payments = $this->getPayments( $entries['order']['payment_name'] ); | |
| 5955 | + $usedpoint = (int) trim( $_POST['offer']['usedpoint'] ); | |
| 5956 | + if ( $usedpoint > $member['point'] ) { | |
| 5957 | + $mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $member['point'] . ' ' . __( 'points', 'usces' ) . '<br />'; | |
| 5958 | + | |
| 5959 | + } elseif ( 'acting_paypal_ec' == $payments['settlement'] ) { | |
| 5960 | + $target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax']; | |
| 5961 | + $target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount']; | |
| 5962 | + if ( 1 == $this->options['point_coverage'] && $usedpoint >= $target_full_price ) { | |
| 5963 | + $target_item_price = $target_full_price; | |
| 5964 | + } elseif ( 'products' == $this->options['tax_target'] ) { | |
| 5965 | + $target_item_price += $entries['order']['tax']; | |
| 5966 | + } | |
| 5967 | + if ( $usedpoint > $target_item_price ) { | |
| 5968 | + $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 />'; | |
| 5969 | + } | |
| 5970 | + | |
| 5971 | + } else { | |
| 5972 | + if ( 1 == $this->options['point_coverage'] ) { | |
| 5973 | + $target_full_price = $entries['order']['total_items_price'] + $entries['order']['discount'] + $entries['order']['shipping_charge'] + $entries['order']['cod_fee'] + $entries['order']['tax']; | |
| 5974 | + if ( $usedpoint > $target_full_price ) { | |
| 5975 | + $mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_full_price . ' ' . __( 'points', 'usces' ) . '<br />'; | |
| 5976 | + } | |
| 5977 | + } else { | |
| 5978 | + $target_item_price = $entries['order']['total_items_price'] + $entries['order']['discount']; | |
| 5979 | + if ( 'products' == $this->options['tax_target'] ) { | |
| 5980 | + $target_item_price += $entries['order']['tax']; | |
| 5981 | + } | |
| 5982 | + if ( $usedpoint > $target_item_price ) { | |
| 5983 | + $mes .= __( 'You have exceeded the maximum available.', 'usces' ) . ' ' . __( 'Max', 'usces' ) . ' ' . $target_item_price . ' ' . __( 'points', 'usces' ) . '<br />'; | |
| 5984 | + } | |
| 5985 | + } | |
| 5986 | + } | |
| 5987 | + $mes = apply_filters( 'usces_filter_point_check', $mes ); | |
| 5988 | + if ( '' != $mes ) { | |
| 5989 | + $_POST['offer']['usedpoint'] = 0; | |
| 5990 | + $array = array( | |
| 5991 | + 'usedpoint' => 0, | |
| 5992 | + ); | |
| 5993 | + $this->cart->set_order_entry( $array ); | |
| 5994 | + } | |
| 5995 | + } | |
| 5996 | + } | |
| 5997 | + $mes = apply_filters( 'usces_filter_point_check_last', $mes ); | |
| 5998 | + return $mes; | |
| 5999 | + } | |
| 6000 | + | |
| 6001 | + public function lostpass_mailaddcheck() { | |
| 6002 | + $mes = ''; | |
| 6003 | + if ( ! is_email( $_POST['loginmail'] ) || WCUtils::is_blank( $_POST['loginmail'] ) ) { | |
| 6004 | + $mes .= __( 'e-mail address is not correct', 'usces' ) . '<br />'; | |
| 6005 | + } | |
| 6006 | + | |
| 6007 | + return $mes; | |
| 6008 | + } | |
| 6009 | + | |
| 6010 | + public function changepass_check() { | |
| 6011 | + $mes = $this->get_pwd_errors( $_POST['loginpass1'] ); | |
| 6012 | + | |
| 6013 | + if ( trim( $_POST['loginpass1'] ) != trim( $_POST['loginpass2'] ) ) { | |
| 6014 | + $mes .= __( 'Password confirm does not match.', 'usces' ) . '<br />'; | |
| 6015 | + } | |
| 6016 | + | |
| 6017 | + return $mes; | |
| 6018 | + } | |
| 6019 | + | |
| 6020 | + public function get_page() { | |
| 6021 | + return $this->page; | |
| 6022 | + } | |
| 6023 | + | |
| 6024 | + public function check_display_mode() { | |
| 6025 | + $options = get_option( 'usces' ); | |
| 6026 | + if ( isset( $options['display_mode'] ) && 'Maintenancemode' == $options['display_mode'] ) { | |
| 6027 | + return; | |
| 6028 | + } | |
| 6029 | + | |
| 6030 | + $start['hour'] = empty( $options['campaign_schedule']['start']['hour'] ) ? 0 : $options['campaign_schedule']['start']['hour']; | |
| 6031 | + $start['min'] = empty( $options['campaign_schedule']['start']['min'] ) ? 0 : $options['campaign_schedule']['start']['min']; | |
| 6032 | + $start['month'] = empty( $options['campaign_schedule']['start']['month'] ) ? 0 : $options['campaign_schedule']['start']['month']; | |
| 6033 | + $start['day'] = empty( $options['campaign_schedule']['start']['day'] ) ? 0 : $options['campaign_schedule']['start']['day']; | |
| 6034 | + $start['year'] = empty( $options['campaign_schedule']['start']['year'] ) ? 0 : $options['campaign_schedule']['start']['year']; | |
| 6035 | + $end['hour'] = empty( $options['campaign_schedule']['end']['hour'] ) ? 0 : $options['campaign_schedule']['end']['hour']; | |
| 6036 | + $end['min'] = empty( $options['campaign_schedule']['end']['min'] ) ? 0 : $options['campaign_schedule']['end']['min']; | |
| 6037 | + $end['month'] = empty( $options['campaign_schedule']['end']['month'] ) ? 0 : $options['campaign_schedule']['end']['month']; | |
| 6038 | + $end['day'] = empty( $options['campaign_schedule']['end']['day'] ) ? 0 : $options['campaign_schedule']['end']['day']; | |
| 6039 | + $end['year'] = empty( $options['campaign_schedule']['end']['year'] ) ? 0 : $options['campaign_schedule']['end']['year']; | |
| 6040 | + $starttime = mktime( $start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year'] ); | |
| 6041 | + $endtime = mktime( $end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year'] ); | |
| 6042 | + $current_time = current_time( 'timestamp' ); | |
| 6043 | + | |
| 6044 | + if ( ( $current_time >= $starttime ) && ( $current_time <= $endtime ) ) { | |
| 6045 | + $options['display_mode'] = 'Promotionsale'; | |
| 6046 | + } else { | |
| 6047 | + $options['display_mode'] = 'Usualsale'; | |
| 6048 | + } | |
| 6049 | + update_option( 'usces', $options ); | |
| 6050 | + } | |
| 6051 | + | |
| 6052 | + public function update_business_days() { | |
| 6053 | + $options = get_option( 'usces' ); | |
| 6054 | + $datetimestr = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 6055 | + $dhour = (int) substr( $datetimestr, 11, 2 ); | |
| 6056 | + $dminute = (int) substr( $datetimestr, 14, 2 ); | |
| 6057 | + $dsecond = (int) substr( $datetimestr, 17, 2 ); | |
| 6058 | + $dmonth = (int) substr( $datetimestr, 5, 2 ); | |
| 6059 | + $dday = (int) substr( $datetimestr, 8, 2 ); | |
| 6060 | + $dyear = (int) substr( $datetimestr, 0, 4 ); | |
| 6061 | + $dtimestamp = mktime( $dhour, $dminute, $dsecond, $dmonth, $dday, $dyear ); | |
| 6062 | + $datenow = getdate( $dtimestamp ); | |
| 6063 | + list( $year, $mon, $mday ) = getBeforeMonth( $datenow['year'], $datenow['mon'], 1, 1 ); | |
| 6064 | + | |
| 6065 | + if ( isset( $options['business_days'][ $year ][ $mon ][1] ) ) { | |
| 6066 | + unset( $options['business_days'][ $year ][ $mon ] ); | |
| 6067 | + } | |
| 6068 | + | |
| 6069 | + for ( $i = 0; $i < 12; $i++ ) { | |
| 6070 | + list( $year, $mon, $mday ) = getAfterMonth( $datenow['year'], $datenow['mon'], 1, $i ); | |
| 6071 | + $last = getLastDay( $year, $mon ); | |
| 6072 | + for ( $j = 1; $j <= $last; $j++ ) { | |
| 6073 | + if ( ! isset( $options['business_days'][ $year ][ $mon ][ $j ] ) ) { | |
| 6074 | + $options['business_days'][ $year ][ $mon ][ $j ] = 1; | |
| 6075 | + } | |
| 6076 | + } | |
| 6077 | + } | |
| 6078 | + update_option( 'usces', $options ); | |
| 6079 | + $this->options = get_option( 'usces' ); | |
| 6080 | + $_SESSION['usces_checked_business_days'] = ''; | |
| 6081 | + } | |
| 6082 | + | |
| 6083 | + public function display_cart() { | |
| 6084 | + if ( $this->cart->num_row() > 0 ) { | |
| 6085 | + // include (USCES_PLUGIN_DIR . '/includes/cart_table.php'); | |
| 6086 | + } else { | |
| 6087 | + echo "<div class='no_cart'>" . __( 'There are no items in your cart.', 'usces' ) . "</div>\n"; | |
| 6088 | + } | |
| 6089 | + } | |
| 6090 | + | |
| 6091 | + public function display_cart_confirm() { | |
| 6092 | + if ( $this->cart->num_row() > 0 ) { | |
| 6093 | + // include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php'); | |
| 6094 | + } else { | |
| 6095 | + echo "<div class='no_cart'>" . __( 'There are no items in your cart.', 'usces' ) . "</div>\n"; | |
| 6096 | + } | |
| 6097 | + } | |
| 6098 | + | |
| 6099 | + public function set_initial() { | |
| 6100 | + $this->set_default_page(); | |
| 6101 | + $this->set_default_categories(); | |
| 6102 | + $this->create_table(); | |
| 6103 | + $this->update_table(); | |
| 6104 | + $rets07 = usces_upgrade_07(); | |
| 6105 | + if ( $rets07 ) { | |
| 6106 | + $rets11 = usces_upgrade_11(); | |
| 6107 | + } | |
| 6108 | + if ( $rets11 ) { | |
| 6109 | + $rets14 = usces_upgrade_14(); | |
| 6110 | + } | |
| 6111 | + if ( $rets14 ) { | |
| 6112 | + $rets141 = usces_upgrade_141(); | |
| 6113 | + } | |
| 6114 | + if ( $rets141 ) { | |
| 6115 | + $rets143 = usces_upgrade_143(); | |
| 6116 | + } | |
| 6117 | + $this->update_options(); | |
| 6118 | + usces_schedule_event(); | |
| 6119 | + do_action( 'usces_on_plugin_activate' ); | |
| 6120 | + } | |
| 6121 | + | |
| 6122 | + public function deactivate() { | |
| 6123 | + wp_clear_scheduled_hook( 'wc_cron' ); | |
| 6124 | + wp_clear_scheduled_hook( 'wc_cron_w' ); | |
| 6125 | + usces_wcsite_deactivate(); | |
| 6126 | + } | |
| 6127 | + | |
| 6128 | + public function create_table() { | |
| 6129 | + global $wpdb; | |
| 6130 | + | |
| 6131 | + if ( ! empty( $wpdb->charset ) ) { | |
| 6132 | + $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; | |
| 6133 | + } | |
| 6134 | + if ( ! empty( $wpdb->collate ) ) { | |
| 6135 | + $charset_collate .= " COLLATE $wpdb->collate"; | |
| 6136 | + } | |
| 6137 | + $access_table = $wpdb->prefix . 'usces_access'; | |
| 6138 | + $member_table = $wpdb->prefix . 'usces_member'; | |
| 6139 | + $member_meta_table = $wpdb->prefix . 'usces_member_meta'; | |
| 6140 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 6141 | + $order_meta_table = $wpdb->prefix . 'usces_order_meta'; | |
| 6142 | + $ordercart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 6143 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 6144 | + $log_table = $wpdb->prefix . 'usces_log'; | |
| 6145 | + $acting_log_table = $wpdb->prefix . 'usces_acting_log'; | |
| 6146 | + $item_table = $wpdb->prefix . 'usces_item'; | |
| 6147 | + $sku_table = $wpdb->prefix . 'usces_skus'; | |
| 6148 | + $opt_table = $wpdb->prefix . 'usces_opts'; | |
| 6149 | + $admin_log_table = $wpdb->prefix . 'usces_admin_log'; | |
| 6150 | + | |
| 6151 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6152 | + | |
| 6153 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$access_table'" ) != $access_table ) { | |
| 6154 | + $sql = 'CREATE TABLE ' . $access_table . " ( | |
| 6155 | + ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6156 | + acc_key VARCHAR( 50 ) NOT NULL , | |
| 6157 | + acc_type VARCHAR( 50 ) NULL , | |
| 6158 | + acc_value LONGTEXT NULL , | |
| 6159 | + acc_date DATE NOT NULL DEFAULT '0000-00-00', | |
| 6160 | + acc_num1 INT( 11 ) NOT NULL DEFAULT 0, | |
| 6161 | + acc_num2 INT( 11 ) NOT NULL DEFAULT 0, | |
| 6162 | + acc_str1 VARCHAR( 200 ) NULL , | |
| 6163 | + acc_str2 VARCHAR( 200 ) NULL , | |
| 6164 | + PRIMARY KEY (`ID`), | |
| 6165 | + KEY acc_key ( acc_key ), | |
| 6166 | + KEY acc_type ( acc_type ), | |
| 6167 | + KEY acc_date ( acc_date ), | |
| 6168 | + KEY acc_num1 ( acc_num1 ), | |
| 6169 | + KEY acc_num2 ( acc_num2 ) | |
| 6170 | + ) AUTO_INCREMENT=0 $charset_collate;"; | |
| 6171 | + dbDelta( $sql ); | |
| 6172 | + add_option( 'usces_db_access', USCES_DB_ACCESS ); | |
| 6173 | + } | |
| 6174 | + | |
| 6175 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$member_table'" ) != $member_table ) { | |
| 6176 | + $sql = 'CREATE TABLE ' . $member_table . " ( | |
| 6177 | + ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6178 | + mem_email VARCHAR( 100 ) NOT NULL , | |
| 6179 | + mem_pass VARCHAR( 64 ) NOT NULL , | |
| 6180 | + mem_status INT( 11 ) NOT NULL DEFAULT '0', | |
| 6181 | + mem_cookie VARCHAR( 13 ) NULL , | |
| 6182 | + mem_point INT( 11 ) NOT NULL DEFAULT '0', | |
| 6183 | + mem_name1 VARCHAR( 100 ) NOT NULL , | |
| 6184 | + mem_name2 VARCHAR( 100 ) NULL , | |
| 6185 | + mem_name3 VARCHAR( 100 ) NULL , | |
| 6186 | + mem_name4 VARCHAR( 100 ) NULL , | |
| 6187 | + mem_zip VARCHAR( 50 ) NULL , | |
| 6188 | + mem_pref VARCHAR( 100 ) NOT NULL , | |
| 6189 | + mem_address1 VARCHAR( 100 ) NOT NULL , | |
| 6190 | + mem_address2 VARCHAR( 100 ) NULL , | |
| 6191 | + mem_address3 VARCHAR( 100 ) NULL , | |
| 6192 | + mem_tel VARCHAR( 100 ) NOT NULL , | |
| 6193 | + mem_fax VARCHAR( 100 ) NULL , | |
| 6194 | + mem_delivery_flag TINYINT ( 1 ) NULL , | |
| 6195 | + mem_delivery LONGTEXT, | |
| 6196 | + mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6197 | + mem_nicename VARCHAR( 50 ) NULL , | |
| 6198 | + PRIMARY KEY (`ID`), | |
| 6199 | + KEY mem_email ( mem_email ) , | |
| 6200 | + KEY mem_pass ( mem_pass ) | |
| 6201 | + ) AUTO_INCREMENT=1000 $charset_collate;"; | |
| 6202 | + dbDelta( $sql ); | |
| 6203 | + add_option( 'usces_db_member', USCES_DB_MEMBER ); | |
| 6204 | + } | |
| 6205 | + | |
| 6206 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$member_meta_table'" ) != $member_meta_table ) { | |
| 6207 | + $sql = 'CREATE TABLE ' . $member_meta_table . " ( | |
| 6208 | + mmeta_id bigint(20) NOT NULL auto_increment, | |
| 6209 | + member_id bigint(20) NOT NULL default '0', | |
| 6210 | + meta_key varchar(255) default NULL, | |
| 6211 | + meta_value longtext, | |
| 6212 | + PRIMARY KEY (mmeta_id), | |
| 6213 | + KEY order_id (member_id), | |
| 6214 | + KEY meta_key (meta_key(191)) | |
| 6215 | + ) $charset_collate;"; | |
| 6216 | + dbDelta( $sql ); | |
| 6217 | + add_option( 'usces_db_member_meta', USCES_DB_MEMBER_META ); | |
| 6218 | + } | |
| 6219 | + | |
| 6220 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$order_table'" ) != $order_table ) { | |
| 6221 | + $sql = 'CREATE TABLE ' . $order_table . " ( | |
| 6222 | + ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6223 | + mem_id BIGINT( 20 ) UNSIGNED NULL , | |
| 6224 | + order_email VARCHAR( 100 ) NOT NULL , | |
| 6225 | + order_name1 VARCHAR( 100 ) NOT NULL , | |
| 6226 | + order_name2 VARCHAR( 100 ) NULL , | |
| 6227 | + order_name3 VARCHAR( 100 ) NULL , | |
| 6228 | + order_name4 VARCHAR( 100 ) NULL , | |
| 6229 | + order_zip VARCHAR( 50 ) NULL , | |
| 6230 | + order_pref VARCHAR( 100 ) NOT NULL , | |
| 6231 | + order_address1 VARCHAR( 100 ) NOT NULL , | |
| 6232 | + order_address2 VARCHAR( 100 ) NULL , | |
| 6233 | + order_address3 VARCHAR( 100 ) NULL , | |
| 6234 | + order_tel VARCHAR( 100 ) NOT NULL , | |
| 6235 | + order_fax VARCHAR( 100 ) NULL , | |
| 6236 | + order_delivery LONGTEXT, | |
| 6237 | + order_cart LONGTEXT, | |
| 6238 | + order_note TEXT, | |
| 6239 | + order_delivery_time VARCHAR( 100 ) NOT NULL , | |
| 6240 | + order_payment_name VARCHAR( 100 ) NOT NULL , | |
| 6241 | + order_condition TEXT, | |
| 6242 | + order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 6243 | + order_getpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 6244 | + order_usedpoint INT( 10 ) NOT NULL DEFAULT '0', | |
| 6245 | + order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 6246 | + order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 6247 | + order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 6248 | + order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00', | |
| 6249 | + order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6250 | + order_modified VARCHAR( 20 ) NULL , | |
| 6251 | + order_status VARCHAR( 255 ) NULL , | |
| 6252 | + order_check TEXT NULL , | |
| 6253 | + order_delidue_date VARCHAR( 30 ) NULL , | |
| 6254 | + order_delivery_method INT( 10 ) NOT NULL DEFAULT -1, | |
| 6255 | + order_delivery_date VARCHAR( 100 ) NULL, | |
| 6256 | + PRIMARY KEY (`ID`), | |
| 6257 | + KEY order_email ( order_email ) , | |
| 6258 | + KEY order_name1 ( order_name1 ) , | |
| 6259 | + KEY order_name2 ( order_name2 ) , | |
| 6260 | + KEY order_pref ( order_pref ) , | |
| 6261 | + KEY order_address1 ( order_address1 ) , | |
| 6262 | + KEY order_tel ( order_tel ) , | |
| 6263 | + KEY mem_id ( mem_id ) , | |
| 6264 | + KEY order_date ( order_date ) | |
| 6265 | + ) AUTO_INCREMENT=1000 $charset_collate;"; | |
| 6266 | + dbDelta( $sql ); | |
| 6267 | + add_option( 'usces_db_order', USCES_DB_ORDER ); | |
| 6268 | + } | |
| 6269 | + | |
| 6270 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$order_meta_table'" ) != $order_meta_table ) { | |
| 6271 | + $sql = 'CREATE TABLE ' . $order_meta_table . " ( | |
| 6272 | + ometa_id bigint(20) NOT NULL auto_increment, | |
| 6273 | + order_id bigint(20) NOT NULL default '0', | |
| 6274 | + meta_key varchar(255) default NULL, | |
| 6275 | + meta_value longtext, | |
| 6276 | + PRIMARY KEY (ometa_id), | |
| 6277 | + KEY order_id (order_id), | |
| 6278 | + KEY meta_key (meta_key(191)) | |
| 6279 | + ) $charset_collate;"; | |
| 6280 | + dbDelta( $sql ); | |
| 6281 | + add_option( 'usces_db_order_meta', USCES_DB_ORDER_META ); | |
| 6282 | + } | |
| 6283 | + | |
| 6284 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$ordercart_table'" ) != $ordercart_table ) { | |
| 6285 | + $sql = 'CREATE TABLE ' . $ordercart_table . " ( | |
| 6286 | + `cart_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT , | |
| 6287 | + `order_id` bigint( 20 ) NOT NULL , | |
| 6288 | + `group_id` int( 3 ) NOT NULL DEFAULT '0', | |
| 6289 | + `row_index` int( 3 ) NOT NULL , | |
| 6290 | + `post_id` bigint( 20 ) NOT NULL , | |
| 6291 | + `item_code` varchar( 100 ) NOT NULL , | |
| 6292 | + `item_name` varchar( 250 ) NOT NULL , | |
| 6293 | + `cprice` decimal( 12, 0 ) DEFAULT NULL , | |
| 6294 | + `sku_code` varchar( 100 ) NOT NULL , | |
| 6295 | + `sku_name` varchar( 250 ) DEFAULT NULL , | |
| 6296 | + `price` decimal( 12, 0 ) NOT NULL , | |
| 6297 | + `quantity` float NOT NULL , | |
| 6298 | + `unit` varchar( 50 ) DEFAULT NULL , | |
| 6299 | + `tax` decimal( 10, 0 ) DEFAULT NULL , | |
| 6300 | + `destination_id` int( 10 ) DEFAULT NULL , | |
| 6301 | + `cart_serial` text, | |
| 6302 | + PRIMARY KEY ( `cart_id` ) , | |
| 6303 | + UNIQUE KEY `row` ( `row_index` , `destination_id` , `order_id` ) , | |
| 6304 | + KEY `order_id` ( `order_id` ) , | |
| 6305 | + KEY `post_id` ( `post_id` ) , | |
| 6306 | + KEY `item_code` ( `item_code` ) , | |
| 6307 | + KEY `item_name` ( `item_name`(191) ) , | |
| 6308 | + KEY `sku_code` ( `sku_code` ) , | |
| 6309 | + KEY `sku_name` ( `sku_name`(191) ) | |
| 6310 | + ) AUTO_INCREMENT=1000 $charset_collate;"; | |
| 6311 | + dbDelta( $sql ); | |
| 6312 | + add_option( 'usces_db_ordercart', USCES_DB_ORDERCART ); | |
| 6313 | + } | |
| 6314 | + | |
| 6315 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$ordercart_meta_table'" ) != $ordercart_meta_table ) { | |
| 6316 | + $sql = 'CREATE TABLE ' . $ordercart_meta_table . " ( | |
| 6317 | + `cartmeta_id` bigint( 20 ) NOT NULL AUTO_INCREMENT , | |
| 6318 | + `cart_id` bigint( 20 ) NOT NULL DEFAULT '0', | |
| 6319 | + `meta_type` varchar( 100 ) NOT NULL , | |
| 6320 | + `meta_key` varchar( 255 ) DEFAULT NULL , | |
| 6321 | + `meta_value` longtext, | |
| 6322 | + PRIMARY KEY ( `cartmeta_id` ) , | |
| 6323 | + KEY `cart_id` ( `cart_id` ) , | |
| 6324 | + KEY `meta_key` ( `meta_key`(191) ) | |
| 6325 | + ) $charset_collate;"; | |
| 6326 | + dbDelta( $sql ); | |
| 6327 | + add_option( 'usces_db_ordercart_meta', USCES_DB_ORDERCART_META ); | |
| 6328 | + } | |
| 6329 | + | |
| 6330 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$log_table'") != $log_table ) { | |
| 6331 | + $sql = 'CREATE TABLE ' . $log_table . " ( | |
| 6332 | + ID BIGINT( 20 ) NOT NULL AUTO_INCREMENT, | |
| 6333 | + datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6334 | + log LONGTEXT NULL, | |
| 6335 | + log_type VARCHAR( 100 ) DEFAULT NULL, | |
| 6336 | + log_key VARCHAR( 255 ) DEFAULT NULL, | |
| 6337 | + PRIMARY KEY ( ID ) , | |
| 6338 | + KEY datetime ( datetime ), | |
| 6339 | + KEY log_type ( log_type ), | |
| 6340 | + KEY log_key ( log_key(191) ) | |
| 6341 | + ) $charset_collate;"; | |
| 6342 | + dbDelta( $sql ); | |
| 6343 | + add_option( 'usces_db_log', USCES_DB_LOG ); | |
| 6344 | + } | |
| 6345 | + | |
| 6346 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$acting_log_table'" ) != $acting_log_table ) { | |
| 6347 | + $sql = 'CREATE TABLE ' . $acting_log_table . " ( | |
| 6348 | + `ID` BIGINT(20) NOT NULL AUTO_INCREMENT, | |
| 6349 | + `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6350 | + `log` LONGTEXT NULL, | |
| 6351 | + `acting` CHAR(32) DEFAULT NULL, | |
| 6352 | + `status` CHAR(32) DEFAULT NULL, | |
| 6353 | + `result` CHAR(32) DEFAULT NULL, | |
| 6354 | + `amount` DECIMAL( 10, 2 ) DEFAULT NULL, | |
| 6355 | + `order_id` BIGINT(20) NOT NULL, | |
| 6356 | + `tracking_id` CHAR(32) DEFAULT NULL, | |
| 6357 | + PRIMARY KEY (`ID`), | |
| 6358 | + KEY `datetime` (`datetime`), | |
| 6359 | + KEY `order_id` (`order_id`), | |
| 6360 | + KEY `tracking_id` (`tracking_id`), | |
| 6361 | + KEY `history_key` (`order_id`,`tracking_id`) | |
| 6362 | + ) $charset_collate;"; | |
| 6363 | + dbDelta( $sql ); | |
| 6364 | + add_option( 'usces_db_acting_log', USCES_DB_ACTING_LOG ); | |
| 6365 | + } | |
| 6366 | + | |
| 6367 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$item_table}'" ) !== $item_table ) { | |
| 6368 | + $sql = 'CREATE TABLE ' . $item_table . ' ( | |
| 6369 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL, | |
| 6370 | + itemCode VARCHAR( 200 ) NULL , | |
| 6371 | + itemName VARCHAR( 250 ) NULL , | |
| 6372 | + itemRestriction VARCHAR( 20 ) NULL , | |
| 6373 | + itemPointrate VARCHAR( 20 ) NULL , | |
| 6374 | + itemGpNum1 VARCHAR( 20 ) NULL , | |
| 6375 | + itemGpNum2 VARCHAR( 20 ) NULL , | |
| 6376 | + itemGpNum3 VARCHAR( 20 ) NULL , | |
| 6377 | + itemGpDis1 VARCHAR( 20 ) NULL , | |
| 6378 | + itemGpDis2 VARCHAR( 20 ) NULL , | |
| 6379 | + itemGpDis3 VARCHAR( 20 ) NULL , | |
| 6380 | + itemOrderAcceptable INT( 2 ) NULL , | |
| 6381 | + itemShipping INT( 3 ) NULL , | |
| 6382 | + itemDeliveryMethod LONGTEXT , | |
| 6383 | + itemShippingCharge VARCHAR( 200 ) NULL , | |
| 6384 | + itemIndividualSCharge VARCHAR( 20 ) NULL , | |
| 6385 | + item_charging_type INT( 3 ) NULL , | |
| 6386 | + item_division VARCHAR( 50 ) NULL , | |
| 6387 | + dlseller_date VARCHAR( 100 ) NULL , | |
| 6388 | + dlseller_file VARCHAR( 200 ) NULL , | |
| 6389 | + dlseller_interval VARCHAR( 20 ) NULL , | |
| 6390 | + dlseller_validity VARCHAR( 20 ) NULL , | |
| 6391 | + dlseller_version VARCHAR( 100 ) NULL , | |
| 6392 | + dlseller_author VARCHAR( 200 ) NULL , | |
| 6393 | + dlseller_purchases VARCHAR( 20 ) NULL , | |
| 6394 | + dlseller_downloads VARCHAR( 20 ) NULL , | |
| 6395 | + item_chargingday VARCHAR( 20 ) NULL , | |
| 6396 | + item_frequency VARCHAR( 20 ) NULL , | |
| 6397 | + wcad_regular_unit VARCHAR( 20 ) NULL , | |
| 6398 | + wcad_regular_interval INT( 10 ) NULL , | |
| 6399 | + wcad_regular_frequency INT( 10 ) NULL , | |
| 6400 | + select_sku_switch INT( 10 ) NULL , | |
| 6401 | + select_sku_display INT( 10 ) NULL , | |
| 6402 | + select_sku LONGTEXT , | |
| 6403 | + atobarai_propriety INT( 5 ) NULL , | |
| 6404 | + atodene_propriety INT( 5 ) NULL , | |
| 6405 | + structuredDataSku VARCHAR( 200 ) NULL , | |
| 6406 | + lower_limit INT( 10 ) NULL , | |
| 6407 | + popularity INT( 10 ) NULL , | |
| 6408 | + main_price DECIMAL( 10, 2 ) NULL , | |
| 6409 | + itemPicts TEXT NULL , | |
| 6410 | + itemAdvanced LONGTEXT NULL , | |
| 6411 | + PRIMARY KEY (`post_id`), | |
| 6412 | + KEY itemCode ( itemCode ) , | |
| 6413 | + KEY itemName ( itemName ) | |
| 6414 | + ) ' . $charset_collate . ';'; | |
| 6415 | + dbDelta( $sql ); | |
| 6416 | + add_option( 'usces_db_item', USCES_DB_ITEM ); | |
| 6417 | + } | |
| 6418 | + | |
| 6419 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$sku_table}'" ) !== $sku_table ) { | |
| 6420 | + $sql = 'CREATE TABLE ' . $sku_table . ' ( | |
| 6421 | + meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6422 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL , | |
| 6423 | + code VARCHAR( 200 ) NULL , | |
| 6424 | + name VARCHAR( 250 ) NULL , | |
| 6425 | + cprice DECIMAL( 10, 2 ) NULL , | |
| 6426 | + price DECIMAL( 10, 2 ) NULL , | |
| 6427 | + unit TEXT NULL , | |
| 6428 | + stocknum VARCHAR( 50 ) NULL , | |
| 6429 | + stock INT( 5 ) NULL , | |
| 6430 | + gp INT( 2 ) NULL , | |
| 6431 | + taxrate VARCHAR( 20 ) NULL , | |
| 6432 | + size VARCHAR( 20 ) NULL , | |
| 6433 | + weight VARCHAR( 20 ) NULL , | |
| 6434 | + pict_id VARCHAR( 20 ) NULL , | |
| 6435 | + advance LONGTEXT , | |
| 6436 | + paternkey VARCHAR( 100 ) NULL , | |
| 6437 | + sort INT( 5 ) NULL , | |
| 6438 | + PRIMARY KEY (`meta_id`), | |
| 6439 | + KEY post_id ( post_id ) , | |
| 6440 | + KEY code ( code ) , | |
| 6441 | + KEY name ( name ) , | |
| 6442 | + KEY price ( price ) , | |
| 6443 | + KEY paternkey ( paternkey ) | |
| 6444 | + ) ' . $charset_collate . ';'; | |
| 6445 | + dbDelta( $sql ); | |
| 6446 | + add_option( 'usces_db_skus', USCES_DB_SKUS ); | |
| 6447 | + } | |
| 6448 | + | |
| 6449 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$opt_table}'" ) !== $opt_table ) { | |
| 6450 | + $sql = 'CREATE TABLE ' . $opt_table . ' ( | |
| 6451 | + meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6452 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL , | |
| 6453 | + code VARCHAR( 200 ) NULL , | |
| 6454 | + name VARCHAR( 250 ) NULL , | |
| 6455 | + means INT( 3 ) NULL , | |
| 6456 | + essential INT( 3 ) NULL , | |
| 6457 | + value TEXT , | |
| 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 | + ) ' . $charset_collate . ';'; | |
| 6464 | + dbDelta( $sql ); | |
| 6465 | + add_option( 'usces_db_opts', USCES_DB_OPTS ); | |
| 6466 | + } | |
| 6467 | + | |
| 6468 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$admin_log_table}'" ) !== $admin_log_table ) { | |
| 6469 | + $sql = "CREATE TABLE {$admin_log_table} ( | |
| 6470 | + `ID` int(11) NOT NULL AUTO_INCREMENT, | |
| 6471 | + `author` varchar(64) NOT NULL, | |
| 6472 | + `message` longtext NOT NULL, | |
| 6473 | + `screen` varchar(64) NOT NULL, | |
| 6474 | + `entity_id` varchar(64) DEFAULT NULL, | |
| 6475 | + `action` varchar(64) NOT NULL, | |
| 6476 | + `data` longblob DEFAULT NULL, | |
| 6477 | + `datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6478 | + PRIMARY KEY (`ID`), | |
| 6479 | + KEY entity_id ( entity_id ) | |
| 6480 | + ) " . $charset_collate . ';'; | |
| 6481 | + dbDelta( $sql ); | |
| 6482 | + add_option( 'usces_db_admin_log', USCES_DB_ADMIN_LOG ); | |
| 6483 | + } | |
| 6484 | + | |
| 6485 | + do_action( 'usces_action_create_table' ); | |
| 6486 | + } | |
| 6487 | + | |
| 6488 | + public function update_table() { | |
| 6489 | + global $wpdb; | |
| 6490 | + $access_table = $wpdb->prefix . 'usces_access'; | |
| 6491 | + $member_table = $wpdb->prefix . 'usces_member'; | |
| 6492 | + $member_meta_table = $wpdb->prefix . 'usces_member_meta'; | |
| 6493 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 6494 | + $order_meta_table = $wpdb->prefix . 'usces_order_meta'; | |
| 6495 | + $ordercart_table = $wpdb->prefix . 'usces_ordercart'; | |
| 6496 | + $ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; | |
| 6497 | + $log_table = $wpdb->prefix . 'usces_log'; | |
| 6498 | + $acting_log_table = $wpdb->prefix . 'usces_acting_log'; | |
| 6499 | + $item_table = $wpdb->prefix . 'usces_item'; | |
| 6500 | + $sku_table = $wpdb->prefix . 'usces_skus'; | |
| 6501 | + $opt_table = $wpdb->prefix . 'usces_opts'; | |
| 6502 | + $admin_log_table = $wpdb->prefix . 'usces_admin_log'; | |
| 6503 | + | |
| 6504 | + $access_ver = get_option( 'usces_db_access' ); | |
| 6505 | + $member_ver = get_option( 'usces_db_member' ); | |
| 6506 | + $member_meta_ver = get_option( 'usces_db_member_meta' ); | |
| 6507 | + $order_ver = get_option( 'usces_db_order' ); | |
| 6508 | + $order_meta_ver = get_option( 'usces_db_order_meta' ); | |
| 6509 | + $ordercart_ver = get_option( 'usces_db_ordercart' ); | |
| 6510 | + $ordercart_meta_ver = get_option( 'usces_db_ordercart_meta' ); | |
| 6511 | + $log_ver = get_option( 'usces_db_log' ); | |
| 6512 | + $acting_log_ver = get_option( 'usces_db_acting_log' ); | |
| 6513 | + $db_item = get_option( 'usces_db_item' ); | |
| 6514 | + $db_skus = get_option( 'usces_db_skus' ); | |
| 6515 | + $db_opts = get_option( 'usces_db_opts' ); | |
| 6516 | + $db_admin_log = get_option( 'usces_db_admin_log' ); | |
| 6517 | + | |
| 6518 | + if ( $access_ver != USCES_DB_ACCESS ) { | |
| 6519 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6520 | + $sql = 'CREATE TABLE ' . $access_table . " ( | |
| 6521 | + ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6522 | + acc_key VARCHAR(50) NOT NULL , | |
| 6523 | + acc_type VARCHAR(50) NULL , | |
| 6524 | + acc_value LONGTEXT NULL , | |
| 6525 | + acc_date DATE NOT NULL DEFAULT '0000-00-00', | |
| 6526 | + acc_num1 INT(11) NOT NULL DEFAULT 0, | |
| 6527 | + acc_num2 INT(11) NOT NULL DEFAULT 0, | |
| 6528 | + acc_str1 VARCHAR(200) NULL , | |
| 6529 | + acc_str2 VARCHAR(200) NULL , | |
| 6530 | + PRIMARY KEY (`ID`), | |
| 6531 | + KEY acc_key (acc_key), | |
| 6532 | + KEY acc_type (acc_type), | |
| 6533 | + KEY acc_date (acc_date), | |
| 6534 | + KEY acc_num1 (acc_num1), | |
| 6535 | + KEY acc_num2 (acc_num2) | |
| 6536 | + );"; | |
| 6537 | + dbDelta( $sql ); | |
| 6538 | + update_option( 'usces_db_access', USCES_DB_ACCESS ); | |
| 6539 | + } | |
| 6540 | + | |
| 6541 | + if ( USCES_DB_MEMBER != $member_ver ) { | |
| 6542 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6543 | + $sql = 'CREATE TABLE ' . $member_table . " ( | |
| 6544 | + ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, | |
| 6545 | + mem_email VARCHAR(100) NOT NULL , | |
| 6546 | + mem_pass VARCHAR(64) NOT NULL , | |
| 6547 | + mem_status INT(11) NOT NULL DEFAULT '0', | |
| 6548 | + mem_cookie VARCHAR(13) NULL , | |
| 6549 | + mem_point INT(11) NOT NULL DEFAULT '0', | |
| 6550 | + mem_name1 VARCHAR(100) NOT NULL , | |
| 6551 | + mem_name2 VARCHAR(100) NULL , | |
| 6552 | + mem_name3 VARCHAR(100) NULL , | |
| 6553 | + mem_name4 VARCHAR(100) NULL , | |
| 6554 | + mem_zip VARCHAR(50) NULL , | |
| 6555 | + mem_pref VARCHAR(100) NOT NULL , | |
| 6556 | + mem_address1 VARCHAR(100) NOT NULL , | |
| 6557 | + mem_address2 VARCHAR(100) NULL , | |
| 6558 | + mem_address3 VARCHAR(100) NULL , | |
| 6559 | + mem_tel VARCHAR(100) NOT NULL , | |
| 6560 | + mem_fax VARCHAR(100) NULL , | |
| 6561 | + mem_delivery_flag TINYINT (1) NULL , | |
| 6562 | + mem_delivery LONGTEXT, | |
| 6563 | + mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6564 | + mem_nicename VARCHAR(50) NULL , | |
| 6565 | + PRIMARY KEY (`ID`), | |
| 6566 | + KEY mem_email (mem_email) , | |
| 6567 | + KEY mem_pass (mem_pass) | |
| 6568 | + );"; | |
| 6569 | + dbDelta( $sql ); | |
| 6570 | + update_option( 'usces_db_member', USCES_DB_MEMBER ); | |
| 6571 | + } | |
| 6572 | + | |
| 6573 | + if ( USCES_DB_MEMBER_META != $member_meta_ver ) { | |
| 6574 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6575 | + $sql = 'CREATE TABLE ' . $member_meta_table . " ( | |
| 6576 | + mmeta_id bigint(20) NOT NULL auto_increment, | |
| 6577 | + member_id bigint(20) NOT NULL default '0', | |
| 6578 | + meta_key varchar(255) default NULL, | |
| 6579 | + meta_value longtext, | |
| 6580 | + PRIMARY KEY (`mmeta_id`), | |
| 6581 | + KEY order_id (member_id), | |
| 6582 | + KEY meta_key (meta_key(191)) | |
| 6583 | + );"; | |
| 6584 | + dbDelta( $sql ); | |
| 6585 | + update_option( 'usces_db_member_meta', USCES_DB_MEMBER_META ); | |
| 6586 | + } | |
| 6587 | + | |
| 6588 | + if ( USCES_DB_ORDER != $order_ver ) { | |
| 6589 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6590 | + $sql = 'CREATE TABLE ' . $order_table . " ( | |
| 6591 | + ID bigint(20) unsigned NOT NULL auto_increment, | |
| 6592 | + mem_id BIGINT(20) UNSIGNED NULL, | |
| 6593 | + order_email VARCHAR(100) NOT NULL, | |
| 6594 | + order_name1 VARCHAR(100) NOT NULL, | |
| 6595 | + order_name2 VARCHAR(100) NULL, | |
| 6596 | + order_name3 VARCHAR(100) NULL, | |
| 6597 | + order_name4 VARCHAR(100) NULL, | |
| 6598 | + order_zip VARCHAR(50) NULL, | |
| 6599 | + order_pref VARCHAR(100) NOT NULL, | |
| 6600 | + order_address1 VARCHAR(100) NOT NULL, | |
| 6601 | + order_address2 VARCHAR(100) NULL, | |
| 6602 | + order_address3 VARCHAR(100) NULL, | |
| 6603 | + order_tel VARCHAR(100) NOT NULL, | |
| 6604 | + order_fax VARCHAR(100) NULL, | |
| 6605 | + order_delivery LONGTEXT, | |
| 6606 | + order_cart LONGTEXT, | |
| 6607 | + order_note TEXT, | |
| 6608 | + order_delivery_time VARCHAR(100) NOT NULL, | |
| 6609 | + order_payment_name VARCHAR(100) NOT NULL, | |
| 6610 | + order_condition TEXT, | |
| 6611 | + order_item_total_price DECIMAL(10,2) NOT NULL DEFAULT '0.00', | |
| 6612 | + order_getpoint INT(10) NOT NULL DEFAULT '0', | |
| 6613 | + order_usedpoint INT(10) NOT NULL DEFAULT '0', | |
| 6614 | + order_discount DECIMAL(10,2) NOT NULL DEFAULT '0.00', | |
| 6615 | + order_shipping_charge DECIMAL(10,2) NOT NULL DEFAULT '0.00', | |
| 6616 | + order_cod_fee DECIMAL(10,2) NOT NULL DEFAULT '0.00', | |
| 6617 | + order_tax DECIMAL(10,2) NOT NULL DEFAULT '0.00', | |
| 6618 | + order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6619 | + order_modified VARCHAR(20) NULL, | |
| 6620 | + order_status VARCHAR(255) NULL, | |
| 6621 | + order_check TEXT NULL, | |
| 6622 | + order_delidue_date VARCHAR(30) NULL, | |
| 6623 | + order_delivery_method INT(10) NOT NULL DEFAULT -1, | |
| 6624 | + order_delivery_date VARCHAR(100) NULL, | |
| 6625 | + PRIMARY KEY (`ID`), | |
| 6626 | + KEY order_email (order_email), | |
| 6627 | + KEY order_name1 (order_name1), | |
| 6628 | + KEY order_name2 (order_name2), | |
| 6629 | + KEY order_pref (order_pref), | |
| 6630 | + KEY order_address1 (order_address1), | |
| 6631 | + KEY order_tel (order_tel), | |
| 6632 | + KEY mem_id ( mem_id ) , | |
| 6633 | + KEY order_date (order_date) | |
| 6634 | + );"; | |
| 6635 | + dbDelta( $sql ); | |
| 6636 | + update_option( 'usces_db_order', USCES_DB_ORDER ); | |
| 6637 | + } | |
| 6638 | + | |
| 6639 | + if ( USCES_DB_ORDER_META != $order_meta_ver ) { | |
| 6640 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6641 | + $sql = 'CREATE TABLE ' . $order_meta_table . " ( | |
| 6642 | + ometa_id bigint(20) NOT NULL auto_increment, | |
| 6643 | + order_id bigint(20) NOT NULL default '0', | |
| 6644 | + meta_key varchar(255) default NULL, | |
| 6645 | + meta_value longtext, | |
| 6646 | + PRIMARY KEY (`ometa_id`), | |
| 6647 | + KEY order_id (order_id), | |
| 6648 | + KEY meta_key (meta_key) | |
| 6649 | + );"; | |
| 6650 | + dbDelta( $sql ); | |
| 6651 | + update_option( 'usces_db_order_meta', USCES_DB_ORDER_META ); | |
| 6652 | + } | |
| 6653 | + | |
| 6654 | + if ( USCES_DB_ORDERCART != $ordercart_ver ) { | |
| 6655 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6656 | + $sql = 'CREATE TABLE ' . $ordercart_table . " ( | |
| 6657 | + cart_id bigint(20) unsigned NOT NULL AUTO_INCREMENT , | |
| 6658 | + order_id bigint(20) NOT NULL , | |
| 6659 | + group_id int(3) NOT NULL DEFAULT '0', | |
| 6660 | + row_index int(3) NOT NULL , | |
| 6661 | + post_id bigint(20) NOT NULL , | |
| 6662 | + item_code varchar(100) NOT NULL , | |
| 6663 | + item_name varchar(250) NOT NULL , | |
| 6664 | + cprice decimal(12,0) DEFAULT NULL , | |
| 6665 | + sku_code varchar(100) NOT NULL , | |
| 6666 | + sku_name varchar(250) DEFAULT NULL , | |
| 6667 | + price decimal(12,0) NOT NULL , | |
| 6668 | + quantity float NOT NULL , | |
| 6669 | + unit varchar(50) DEFAULT NULL , | |
| 6670 | + tax decimal(10,0) DEFAULT NULL , | |
| 6671 | + destination_id int(10) DEFAULT NULL , | |
| 6672 | + cart_serial text, | |
| 6673 | + UNIQUE KEY row (row_index,destination_id,order_id) , | |
| 6674 | + PRIMARY KEY (`cart_id`), | |
| 6675 | + KEY order_id (order_id) , | |
| 6676 | + KEY post_id (post_id) , | |
| 6677 | + KEY item_code (item_code) , | |
| 6678 | + KEY item_name (item_name(191)) , | |
| 6679 | + KEY sku_code (sku_code) , | |
| 6680 | + KEY sku_name (sku_name(191)) | |
| 6681 | + );"; | |
| 6682 | + dbDelta( $sql ); | |
| 6683 | + update_option( 'usces_db_ordercart', USCES_DB_ORDERCART ); | |
| 6684 | + } | |
| 6685 | + | |
| 6686 | + if ( USCES_DB_ORDERCART_META != $ordercart_meta_ver ) { | |
| 6687 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6688 | + $sql = 'CREATE TABLE ' . $ordercart_meta_table . " ( | |
| 6689 | + cartmeta_id bigint(20) NOT NULL AUTO_INCREMENT, | |
| 6690 | + cart_id bigint(20) NOT NULL DEFAULT '0', | |
| 6691 | + meta_type varchar(100) NOT NULL , | |
| 6692 | + meta_key varchar(255) DEFAULT NULL , | |
| 6693 | + meta_value longtext, | |
| 6694 | + PRIMARY KEY (`cartmeta_id`), | |
| 6695 | + KEY cart_id (cart_id) , | |
| 6696 | + KEY meta_key (meta_key(191)) | |
| 6697 | + );"; | |
| 6698 | + dbDelta( $sql ); | |
| 6699 | + update_option( 'usces_db_ordercart_meta', USCES_DB_ORDERCART_META ); | |
| 6700 | + } | |
| 6701 | + | |
| 6702 | + if ( USCES_DB_LOG != $log_ver ) { | |
| 6703 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6704 | + $sql = 'CREATE TABLE ' . $log_table . " ( | |
| 6705 | + ID bigint(20) NOT NULL AUTO_INCREMENT, | |
| 6706 | + datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6707 | + log LONGTEXT NULL, | |
| 6708 | + log_type VARCHAR(100) DEFAULT NULL, | |
| 6709 | + log_key VARCHAR(255) DEFAULT NULL, | |
| 6710 | + PRIMARY KEY (`ID`), | |
| 6711 | + KEY datetime (datetime), | |
| 6712 | + KEY log_type (log_type), | |
| 6713 | + KEY log_key (log_key(191)) | |
| 6714 | + );"; | |
| 6715 | + dbDelta( $sql ); | |
| 6716 | + update_option( 'usces_db_log', USCES_DB_LOG ); | |
| 6717 | + } | |
| 6718 | + | |
| 6719 | + if ( USCES_DB_ACTING_LOG != $acting_log_ver ) { | |
| 6720 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6721 | + $sql = 'CREATE TABLE ' . $acting_log_table . " ( | |
| 6722 | + `ID` BIGINT(20) NOT NULL AUTO_INCREMENT, | |
| 6723 | + `datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6724 | + `log` LONGTEXT NULL, | |
| 6725 | + `acting` CHAR(32) DEFAULT NULL, | |
| 6726 | + `status` CHAR(32) DEFAULT NULL, | |
| 6727 | + `result` CHAR(32) DEFAULT NULL, | |
| 6728 | + `amount` DECIMAL( 10, 2 ) DEFAULT NULL, | |
| 6729 | + `order_id` BIGINT(20) NOT NULL, | |
| 6730 | + `tracking_id` CHAR(32) DEFAULT NULL, | |
| 6731 | + PRIMARY KEY (`ID`), | |
| 6732 | + KEY `datetime` (`datetime`), | |
| 6733 | + KEY `order_id` (`order_id`), | |
| 6734 | + KEY `tracking_id` (`tracking_id`), | |
| 6735 | + KEY `history_key` (`order_id`,`tracking_id`) | |
| 6736 | + );"; | |
| 6737 | + dbDelta( $sql ); | |
| 6738 | + update_option( 'usces_db_acting_log', USCES_DB_ACTING_LOG ); | |
| 6739 | + } | |
| 6740 | + | |
| 6741 | + if ( USCES_DB_ITEM != $db_item ) { | |
| 6742 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6743 | + $sql = 'CREATE TABLE ' . $item_table . ' ( | |
| 6744 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL , | |
| 6745 | + itemCode VARCHAR( 200 ) NULL , | |
| 6746 | + itemName VARCHAR( 250 ) NULL , | |
| 6747 | + itemRestriction VARCHAR( 20 ) NULL , | |
| 6748 | + itemPointrate VARCHAR( 20 ) NULL , | |
| 6749 | + itemGpNum1 VARCHAR( 20 ) NULL , | |
| 6750 | + itemGpNum2 VARCHAR( 20 ) NULL , | |
| 6751 | + itemGpNum3 VARCHAR( 20 ) NULL , | |
| 6752 | + itemGpDis1 VARCHAR( 20 ) NULL , | |
| 6753 | + itemGpDis2 VARCHAR( 20 ) NULL , | |
| 6754 | + itemGpDis3 VARCHAR( 20 ) NULL , | |
| 6755 | + itemOrderAcceptable INT( 2 ) NULL , | |
| 6756 | + itemShipping INT( 3 ) NULL , | |
| 6757 | + itemDeliveryMethod LONGTEXT , | |
| 6758 | + itemShippingCharge VARCHAR( 200 ) NULL , | |
| 6759 | + itemIndividualSCharge VARCHAR( 20 ) NULL , | |
| 6760 | + item_charging_type INT( 3 ) NULL , | |
| 6761 | + item_division VARCHAR( 50 ) NULL , | |
| 6762 | + dlseller_date VARCHAR( 100 ) NULL , | |
| 6763 | + dlseller_file VARCHAR( 200 ) NULL , | |
| 6764 | + dlseller_interval VARCHAR( 20 ) NULL , | |
| 6765 | + dlseller_validity VARCHAR( 20 ) NULL , | |
| 6766 | + dlseller_version VARCHAR( 100 ) NULL , | |
| 6767 | + dlseller_author VARCHAR( 200 ) NULL , | |
| 6768 | + dlseller_purchases VARCHAR( 20 ) NULL , | |
| 6769 | + dlseller_downloads VARCHAR( 20 ) NULL , | |
| 6770 | + item_chargingday VARCHAR( 20 ) NULL , | |
| 6771 | + item_frequency VARCHAR( 20 ) NULL , | |
| 6772 | + wcad_regular_unit VARCHAR( 20 ) NULL , | |
| 6773 | + wcad_regular_interval INT( 10 ) NULL , | |
| 6774 | + wcad_regular_frequency INT( 10 ) NULL , | |
| 6775 | + select_sku_switch INT( 10 ) NULL , | |
| 6776 | + select_sku_display INT( 10 ) NULL , | |
| 6777 | + select_sku LONGTEXT , | |
| 6778 | + atobarai_propriety INT( 5 ) NULL , | |
| 6779 | + atodene_propriety INT( 5 ) NULL , | |
| 6780 | + structuredDataSku VARCHAR( 200 ) NULL , | |
| 6781 | + lower_limit INT( 10 ) NULL , | |
| 6782 | + popularity INT( 10 ) NULL , | |
| 6783 | + main_price DECIMAL( 10, 2 ) NULL , | |
| 6784 | + itemPicts TEXT NULL , | |
| 6785 | + itemAdvanced LONGTEXT NULL , | |
| 6786 | + PRIMARY KEY (`post_id`), | |
| 6787 | + KEY itemCode ( itemCode ) , | |
| 6788 | + KEY itemName ( itemName ) | |
| 6789 | + );'; | |
| 6790 | + dbDelta( $sql ); | |
| 6791 | + update_option( 'usces_db_item', USCES_DB_ITEM ); | |
| 6792 | + } | |
| 6793 | + | |
| 6794 | + if ( USCES_DB_SKUS != $db_skus ) { | |
| 6795 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6796 | + $sql = 'CREATE TABLE ' . $sku_table . ' ( | |
| 6797 | + meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , | |
| 6798 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL , | |
| 6799 | + code VARCHAR( 200 ) NULL , | |
| 6800 | + name VARCHAR( 250 ) NULL , | |
| 6801 | + cprice DECIMAL( 10, 2 ) NULL , | |
| 6802 | + price DECIMAL( 10, 2 ) NULL , | |
| 6803 | + unit TEXT NULL , | |
| 6804 | + stocknum VARCHAR( 50 ) NULL , | |
| 6805 | + stock INT( 5 ) NULL , | |
| 6806 | + gp INT( 2 ) NULL , | |
| 6807 | + taxrate VARCHAR( 20 ) NULL , | |
| 6808 | + size VARCHAR( 20 ) NULL , | |
| 6809 | + weight VARCHAR( 20 ) NULL , | |
| 6810 | + pict_id VARCHAR( 20 ) NULL , | |
| 6811 | + advance LONGTEXT , | |
| 6812 | + paternkey VARCHAR( 100 ) NULL , | |
| 6813 | + sort INT( 5 ) NULL , | |
| 6814 | + PRIMARY KEY (`meta_id`), | |
| 6815 | + KEY post_id ( post_id ) , | |
| 6816 | + KEY code ( code ) , | |
| 6817 | + KEY name ( name ) , | |
| 6818 | + KEY price ( price ) , | |
| 6819 | + KEY paternkey ( paternkey ) | |
| 6820 | + );'; | |
| 6821 | + dbDelta( $sql ); | |
| 6822 | + update_option( 'usces_db_skus', USCES_DB_SKUS ); | |
| 6823 | + } | |
| 6824 | + | |
| 6825 | + if ( USCES_DB_OPTS != $db_opts ) { | |
| 6826 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6827 | + $sql = 'CREATE TABLE ' . $opt_table . ' ( | |
| 6828 | + meta_id BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , | |
| 6829 | + post_id BIGINT( 20 ) UNSIGNED NOT NULL , | |
| 6830 | + code VARCHAR( 200 ) NULL , | |
| 6831 | + name VARCHAR( 250 ) NULL , | |
| 6832 | + means INT( 3 ) NULL , | |
| 6833 | + essential INT( 3 ) NULL , | |
| 6834 | + value TEXT , | |
| 6835 | + sort INT( 5 ) NULL , | |
| 6836 | + PRIMARY KEY (`meta_id`), | |
| 6837 | + KEY post_id ( post_id ) , | |
| 6838 | + KEY code ( code ) , | |
| 6839 | + KEY name ( name ) | |
| 6840 | + );'; | |
| 6841 | + dbDelta( $sql ); | |
| 6842 | + update_option( 'usces_db_opts', USCES_DB_OPTS ); | |
| 6843 | + } | |
| 6844 | + | |
| 6845 | + if ( USCES_DB_ADMIN_LOG != $db_admin_log ) { | |
| 6846 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 6847 | + $sql = "CREATE TABLE {$admin_log_table} ( | |
| 6848 | + `ID` int(11) NOT NULL AUTO_INCREMENT, | |
| 6849 | + `author` varchar(64) NOT NULL, | |
| 6850 | + `message` longtext NOT NULL, | |
| 6851 | + `screen` varchar(64) NOT NULL, | |
| 6852 | + `entity_id` varchar(64) DEFAULT NULL, | |
| 6853 | + `action` varchar(64) NOT NULL, | |
| 6854 | + `data` longblob DEFAULT NULL, | |
| 6855 | + `datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', | |
| 6856 | + PRIMARY KEY (`ID`), | |
| 6857 | + KEY entity_id ( entity_id ) | |
| 6858 | + );"; | |
| 6859 | + dbDelta( $sql ); | |
| 6860 | + update_option( 'usces_db_admin_log', USCES_DB_ADMIN_LOG ); | |
| 6861 | + } | |
| 6862 | + | |
| 6863 | + do_action( 'usces_action_update_table' ); | |
| 6864 | + } | |
| 6865 | + | |
| 6866 | + public function dir_copy( $source, $dest ) { | |
| 6867 | + if ( $res = opendir( $source ) ) { | |
| 6868 | + while ( ( $file = readdir( $res ) ) !== false ) { | |
| 6869 | + $sorce_path = $source . '/' . $file; | |
| 6870 | + $dest_path = $dest . '/' . $file; | |
| 6871 | + $filetype = @filetype( $sorce_path ); | |
| 6872 | + if ( 'file' == $filetype ) { | |
| 6873 | + copy( $sorce_path, $dest_path ); | |
| 6874 | + } elseif ( 'dir' == $filetype && '..' != $file && '.' != $file ) { | |
| 6875 | + mkdir( $dest_path ); | |
| 6876 | + $this->dir_copy( $sorce_path, $dest_path ); | |
| 6877 | + } | |
| 6878 | + } | |
| 6879 | + closedir( $res ); | |
| 6880 | + } | |
| 6881 | + } | |
| 6882 | + | |
| 6883 | + public function set_default_page() { | |
| 6884 | + global $wpdb; | |
| 6885 | + | |
| 6886 | + $datetime = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ); | |
| 6887 | + $datetime_gmt = gmdate( 'Y-m-d H:i:s', time() ); | |
| 6888 | + | |
| 6889 | + // cart_page. | |
| 6890 | + $query = $wpdb->prepare( "SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER ); | |
| 6891 | + $cart_number = $wpdb->get_var( $query ); | |
| 6892 | + if ( null === $cart_number ) { | |
| 6893 | + $query = $wpdb->prepare( | |
| 6894 | + "INSERT INTO $wpdb->posts | |
| 6895 | + (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, | |
| 6896 | + comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, | |
| 6897 | + post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) | |
| 6898 | + VALUES (%d, %s, %s, %s, %s, %s, %s, | |
| 6899 | + %s, %s, %s, %s, %s, %s, %s, %s, | |
| 6900 | + %s, %d, %s, %d, %s, %s, %d)", | |
| 6901 | + 1, $datetime, $datetime_gmt, '', __( 'Cart', 'usces' ), '', 'publish', | |
| 6902 | + 'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt, | |
| 6903 | + '', 0, '', 0, 'page', '', 0 | |
| 6904 | + ); | |
| 6905 | + $wpdb->query( $query ); | |
| 6906 | + $cart_number = $wpdb->insert_id; | |
| 6907 | + if ( null !== $cart_number ) { | |
| 6908 | + $query = $wpdb->prepare( | |
| 6909 | + "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)", | |
| 6910 | + $cart_number, '_wp_page_template', 'uscescart.php' | |
| 6911 | + ); | |
| 6912 | + $wpdb->query( $query ); | |
| 6913 | + } | |
| 6914 | + } | |
| 6915 | + update_option( 'usces_cart_number', $cart_number ); | |
| 6916 | + | |
| 6917 | + // member_page. | |
| 6918 | + $query = $wpdb->prepare( "SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER ); | |
| 6919 | + $member_number = $wpdb->get_var( $query ); | |
| 6920 | + if ( null === $member_number ) { | |
| 6921 | + $query = $wpdb->prepare( | |
| 6922 | + "INSERT INTO $wpdb->posts | |
| 6923 | + (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, | |
| 6924 | + comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, | |
| 6925 | + post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) | |
| 6926 | + VALUES (%d, %s, %s, %s, %s, %s, %s, | |
| 6927 | + %s, %s, %s, %s, %s, %s, %s, %s, | |
| 6928 | + %s, %d, %s, %d, %s, %s, %d)", | |
| 6929 | + 1, $datetime, $datetime_gmt, '', __( 'Membership', 'usces' ), '', 'publish', | |
| 6930 | + 'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt, | |
| 6931 | + '', 0, '', 0, 'page', '', 0 | |
| 6932 | + ); | |
| 6933 | + $wpdb->query( $query ); | |
| 6934 | + $member_number = $wpdb->insert_id; | |
| 6935 | + if ( null !== $member_number ) { | |
| 6936 | + $query = $wpdb->prepare( | |
| 6937 | + "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)", | |
| 6938 | + $member_number, '_wp_page_template', 'uscesmember.php' | |
| 6939 | + ); | |
| 6940 | + $wpdb->query( $query ); | |
| 6941 | + } | |
| 6942 | + } | |
| 6943 | + update_option( 'usces_member_number', $member_number ); | |
| 6944 | + } | |
| 6945 | + | |
| 6946 | + public function set_default_categories() { | |
| 6947 | + global $wpdb; | |
| 6948 | + | |
| 6949 | + $item_category_slug = apply_filters( 'usces_item_category_slug', 'item' ); | |
| 6950 | + | |
| 6951 | + $idObj = get_category_by_slug( $item_category_slug ); | |
| 6952 | + if ( empty( $idObj ) ) { | |
| 6953 | + $item_cat = array( | |
| 6954 | + 'cat_name' => __( 'Items', 'usces' ), | |
| 6955 | + 'category_description' => '', | |
| 6956 | + 'category_nicename' => $item_category_slug, | |
| 6957 | + 'category_parent' => 0, | |
| 6958 | + ); | |
| 6959 | + $item_cat_id = wp_insert_category( $item_cat ); | |
| 6960 | + update_option( 'usces_item_cat_parent_id', $item_cat_id ); | |
| 6961 | + } | |
| 6962 | + | |
| 6963 | + $idObj = get_category_by_slug( 'itemreco' ); | |
| 6964 | + if ( empty( $idObj ) && isset( $item_cat_id ) ) { | |
| 6965 | + $itemreco_cat = array( | |
| 6966 | + 'cat_name' => __( 'Items recommended', 'usces' ), | |
| 6967 | + 'category_description' => '', | |
| 6968 | + 'category_nicename' => 'itemreco', | |
| 6969 | + 'category_parent' => $item_cat_id, | |
| 6970 | + ); | |
| 6971 | + $itemreco_cat_id = wp_insert_category( $itemreco_cat ); | |
| 6972 | + } | |
| 6973 | + | |
| 6974 | + $idObj = get_category_by_slug( 'itemnew' ); | |
| 6975 | + if ( empty( $idObj ) && isset( $item_cat_id ) ) { | |
| 6976 | + $itemnew_cat = array( | |
| 6977 | + 'cat_name' => __( 'New items', 'usces' ), | |
| 6978 | + 'category_description' => '', | |
| 6979 | + 'category_nicename' => 'itemnew', | |
| 6980 | + 'category_parent' => $item_cat_id, | |
| 6981 | + ); | |
| 6982 | + $itemnew_cat_id = wp_insert_category( $itemnew_cat ); | |
| 6983 | + } | |
| 6984 | + | |
| 6985 | + $idObj = get_category_by_slug( 'itemgenre' ); | |
| 6986 | + if ( empty( $idObj ) && isset( $item_cat_id ) ) { | |
| 6987 | + $itemgenre_cat = array( | |
| 6988 | + 'cat_name' => __( 'Item genre', 'usces' ), | |
| 6989 | + 'category_description' => '', | |
| 6990 | + 'category_nicename' => 'itemgenre', | |
| 6991 | + 'category_parent' => $item_cat_id, | |
| 6992 | + ); | |
| 6993 | + $itemgenre_cat_id = wp_insert_category( $itemgenre_cat ); | |
| 6994 | + } | |
| 6995 | + } | |
| 6996 | + | |
| 6997 | + public function update_options() { | |
| 6998 | + $target_market = $this->options['system']['target_market']; | |
| 6999 | + | |
| 7000 | + $update_shipping_charge = false; | |
| 7001 | + $shipping_charge = isset( $this->options['shipping_charge'] ) ? $this->options['shipping_charge'] : array(); | |
| 7002 | + $shipping_charge_count = ( $shipping_charge && is_array( $shipping_charge ) ) ? count( $shipping_charge ) : 0; | |
| 7003 | + foreach ( (array) $target_market as $tm ) { | |
| 7004 | + for ( $i = 0; $i < $shipping_charge_count; $i++ ) { | |
| 7005 | + if ( isset( $shipping_charge[ $i ]['country'] ) && $shipping_charge[ $i ]['country'] == $tm ) { | |
| 7006 | + foreach ( $shipping_charge[ $i ]['value'] as $pref => $value ) { | |
| 7007 | + $shipping_charge[ $i ][ $tm ][ $pref ] = $value; | |
| 7008 | + } | |
| 7009 | + unset( $shipping_charge[ $i ]['country'] ); | |
| 7010 | + unset( $shipping_charge[ $i ]['value'] ); | |
| 7011 | + $update_shipping_charge = true; | |
| 7012 | + } | |
| 7013 | + } | |
| 7014 | + } | |
| 7015 | + if ( $update_shipping_charge ) { | |
| 7016 | + $this->options['shipping_charge'] = $shipping_charge; | |
| 7017 | + } | |
| 7018 | + | |
| 7019 | + $update_delivery_days = false; | |
| 7020 | + $delivery_days = isset( $this->options['delivery_days'] ) ? $this->options['delivery_days'] : array(); | |
| 7021 | + $delivery_days_count = ( $delivery_days && is_array( $delivery_days ) ) ? count( $delivery_days ) : 0; | |
| 7022 | + foreach ( (array) $target_market as $tm ) { | |
| 7023 | + for ( $i = 0; $i < $delivery_days_count; $i++ ) { | |
| 7024 | + if ( isset( $delivery_days[ $i ]['country'] ) && $delivery_days[ $i ]['country'] == $tm ) { | |
| 7025 | + foreach ( $delivery_days[ $i ]['value'] as $pref => $value ) { | |
| 7026 | + $delivery_days[ $i ][ $tm ][ $pref ] = $value; | |
| 7027 | + } | |
| 7028 | + unset( $delivery_days[ $i ]['country'] ); | |
| 7029 | + unset( $delivery_days[ $i ]['value'] ); | |
| 7030 | + $update_delivery_days = true; | |
| 7031 | + } | |
| 7032 | + } | |
| 7033 | + } | |
| 7034 | + if ( $update_delivery_days ) { | |
| 7035 | + $this->options['delivery_days'] = $delivery_days; | |
| 7036 | + } | |
| 7037 | + | |
| 7038 | + if ( $update_shipping_charge || $update_delivery_days ) { | |
| 7039 | + update_option( 'usces', $this->options ); | |
| 7040 | + } | |
| 7041 | + } | |
| 7042 | + | |
| 7043 | + public function get_item_cat_ids() { | |
| 7044 | + $ids = array(); | |
| 7045 | + $args = array( | |
| 7046 | + 'child_of' => USCES_ITEM_CAT_PARENT_ID, | |
| 7047 | + 'hide_empty' => 0, | |
| 7048 | + 'hierarchical' => 0, | |
| 7049 | + ); | |
| 7050 | + $categories = get_categories( $args ); | |
| 7051 | + foreach ( (array) $categories as $category ) { | |
| 7052 | + $ids[] = $category->term_id; | |
| 7053 | + } | |
| 7054 | + return $ids; | |
| 7055 | + } | |
| 7056 | + | |
| 7057 | + public function get_item_post_ids() { | |
| 7058 | + global $wpdb; | |
| 7059 | + $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item' ); | |
| 7060 | + $ids = $wpdb->get_col( $query ); | |
| 7061 | + | |
| 7062 | + return $ids; | |
| 7063 | + } | |
| 7064 | + | |
| 7065 | + public function get_item_cat_genre_ids( $post_id ) { | |
| 7066 | + $ids = array(); | |
| 7067 | + $all_ids = array(); | |
| 7068 | + $genre = get_category_by_slug( 'itemgenre' ); | |
| 7069 | + if ( ! empty( $genre->term_id ) ) { | |
| 7070 | + $genre_id = $genre->term_id; | |
| 7071 | + $args = array( | |
| 7072 | + 'child_of' => $genre_id, | |
| 7073 | + 'hide_empty' => 0, | |
| 7074 | + 'hierarchical' => 0, | |
| 7075 | + ); | |
| 7076 | + $categories = get_categories( $args ); | |
| 7077 | + foreach ( (array) $categories as $category ) { | |
| 7078 | + $ids[] = $category->term_id; | |
| 7079 | + } | |
| 7080 | + $allcats = get_the_category( $post_id ); | |
| 7081 | + foreach ( (array) $allcats as $cat ) { | |
| 7082 | + $all_ids[] = $cat->term_id; | |
| 7083 | + } | |
| 7084 | + $results = array_intersect( $ids, $all_ids ); | |
| 7085 | + } else { | |
| 7086 | + $results = array(); | |
| 7087 | + } | |
| 7088 | + return $results; | |
| 7089 | + } | |
| 7090 | + | |
| 7091 | + public function set_item_mime( $post_id, $str ) { | |
| 7092 | + global $wpdb; | |
| 7093 | + if ( WCUtils::is_blank( $str ) ) { | |
| 7094 | + return; | |
| 7095 | + } | |
| 7096 | + $query = $wpdb->prepare( "UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id ); | |
| 7097 | + $results = $wpdb->query( $query ); | |
| 7098 | + return $results; | |
| 7099 | + } | |
| 7100 | + | |
| 7101 | + public function isAdnminSSL() { | |
| 7102 | + $plugins = get_option( 'active_plugins' ); | |
| 7103 | + foreach ( $plugins as $plugin ) { | |
| 7104 | + if ( false !== strpos( $plugin, USCES_ADMIN_SSL_BASE_NAME ) ) { | |
| 7105 | + return true; | |
| 7106 | + } | |
| 7107 | + } | |
| 7108 | + return false; | |
| 7109 | + } | |
| 7110 | + | |
| 7111 | + public function getGuidTax() { | |
| 7112 | + if ( isset( $this->options['tax_display'] ) && 'deactivate' == $this->options['tax_display'] ) { | |
| 7113 | + $str = ''; | |
| 7114 | + } else { | |
| 7115 | + $tax_rate = (int) $this->options['tax_rate']; | |
| 7116 | + | |
| 7117 | + if ( isset( $this->options['tax_mode'] ) ) { | |
| 7118 | + if ( 'exclude' == $this->options['tax_mode'] ) { | |
| 7119 | + $str = '<em class="tax">' . __( '(Excl. Tax)', 'usces' ) . '</em>'; | |
| 7120 | + } else { | |
| 7121 | + $str = '<em class="tax">' . __( '(Incl. Tax)', 'usces' ) . '</em>'; | |
| 7122 | + } | |
| 7123 | + } else { | |
| 7124 | + if ( 0 < $tax_rate ) { | |
| 7125 | + $str = '<em class="tax">' . __( '(Excl. Tax)', 'usces' ) . '</em>'; | |
| 7126 | + } else { | |
| 7127 | + $str = '<em class="tax">' . __( '(Incl. Tax)', 'usces' ) . '</em>'; | |
| 7128 | + } | |
| 7129 | + } | |
| 7130 | + $str = apply_filters( 'usces_filter_tax_guid', $str, $tax_rate ); | |
| 7131 | + } | |
| 7132 | + return $str; | |
| 7133 | + } | |
| 7134 | + | |
| 7135 | + public function getItemCode( $post_id, $cache = true ) { | |
| 7136 | + $product = wel_get_product( $post_id, $cache ); | |
| 7137 | + $itemCode = isset( $product['itemCode'] ) ? $product['itemCode'] : null; | |
| 7138 | + return $itemCode; | |
| 7139 | + } | |
| 7140 | + | |
| 7141 | + public function getItemName( $post_id, $cache = true ) { | |
| 7142 | + $product = wel_get_product( $post_id, $cache ); | |
| 7143 | + $itemName = isset( $product['itemName'] ) ? $product['itemName'] : null; | |
| 7144 | + return $itemName; | |
| 7145 | + } | |
| 7146 | + | |
| 7147 | + public function getItemRestriction( $post_id, $cache = true ) { | |
| 7148 | + $product = wel_get_product( $post_id, $cache ); | |
| 7149 | + $itemRestriction = isset( $product['itemRestriction'] ) ? $product['itemRestriction'] : null; | |
| 7150 | + return $itemRestriction; | |
| 7151 | + } | |
| 7152 | + | |
| 7153 | + public function getItemOrderAcceptable( $post_id, $cache = true ) { | |
| 7154 | + $product = wel_get_product( $post_id, $cache ); | |
| 7155 | + $value = ( ! empty( $product['itemOrderAcceptable'] ) ) ? (int) $product['itemOrderAcceptable'] : 0; | |
| 7156 | + return $value; | |
| 7157 | + } | |
| 7158 | + | |
| 7159 | + public function getItemPointrate( $post_id, $cache = true ) { | |
| 7160 | + $product = wel_get_product( $post_id, $cache ); | |
| 7161 | + $itemPointrate = isset( $product['itemPointrate'] ) ? $product['itemPointrate'] : null; | |
| 7162 | + return $itemPointrate; | |
| 7163 | + } | |
| 7164 | + | |
| 7165 | + public function getItemShipping( $post_id, $cache = true ) { | |
| 7166 | + $product = wel_get_product( $post_id, $cache ); | |
| 7167 | + $itemShipping = isset( $product['itemShipping'] ) ? $product['itemShipping'] : null; | |
| 7168 | + return $itemShipping; | |
| 7169 | + } | |
| 7170 | + | |
| 7171 | + public function getItemShippingCharge( $post_id, $cache = true ) { | |
| 7172 | + $product = wel_get_product( $post_id, $cache ); | |
| 7173 | + $itemShippingCharge = isset( $product['itemShippingCharge'] ) ? (float) $product['itemShippingCharge'] : null; | |
| 7174 | + return $itemShippingCharge; | |
| 7175 | + } | |
| 7176 | + | |
| 7177 | + public function getItemDeliveryMethod( $post_id, $cache = true ) { | |
| 7178 | + $product = wel_get_product( $post_id, $cache ); | |
| 7179 | + if ( empty( $product['itemDeliveryMethod'] ) ) { | |
| 7180 | + return array(); | |
| 7181 | + } else { | |
| 7182 | + return $product['itemDeliveryMethod']; | |
| 7183 | + } | |
| 7184 | + } | |
| 7185 | + | |
| 7186 | + public function getItemIndividualSCharge( $post_id, $cache = true ) { | |
| 7187 | + $product = wel_get_product( $post_id, $cache ); | |
| 7188 | + $itemIndividualSCharge = isset( $product['itemIndividualSCharge'] ) ? $product['itemIndividualSCharge'] : null; | |
| 7189 | + return $itemIndividualSCharge; | |
| 7190 | + } | |
| 7191 | + | |
| 7192 | + public function getItemGpNum1( $post_id, $cache = true ) { | |
| 7193 | + $product = wel_get_product( $post_id, $cache ); | |
| 7194 | + $itemGpNum1 = isset( $product['itemGpNum1'] ) ? $product['itemGpNum1'] : null; | |
| 7195 | + return $itemGpNum1; | |
| 7196 | + } | |
| 7197 | + | |
| 7198 | + public function getItemGpNum2( $post_id, $cache = true ) { | |
| 7199 | + $product = wel_get_product( $post_id, $cache ); | |
| 7200 | + $itemGpNum2 = isset( $product['itemGpNum2'] ) ? $product['itemGpNum2'] : null; | |
| 7201 | + return $itemGpNum2; | |
| 7202 | + } | |
| 7203 | + | |
| 7204 | + public function getItemGpNum3( $post_id, $cache = true ) { | |
| 7205 | + $product = wel_get_product( $post_id, $cache ); | |
| 7206 | + $itemGpNum3 = isset( $product['itemGpNum3'] ) ? $product['itemGpNum3'] : null; | |
| 7207 | + return $itemGpNum3; | |
| 7208 | + } | |
| 7209 | + | |
| 7210 | + public function getItemGpDis1( $post_id, $cache = true ) { | |
| 7211 | + $product = wel_get_product( $post_id, $cache ); | |
| 7212 | + $itemGpDis1 = isset( $product['itemGpDis1'] ) ? $product['itemGpDis1'] : null; | |
| 7213 | + return $itemGpDis1; | |
| 7214 | + } | |
| 7215 | + | |
| 7216 | + public function getItemGpDis2( $post_id, $cache = true ) { | |
| 7217 | + $product = wel_get_product( $post_id, $cache ); | |
| 7218 | + $itemGpDis2 = isset( $product['itemGpDis2'] ) ? $product['itemGpDis2'] : null; | |
| 7219 | + return $itemGpDis2; | |
| 7220 | + } | |
| 7221 | + | |
| 7222 | + public function getItemGpDis3( $post_id, $cache = true ) { | |
| 7223 | + $product = wel_get_product( $post_id, $cache ); | |
| 7224 | + $itemGpDis3 = isset( $product['itemGpDis3'] ) ? $product['itemGpDis3'] : null; | |
| 7225 | + return $itemGpDis3; | |
| 7226 | + } | |
| 7227 | + | |
| 7228 | + /** | |
| 7229 | + * Unused function | |
| 7230 | + */ | |
| 7231 | + public function getItemSku( $post_id, $index = '', $cache = true ) { | |
| 7232 | + $array = array(); | |
| 7233 | + $skus = $this->get_skus( $post_id, 'sort', $cache ); | |
| 7234 | + foreach ( (array) $skus as $sku ) { | |
| 7235 | + $array[] = $sku['code']; | |
| 7236 | + } | |
| 7237 | + if ( ! $array ) { | |
| 7238 | + return false; | |
| 7239 | + } | |
| 7240 | + if ( '' == $index ) { | |
| 7241 | + return $array; | |
| 7242 | + } elseif ( isset( $array[ $index ] ) ) { | |
| 7243 | + return $array[ $index ]; | |
| 7244 | + } else { | |
| 7245 | + return false; | |
| 7246 | + } | |
| 7247 | + } | |
| 7248 | + | |
| 7249 | + public function getItemPrice( $post_id, $skukey = '', $cache = true ) { | |
| 7250 | + $array = array(); | |
| 7251 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7252 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7253 | + $array[ $key ] = (float) str_replace( ',', '', $sku['price'] ); | |
| 7254 | + } | |
| 7255 | + $array = apply_filters( 'usces_filter_get_item_price', $array, $post_id, $skukey, $skus ); | |
| 7256 | + if ( ! $array ) { | |
| 7257 | + return false; | |
| 7258 | + } | |
| 7259 | + if ( '' === $skukey ) { | |
| 7260 | + return $array; | |
| 7261 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7262 | + return $array[ $skukey ]; | |
| 7263 | + } else { | |
| 7264 | + return false; | |
| 7265 | + } | |
| 7266 | + } | |
| 7267 | + | |
| 7268 | + public function getItemDiscount( $post_id, $skukey = '', $cache = true ) { | |
| 7269 | + $display_mode = $this->options['display_mode']; | |
| 7270 | + $decimal = $this->get_currency_decimal(); | |
| 7271 | + $array = array(); | |
| 7272 | + | |
| 7273 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7274 | + $discount = 0; | |
| 7275 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7276 | + $price = (float) str_replace( ',', '', $sku['price'] ); | |
| 7277 | + if ( 'Promotionsale' == $display_mode ) { | |
| 7278 | + if ( 'discount' === $this->options['campaign_privilege'] ) { | |
| 7279 | + if ( 0 === (int) $this->options['campaign_category'] || in_category( (int) $this->options['campaign_category'], $post_id ) ) { | |
| 7280 | + $discount = (float) sprintf( '%.3f', $price * $this->options['privilege_discount'] / 100 ); | |
| 7281 | + } else { | |
| 7282 | + $discount = 0; | |
| 7283 | + } | |
| 7284 | + } elseif ( 'point' === $this->options['campaign_privilege'] ) { | |
| 7285 | + $discount = 0; | |
| 7286 | + } | |
| 7287 | + } | |
| 7288 | + if ( 0 != $discount ) { | |
| 7289 | + if ( 0 == $decimal ) { | |
| 7290 | + $discount = ceil( $discount ); | |
| 7291 | + } else { | |
| 7292 | + $decipad = (int) str_pad( '1', $decimal + 1, '0', STR_PAD_RIGHT ); | |
| 7293 | + $discount = ceil( $discount * $decipad ) / $decipad; | |
| 7294 | + } | |
| 7295 | + } | |
| 7296 | + $discount = apply_filters( 'usces_filter_getItemDiscount', $discount, $price, $post_id, $sku, $display_mode ); | |
| 7297 | + $array[ $key ] = $discount; | |
| 7298 | + } | |
| 7299 | + if ( ! $array ) { | |
| 7300 | + return false; | |
| 7301 | + } | |
| 7302 | + if ( '' === $skukey ) { | |
| 7303 | + return $array; | |
| 7304 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7305 | + return $array[ $skukey ]; | |
| 7306 | + } else { | |
| 7307 | + return false; | |
| 7308 | + } | |
| 7309 | + } | |
| 7310 | + | |
| 7311 | + public function getItemZaiko( $post_id, $skukey = '', $cache = true ) { | |
| 7312 | + $itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id ); | |
| 7313 | + $array = array(); | |
| 7314 | + | |
| 7315 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7316 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7317 | + $num = $sku['stock']; | |
| 7318 | + if ( 1 != $itemOrderAcceptable || WCUtils::is_blank( $sku['stocknum'] ) ) { | |
| 7319 | + $array[ $key ] = $this->zaiko_status[ $num ]; | |
| 7320 | + } else { | |
| 7321 | + if ( 2 > $num && 0 >= (int) $sku['stocknum'] ) { | |
| 7322 | + $array[ $key ] = ( ! empty( $this->options['order_acceptable_label'] ) ) ? $this->options['order_acceptable_label'] : __( 'Order acceptable', 'usces' ); | |
| 7323 | + } else { | |
| 7324 | + $array[ $key ] = $this->zaiko_status[ $num ]; | |
| 7325 | + } | |
| 7326 | + } | |
| 7327 | + } | |
| 7328 | + if ( ! $array ) { | |
| 7329 | + return false; | |
| 7330 | + } | |
| 7331 | + if ( '' === $skukey ) { | |
| 7332 | + return $array; | |
| 7333 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7334 | + return $array[ $skukey ]; | |
| 7335 | + } else { | |
| 7336 | + return false; | |
| 7337 | + } | |
| 7338 | + } | |
| 7339 | + | |
| 7340 | + public function getItemZaikoStatusId( $post_id, $skukey = '', $cache = true ) { | |
| 7341 | + $array = array(); | |
| 7342 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7343 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7344 | + $num = $sku['stock']; | |
| 7345 | + $array[ $key ] = $num; | |
| 7346 | + } | |
| 7347 | + if ( ! $array ) { | |
| 7348 | + return false; | |
| 7349 | + } | |
| 7350 | + if ( '' === $skukey ) { | |
| 7351 | + return $array; | |
| 7352 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7353 | + return $array[ $skukey ]; | |
| 7354 | + } else { | |
| 7355 | + return false; | |
| 7356 | + } | |
| 7357 | + } | |
| 7358 | + | |
| 7359 | + public function updateItemZaiko( $post_id, $skucode, $value ) { | |
| 7360 | + $res = usces_update_sku( $post_id, $skucode, 'stock', $value ); | |
| 7361 | + if ( ! $res ) { | |
| 7362 | + return false; | |
| 7363 | + } else { | |
| 7364 | + return true; | |
| 7365 | + } | |
| 7366 | + } | |
| 7367 | + | |
| 7368 | + public function getItemZaikoNum( $post_id, $skukey = '', $cache = true ) { | |
| 7369 | + $array = array(); | |
| 7370 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7371 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7372 | + $array[ $key ] = $sku['stocknum']; | |
| 7373 | + } | |
| 7374 | + if ( ! $array ) { | |
| 7375 | + return false; | |
| 7376 | + } | |
| 7377 | + if ( '' === $skukey ) { | |
| 7378 | + return $array; | |
| 7379 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7380 | + return $array[ $skukey ]; | |
| 7381 | + } else { | |
| 7382 | + return false; | |
| 7383 | + } | |
| 7384 | + } | |
| 7385 | + | |
| 7386 | + public function updateItemZaikoNum( $post_id, $skucode, $value ) { | |
| 7387 | + $res = usces_update_sku( $post_id, $skucode, 'stocknum', $value ); | |
| 7388 | + if ( ! $res ) { | |
| 7389 | + return false; | |
| 7390 | + } else { | |
| 7391 | + return true; | |
| 7392 | + } | |
| 7393 | + } | |
| 7394 | + | |
| 7395 | + public function getItemDivision( $post_id, $cache = true ) { | |
| 7396 | + if ( usces_is_item( $post_id ) ) { | |
| 7397 | + $product = wel_get_product( $post_id, $cache ); | |
| 7398 | + $item_division = $product['item_division']; | |
| 7399 | + $division = empty( $item_division ) ? 'shipped' : $item_division; | |
| 7400 | + } else { | |
| 7401 | + $division = null; | |
| 7402 | + } | |
| 7403 | + return $division; | |
| 7404 | + } | |
| 7405 | + | |
| 7406 | + public function getItemChargingType( $post_id, $cart = array(), $cache = true ) { | |
| 7407 | + if ( usces_is_item( $post_id ) ) { | |
| 7408 | + $product = wel_get_product( $post_id, $cache ); | |
| 7409 | + $charging = $product['item_charging_type']; | |
| 7410 | + if ( ! defined( 'WCEX_DLSELLER' ) && ! defined( 'WCEX_AUTO_DELIVERY' ) ) { | |
| 7411 | + $charging = null; | |
| 7412 | + } | |
| 7413 | + } else { | |
| 7414 | + $charging = null; | |
| 7415 | + } | |
| 7416 | + switch ( $charging ) { | |
| 7417 | + case 0: | |
| 7418 | + $type = 'once'; | |
| 7419 | + break; | |
| 7420 | + case 1: | |
| 7421 | + $type = 'continue'; | |
| 7422 | + break; | |
| 7423 | + case 2: | |
| 7424 | + $type = 'regular'; | |
| 7425 | + if ( ! empty( $cart ) ) { | |
| 7426 | + if ( empty( $cart['advance'] ) ) { | |
| 7427 | + $type = 'once'; | |
| 7428 | + } else { | |
| 7429 | + if ( is_array( $cart['advance'] ) && array_key_exists( 'regular', $cart['advance'] ) ) { | |
| 7430 | + $regular = wel_safe_maybe_unserialize( $cart['advance']['regular'] ); | |
| 7431 | + } else { | |
| 7432 | + $advance = $this->cart->wc_unserialize( $cart['advance'] ); | |
| 7433 | + $sku = urldecode( $cart['sku'] ); | |
| 7434 | + $sku_encoded = $cart['sku']; | |
| 7435 | + $regular = $advance[ $post_id ][ $sku_encoded ]['regular']; | |
| 7436 | + } | |
| 7437 | + $unit = isset( $regular['unit'] ) ? $regular['unit'] : ''; | |
| 7438 | + $interval = isset( $regular['interval'] ) ? (int) $regular['interval'] : 0; | |
| 7439 | + /* Treated as normal billing */ | |
| 7440 | + if ( empty( $unit ) || 1 > $interval ) { | |
| 7441 | + $type = 'once'; | |
| 7442 | + } | |
| 7443 | + } | |
| 7444 | + } | |
| 7445 | + break; | |
| 7446 | + default: | |
| 7447 | + $type = null; | |
| 7448 | + } | |
| 7449 | + return $type; | |
| 7450 | + } | |
| 7451 | + | |
| 7452 | + public function getItemFrequency( $post_id, $cache = true ) { | |
| 7453 | + $product = wel_get_product( $post_id, $cache ); | |
| 7454 | + return $product['item_frequency']; | |
| 7455 | + } | |
| 7456 | + | |
| 7457 | + public function getItemChargingDay( $post_id, $cache = true ) { | |
| 7458 | + $product = wel_get_product( $post_id, $cache ); | |
| 7459 | + $day = (int) $product['item_chargingday']; | |
| 7460 | + | |
| 7461 | + $chargingday = empty( $day ) ? 1 : $day; | |
| 7462 | + return $chargingday; | |
| 7463 | + } | |
| 7464 | + | |
| 7465 | + public function getItemSkuDisp( $post_id, $skukey = '', $cache = true ) { | |
| 7466 | + $array = array(); | |
| 7467 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7468 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7469 | + $array[ $key ] = $sku['name']; | |
| 7470 | + } | |
| 7471 | + if ( ! $array ) { | |
| 7472 | + return false; | |
| 7473 | + } | |
| 7474 | + if ( '' === $skukey ) { | |
| 7475 | + return $array; | |
| 7476 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7477 | + return $array[ $skukey ]; | |
| 7478 | + } else { | |
| 7479 | + return false; | |
| 7480 | + } | |
| 7481 | + } | |
| 7482 | + | |
| 7483 | + public function getItemSkuUnit( $post_id, $skukey = '', $cache = true ) { | |
| 7484 | + $array = array(); | |
| 7485 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7486 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7487 | + $array[ $key ] = $sku['unit']; | |
| 7488 | + } | |
| 7489 | + if ( ! $array ) { | |
| 7490 | + return false; | |
| 7491 | + } | |
| 7492 | + if ( '' === $skukey ) { | |
| 7493 | + return $array; | |
| 7494 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7495 | + return $array[ $skukey ]; | |
| 7496 | + } else { | |
| 7497 | + return false; | |
| 7498 | + } | |
| 7499 | + } | |
| 7500 | + | |
| 7501 | + public function getItemSkuAdvance( $post_id, $skukey = '', $cache = true ) { | |
| 7502 | + $array = array(); | |
| 7503 | + $skus = wel_get_skus( $post_id, 'code', $cache ); | |
| 7504 | + foreach ( (array) $skus as $key => $sku ) { | |
| 7505 | + $array[ $key ] = $sku['advance']; | |
| 7506 | + } | |
| 7507 | + if ( ! $array ) { | |
| 7508 | + return false; | |
| 7509 | + } | |
| 7510 | + if ( '' === $skukey ) { | |
| 7511 | + return $array; | |
| 7512 | + } elseif ( isset( $array[ $skukey ] ) ) { | |
| 7513 | + return $array[ $skukey ]; | |
| 7514 | + } else { | |
| 7515 | + return false; | |
| 7516 | + } | |
| 7517 | + } | |
| 7518 | + | |
| 7519 | + public function get_item( $post_id, $cache = true ) { | |
| 7520 | + return wel_get_product( $post_id, $cache ); | |
| 7521 | + } | |
| 7522 | + | |
| 7523 | + public function get_itemOptionKey( $post_id, $enc = false, $cache = true ) { | |
| 7524 | + $opts = usces_get_opts( $post_id, 'sort', $cache ); | |
| 7525 | + if ( empty( $opts ) ) { | |
| 7526 | + return; | |
| 7527 | + } | |
| 7528 | + | |
| 7529 | + $res = array(); | |
| 7530 | + foreach ( (array) $opts as $opt ) { | |
| 7531 | + if ( $enc ) { | |
| 7532 | + $res[] = urlencode( $opt['name'] ); | |
| 7533 | + } else { | |
| 7534 | + $res[] = $opt['name']; | |
| 7535 | + } | |
| 7536 | + } | |
| 7537 | + return $res; | |
| 7538 | + } | |
| 7539 | + | |
| 7540 | + public function get_itemOptions( $key, $post_id, $cache = true ) { | |
| 7541 | + $opts = wel_get_opts( $post_id, 'name', $cache ); | |
| 7542 | + if ( ! isset( $opts[ $key ] ) ) { | |
| 7543 | + return false; | |
| 7544 | + } else { | |
| 7545 | + return $opts[ $key ]; | |
| 7546 | + } | |
| 7547 | + } | |
| 7548 | + | |
| 7549 | + public function get_postIDbyCode( $item_code, $cache = true ) { | |
| 7550 | + if ( null === $item_code ) { | |
| 7551 | + return false; | |
| 7552 | + } | |
| 7553 | + | |
| 7554 | + $post_id = wel_get_id_by_item_code( $item_code, $cache ); | |
| 7555 | + | |
| 7556 | + return $post_id; | |
| 7557 | + } | |
| 7558 | + | |
| 7559 | + public function get_itemByCode( $item_code, $cache = true ) { | |
| 7560 | + if ( null === $item_code ) { | |
| 7561 | + return false; | |
| 7562 | + } | |
| 7563 | + | |
| 7564 | + $product = wel_get_product_by_code( $item_code, $cache ); | |
| 7565 | + | |
| 7566 | + return $product; | |
| 7567 | + } | |
| 7568 | + | |
| 7569 | + public function get_pictids( $item_code, $cache = true ) { | |
| 7570 | + return wel_get_sub_pict_ids_by_code( $item_code, $cache ); | |
| 7571 | + } | |
| 7572 | + | |
| 7573 | + public function get_mainpictid( $item_code, $cache = true ) { | |
| 7574 | + return wel_get_main_pict_id_by_code( $item_code, $cache ); | |
| 7575 | + } | |
| 7576 | + | |
| 7577 | + public function get_subpictid( $sku_code, $cache = true ) { | |
| 7578 | + global $wpdb; | |
| 7579 | + if ( empty( $sku_code) ) { | |
| 7580 | + return 0; | |
| 7581 | + } | |
| 7582 | + $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $sku_code ); | |
| 7583 | + $id = $wpdb->get_var( $query ); | |
| 7584 | + $id = apply_filters( 'usces_filter_get_subpictid', $id, $sku_code ); | |
| 7585 | + return $id; | |
| 7586 | + } | |
| 7587 | + | |
| 7588 | + public function get_skus( $post_id, $keyflag = 'sort', $cache = true ) { | |
| 7589 | + if ( null === $post_id ) { | |
| 7590 | + return false; | |
| 7591 | + } | |
| 7592 | + | |
| 7593 | + $skus = wel_get_skus( $post_id, $keyflag, $cache ); | |
| 7594 | + | |
| 7595 | + return $skus; | |
| 7596 | + } | |
| 7597 | + | |
| 7598 | + public function is_item( $post ) { | |
| 7599 | + if ( 'item' == $post->post_mime_type ) { | |
| 7600 | + return true; | |
| 7601 | + } else { | |
| 7602 | + return false; | |
| 7603 | + } | |
| 7604 | + } | |
| 7605 | + | |
| 7606 | + public function getItemIds( $end_type ) { | |
| 7607 | + global $wpdb; | |
| 7608 | + | |
| 7609 | + $cache_key = 'wel_item_ids_' . $end_type; | |
| 7610 | + | |
| 7611 | + $ids = wp_cache_get( $cache_key ); | |
| 7612 | + if ( false === $ids ) { | |
| 7613 | + | |
| 7614 | + if ( 'front' == $end_type ) { | |
| 7615 | + $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item' ); | |
| 7616 | + } | |
| 7617 | + if ( 'back' == $end_type ) { | |
| 7618 | + $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item' ); | |
| 7619 | + } | |
| 7620 | + $ids = $wpdb->get_col( $query ); | |
| 7621 | + | |
| 7622 | + if ( null !== $ids ) { | |
| 7623 | + wp_cache_set( $cache_key, $ids ); | |
| 7624 | + } | |
| 7625 | + } | |
| 7626 | + | |
| 7627 | + if ( null === $ids ) { | |
| 7628 | + return array(); | |
| 7629 | + } else { | |
| 7630 | + return $ids; | |
| 7631 | + } | |
| 7632 | + } | |
| 7633 | + | |
| 7634 | + public function getNotItemIds() { | |
| 7635 | + global $wpdb; | |
| 7636 | + $query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item' ); | |
| 7637 | + $ids = $wpdb->get_col( $query ); | |
| 7638 | + if ( empty( $ids ) ) { | |
| 7639 | + $ids = array(); | |
| 7640 | + } | |
| 7641 | + return $ids; | |
| 7642 | + } | |
| 7643 | + | |
| 7644 | + public function getPaymentMethod( $name ) { | |
| 7645 | + $res = array(); | |
| 7646 | + $payments = $this->options['payment_method']; | |
| 7647 | + foreach ( (array) $payments as $payment ) { | |
| 7648 | + if ( $name == $payment['name'] ) { | |
| 7649 | + $res = $payment; | |
| 7650 | + break; | |
| 7651 | + } | |
| 7652 | + } | |
| 7653 | + return $res; | |
| 7654 | + } | |
| 7655 | + | |
| 7656 | + public function order_processing( $results = array() ) { | |
| 7657 | + do_action( 'usces_pre_reg_orderdata' ); | |
| 7658 | + $acting = isset( $_REQUEST['acting'] ) ? $_REQUEST['acting'] : ''; | |
| 7659 | + global $usces; | |
| 7660 | + $usces_entries = $this->cart->get_entry(); | |
| 7661 | + $payments = $this->getPayments( $usces_entries['order']['payment_name'] ); | |
| 7662 | + $nonacting_settlements = apply_filters( 'usces_filter_nonacting_settlements', $this->nonacting_settlements ); | |
| 7663 | + | |
| 7664 | + $res = usces_check_acting_return_duplicate( $results ); | |
| 7665 | + if ( $res != null && ! in_array( $payments['settlement'], $nonacting_settlements ) ) { | |
| 7666 | + usces_log( 'order processing duplicate : acting=' . $acting . ', order_id=' . $res, 'acting_transaction.log' ); | |
| 7667 | + return 'ordercompletion'; | |
| 7668 | + } | |
| 7669 | + if ( isset( $_REQUEST['acting'] ) && ( 'jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'] ) ) { | |
| 7670 | + usces_log( $_REQUEST['acting'] . ' transaction : ' . $_REQUEST['gid'], 'acting_transaction.log' ); // OK. | |
| 7671 | + } | |
| 7672 | + if ( isset( $_REQUEST['acting'] ) && ( 'paypal_ec' == $_REQUEST['acting'] ) ) { | |
| 7673 | + if ( ! usces_paypal_doecp( $results ) ) { | |
| 7674 | + return 'error'; | |
| 7675 | + } | |
| 7676 | + } | |
| 7677 | + $order_id = usces_reg_orderdata( $results ); | |
| 7678 | + do_action( 'usces_post_reg_orderdata', $order_id, $results ); | |
| 7679 | + | |
| 7680 | + if ( $order_id ) { | |
| 7681 | + // mail(function.php). | |
| 7682 | + $mail_res = usces_send_ordermail( $order_id ); | |
| 7683 | + return 'ordercompletion'; | |
| 7684 | + | |
| 7685 | + } else { | |
| 7686 | + return 'error'; | |
| 7687 | + } | |
| 7688 | + } | |
| 7689 | + | |
| 7690 | + /** | |
| 7691 | + * 決済処理 | |
| 7692 | + * | |
| 7693 | + * @param string $acting_flg Payment type. | |
| 7694 | + * @param array $post_query Post data. | |
| 7695 | + * @param string $acting_status Status. | |
| 7696 | + * @return mixed | |
| 7697 | + */ | |
| 7698 | + public function acting_processing( $acting_flg, $post_query, $acting_status ) { | |
| 7699 | + global $wpdb; | |
| 7700 | + | |
| 7701 | + $entry = $this->cart->get_entry(); | |
| 7702 | + $delim = apply_filters( 'usces_filter_delim', $this->delim ); | |
| 7703 | + $acting_flg = trim( $acting_flg ); | |
| 7704 | + | |
| 7705 | + if ( empty( $acting_flg ) ) { | |
| 7706 | + return 'error'; | |
| 7707 | + } | |
| 7708 | + | |
| 7709 | + if ( 'paypal.php' == $acting_flg ) { | |
| 7710 | + | |
| 7711 | + } elseif ( 'epsilon.php' == $acting_flg ) { | |
| 7712 | + | |
| 7713 | + } elseif ( 'acting_paypal_ec' == $acting_flg ) { | |
| 7714 | + $acting_opts = $this->options['acting_settings']['paypal']; | |
| 7715 | + $addroverride = '1'; | |
| 7716 | + if ( isset( $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) ) { | |
| 7717 | + if ( 'US' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] || 'CA' == $_POST['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) { | |
| 7718 | + $addroverride = '0'; | |
| 7719 | + } | |
| 7720 | + } else { | |
| 7721 | + $addroverride = '0'; | |
| 7722 | + } | |
| 7723 | + $rand = ( isset( $_POST['PAYMENTREQUEST_0_CUSTOM'] ) ) ? $_POST['PAYMENTREQUEST_0_CUSTOM'] : '(empty key)'; | |
| 7724 | + | |
| 7725 | + $nvpstr = $post_query; | |
| 7726 | + $nvpstr .= '&ADDROVERRIDE=' . $addroverride; | |
| 7727 | + $nvpstr .= '&PAYMENTREQUEST_0_PAYMENTACTION=' . apply_filters( 'usces_filter_paypal_ec_paymentaction', 'Sale' ); | |
| 7728 | + | |
| 7729 | + // The returnURL is the location where buyers return to when a payment has been succesfully authorized. | |
| 7730 | + $nvpstr .= '&RETURNURL=' . urlencode( USCES_CART_URL . $delim . 'acting=paypal_ec&acting_return=1' ); | |
| 7731 | + | |
| 7732 | + // The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow. | |
| 7733 | + $cancelurl = urlencode( USCES_CART_URL . $delim . 'confirm=1' ); | |
| 7734 | + $pos = strpos( $post_query, 'paypal_from_cart' ); | |
| 7735 | + if ( false !== $pos ) { | |
| 7736 | + $cancelurl = urlencode( USCES_CART_URL ); | |
| 7737 | + } | |
| 7738 | + $nvpstr .= '&CANCELURL=' . apply_filters( 'usces_filter_paypal_ec_cancelurl', $cancelurl, $post_query ); | |
| 7739 | + | |
| 7740 | + $nvpstr .= '&PAYMENTREQUEST_0_NOTIFYURL=' . urlencode( USCES_PAYPAL_NOTIFY_URL ); | |
| 7741 | + | |
| 7742 | + // Seamless checkout. | |
| 7743 | + if ( isset( $_SESSION['liwpp']['token'] ) && ! empty( $_SESSION['liwpp']['token'] ) ) { | |
| 7744 | + $nvpstr .= '&IDENTITYACCESSTOKEN=' . $_SESSION['liwpp']['token']; | |
| 7745 | + } | |
| 7746 | + | |
| 7747 | + $this->paypal->setMethod( 'SetExpressCheckout' ); | |
| 7748 | + $this->paypal->setData( $nvpstr ); | |
| 7749 | + $res = $this->paypal->doExpressCheckout(); | |
| 7750 | + $resArray = $this->paypal->getResponse(); | |
| 7751 | + $ack = strtoupper( $resArray['ACK'] ); | |
| 7752 | + if ( 'SUCCESS' == $ack || 'SUCCESSWITHWARNING' == $ack ) { | |
| 7753 | + $token = urldecode( $resArray['TOKEN'] ); | |
| 7754 | + $payPalURL = $acting_opts['paypal_url'] . '?cmd=_express-checkout&token=' . $token . '&useraction=commit'; | |
| 7755 | + header( 'Location: ' . $payPalURL ); | |
| 7756 | + | |
| 7757 | + } else { | |
| 7758 | + // Display a user friendly Error on the page using any of the following error information returned by PayPal. | |
| 7759 | + $ErrorCode = urldecode( $resArray['L_ERRORCODE0'] ); | |
| 7760 | + $ErrorShortMsg = urldecode( $resArray['L_SHORTMESSAGE0'] ); | |
| 7761 | + $ErrorLongMsg = urldecode( $resArray['L_LONGMESSAGE0'] ); | |
| 7762 | + $ErrorSeverityCode = urldecode( $resArray['L_SEVERITYCODE0'] ); | |
| 7763 | + 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' ); | |
| 7764 | + $log = array( | |
| 7765 | + 'acting' => 'paypal_ec', | |
| 7766 | + 'key' => $rand, | |
| 7767 | + 'result' => $ack, | |
| 7768 | + 'data' => $resArray, | |
| 7769 | + ); | |
| 7770 | + usces_save_order_acting_error( $log ); | |
| 7771 | + header( 'Location: ' . USCES_CART_URL . $delim . 'acting=paypal_ec&acting_return=0' ); | |
| 7772 | + } | |
| 7773 | + exit; | |
| 7774 | + | |
| 7775 | + } elseif ( 'acting_telecom_edy' == $acting_flg ) { /* テレコムクレジット Edy決済 */ | |
| 7776 | + $table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 7777 | + $value = array(); | |
| 7778 | + $value['usces_cart'] = $_SESSION['usces_cart']; | |
| 7779 | + $value['usces_entry'] = $_SESSION['usces_entry']; | |
| 7780 | + $value['usces_member'] = $_SESSION['usces_member']; | |
| 7781 | + $mvalue = serialize( $value ); | |
| 7782 | + $mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue ); | |
| 7783 | + $res = $wpdb->query( $mquery ); | |
| 7784 | + | |
| 7785 | + unset( $_SESSION['usces_cart'] ); | |
| 7786 | + unset( $_SESSION['usces_entry'] ); | |
| 7787 | + | |
| 7788 | + $acting_opts = $this->options['acting_settings']['telecom']; | |
| 7789 | + header( 'location: ' . $acting_opts['send_url_edy'] . '?acting=telecom_edy' . $post_query ); | |
| 7790 | + exit; | |
| 7791 | + | |
| 7792 | + } elseif ( 'acting_digitalcheck_card' == $acting_flg ) { /* ペイメントフォー カード決済(旧メタップスペイメント、旧デジタルチェック、旧ペイデザイン) */ | |
| 7793 | + $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 7794 | + $interface = parse_url( $acting_opts['send_url_user_id'] ); | |
| 7795 | + $kakutei = ( empty( $acting_opts['card_kakutei'] ) ) ? '0' : $acting_opts['card_kakutei']; | |
| 7796 | + | |
| 7797 | + $params = array( | |
| 7798 | + 'IP' => $acting_opts['card_ip'], | |
| 7799 | + 'PASS' => $acting_opts['card_pass'], | |
| 7800 | + 'SID' => $_POST['SID'], | |
| 7801 | + 'IP_USER_ID' => $_POST['IP_USER_ID'], | |
| 7802 | + 'N1' => $_POST['N1'], | |
| 7803 | + 'K1' => $_POST['K1'], | |
| 7804 | + 'FUKA' => $acting_flg, | |
| 7805 | + 'KAKUTEI' => $kakutei, | |
| 7806 | + ); | |
| 7807 | + $vars = http_build_query( $params ); | |
| 7808 | + | |
| 7809 | + $header = 'POST ' . $interface['path'] . " HTTP/1.1\r\n"; | |
| 7810 | + $header .= 'Host: ' . $interface['host'] . "\r\n"; | |
| 7811 | + $header .= "User-Agent: PHP Script\r\n"; | |
| 7812 | + $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| 7813 | + $header .= 'Content-Length: ' . strlen( $vars ) . "\r\n"; | |
| 7814 | + $header .= "Connection: close\r\n\r\n"; | |
| 7815 | + $header .= $vars; | |
| 7816 | + | |
| 7817 | + $fp = @stream_socket_client( 'tlsv1.2://' . $interface['host'] . ':443', $errno, $errstr, 30 ); | |
| 7818 | + if ( ! $fp ) { | |
| 7819 | + // usces_log( 'digitalcheck card : TLS(v1.2) Error', 'acting_transaction.log' ); | |
| 7820 | + $log = array( | |
| 7821 | + 'acting' => 'digitalcheck_card', | |
| 7822 | + 'key' => $_POST['SID'], | |
| 7823 | + 'result' => 'SSL/TLS ERROR (' . $errno . ')', | |
| 7824 | + 'data' => array( $errstr ), | |
| 7825 | + ); | |
| 7826 | + usces_save_order_acting_error( $log ); | |
| 7827 | + wp_redirect( | |
| 7828 | + add_query_arg( | |
| 7829 | + array( | |
| 7830 | + 'acting' => 'digitalcheck_card', | |
| 7831 | + 'acting_return' => 0, | |
| 7832 | + ), | |
| 7833 | + USCES_CART_URL | |
| 7834 | + ) | |
| 7835 | + ); | |
| 7836 | + exit(); | |
| 7837 | + } | |
| 7838 | + | |
| 7839 | + if ( $fp ) { | |
| 7840 | + fwrite( $fp, $header ); | |
| 7841 | + $headerdone = false; | |
| 7842 | + $page = ''; | |
| 7843 | + while ( ! feof( $fp ) ) { | |
| 7844 | + $line = fgets( $fp, 1024 ); | |
| 7845 | + if ( 0 == strcmp( $line, "\r\n" ) ) { | |
| 7846 | + $headerdone = true; | |
| 7847 | + } elseif ( $headerdone ) { | |
| 7848 | + $page .= $line; | |
| 7849 | + } | |
| 7850 | + } | |
| 7851 | + fclose( $fp ); | |
| 7852 | + $lines = explode( "\n", $page ); | |
| 7853 | + if ( false !== strpos( $lines[0], 'OK' ) ) { | |
| 7854 | + // usces_log( 'digitalcheck card entry data (acting_processing) : ' . print_r( $entry, true ), 'acting_transaction.log'); | |
| 7855 | + wp_redirect( | |
| 7856 | + add_query_arg( | |
| 7857 | + array( | |
| 7858 | + 'acting' => 'digitalcheck_card', | |
| 7859 | + 'acting_return' => 1, | |
| 7860 | + 'SID' => $_POST['SID'], | |
| 7861 | + 'FUKA' => $acting_flg, | |
| 7862 | + ), | |
| 7863 | + USCES_CART_URL | |
| 7864 | + ) | |
| 7865 | + ); | |
| 7866 | + exit(); | |
| 7867 | + } else { | |
| 7868 | + // usces_log( 'digitalcheck card : Certification Error : ' . $page, 'acting_transaction.log' ); | |
| 7869 | + $log = array( | |
| 7870 | + 'acting' => 'digitalcheck_card', | |
| 7871 | + 'key' => $_POST['SID'], | |
| 7872 | + 'result' => 'CERTIFICATION ERROR', | |
| 7873 | + 'data' => $lines, | |
| 7874 | + ); | |
| 7875 | + usces_save_order_acting_error( $log ); | |
| 7876 | + wp_redirect( | |
| 7877 | + add_query_arg( | |
| 7878 | + array( | |
| 7879 | + 'acting' => 'digitalcheck_card', | |
| 7880 | + 'acting_return' => 0, | |
| 7881 | + ), | |
| 7882 | + USCES_CART_URL | |
| 7883 | + ) | |
| 7884 | + ); | |
| 7885 | + exit(); | |
| 7886 | + } | |
| 7887 | + } | |
| 7888 | + exit(); | |
| 7889 | + | |
| 7890 | + } elseif ( 'acting_digitalcheck_conv' == $acting_flg ) { /* ペイメントフォー コンビニ決済(旧メタップスペイメント、旧デジタルチェック、旧ペイデザイン) */ | |
| 7891 | + if ( isset( $_REQUEST['STORE'] ) && '99' != $_REQUEST['STORE'] ) { | |
| 7892 | + $res = $this->order_processing(); | |
| 7893 | + if ( 'ordercompletion' == $res ) { | |
| 7894 | + $table_meta_name = $wpdb->prefix . 'usces_order_meta'; | |
| 7895 | + $mquery = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] ); | |
| 7896 | + $order_id = $wpdb->get_var( $mquery ); | |
| 7897 | + if ( $order_id ) { | |
| 7898 | + $data = array( | |
| 7899 | + 'settltment_status' => __( 'Failure', 'usces' ), | |
| 7900 | + 'settltment_errmsg' => __( 'Settlement was not completed.', 'usces' ), | |
| 7901 | + ); | |
| 7902 | + $this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id ); | |
| 7903 | + $this->set_order_meta_value( 'wc_trans_id', $_REQUEST['SID'], $order_id ); | |
| 7904 | + } | |
| 7905 | + $this->cart->crear_cart(); | |
| 7906 | + $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 7907 | + header( 'location: ' . $acting_opts['send_url_conv'] . '?acting=digitalcheck_conv' . $post_query ); | |
| 7908 | + exit; | |
| 7909 | + } else { | |
| 7910 | + // usces_log( 'digitalcheck conv : order processing error', 'acting_transaction.log' ); | |
| 7911 | + $log = array( | |
| 7912 | + 'acting' => 'digitalcheck_conv', | |
| 7913 | + 'key' => $_REQUEST['SID'], | |
| 7914 | + 'result' => 'ORDER DATA REGISTERED ERROR', | |
| 7915 | + 'data' => $_REQUEST, | |
| 7916 | + ); | |
| 7917 | + usces_save_order_acting_error( $log ); | |
| 7918 | + header( 'location: ' . USCES_CART_URL . $delim . 'acting=digitalcheck_conv&acting_return=0' ); | |
| 7919 | + exit; | |
| 7920 | + } | |
| 7921 | + } else { | |
| 7922 | + $acting_opts = $this->options['acting_settings']['digitalcheck']; | |
| 7923 | + header( 'location: ' . $acting_opts['send_url_conv'] . '?acting=digitalcheck_conv' . $post_query ); | |
| 7924 | + exit; | |
| 7925 | + } | |
| 7926 | + | |
| 7927 | + } elseif ( 'acting_veritrans_card' == $acting_flg || 'acting_veritrans_conv' == $acting_flg ) { /* ベリトランス カード決済・コンビニ決済 */ | |
| 7928 | + $acting_opts = $this->options['acting_settings']['veritrans']; | |
| 7929 | + $acting = substr( $acting_flg, 7 ); | |
| 7930 | + $dummy_payment_flag = ( 'public' == $acting_opts['ope'] ) ? '0' : '1'; | |
| 7931 | + $order_id = isset( $_POST['ORDER_ID'] ) ? $_POST['ORDER_ID'] : ''; | |
| 7932 | + $regist_url = ( defined( 'VERITRANS_SHA2_TEST' ) ) ? 'https://sair.veritrans.co.jp/web/commodityRegist.action' : $acting_opts['regist_url']; | |
| 7933 | + $url = parse_url( $regist_url ); | |
| 7934 | + $path = empty( $url['path'] ) ? '/' : $url['path']; | |
| 7935 | + | |
| 7936 | + $postdata = $post_query; | |
| 7937 | + if ( 'acting_veritrans_card' == $acting_flg ) { | |
| 7938 | + $card_capture_flag = ( 'capture' == $acting_opts['card_capture_flag'] ) ? '1' : '0'; | |
| 7939 | + $postdata .= '&CARD_CAPTURE_FLAG=' . $card_capture_flag; | |
| 7940 | + } | |
| 7941 | + if ( 'acting_veritrans_conv' == $acting_flg ) { | |
| 7942 | + $postdata .= '&NAME1=' . urlencode( mb_substr( mb_convert_kana( $entry['customer']['name1'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ) ); | |
| 7943 | + $postdata .= '&NAME2=' . urlencode( mb_substr( mb_convert_kana( $entry['customer']['name2'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ) ); | |
| 7944 | + if ( ! empty( $entry['customer']['name3'] ) ) { | |
| 7945 | + $kana1 = mb_substr( mb_convert_kana( $entry['customer']['name3'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ); | |
| 7946 | + mb_regex_encoding( 'UTF-8' ); | |
| 7947 | + if ( mb_ereg( "^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana1 ) ) { | |
| 7948 | + $postdata .= '&KANA1=' . urlencode( $kana1 ); | |
| 7949 | + } | |
| 7950 | + } | |
| 7951 | + if ( ! empty( $entry['customer']['name4'] ) ) { | |
| 7952 | + $kana2 = mb_substr( mb_convert_kana( $entry['customer']['name4'], 'ASKV', 'UTF-8' ), 0, 10, 'UTF-8' ); | |
| 7953 | + mb_regex_encoding( 'UTF-8' ); | |
| 7954 | + if ( mb_ereg( "^[ア-ン゛゜ァ-ォャ-ョー]+$", $kana2 ) ) { | |
| 7955 | + $postdata .= '&KANA2=' . urlencode( $kana2 ); | |
| 7956 | + } | |
| 7957 | + } | |
| 7958 | + $postdata .= '&TELEPHONE_NO=' . str_replace( '-', '', $entry['customer']['tel'] ); | |
| 7959 | + if ( 1 < (int) $acting_opts['conv_timelimit'] && (int) $acting_opts['conv_timelimit'] <= 60 ) { | |
| 7960 | + $timelimit = date( 'Ymd', strtotime( '+' . $acting_opts['conv_timelimit'] . ' days' ) ); | |
| 7961 | + $postdata .= '&TIMELIMIT_OF_PAYMENT=' . $timelimit; | |
| 7962 | + } | |
| 7963 | + } | |
| 7964 | + if ( 'on' == $acting_opts['mailaddress'] ) { | |
| 7965 | + $postdata .= '&MAILADDRESS=' . $entry['customer']['mailaddress1']; | |
| 7966 | + } | |
| 7967 | + $postdata .= '&MERCHANT_ID=' . $acting_opts['merchant_id']; | |
| 7968 | + $postdata .= '&SESSION_ID=' . session_id(); | |
| 7969 | + $postdata .= '&FINISH_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&acting_return=1&result=1' ); | |
| 7970 | + $postdata .= '&UNFINISH_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&confirm=1' ); | |
| 7971 | + $postdata .= '&ERROR_PAYMENT_RETURN_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting . '&acting_return=0' ); | |
| 7972 | + $postdata .= '&FINISH_PAYMENT_ACCESS_URL=' . urlencode( USCES_CART_URL . $delim . 'acting=' . $acting ); | |
| 7973 | + $postdata .= '&DUMMY_PAYMENT_FLAG=' . $dummy_payment_flag; | |
| 7974 | + | |
| 7975 | + $postlength = strlen( $postdata ); | |
| 7976 | + | |
| 7977 | + $request = 'POST ' . $path . ' HTTP/1.1' . "\r\n"; | |
| 7978 | + $request .= 'Host: ' . $url['host'] . "\r\n"; | |
| 7979 | + $request .= 'User-Agent: HttpRequest Powered by ' . phpversion() . "\r\n"; | |
| 7980 | + $request .= 'Connection: close' . "\r\n"; | |
| 7981 | + $request .= 'Accept-Language: ja' . "\r\n"; | |
| 7982 | + $request .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; | |
| 7983 | + $request .= 'Content-Length: ' . $postlength . "\r\n\r\n"; | |
| 7984 | + $request .= $postdata; | |
| 7985 | + | |
| 7986 | + $code = 0; | |
| 7987 | + $resBody = ''; | |
| 7988 | + $con = @stream_socket_client( 'tlsv1.2://' . $url['host'] . ':443', $errno, $errstr, 30 ); | |
| 7989 | + if ( ! $con ) { | |
| 7990 | + usces_log( 'Veritrans : TLS(v1.2) Error', 'acting_transaction.log' ); | |
| 7991 | + $con = @fsockopen( 'ssl://' . $url['host'], 443, $errno, $errstr, 30 ); | |
| 7992 | + if ( ! $con ) { | |
| 7993 | + usces_log( 'Veritrans : SSL Error', 'acting_transaction.log' ); | |
| 7994 | + $log = array( | |
| 7995 | + 'acting' => $acting, | |
| 7996 | + 'key' => $order_id, | |
| 7997 | + 'result' => 'SSL/TLS ERROR (' . $errno . ')', | |
| 7998 | + 'data' => array( $errstr ), | |
| 7999 | + ); | |
| 8000 | + usces_save_order_acting_error( $log ); | |
| 8001 | + header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' ); | |
| 8002 | + exit; | |
| 8003 | + } | |
| 8004 | + } | |
| 8005 | + | |
| 8006 | + if ( $con ) { | |
| 8007 | + $ret = fwrite( $con, $request ); | |
| 8008 | + if ( $ret == strlen( $request ) ) { | |
| 8009 | + $res = $this->readResponse( $con ); | |
| 8010 | + $code = $res['Code']; | |
| 8011 | + $resBody = $res['Body']; | |
| 8012 | + | |
| 8013 | + } else { | |
| 8014 | + usces_log( 'Veritrans Write NG: Sent:' . strlen( $request ) . ' Send:' . $ret, 'acting_transaction.log' ); | |
| 8015 | + } | |
| 8016 | + fclose( $con ); | |
| 8017 | + } | |
| 8018 | + | |
| 8019 | + // 正常終了(200 OK)が返ったか. | |
| 8020 | + if ( 200 == intval( $code ) ) { | |
| 8021 | + $merchantKey = null; | |
| 8022 | + $browserKey = null; | |
| 8023 | + $scd = null; | |
| 8024 | + $error_message = null; | |
| 8025 | + | |
| 8026 | + // レスポンスデータからマーチャントキー、ブラウザキーを取得. | |
| 8027 | + $bodyLine = explode( "\n", $resBody ); | |
| 8028 | + foreach ( $bodyLine as $line ) { | |
| 8029 | + if ( preg_match( '/^MERCHANT_ENCRYPTION_KEY=(.+)/', $line, $match ) ) { | |
| 8030 | + $merchantKey = $match[1]; | |
| 8031 | + } elseif ( preg_match( '/^BROWSER_ENCRYPTION_KEY=(.+)/', $line, $match ) ) { | |
| 8032 | + $browserKey = $match[1]; | |
| 8033 | + } elseif ( preg_match('/^SCD=(.+)/', $line, $match ) ) { | |
| 8034 | + $scd = $match[1]; | |
| 8035 | + } elseif ( preg_match( '/^ERROR_MESSAGE=(.+)/', $line, $match ) ) { | |
| 8036 | + $error_message = $match[1]; | |
| 8037 | + } | |
| 8038 | + } | |
| 8039 | + | |
| 8040 | + // 両方取れたらOK。SCDはカードでセキュリティコードが入力された場合のみ. | |
| 8041 | + if ( ! is_null( $merchantKey ) && ! is_null( $browserKey ) ) { | |
| 8042 | + $getdata = '?MERCHANT_ID=' . $acting_opts['merchant_id']; | |
| 8043 | + $getdata .= '&ORDER_ID=' . $order_id; | |
| 8044 | + $getdata .= '&BROWSER_ENCRYPTION_KEY=' . urlencode( $browserKey ); | |
| 8045 | + $payment_url = ( defined( 'VERITRANS_SHA2_TEST' ) ) ? 'https://sair.veritrans.co.jp/web/paymentStart.action' : $acting_opts['payment_url']; | |
| 8046 | + header( 'location: ' . $payment_url . $getdata ); | |
| 8047 | + | |
| 8048 | + } else { | |
| 8049 | + if ( ! is_null( $error_message ) ) { | |
| 8050 | + usces_log( 'Veritrans AWeb:' . $error_message, 'acting_transaction.log' ); | |
| 8051 | + $log = array( | |
| 8052 | + 'acting' => $acting, | |
| 8053 | + 'key' => $order_id, | |
| 8054 | + 'result' => $code, | |
| 8055 | + 'data' => $bodyLine, | |
| 8056 | + ); | |
| 8057 | + usces_save_order_acting_error( $log ); | |
| 8058 | + } | |
| 8059 | + header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' ); | |
| 8060 | + } | |
| 8061 | + | |
| 8062 | + } else { | |
| 8063 | + usces_log( 'Veritrans Response NG: ' . $resBody, 'acting_transaction.log' ); | |
| 8064 | + $bodyLine = explode( "\n", $resBody ); | |
| 8065 | + $log = array( | |
| 8066 | + 'acting' => $acting, | |
| 8067 | + 'key' => $order_id, | |
| 8068 | + 'result' => $code, | |
| 8069 | + 'data' => $bodyLine, | |
| 8070 | + ); | |
| 8071 | + usces_save_order_acting_error( $log ); | |
| 8072 | + header( 'location: ' . USCES_CART_URL . $delim . 'acting=' . $acting_flg . '&acting_return=0' ); | |
| 8073 | + } | |
| 8074 | + exit; | |
| 8075 | + } | |
| 8076 | + | |
| 8077 | + do_action( 'usces_action_acting_processing', $acting_flg, $post_query ); | |
| 8078 | + $acting_status = apply_filters( 'usces_filter_acting_processing', $acting_flg, $post_query, $acting_status ); | |
| 8079 | + return $acting_status; | |
| 8080 | + } | |
| 8081 | + | |
| 8082 | + private function readResponse( $fp ) { | |
| 8083 | + $res = array( | |
| 8084 | + 'Status' => '', | |
| 8085 | + 'Version' => '', | |
| 8086 | + 'Code' => 0, | |
| 8087 | + 'Message' => '', | |
| 8088 | + 'Headers' => array(), | |
| 8089 | + 'Body' => '', | |
| 8090 | + ); | |
| 8091 | + | |
| 8092 | + // HTTPステータスの読み込み. | |
| 8093 | + $line = $this->readLine( $fp ); | |
| 8094 | + if ( 0 == preg_match( '/^(HTTP\/1\.[0-9x]+)\s+([0-9]+)\s+(.+)/i', $line, $match ) ) { | |
| 8095 | + return $res; | |
| 8096 | + } | |
| 8097 | + $res['Status'] = $line; | |
| 8098 | + $res['Version'] = $match[1]; | |
| 8099 | + $res['Code'] = $match[2]; | |
| 8100 | + $res['Message'] = $match[3]; | |
| 8101 | + | |
| 8102 | + // レスポンスヘッダの読み込み. | |
| 8103 | + while ( ! feof( $fp ) ) { | |
| 8104 | + $line = $this->readLine( $fp ); | |
| 8105 | + if ( '' != $line ) { | |
| 8106 | + list( $hname, $hvalue ) = explode( ':', $line, 2 ); | |
| 8107 | + $res['Headers'][ strtolower( $hname ) ] = ltrim( $hvalue ); | |
| 8108 | + } else { | |
| 8109 | + break; | |
| 8110 | + } | |
| 8111 | + } | |
| 8112 | + // レスポンスデータの読み込み. | |
| 8113 | + while ( ! feof( $fp ) ) { | |
| 8114 | + $data = $this->readLine( $fp ) . "\n"; | |
| 8115 | + if ( '' == $data ) { | |
| 8116 | + break; | |
| 8117 | + } | |
| 8118 | + $res['Body'] .= $data; | |
| 8119 | + } | |
| 8120 | + return $res; | |
| 8121 | + } | |
| 8122 | + | |
| 8123 | + private function readLine( $fp ) { | |
| 8124 | + if ( ! $fp ) { | |
| 8125 | + return ''; | |
| 8126 | + } | |
| 8127 | + // レスポンスデータを受信. | |
| 8128 | + $line = null; | |
| 8129 | + while ( ! feof( $fp ) ) { | |
| 8130 | + $line .= @fgets( $fp, 4096 ); | |
| 8131 | + if ( "\n" == substr( $line, -1 ) ) { | |
| 8132 | + return rtrim( $line, "\r\n" ); | |
| 8133 | + } | |
| 8134 | + } | |
| 8135 | + return $line; | |
| 8136 | + } | |
| 8137 | + | |
| 8138 | + public function inquiry_processing() { | |
| 8139 | + $mail_res = usces_send_inquirymail(); | |
| 8140 | + | |
| 8141 | + if ( $mail_res ) { | |
| 8142 | + return 'inquiry_comp'; | |
| 8143 | + } else { | |
| 8144 | + return 'inquiry_error'; | |
| 8145 | + } | |
| 8146 | + } | |
| 8147 | + | |
| 8148 | + public function lastprocessing() { | |
| 8149 | + if ( 'ordercompletion' == $this->page ) { | |
| 8150 | + $this->cart->crear_cart(); | |
| 8151 | + } | |
| 8152 | + do_action( 'usces_action_lastprocessing' ); | |
| 8153 | + | |
| 8154 | + unset( $_SESSION['usces_singleitem'] ); | |
| 8155 | + } | |
| 8156 | + | |
| 8157 | + public function is_item_zaiko( $post_id, $sku_code ) { | |
| 8158 | + $res = false; | |
| 8159 | + $status_num = false; | |
| 8160 | + $zaiko_num = false; | |
| 8161 | + if ( ! empty( $post_id ) ) { | |
| 8162 | + $sku_code = (string) $sku_code; | |
| 8163 | + $status_num = $this->getItemZaikoStatusId( $post_id, $sku_code ); | |
| 8164 | + $zaiko_num = $this->getItemZaikoNum( $post_id, $sku_code ); | |
| 8165 | + $itemOrderAcceptable = $this->getItemOrderAcceptable( $post_id ); | |
| 8166 | + if ( 1 != $itemOrderAcceptable ) { | |
| 8167 | + if ( false !== $zaiko_num | |
| 8168 | + && ( 0 < (int) $zaiko_num || WCUtils::is_blank( $zaiko_num ) ) | |
| 8169 | + && false !== $status_num | |
| 8170 | + && 2 > (int) $status_num ) { | |
| 8171 | + $res = true; | |
| 8172 | + } else { | |
| 8173 | + $res = false; | |
| 8174 | + } | |
| 8175 | + } else { | |
| 8176 | + if ( false !== $status_num | |
| 8177 | + && 2 > (int) $status_num ) { | |
| 8178 | + $res = true; | |
| 8179 | + } else { | |
| 8180 | + $res = false; | |
| 8181 | + } | |
| 8182 | + } | |
| 8183 | + } | |
| 8184 | + return apply_filters( 'usces_is_item_zaiko', $res, $post_id, $sku_code, $status_num, $zaiko_num ); | |
| 8185 | + } | |
| 8186 | + | |
| 8187 | + public function get_total_price( $cart = array() ) { | |
| 8188 | + if ( empty( $cart ) ) { | |
| 8189 | + $cart = $this->cart->get_cart(); | |
| 8190 | + } | |
| 8191 | + $total_price = 0; | |
| 8192 | + | |
| 8193 | + if ( ! empty( $cart ) ) { | |
| 8194 | + $cart_count = ( is_array( $cart ) ) ? count( $cart ) : 0; | |
| 8195 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 8196 | + $quantity = (float) $cart[ $i ]['quantity']; | |
| 8197 | + $skuPrice = (float) $cart[ $i ]['price']; | |
| 8198 | + | |
| 8199 | + $total_price += ( $skuPrice * $quantity ); | |
| 8200 | + } | |
| 8201 | + } | |
| 8202 | + return apply_filters( 'usces_filter_get_total_price', $total_price, $cart ); | |
| 8203 | + } | |
| 8204 | + | |
| 8205 | + public function get_total_quantity( $cart = array() ) { | |
| 8206 | + if ( empty( $cart ) ) { | |
| 8207 | + $cart = $this->cart->get_cart(); | |
| 8208 | + } | |
| 8209 | + $total_quantity = 0; | |
| 8210 | + | |
| 8211 | + if ( ! empty( $cart ) ) { | |
| 8212 | + $cart_count = ( is_array( $cart ) ) ? count( $cart ) : 0; | |
| 8213 | + for ( $i = 0; $i < $cart_count; $i++ ) { | |
| 8214 | + $total_quantity += (float) $cart[ $i ]['quantity']; | |
| 8215 | + } | |
| 8216 | + } | |
| 8217 | + return $total_quantity; | |
| 8218 | + } | |
| 8219 | + | |
| 8220 | + public function get_order_point( $mem_id = '', $display_mode = '', $cart = array() ) { | |
| 8221 | + if ( '' == $mem_id || 'deactivate' == $this->options['membersystem_state'] || 'deactivate' == $this->options['membersystem_point'] ) { | |
| 8222 | + return 0; | |
| 8223 | + } | |
| 8224 | + | |
| 8225 | + if ( empty( $cart ) ) { | |
| 8226 | + $cart = $this->cart->get_cart(); | |
| 8227 | + } | |
| 8228 | + if ( empty( $display_mode ) ) { | |
| 8229 | + $display_mode = $this->options['display_mode']; | |
| 8230 | + } | |
| 8231 | + $point = 0; | |
| 8232 | + $total = $this->get_total_price( $cart ); | |
| 8233 | + if ( 'Promotionsale' == $display_mode ) { | |
| 8234 | + if ( 'discount' == $this->options['campaign_privilege'] ) { | |
| 8235 | + foreach ( $cart as $rows ) { | |
| 8236 | + $cats = $this->get_post_term_ids( $rows['post_id'], 'category' ); | |
| 8237 | + if ( ! in_array( $this->options['campaign_category'], $cats ) ) { | |
| 8238 | + $product = wel_get_product( $rows['post_id'] ); | |
| 8239 | + $rate = (float) $product['itemPointrate']; | |
| 8240 | + $price = (float) $rows['price'] * (float) $rows['quantity']; | |
| 8241 | + $point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 ) ); | |
| 8242 | + } | |
| 8243 | + } | |
| 8244 | + } elseif ( 'point' == $this->options['campaign_privilege'] ) { | |
| 8245 | + foreach ( $cart as $rows ) { | |
| 8246 | + $product = wel_get_product( $rows['post_id'] ); | |
| 8247 | + $rate = (float) $product['itemPointrate']; | |
| 8248 | + $price = (float) $rows['price'] * (float) $rows['quantity']; | |
| 8249 | + $cats = $this->get_post_term_ids( $rows['post_id'], 'category' ); | |
| 8250 | + if ( in_array( $this->options['campaign_category'], $cats ) ) { | |
| 8251 | + $point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 * (float) $this->options['privilege_point'] ) ); | |
| 8252 | + } else { | |
| 8253 | + $point = (float) sprintf( '%.3f', $point + ( $price * $rate / 100 ) ); | |
| 8254 | + } | |
| 8255 | + } | |
| 8256 | + } | |
| 8257 | + } else { | |
| 8258 | + foreach ( $cart as $rows ) { | |
| 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 | + | |
| 8266 | + $entry = $this->cart->get_entry(); | |
| 8267 | + $use_point = isset( $entry['order']['usedpoint'] ) ? (int) $entry['order']['usedpoint'] : 0; | |
| 8268 | + if ( 0 < $use_point && 0 < $total ) { | |
| 8269 | + $point = (float) sprintf( '%.3f', $point - ( $point * $use_point / $total ) ); | |
| 8270 | + $point = ceil( $point ); | |
| 8271 | + if ( 0 > $point ) { | |
| 8272 | + $point = 0; | |
| 8273 | + } | |
| 8274 | + } else { | |
| 8275 | + if ( 0 < $point ) { | |
| 8276 | + $point = ceil( $point ); | |
| 8277 | + } | |
| 8278 | + } | |
| 8279 | + | |
| 8280 | + return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart ); | |
| 8281 | + } | |
| 8282 | + | |
| 8283 | + public function get_order_discount( $display_mode = '', $cart = array() ) { | |
| 8284 | + if ( empty( $cart ) ) { | |
| 8285 | + $cart = $this->cart->get_cart(); | |
| 8286 | + } | |
| 8287 | + if ( empty( $display_mode ) ) { | |
| 8288 | + $display_mode = $this->options['display_mode']; | |
| 8289 | + } | |
| 8290 | + $discount = 0; | |
| 8291 | + if ( 'Promotionsale' == $display_mode ) { | |
| 8292 | + if ( 'discount' == $this->options['campaign_privilege'] ) { | |
| 8293 | + if ( 0 === (int) $this->options['campaign_category'] ) { | |
| 8294 | + $total = $this->get_total_price( $cart ); | |
| 8295 | + $discount = (float) sprintf( '%.3f', $total * (float) $this->options['privilege_discount'] / 100 ); | |
| 8296 | + } else { | |
| 8297 | + foreach ( $cart as $cart_row ) { | |
| 8298 | + if ( in_category( (int) $this->options['campaign_category'], $cart_row['post_id'] ) ) { | |
| 8299 | + $discount += (float) sprintf( '%.3f', (float) $cart_row['price'] * (float) $cart_row['quantity'] * (float) $this->options['privilege_discount'] / 100 ); | |
| 8300 | + } | |
| 8301 | + } | |
| 8302 | + } | |
| 8303 | + if ( 0 != $discount ) { | |
| 8304 | + $decimal = $this->get_currency_decimal(); | |
| 8305 | + if ( 0 == $decimal ) { | |
| 8306 | + $discount = ceil( $discount ); | |
| 8307 | + } else { | |
| 8308 | + $decipad = (int) str_pad( '1', $decimal + 1, '0', STR_PAD_RIGHT ); | |
| 8309 | + $discount = ceil( $discount * $decipad ) / $decipad; | |
| 8310 | + } | |
| 8311 | + $discount = $discount * -1; | |
| 8312 | + } | |
| 8313 | + } elseif ( 'point' == $this->options['campaign_privilege'] ) { | |
| 8314 | + $discount = 0; | |
| 8315 | + } | |
| 8316 | + } | |
| 8317 | + $discount = apply_filters( 'usces_order_discount', $discount, $cart ); | |
| 8318 | + return $discount; | |
| 8319 | + } | |
| 8320 | + | |
| 8321 | + public function getShippingCharge( $pref, $cart = array(), $entry = array() ) { | |
| 8322 | + if ( empty( $cart ) ) { | |
| 8323 | + $cart = $this->cart->get_cart(); | |
| 8324 | + } | |
| 8325 | + if ( empty( $entry ) ) { | |
| 8326 | + $entry = $this->cart->get_entry(); | |
| 8327 | + } | |
| 8328 | + if ( function_exists( 'dlseller_have_shipped' ) && ! dlseller_have_shipped() ) { | |
| 8329 | + $charge = 0; | |
| 8330 | + $charge = apply_filters( 'usces_filter_getShippingCharge', $charge, $cart, $entry ); | |
| 8331 | + return $charge; | |
| 8332 | + } | |
| 8333 | + | |
| 8334 | + // 配送方法ID. | |
| 8335 | + $d_method_id = $entry['order']['delivery_method']; | |
| 8336 | + // 配送方法index. | |
| 8337 | + $d_method_index = $this->get_delivery_method_index( $d_method_id ); | |
| 8338 | + // 送料ID. | |
| 8339 | + $fixed_charge_id = ( isset( $this->options['delivery_method'][ $d_method_index ]['charge'] ) ) ? $this->options['delivery_method'][ $d_method_index ]['charge'] : -1; | |
| 8340 | + $individual_quant = 0; | |
| 8341 | + $total_quant = 0; | |
| 8342 | + $charges = array(); | |
| 8343 | + $individual_charges = array(); | |
| 8344 | + $country = ( isset( $entry['delivery']['country'] ) && ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : $entry['customer']['country']; | |
| 8345 | + | |
| 8346 | + foreach ( $cart as $rows ) { | |
| 8347 | + | |
| 8348 | + if ( 'shipped' !== $this->getItemDivision( $rows['post_id'] ) ) { | |
| 8349 | + continue; | |
| 8350 | + } | |
| 8351 | + | |
| 8352 | + if ( -1 == $fixed_charge_id ) { | |
| 8353 | + // 商品送料ID. | |
| 8354 | + $s_charge_id = $this->getItemShippingCharge( $rows['post_id'] ); | |
| 8355 | + // 商品送料index. | |
| 8356 | + $s_charge_index = $this->get_shipping_charge_index( $s_charge_id ); | |
| 8357 | + $s_charge = isset( $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] ) ? (float) $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] : 0; | |
| 8358 | + } else { | |
| 8359 | + $s_charge_index = $this->get_shipping_charge_index( $fixed_charge_id ); | |
| 8360 | + $s_charge = isset( $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] ) ? (float) $this->options['shipping_charge'][ $s_charge_index ][ $country ][ $pref ] : 0; | |
| 8361 | + } | |
| 8362 | + | |
| 8363 | + if ( $this->getItemIndividualSCharge( $rows['post_id'] ) ) { | |
| 8364 | + $individual_quant += (float) $rows['quantity']; | |
| 8365 | + $individual_charges[] = (float) $rows['quantity'] * $s_charge; | |
| 8366 | + } else { | |
| 8367 | + $charges[] = $s_charge; | |
| 8368 | + } | |
| 8369 | + $total_quant += $rows['quantity']; | |
| 8370 | + } | |
| 8371 | + | |
| 8372 | + if ( count( $charges ) > 0 ) { | |
| 8373 | + rsort( $charges ); | |
| 8374 | + $max_charge = $charges[0]; | |
| 8375 | + $charge = $max_charge + array_sum( array_filter( $individual_charges, 'is_numeric' ) ); | |
| 8376 | + } else { | |
| 8377 | + $charge = array_sum( array_filter( $individual_charges, 'is_numeric' ) ); | |
| 8378 | + } | |
| 8379 | + | |
| 8380 | + $charge = apply_filters( 'usces_filter_getShippingCharge', $charge, $cart, $entry ); | |
| 8381 | + | |
| 8382 | + return $charge; | |
| 8383 | + } | |
| 8384 | + | |
| 8385 | + public function getCODFee( $payment_name, $amount_by_cod, $current_entries ) { | |
| 8386 | + global $usces_entries; | |
| 8387 | + | |
| 8388 | + $payments = $this->getPayments( $payment_name ); | |
| 8389 | + if ( ! isset( $payments['settlement'] ) || 'COD' != $payments['settlement'] ) { | |
| 8390 | + $fee = 0; | |
| 8391 | + | |
| 8392 | + } elseif ( 'change' != $this->options['cod_type'] ) { | |
| 8393 | + $fee = isset( $this->options['cod_fee'] ) ? $this->options['cod_fee'] : 0; | |
| 8394 | + | |
| 8395 | + } else { | |
| 8396 | + $materials = array( | |
| 8397 | + 'total_items_price' => $current_entries['order']['total_items_price'], | |
| 8398 | + 'discount' => ( isset( $current_entries['order']['discount'] ) ) ? $current_entries['order']['discount'] : 0, | |
| 8399 | + 'shipping_charge' => ( isset( $current_entries['order']['shipping_charge'] ) ) ? $current_entries['order']['shipping_charge'] : 0, | |
| 8400 | + 'cod_fee' => 0, | |
| 8401 | + 'use_point' => 0, | |
| 8402 | + ); | |
| 8403 | + $price = $amount_by_cod + $this->getTax( $amount_by_cod, $materials ); | |
| 8404 | + if ( $price <= $this->options['cod_first_amount'] ) { | |
| 8405 | + $fee = $this->options['cod_first_fee']; | |
| 8406 | + | |
| 8407 | + } elseif ( isset( $this->options['cod_amounts'] ) ) { | |
| 8408 | + $last = count( $this->options['cod_amounts'] ) - 1; | |
| 8409 | + if ( $price > $this->options['cod_amounts'][ $last ] ) { | |
| 8410 | + $fee = $this->options['cod_end_fee']; | |
| 8411 | + | |
| 8412 | + } else { | |
| 8413 | + $fee = 0; | |
| 8414 | + foreach ( $this->options['cod_amounts'] as $key => $value ) { | |
| 8415 | + if ( $price <= $value ) { | |
| 8416 | + $fee = $this->options['cod_fees'][ $key ]; | |
| 8417 | + break; | |
| 8418 | + } | |
| 8419 | + } | |
| 8420 | + } | |
| 8421 | + } else { | |
| 8422 | + $fee = $this->options['cod_end_fee']; | |
| 8423 | + } | |
| 8424 | + } | |
| 8425 | + $fee = apply_filters( 'usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod, $current_entries ); | |
| 8426 | + return $fee; | |
| 8427 | + } | |
| 8428 | + | |
| 8429 | + public function getTax( $total, $materials = array() ) { | |
| 8430 | + global $usces_settings; | |
| 8431 | + | |
| 8432 | + if ( isset( $this->options['tax_display'] ) && 'deactivate' == $this->options['tax_display'] ) { | |
| 8433 | + return 0; | |
| 8434 | + } | |
| 8435 | + if ( empty( $this->options['tax_rate'] ) ) { | |
| 8436 | + return 0; | |
| 8437 | + } | |
| 8438 | + // if ( ! empty( $materials ) ) { | |
| 8439 | + // extract( $materials );//need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' ) | |
| 8440 | + // } | |
| 8441 | + | |
| 8442 | + if ( $this->is_reduced_taxrate() ) { | |
| 8443 | + if ( 'include' == $this->options['tax_mode'] ) { | |
| 8444 | + return 0; | |
| 8445 | + } | |
| 8446 | + if ( ! empty( $materials ) ) { | |
| 8447 | + extract( $materials ); | |
| 8448 | + if ( empty( $carts ) ) { | |
| 8449 | + $carts = array(); | |
| 8450 | + $materials = compact( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point', 'carts' ); | |
| 8451 | + } | |
| 8452 | + } | |
| 8453 | + | |
| 8454 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 8455 | + $usces_tax->get_order_tax( $materials ); | |
| 8456 | + $tax = apply_filters( 'usces_filter_getTax', $usces_tax->tax, $materials ); | |
| 8457 | + | |
| 8458 | + } else { | |
| 8459 | + | |
| 8460 | + if ( empty( $materials ) ) { | |
| 8461 | + | |
| 8462 | + if ( 'include' == $this->options['tax_mode'] ) { | |
| 8463 | + $tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / ( 100 + (float) $this->options['tax_rate'] ) ); | |
| 8464 | + } else { | |
| 8465 | + $tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / 100 ); | |
| 8466 | + } | |
| 8467 | + | |
| 8468 | + } else { | |
| 8469 | + if ( 'include' == $this->options['tax_mode'] ) { | |
| 8470 | + return 0; | |
| 8471 | + } | |
| 8472 | + | |
| 8473 | + extract( $materials ); // need( 'total_items_price', 'shipping_charge', 'discount', 'cod_fee', 'use_point' ). | |
| 8474 | + | |
| 8475 | + if ( 1 == $this->options['point_coverage'] ) { | |
| 8476 | + if ( 'products' == $this->options['tax_target'] ) { | |
| 8477 | + $total = (float) $total_items_price + (float) $discount; | |
| 8478 | + } else { | |
| 8479 | + $total = (float) $total_items_price + (float) $discount + (float) $shipping_charge + (float) $cod_fee; | |
| 8480 | + } | |
| 8481 | + } else { | |
| 8482 | + if ( 'products' == $this->options['tax_target'] ) { | |
| 8483 | + $total = (float) $total_items_price + (float) $discount; | |
| 8484 | + } else { | |
| 8485 | + if ( empty( $use_point ) ) { | |
| 8486 | + $use_point = 0; | |
| 8487 | + } | |
| 8488 | + $total = (float) $total_items_price + (float) $discount - (int) $use_point + (float) $shipping_charge + (float) $cod_fee; | |
| 8489 | + } | |
| 8490 | + } | |
| 8491 | + $total = apply_filters( 'usces_filter_getTax_total', $total, $materials ); | |
| 8492 | + | |
| 8493 | + $tax = (float) sprintf( '%.3f', (float) $total * (float) $this->options['tax_rate'] / 100 ); | |
| 8494 | + } | |
| 8495 | + | |
| 8496 | + $tax = usces_tax_rounding_off( $tax ); | |
| 8497 | + $tax = apply_filters( 'usces_filter_getTax', $tax, $materials ); | |
| 8498 | + } | |
| 8499 | + | |
| 8500 | + return $tax; | |
| 8501 | + } | |
| 8502 | + | |
| 8503 | + public function set_cart_fees( $member, $entries ) { | |
| 8504 | + global $usces_entries; | |
| 8505 | + | |
| 8506 | + $carts = $this->cart->get_cart(); | |
| 8507 | + $entries = $this->cart->get_entry(); | |
| 8508 | + $total_items_price = $this->get_total_price(); | |
| 8509 | + $entries['order']['total_items_price'] = $total_items_price; | |
| 8510 | + | |
| 8511 | + if ( empty( $this->options['postage_privilege'] ) || $total_items_price < $this->options['postage_privilege'] ) { | |
| 8512 | + $shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'], $carts, $entries ); | |
| 8513 | + } else { | |
| 8514 | + $shipping_charge = 0; | |
| 8515 | + } | |
| 8516 | + $shipping_charge = apply_filters( 'usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries ); | |
| 8517 | + $entries['order']['shipping_charge'] = $shipping_charge; | |
| 8518 | + | |
| 8519 | + $payments = $this->getPayments( $entries['order']['payment_name'] ); | |
| 8520 | + $use_point = ( isset( $entries['order']['usedpoint'] ) ) ? (int) $entries['order']['usedpoint'] : 0; | |
| 8521 | + if ( $this->is_reduced_taxrate() ) { | |
| 8522 | + $usces_tax = Welcart_Tax::get_instance(); | |
| 8523 | + $discount = $usces_tax->get_order_discount( $carts ); | |
| 8524 | + $entries['order']['discount'] = $discount; | |
| 8525 | + $amount_by_cod = $total_items_price - $use_point + $discount; | |
| 8526 | + if ( 'all' == usces_is_fee_subject() ) { | |
| 8527 | + $amount_by_cod += $shipping_charge; | |
| 8528 | + } | |
| 8529 | + $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 ); | |
| 8530 | + $cod_fee = $this->getCODFee( $entries['order']['payment_name'], $amount_by_cod, $entries ); | |
| 8531 | + $cod_fee = apply_filters( 'usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod ); | |
| 8532 | + $entries['order']['cod_fee'] = $cod_fee; | |
| 8533 | + | |
| 8534 | + if ( 'include' == $this->options['tax_mode'] ) { | |
| 8535 | + $tax = 0; | |
| 8536 | + } else { | |
| 8537 | + $materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point' ); | |
| 8538 | + $usces_tax->get_order_tax( $materials ); | |
| 8539 | + $tax = apply_filters( 'usces_filter_getTax', $usces_tax->tax, $materials ); | |
| 8540 | + } | |
| 8541 | + | |
| 8542 | + $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee; | |
| 8543 | + if ( $total_price < 0 ) { | |
| 8544 | + $total_price = 0; | |
| 8545 | + } | |
| 8546 | + $total_price = apply_filters( 'usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee ); | |
| 8547 | + | |
| 8548 | + } else { | |
| 8549 | + $discount = $this->get_order_discount( null, $carts ); | |
| 8550 | + $entries['order']['discount'] = $discount; | |
| 8551 | + $amount_by_cod = $total_items_price - $use_point + $discount; | |
| 8552 | + if ( 'all' == usces_is_fee_subject() ) { | |
| 8553 | + $amount_by_cod += $shipping_charge; | |
| 8554 | + } | |
| 8555 | + $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 ); | |
| 8556 | + $cod_fee = $this->getCODFee( $entries['order']['payment_name'], $amount_by_cod, $entries ); | |
| 8557 | + $cod_fee = apply_filters( 'usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge, $amount_by_cod ); | |
| 8558 | + $entries['order']['cod_fee'] = $cod_fee; | |
| 8559 | + | |
| 8560 | + $total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee; | |
| 8561 | + if ( $total_price < 0 ) { | |
| 8562 | + $total_price = 0; | |
| 8563 | + } | |
| 8564 | + $total_price = apply_filters( 'usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee ); | |
| 8565 | + | |
| 8566 | + $materials = compact( 'member', 'entries', 'carts', 'total_items_price', 'shipping_charge', 'payments', 'discount', 'cod_fee', 'use_point' ); | |
| 8567 | + $tax = $this->getTax( $total_price, $materials ); | |
| 8568 | + } | |
| 8569 | + $entries['order']['total_price'] = $total_price; | |
| 8570 | + $entries['order']['tax'] = $tax; | |
| 8571 | + | |
| 8572 | + if ( 'exclude' == $this->options['tax_mode'] ) { | |
| 8573 | + if ( 0 < $use_point ) { | |
| 8574 | + $total_full_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee + $tax; | |
| 8575 | + if ( $total_full_price < 0 ) { | |
| 8576 | + $total_full_price = 0; | |
| 8577 | + } | |
| 8578 | + } else { | |
| 8579 | + $total_full_price = $total_price + $tax; | |
| 8580 | + } | |
| 8581 | + } else { | |
| 8582 | + $total_full_price = $total_price; | |
| 8583 | + } | |
| 8584 | + | |
| 8585 | + $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 ); | |
| 8586 | + $entries['order']['total_full_price'] = $total_full_price; | |
| 8587 | + | |
| 8588 | + $mem_id = isset( $member['ID'] ) ? $member['ID'] : null; | |
| 8589 | + $get_point = $this->get_order_point( $mem_id ); | |
| 8590 | + $get_point = apply_filters( 'usces_filter_set_get_point', $get_point, $entries, $carts ); | |
| 8591 | + | |
| 8592 | + $array = array( | |
| 8593 | + 'total_items_price' => $total_items_price, | |
| 8594 | + 'total_price' => $total_price, | |
| 8595 | + 'total_full_price' => $total_full_price, | |
| 8596 | + 'getpoint' => $get_point, | |
| 8597 | + 'usedpoint' => $use_point, | |
| 8598 | + 'discount' => $discount, | |
| 8599 | + 'shipping_charge' => $shipping_charge, | |
| 8600 | + 'cod_fee' => $cod_fee, | |
| 8601 | + 'tax' => $tax, | |
| 8602 | + ); | |
| 8603 | + $this->cart->set_order_entry( $array ); | |
| 8604 | + $usces_entries = $this->cart->get_entry(); | |
| 8605 | + } | |
| 8606 | + | |
| 8607 | + public function getPayments( $payment_name ) { | |
| 8608 | + $init = array( | |
| 8609 | + 'id' => null, | |
| 8610 | + 'name' => null, | |
| 8611 | + 'explanation' => null, | |
| 8612 | + 'settlement' => null, | |
| 8613 | + 'module' => null, | |
| 8614 | + 'sort' => null, | |
| 8615 | + 'use' => null, | |
| 8616 | + ); | |
| 8617 | + | |
| 8618 | + if ( '#none#' == $payment_name ) { | |
| 8619 | + return $init; | |
| 8620 | + } | |
| 8621 | + $payments = usces_get_system_option( 'usces_payment_method', 'name' ); | |
| 8622 | + if ( isset( $payments[ $payment_name ] ) ) { | |
| 8623 | + return $payments[ $payment_name ]; | |
| 8624 | + } | |
| 8625 | + return $init; | |
| 8626 | + } | |
| 8627 | + | |
| 8628 | + public function is_maintenance() { | |
| 8629 | + if ( 'Maintenancemode' == $this->options['display_mode'] ) { | |
| 8630 | + return true; | |
| 8631 | + } else { | |
| 8632 | + return false; | |
| 8633 | + } | |
| 8634 | + } | |
| 8635 | + | |
| 8636 | + public function get_member_history( $mem_id, $allow_filter = false ) { | |
| 8637 | + global $wpdb; | |
| 8638 | + $order_table = $wpdb->prefix . 'usces_order'; | |
| 8639 | + | |
| 8640 | + if ( is_user_logged_in() && is_admin() ) { | |
| 8641 | + | |
| 8642 | + $query = $wpdb->prepare( "SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id ); | |
| 8643 | + $query = apply_filters( 'usces_filter_member_history_query', $query, $mem_id, $allow_filter ); | |
| 8644 | + $results = $wpdb->get_results( $query ); | |
| 8645 | + | |
| 8646 | + } elseif ( ! is_admin() ) { | |
| 8647 | + | |
| 8648 | + $cancel_query = '%cancel%'; | |
| 8649 | + $estimate_query = '%estimate%'; | |
| 8650 | + $exclude_cancel = $this->usces_get_member_cookies( 'ord_ex_cancel' ); | |
| 8651 | + if ( $allow_filter && 'on' === (string) $exclude_cancel ) { | |
| 8652 | + $condition = ' ( order_status NOT LIKE %s AND order_status NOT LIKE %s ) '; | |
| 8653 | + } else { | |
| 8654 | + $condition = ' ( order_status LIKE %s OR order_status NOT LIKE %s ) '; | |
| 8655 | + } | |
| 8656 | + | |
| 8657 | + $pur_date = $this->usces_get_member_cookies( 'pur-date' ); | |
| 8658 | + if ( $allow_filter && $pur_date ) { | |
| 8659 | + $now = current_time( 'timestamp' ); | |
| 8660 | + $type_filter = 'date'; | |
| 8661 | + if ( false !== strpos( $pur_date, 'y_' ) ) { | |
| 8662 | + $type_filter = 'year'; | |
| 8663 | + } elseif ( false !== strpos( $pur_date, 'm_' ) ) { | |
| 8664 | + $type_filter = 'month'; | |
| 8665 | + } | |
| 8666 | + if ( 'year' === $type_filter ) { | |
| 8667 | + $purchase_year = (int) str_replace( 'y_', '', $pur_date ); | |
| 8668 | + } elseif ( 'month' === $type_filter ) { | |
| 8669 | + $month_ago = (int) str_replace( 'm_', '', $pur_date ); | |
| 8670 | + $first_day_of_previous_months = strtotime( "first day of -{$month_ago} months", $now ); | |
| 8671 | + $last_day_of_previous_months = strtotime( "last day of -{$month_ago} months", $now ); | |
| 8672 | + $purchase_date_from_string = date( 'Y-m-d 00:00:00', $first_day_of_previous_months ); | |
| 8673 | + $purchase_date_to_string = date( 'Y-m-d 23:59:59', $last_day_of_previous_months ); | |
| 8674 | + } else { | |
| 8675 | + $pur_date_val = (int) str_replace( 'd_', '', $pur_date ); | |
| 8676 | + $previous_date = strtotime( "-{$pur_date_val} days", $now ); | |
| 8677 | + $purchase_date_string = date( 'Y-m-d 00:00:00', $previous_date ); | |
| 8678 | + } | |
| 8679 | + if ( 'year' === $type_filter ) { | |
| 8680 | + $query = $wpdb->prepare( | |
| 8681 | + "SELECT * FROM $order_table WHERE mem_id = %d AND YEAR(order_date) = %d AND {$condition} ORDER BY order_date DESC", | |
| 8682 | + $mem_id, | |
| 8683 | + $purchase_year, | |
| 8684 | + $cancel_query, | |
| 8685 | + $estimate_query | |
| 8686 | + ); | |
| 8687 | + } elseif ( 'month' === $type_filter ) { | |
| 8688 | + $query = $wpdb->prepare( | |
| 8689 | + "SELECT * FROM $order_table WHERE mem_id = %d AND order_date >= %s AND order_date <= %s AND {$condition} ORDER BY order_date DESC", | |
| 8690 | + $mem_id, | |
| 8691 | + $purchase_date_from_string, | |
| 8692 | + $purchase_date_to_string, | |
| 8693 | + $cancel_query, | |
| 8694 | + $estimate_query | |
| 8695 | + ); | |
| 8696 | + } else { | |
| 8697 | + $query = $wpdb->prepare( | |
| 8698 | + "SELECT * FROM $order_table WHERE mem_id = %d AND order_date >= %s AND {$condition} ORDER BY order_date DESC", | |
| 8699 | + $mem_id, | |
| 8700 | + $purchase_date_string, | |
| 8701 | + $cancel_query, | |
| 8702 | + $estimate_query | |
| 8703 | + ); | |
| 8704 | + } | |
| 8705 | + } else { | |
| 8706 | + $query = $wpdb->prepare( | |
| 8707 | + "SELECT * FROM $order_table WHERE mem_id = %d AND {$condition} ORDER BY order_date DESC", | |
| 8708 | + $mem_id, | |
| 8709 | + $cancel_query, | |
| 8710 | + $estimate_query | |
| 8711 | + ); | |
| 8712 | + } | |
| 8713 | + | |
| 8714 | + $query = apply_filters( 'usces_filter_member_history_query_front', $query, $mem_id, $allow_filter ); | |
| 8715 | + $results = $wpdb->get_results( $query ); | |
| 8716 | + } | |
| 8717 | + | |
| 8718 | + $i = 0; | |
| 8719 | + $res = array(); | |
| 8720 | + | |
| 8721 | + foreach ( $results as $value ) { | |
| 8722 | + $cart = usces_get_ordercartdata( $value->ID ); | |
| 8723 | + $total_items_price = $this->get_total_price( $cart ); | |
| 8724 | + | |
| 8725 | + $data = array( | |
| 8726 | + 'ID' => $value->ID, | |
| 8727 | + 'cart' => $cart, | |
| 8728 | + 'condition' => wel_safe_unserialize( $value->order_condition ), | |
| 8729 | + 'getpoint' => $value->order_getpoint, | |
| 8730 | + 'usedpoint' => $value->order_usedpoint, | |
| 8731 | + 'discount' => $value->order_discount, | |
| 8732 | + 'shipping_charge' => $value->order_shipping_charge, | |
| 8733 | + 'payment_name' => $value->order_payment_name, | |
| 8734 | + 'cod_fee' => $value->order_cod_fee, | |
| 8735 | + 'tax' => $value->order_tax, | |
| 8736 | + 'total_items_price' => $total_items_price, | |
| 8737 | + 'order_status' => $value->order_status, | |
| 8738 | + 'date' => mysql2date( __( 'Y/m/d' ), $value->order_date ), | |
| 8739 | + 'order_date' => $value->order_date, | |
| 8740 | + 'order_delidue_date' => $value->order_delidue_date, | |
| 8741 | + 'order_delivery_method' => $value->order_delivery_method, | |
| 8742 | + 'order_delivery_method_name' => usces_delivery_method_name( $value->order_delivery_method, 'return' ), | |
| 8743 | + 'order_delivery_date' => $value->order_delivery_date, | |
| 8744 | + 'order_modified' => $value->order_modified, | |
| 8745 | + ); | |
| 8746 | + $res[] = apply_filters( 'usces_filter_member_history_data', $data, $mem_id, $value, $cart, $total_items_price ); | |
| 8747 | + } | |
| 8748 | + | |
| 8749 | + return $res; | |
| 8750 | + } | |
| 8751 | + | |
| 8752 | + public function get_post_term_ids( $post_id, $taxonomy ) { | |
| 8753 | + global $wpdb; | |
| 8754 | + $query = $wpdb->prepare( | |
| 8755 | + "SELECT tt.term_id FROM $wpdb->term_relationships AS `tr` | |
| 8756 | + INNER JOIN $wpdb->term_taxonomy AS `tt` ON tt.term_taxonomy_id = tr.term_taxonomy_id | |
| 8757 | + WHERE tt.taxonomy = %s AND tr.object_id = %d", | |
| 8758 | + $taxonomy, $post_id | |
| 8759 | + ); | |
| 8760 | + $ids = $wpdb->get_col( $query ); | |
| 8761 | + | |
| 8762 | + return $ids; | |
| 8763 | + } | |
| 8764 | + | |
| 8765 | + public function get_tag_names( $post_id ) { | |
| 8766 | + global $wpdb; | |
| 8767 | + $tag = 'post_tag'; | |
| 8768 | + $query = $wpdb->prepare( | |
| 8769 | + "SELECT t.name FROM $wpdb->term_relationships AS `tr` | |
| 8770 | + INNER JOIN $wpdb->term_taxonomy AS `tt` ON tt.term_taxonomy_id = tr.term_taxonomy_id | |
| 8771 | + INNER JOIN $wpdb->terms AS `t` ON t.term_id = tt.term_id | |
| 8772 | + WHERE tt.taxonomy = %s AND tr.object_id = %d", | |
| 8773 | + $tag, $post_id | |
| 8774 | + ); | |
| 8775 | + $names = $wpdb->get_col( $query ); | |
| 8776 | + | |
| 8777 | + return apply_filters( 'usces_filter_get_tag_names', $names, $post_id ); | |
| 8778 | + } | |
| 8779 | + | |
| 8780 | + public function get_ID_byItemName( $item_code, $status = 'publish' ) { | |
| 8781 | + global $wpdb; | |
| 8782 | + | |
| 8783 | + $table = usces_get_tablename( 'usces_item' ); | |
| 8784 | + $id = $wpdb->get_var( | |
| 8785 | + $wpdb->prepare( | |
| 8786 | + "SELECT p.ID FROM {$wpdb->posts} AS `p` | |
| 8787 | + INNER JOIN {$table} AS `item` ON p.ID = item.post_id | |
| 8788 | + WHERE p.post_status = %s AND item.itemCode = %s", | |
| 8789 | + $status, | |
| 8790 | + $item_code | |
| 8791 | + ) | |
| 8792 | + ); | |
| 8793 | + | |
| 8794 | + return $id; | |
| 8795 | + } | |
| 8796 | + | |
| 8797 | + /** | |
| 8798 | + * @deprecated A1/C (Layer 3 / uscesid removal). uscesid 難読化生成。本体は不使用。未移行の拡張・ | |
| 8799 | + * クライアント後方互換のためのみ残置。全消費側移行後に get_uscesid()/uscesdc() ともども削除する。 | |
| 8800 | + */ | |
| 8801 | + public function uscescv( $sessid, $flag ) { | |
| 8802 | + $chars = ''; | |
| 8803 | + $i = 0; | |
| 8804 | + $h = 0; | |
| 8805 | + $usces_cookie = $this->get_cookie(); | |
| 8806 | + if ( isset( $usces_cookie['id'] ) && ! empty( $usces_cookie['id'] ) ) { | |
| 8807 | + $cid = $usces_cookie['id']; | |
| 8808 | + } elseif ( isset( $_SESSION['usces_cookieid'] ) && ! empty( $_SESSION['usces_cookieid'] ) ) { | |
| 8809 | + $cid = $_SESSION['usces_cookieid']; | |
| 8810 | + } else { | |
| 8811 | + $cid = 0; | |
| 8812 | + } | |
| 8813 | + while ( $h < strlen( $sessid ) ) { | |
| 8814 | + if ( 0 == $i % 3 ) { | |
| 8815 | + $chars .= substr( $i, -1 ); | |
| 8816 | + } else { | |
| 8817 | + $chars .= substr( $sessid, $h, 1 ); | |
| 8818 | + $h++; | |
| 8819 | + } | |
| 8820 | + $i++; | |
| 8821 | + } | |
| 8822 | + if ( $flag ) { | |
| 8823 | + $postfix = ( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['REMOTE_ADDR'] ) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR'; | |
| 8824 | + $postfix = apply_filters( 'usces_sessid_force', $postfix ); | |
| 8825 | + $sessid = $chars . '_' . $postfix . '_' . $cid . '_A'; | |
| 8826 | + } else { | |
| 8827 | + $sessid = $chars . '_' . apply_filters( 'usces_sessid_flag', 'acting' ) . '_' . $cid . '_A'; | |
| 8828 | + } | |
| 8829 | + $sessid = urlencode( base64_encode( $sessid ) ); | |
| 8830 | + | |
| 8831 | + return $sessid; | |
| 8832 | + } | |
| 8833 | + | |
| 8834 | + /** | |
| 8835 | + * @deprecated A1/C (Layer 3 / uscesid removal). uscesid 復号。本体は不使用(A1 で唯一の呼び出しを撤去)。 | |
| 8836 | + * 未移行の拡張・クライアント(直接 uscesdc()→session_id() する nopriv AJAX)後方互換のためのみ残置。 | |
| 8837 | + * 全消費側移行後に get_uscesid()/uscescv() ともども削除する。 | |
| 8838 | + */ | |
| 8839 | + public function uscesdc( $sessid ) { | |
| 8840 | + $sessid = base64_decode( urldecode( $sessid ) ); | |
| 8841 | + list( $sess, $addr, $cookieid, $none ) = explode( '_', $sessid, 4 ); | |
| 8842 | + $postfix = ( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['REMOTE_ADDR'] ) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR'; | |
| 8843 | + $postfix = apply_filters( 'usces_sessid_force', $postfix ); | |
| 8844 | + if ( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) { | |
| 8845 | + $sessid = ''; | |
| 8846 | + return null; | |
| 8847 | + } | |
| 8848 | + $chars = ''; | |
| 8849 | + $h = 0; | |
| 8850 | + while ( $h < strlen( $sess ) ) { | |
| 8851 | + if ( 0 != $h % 3 ) { | |
| 8852 | + $chars .= substr( $sess, $h, 1 ); | |
| 8853 | + } | |
| 8854 | + $h++; | |
| 8855 | + } | |
| 8856 | + $sessid = $chars; | |
| 8857 | + | |
| 8858 | + return $sessid; | |
| 8859 | + } | |
| 8860 | + | |
| 8861 | + public function get_visiter( $period ) { | |
| 8862 | + global $wpdb; | |
| 8863 | + $datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 ); | |
| 8864 | + $yearstr = substr( $datestr, 0, 4 ); | |
| 8865 | + $monthstr = substr( $datestr, 5, 2 ); | |
| 8866 | + $daystr = substr( $datestr, 8, 2 ); | |
| 8867 | + if ( 'today' == $period ) { | |
| 8868 | + $date = $datestr; | |
| 8869 | + $today = $datestr; | |
| 8870 | + } elseif ( 'thismonth' == $period ) { | |
| 8871 | + $date = date( 'Y-m-01' ); | |
| 8872 | + $today = $datestr; | |
| 8873 | + } elseif ( 'lastyear' == $period ) { | |
| 8874 | + $date = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr-1 ) ); | |
| 8875 | + $today = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, (int) $daystr, (int) $yearstr-1 ) ); | |
| 8876 | + } | |
| 8877 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 8878 | + | |
| 8879 | + $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 ); | |
| 8880 | + $res = $wpdb->get_row( $query, ARRAY_A ); | |
| 8881 | + | |
| 8882 | + if ( null == $res ) { | |
| 8883 | + return 0; | |
| 8884 | + } else { | |
| 8885 | + return $res['ct1'] + $res['ct2']; | |
| 8886 | + } | |
| 8887 | + } | |
| 8888 | + | |
| 8889 | + public function get_fvisiter( $period ) { | |
| 8890 | + global $wpdb; | |
| 8891 | + $datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 ); | |
| 8892 | + $yearstr = substr( $datestr, 0, 4 ); | |
| 8893 | + $monthstr = substr( $datestr, 5, 2 ); | |
| 8894 | + $daystr = substr( $datestr, 8, 2 ); | |
| 8895 | + if ( 'today' == $period ) { | |
| 8896 | + $date = $datestr; | |
| 8897 | + $today = $datestr; | |
| 8898 | + } elseif ( 'thismonth' == $period ) { | |
| 8899 | + $date = date( 'Y-m-01' ); | |
| 8900 | + $today = $datestr; | |
| 8901 | + } elseif ( 'lastyear' == $period ) { | |
| 8902 | + $date = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) ); | |
| 8903 | + $today = date( 'Y-m-01', mktime( 0, 0, 0, (int) $monthstr, (int) $daystr, (int) $yearstr - 1 ) ); | |
| 8904 | + } | |
| 8905 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 8906 | + | |
| 8907 | + $query = $wpdb->prepare( "SELECT SUM(acc_num2) AS `ct` FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today ); | |
| 8908 | + $res = $wpdb->get_var( $query ); | |
| 8909 | + | |
| 8910 | + if ( null == $res ) { | |
| 8911 | + return 0; | |
| 8912 | + } else { | |
| 8913 | + return $res; | |
| 8914 | + } | |
| 8915 | + } | |
| 8916 | + | |
| 8917 | + public function get_order_num( $period ) { | |
| 8918 | + global $wpdb; | |
| 8919 | + $datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 ); | |
| 8920 | + $yearstr = substr( $datestr, 0, 4 ); | |
| 8921 | + $monthstr = substr( $datestr, 5, 2 ); | |
| 8922 | + $daystr = substr( $datestr, 8, 2 ); | |
| 8923 | + if ( 'today' == $period ) { | |
| 8924 | + $date = date( 'Y-m-d 00:00:00', current_time( 'timestamp' ) ); | |
| 8925 | + $today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) ); | |
| 8926 | + } elseif ( 'thismonth' == $period ) { | |
| 8927 | + $date = date( 'Y-m-01 00:00:00', current_time( 'timestamp' ) ); | |
| 8928 | + $today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) ); | |
| 8929 | + } elseif ( 'lastyear' == $period ) { | |
| 8930 | + $date = date( 'Y-m-01 00:00:00', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) ); | |
| 8931 | + $today = date( 'Y-m-d 23:59:59', mktime( 0, 0, 0, (int) $monthstr + 1, 0, (int) $yearstr - 1 ) ); | |
| 8932 | + } | |
| 8933 | + $table_name = $wpdb->prefix . 'usces_order'; | |
| 8934 | + | |
| 8935 | + $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' ); | |
| 8936 | + $res = $wpdb->get_var( $query ); | |
| 8937 | + | |
| 8938 | + if ( null == $res ) { | |
| 8939 | + return 0; | |
| 8940 | + } else { | |
| 8941 | + return $res; | |
| 8942 | + } | |
| 8943 | + } | |
| 8944 | + | |
| 8945 | + public function get_order_amount( $period ) { | |
| 8946 | + global $wpdb; | |
| 8947 | + | |
| 8948 | + $cache_key = 'wel_order_amount_period_' . $period; | |
| 8949 | + | |
| 8950 | + $res = wp_cache_get( $cache_key ); | |
| 8951 | + if ( false === $res ) { | |
| 8952 | + | |
| 8953 | + $datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 ); | |
| 8954 | + $yearstr = substr( $datestr, 0, 4 ); | |
| 8955 | + $monthstr = substr( $datestr, 5, 2 ); | |
| 8956 | + $daystr = substr( $datestr, 8, 2 ); | |
| 8957 | + if ( 'today' == $period ) { | |
| 8958 | + $date = date( 'Y-m-d 00:00:00', current_time( 'timestamp' ) ); | |
| 8959 | + $today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) ); | |
| 8960 | + } elseif ( 'thismonth' == $period ) { | |
| 8961 | + $date = date( 'Y-m-01 00:00:00', current_time( 'timestamp' ) ); | |
| 8962 | + $today = date( 'Y-m-d 23:59:59', current_time( 'timestamp' ) ); | |
| 8963 | + } elseif ( 'lastyear' == $period ) { | |
| 8964 | + $date = date( 'Y-m-01 00:00:00', mktime( 0, 0, 0, (int) $monthstr, 1, (int) $yearstr - 1 ) ); | |
| 8965 | + $today = date( 'Y-m-d 23:59:59', mktime( 0, 0, 0, (int) $monthstr + 1, 0, (int) $yearstr - 1 ) ); | |
| 8966 | + } | |
| 8967 | + $table_name = $wpdb->prefix . 'usces_order'; | |
| 8968 | + | |
| 8969 | + $query = $wpdb->prepare( | |
| 8970 | + "SELECT | |
| 8971 | + SUM(order_item_total_price) AS `price`, | |
| 8972 | + SUM(order_usedpoint) AS `point`, | |
| 8973 | + SUM(order_discount) AS `discount`, | |
| 8974 | + SUM(order_shipping_charge) AS `shipping`, | |
| 8975 | + SUM(order_cod_fee) AS `cod`, | |
| 8976 | + SUM(order_tax) AS `tax` | |
| 8977 | + FROM $table_name WHERE order_date >= %s AND order_date <= %s AND 0 = LOCATE(%s, order_status) AND 0 = LOCATE(%s, order_status)", | |
| 8978 | + $date, $today, 'cancel', 'estimate' | |
| 8979 | + ); | |
| 8980 | + $res = $wpdb->get_row( $query, ARRAY_A ); | |
| 8981 | + | |
| 8982 | + if ( null !== $res ) { | |
| 8983 | + wp_cache_set( $cache_key, $res ); | |
| 8984 | + } | |
| 8985 | + } | |
| 8986 | + | |
| 8987 | + if ( null == $res ) { | |
| 8988 | + return 0; | |
| 8989 | + } else { | |
| 8990 | + return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax']; | |
| 8991 | + } | |
| 8992 | + } | |
| 8993 | + | |
| 8994 | + public function is_status( $need, $str ) { | |
| 8995 | + if ( ! is_string( $str ) || empty( $str ) ) { | |
| 8996 | + $array = array(); | |
| 8997 | + } else { | |
| 8998 | + $array = explode( ',', $str ); | |
| 8999 | + } | |
| 9000 | + return in_array( $need, $array ); | |
| 9001 | + } | |
| 9002 | + | |
| 9003 | + public function make_status( $taio = '', $receipt = '', $admin = '' ) { | |
| 9004 | + $str = ''; | |
| 9005 | + if ( '' != $taio && '#none#' != $taio ) { | |
| 9006 | + $str .= $taio . ','; | |
| 9007 | + } | |
| 9008 | + if ( '' != $receipt && '#none#' != $receipt ) { | |
| 9009 | + $str .= $receipt . ','; | |
| 9010 | + } | |
| 9011 | + if ( '' != $admin && '#none#' != $admin ) { | |
| 9012 | + $str .= $admin . ','; | |
| 9013 | + } | |
| 9014 | + return $str; | |
| 9015 | + } | |
| 9016 | + | |
| 9017 | + public function get_memberid_by_email( $email ) { | |
| 9018 | + global $wpdb; | |
| 9019 | + $table_name = usces_get_tablename( 'usces_member' ); | |
| 9020 | + $query = $wpdb->prepare( "SELECT ID FROM $table_name WHERE mem_email = %s", $email ); | |
| 9021 | + $res = $wpdb->get_var( $query ); | |
| 9022 | + return $res; | |
| 9023 | + } | |
| 9024 | + | |
| 9025 | + public function get_condition() { | |
| 9026 | + $order_conditions = array( | |
| 9027 | + 'display_mode' => $this->options['display_mode'], | |
| 9028 | + 'campaign_privilege' => $this->options['campaign_privilege'], | |
| 9029 | + 'campaign_category' => $this->options['campaign_category'], | |
| 9030 | + 'privilege_point' => $this->options['privilege_point'], | |
| 9031 | + 'privilege_discount' => $this->options['privilege_discount'], | |
| 9032 | + 'tax_display' => ( isset( $this->options['tax_display'] ) ) ? $this->options['tax_display'] : 'activate', | |
| 9033 | + 'tax_mode' => $this->options['tax_mode'], | |
| 9034 | + 'tax_target' => $this->options['tax_target'], | |
| 9035 | + 'tax_rate' => $this->options['tax_rate'], | |
| 9036 | + 'tax_method' => $this->options['tax_method'], | |
| 9037 | + 'applicable_taxrate' => ( isset( $this->options['applicable_taxrate'] ) ) ? $this->options['applicable_taxrate'] : 'standard', | |
| 9038 | + 'tax_rate_reduced' => ( isset( $this->options['tax_rate_reduced'] ) ) ? $this->options['tax_rate_reduced'] : $this->options['tax_rate'], | |
| 9039 | + 'membersystem_state' => $this->options['membersystem_state'], | |
| 9040 | + 'membersystem_point' => $this->options['membersystem_point'], | |
| 9041 | + 'point_coverage' => $this->options['point_coverage'], | |
| 9042 | + ); | |
| 9043 | + return $order_conditions; | |
| 9044 | + } | |
| 9045 | + | |
| 9046 | + public function get_bestseller_ids( $days = '' ) { | |
| 9047 | + global $wpdb; | |
| 9048 | + | |
| 9049 | + $datestr = substr( get_date_from_gmt( gmdate( 'Y-m-d H:i:s', time() ) ), 0, 10 ); | |
| 9050 | + $yearstr = substr( $datestr, 0, 4 ); | |
| 9051 | + $monthstr = substr( $datestr, 5, 2 ); | |
| 9052 | + $daystr = substr( $datestr, 8, 2 ); | |
| 9053 | + | |
| 9054 | + $res = array(); | |
| 9055 | + $order_table_name = $wpdb->prefix . 'usces_order'; | |
| 9056 | + $where = ''; | |
| 9057 | + if ( empty( $days ) ) { | |
| 9058 | + $days = 30; | |
| 9059 | + } | |
| 9060 | + $order_date = date( 'Y-m-d H:i:s', mktime( 0, 0, 0, (int) $monthstr, ( (int) $daystr - $days), (int) $yearstr ) ); | |
| 9061 | + $where = " WHERE order_date >= '{$order_date}'"; | |
| 9062 | + $query = "SELECT order_cart FROM {$order_table_name}" . $where; | |
| 9063 | + $dbres = $wpdb->get_col( $query ); | |
| 9064 | + if ( ! $dbres ) { | |
| 9065 | + return false; | |
| 9066 | + } | |
| 9067 | + | |
| 9068 | + foreach ( (array) $dbres as $carts ) { | |
| 9069 | + $rows = wel_safe_unserialize( $carts ); | |
| 9070 | + foreach ( (array) $rows as $carts ) { | |
| 9071 | + if ( 'publish' != get_post_status( $carts['post_id'] ) ) { | |
| 9072 | + continue; | |
| 9073 | + } | |
| 9074 | + $id = $carts['post_id']; | |
| 9075 | + $qu = $carts['quantity']; | |
| 9076 | + if ( array_key_exists( $id, $res ) ) { | |
| 9077 | + $res[ $id ] = $res[ $id ] + $qu; | |
| 9078 | + } else { | |
| 9079 | + $res[ $id ] = $qu; | |
| 9080 | + } | |
| 9081 | + } | |
| 9082 | + } | |
| 9083 | + arsort( $res ); | |
| 9084 | + $results = array_keys( $res ); | |
| 9085 | + return $results; | |
| 9086 | + } | |
| 9087 | + | |
| 9088 | + public function get_items_num() { | |
| 9089 | + global $wpdb; | |
| 9090 | + $res = $wpdb->get_var( | |
| 9091 | + $wpdb->prepare( | |
| 9092 | + "SELECT COUNT(ID) AS `ct` FROM {$wpdb->posts} | |
| 9093 | + WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s", | |
| 9094 | + 'item', | |
| 9095 | + 'post', | |
| 9096 | + 'trash' | |
| 9097 | + ) | |
| 9098 | + ); | |
| 9099 | + | |
| 9100 | + return $res; | |
| 9101 | + } | |
| 9102 | + | |
| 9103 | + public function is_gptekiyo( $post_id, $sku, $quant ) { | |
| 9104 | + $skus = $this->get_skus( $post_id, 'code' ); | |
| 9105 | + if ( ! isset( $skus[ $sku ]['gp'] ) || ! $skus[ $sku ]['gp'] ) { | |
| 9106 | + return false; | |
| 9107 | + } | |
| 9108 | + | |
| 9109 | + $GpN1 = $this->getItemGpNum1( $post_id ); | |
| 9110 | + $GpN2 = $this->getItemGpNum2( $post_id ); | |
| 9111 | + $GpN3 = $this->getItemGpNum3( $post_id ); | |
| 9112 | + | |
| 9113 | + if ( empty( $GpN1 ) ) { | |
| 9114 | + | |
| 9115 | + return false; | |
| 9116 | + | |
| 9117 | + } elseif ( ! empty( $GpN1 ) && empty( $GpN2 ) ) { | |
| 9118 | + | |
| 9119 | + if ( $quant >= $GpN1 ) { | |
| 9120 | + return true; | |
| 9121 | + } else { | |
| 9122 | + return false; | |
| 9123 | + } | |
| 9124 | + | |
| 9125 | + } elseif ( ! empty( $GpN1 ) && ! empty( $GpN2 ) && empty( $GpN3 ) ) { | |
| 9126 | + | |
| 9127 | + if ( $quant >= $GpN2 ) { | |
| 9128 | + return true; | |
| 9129 | + } elseif ( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 9130 | + return true; | |
| 9131 | + } else { | |
| 9132 | + return false; | |
| 9133 | + } | |
| 9134 | + | |
| 9135 | + } elseif ( ! empty( $GpN1 ) && ! empty( $GpN2 ) && ! empty( $GpN3 ) ) { | |
| 9136 | + | |
| 9137 | + if ( $quant >= $GpN3 ) { | |
| 9138 | + return true; | |
| 9139 | + } elseif ( $quant >= $GpN2 && $quant < $GpN3 ) { | |
| 9140 | + return true; | |
| 9141 | + } elseif ( $quant >= $GpN1 && $quant < $GpN2 ) { | |
| 9142 | + return true; | |
| 9143 | + } else{ | |
| 9144 | + return false; | |
| 9145 | + } | |
| 9146 | + } | |
| 9147 | + } | |
| 9148 | + | |
| 9149 | + public function get_available_delivery_method() { | |
| 9150 | + if ( $this->cart->num_row() > 0 ) { | |
| 9151 | + $cart = $this->cart->get_cart(); | |
| 9152 | + $before_deli = array(); | |
| 9153 | + $intersect = array(); | |
| 9154 | + $integration = array(); | |
| 9155 | + $temp = array(); | |
| 9156 | + $in = 0; | |
| 9157 | + foreach ( $cart as $key => $row ) { | |
| 9158 | + $deli = $this->getItemDeliveryMethod( $row['post_id'] ); | |
| 9159 | + if ( empty( $deli ) ) { | |
| 9160 | + continue; | |
| 9161 | + } | |
| 9162 | + if ( 0 === $in ) { | |
| 9163 | + $intersect = $deli; | |
| 9164 | + } | |
| 9165 | + $intersect = array_intersect( $deli, $intersect ); | |
| 9166 | + $before_deli = $deli; | |
| 9167 | + foreach ( $deli as $value ) { | |
| 9168 | + $integration[] = $value; | |
| 9169 | + } | |
| 9170 | + $in++; | |
| 9171 | + } | |
| 9172 | + $integration = array_unique( $integration ); | |
| 9173 | + foreach ( $integration as $id ) { | |
| 9174 | + $index = $this->get_delivery_method_index( $id ); | |
| 9175 | + if ( 0 <= $index ) { | |
| 9176 | + $temp[ $index ] = $id; | |
| 9177 | + } | |
| 9178 | + } | |
| 9179 | + ksort( $temp ); | |
| 9180 | + $force = array( array_shift( $temp ) ); | |
| 9181 | + | |
| 9182 | + if ( empty( $intersect ) ) { | |
| 9183 | + return $force; | |
| 9184 | + } else { | |
| 9185 | + return $intersect; | |
| 9186 | + } | |
| 9187 | + } | |
| 9188 | + return array(); | |
| 9189 | + } | |
| 9190 | + | |
| 9191 | + public function get_delivery_method_index( $id ) { | |
| 9192 | + $index = false; | |
| 9193 | + $delivery_method_count = ( $this->options['delivery_method'] && is_array( $this->options['delivery_method'] ) ) ? count( $this->options['delivery_method'] ) : 0; | |
| 9194 | + for ( $i = 0; $i < $delivery_method_count; $i++ ) { | |
| 9195 | + if ( isset( $this->options['delivery_method'][ $i ]['id'] ) && $this->options['delivery_method'][ $i ]['id'] === (int) $id ) { | |
| 9196 | + $index = $i; | |
| 9197 | + } | |
| 9198 | + } | |
| 9199 | + if ( false === $index ) { | |
| 9200 | + return -1; | |
| 9201 | + } else { | |
| 9202 | + return $index; | |
| 9203 | + } | |
| 9204 | + } | |
| 9205 | + | |
| 9206 | + public function get_shipping_charge_index( $id ) { | |
| 9207 | + $index = false; | |
| 9208 | + $shipping_charge_count = ( $this->options['shipping_charge'] && is_array( $this->options['shipping_charge'] ) ) ? count( $this->options['shipping_charge'] ) : 0; | |
| 9209 | + for ( $i = 0; $i < $shipping_charge_count; $i++ ) { | |
| 9210 | + if ( isset( $this->options['shipping_charge'][ $i ] ) && (int) $this->options['shipping_charge'][ $i ]['id'] == (int) $id ) { | |
| 9211 | + $index = $i; | |
| 9212 | + } | |
| 9213 | + } | |
| 9214 | + if ( false === $index ) { | |
| 9215 | + return -1; | |
| 9216 | + } else { | |
| 9217 | + return $index; | |
| 9218 | + } | |
| 9219 | + } | |
| 9220 | + | |
| 9221 | + public function get_initial_data( $xml ) { | |
| 9222 | + $buf = file_get_contents( $xml ); | |
| 9223 | + 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 ); | |
| 9224 | + return $match; | |
| 9225 | + } | |
| 9226 | + | |
| 9227 | + public function getCurrencySymbol() { | |
| 9228 | + global $usces_settings; | |
| 9229 | + $cr = $this->options['system']['currency']; | |
| 9230 | + list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ]; | |
| 9231 | + return $symbol; | |
| 9232 | + } | |
| 9233 | + | |
| 9234 | + public function getCartItemName( $post_id, $sku ) { | |
| 9235 | + $name_arr = array(); | |
| 9236 | + $name_str = ''; | |
| 9237 | + | |
| 9238 | + foreach ( $this->options['indi_item_name'] as $key => $value ) { | |
| 9239 | + if ( $value ) { | |
| 9240 | + $pos = (int) $this->options['pos_item_name'][ $key ]; | |
| 9241 | + $ind = ( 0 === $pos ) ? 'A' : $pos; | |
| 9242 | + switch ( $key ) { | |
| 9243 | + case 'item_name': | |
| 9244 | + $name_arr[ $ind ][ $key ] = $this->getItemName( $post_id ); | |
| 9245 | + break; | |
| 9246 | + case 'item_code': | |
| 9247 | + $name_arr[ $ind ][ $key ] = $this->getItemCode( $post_id ); | |
| 9248 | + break; | |
| 9249 | + case 'sku_name': | |
| 9250 | + $name_arr[ $ind ][ $key ] = $this->getItemSkuDisp( $post_id, $sku ); | |
| 9251 | + break; | |
| 9252 | + case 'sku_code': | |
| 9253 | + $name_arr[ $ind ][ $key ] = $sku; | |
| 9254 | + break; | |
| 9255 | + } | |
| 9256 | + } | |
| 9257 | + } | |
| 9258 | + ksort( $name_arr ); | |
| 9259 | + foreach ( $name_arr as $vals ) { | |
| 9260 | + foreach ( $vals as $key => $value ) { | |
| 9261 | + $name_str .= $value . ' '; | |
| 9262 | + } | |
| 9263 | + } | |
| 9264 | + | |
| 9265 | + $name_str = apply_filters( 'usces_admin_order_item_name_filter', $name_str, $post_id, $sku ); | |
| 9266 | + | |
| 9267 | + return trim( $name_str ); | |
| 9268 | + } | |
| 9269 | + | |
| 9270 | + public function getCartItemName_byOrder( $cart_row ) { | |
| 9271 | + $name_arr = array(); | |
| 9272 | + $name_str = ''; | |
| 9273 | + | |
| 9274 | + foreach ( $this->options['indi_item_name'] as $key => $value ) { | |
| 9275 | + if ( $value ) { | |
| 9276 | + $pos = (int) $this->options['pos_item_name'][ $key ]; | |
| 9277 | + $ind = ( 0 === $pos ) ? 'A' : $pos; | |
| 9278 | + switch ( $key ) { | |
| 9279 | + case 'item_name': | |
| 9280 | + $name_arr[ $ind ][ $key ] = $cart_row['item_name']; | |
| 9281 | + break; | |
| 9282 | + case 'item_code': | |
| 9283 | + $name_arr[ $ind ][ $key ] = $cart_row['item_code']; | |
| 9284 | + break; | |
| 9285 | + case 'sku_name': | |
| 9286 | + $name_arr[ $ind ][ $key ] = $cart_row['sku_name']; | |
| 9287 | + break; | |
| 9288 | + case 'sku_code': | |
| 9289 | + $name_arr[ $ind ][ $key ] = $cart_row['sku_code']; | |
| 9290 | + break; | |
| 9291 | + } | |
| 9292 | + } | |
| 9293 | + } | |
| 9294 | + ksort( $name_arr ); | |
| 9295 | + foreach ( $name_arr as $vals ) { | |
| 9296 | + foreach ( $vals as $key => $value ) { | |
| 9297 | + $name_str .= $value . ' '; | |
| 9298 | + } | |
| 9299 | + } | |
| 9300 | + | |
| 9301 | + $name_str = apply_filters( 'usces_filter_item_mame_by_order', $name_str, $cart_row ); | |
| 9302 | + | |
| 9303 | + return trim( $name_str ); | |
| 9304 | + } | |
| 9305 | + | |
| 9306 | + public function set_reserve_pre_order_id() { | |
| 9307 | + $entry = $this->cart->get_entry(); | |
| 9308 | + $id = ( isset( $entry['reserve']['pre_order_id'] ) && ! empty( $entry['reserve']['pre_order_id'] ) ) ? $entry['reserve']['pre_order_id'] : uniqid( '' ); | |
| 9309 | + $this->cart->set_pre_order_id( $id ); | |
| 9310 | + } | |
| 9311 | + | |
| 9312 | + public function get_current_pre_order_id() { | |
| 9313 | + $entry = $this->cart->get_entry(); | |
| 9314 | + $id = ( isset( $entry['reserve']['pre_order_id'] ) && ! empty( $entry['reserve']['pre_order_id'] ) ) ? $entry['reserve']['pre_order_id'] : null; | |
| 9315 | + return $id; | |
| 9316 | + } | |
| 9317 | + | |
| 9318 | + public function get_order_id_by_pre_order_id( $pre_order_id ) { | |
| 9319 | + global $wpdb; | |
| 9320 | + $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 ); | |
| 9321 | + $order_id = $wpdb->get_var( $query ); | |
| 9322 | + return $order_id; | |
| 9323 | + } | |
| 9324 | + | |
| 9325 | + public function get_reserve( $order_id, $key ) { | |
| 9326 | + global $wpdb; | |
| 9327 | + $order_meta_table_name = $wpdb->prefix . 'usces_order_meta'; | |
| 9328 | + $query = $wpdb->prepare( "SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key ); | |
| 9329 | + $res = $wpdb->get_var( $query ); | |
| 9330 | + return $res; | |
| 9331 | + } | |
| 9332 | + | |
| 9333 | + public function get_order_meta_value( $key, $order_id ) { | |
| 9334 | + global $wpdb; | |
| 9335 | + $order_meta_table_name = $wpdb->prefix . 'usces_order_meta'; | |
| 9336 | + $query = $wpdb->prepare( "SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key ); | |
| 9337 | + $res = $wpdb->get_var( $query ); | |
| 9338 | + return $res; | |
| 9339 | + } | |
| 9340 | + | |
| 9341 | + public function set_order_meta_value( $key, $meta_value, $order_id, $check = 1 ) { | |
| 9342 | + global $wpdb; | |
| 9343 | + | |
| 9344 | + if ( empty( $order_id ) ) { | |
| 9345 | + return; | |
| 9346 | + } | |
| 9347 | + | |
| 9348 | + $order_id = (int) $order_id; | |
| 9349 | + if ( $check ) { | |
| 9350 | + $order = $this->get_order_data( $order_id, 'direct' ); | |
| 9351 | + if ( null === $order ) { | |
| 9352 | + return; | |
| 9353 | + } | |
| 9354 | + } | |
| 9355 | + | |
| 9356 | + $table_name = $wpdb->prefix . 'usces_order_meta'; | |
| 9357 | + $query = $wpdb->prepare( | |
| 9358 | + "SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s", | |
| 9359 | + $order_id, $key | |
| 9360 | + ); | |
| 9361 | + $res = $wpdb->get_var( $query ); | |
| 9362 | + if ( 0 < $res ) { | |
| 9363 | + $query = $wpdb->prepare( | |
| 9364 | + "UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", | |
| 9365 | + $meta_value, | |
| 9366 | + $order_id, | |
| 9367 | + $key | |
| 9368 | + ); | |
| 9369 | + $res2 = $wpdb->query( $query ); | |
| 9370 | + } else { | |
| 9371 | + $query = $wpdb->prepare( | |
| 9372 | + "INSERT INTO $table_name (order_id, meta_key, meta_value) | |
| 9373 | + VALUES(%d, %s, %s)", | |
| 9374 | + $order_id, | |
| 9375 | + $key, | |
| 9376 | + $meta_value | |
| 9377 | + ); | |
| 9378 | + $res2 = $wpdb->query( $query ); | |
| 9379 | + } | |
| 9380 | + return $res2; | |
| 9381 | + } | |
| 9382 | + | |
| 9383 | + public function del_order_meta( $key, $order_id ) { | |
| 9384 | + global $wpdb; | |
| 9385 | + $table_name = $wpdb->prefix . 'usces_order_meta'; | |
| 9386 | + $query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key ); | |
| 9387 | + $res = $wpdb->query( $query ); | |
| 9388 | + return $res; | |
| 9389 | + } | |
| 9390 | + | |
| 9391 | + public function set_session_custom_member( $member_id ) { | |
| 9392 | + unset( $_SESSION['usces_member']['custom_member'] ); | |
| 9393 | + $meta = usces_has_custom_field_meta( 'member' ); | |
| 9394 | + if ( is_array( $meta ) ) { | |
| 9395 | + $keys = array_keys( $meta ); | |
| 9396 | + foreach ( $keys as $key ) { | |
| 9397 | + $csmb_key = 'csmb_' . $key; | |
| 9398 | + $_SESSION['usces_member']['custom_member'][ $key ] = wel_safe_maybe_unserialize( $this->get_member_meta_value( $csmb_key, $member_id ) ); | |
| 9399 | + } | |
| 9400 | + } | |
| 9401 | + } | |
| 9402 | + | |
| 9403 | + public function reg_custom_member( $member_id ) { | |
| 9404 | + $csmb_meta = usces_has_custom_field_meta( 'member' ); | |
| 9405 | + if ( is_array( $csmb_meta ) ) { | |
| 9406 | + foreach ( $csmb_meta as $key => $entry ) { | |
| 9407 | + if ( '4' == $entry['means'] ) { | |
| 9408 | + $this->del_member_meta( 'csmb_' . $key, $member_id ); | |
| 9409 | + } | |
| 9410 | + } | |
| 9411 | + } | |
| 9412 | + if ( ! empty( $_POST['custom_member'] ) ) { | |
| 9413 | + foreach ( $_POST['custom_member'] as $key => $value ) { | |
| 9414 | + $csmb_key = 'csmb_' . $key; | |
| 9415 | + $value = wel_safe_text_serialize( $value ); | |
| 9416 | + if ( is_array( $value ) ) { | |
| 9417 | + $value = serialize( $value ); | |
| 9418 | + } | |
| 9419 | + $res = $this->set_member_meta_value( $csmb_key, $value, $member_id ); | |
| 9420 | + if ( false === $res ) { | |
| 9421 | + return false; | |
| 9422 | + } | |
| 9423 | + } | |
| 9424 | + } elseif ( isset( $_POST['custom_customer'] ) ) { | |
| 9425 | + foreach ( $_POST['custom_customer'] 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 | + } | |
| 9437 | + } | |
| 9438 | + | |
| 9439 | + public function save_order_acting_data( $rand ) { | |
| 9440 | + global $wpdb; | |
| 9441 | + $data = serialize( | |
| 9442 | + array( | |
| 9443 | + 'cart' => $this->cart->get_cart(), | |
| 9444 | + 'entry' => $this->cart->get_entry(), | |
| 9445 | + ) | |
| 9446 | + ); | |
| 9447 | + $table_name = $wpdb->prefix . 'usces_access'; | |
| 9448 | + $query = $wpdb->prepare( | |
| 9449 | + "INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value) | |
| 9450 | + VALUES(%s, %s, now(), %s, %s)", | |
| 9451 | + 'acting_data', | |
| 9452 | + $this->get_uscesid(false), | |
| 9453 | + $rand, | |
| 9454 | + $data | |
| 9455 | + ); | |
| 9456 | + $res = $wpdb->query( $query ); | |
| 9457 | + return $res; | |
| 9458 | + } | |
| 9459 | + | |
| 9460 | + public function set_member_meta_value( $key, $meta_value, $member_id = '' ) { | |
| 9461 | + global $wpdb; | |
| 9462 | + | |
| 9463 | + if ( WCUtils::is_blank( $member_id ) ) { | |
| 9464 | + if ( ! $this->is_member_logged_in() ) { | |
| 9465 | + return; | |
| 9466 | + } | |
| 9467 | + $member = $this->get_member(); | |
| 9468 | + $member_id = $member['ID']; | |
| 9469 | + } | |
| 9470 | + | |
| 9471 | + $table_name = usces_get_tablename( 'usces_member_meta' ); | |
| 9472 | + $query = $wpdb->prepare( "SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key ); | |
| 9473 | + $res = $wpdb->get_var( $query ); | |
| 9474 | + if ( 0 < $res ) { | |
| 9475 | + $query = $wpdb->prepare( | |
| 9476 | + "UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s", | |
| 9477 | + $meta_value, | |
| 9478 | + $member_id, | |
| 9479 | + $key | |
| 9480 | + ); | |
| 9481 | + $res2 = $wpdb->query( $query ); | |
| 9482 | + } else { | |
| 9483 | + $query = $wpdb->prepare( | |
| 9484 | + "INSERT INTO $table_name (member_id, meta_key, meta_value) | |
| 9485 | + VALUES(%d, %s, %s)", | |
| 9486 | + $member_id, | |
| 9487 | + $key, | |
| 9488 | + $meta_value | |
| 9489 | + ); | |
| 9490 | + $res2 = $wpdb->query( $query ); | |
| 9491 | + } | |
| 9492 | + return $res2; | |
| 9493 | + } | |
| 9494 | + | |
| 9495 | + public function get_member_meta_value( $key, $member_id ) { | |
| 9496 | + global $wpdb; | |
| 9497 | + $table_name = usces_get_tablename( 'usces_member_meta' ); | |
| 9498 | + $query = $wpdb->prepare( "SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key ); | |
| 9499 | + $res = $wpdb->get_var( $query ); | |
| 9500 | + return $res; | |
| 9501 | + } | |
| 9502 | + | |
| 9503 | + public function del_member_meta( $key, $member_id ) { | |
| 9504 | + global $wpdb; | |
| 9505 | + $table_name = usces_get_tablename( 'usces_member_meta' ); | |
| 9506 | + $query = $wpdb->prepare( "DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s", $member_id, $key ); | |
| 9507 | + $res = $wpdb->query( $query ); | |
| 9508 | + return $res; | |
| 9509 | + } | |
| 9510 | + | |
| 9511 | + public function get_member_meta( $member_id ) { | |
| 9512 | + global $wpdb; | |
| 9513 | + $table_name = usces_get_tablename( 'usces_member_meta' ); | |
| 9514 | + $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_%' ); | |
| 9515 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 9516 | + return $res; | |
| 9517 | + } | |
| 9518 | + | |
| 9519 | + public function get_settle_info_field( $order_id ) { | |
| 9520 | + global $wpdb; | |
| 9521 | + $fields = array(); | |
| 9522 | + $table_name = $wpdb->prefix . 'usces_order_meta'; | |
| 9523 | + $meta_keys = apply_filters( 'usces_filter_settle_info_field_meta_keys', array( 'settlement_id', 'order_number', 'res_tracking_id', 'SID', 'TransactionId' ) ); | |
| 9524 | + $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 ) ); | |
| 9525 | + $query = stripslashes( $query ); | |
| 9526 | + $res = $wpdb->get_results( $query, ARRAY_A ); | |
| 9527 | + if ( ! $res ) { | |
| 9528 | + return $fields; | |
| 9529 | + } | |
| 9530 | + foreach ( $res as $value ) { | |
| 9531 | + if ( in_array( $value['meta_key'], $meta_keys ) ) { | |
| 9532 | + $meta_key = $value['meta_key']; | |
| 9533 | + if ( 'settlement_id' == $meta_key ) { | |
| 9534 | + $meta_values = wel_safe_maybe_unserialize( $value['meta_value'] ); | |
| 9535 | + if ( is_array( $meta_values ) ) { | |
| 9536 | + foreach ( $meta_values as $key => $meta_value ) { | |
| 9537 | + $fields[ $key ] = $meta_value; | |
| 9538 | + } | |
| 9539 | + } else { | |
| 9540 | + $fields['settlement_id'] = $meta_values; | |
| 9541 | + } | |
| 9542 | + } else { | |
| 9543 | + $fields[ $meta_key ] = $value['meta_value']; | |
| 9544 | + } | |
| 9545 | + } elseif ( 'acting_' == substr( $value['meta_key'], 0, 7 ) ) { | |
| 9546 | + $meta_values = usces_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 | + $meta_values = wel_safe_maybe_unserialize( $value['meta_value'] ); | |
| 9553 | + if ( is_array( $meta_values ) ) { | |
| 9554 | + foreach ( $meta_values as $key => $meta_value ) { | |
| 9555 | + $fields[ $key ] = $meta_value; | |
| 9556 | + } | |
| 9557 | + } | |
| 9558 | + } | |
| 9559 | + } | |
| 9560 | + } | |
| 9561 | + return $fields; | |
| 9562 | + } | |
| 9563 | + | |
| 9564 | + public function get_post_custom( $post_id, $orderby = 'meta_id', $order = 'ASC' ) { | |
| 9565 | + global $wpdb; | |
| 9566 | + $table = $wpdb->prefix . 'postmeta'; | |
| 9567 | + $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 ); | |
| 9568 | + | |
| 9569 | + if ( ! empty( $meta_list ) ) { | |
| 9570 | + foreach ( $meta_list as $metarow ) { | |
| 9571 | + $mkey = $metarow['meta_key']; | |
| 9572 | + $mval = $metarow['meta_value']; | |
| 9573 | + $res[ $mkey ][] = $mval; | |
| 9574 | + } | |
| 9575 | + } | |
| 9576 | + return $res; | |
| 9577 | + } | |
| 9578 | + | |
| 9579 | + public function get_post_user_custom( $post_id, $orderby = 'meta_id', $order = 'ASC' ) { | |
| 9580 | + global $wpdb; | |
| 9581 | + $res = array(); | |
| 9582 | + $table = $wpdb->prefix . 'postmeta'; | |
| 9583 | + $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 ); | |
| 9584 | + | |
| 9585 | + if ( ! empty( $meta_list ) ) { | |
| 9586 | + foreach ( $meta_list as $metarow ) { | |
| 9587 | + if ( 0 === strpos( $metarow['meta_key'], '_' ) ) { | |
| 9588 | + continue; | |
| 9589 | + } | |
| 9590 | + $mkey = $metarow['meta_key']; | |
| 9591 | + $mval = $metarow['meta_value']; | |
| 9592 | + if ( array_key_exists( $mkey, $res ) ) { | |
| 9593 | + $cval = $res[ $mkey ]; | |
| 9594 | + $cval = (array) $cval; | |
| 9595 | + $cval[] = $mval; | |
| 9596 | + $res[ $mkey ] = $cval; | |
| 9597 | + } else { | |
| 9598 | + $res[ $mkey ] = $mval; | |
| 9599 | + } | |
| 9600 | + } | |
| 9601 | + } | |
| 9602 | + $res = apply_filters( 'usces_filter_get_post_user_custom', $res, $meta_list, $post_id, $orderby, $order ); | |
| 9603 | + return $res; | |
| 9604 | + } | |
| 9605 | + | |
| 9606 | + public function get_currency( $amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ) { | |
| 9607 | + global $usces_settings; | |
| 9608 | + $cr = $this->options['system']['currency']; | |
| 9609 | + list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ]; | |
| 9610 | + if ( ! $seperator_flag ) { | |
| 9611 | + $seperator = ''; | |
| 9612 | + } | |
| 9613 | + $price = number_format( (double) $amount, $decimal, $point, $seperator ); | |
| 9614 | + | |
| 9615 | + if ( $symbol_pre ) { | |
| 9616 | + $price = ( usces_is_entity( $symbol ) ? mb_convert_encoding( $symbol, 'UTF-8', 'HTML-ENTITIES' ) : $symbol ) . $price; | |
| 9617 | + } | |
| 9618 | + if ( $symbol_post ) { | |
| 9619 | + $price = $price . __( $code, 'usces' ); | |
| 9620 | + } | |
| 9621 | + $price = apply_filters( 'usces_filter_get_currency', $price, $amount, $symbol_pre, $symbol_post, $seperator_flag ); | |
| 9622 | + return $price; | |
| 9623 | + } | |
| 9624 | + | |
| 9625 | + public function get_currency_code() { | |
| 9626 | + global $usces_settings; | |
| 9627 | + $cr = $this->options['system']['currency']; | |
| 9628 | + list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ]; | |
| 9629 | + return $code; | |
| 9630 | + } | |
| 9631 | + | |
| 9632 | + public function get_currency_decimal() { | |
| 9633 | + global $usces_settings; | |
| 9634 | + $cr = $this->options['system']['currency']; | |
| 9635 | + list( $code, $decimal, $point, $seperator, $symbol ) = $usces_settings['currency'][ $cr ]; | |
| 9636 | + return $decimal; | |
| 9637 | + } | |
| 9638 | + | |
| 9639 | + public function get_next_page_uri( $type, $current ) { | |
| 9640 | + global $wpdb; | |
| 9641 | + | |
| 9642 | + $table = $wpdb->prefix . 'usces_' . $type; | |
| 9643 | + if ( ! isset( $_COOKIE[ $table ] ) ) { | |
| 9644 | + return false; | |
| 9645 | + } | |
| 9646 | + | |
| 9647 | + $cookie = ( isset( $_COOKIE[ $table ] ) ) ? json_decode( str_replace( "\'", "'", str_replace( '\"', '"', $_COOKIE[ $table ] ) ), true ) : array(); | |
| 9648 | + if ( ! isset( $cookie['currentPageIds'] ) ) { | |
| 9649 | + return false; | |
| 9650 | + } | |
| 9651 | + | |
| 9652 | + $ids = $cookie['currentPageIds']; | |
| 9653 | + foreach ( $ids as $key => $id ) { | |
| 9654 | + if ( $id == $current ) { | |
| 9655 | + $next = isset( $ids[ ( $key + 1 ) ] ) ? $ids[ ( $key + 1 ) ] : ''; | |
| 9656 | + break; | |
| 9657 | + } | |
| 9658 | + } | |
| 9659 | + | |
| 9660 | + if ( empty( $next ) ) { | |
| 9661 | + $uri = ''; | |
| 9662 | + } else { | |
| 9663 | + $uri = USCES_ADMIN_URL . "?page=usces_{$type}list&{$type}_action=edit&{$type}_id=" . $next; | |
| 9664 | + } | |
| 9665 | + | |
| 9666 | + return esc_url( $uri ); | |
| 9667 | + } | |
| 9668 | + | |
| 9669 | + public function get_prev_page_uri( $type, $current ) { | |
| 9670 | + global $wpdb; | |
| 9671 | + | |
| 9672 | + $table = $wpdb->prefix . 'usces_' . $type; | |
| 9673 | + if ( ! isset( $_COOKIE[ $table ] ) ) { | |
| 9674 | + return false; | |
| 9675 | + } | |
| 9676 | + | |
| 9677 | + $cookie = ( isset( $_COOKIE[ $table ] ) ) ? json_decode( str_replace( "\'", "'", str_replace( '\"', '"', $_COOKIE[ $table ] ) ), true ) : array(); | |
| 9678 | + if ( ! isset( $cookie['currentPageIds'] ) ) { | |
| 9679 | + return false; | |
| 9680 | + } | |
| 9681 | + | |
| 9682 | + $ids = $cookie['currentPageIds']; | |
| 9683 | + foreach ( $ids as $key => $id ) { | |
| 9684 | + if ( $id == $current ) { | |
| 9685 | + $prev = isset( $ids[ ( $key - 1 ) ] ) ? $ids[ ( $key - 1 ) ] : ''; | |
| 9686 | + break; | |
| 9687 | + } | |
| 9688 | + } | |
| 9689 | + | |
| 9690 | + if ( empty( $prev ) ) { | |
| 9691 | + $uri = ''; | |
| 9692 | + } else { | |
| 9693 | + $uri = USCES_ADMIN_URL . "?page=usces_{$type}list&{$type}_action=edit&{$type}_id=" . $prev; | |
| 9694 | + } | |
| 9695 | + | |
| 9696 | + return esc_url( $uri ); | |
| 9697 | + } | |
| 9698 | + | |
| 9699 | + public function is_reduced_taxrate() { | |
| 9700 | + | |
| 9701 | + $reduced = ( isset( $this->options['applicable_taxrate'] ) && 'reduced' == $this->options['applicable_taxrate'] ) ? true : false; | |
| 9702 | + return $reduced; | |
| 9703 | + } | |
| 9704 | + | |
| 9705 | + public function sc_company_name() { | |
| 9706 | + return htmlspecialchars( $this->options['company_name'], ENT_COMPAT ); | |
| 9707 | + } | |
| 9708 | + | |
| 9709 | + public function sc_zip_code() { | |
| 9710 | + return htmlspecialchars( $this->options['zip_code'], ENT_COMPAT ); | |
| 9711 | + } | |
| 9712 | + | |
| 9713 | + public function sc_address1() { | |
| 9714 | + return htmlspecialchars( $this->options['address1'], ENT_COMPAT ); | |
| 9715 | + } | |
| 9716 | + | |
| 9717 | + public function sc_address2() { | |
| 9718 | + return htmlspecialchars( $this->options['address2'], ENT_COMPAT ); | |
| 9719 | + } | |
| 9720 | + | |
| 9721 | + public function sc_tel_number() { | |
| 9722 | + return htmlspecialchars( $this->options['tel_number'], ENT_COMPAT ); | |
| 9723 | + } | |
| 9724 | + | |
| 9725 | + public function sc_fax_number() { | |
| 9726 | + return htmlspecialchars( $this->options['fax_number'], ENT_COMPAT ); | |
| 9727 | + } | |
| 9728 | + | |
| 9729 | + public function sc_inquiry_mail() { | |
| 9730 | + return htmlspecialchars( $this->options['inquiry_mail'], ENT_COMPAT ); | |
| 9731 | + } | |
| 9732 | + | |
| 9733 | + public function sc_payment() { | |
| 9734 | + $payments = usces_get_system_option( 'usces_payment_method', 'sort' ); | |
| 9735 | + $htm = "<ul>\n"; | |
| 9736 | + foreach ( (array) $payments as $payment ) { | |
| 9737 | + $htm .= '<li>' . htmlspecialchars( $payment['name'], ENT_COMPAT ) . "<br />\n"; | |
| 9738 | + $htm .= nl2br( htmlspecialchars( $payment['explanation'], ENT_COMPAT ) ) . "</li>\n"; | |
| 9739 | + } | |
| 9740 | + $htm .= "</ul>\n"; | |
| 9741 | + return $htm; | |
| 9742 | + } | |
| 9743 | + | |
| 9744 | + public function sc_payment_title() { | |
| 9745 | + $payments = $this->options['payment_method']; | |
| 9746 | + $htm = "<ul>\n"; | |
| 9747 | + foreach ( (array) $payments as $payment ) { | |
| 9748 | + $htm .= '<li>' . esc_html( $payment['name'] ) . "</li>\n"; | |
| 9749 | + } | |
| 9750 | + $htm .= "</ul>\n"; | |
| 9751 | + return $htm; | |
| 9752 | + } | |
| 9753 | + | |
| 9754 | + public function sc_cod_fee() { | |
| 9755 | + return number_format( $this->options['cod_fee'] ); | |
| 9756 | + } | |
| 9757 | + | |
| 9758 | + public function sc_start_point() { | |
| 9759 | + return number_format( $this->options['start_point'] ); | |
| 9760 | + } | |
| 9761 | + | |
| 9762 | + public function sc_postage_privilege() { | |
| 9763 | + if ( empty( $this->options['postage_privilege'] ) ) { | |
| 9764 | + return; | |
| 9765 | + } | |
| 9766 | + return number_format( $this->options['postage_privilege'] ); | |
| 9767 | + } | |
| 9768 | + | |
| 9769 | + public function sc_shipping_charge() { | |
| 9770 | + $entry = $this->cart->get_entry(); | |
| 9771 | + $country = ( isset( $entry['delivery']['country'] ) && ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : $entry['customer']['country']; | |
| 9772 | + $arr = array(); | |
| 9773 | + foreach ( (array) $this->options['shipping_charge'] as $charges ) { | |
| 9774 | + foreach ( (array) $charges[ $country ] as $value ) { | |
| 9775 | + $arr[] = $value; | |
| 9776 | + } | |
| 9777 | + } | |
| 9778 | + sort( $arr ); | |
| 9779 | + $min = $arr[0]; | |
| 9780 | + rsort( $arr ); | |
| 9781 | + $max = $arr[0]; | |
| 9782 | + if ( $min == $max ) { | |
| 9783 | + $res = number_format( $min ); | |
| 9784 | + } else { | |
| 9785 | + $res = number_format( $min ) . __( ' - ', 'usces' ) . number_format( $max ); | |
| 9786 | + } | |
| 9787 | + return $res; | |
| 9788 | + } | |
| 9789 | + | |
| 9790 | + public function sc_site_url() { | |
| 9791 | + return get_option( 'home' ); | |
| 9792 | + } | |
| 9793 | + | |
| 9794 | + public function sc_button_to_cart( $atts ) { | |
| 9795 | + extract( | |
| 9796 | + shortcode_atts( | |
| 9797 | + array( | |
| 9798 | + 'item' => '', | |
| 9799 | + 'sku' => '', | |
| 9800 | + 'value' => __( 'to the cart', 'usces' ), | |
| 9801 | + 'force' => 0, | |
| 9802 | + 'quant' => 0, | |
| 9803 | + 'opt' => 1, | |
| 9804 | + ), | |
| 9805 | + $atts | |
| 9806 | + ) | |
| 9807 | + ); | |
| 9808 | + | |
| 9809 | + $post_id = $this->get_ID_byItemName( $item ); | |
| 9810 | + $datas = $this->get_skus( $post_id, 'code' ); | |
| 9811 | + $zaikonum = ( isset( $datas[ $sku ]['stocknum'] ) ) ? $datas[ $sku ]['stocknum'] : null; | |
| 9812 | + $zaiko = ( isset( $datas[ $sku ]['stock'] ) ) ? $datas[ $sku ]['stock'] : 2; | |
| 9813 | + $gptekiyo = ( isset( $datas[ $sku ]['gp'] ) ) ? $datas[ $sku ]['gp'] : null; | |
| 9814 | + $skuPrice = ( isset( $datas[ $sku ]['price'] ) ) ? $datas[ $sku ]['price'] : 0; | |
| 9815 | + $sku_enc = urlencode( $sku ); | |
| 9816 | + $options = usces_get_opts( $post_id, 'sort' ); | |
| 9817 | + $mats = compact( 'item', 'sku', 'value', 'force', 'quant', 'post_id', 'datas', 'zaikonum', 'zaiko', 'gptekiyo', 'skuPrice', 'sku_enc' ); | |
| 9818 | + if ( ! $this->is_item_zaiko( $post_id, $sku ) ) { | |
| 9819 | + return '<div class="button_status">' . esc_html( $this->zaiko_status[ $zaiko ] ) . '</div>'; | |
| 9820 | + } | |
| 9821 | + | |
| 9822 | + $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n"; | |
| 9823 | + $html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaikonum ) . "\" />\n"; | |
| 9824 | + $html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaiko ) . "\" />\n"; | |
| 9825 | + $html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $gptekiyo ) . "\" />\n"; | |
| 9826 | + $html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $skuPrice ) . "\" />\n"; | |
| 9827 | + if ( 1 == $opt ) { | |
| 9828 | + $html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' ); | |
| 9829 | + } elseif ( 2 == $opt ) { | |
| 9830 | + $html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' ); | |
| 9831 | + } | |
| 9832 | + if ( $quant ) { | |
| 9833 | + $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;}\" />"; | |
| 9834 | + $html .= apply_filters( 'usces_filter_sc_itemQuant', $quant_field, $mats ); | |
| 9835 | + } | |
| 9836 | + $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 ) . ' />'; | |
| 9837 | + $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . esc_url( $_SERVER['REQUEST_URI'] ) . "\" />\n"; | |
| 9838 | + if ( $force ) { | |
| 9839 | + $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n"; | |
| 9840 | + } | |
| 9841 | + $html = apply_filters( 'usces_filter_single_item_inform', $html ); | |
| 9842 | + $html .= '</form>'; | |
| 9843 | + $html .= '<div class="error_message">' . usces_singleitem_error_message( $post_id, $sku, 'return' ) . '</div>' . "\n"; | |
| 9844 | + | |
| 9845 | + return $html; | |
| 9846 | + } | |
| 9847 | + | |
| 9848 | + public function filter_itemPage( $content ) { | |
| 9849 | + global $post; | |
| 9850 | + $html = ''; | |
| 9851 | + | |
| 9852 | + if ( ( 'item' != $post->post_mime_type || ! is_single() ) ) { | |
| 9853 | + return $content; | |
| 9854 | + } | |
| 9855 | + if ( post_password_required( $post ) ) { | |
| 9856 | + return $content; | |
| 9857 | + } | |
| 9858 | + | |
| 9859 | + $temp_path = apply_filters( 'usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php' ); | |
| 9860 | + include $temp_path; | |
| 9861 | + | |
| 9862 | + $content = apply_filters( 'usces_filter_itemPage', $html, $post->ID ); | |
| 9863 | + | |
| 9864 | + return $content; | |
| 9865 | + } | |
| 9866 | + | |
| 9867 | + public function filter_cartContent( $content ) { | |
| 9868 | + global $post; | |
| 9869 | + $html = ''; | |
| 9870 | + switch ( $this->page ) { | |
| 9871 | + case 'cart': | |
| 9872 | + $temp_path = apply_filters( 'usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php' ); | |
| 9873 | + include $temp_path; | |
| 9874 | + break; | |
| 9875 | + case 'customer': | |
| 9876 | + $temp_path = apply_filters( 'usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php' ); | |
| 9877 | + include $temp_path; | |
| 9878 | + break; | |
| 9879 | + case 'delivery': | |
| 9880 | + $temp_path = apply_filters( 'usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php' ); | |
| 9881 | + include $temp_path; | |
| 9882 | + break; | |
| 9883 | + case 'confirm': | |
| 9884 | + $temp_path = apply_filters( 'usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php' ); | |
| 9885 | + include $temp_path; | |
| 9886 | + break; | |
| 9887 | + case 'ordercompletion': | |
| 9888 | + $temp_path = apply_filters( 'usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php' ); | |
| 9889 | + include $temp_path; | |
| 9890 | + break; | |
| 9891 | + case 'cartverifying': | |
| 9892 | + $temp_path = apply_filters( 'usces_template_path_cartverifying', USCES_PLUGIN_DIR . '/templates/cart/verifying.php' ); | |
| 9893 | + include $temp_path; | |
| 9894 | + break; | |
| 9895 | + case 'cartverified': | |
| 9896 | + $temp_path = apply_filters( 'usces_template_path_cartverified', USCES_PLUGIN_DIR . '/templates/cart/verified.php' ); | |
| 9897 | + include $temp_path; | |
| 9898 | + break; | |
| 9899 | + case 'error': | |
| 9900 | + $temp_path = apply_filters( 'usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php' ); | |
| 9901 | + include $temp_path; | |
| 9902 | + break; | |
| 9903 | + case 'maintenance': | |
| 9904 | + $temp_path = apply_filters( 'usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php' ); | |
| 9905 | + include $temp_path; | |
| 9906 | + break; | |
| 9907 | + case 'search_item': | |
| 9908 | + $temp_path = apply_filters( 'usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php' ); | |
| 9909 | + include $temp_path; | |
| 9910 | + break; | |
| 9911 | + case 'wp_search': | |
| 9912 | + if ( 'item' == $post->post_mime_type ) { | |
| 9913 | + $temp_path = apply_filters( 'usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php' ); | |
| 9914 | + include $temp_path; | |
| 9915 | + } else { | |
| 9916 | + $html = $content; | |
| 9917 | + } | |
| 9918 | + break; | |
| 9919 | + default: | |
| 9920 | + $html = $content; | |
| 9921 | + } | |
| 9922 | + | |
| 9923 | + if ( $this->use_ssl && ( $this->is_cart_or_member_page( $_SERVER['REQUEST_URI'] ) || $this->is_inquiry_page( $_SERVER['REQUEST_URI'] ) ) ) { | |
| 9924 | + $html = str_replace( 'src="' . site_url(), 'src="' . USCES_SSL_URL_ADMIN, $html ); | |
| 9925 | + } | |
| 9926 | + | |
| 9927 | + $html = apply_filters( 'usces_filter_cartContent', $html ); | |
| 9928 | + | |
| 9929 | + $content = $html; | |
| 9930 | + | |
| 9931 | + remove_filter( 'the_title', array( $this, 'filter_cartTitle' ) ); | |
| 9932 | + | |
| 9933 | + return $content; | |
| 9934 | + } | |
| 9935 | + | |
| 9936 | + public function filter_cartTitle( $title ) { | |
| 9937 | + if ( is_admin() ) { | |
| 9938 | + return $title; | |
| 9939 | + } | |
| 9940 | + | |
| 9941 | + if ( 'Cart' == $title || __( 'Cart', 'usces' ) == $title ) { | |
| 9942 | + switch ( $this->page ) { | |
| 9943 | + case 'cart': | |
| 9944 | + $newtitle = apply_filters( 'usces_filter_title_cart', __( 'In the cart', 'usces' ) ); | |
| 9945 | + break; | |
| 9946 | + case 'customer': | |
| 9947 | + $newtitle = apply_filters( 'usces_filter_title_customer', __( 'Customer Information', 'usces' ) ); | |
| 9948 | + break; | |
| 9949 | + case 'delivery': | |
| 9950 | + $newtitle = apply_filters( 'usces_filter_title_delivery', __( 'Shipping / Payment options', 'usces' ) ); | |
| 9951 | + break; | |
| 9952 | + case 'confirm': | |
| 9953 | + $newtitle = apply_filters( 'usces_filter_title_confirm', __( 'Confirmation', 'usces' ) ); | |
| 9954 | + break; | |
| 9955 | + case 'ordercompletion': | |
| 9956 | + $newtitle = apply_filters( 'usces_filter_title_ordercompletion', __( 'Completion', 'usces' ) ); | |
| 9957 | + break; | |
| 9958 | + case 'error': | |
| 9959 | + $newtitle = apply_filters( 'usces_filter_title_carterror', __( 'Error', 'usces' ) ); | |
| 9960 | + break; | |
| 9961 | + case 'cartverified': | |
| 9962 | + $newtitle = apply_filters( 'usces_filter_title_cartverified', __( 'Member registration complete', 'usces' ) ); | |
| 9963 | + break; | |
| 9964 | + case 'search_item': | |
| 9965 | + $newtitle = apply_filters( 'usces_filter_title_search_item', __( "'AND' search by categories", 'usces' ) ); | |
| 9966 | + break; | |
| 9967 | + case 'maintenance': | |
| 9968 | + $newtitle = apply_filters( 'usces_filter_title_maintenance', __( 'Under Maintenance', 'usces' ) ); | |
| 9969 | + break; | |
| 9970 | + case 'login': | |
| 9971 | + $newtitle = apply_filters( 'usces_filter_title_login', __( 'Log-in for members', 'usces' ) ); | |
| 9972 | + break; | |
| 9973 | + default: | |
| 9974 | + $newtitle = apply_filters( 'usces_filter_title_cart_default', $title ); | |
| 9975 | + } | |
| 9976 | + } else { | |
| 9977 | + $newtitle = $title; | |
| 9978 | + } | |
| 9979 | + | |
| 9980 | + $newtitle = apply_filters( 'usces_filter_cartTitle', $newtitle ); | |
| 9981 | + return $newtitle; | |
| 9982 | + } | |
| 9983 | + | |
| 9984 | + public function action_cartFilter() { | |
| 9985 | + add_filter( 'the_title', array( $this, 'filter_cartTitle' ), 20 ); | |
| 9986 | + add_filter( 'the_content', array( $this, 'filter_cartContent' ), 20 ); | |
| 9987 | + } | |
| 9988 | + | |
| 9989 | + public function action_search_item() { | |
| 9990 | + include get_template_directory() . '/page.php'; | |
| 9991 | + exit; | |
| 9992 | + } | |
| 9993 | + | |
| 9994 | + public function filter_memberContent( $content ) { | |
| 9995 | + global $post; | |
| 9996 | + $html = ''; | |
| 9997 | + | |
| 9998 | + if ( 'activate' == $this->options['membersystem_state'] ) { | |
| 9999 | + | |
| 10000 | + if ( $this->is_member_logged_in() ) { | |
| 10001 | + | |
| 10002 | + $member_regmode = 'editmemberform'; | |
| 10003 | + $temp_path = apply_filters( 'usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php' ); | |
| 10004 | + include $temp_path; | |
| 10005 | + | |
| 10006 | + } else { | |
| 10007 | + | |
| 10008 | + switch ( $this->page ) { | |
| 10009 | + case 'login': | |
| 10010 | + $temp_path = apply_filters( 'usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php' ); | |
| 10011 | + include $temp_path; | |
| 10012 | + break; | |
| 10013 | + case 'lostmemberpassword': | |
| 10014 | + $temp_path = apply_filters( 'usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php' ); | |
| 10015 | + include $temp_path; | |
| 10016 | + break; | |
| 10017 | + case 'changepassword': | |
| 10018 | + $temp_path = apply_filters( 'usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php' ); | |
| 10019 | + include $temp_path; | |
| 10020 | + break; | |
| 10021 | + case 'newcompletion': | |
| 10022 | + case 'editcompletion': | |
| 10023 | + case 'lostcompletion': | |
| 10024 | + case 'changepasscompletion': | |
| 10025 | + $temp_path = apply_filters( 'usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php' ); | |
| 10026 | + include $temp_path; | |
| 10027 | + break; | |
| 10028 | + case 'memberverifying': | |
| 10029 | + $temp_path = apply_filters( 'usces_template_path_memberverifying', USCES_PLUGIN_DIR . '/templates/member/verifying.php' ); | |
| 10030 | + include $temp_path; | |
| 10031 | + break; | |
| 10032 | + // case 'memberverified': | |
| 10033 | + // $temp_path = apply_filters('usces_template_path_memberverified', USCES_PLUGIN_DIR . '/templates/member/member_verified.php'); | |
| 10034 | + // include $temp_path; | |
| 10035 | + // break; | |
| 10036 | + case 'newmemberform': | |
| 10037 | + $member_form_title = apply_filters( 'usces_filter_title_newmemberform', __( 'New enrollment form', 'usces' ) ); | |
| 10038 | + $member_regmode = 'newmemberform'; | |
| 10039 | + $temp_path = apply_filters( 'usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php' ); | |
| 10040 | + include $temp_path; | |
| 10041 | + break; | |
| 10042 | + default: | |
| 10043 | + $temp_path = apply_filters( 'usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php' ); | |
| 10044 | + include $temp_path; | |
| 10045 | + } | |
| 10046 | + } | |
| 10047 | + } else { | |
| 10048 | + $html .= '<p>' . __( 'Member Services is not running currently.', 'usces' ) . '</p>'; | |
| 10049 | + } | |
| 10050 | + | |
| 10051 | + $content = $html; | |
| 10052 | + | |
| 10053 | + remove_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 ); | |
| 10054 | + | |
| 10055 | + return $content; | |
| 10056 | + } | |
| 10057 | + | |
| 10058 | + public function filter_memberTitle( $title ) { | |
| 10059 | + if ( is_admin() ) { | |
| 10060 | + return $title; | |
| 10061 | + } | |
| 10062 | + | |
| 10063 | + if ( 'activate' == $this->options['membersystem_state'] && $this->is_member_page( $_SERVER['REQUEST_URI'] ) ) { | |
| 10064 | + switch ( $this->page ) { | |
| 10065 | + case 'login': | |
| 10066 | + $newtitle = apply_filters( 'usces_filter_title_login', __( 'Log-in for members', 'usces' ) ); | |
| 10067 | + break; | |
| 10068 | + case 'newmemberform': | |
| 10069 | + $newtitle = apply_filters( 'usces_filter_title_newmemberform', __( 'New enrollment form', 'usces' ) ); | |
| 10070 | + break; | |
| 10071 | + case 'lostmemberpassword': | |
| 10072 | + $newtitle = apply_filters( 'usces_filter_title_lostmemberpassword', __( 'The new password acquisition', 'usces' ) ); | |
| 10073 | + break; | |
| 10074 | + case 'changepassword': | |
| 10075 | + $newtitle = apply_filters( 'usces_filter_title_changepassword', __( 'Change password', 'usces' ) ); | |
| 10076 | + break; | |
| 10077 | + case 'newcompletion': | |
| 10078 | + case 'editcompletion': | |
| 10079 | + case 'lostcompletion': | |
| 10080 | + case 'changepasscompletion': | |
| 10081 | + $newtitle = apply_filters( 'usces_filter_title_changepasscompletion', __( 'Completion', 'usces' ) ); | |
| 10082 | + break; | |
| 10083 | + case 'memberverifying': | |
| 10084 | + $newtitle = apply_filters( 'usces_filter_title_memberverifying', __( 'Verifying', 'usces' ) ); | |
| 10085 | + break; | |
| 10086 | + case 'error': | |
| 10087 | + $newtitle = apply_filters( 'usces_filter_title_membererror', __( 'Error', 'usces' ) ); | |
| 10088 | + break; | |
| 10089 | + default: | |
| 10090 | + $newtitle = apply_filters( 'usces_filter_title_member_default', $title ); | |
| 10091 | + } | |
| 10092 | + } else { | |
| 10093 | + $newtitle = $title; | |
| 10094 | + } | |
| 10095 | + | |
| 10096 | + $newtitle = apply_filters( 'usces_filter_memberTitle', $newtitle ); | |
| 10097 | + return $newtitle; | |
| 10098 | + } | |
| 10099 | + | |
| 10100 | + public function action_memberFilter() { | |
| 10101 | + add_filter( 'the_title', array( $this, 'filter_memberTitle' ), 20 ); | |
| 10102 | + add_filter( 'the_content', array( $this, 'filter_memberContent' ), 20 ); | |
| 10103 | + } | |
| 10104 | + | |
| 10105 | + public function filter_usces_cart_css() { | |
| 10106 | + $path = get_stylesheet_directory_uri() . '/usces_cart.css'; | |
| 10107 | + return $path; | |
| 10108 | + } | |
| 10109 | + | |
| 10110 | + public function filter_divide_item() { | |
| 10111 | + global $wp_query; | |
| 10112 | + | |
| 10113 | + if ( ( $this->options['divide_item'] && ! is_category() && ! is_search() && ! is_singular() && ! is_admin() ) ) { | |
| 10114 | + $ids = $this->getItemIds( 'front' ); | |
| 10115 | + if ( isset( $wp_query->query_vars['post__not_in'] ) ) { | |
| 10116 | + $wp_query->query_vars['post__not_in'] = $ids; | |
| 10117 | + } | |
| 10118 | + } | |
| 10119 | + if ( is_admin() ) { | |
| 10120 | + $ids = $this->getItemIds( 'back' ); | |
| 10121 | + if ( isset( $wp_query->query_vars['post__not_in'] ) ) { | |
| 10122 | + $wp_query->query_vars['post__not_in'] = $ids; | |
| 10123 | + } | |
| 10124 | + } | |
| 10125 | + do_action( 'usces_action_divide_item' ); | |
| 10126 | + } | |
| 10127 | + | |
| 10128 | + public function load_upload_template() { | |
| 10129 | + $post_id = $_POST['post_id']; | |
| 10130 | + $file = 'upload_template01.php'; | |
| 10131 | + include get_template_directory() . '/' . $file; | |
| 10132 | + exit; | |
| 10133 | + } | |
| 10134 | + | |
| 10135 | + public function filter_itemimg_anchor_rel( $html ) { | |
| 10136 | + if ( is_single() ) { | |
| 10137 | + $str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"'; | |
| 10138 | + } else { | |
| 10139 | + $str = ''; | |
| 10140 | + } | |
| 10141 | + return $html . $str; | |
| 10142 | + } | |
| 10143 | + | |
| 10144 | + public function filter_permalink( $link ) { | |
| 10145 | + if ( false !== strpos( '?page_id=4', $link ) || false !== strpos( '?page_id=3', $link ) || false !== strpos( 'usces-cart', $link ) || false !== strpos( 'usces-member', $link ) ) { | |
| 10146 | + $link = str_replace( 'http://', 'https://', $link ); | |
| 10147 | + } | |
| 10148 | + return $link; | |
| 10149 | + } | |
| 10150 | + | |
| 10151 | + public function filter_cart_page_header( $html ) { | |
| 10152 | + if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) { | |
| 10153 | + $html = $this->options['cart_page_data']['header']['cart']; | |
| 10154 | + } | |
| 10155 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10156 | + } | |
| 10157 | + | |
| 10158 | + public function filter_cart_page_footer( $html ) { | |
| 10159 | + if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) { | |
| 10160 | + $html = $this->options['cart_page_data']['footer']['cart']; | |
| 10161 | + } | |
| 10162 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10163 | + } | |
| 10164 | + | |
| 10165 | + public function filter_customer_page_header( $html ) { | |
| 10166 | + if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) { | |
| 10167 | + $html = $this->options['cart_page_data']['header']['customer']; | |
| 10168 | + } | |
| 10169 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10170 | + } | |
| 10171 | + | |
| 10172 | + public function filter_customer_page_footer( $html ) { | |
| 10173 | + if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) { | |
| 10174 | + $html = $this->options['cart_page_data']['footer']['customer']; | |
| 10175 | + } | |
| 10176 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10177 | + } | |
| 10178 | + | |
| 10179 | + public function filter_delivery_page_header( $html ) { | |
| 10180 | + if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) { | |
| 10181 | + $html = $this->options['cart_page_data']['header']['delivery']; | |
| 10182 | + } | |
| 10183 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10184 | + } | |
| 10185 | + | |
| 10186 | + public function filter_delivery_page_footer( $html ) { | |
| 10187 | + if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) { | |
| 10188 | + $html = $this->options['cart_page_data']['footer']['delivery']; | |
| 10189 | + } | |
| 10190 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10191 | + } | |
| 10192 | + | |
| 10193 | + public function filter_confirm_page_header( $html ) { | |
| 10194 | + if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) { | |
| 10195 | + $html = $this->options['cart_page_data']['header']['confirm']; | |
| 10196 | + } | |
| 10197 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10198 | + } | |
| 10199 | + | |
| 10200 | + public function filter_confirm_page_footer( $html ) { | |
| 10201 | + if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) { | |
| 10202 | + $html = $this->options['cart_page_data']['footer']['confirm']; | |
| 10203 | + } | |
| 10204 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10205 | + } | |
| 10206 | + | |
| 10207 | + public function filter_cartcompletion_page_header( $html ) { | |
| 10208 | + if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) { | |
| 10209 | + $html = $this->options['cart_page_data']['header']['completion']; | |
| 10210 | + } | |
| 10211 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10212 | + } | |
| 10213 | + | |
| 10214 | + public function filter_cartcompletion_page_footer( $html ) { | |
| 10215 | + if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) { | |
| 10216 | + $html = $this->options['cart_page_data']['footer']['completion']; | |
| 10217 | + } | |
| 10218 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10219 | + } | |
| 10220 | + | |
| 10221 | + public function filter_login_page_header( $html ) { | |
| 10222 | + if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) { | |
| 10223 | + $html = $this->options['member_page_data']['header']['login']; | |
| 10224 | + } | |
| 10225 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10226 | + } | |
| 10227 | + | |
| 10228 | + public function filter_login_page_footer( $html ) { | |
| 10229 | + if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) { | |
| 10230 | + $html = $this->options['member_page_data']['footer']['login']; | |
| 10231 | + } | |
| 10232 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10233 | + } | |
| 10234 | + | |
| 10235 | + public function filter_newmember_page_header( $html ) { | |
| 10236 | + if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) { | |
| 10237 | + $html = $this->options['member_page_data']['header']['newmember']; | |
| 10238 | + } | |
| 10239 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10240 | + } | |
| 10241 | + | |
| 10242 | + public function filter_newmember_page_footer( $html ) { | |
| 10243 | + if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) { | |
| 10244 | + $html = $this->options['member_page_data']['footer']['newmember']; | |
| 10245 | + } | |
| 10246 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10247 | + } | |
| 10248 | + | |
| 10249 | + public function filter_newpass_page_header( $html ) { | |
| 10250 | + if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) { | |
| 10251 | + $html = $this->options['member_page_data']['header']['newpass']; | |
| 10252 | + } | |
| 10253 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10254 | + } | |
| 10255 | + | |
| 10256 | + public function filter_newpass_page_footer( $html ) { | |
| 10257 | + if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) { | |
| 10258 | + $html = $this->options['member_page_data']['footer']['newpass']; | |
| 10259 | + } | |
| 10260 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10261 | + } | |
| 10262 | + | |
| 10263 | + public function filter_changepass_page_header( $html ) { | |
| 10264 | + if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) { | |
| 10265 | + $html = $this->options['member_page_data']['header']['changepass']; | |
| 10266 | + } | |
| 10267 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10268 | + } | |
| 10269 | + | |
| 10270 | + public function filter_changepass_page_footer( $html ) { | |
| 10271 | + if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) { | |
| 10272 | + $html = $this->options['member_page_data']['footer']['changepass']; | |
| 10273 | + } | |
| 10274 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10275 | + } | |
| 10276 | + | |
| 10277 | + public function filter_memberinfo_page_header( $html ) { | |
| 10278 | + if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) { | |
| 10279 | + $html = $this->options['member_page_data']['header']['memberinfo']; | |
| 10280 | + } | |
| 10281 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10282 | + } | |
| 10283 | + | |
| 10284 | + public function filter_memberinfo_page_footer( $html ) { | |
| 10285 | + if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) { | |
| 10286 | + $html = $this->options['member_page_data']['footer']['memberinfo']; | |
| 10287 | + } | |
| 10288 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10289 | + } | |
| 10290 | + | |
| 10291 | + public function filter_membercompletion_page_header( $html ) { | |
| 10292 | + if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) { | |
| 10293 | + $html = $this->options['member_page_data']['header']['completion']; | |
| 10294 | + } | |
| 10295 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10296 | + } | |
| 10297 | + | |
| 10298 | + public function filter_membercompletion_page_footer( $html ) { | |
| 10299 | + if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) { | |
| 10300 | + $html = $this->options['member_page_data']['footer']['completion']; | |
| 10301 | + } | |
| 10302 | + return do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10303 | + } | |
| 10304 | + | |
| 10305 | + public function action_cart_page_header() { | |
| 10306 | + if ( ! empty( $this->options['cart_page_data']['header']['cart'] ) ) { | |
| 10307 | + $html = $this->options['cart_page_data']['header']['cart']; | |
| 10308 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10309 | + } | |
| 10310 | + } | |
| 10311 | + | |
| 10312 | + public function action_cart_page_footer() { | |
| 10313 | + if ( ! empty( $this->options['cart_page_data']['footer']['cart'] ) ) { | |
| 10314 | + $html = $this->options['cart_page_data']['footer']['cart']; | |
| 10315 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10316 | + } | |
| 10317 | + } | |
| 10318 | + | |
| 10319 | + public function action_customer_page_header() { | |
| 10320 | + if ( ! empty( $this->options['cart_page_data']['header']['customer'] ) ) { | |
| 10321 | + $html = $this->options['cart_page_data']['header']['customer']; | |
| 10322 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10323 | + } | |
| 10324 | + } | |
| 10325 | + | |
| 10326 | + public function action_customer_page_footer() { | |
| 10327 | + if ( ! empty( $this->options['cart_page_data']['footer']['customer'] ) ) { | |
| 10328 | + $html = $this->options['cart_page_data']['footer']['customer']; | |
| 10329 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10330 | + } | |
| 10331 | + } | |
| 10332 | + | |
| 10333 | + public function action_delivery_page_header() { | |
| 10334 | + if ( ! empty( $this->options['cart_page_data']['header']['delivery'] ) ) { | |
| 10335 | + $html = $this->options['cart_page_data']['header']['delivery']; | |
| 10336 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10337 | + } | |
| 10338 | + } | |
| 10339 | + | |
| 10340 | + public function action_delivery_page_footer() { | |
| 10341 | + if ( ! empty( $this->options['cart_page_data']['footer']['delivery'] ) ) { | |
| 10342 | + $html = $this->options['cart_page_data']['footer']['delivery']; | |
| 10343 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10344 | + } | |
| 10345 | + } | |
| 10346 | + | |
| 10347 | + public function action_confirm_page_header() { | |
| 10348 | + if ( ! empty( $this->options['cart_page_data']['header']['confirm'] ) ) { | |
| 10349 | + $html = $this->options['cart_page_data']['header']['confirm']; | |
| 10350 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10351 | + } | |
| 10352 | + } | |
| 10353 | + | |
| 10354 | + public function action_confirm_page_footer() { | |
| 10355 | + if ( ! empty( $this->options['cart_page_data']['footer']['confirm'] ) ) { | |
| 10356 | + $html = $this->options['cart_page_data']['footer']['confirm']; | |
| 10357 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10358 | + } | |
| 10359 | + } | |
| 10360 | + | |
| 10361 | + public function action_cartcompletion_page_header() { | |
| 10362 | + if ( ! empty( $this->options['cart_page_data']['header']['completion'] ) ) { | |
| 10363 | + $html = $this->options['cart_page_data']['header']['completion']; | |
| 10364 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10365 | + } | |
| 10366 | + } | |
| 10367 | + | |
| 10368 | + public function action_cartcompletion_page_footer() { | |
| 10369 | + if ( ! empty( $this->options['cart_page_data']['footer']['completion'] ) ) { | |
| 10370 | + $html = $this->options['cart_page_data']['footer']['completion']; | |
| 10371 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10372 | + } | |
| 10373 | + } | |
| 10374 | + | |
| 10375 | + public function action_login_page_header() { | |
| 10376 | + if ( ! empty( $this->options['member_page_data']['header']['login'] ) ) { | |
| 10377 | + $html = $this->options['member_page_data']['header']['login']; | |
| 10378 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10379 | + } | |
| 10380 | + } | |
| 10381 | + | |
| 10382 | + public function action_login_page_footer() { | |
| 10383 | + if ( ! empty( $this->options['member_page_data']['footer']['login'] ) ) { | |
| 10384 | + $html = $this->options['member_page_data']['footer']['login']; | |
| 10385 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10386 | + } | |
| 10387 | + } | |
| 10388 | + | |
| 10389 | + public function action_newmember_page_header() { | |
| 10390 | + if ( ! empty( $this->options['member_page_data']['header']['newmember'] ) ) { | |
| 10391 | + $html = $this->options['member_page_data']['header']['newmember']; | |
| 10392 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10393 | + } | |
| 10394 | + } | |
| 10395 | + | |
| 10396 | + public function action_newmember_page_footer() { | |
| 10397 | + if ( ! empty( $this->options['member_page_data']['footer']['newmember'] ) ) { | |
| 10398 | + $html = $this->options['member_page_data']['footer']['newmember']; | |
| 10399 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10400 | + } | |
| 10401 | + } | |
| 10402 | + | |
| 10403 | + public function action_newpass_page_header() { | |
| 10404 | + if ( ! empty( $this->options['member_page_data']['header']['newpass'] ) ) { | |
| 10405 | + $html = $this->options['member_page_data']['header']['newpass']; | |
| 10406 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10407 | + } | |
| 10408 | + } | |
| 10409 | + | |
| 10410 | + public function action_newpass_page_footer() { | |
| 10411 | + if ( ! empty( $this->options['member_page_data']['footer']['newpass'] ) ) { | |
| 10412 | + $html = $this->options['member_page_data']['footer']['newpass']; | |
| 10413 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10414 | + } | |
| 10415 | + } | |
| 10416 | + | |
| 10417 | + public function action_changepass_page_header() { | |
| 10418 | + if ( ! empty( $this->options['member_page_data']['header']['changepass'] ) ) { | |
| 10419 | + $html = $this->options['member_page_data']['header']['changepass']; | |
| 10420 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10421 | + } | |
| 10422 | + } | |
| 10423 | + | |
| 10424 | + public function action_changepass_page_footer() { | |
| 10425 | + if ( ! empty( $this->options['member_page_data']['footer']['changepass'] ) ) { | |
| 10426 | + $html = $this->options['member_page_data']['footer']['changepass']; | |
| 10427 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10428 | + } | |
| 10429 | + } | |
| 10430 | + | |
| 10431 | + public function action_memberinfo_page_header() { | |
| 10432 | + if ( ! empty( $this->options['member_page_data']['header']['memberinfo'] ) ) { | |
| 10433 | + $html = $this->options['member_page_data']['header']['memberinfo']; | |
| 10434 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10435 | + } | |
| 10436 | + } | |
| 10437 | + | |
| 10438 | + public function action_memberinfo_page_footer() { | |
| 10439 | + if ( ! empty( $this->options['member_page_data']['footer']['memberinfo'] ) ) { | |
| 10440 | + $html = $this->options['member_page_data']['footer']['memberinfo']; | |
| 10441 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10442 | + } | |
| 10443 | + } | |
| 10444 | + | |
| 10445 | + public function action_membercompletion_page_header() { | |
| 10446 | + if ( ! empty( $this->options['member_page_data']['header']['completion'] ) ) { | |
| 10447 | + $html = $this->options['member_page_data']['header']['completion']; | |
| 10448 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10449 | + } | |
| 10450 | + } | |
| 10451 | + | |
| 10452 | + public function action_membercompletion_page_footer() { | |
| 10453 | + if ( ! empty( $this->options['member_page_data']['footer']['completion'] ) ) { | |
| 10454 | + $html = $this->options['member_page_data']['footer']['completion']; | |
| 10455 | + echo do_shortcode( stripslashes( nl2br( $html ) ) ); | |
| 10456 | + } | |
| 10457 | + } | |
| 10458 | + | |
| 10459 | + public function filter_confirm_page_notes( $html ) { | |
| 10460 | + if ( ! empty( $this->options['cart_page_data']['confirm_notes'] ) ) { | |
| 10461 | + $html = '<div class="wc_confirm_notes_area">' . $this->options['cart_page_data']['confirm_notes'] . '</div>'; | |
| 10462 | + } | |
| 10463 | + return stripslashes( nl2br( $html ) ); | |
| 10464 | + } | |
| 10465 | + | |
| 10466 | + public function action_confirm_page_notes() { | |
| 10467 | + if ( ! empty( $this->options['cart_page_data']['confirm_notes'] ) ) { | |
| 10468 | + $html = '<div class="wc_confirm_notes_area">' . $this->options['cart_page_data']['confirm_notes'] . '</div>'; | |
| 10469 | + echo stripslashes( nl2br( $html ) ); | |
| 10470 | + } | |
| 10471 | + } | |
| 10472 | + | |
| 10473 | + /** | |
| 10474 | + * Get member cookies. | |
| 10475 | + * | |
| 10476 | + * @param string $key string cookies key. | |
| 10477 | + * | |
| 10478 | + * @return string | |
| 10479 | + */ | |
| 10480 | + public function usces_get_member_cookies( $key ) { | |
| 10481 | + $result = ''; | |
| 10482 | + switch ( $key ) { | |
| 10483 | + case 'ord_ex_cancel': | |
| 10484 | + $ex_cancel = filter_input( INPUT_GET, 'ord_ex_cancel' ); | |
| 10485 | + if ( $ex_cancel ) { | |
| 10486 | + $result = ( 'on' === $ex_cancel ) ? 'on' : 'off'; | |
| 10487 | + } else { | |
| 10488 | + $cookie = $this->get_cookie( 'usces_front' ); | |
| 10489 | + $result = isset( $cookie['ord_ex_cancel'] ) ? $cookie['ord_ex_cancel'] : 'on'; | |
| 10490 | + $result = apply_filters( 'usces_filter_ord_ex_cancel_init', $result ); | |
| 10491 | + } | |
| 10492 | + break; | |
| 10493 | + case 'pur-date': | |
| 10494 | + $result = filter_input( INPUT_GET, 'pur-date' ); | |
| 10495 | + if ( null === $result ) { | |
| 10496 | + $cookie = $this->get_cookie( 'usces_front' ); | |
| 10497 | + $result = isset( $cookie['usces_purdate'] ) ? $cookie['usces_purdate'] : 'd_30'; | |
| 10498 | + $result = apply_filters( 'usces_filter_ord_purdate_init', $result ); | |
| 10499 | + } | |
| 10500 | + break; | |
| 10501 | + } | |
| 10502 | + return $result; | |
| 10503 | + } | |
| 10504 | + | |
| 10505 | +} | |