static function stripslashes_deep_post( $array ){ $res = array(); foreach( $array as $key => $value ){ $key = stripslashes($key); if( is_array($value) ){ $value = WC2_Utils::stripslashes_deep_post( $value ); }else{ $value = stripslashes($value); } $res[$key] = $value; } return $res; }
function process_posts() { if (!($fp = fopen($this->file, "r"))) { echo '<p><strong>' . __('Failed to open file.', 'wc2') . '</strong></p>'; wp_import_cleanup($this->id); return false; } global $wpdb; $wc2_item = WC2_DB_Item::get_instance(); //all delete //$wc2_item->delete_all_item_data(); //die(); $err = new WP_Error(); $sp = ","; $lines = array(); $buf = ''; while (!feof($fp)) { $temp = fgets($fp, 10240); if (0 == strlen($temp)) { continue; } $num = substr_count($temp, '"'); if (0 == $num % 2 && '' == $buf) { $lines[] = $temp; } elseif (1 == $num % 2 && '' == $buf) { $buf .= $temp; } elseif (0 == $num % 2 && '' != $buf) { $buf .= $temp; } elseif (1 == $num % 2 && '' != $buf) { $buf .= $temp; $lines[] = $buf; $buf = ''; } } fclose($fp); //Post data - fixed define('COL_POST_ID', 0); define('COL_POST_AUTHOR', 1); define('COL_POST_CONTENT', 2); define('COL_POST_TITLE', 3); define('COL_POST_EXCERPT', 4); define('COL_POST_STATUS', 5); define('COL_POST_COMMENT_STATUS', 6); define('COL_POST_PASSWORD', 7); define('COL_POST_NAME', 8); define('COL_POST_MODIFIED', 9); define('COL_POST_CATEGORY', 10); define('COL_POST_TAG', 11); define('COL_POST_CUSTOM_FIELD', 12); define('COL_ITEM_CODE', 13); define('COL_ITEM_NAME', 14); $item_base_column = $wc2_item->get_item_base_column(); $item_meta_column = $wc2_item->get_item_meta_column(); $item_sku_column = $wc2_item->get_item_sku_column(); $item_sku_meta_column = $wc2_item->get_item_sku_meta_column(); $system = wc2_get_option('system'); $this->encode_type = isset($system['csv_encode_type']) ? $system['csv_encode_type'] : 0; $start_col = 13; $sku_start_col = $start_col; foreach ((array) $item_base_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $sku_start_col++; } } foreach ((array) $item_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $sku_start_col++; } } $post_status = array('publish', 'future', 'draft', 'pending', 'private'); $pre_item_code = ''; $item_id = 0; $sku_id = 1; $this->data_rows = count($lines); $this->success = 0; $this->false = 0; //Progressbar 処理件数SET echo '<script type="text/javascript">PG_Set_Max(' . $this->data_rows . ');</script>' . "\r\n"; ob_flush(); flush(); foreach ($lines as $row => $line) { $datas = array(); $datas = explode($sp, trim($line)); $this->values = array(); $buf = ''; foreach ($datas as $data) { $num = substr_count($data, '"'); if (0 == $num % 2 && '' == $buf) { if ('"' == substr($data, 0, 1)) { $data = substr($data, 1); } if ('"' == substr($data, -1)) { $data = substr($data, 0, -1); } $data = str_replace(array('""'), '"', $data); $this->values[] = false !== $data ? $data : ''; } elseif (1 == $num % 2 && '' == $buf) { $buf .= $data; } elseif (0 == $num % 2 && '' != $buf) { $buf .= $sp . $data; } elseif (1 == $num % 2 && '' != $buf) { $buf .= $sp . $data; if ('"' == substr($buf, 0, 1)) { $buf = substr($buf, 1); } if ('"' == substr($buf, -1)) { $buf = substr($buf, 0, -1); } $buf = str_replace(array('""'), '"', $buf); $this->values[] = false !== $buf ? $buf : ''; $buf = ''; } } if ('Post ID' == $this->values[COL_POST_ID]) { $this->data_rows -= 1; $this->progress_add(); continue; } if ($pre_item_code == $this->values[COL_ITEM_CODE] && WC2_Utils::is_blank($this->values[COL_POST_ID])) { $mode = 'add'; $post_id = ''; } else { $post_id = !WC2_Utils::is_blank($this->values[COL_POST_ID]) ? (int) $this->values[COL_POST_ID] : ''; if ($post_id) { $post_ob = get_post($post_id); if (!isset($post_ob->ID) || empty($post_ob)) { $this->error_log($row, __("Post-ID {$post_id} does not exist.", 'wc2')); $this->create_log(); $this->progress_add(); continue; } $mode = 'upd'; } else { $mode = 'add'; } } $wc2_item->set_the_post_id($post_id); //data_check foreach ($this->values as $key => $val) { $value = trim($val); switch ($key) { case COL_POST_ID: if (!preg_match("/^[0-9]+\$/", $value) && 0 != strlen($value)) { $this->error_log($row, __('A value of the Post-ID is abnormal.', 'wc2')); } break; case COL_POST_AUTHOR: case COL_POST_COMMENT_STATUS: case COL_POST_PASSWORD: case COL_POST_NAME: case COL_POST_TITLE: case COL_POST_CONTENT: case COL_POST_EXCERPT: break; case COL_POST_STATUS: if (0 == strlen($value) || !in_array($value, $post_status)) { $this->error_log($row, __('A value of the display status is abnormal.', 'wc2')); } break; case COL_POST_MODIFIED: if ('future' == $this->values[COL_POST_STATUS] && (0 == strlen($value) || '0000-00-00 00:00:00' == $value)) { if (preg_match($date_pattern, $value, $match)) { if (checkdate($match[2], $match[3], $match[1]) && (0 < $match[4] && 24 > $match[4]) && (0 < $match[5] && 60 > $match[5]) && (0 < $match[6] && 60 > $match[6])) { } else { $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2')); } } else { $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2')); } } else { if (0 != strlen($value) && '0000-00-00 00:00:00' != $value) { if (preg_match("/^[0-9]+\$/", substr($value, 0, 4))) { if (strtotime($value) === false) { $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2')); } } else { $datetime = explode(' ', $value); $date_str = $this->dates_interconv($datetime[0]) . ' ' . $datetime[1]; if (strtotime($date_str) === false) { $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2')); } } } } break; case COL_POST_CATEGORY: if (0 == strlen($value)) { $this->error_log($row, __('A category is non-input.', 'wc2')); } break; case COL_POST_TAG: case COL_POST_CUSTOM_FIELD: break; case COL_ITEM_CODE: if (0 == strlen($value)) { $this->error_log($row, __('An item code is non-input.', 'wc2')); } else { $post_ids = $wc2_item->get_some_post_ids_by_item_code($value); if ('upd' == $mode) { if (1 < count($post_ids)) { $this->error_log($row, __('This Item-Code has been duplicated.', 'wc2')); foreach ($post_ids as $res_val) { $this->error_log($row, "item_code=" . $value . ", post_id=" . $res_val['item_post_id']); } } elseif (1 === count($post_ids)) { if ($post_ids[0]['item_post_id'] != $post_id) { $this->error_log($row, __('This Item-Code has already been used.', 'wc2')); $this->error_log($row, "item_code=" . $value . ", post_id=" . $post_ids[0]['item_post_id']); } } } else { if ('add' == $mode) { if ($value != $pre_item_code) { if (0 < count($post_ids)) { $this->error_log($row, __('This Item-Code has already been used.', 'wc2')); foreach ($post_ids as $res_val) { $this->error_log($row, "item_code=" . $value . ", post_id=" . $res_val['item_post_id']); } } } } } } break; case COL_ITEM_NAME: if (0 == strlen($value)) { $this->error_log($row, __('An item name is non-input.', 'wc2')); } break; } } //表示する Item column をエラーチェック $check_num = $start_col; foreach ($item_base_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $check_column[$key] = $check_num; $check_num++; } } foreach ($item_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $check_column[$key] = $check_num; $check_num++; } } foreach ($item_sku_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $check_column[$key] = $check_num; $check_num++; } } foreach ($item_sku_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $check_column[$key] = $check_num; $check_num++; } } foreach ($check_column as $column_key => $data_num) { switch ($column_key) { case ITEM_PRODUCT_TYPE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Product type is abnormal.', 'wc2')); } break; case ITEM_CHARGES_TYPE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Billing type is abnormal.', 'wc2')); } break; case ITEM_PURCHASE_LIMIT_LOWEST: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Purchase limit(lowest) is abnormal.', 'wc2')); } break; case ITEM_PURCHASE_LIMIT_HIGHEST: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Purchase limit(highest) is abnormal.', 'wc2')); } break; case ITEM_POINT_RATE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the point rate is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_NUM1: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount1(number) is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_RATE1: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount1(rate) is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_NUM2: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount2(number) is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_RATE2: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount2(rate) is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_NUM3: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount3(number) is abnormal.', 'wc2')); } break; case ITEM_QUANTITY_DISCOUNT_RATE3: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount3(rate) is abnormal.', 'wc2')); } break; case ITEM_SKU_CODE: if (0 == strlen($this->values[$data_num])) { $this->error_log($row, __('A SKU code is non-input.', 'wc2')); } break; case ITEM_SKU_NAME: case ITEM_SKU_UNIT: break; case ITEM_SKU_STOCK: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the SKU stock is abnormal.', 'wc2')); } break; case ITEM_SKU_STATUS: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the SKU status is abnormal.', 'wc2')); } break; case ITEM_SKU_PRICE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the SKU price is abnormal.', 'wc2')); } break; case ITEM_SKU_COSTPRICE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the SKU cost price is abnormal.', 'wc2')); } break; case ITEM_SKU_LISTPRICE: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the SKU list price is abnormal.', 'wc2')); } break; case ITEM_SKU_SET_QUANTITY_DISCOUNT: if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) { $this->error_log($row, __('A value of the Quantity discount applies is abnormal.', 'wc2')); } break; } } if ('' != $this->get_log_line()) { $this->create_log(); $this->progress_add(); continue; } $post = array(); if ($pre_item_code != $this->values[COL_ITEM_CODE]) { $sku_id = 1; if ($this->values[COL_POST_MODIFIED] == '' || $this->values[COL_POST_MODIFIED] == '0000-00-00 00:00:00') { $post['post_date'] = current_time('mysql'); $post['post_date_gmt'] = current_time('mysql', 1); $post['post_modified'] = current_time('mysql'); $post['post_modified_gmt'] = current_time('mysql', 1); } else { if (preg_match("/^[0-9]+\$/", substr($this->values[COL_POST_MODIFIED], 0, 4))) { $time_data = strtotime($this->values[COL_POST_MODIFIED]); } else { $datetime = explode(' ', $this->values[COL_POST_MODIFIED]); $date_str = $this->dates_interconv($datetime[0]) . ' ' . $datetime[1]; $time_data = strtotime($date_str); } $post['post_date'] = date('Y-m-d H:i:s', $time_data); $post['post_date_gmt'] = gmdate('Y-m-d H:i:s', $time_data); $post['post_modified'] = date('Y-m-d H:i:s', $time_data); $post['post_modified_gmt'] = gmdate('Y-m-d H:i:s', $time_data); } if ('publish' == $this->values[COL_POST_STATUS]) { $now = current_time('mysql'); if (mysql2date('U', $post['post_modified'], false) > mysql2date('U', $now, false)) { $this->values[COL_POST_STATUS] = 'future'; } } elseif ('future' == $this->values[COL_POST_STATUS]) { $now = current_time('mysql'); if (mysql2date('U', $post['post_modified'], false) <= mysql2date('U', $now, false)) { $this->values[COL_POST_STATUS] = 'publish'; } } $post['ID'] = $post_id; $post['post_author'] = !WC2_Utils::is_blank($this->values[COL_POST_AUTHOR]) ? $this->values[COL_POST_AUTHOR] : 1; $post['post_content'] = $this->convert_encoding($this->values[COL_POST_CONTENT]); $post['post_title'] = $this->convert_encoding($this->values[COL_POST_TITLE]); $post['post_excerpt'] = $this->convert_encoding($this->values[COL_POST_EXCERPT]); $post['post_status'] = $this->values[COL_POST_STATUS]; $post['comment_status'] = !WC2_Utils::is_blank($this->values[COL_POST_COMMENT_STATUS]) ? $this->values[COL_POST_COMMENT_STATUS] : 'close'; $post['ping_status'] = 'close'; $post['post_password'] = '******' == $post['post_status'] ? '' : $this->values[COL_POST_PASSWORD]; $post['post_type'] = ITEM_POST_TYPE; $post['post_parent'] = 0; $post_name = sanitize_title($this->convert_encoding($this->values[COL_POST_NAME])); $post['post_name'] = wp_unique_post_slug($post_name, $post_id, $post['post_status'], $post['post_type'], $post['post_parent']); $post['to_ping'] = ''; $post['pinged'] = ''; $post['menu_order'] = 0; $post['post_content_filtered'] = ''; if (empty($post['post_name']) && !in_array($post['post_status'], array('draft', 'pending', 'auto-draft'))) { $post['post_name'] = sanitize_title($post['post_title'], $post_id); } if ($mode == 'add') { $post['guid'] = ''; if (false === $wpdb->insert($wpdb->posts, $post)) { $this->error_log($row, __('This data was not registered in the database.', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; $this->create_log(); $this->progress_add(); continue; } $post_id = $wpdb->insert_id; $wc2_item->set_the_post_id($post_id); $where = array('ID' => $post_id); $wpdb->update($wpdb->posts, array('guid' => get_permalink($post_id)), $where); } elseif ($mode == 'upd') { $where = array('ID' => $post_id); if (false === $wpdb->update($wpdb->posts, $post, $where)) { $this->error_log($row, __('The data were not registered with a database.', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; $this->create_log(); $this->progress_add(); continue; } //delete all metas of Item $meta_key_table = array(); $cfrows = explode(';', trim($this->values[COL_POST_CUSTOM_FIELD])); //if( !(1 === count($cfrows) && '' == reset($cfrows)) ) { if ('' != reset($cfrows)) { foreach ($cfrows as $cf) { list($meta_key, $meta_value) = explode('=', $cf, 2); if (!WC2_Utils::is_blank($meta_key)) { array_push($meta_key_table, $this->convert_encoding($meta_key)); } } } $meta_key_table = apply_filters('wc2_filter_importitem_delete_postmeta', $meta_key_table); $res = $wc2_item->delete_custome_field_key($meta_key_table); if (false === $res) { $this->error_log($row, __('Error : delete postmeta', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; $this->create_log(); $this->progress_add(); continue; } //delete Item revisions $res = $wc2_item->delete_item_revision(); if (false === $res) { $this->error_log($row, __('Error : delete revisions', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; $this->create_log(); $this->progress_add(); continue; } //delete relationships of category $res = $wc2_item->delete_term_relationship(); if (false === $res) { $this->error_log($row, __('Error : delete term_relationships(category)', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; $this->create_log(); $this->progress_add(); continue; } //delete relationships of tag //$query = "SELECT term_taxonomy_id, COUNT(*) AS ct FROM {$wpdb->term_relationships} GROUP BY term_taxonomy_id"; //$relation_data = $wpdb->get_results( $query, ARRAY_A ); $relation_data = $wc2_item->get_count_term_taxonomy(); foreach ((array) $relation_data as $relation_rows) { $term_taxonomy_where['term_taxonomy_id'] = $relation_rows['term_taxonomy_id']; // $term_taxonomy_id['term_taxonomy_id'] = $relation_rows['term_taxonomy_id']; $term_taxonomy_updatas['count'] = $relation_rows['ct']; if (false === $wpdb->update($wpdb->term_taxonomy, $term_taxonomy_updatas, $term_taxonomy_where)) { $this->error_log($row, __('Error : delete term_relationships(tag)', 'wc2')); $pre_item_code = $this->values[COL_ITEM_CODE]; continue; } } } //add term_relationships, edit term_taxonomy //category $categories = explode(';', $this->values[COL_POST_CATEGORY]); $category_ids = array(); foreach ((array) $categories as $category) { $cat = get_term_by('slug', $category, 'item'); if ($cat == false) { $category = (string) $category; $this->error_log($row, __(sprintf('Since the category slug "%s" does not exist or could not be category registration.', $this->convert_encoding($category)), 'wc2')); continue; } $category_ids[] = $cat->term_id; } $term_taxonomy_ids = wp_set_post_terms($post_id, $category_ids, 'item'); foreach ($term_taxonomy_ids as $term_taxonomy_id) { $wc2_item->term_taxonomy_count_post($term_taxonomy_id); } //tag $tags_concat = str_replace(';', ',', $this->convert_encoding($this->values[COL_POST_TAG])); $term_taxonomy_ids = wp_set_post_terms($post_id, $tags_concat, 'item-tag'); foreach ($term_taxonomy_ids as $term_taxonomy_id) { $wc2_item->term_taxonomy_count_post($term_taxonomy_id); } //add custom field $cfrows = explode(';', trim($this->values[COL_POST_CUSTOM_FIELD])); //if( !(1 === count($cfrows) && '' == reset($cfrows)) ) { if ('' != reset($cfrows)) { $valstr = ''; foreach ($cfrows as $cf) { list($meta_key, $meta_value) = explode('=', $cf, 2); if (!WC2_Utils::is_blank($meta_key)) { update_post_meta($post_id, $this->convert_encoding($meta_key), $this->convert_encoding($meta_value)); } } } $wc2_item->clear_column(); //Item data set $col = $start_col; foreach ($item_base_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type'])); $col++; } } foreach ($item_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type'])); $col++; } } //SKU data set $col = $sku_start_col; foreach ($item_sku_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type'])); $col++; } } foreach ($item_sku_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type'])); $col++; } } if ($mode == 'add') { $wc2_item->add_item_data(); } elseif ($mode == 'upd') { $wc2_item->update_item_data(); } } else { //sku登録のみの行 $sku_id++; //SKU data set $col = $sku_start_col; foreach ($item_sku_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type'])); $col++; } } foreach ($item_sku_meta_column as $key => $column) { if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) { $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type'])); $col++; } } $item_id = $wc2_item->get_item_id_by_post_id($post_id); $sku_data = $wc2_item->get_item_sku_data($item_id, $sku_id); if (0 == $wc2_item->count_sku_data($sku_id)) { if (0 < $sku_id and '' != $wc2_item->get_the_item_sku_code($sku_id)) { $res = $wc2_item->add_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id)); if (false === $res) { break; } } } else { $res = $wc2_item->update_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id)); if (false === $res) { break; } } } if ('' != $this->get_log_line()) { $this->create_log(); } //登録成功数加算 $this->success += 1; $pre_item_code = $this->values[COL_ITEM_CODE]; clean_post_cache($post_id); wp_cache_delete($post_id, 'posts'); wp_cache_delete($post_id, 'post_meta'); clean_object_term_cache($post_id, 'post'); //進捗加算 $this->progress_add(); } wp_import_cleanup($this->id); $this->false = $this->data_rows - $this->success; echo '<h3>' . __('All Done.', 'wc2') . '</h3> <h3>' . sprintf(__('Success %d failure %d', 'wc2'), $this->success, $this->false) . '</h3>'; if (0 < strlen($this->log)) { WC2_Utils::wc2_log($this->log, "import_item.log"); echo str_replace("\n", "<br />", $this->log); } }
public function admin_delivery_page() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix != $screen->id) { return; } $delivery = wc2_get_option('delivery'); if (isset($_POST['wc2_option_update'])) { check_admin_referer('wc2_setting_delivery', 'wc2_nonce'); $_POST = WC2_Utils::stripslashes_deep_post($_POST); if (isset($_POST['delivery_time_limit'])) { $delivery['delivery_time_limit'] = $_POST['delivery_time_limit']; } if (isset($_POST['shortest_delivery_time'])) { $delivery['shortest_delivery_time'] = $_POST['shortest_delivery_time']; } if (isset($_POST['delivery_after_days'])) { $delivery['delivery_after_days'] = $_POST['delivery_after_days']; } if (isset($_POST['delivery_limit_option'])) { $delivery['delivery_limit_option'] = $_POST['delivery_limit_option']; } wc2_update_option('delivery', $delivery); $this->action_status = 'success'; $this->action_message = __('Updated!'); } else { $this->action_status = 'none'; $this->action_message = ''; } $delivery_time_limit['hour'] = isset($delivery['delivery_time_limit']['hour']) ? $delivery['delivery_time_limit']['hour'] : '00'; $delivery_time_limit['min'] = isset($delivery['delivery_time_limit']['min']) ? $delivery['delivery_time_limit']['min'] : '00'; $shortest_delivery_time = isset($delivery['shortest_delivery_time']) ? $delivery['shortest_delivery_time'] : '0'; $delivery_after_days = empty($delivery['delivery_after_days']) ? 15 : (int) $delivery['delivery_after_days']; $delivery_limit_option = isset($delivery['delivery_limit_option']) ? $delivery['delivery_limit_option'] : 'none'; $status = $this->action_status; $message = $this->action_message; require_once WC2_PLUGIN_DIR . '/admin/views/setting-delivery.php'; }
public function general_setting_page() { global $allowedposttags; if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix != $screen->id) { return; } $general = wc2_get_option('general'); $cart_description = wc2_get_option('cart_description'); $member_description = wc2_get_option('member_description'); if (array_key_exists('wc2_option_update', $_POST)) { check_admin_referer('wc2_setting_general', 'wc2_nonce'); // $this->error_message = $this->setting_delivery_check(); $_POST = WC2_Utils::stripslashes_deep_post($_POST); //ショップ設定 $general['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : ''; $general['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : ''; $general['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : ''; $general['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : ''; $general['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : ''; $general['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : ''; $general['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : ''; $general['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : ''; $general['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : ''; $general['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : ''; $general['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : ''; $general['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : ''; $general['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : ''; $general['tax_mode'] = isset($_POST['tax_mode']) ? trim($_POST['tax_mode']) : 'include'; $general['tax_target'] = isset($_POST['tax_target']) ? trim($_POST['tax_target']) : 'products'; $general['tax_rate'] = isset($_POST['tax_rate']) ? (int) $_POST['tax_rate'] : ''; $general['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : ''; $general['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : ''; $general['add2cart'] = isset($_POST['add2cart']) ? trim($_POST['add2cart']) : '0'; //営業設定 $general['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : ''; $general['campaign_category'] = empty($_POST['cat']) ? '0' : $_POST['cat']; $general['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : ''; $general['privilege_point'] = isset($_POST['point_num']) ? (int) $_POST['point_num'] : ''; $general['privilege_discount'] = isset($_POST['discount_num']) ? (int) $_POST['discount_num'] : ''; $general['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0'; if (isset($_POST['business_days'])) { $general['business_days'] = $_POST['business_days']; } //会員システム $general['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : ''; $general['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : ''; $general['point_rate'] = isset($_POST['point_rate']) ? (int) $_POST['point_rate'] : 1; $general['start_point'] = isset($_POST['start_point']) ? (int) $_POST['start_point'] : ''; $general['point_coverage'] = isset($_POST['point_coverage']) ? (int) $_POST['point_coverage'] : 0; $general['point_assign'] = isset($_POST['point_assign']) ? (int) $_POST['point_assign'] : 1; $general['member_pass_rule_min'] = isset($_POST['member_pass_rule_min']) ? (int) $_POST['member_pass_rule_min'] : 6; $general['member_pass_rule_max'] = isset($_POST['member_pass_rule_max']) && !empty($_POST['member_pass_rule_max']) ? (int) $_POST['member_pass_rule_max'] : ''; //カートページ設定 foreach ($general['indi_item_name'] as $key => $val) { $general['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0; } foreach ($_POST['position'] as $key => $value) { $general['position'][$key] = $value; } //カート関連ページに挿入する説明書き foreach ($_POST['cart_header'] as $key => $value) { $cart_description['cart_header'][$key] = isset($_POST['cart_header'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : ''; } foreach ($_POST['cart_footer'] as $key => $value) { $cart_description['cart_footer'][$key] = isset($_POST['cart_footer'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : ''; } //会員関連ページに挿入する説明書き foreach ($_POST['member_header'] as $key => $value) { $member_description['member_header'][$key] = isset($_POST['member_header'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : ''; } foreach ($_POST['member_footer'] as $key => $value) { $member_description['member_footer'][$key] = isset($_POST['member_footer'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : ''; } if (!isset($general['indi_item_name'])) { $general['indi_item_name']['item_name'] = 1; $general['indi_item_name']['item_code'] = 1; $general['indi_item_name']['sku_name'] = 1; $general['indi_item_name']['sku_code'] = 1; $general['pos_item_name']['item_name'] = 1; $general['pos_item_name']['item_code'] = 2; $general['pos_item_name']['sku_name'] = 3; $general['pos_item_name']['sku_code'] = 4; } $general = apply_filters('wc2_filter_admin_setup_options', $general); wc2_update_option('general', $general); wc2_update_option('cart_description', $cart_description); wc2_update_option('member_description', $member_description); do_action('wc2_action_general_option_update'); $this->action_status = 'success'; $this->action_message = __('Updated!'); } else { $this->action_status = 'none'; $this->action_message = ''; } $status = $this->action_status; $message = $this->action_message; //today list($todayyy, $todaymm, $todaydd) = wc2_get_today(); for ($i = 0; $i < 12; $i++) { if (0 == $i) { $this->cal[$i] = new Calendar_Data(); $this->cal[$i]->setToday($todayyy, $todaymm, $todaydd); $this->cal[$i]->setCalendarData(); } list($month_yy[$i], $month_mm[$i], $month_dd[$i]) = wc2_get_aftermonth($todayyy, $todaymm, 1, $i); $this->cal[$i] = new Calendar_Data(); $this->cal[$i]->setToday($month_yy[$i], $month_mm[$i], $month_dd[$i]); $this->cal[$i]->setCalendarData(); } $yearstr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 4); $campaign_schedule_start_year = isset($general['campaign_schedule']['start']['year']) ? $general['campaign_schedule']['start']['year'] : 0; $campaign_schedule_start_month = isset($general['campaign_schedule']['start']['month']) ? $general['campaign_schedule']['start']['month'] : 0; $campaign_schedule_start_day = isset($general['campaign_schedule']['start']['day']) ? $general['campaign_schedule']['start']['day'] : 0; $campaign_schedule_start_hour = isset($general['campaign_schedule']['start']['hour']) ? $general['campaign_schedule']['start']['hour'] : 0; $campaign_schedule_start_min = isset($general['campaign_schedule']['start']['min']) ? $general['campaign_schedule']['start']['min'] : 0; $campaign_schedule_end_year = isset($general['campaign_schedule']['end']['year']) ? $general['campaign_schedule']['end']['year'] : 0; $campaign_schedule_end_month = isset($general['campaign_schedule']['end']['month']) ? $general['campaign_schedule']['end']['month'] : 0; $campaign_schedule_end_day = isset($general['campaign_schedule']['end']['day']) ? $general['campaign_schedule']['end']['day'] : 0; $campaign_schedule_end_hour = isset($general['campaign_schedule']['end']['hour']) ? $general['campaign_schedule']['end']['hour'] : 0; $campaign_schedule_end_min = isset($general['campaign_schedule']['end']['min']) ? $general['campaign_schedule']['end']['min'] : 0; $common_opts = isset($general['_iopt_']) ? $general['_iopt_'] : ''; $display_mode_label = wc2_get_option('display_mode_label'); $indi_item_name = $general['indi_item_name']; $pos_item_name = $general['pos_item_name']; foreach ((array) $indi_item_name as $key => $value) { $checked_item_name[$key] = $indi_item_name[$key] == 1 ? ' checked="checked"' : ''; } if (!empty($cart_description)) { $cart_page_data = stripslashes_deep($cart_description); } else { $cart_page_data['cart_header'] = array(); $cart_page_data['cart_footer'] = array(); } if (!empty($member_description)) { $member_page_data = stripslashes_deep($member_description); } else { $member_page_data['member_header'] = array(); $member_page_data['member_footer'] = array(); } require_once WC2_PLUGIN_DIR . '/admin/views/setting-general.php'; }
public function edit_member_data($mem_id, $type = 'member') { global $wpdb; if (empty($mem_id) || !array_key_exists($type, $_POST)) { return false; } $wc2_db_member = WC2_DB_Member::get_instance(); //$wc2_db_member->get_member_data($mem_id); $_POST = WC2_Utils::stripslashes_deep_post($_POST); $passwd = is_admin() || !is_admin() && wc2_is_blank($_POST[$type]['passwd']) && wc2_is_blank($_POST[$type]['passwd2']) ? $wc2_db_member->get_value('passwd') : md5(trim($_POST[$type]['passwd'])); $point = is_admin() && isset($_POST['member']['point']) ? trim($_POST['member']['point']) : $wc2_db_member->get_value('rank'); $rank = is_admin() ? trim($_POST['member']['rank']) : $wc2_db_member->get_value('rank'); $wc2_db_member->clear_column(); $wc2_db_member->set_member_id($mem_id); $wc2_db_member->set_value('account', trim($_POST[$type]['account'])); $wc2_db_member->set_value('email', trim($_POST[$type]['email'])); $wc2_db_member->set_value('passwd', $passwd); $wc2_db_member->set_value('rank', $rank); $wc2_db_member->set_value('point', $point); $wc2_db_member->set_value('name1', trim($_POST[$type]['name1'])); $wc2_db_member->set_value('name2', trim($_POST[$type]['name2'])); $wc2_db_member->set_value('name3', trim($_POST[$type]['name3'])); $wc2_db_member->set_value('name4', trim($_POST[$type]['name4'])); $wc2_db_member->set_value('country', trim($_POST[$type]['country'])); $wc2_db_member->set_value('zipcode', trim($_POST[$type]['zipcode'])); $wc2_db_member->set_value('pref', trim($_POST[$type]['pref'])); $wc2_db_member->set_value('address1', trim($_POST[$type]['address1'])); $wc2_db_member->set_value('address2', trim($_POST[$type]['address2'])); $wc2_db_member->set_value('tel', trim($_POST[$type]['tel'])); $wc2_db_member->set_value('fax', trim($_POST[$type]['fax'])); if ($type == 'member') { //csmb $csmb_keys = wc2_get_custom_field_keys(WC2_CSMB); if (!empty($csmb_keys) && is_array($csmb_keys)) { $csmb = array(); foreach ($csmb_keys as $key) { list($pfx, $csmb_key) = explode('_', $key, 2); //$csmb_val = ( isset( $_POST[WC2_CUSTOM_MEMBER][$csmb_key] ) ) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key]: ''; $csmb[$csmb_key] = isset($_POST[WC2_CUSTOM_MEMBER][$csmb_key]) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key] : ''; } $wc2_db_member->set_value(WC2_CUSTOM_MEMBER, $csmb); } //meta //meta_typeあり //$wc2_db_member->set_meta_value($key, $value, $type); //meta_typeなし //$wc2_db_member->set_meta_value($key, $value); } elseif ($type == 'customer') { //cscs $cscs_keys = wc2_get_custom_field_keys(WC2_CSCS); if (!empty($cscs_keys) && is_array($cscs_keys)) { $cscs = array(); foreach ($cscs_keys as $key) { list($pfx, $cscs_key) = explode('_', $key, 2); //$cscs_val = ( isset( $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] ) ) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]: ''; $cscs[$cscs_key] = isset($_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] : ''; } $wc2_db_member->set_value(WC2_CUSTOM_CUSTOMER, $cscs); } //meta //meta_typeあり //$wc2_db_member->set_meta_value($key, $value, $type); //meta_typeなし //$wc2_db_member->set_meta_value($key, $value); } do_action('wc2_action_edit_member_data', $mem_id, $type); $res = $wc2_db_member->update_member_data($mem_id); return $res; }
/** * Delivery input check * */ public function delivery_check() { $mes = array(); if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { //氏名 if ( WC2_Utils::is_blank($_POST['delivery']['name1']) || WC2_Utils::is_blank($_POST['delivery']['name2']) ){ $mes[] = __('氏名を入力してください。', 'wc2'); } //郵便番号 if ( WC2_Utils::is_blank($_POST['delivery']['zipcode']) ){ $mes[] = __('郵便番号が入力されていません。', 'wc2'); }elseif( preg_match('/[^\d-]/', trim($_POST['delivery']['zipcode'])) ){ $mes[] = __('郵便番号は半角数字で入力してください。', 'wc2'); } //都道府県 if ( WC2_UNSELECTED == ($_POST['delivery']['pref']) ) $mes[] = __('都道府県が選択されていません。', 'wc2'); //市区町村・番地 if ( WC2_Utils::is_blank($_POST['delivery']['address1']) ) $mes[] = __('市区町村・番地が入力されていません。', 'wc2'); //電話番号 if( WC2_Utils::is_blank($_POST['delivery']['tel']) ){ $mes[] = __('電話番号が入力されていません。', 'wc2'); }elseif( !WC2_Utils::is_blank($_POST['delivery']['tel']) && preg_match('/[^\d]/', trim($_POST['delivery']['tel'])) ){ $mes[] = __('電話番号は半角数字で入力してください。', 'wc2'); } } if( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WC2_Utils::is_zero($_POST['offer']['delivery_method'])) ) $mes[] = __('配送方法を選択してください。', 'wc2'); if( !isset($_POST['offer']['payment_method']) ) { $mes[] = __('支払方法を選択してください。', 'wc2'); } else { $entry_data = wc2_get_entry(); $delivery = wc2_get_option( 'delivery' ); $general = wc2_get_option( 'general' ); $payment = wc2_get_payment( $_POST['offer']['payment_method'] ); if( 'COD' == $payment['settlement'] ) { $item_total_price = wc2_get_item_total_price(); $materials = array( 'total_price' => $item_total_price, 'discount' => $entry_data['order']['discount'], 'shipping_charge' => $entry_data['order']['shipping_charge'], 'cod_fee' => $entry_data['order']['cod_fee'], ); $item_total_price += wc2_get_tax( $materials ); $cod_limit_amount = ( isset($general['cod_limit_amount']) && 0 < (int)$general['cod_limit_amount'] ) ? $general['cod_limit_amount'] : 0; if( 0 < $cod_limit_amount && $item_total_price > $cod_limit_amount ) $mes[] = sprintf(__('商品合計金額が、代引きでご購入できる上限額(%s)を超えています。', 'wc2'), wc2_crform( $general['cod_limit_amount'], true, false )); } $d_method_index = wc2_get_delivery_method_index( (int)$_POST['offer']['delivery_method'] ); if( $delivery['delivery_method'][$d_method_index]['nocod'] == 1 ) { if('COD' == $payment['settlement']) $mes[] = __('この配送方法では、代引きはご利用できません。', 'wc2'); } $country = $entry_data['delivery']['country']; $local_country = wc2_get_base_country(); if( $country == $local_country ) { if( $delivery['delivery_method'][$d_method_index]['intl'] == 1 ) { $mes[] = __('配送方法が誤っています。国際便は指定できません。', 'wc2'); } } else { if( WC2_Utils::is_zero($delivery['delivery_method'][$d_method_index]['intl']) ) { $mes[] = __('配送方法が誤っています。国際便を指定してください。', 'wc2'); } } } //custom_delivery check $csde_mes = wc2_custom_field_enter_check('delivery'); foreach( $csde_mes as $csde_mes_val ){ $mes[] = $csde_mes_val; } //custom_order check $csod_mes = wc2_custom_field_enter_check('order'); foreach( $csod_mes as $csod_mes_val ){ $mes[] = $csod_mes_val; } $mes = apply_filters( 'wc2_filter_delivery_check', $mes ); return $mes; }
public function phrase_ajax() { //if( !check_ajax_referer( 'wc2_setting_phrase', 'wc2_nonce', false ) ) die(); if (!isset($_POST['action']) or !isset($_POST['mode'])) { die; } if ($_POST['action'] != 'phrase_ajax') { die; } $res = ''; switch ($_POST['mode']) { case 'select': $phrase = $_POST['phrase']; $phrase_options = wc2_get_option('phrase'); $phrase_default = wc2_get_option('phrase_default'); $title = WC2_Utils::is_blank($phrase_options['title'][$phrase]) ? $phrase_default['title'][$phrase] : $phrase_options['title'][$phrase]; $header = WC2_Utils::is_blank($phrase_options['header'][$phrase]) ? $phrase_default['header'][$phrase] : $phrase_options['header'][$phrase]; $footer = WC2_Utils::is_blank($phrase_options['footer'][$phrase]) ? $phrase_default['footer'][$phrase] : $phrase_options['footer'][$phrase]; $res = 'OK' . WC2_SPLIT . $title . WC2_SPLIT . $header . WC2_SPLIT . $footer; break; case 'update': if (!check_ajax_referer('wc2_setting_phrase', 'wc2_nonce', false)) { $res = 'NG' . WC2_SPLIT . __('Security error.'); } else { $_POST = wc2_stripslashes_deep_post($_POST); $phrase = $_POST['phrase']; $phrase_options = wc2_get_option('phrase'); $phrase_options['title'][$phrase] = urldecode(trim($_POST['title'])); $phrase_options['header'][$phrase] = urldecode(trim($_POST['header'])); $phrase_options['footer'][$phrase] = urldecode(trim($_POST['footer'])); $phrase_options = apply_filters('wc2_filter_admin_phrase_update', $phrase_options, $phrase); wc2_update_option('phrase', $phrase_options); $res = 'OK' . WC2_SPLIT . $phrase_options['footer'][$phrase]; } break; } $res = apply_filters('wc2_filter_admin_phrase_ajax', $res); die($res); }
function wc2_log($log, $file, $place = ''){ WC2_Utils::wc2_log($log, $file, $place); }
<th><?php _e('ポイント付与のタイミング', 'wc2'); ?> </th> <td class="horizontal"> <label title="1"><input name="point_assign" id="point_assign_receipt" type="radio" value="1"<?php if ($general['point_assign'] == 1) { echo ' checked="checked"'; } ?> /><span><?php _e('入金時', 'wc2'); ?> </span></label> <label title="0"><input name="point_assign" id="point_assign_immediately" type="radio" value="0"<?php if (WC2_Utils::is_zero($general['point_assign'])) { echo ' checked="checked"'; } ?> /><span><?php _e('即時', 'wc2'); ?> </span></label> </td> </tr> <tr> <th><?php _e('会員パスワードの文字数制限', 'wc2'); ?> </th> <td>
public function changepass_check(){ $mes = array(); //文字数チェック追加 if( WC2_Utils::is_blank($_POST['new_password1']) || WC2_Utils::is_blank($_POST['new_password2']) ){ $mes[] = __('新しいパスワードを入力してください。', 'wc2'); }elseif( trim($_POST['new_password1']) != trim($_POST['new_password2']) ){ $mes[] = __('確認用パスワードと異なります。', 'wc2'); }elseif( !preg_match( "/^[a-zA-Z0-9]+$/", trim( $_POST['new_password1'] ) ) ){ $mes[] = __('パスワードは半角英数字で入力してください。', 'wc2'); }else{ $general = wc2_get_option('general'); $member_pass_rule_min = $general['member_pass_rule_min']; $member_pass_rule_max = $general['member_pass_rule_max']; if( !empty( $member_pass_rule_max ) ){ if( $member_pass_rule_min > strlen( trim($_POST['new_password1']) ) || strlen( trim($_POST['new_password1']) ) > $member_pass_rule_max ){ $mes[] = sprintf(__('パスワードは%1$s文字以上%2$s文字以下で入力してください。', 'wc2'), $member_pass_rule_min, $member_pass_rule_max ); } }else{ if( $member_pass_rule_min > strlen( trim($_POST['new_password1']) ) ){ $mes[] = sprintf(__('パスワードは%s文字以上で入力してください。', 'wc2'), $member_pass_rule_min); } } } return $mes; }
function setup_cod_ajax() { if (!check_ajax_referer('wc2_setting_payment', 'wc2_nonce', false)) { die; } $payment_info = wc2_get_option('payment_info'); $message = ''; $_POST = WC2_Utils::stripslashes_deep_post($_POST); $payment_info['cod_type'] = isset($_POST['cod_type']) ? $_POST['cod_type'] : 'fix'; if (isset($_POST['cod_fee'])) { $payment_info['cod_fee'] = (int) $_POST['cod_fee']; } if ('fix' == $payment_info['cod_type']) { if (isset($_POST['cod_fee'])) { $payment_info['cod_fee'] = (int) $_POST['cod_fee']; if (!is_numeric($_POST['cod_fee'])) { $message = __('値が不正な項目があります', 'wc2'); } } if (isset($_POST['cod_limit_amount'])) { $payment_info['cod_limit_amount'] = (int) $_POST['cod_limit_amount']; if (!WC2_Utils::is_blank($_POST['cod_limit_amount']) && 0 === (int) $_POST['cod_limit_amount']) { $message = __('値が不正な項目があります', 'wc2'); } } } elseif ('change' == $payment_info['cod_type']) { if (isset($_POST['cod_first_amount'])) { $payment_info['cod_first_amount'] = (int) $_POST['cod_first_amount']; if (0 === (int) $_POST['cod_first_amount']) { $message = __('値が不正な項目があります', 'wc2'); } } if (isset($_POST['cod_limit_amount'])) { $payment_info['cod_limit_amount'] = (int) $_POST['cod_limit_amount']; if (!WC2_Utils::is_blank($_POST['cod_limit_amount']) && 0 === (int) $_POST['cod_limit_amount']) { $message = __('値が不正な項目があります', 'wc2'); } } if (isset($_POST['cod_first_fee'])) { $payment_info['cod_first_fee'] = (int) $_POST['cod_first_fee']; if (0 === (int) $_POST['cod_first_fee'] && '0' !== $_POST['cod_first_fee']) { $message = __('値が不正な項目があります', 'wc2'); } } if (isset($_POST['cod_end_fee'])) { $payment_info['cod_end_fee'] = (int) $_POST['cod_end_fee']; if (0 === (int) $_POST['cod_end_fee'] && '0' !== $_POST['cod_end_fee']) { $message = __('値が不正な項目があります', 'wc2'); } } unset($payment_info['cod_amounts'], $payment_info['cod_fees']); if (isset($_POST['cod_amounts'])) { for ($i = 0; $i < count((array) $_POST['cod_amounts']); $i++) { $payment_info['cod_amounts'][$i] = (int) $_POST['cod_amounts'][$i]; $payment_info['cod_fees'][$i] = (int) $_POST['cod_fees'][$i]; if (0 === (int) $_POST['cod_amounts'][$i] || 0 === (int) $_POST['cod_fees'][$i] && '0' !== $_POST['cod_fees'][$i]) { $message = __('値が不正な項目があります', 'wc2'); } } } } if ('' == $message) { $r = 'success'; wc2_update_option('payment_info', $payment_info); } else { $r = 'error' . WC2_SPLIT . $message; } $r = apply_filters('wc2_filter_admin_payment_setup_cod_ajax', $r); die($r); }
static function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true) { $locale_options = wc2_get_option('locale_options'); $system_options = wc2_get_option('system'); $cr = $system_options['currency']; list($code, $decimal, $point, $seperator, $symbol) = $locale_options['currency'][$cr]; if (!$seperator_flag) { $seperator = ''; } $price = number_format((double) $amount, $decimal, $point, $seperator); if ($symbol_pre) { $price = (WC2_Utils::is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol) . $price; } if ($symbol_post) { $price = $price . __($code, 'wc2'); } return $price; }
public function system_setting_page() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix != $screen->id) { return; } $system_options = wc2_get_option('system'); $states = wc2_get_option('states_options'); $locale = wc2_get_option('locale_options'); if (array_key_exists('wc2_option_update', $_POST)) { $this->action_status = 'success'; $_POST = WC2_Utils::stripslashes_deep_post($_POST); $system_options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0; $system_options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : ''; $system_options['composite_category_orderby'] = isset($_POST['composite_category_orderby']) ? $_POST['composite_category_orderby'] : ''; $system_options['composite_category_order'] = isset($_POST['composite_category_order']) ? $_POST['composite_category_order'] : ''; $system_options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : ''; if (WC2_Utils::is_blank($system_options['settlement_path'])) { $system_options['settlement_path'] = WC2_PLUGIN_DIR . '/settlement/'; } $sl = substr($system_options['settlement_path'], -1); if ($sl != '/' && $sl != '\\') { $system_options['settlement_path'] .= '/'; } $system_options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : ''; if (!WC2_Utils::is_blank($system_options['logs_path'])) { $sl = substr($system_options['logs_path'], -1); if ($sl == '/' || $sl == '\\') { $system_options['logs_path'] = substr($system_options['logs_path'], 0, -1); } } $system_options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0; $system_options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : ''; $system_options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : ''; if (WC2_Utils::is_blank($system_options['ssl_url']) || WC2_Utils::is_blank($system_options['ssl_url_admin'])) { $system_options['use_ssl'] = 0; } $system_options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : ''; $system_options['use_javascript'] = isset($_POST['use_javascript']) ? (int) $_POST['use_javascript'] : 1; $system_options['front_lang'] = isset($_POST['front_lang']) && 'others' != $_POST['front_lang'] ? $_POST['front_lang'] : wc2_get_local_language(); $system_options['currency'] = isset($_POST['currency']) && 'others' != $_POST['currency'] ? $_POST['currency'] : wc2_get_base_country(); $system_options['addressform'] = isset($_POST['addressform']) ? $_POST['addressform'] : wc2_get_local_addressform(); $system_options['target_market'] = isset($_POST['target_market']) ? $_POST['target_market'] : wc2_get_local_target_market(); $system_options['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0; $system_options['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int) $_POST['dec_orderID_flag'] : 0; $system_options['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : ''; $system_options['pdf_delivery'] = isset($_POST['pdf_delivery']) ? (int) $_POST['pdf_delivery'] : 0; $system_options['csv_encode_type'] = isset($_POST['csv_encode_type']) ? (int) $_POST['csv_encode_type'] : 0; if (isset($_POST['dec_orderID_digit'])) { $dec_orderID_digit = (int) rtrim($_POST['dec_orderID_digit']); if (6 > $dec_orderID_digit) { $system_options['dec_orderID_digit'] = 6; } else { $system_options['dec_orderID_digit'] = $dec_orderID_digit; } } else { $system_options['dec_orderID_digit'] = 6; } $system_options['subimage_rule'] = isset($_POST['subimage_rule']) ? (int) $_POST['subimage_rule'] : 0; unset($system_options['province']); foreach ((array) $system_options['target_market'] as $target_market) { $province = array(); if (!empty($_POST['province_' . $target_market])) { $temp_pref = explode("\n", $_POST['province_' . $target_market]); foreach ($temp_pref as $pref) { if (!WC2_Utils::is_blank($pref)) { $province[] = trim($pref); } } if (1 == count($province)) { $this->action_status = 'error'; } } else { if (isset($states[$target_market]) && is_array($states[$target_market])) { $province = $states[$target_market]; } else { $this->action_status = 'error'; } } $system_options['province'][$target_market] = $province; } if ($this->action_status != 'success') { $this->action_message = __('データに不備があります', 'wc2'); } else { wc2_update_option('system', $system_options); $this->action_message = __('Updated!'); } } else { if (!isset($system_options['province']) || empty($system_options['province'])) { $system_options['province'][$system_options['base_country']] = $states[$system_options['base_country']]; } $this->action_status = 'none'; $this->action_message = ''; } $status = $this->action_status; $message = $this->action_message; $divide_item = $system_options['divide_item']; $itemimg_anchor_rel = $system_options['itemimg_anchor_rel']; $composite_category_orderby = $system_options['composite_category_orderby']; $composite_category_order = $system_options['composite_category_order']; $logs_path = isset($system_options['logs_path']) ? $system_options['logs_path'] : ''; $use_ssl = $system_options['use_ssl']; $ssl_url = $system_options['ssl_url']; $ssl_url_admin = $system_options['ssl_url_admin']; $inquiry_id = $system_options['inquiry_id']; $orderby_itemsku = isset($system_options['orderby_itemsku']) ? $system_options['orderby_itemsku'] : 0; $orderby_itemopt = isset($system_options['orderby_itemopt']) ? $system_options['orderby_itemopt'] : 0; $system_front_lang = isset($system_options['front_lang']) && !empty($system_options['front_lang']) ? $system_options['front_lang'] : wc2_get_local_language(); $system_currency = isset($system_options['currency']) && !empty($system_options['currency']) ? $system_options['currency'] : wc2_get_base_country(); $system_addressform = isset($system_options['addressform']) && !empty($system_options['addressform']) ? $system_options['addressform'] : wc2_get_local_addressform(); $system_target_markets = isset($system_options['target_market']) && !empty($system_options['target_market']) ? $system_options['target_market'] : wc2_get_local_target_market(); $no_cart_css = isset($system_options['no_cart_css']) ? $system_options['no_cart_css'] : 0; $dec_orderID_flag = isset($system_options['dec_orderID_flag']) ? $system_options['dec_orderID_flag'] : 0; $dec_orderID_prefix = isset($system_options['dec_orderID_prefix']) ? $system_options['dec_orderID_prefix'] : ''; $dec_orderID_digit = isset($system_options['dec_orderID_digit']) ? $system_options['dec_orderID_digit'] : ''; $subimage_rule = isset($system_options['subimage_rule']) ? $system_options['subimage_rule'] : 0; $pdf_delivery = isset($system_options['pdf_delivery']) ? $system_options['pdf_delivery'] : 0; $csv_encode_type = isset($system_options['csv_encode_type']) ? $system_options['csv_encode_type'] : 0; require_once WC2_PLUGIN_DIR . '/admin/views/setting-system.php'; }
function order_edit_ajax() { //wc2_log(print_r($_POST,true),"test.log"); if ($_POST['action'] != 'order_edit_ajax') { die(0); } $res = false; $_POST = WC2_Utils::stripslashes_deep_post($_POST); switch ($_POST['mode']) { case 'add2cart': $slug = apply_filters('wc2_filter_cart_slug', 'cart'); $general_options = wc2_get_option('general'); $add_cart = array(); $item_id = isset($_POST['item_id']) ? $_POST['item_id'] : 0; $sku_id = isset($_POST['sku_id']) ? $_POST['sku_id'] : 0; $quantity = isset($_POST['quantity']) ? $_POST['quantity'] : 1; $cart_row = isset($_POST['cart_row']) ? $_POST['cart_row'] : 1; $item_sku_data = wc2_get_item_sku_data($item_id, $sku_id); $price = $item_sku_data['sku_price']; $price = apply_filters('wc2_filter_admin_order_add2cart_price', $price, $quantity, $item_id, $sku_id, $slug); if (empty($general_options['tax_rate'])) { $tax = 0; } else { $materials = array('total_price' => $price * $quantity, 'discount' => 0, 'shipping_charge' => 0, 'cod_fee' => 0); $tax = wc2_internal_tax($materials); } $add_cart['group_id'] = 0; $add_cart['row_index'] = $cart_row; $add_cart['post_id'] = $item_sku_data['item_post_id']; $add_cart['item_id'] = $item_id; $add_cart['item_code'] = $item_sku_data['item_code']; $add_cart['item_name'] = $item_sku_data['item_name']; $add_cart['sku_id'] = $sku_id; $add_cart['sku_code'] = $item_sku_data['sku_code']; $add_cart['sku_name'] = $item_sku_data['sku_name']; $add_cart['price'] = $price; $add_cart['cprice'] = $item_sku_data['sku_costprice']; $add_cart['quantity'] = $quantity; $add_cart['unit'] = $item_sku_data['sku_unit']; $add_cart['tax'] = $tax; $add_cart['destination_id'] = 0; $add_cart['meta_type'] = apply_filters('wc2_filter_admin_order_add2cart_meta_type', array(), $quantity, $item_id, $sku_id, $slug); $add_cart['meta_key'] = apply_filters('wc2_filter_admin_order_add2cart_meta_key', array(), $quantity, $item_id, $sku_id, $slug); $add_cart = apply_filters('wc2_filter_admin_order_add2cart', $add_cart, $slug); $res = wc2_add_order_cart_data($_POST['order_id'], $add_cart); if (!$res) { die($res); } $cart = wc2_get_order_cart_data($_POST['order_id']); //*** LI CUSTOMIZE >>> //$res = wc2_get_admin_order_cart_row( $_POST['order_id'], $cart ); $cart_row = wc2_get_admin_order_cart_row($_POST['order_id'], $cart); $order_history_form = li_get_order_history_form($_POST['order_id']); $res = 'OK' . WC2_SPLIT . $cart_row . WC2_SPLIT . $order_history_form; $shipping_charge = li_get_delivery_shipping_charge($_POST['delivery_method'], $_POST['delivery_pref'], $cart); $order_modified = wc2_get_today_datetime_format(); $update_query = " shipping_charge = " . $shipping_charge . ", order_modified = '" . $order_modified . "'"; wc2_update_order_data_value($_POST['order_id'], $update_query); //*** LI CUSTOMIZE <<< break; case 'cart_remove': $res = wc2_remove_order_cart_data($_POST['order_id'], $_POST['cart_id']); if (!$res) { die($res); } $cart = wc2_get_order_cart_data($_POST['order_id']); //*** LI CUSTOMIZE >>> //$res = wc2_get_admin_order_cart_row( $_POST['order_id'], $cart ); $cart_row = wc2_get_admin_order_cart_row($_POST['order_id'], $cart); $order_history_form = li_get_order_history_form($_POST['order_id']); $res = 'OK' . WC2_SPLIT . $cart_row . WC2_SPLIT . $order_history_form; $shipping_charge = li_get_delivery_shipping_charge($_POST['delivery_method'], $_POST['delivery_pref'], $cart); $order_modified = wc2_get_today_datetime_format(); $update_query = " shipping_charge = " . $shipping_charge . ", order_modified = '" . $order_modified . "'"; wc2_update_order_data_value($_POST['order_id'], $update_query); //*** LI CUSTOMIZE <<< break; case 'mail_completion': case 'mail_order': case 'mail_change': case 'mail_receipt': case 'mail_estimate': case 'mail_cancel': case 'mail_other': $res = wc2_ordermail_admin($_POST['order_id']); break; case 'sendmail': $res = wc2_send_ordermail_admin(); break; case 'get_add_item': $res = wc2_get_add_item($_POST['item_code']); break; case 'get_select_item': $res = wc2_get_select_item($_POST['cat_id']); break; case 'checkpost': $res = wc2_update_order_check($_POST['order_id'], $_POST['checked']); break; case 'get_member': $res = wc2_get_member_neworder($_POST['email']); break; case 'recalculation': $res = wc2_order_recalculation($_POST['order_id'], $_POST['member_id'], $_POST['item_ids'], $_POST['skus'], $_POST['prices'], $_POST['quantities'], $_POST['usedpoint'], $_POST['shipping_charge'], $_POST['cod_fee']); break; } $res = apply_filters('wc2_filter_admin_order_edit_ajax', $res); //wc2_log($res,"test.log"); die($res); }