getItemZaiko($post_id, $sku);
$zaiko_id = (int)$this->getItemZaikoStatusId($post_id, $sku_code);
$stock = $this->getItemZaikoNum($post_id, $sku_code);
if( !isset($stocks[$post_id][$sku]) ){
if( !WCUtils::is_blank($stock) ){
$stocks[$post_id][$sku] = $stock;
}else{
$stocks[$post_id][$sku] = NULL;
}
}
$checkstock = $stocks[$post_id][$sku];
$stocks[$post_id][$sku] = $stocks[$post_id][$sku] - $quant;
$itemRestriction = get_post_meta($post_id, '_itemRestriction', true);
//$red = (in_array($zaiko_status, array(__('Sold Out', 'usces'), __('Out Of Stock', 'usces'), __('Out of print', 'usces')))) ? 'red' : '';
if( 1 > (int)$quant ){
$mes .= sprintf(__("Enter the correct amount for the No.%d item.", 'usces'), ($i+1)) . "
";
}else if( 1 < $zaiko_id || WCUtils::is_zero($stock) ){
$mes .= sprintf(__('Sorry, No.%d item is sold out.', 'usces'), ($i+1)) . "
";
}else if( $quant > (int)$itemRestriction && !WCUtils::is_blank($itemRestriction) && !WCUtils::is_zero($itemRestriction) ){
$mes .= sprintf(__('This article is limited by %1$d at a time for the No.%2$d item.', 'usces'), $itemRestriction, ($i+1)) . "
";
}else if( 0 > $stocks[$post_id][$sku] && !WCUtils::is_blank($stock) ){
$mes .= sprintf(__('Stock of No.%1$d item is remainder %2$d.', 'usces'), ($i+1), $checkstock) . "
";
}
}
$mes = apply_filters('usces_filter_zaiko_check', $mes, $cart);
return $mes;
}
function member_check() {
$mes = '';
foreach ( $_POST['member'] as $key => $vlue ) {
$_SESSION['usces_member'][$key] = trim($vlue);
}
if ( $_POST['member_regmode'] == 'editmemberform' ) {
if ( (!WCUtils::is_blank($_POST['member']['password1']) || !WCUtils::is_blank($_POST['member']['password2']) ) && trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
$mes .= __('Password is not correct.', 'usces') . "
";
if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) )
$mes .= __('e-mail address is not correct', 'usces') . "
";
} else {
if ( WCUtils::is_blank($_POST['member']['password1']) || WCUtils::is_blank($_POST['member']['password2']) || trim($_POST['member']['password1']) != trim($_POST['member']['password2']) )
$mes .= __('Password is not correct.', 'usces') . "
";
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']) )
$mes .= __('e-mail address is not correct', 'usces') . "
";
}
if ( WCUtils::is_blank($_POST["member"]["name1"]) )
$mes .= __('Name is not correct', 'usces') . "
";//20111116ysk 0000299
// if ( trim($_POST["member"]["name3"]) == "" && USCES_JP )
// $mes .= __('Invalid CANNAT pretend.', 'usces') . "
";
if ( WCUtils::is_blank($_POST["member"]["zipcode"]) )
$mes .= __('postal code is not correct', 'usces') . "
";
if ( $_POST["member"]["pref"] == __('-- Select --', 'usces') )
$mes .= __('enter the prefecture', 'usces') . "
";
if ( WCUtils::is_blank($_POST["member"]["address1"]) )
$mes .= __('enter the city name', 'usces') . "
";
if ( WCUtils::is_blank($_POST["member"]["address2"]) )
$mes .= __('enter house numbers', 'usces') . "
";
if ( WCUtils::is_blank($_POST["member"]["tel"]) )
$mes .= __('enter phone numbers', 'usces') . "
";
if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
$mes .= __('Please input a phone number with a half size number.', 'usces') . "
";
$mes = apply_filters('usces_filter_member_check', $mes);
return $mes;
}
function member_check_fromcart() {
$mes = '';
if ( WCUtils::is_blank($_POST['customer']['password1']) || WCUtils::is_blank($_POST['customer']['password2']) || trim($_POST['customer']['password1']) != trim($_POST['customer']['password2']) )
$mes .= __('Password is not correct.', 'usces') . "
";
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']) )
$mes .= __('e-mail address is not correct', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
$mes .= __('Name is not correct', 'usces') . "
";//20111116ysk 0000299
// if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
// $mes .= __('Invalid CANNAT pretend.', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
$mes .= __('postal code is not correct', 'usces') . "
";
if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
$mes .= __('enter the prefecture', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
$mes .= __('enter the city name', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
$mes .= __('enter house numbers', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
$mes .= __('enter phone numbers', 'usces') . "
";
if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
$mes .= __('Please input a phone number with a half size number.', 'usces') . "
";
$mes = apply_filters('usces_filter_member_check_fromcart', $mes);
return $mes;
}
function admin_member_check() {
global $wpdb;
$mes = '';
if ( !is_email( trim($_POST['member']["email"]) ) ){
$mes .= __('e-mail address is not correct', 'usces') . "
";
}else{
$member_table = $wpdb->prefix . "usces_member";
$mem_email = $wpdb->get_var( $wpdb->prepare("SELECT mem_email FROM $member_table WHERE ID = %d LIMIT 1", trim($_POST['member_id'])) );
if( trim($_POST['member']["email"]) != $mem_email ){
$mem_ID = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s LIMIT 1", trim($_POST['member']["email"])) );
if( !empty($mem_ID) )
$mes .= __('This e-mail address has been already registered.', 'usces') . "
";
}
}
if ( WCUtils::is_blank($_POST['member']["name1"]) )
$mes .= __('Name is not correct', 'usces') . "
";
// if ( trim($_POST["mem_name3"]) == "" && USCES_JP )
// $mes .= __('Invalid CANNAT pretend.', 'usces') . "
";
// if ( trim($_POST['member']["zipcode"]) == "" )
// $mes .= __('postal code is not correct', 'usces') . "
";
// if ( $_POST['member']["pref"] == __('-- Select --', 'usces') )
// $mes .= __('enter the prefecture', 'usces') . "
";
// if ( trim($_POST['member']["address1"]) == "" )
// $mes .= __('enter the city name', 'usces') . "
";
// if ( trim($_POST['member']["address2"]) == "" )
// $mes .= __('enter house numbers', 'usces') . "
";
// if ( trim($_POST['member']["tel"]) == "" )
// $mes .= __('enter phone numbers', 'usces') . "
";
if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d-]/", trim($_POST["member"]["tel"])) )
$mes .= __('Please input a phone number with a half size number.', 'usces') . "
";
$mes = apply_filters('usces_filter_admin_member_check', $mes);
return $mes;
}
function customer_check() {
$mes = '';
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']) )
$mes .= __('e-mail address is not correct', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["name1"]) )
$mes .= __('Name is not correct', 'usces') . "
";//20111116ysk 0000299
// if ( trim($_POST["customer"]["name3"]) == "" && USCES_JP )
// $mes .= __('Invalid CANNAT pretend.', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["zipcode"]) )
$mes .= __('postal code is not correct', 'usces') . "
";
if ( $_POST["customer"]["pref"] == __('-- Select --', 'usces') )
$mes .= __('enter the prefecture', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["address1"]) )
$mes .= __('enter the city name', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["address2"]) )
$mes .= __('enter house numbers', 'usces') . "
";
if ( WCUtils::is_blank($_POST["customer"]["tel"]) )
$mes .= __('enter phone numbers', 'usces') . "
";
if( !WCUtils::is_blank($_POST['customer']["tel"]) && preg_match("/[^\d-]/", trim($_POST["customer"]["tel"])) )
$mes .= __('Please input a phone number with a half size number.', 'usces') . "
";
$mes = apply_filters('usces_filter_customer_check', $mes);
return $mes;
}
function delivery_check() {
$mes = '';
if ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
if ( WCUtils::is_blank($_POST["delivery"]["name1"]) )
$mes .= __('Name is not correct', 'usces') . "
";//20111116ysk 0000299
// if ( trim($_POST["delivery"]["name3"]) == "" && USCES_JP )
// $mes .= __('Invalid CANNAT pretend.', 'usces') . "
";
if ( WCUtils::is_blank($_POST["delivery"]["zipcode"]) )
$mes .= __('postal code is not correct', 'usces') . "
";
if ( $_POST["delivery"]["pref"] == __('-- Select --', 'usces') )
$mes .= __('enter the prefecture', 'usces') . "
";
if ( WCUtils::is_blank($_POST["delivery"]["address1"]) )
$mes .= __('enter the city name', 'usces') . "
";
if ( WCUtils::is_blank($_POST["delivery"]["address2"]) )
$mes .= __('enter house numbers', 'usces') . "
";
if ( WCUtils::is_blank($_POST["delivery"]["tel"]) )
$mes .= __('enter phone numbers', 'usces') . "
";
}
if ( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WCUtils::is_zero($_POST['offer']['delivery_method'])) )
$mes .= __('chose one from delivery method.', 'usces') . "
";
if ( !isset($_POST['offer']['payment_name']) ){
$mes .= __('chose one from payment options.', 'usces') . "
";
}else{
$payments = $this->getPayments($_POST['offer']['payment_name']);
if('COD' == $payments['settlement']){
$total_items_price = $this->get_total_price();
$tax = $this->getTax( $total_items_price );
$total_items_price = $total_items_price + $tax;
$cod_limit_amount = ( isset($this->options['cod_limit_amount']) && 0 < (int)$this->options['cod_limit_amount'] ) ? $this->options['cod_limit_amount'] : 0;
if( 0 < $cod_limit_amount && $total_items_price > $cod_limit_amount )
$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')) . "
";
}
}
//20101119ysk start
if(isset($_POST['offer']['delivery_method']) and isset($_POST['offer']['payment_name'])) {
$d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
if($this->options['delivery_method'][$d_method_index]['nocod'] == 1) {
$payments = $this->getPayments($_POST['offer']['payment_name']);
if('COD' == $payments['settlement'])
$mes .= __('COD is not available.', 'usces') . "
";
}
}
//20101119ysk end
//20110317ysk start
if(isset($_POST['offer']['delivery_method'])) {
$d_method_index = $this->get_delivery_method_index((int)$_POST['offer']['delivery_method']);
$country = $_SESSION['usces_entry']["delivery"]["country"];
$local_country = usces_get_base_country();
if($country == $local_country) {
if($this->options['delivery_method'][$d_method_index]['intl'] == 1) {
$mes .= __('配送方法が誤っています。国際便は指定できません。', 'usces') . "
";
}
} else {
if( WCUtils::is_zero($this->options['delivery_method'][$d_method_index]['intl']) ) {
$mes .= __('配送方法が誤っています。国際便を指定してください。', 'usces') . "
";
}
}
}
//20110317ysk end
$mes = apply_filters('usces_filter_delivery_check', $mes);
return $mes;
}
function point_check( $entries ) {
$member = $this->get_member();
$this->set_cart_fees( $member, $entries );
$mes = '';
if( isset($_POST['offer']["usedpoint"]) ) {
if ( WCUtils::is_blank($_POST['offer']["usedpoint"]) || !preg_match("/^[0-9]+$/", $_POST['offer']["usedpoint"]) || (int)$_POST['offer']["usedpoint"] < 0 ) {
$mes .= __('Invalid value. Please enter in the numbers.', 'usces') . "
";
} else {
/* if ( trim($_POST['offer']["usedpoint"]) > $member['point'] ){
$mes .= __('You have exceeded the maximum available.', 'usces') . "max".$member['point']."pt
";
$_POST['offer']["usedpoint"] = 0;
$array = array(
'usedpoint' => 0
);
$this->cart->set_order_entry( $array );
}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'])){
$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
";
$_POST['offer']["usedpoint"] = 0;
$array = array(
'usedpoint' => 0
);
$this->cart->set_order_entry( $array );
}elseif(!$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount'])){
$mes .= __('You have exceeded the maximum available.', 'usces') . "max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt
";
$_POST['offer']["usedpoint"] = 0;
$array = array(
'usedpoint' => 0
);
$this->cart->set_order_entry( $array );
}
*/ if( trim($_POST['offer']["usedpoint"]) > $member['point'] ) {
$mes .= __('You have exceeded the maximum available.', 'usces')."max".$member['point']."pt
";
} 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']) ) {
$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
";
} elseif( !$this->options['point_coverage'] && trim($_POST['offer']["usedpoint"]) > ($entries['order']['total_items_price'] + $entries['order']['discount']) ) {
$mes .= __('You have exceeded the maximum available.', 'usces')."max".($entries['order']['total_items_price'] + $entries['order']['discount'])."pt
";
}
$mes = apply_filters( 'usces_filter_point_check', $mes );
if( '' != $mes ) {
$_POST['offer']["usedpoint"] = 0;
$array = array(
'usedpoint' => 0
);
$this->cart->set_order_entry( $array );
}
}
}
return $mes;
}
function lostpass_mailaddcheck() {
$mes = '';
if ( !is_email($_POST['loginmail']) || WCUtils::is_blank($_POST['loginmail']) ) {
$mes .= __('e-mail address is not correct', 'usces') . "
";
}elseif( !$this->is_member($_POST['loginmail']) ){
$mes .= __('It is the e-mail address that there is not.', 'usces') . "
";
}
return $mes;
}
function changepass_check() {
$mes = '';
if ( WCUtils::is_blank($_POST['loginpass1']) || WCUtils::is_blank($_POST['loginpass2']) || (trim($_POST['loginpass1']) != trim($_POST['loginpass2'])))
$mes .= __('Password is not correct.', 'usces') . "
";
return $mes;
}
function get_page() {
return $this->page;
}
function check_display_mode() {
$options = get_option('usces');
if( isset($options['display_mode']) && $options['display_mode'] == 'Maintenancemode' ) return;
$start['hour'] = empty($options['campaign_schedule']['start']['hour']) ? 0 : $options['campaign_schedule']['start']['hour'];
$start['min'] = empty($options['campaign_schedule']['start']['min']) ? 0 : $options['campaign_schedule']['start']['min'];
$start['month'] = empty($options['campaign_schedule']['start']['month']) ? 0 : $options['campaign_schedule']['start']['month'];
$start['day'] = empty($options['campaign_schedule']['start']['day']) ? 0 : $options['campaign_schedule']['start']['day'];
$start['year'] = empty($options['campaign_schedule']['start']['year']) ? 0 : $options['campaign_schedule']['start']['year'];
$end['hour'] = empty($options['campaign_schedule']['end']['hour']) ? 0 : $options['campaign_schedule']['end']['hour'];
$end['min'] = empty($options['campaign_schedule']['end']['min']) ? 0 : $options['campaign_schedule']['end']['min'];
$end['month'] = empty($options['campaign_schedule']['end']['month']) ? 0 : $options['campaign_schedule']['end']['month'];
$end['day'] = empty($options['campaign_schedule']['end']['day']) ? 0 : $options['campaign_schedule']['end']['day'];
$end['year'] = empty($options['campaign_schedule']['end']['year']) ? 0 : $options['campaign_schedule']['end']['year'];
$starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
$endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
$current_time = current_time('timestamp');
if( ($current_time >= $starttime) && ($current_time <= $endtime) )
$options['display_mode'] = 'Promotionsale';
else
$options['display_mode'] = 'Usualsale';
update_option('usces', $options);
}
function update_business_days() {
$options = get_option('usces');
$datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
$dhour = (int)substr($datetimestr, 11, 2);
$dminute = (int)substr($datetimestr, 14, 2);
$dsecond = (int)substr($datetimestr, 17, 2);
$dmonth = (int)substr($datetimestr, 5, 2);
$dday = (int)substr($datetimestr, 8, 2);
$dyear = (int)substr($datetimestr, 0, 4);
$dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear);
$datenow = getdate($dtimestamp);
//list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1);
list($year, $mon, $mday) = getBeforeMonth($datenow['year'], $datenow['mon'], 1, 1);
if(isset($options['business_days'][$year][$mon][1]))
unset($options['business_days'][$year][$mon]);
for($i=0; $i<3; $i++){
//list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i);
list($year, $mon, $mday) = getAfterMonth($datenow['year'], $datenow['mon'], 1, $i);
$last = getLastDay($year, $mon);
for($j=1; $j<=$last; $j++){
if(!isset($options['business_days'][$year][$mon][$j]))
$options['business_days'][$year][$mon][$j] = 1;
}
}
update_option('usces', $options);
$_SESSION['usces_checked_business_days'] = '';
}
function display_cart() {
if($this->cart->num_row() > 0) {
include (USCES_PLUGIN_DIR . '/includes/cart_table.php');
} else {
echo "" . __('There are no items in your cart.', 'usces') . "
\n";
}
}
function display_cart_confirm() {
if($this->cart->num_row() > 0) {
include (USCES_PLUGIN_DIR . '/includes/cart_confirm.php');
} else {
echo "" . __('There are no items in your cart.', 'usces') . "
\n";
}
}
function set_initial() {
usces_log('set_initial : OK', 'database_error.log');
$rets07 = usces_upgrade_07();
$rets11 = usces_upgrade_11();
usces_log('rets11 : ' . print_r($rets11,true), 'database_error.log');
$this->set_default_theme();
$this->set_default_page();
$this->set_default_categories();
$this->create_table();
$this->update_table();
$this->update_options();//20120710ysk 0000472
}
function create_table() {
global $wpdb;
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
$access_table = $wpdb->prefix . "usces_access";
$member_table = $wpdb->prefix . "usces_member";
$member_meta_table = $wpdb->prefix . "usces_member_meta";
$order_table = $wpdb->prefix . "usces_order";
$order_meta_table = $wpdb->prefix . "usces_order_meta";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
$sql = "CREATE TABLE " . $access_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
acc_key VARCHAR( 50 ) NOT NULL ,
acc_type VARCHAR( 50 ) NULL ,
acc_value LONGTEXT NULL ,
acc_date DATE NOT NULL DEFAULT '0000-00-00',
acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
acc_str1 VARCHAR( 200 ) NULL ,
acc_str2 VARCHAR( 200 ) NULL ,
KEY acc_key ( acc_key ),
KEY acc_type ( acc_type ),
KEY acc_date ( acc_date ),
KEY acc_num1 ( acc_num1 ),
KEY acc_num2 ( acc_num2 )
) ENGINE = MYISAM AUTO_INCREMENT=0 $charset_collate;";
dbDelta($sql);
add_option("usces_db_access", USCES_DB_ACCESS);
}
if($wpdb->get_var("show tables like '$member_table'") != $member_table) {
$sql = "CREATE TABLE " . $member_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
mem_email VARCHAR( 100 ) NOT NULL ,
mem_pass VARCHAR( 64 ) NOT NULL ,
mem_status INT( 11 ) NOT NULL DEFAULT '0',
mem_cookie VARCHAR( 13 ) NULL ,
mem_point INT( 11 ) NOT NULL DEFAULT '0',
mem_name1 VARCHAR( 100 ) NOT NULL ,
mem_name2 VARCHAR( 100 ) NULL ,
mem_name3 VARCHAR( 100 ) NULL ,
mem_name4 VARCHAR( 100 ) NULL ,
mem_zip VARCHAR( 50 ) NULL ,
mem_pref VARCHAR( 100 ) NOT NULL ,
mem_address1 VARCHAR( 100 ) NOT NULL ,
mem_address2 VARCHAR( 100 ) NULL ,
mem_address3 VARCHAR( 100 ) NULL ,
mem_tel VARCHAR( 100 ) NOT NULL ,
mem_fax VARCHAR( 100 ) NULL ,
mem_delivery_flag TINYINT ( 1 ) NULL ,
mem_delivery LONGTEXT,
mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
mem_nicename VARCHAR( 50 ) NULL ,
KEY mem_email ( mem_email ) ,
KEY mem_pass ( mem_pass )
) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
dbDelta($sql);
add_option("usces_db_member", USCES_DB_MEMBER);
}
if($wpdb->get_var("show tables like '$member_meta_table'") != $member_meta_table) {
$sql = "CREATE TABLE " . $member_meta_table . " (
mmeta_id bigint(20) NOT NULL auto_increment,
member_id bigint(20) NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (mmeta_id),
KEY order_id (member_id),
KEY meta_key (meta_key)
) ENGINE = MYISAM $charset_collate;";
dbDelta($sql);
add_option("usces_db_member_meta", USCES_DB_MEMBER_META);
}
if($wpdb->get_var("show tables like '$order_table'") != $order_table) {
$sql = "CREATE TABLE " . $order_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
mem_id BIGINT( 20 ) UNSIGNED NULL ,
order_email VARCHAR( 100 ) NOT NULL ,
order_name1 VARCHAR( 100 ) NOT NULL ,
order_name2 VARCHAR( 100 ) NULL ,
order_name3 VARCHAR( 100 ) NULL ,
order_name4 VARCHAR( 100 ) NULL ,
order_zip VARCHAR( 50 ) NULL ,
order_pref VARCHAR( 100 ) NOT NULL ,
order_address1 VARCHAR( 100 ) NOT NULL ,
order_address2 VARCHAR( 100 ) NULL ,
order_address3 VARCHAR( 100 ) NULL ,
order_tel VARCHAR( 100 ) NOT NULL ,
order_fax VARCHAR( 100 ) NULL ,
order_delivery LONGTEXT,
order_cart LONGTEXT,
order_note TEXT,
order_delivery_time VARCHAR( 100 ) NOT NULL ,
order_payment_name VARCHAR( 100 ) NOT NULL ,
order_condition TEXT,
order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
order_modified VARCHAR( 20 ) NULL ,
order_status VARCHAR( 255 ) NULL ,
order_check VARCHAR( 255 ) NULL ,
order_delidue_date VARCHAR( 30 ) NULL ,
order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
order_delivery_date VARCHAR( 100 ) NULL,
KEY order_email ( order_email ) ,
KEY order_name1 ( order_name1 ) ,
KEY order_name2 ( order_name2 ) ,
KEY order_pref ( order_pref ) ,
KEY order_address1 ( order_address1 ) ,
KEY order_tel ( order_tel ) ,
KEY order_date ( order_date )
) ENGINE = MYISAM AUTO_INCREMENT=1000 $charset_collate;";
dbDelta($sql);
add_option("usces_db_order", USCES_DB_ORDER);
}
if($wpdb->get_var("show tables like '$order_meta_table'") != $order_meta_table) {
$sql = "CREATE TABLE " . $order_meta_table . " (
ometa_id bigint(20) NOT NULL auto_increment,
order_id bigint(20) NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (ometa_id),
KEY order_id (order_id),
KEY meta_key (meta_key)
) ENGINE = MYISAM $charset_collate;";
dbDelta($sql);
add_option("usces_db_order_meta", USCES_DB_ORDER_META);
}
}
function update_table()
{
global $wpdb;
$access_table = $wpdb->prefix . "usces_access";
$member_table = $wpdb->prefix . "usces_member";
$member_meta_table = $wpdb->prefix . "usces_member_meta";
$order_table = $wpdb->prefix . "usces_order";
$order_meta_table = $wpdb->prefix . "usces_order_meta";
$access_ver = get_option( "usces_db_access" );
$member_ver = get_option( "usces_db_member" );
$member_meta_ver = get_option( "usces_db_member_meta" );
$order_ver = get_option( "usces_db_order" );
$order_meta_ver = get_option( "usces_db_order_meta" );
if( $access_ver != USCES_DB_ACCESS ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE " . $access_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
acc_key VARCHAR( 50 ) NOT NULL ,
acc_type VARCHAR( 50 ) NULL ,
acc_value LONGTEXT NULL ,
acc_date DATE NOT NULL DEFAULT '0000-00-00',
acc_num1 INT( 11 ) NOT NULL DEFAULT 0,
acc_num2 INT( 11 ) NOT NULL DEFAULT 0,
acc_str1 VARCHAR( 200 ) NULL ,
acc_str2 VARCHAR( 200 ) NULL ,
KEY acc_key ( acc_key ),
KEY acc_type ( acc_type ),
KEY acc_date ( acc_date ),
KEY acc_num1 ( acc_num1 ),
KEY acc_num2 ( acc_num2 )
) ENGINE = MYISAM;";
dbDelta($sql);
update_option( "usces_db_access", USCES_DB_ACCESS );
}
if( $member_ver != USCES_DB_MEMBER ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE " . $member_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
mem_email VARCHAR( 100 ) NOT NULL ,
mem_pass VARCHAR( 64 ) NOT NULL ,
mem_status INT( 11 ) NOT NULL DEFAULT '0',
mem_cookie VARCHAR( 13 ) NULL ,
mem_point INT( 11 ) NOT NULL DEFAULT '0',
mem_name1 VARCHAR( 100 ) NOT NULL ,
mem_name2 VARCHAR( 100 ) NULL ,
mem_name3 VARCHAR( 100 ) NULL ,
mem_name4 VARCHAR( 100 ) NULL ,
mem_zip VARCHAR( 50 ) NULL ,
mem_pref VARCHAR( 100 ) NOT NULL ,
mem_address1 VARCHAR( 100 ) NOT NULL ,
mem_address2 VARCHAR( 100 ) NULL ,
mem_address3 VARCHAR( 100 ) NULL ,
mem_tel VARCHAR( 100 ) NOT NULL ,
mem_fax VARCHAR( 100 ) NULL ,
mem_delivery_flag TINYINT ( 1 ) NULL ,
mem_delivery LONGTEXT,
mem_registered DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
mem_nicename VARCHAR( 50 ) NULL ,
KEY mem_email ( mem_email ) ,
KEY mem_pass ( mem_pass )
) ENGINE = MYISAM;";
dbDelta($sql);
update_option( "usces_db_member", USCES_DB_MEMBER );
}
if( $member_meta_ver != USCES_DB_MEMBER_META ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE " . $member_meta_table . " (
mmeta_id bigint(20) NOT NULL auto_increment,
member_id bigint(20) NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (mmeta_id),
KEY order_id (member_id),
KEY meta_key (meta_key)
) ENGINE = MYISAM;";
dbDelta($sql);
update_option("usces_db_member_meta", USCES_DB_MEMBER_META);
}
if( $order_ver != USCES_DB_ORDER ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE " . $order_table . " (
ID BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
mem_id BIGINT( 20 ) UNSIGNED NULL ,
order_email VARCHAR( 100 ) NOT NULL ,
order_name1 VARCHAR( 100 ) NOT NULL ,
order_name2 VARCHAR( 100 ) NULL ,
order_name3 VARCHAR( 100 ) NULL ,
order_name4 VARCHAR( 100 ) NULL ,
order_zip VARCHAR( 50 ) NULL ,
order_pref VARCHAR( 100 ) NOT NULL ,
order_address1 VARCHAR( 100 ) NOT NULL ,
order_address2 VARCHAR( 100 ) NULL ,
order_address3 VARCHAR( 100 ) NULL ,
order_tel VARCHAR( 100 ) NOT NULL ,
order_fax VARCHAR( 100 ) NULL ,
order_delivery LONGTEXT,
order_cart LONGTEXT,
order_note TEXT,
order_delivery_time VARCHAR( 100 ) NOT NULL ,
order_payment_name VARCHAR( 100 ) NOT NULL ,
order_condition TEXT,
order_item_total_price DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_getpoint INT( 10 ) NOT NULL DEFAULT '0',
order_usedpoint INT( 10 ) NOT NULL DEFAULT '0',
order_discount DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_shipping_charge DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_cod_fee DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_tax DECIMAL( 10, 2 ) NOT NULL DEFAULT '0.00',
order_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
order_modified VARCHAR( 20 ) NULL ,
order_status VARCHAR( 255 ) NULL ,
order_check VARCHAR( 255 ) NULL ,
order_delidue_date VARCHAR( 30 ) NULL ,
order_delivery_method INT( 10 ) NOT NULL DEFAULT -1,
order_delivery_date VARCHAR( 100 ) NULL,
KEY order_email ( order_email ) ,
KEY order_name1 ( order_name1 ) ,
KEY order_name2 ( order_name2 ) ,
KEY order_pref ( order_pref ) ,
KEY order_address1 ( order_address1 ) ,
KEY order_tel ( order_tel ) ,
KEY order_date ( order_date )
) ENGINE = MYISAM;";
dbDelta($sql);
update_option("usces_db_order", USCES_DB_ORDER);
}
if( $order_meta_ver != USCES_DB_ORDER_META ) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$sql = "CREATE TABLE " . $order_meta_table . " (
ometa_id bigint(20) NOT NULL auto_increment,
order_id bigint(20) NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (ometa_id),
KEY order_id (order_id),
KEY meta_key (meta_key)
) ENGINE = MYISAM;";
dbDelta($sql);
update_option("usces_db_order_meta", USCES_DB_ORDER_META);
}
}
function set_default_theme()
{
$themepath = USCES_WP_CONTENT_DIR.'/themes/welcart_default';
$resourcepath = USCES_WP_CONTENT_DIR.'/plugins/usc-e-shop/theme/welcart_default';
if( file_exists($themepath) ) return false;
if(!file_exists($resourcepath) ) return false;
mkdir($themepath, 0775);
$this->dir_copy($resourcepath, $themepath);
}
function dir_copy($source, $dest){
if ($res = opendir($source)) {
while (($file = readdir($res)) !== false) {
$sorce_path = $source . '/' . $file;
$dest_path = $dest . '/' . $file;
$filetype = @filetype($sorce_path);
if( $filetype == 'file' ) {
copy($sorce_path, $dest_path);
}elseif( $filetype == 'dir' && $file != '..' && $file != '.' ){
mkdir($dest_path);
$this->dir_copy($sorce_path, $dest_path);
}
}
closedir($res);
}
}
function set_default_page()
{
global $wpdb;
$datetime = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
$datetime_gmt = gmdate('Y-m-d H:i:s', time());
//cart_page
$query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_CART_FOLDER);
$cart_number = $wpdb->get_var( $query );
if( $cart_number === NULL ) {
$query = $wpdb->prepare("INSERT INTO $wpdb->posts
(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
VALUES (%d, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s,
%s, %d, %s, %d, %s, %s, %d)",
1, $datetime, $datetime_gmt, '', __('Cart', 'usces'), '', 'publish',
'closed', 'closed', '', USCES_CART_FOLDER, '', '', $datetime, $datetime_gmt,
'', 0, '', 0, 'page', '', 0);
$wpdb->query($query);
$cart_number = $wpdb->insert_id;
if( $cart_number !== NULL ) {
$query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
$cart_number, '_wp_page_template', 'uscescart.php');
$wpdb->query($query);
}
}
update_option('usces_cart_number', $cart_number);
//member_page
$query = $wpdb->prepare("SELECT ID from $wpdb->posts where post_name = %s", USCES_MEMBER_FOLDER);
$member_number = $wpdb->get_var( $query );
if( $member_number === NULL ) {
$query = $wpdb->prepare("INSERT INTO $wpdb->posts
(post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status,
comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt,
post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count)
VALUES (%d, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s,
%s, %d, %s, %d, %s, %s, %d)",
1, $datetime, $datetime_gmt, '', __('Membership', 'usces'), '', 'publish',
'closed', 'closed', '', USCES_MEMBER_FOLDER, '', '', $datetime, $datetime_gmt,
'', 0, '', 0, 'page', '', 0);
$wpdb->query($query);
$member_number = $wpdb->insert_id;
if( $member_number !== NULL ) {
$query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES (%d, %s, %s)",
$member_number, '_wp_page_template', 'uscesmember.php');
$wpdb->query($query);
}
}
update_option('usces_member_number', $member_number);
}
function set_default_categories()
{
global $wpdb;
$idObj = get_category_by_slug('item');
if( empty($idObj) ) {
$item_cat = array('cat_name' => __('Items', 'usces'), 'category_description' => '', 'category_nicename' => 'item', 'category_parent' => 0);
$item_cat_id = wp_insert_category($item_cat);
update_option('usces_item_cat_parent_id', $item_cat_id);
}
$idObj = get_category_by_slug('itemreco');
if( empty($idObj) && isset($item_cat_id) ) {
$itemreco_cat = array('cat_name' => __('Items recommended', 'usces'), 'category_description' => '', 'category_nicename' => 'itemreco', 'category_parent' => $item_cat_id);
$itemreco_cat_id = wp_insert_category($itemreco_cat);
}
$idObj = get_category_by_slug('itemnew');
if( empty($idObj) && isset($item_cat_id) ) {
$itemnew_cat = array('cat_name' => __('New items', 'usces'), 'category_description' => '', 'category_nicename' => 'itemnew', 'category_parent' => $item_cat_id);
$itemnew_cat_id = wp_insert_category($itemnew_cat);
}
$idObj = get_category_by_slug('itemgenre');
if( empty($idObj) && isset($item_cat_id) ) {
$itemgenre_cat = array('cat_name' => __('Item genre', 'usces'), 'category_description' => '', 'category_nicename' => 'itemgenre', 'category_parent' => $item_cat_id);
$itemgenre_cat_id = wp_insert_category($itemgenre_cat);
}
}
//20120710ysk start 0000472
function update_options() {
$target_market = $this->options['system']['target_market'];
$update_shipping_charge = false;
$shipping_charge = isset($this->options['shipping_charge']) ? $this->options['shipping_charge'] : array();
foreach( (array)$target_market as $tm ) {
for( $i = 0; $i < count($shipping_charge); $i++ ) {
if( isset($shipping_charge[$i]['country']) and $shipping_charge[$i]['country'] == $tm ) {
foreach( $shipping_charge[$i]['value'] as $pref => $value ) {
$shipping_charge[$i][$tm][$pref] = $value;
}
unset($shipping_charge[$i]['country']);
unset($shipping_charge[$i]['value']);
$update_shipping_charge = true;
}
}
}
if( $update_shipping_charge ) $this->options['shipping_charge'] = $shipping_charge;
$update_delivery_days = false;
$delivery_days = isset($this->options['delivery_days']) ? $this->options['delivery_days'] : array();
foreach( (array)$target_market as $tm ) {
for( $i = 0; $i < count($delivery_days); $i++ ) {
if( isset($delivery_days[$i]['country']) and $delivery_days[$i]['country'] == $tm ) {
foreach( $delivery_days[$i]['value'] as $pref => $value ) {
$delivery_days[$i][$tm][$pref] = $value;
}
unset($delivery_days[$i]['country']);
unset($delivery_days[$i]['value']);
$update_delivery_days = true;
}
}
}
if( $update_delivery_days ) $this->options['delivery_days'] = $delivery_days;
if( $update_shipping_charge or $update_delivery_days )
update_option('usces', $this->options);
}
//20120710ysk end
function get_item_cat_ids(){
$args = array('child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0, 'hierarchical' => 0);
$categories = get_categories( $args );
foreach($categories as $category){
$ids[] = $category->term_id;
}
return $ids;
}
function get_item_post_ids(){
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
$ids = $wpdb->get_col( $query );
return $ids;
}
function get_item_cat_genre_ids( $post_id ){
$ids = array();
$all_ids = array();
$genre = get_category_by_slug( 'itemgenre' );
$genre_id = $genre->term_id;
$args = array('child_of' => $genre_id, 'hide_empty' => 0, 'hierarchical' => 0);
$categories = get_categories( $args );
foreach($categories as $category){
$ids[] = $category->term_id;
}
$allcats = get_the_category( $post_id );
foreach($allcats as $cat){
$all_ids[] = $cat->term_id;
}
//$all_ids =
$results = array_intersect($ids, $all_ids);
return $results;
}
function set_item_mime($post_id, $str)
{
global $wpdb;
if( WCUtils::is_blank($str) ) return;
$query = $wpdb->prepare("UPDATE $wpdb->posts SET post_mime_type = %s WHERE ID = %s", $str, $post_id);
$results = $wpdb->query( $query );
return $results;
}
function isAdnminSSL()
{
$plugins = get_option('active_plugins');
foreach($plugins as $plugin) {
if( false !== strpos($plugin, USCES_ADMIN_SSL_BASE_NAME) )
return true;
}
return false;
}
function getGuidTax() {
$tax_rate = (int)$this->options['tax_rate'];
if ( 0 < $tax_rate )
$str = ''.__('(Excl. Tax)', 'usces').'';
else
$str = ''.__('(Incl. Tax)', 'usces').'';
return apply_filters('usces_filter_tax_guid', $str, $tax_rate);
}
function getItemCode($post_id) {
$str = get_post_meta($post_id, '_itemCode', true);
return $str;
}
function getItemName($post_id) {
$str = get_post_meta($post_id, '_itemName', true);
return $str;
}
function getItemRestriction($post_id) {
$str = get_post_meta($post_id, '_itemRestriction', true);
return $str;
}
function getItemPointrate($post_id) {
$str = get_post_meta($post_id, '_itemPointrate', true);
return $str;
}
function getItemShipping($post_id) {
$str = get_post_meta($post_id, '_itemShipping', true);
return $str;
}
function getItemShippingCharge($post_id) {
$str = get_post_meta($post_id, '_itemShippingCharge', true);
return (float)$str;
}
function getItemDeliveryMethod($post_id) {
$str = get_post_meta($post_id, '_itemDeliveryMethod', true);
if( empty($str) )
return array();
else
return $str;
}
function getItemIndividualSCharge($post_id) {
$str = get_post_meta($post_id, '_itemIndividualSCharge', true);
return $str;
}
function getItemGpNum1($post_id) {
$str = get_post_meta($post_id, '_itemGpNum1', true);
return $str;
}
function getItemGpNum2($post_id) {
$str = get_post_meta($post_id, '_itemGpNum2', true);
return $str;
}
function getItemGpNum3($post_id) {
$str = get_post_meta($post_id, '_itemGpNum3', true);
return $str;
}
function getItemGpDis1($post_id) {
$str = get_post_meta($post_id, '_itemGpDis1', true);
return $str;
}
function getItemGpDis2($post_id) {
$str = get_post_meta($post_id, '_itemGpDis2', true);
return $str;
}
function getItemGpDis3($post_id) {
$str = get_post_meta($post_id, '_itemGpDis3', true);
return $str;
}
function getItemSku($post_id, $index = '') {
$array = array();
$skus = $this->get_skus($post_id, 'sort');
foreach((array)$skus as $sku){
$array[] = $sku['code'];
}
if(!$array) return false;
if($index == ''){
return $array;
}else if(isset($array[$index])){
return $array[$index];
}else{
return false;
}
}
function getItemPrice($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$array[$key] = (float)str_replace('.', '', $sku['price']);
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function getItemDiscount($post_id, $skukey = '') {
$display_mode = $this->options['display_mode'];
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$price = (float)str_replace(',', '', $sku['price']);
if ( $display_mode == 'Promotionsale' ) {
if ( $this->options['campaign_privilege'] == 'discount' ){
if( 0 === (int)$this->options['campaign_category'] || in_category((int)$this->options['campaign_category'], $post_id) ){
$discount = $price * $this->options['privilege_discount'] / 100;
}else{
$discount = 0;
}
}else if ( $this->options['campaign_privilege'] == 'point' ){
$discount = 0;
}
}
$discount = ceil($discount);
$array[$key] = $discount;
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function getItemZaiko($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$num = $sku['stock'];
$array[$key] = $this->zaiko_status[$num];
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function getItemZaikoStatusId($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$num = $sku['stock'];
$array[$key] = $num;
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function updateItemZaiko($post_id, $skucode, $value) {
$res = usces_update_sku( $post_id, $skucode, 'stock', $value );
if( !$res ){
return false;
}else{
return true;
}
}
function getItemZaikoNum($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$array[$key] = $sku['stocknum'];
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function updateItemZaikoNum($post_id, $skucode, $value) {
$res = usces_update_sku( $post_id, $skucode, 'stocknum', $value );
if( !$res ){
return false;
}else{
return true;
}
}
//20120629ysk start 0000520
function getItemDivision( $post_id ){
if( usces_is_item($post_id) ){
$item_division = get_post_meta($post_id, '_item_division', true);
$division = empty($item_division) ? 'shipped' : $item_division;
}else{
$division = NULL;
}
return $division;
}
//20120629ysk end
function getItemChargingType( $post_id, $cart = array() ){
if( usces_is_item($post_id) ){
$charging = get_post_meta($post_id, '_item_charging_type', true);
//if( !defined('WCEX_DLSELLER') )
if( !defined('WCEX_DLSELLER') and !defined('WCEX_AUTO_DELIVERY') )
$charging = NULL;
}else{
$charging = NULL;
}
switch( $charging ){
case 0:
$type = 'once';
break;
case 1:
$type = 'continue';
break;
case 2:
$type = 'regular';
if( !empty($cart) ) {
if( empty($cart['advance']) ) {
$type = 'once';
} else {
$advance = $this->cart->wc_unserialize( $cart['advance'] );
$sku = urldecode( $cart['sku'] );
$regular = $advance[$post_id][$sku]['regular'];
$unit = isset( $regular['unit'] ) ? $regular['unit'] : '';
$interval = isset( $regular['interval'] ) ? (int)$regular['interval'] : 0;
if( empty($unit) or 1 > $interval ) //通常課金扱い
$type = 'once';
}
}
break;
default:
$type = NULL;
}
return $type;
}
function getItemFrequency( $post_id ){
$frequency = get_post_meta($post_id, '_item_frequency',true );
return $frequency;
}
function getItemChargingDay( $post_id ){
$array = get_post_meta($post_id, '_item_chargingday',true );
$day = (int)$array;
$chargingday = empty($day) ? 1 : $day;
return $chargingday;
}
function getItemSkuDisp($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$array[$key] = $sku['name'];
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
// function getItemSkuChargingType($post_id, $skukey = '') {
// $fields = get_post_custom($post_id);
// $skus = array();
// foreach((array)$fields as $key => $value){
// if( preg_match('/^_isku_/', $key, $match) ){
// $key = substr($key, 6);
// $values = maybe_unserialize($value[0]);
// if( isset($values['charging_type']) && "undefined" != $values['charging_type'] && !empty($values['charging_type']) ){
// $skus[$key] = $values['charging_type'];
// }else{
// continue;
// }
// }
// }
// if( empty($skus) ) return false;
// if($skukey == ''){
// return $skus;
// }elseif( isset($skus[$skukey]) ){
// return $skus[$skukey];
// }else{
// return false;
// }
// }
function getItemSkuUnit($post_id, $skukey = '') {
$array = array();
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$array[$key] = $sku['unit'];
}
if(!$array) return false;
if($skukey == ''){
return $array;
}else if(isset($array[$skukey])){
return $array[$skukey];
}else{
return false;
}
}
function get_item( $post_id ) {
$usces_item['post_id'] = $post_id;
$usces_item['itemCode'] = $this->getItemCode($post_id);
$usces_item['itemName'] = $this->getItemName($post_id);
$skus = $this->get_skus($post_id, 'code');
foreach((array)$skus as $key => $sku){
$usces_item['skuCodes'][] = $key;
$usces_item['skuValues'][] = $sku;
}
$usces_item = apply_filters('usces_filter_get_item', $usces_item, $post_id);
return $usces_item;
}
function get_itemOptionKey( $post_id, $enc = false ) {
$opts = usces_get_opts( $post_id );
if(empty($opts)) return;
$res = array();
foreach ( (array)$opts as $opt ) {
if( $enc )
$res[] = urlencode($opt['name']);
else
$res[] = $opt['name'];
}
return $res;
}
function get_itemOptions( $key, $post_id ) {
$opts = usces_get_opts( $post_id, 'name' );
if(empty($opts[$key]))
return;
else
return $opts[$key];
}
function get_postIDbyCode( $itemcode ) {
global $wpdb;
$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", '_itemCode', $itemcode);
$res = $wpdb->get_var( $query );
return $res;
}
function get_pictids($item_code) {
global $wpdb, $usces;
if( empty($item_code) )
return false;
if( !$usces->options['system']['subimage_rule'] ){
$codestr = $item_code.'%';
$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);
}else{
$codestr = $item_code.'--%';
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
}
$results = $wpdb->get_col( $query );
return $results;
}
function get_mainpictid($item_code) {
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'attachment' LIMIT 1", $item_code);
$id = $wpdb->get_var( $query );
$id = apply_filters( 'usces_filter_get_mainpictid', $id, $item_code );
return $id;
}
function get_skus( $post_id, $keyflag = 'sort' ) {
if( !$post_id )
return array();
$skus = array();
$metas = usces_get_post_meta($post_id, '_isku_');
if( empty($metas) ) return $skus;
foreach( $metas as $rows ){
$values = unserialize($rows['meta_value']);
$key = isset($values[$keyflag]) ? $values[$keyflag] : $values['sort'];
$skus[$key] = array(
'meta_id' => $rows['meta_id'],
'code' => $values['code'],
'name' => $values['name'],
'cprice' => $values['cprice'],
'price' => $values['price'],
'unit' => $values['unit'],
'stocknum' => $values['stocknum'],
'stock' => $values['stock'],
'gp' => $values['gp'],
'sort' => $values['sort'],
'advance' => isset($values['advance']) ? $values['advance'] : ''
);
}
$skus = apply_filters( 'usces_filter_get_skus', $skus, $post_id, $keyflag );
ksort($skus);
return $skus;
}
function is_item( $post ) {
if( $post->post_mime_type == 'item' )
return true;
else
return false;
}
function getItemIds( $end_type ) {
global $wpdb;
if( 'front' == $end_type )
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type = %s", 'publish', 'item');
if( 'back' == $end_type )
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_mime_type = %s", 'item');
$ids = $wpdb->get_col( $query );
if( empty($ids) ) $ids = array();
return $ids;
}
function getNotItemIds() {
global $wpdb;
$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = %s AND post_mime_type <> %s", 'publish', 'item');
$ids = $wpdb->get_col( $query );
if( empty($ids) ) $ids = array();
return $ids;
}
function getPaymentMethod( $name ) {
$res = array();
$payments = $this->options['payment_method'];
foreach ( (array)$payments as $payment ) {
if($name = $payment['name']) {
$res = $payment;
break;
}
}
return $res;
}
function order_processing( $results = array() ) {
do_action('usces_pre_reg_orderdata');
//db(function.php)
//20110203ysk start
$res = usces_check_acting_return_duplicate( $results );
if($res != NULL) {
usces_log('order processing duplicate : acting='.$_REQUEST['acting'].', order_id='.$res, 'acting_transaction.log');
return 'ordercompletion';
}
if(isset($_REQUEST['acting']) && ('jpayment_card' == $_REQUEST['acting'] || 'jpayment_conv' == $_REQUEST['acting'] || 'jpayment_bank' == $_REQUEST['acting'])) {
usces_log($_REQUEST['acting'].' transaction : '.$_REQUEST['gid'], 'acting_transaction.log');//OK
}
//20110203ysk end
//20110621ysk start 0000184
if(isset($_REQUEST['acting']) && ('paypal_ec' == $_REQUEST['acting'])) {
if( !usces_paypal_doecp( $results ) )
return 'error';
}
//20110621ysk end
$order_id = usces_reg_orderdata( $results );
do_action('usces_post_reg_orderdata', $order_id, $results);
if ( $order_id ) {
//mail(function.php)
$mail_res = usces_send_ordermail( $order_id );
return 'ordercompletion';
} else {
return 'error';
}
}
function acting_processing($acting_flg, $query) {
global $wpdb;
$entry = $this->cart->get_entry();
$delim = apply_filters( 'usces_filter_delim', $this->delim );
$acting_flg = trim($acting_flg);
//$usces_entries = $this->cart->get_entry();
if( empty($acting_flg) ) return 'error';
//include(USCES_PLUGIN_DIR . '/settlement/' . $acting_flg);
if($acting_flg == 'paypal.php'){
// if( !file_exists($this->options['settlement_path'] . $acting_flg) )
// return 'error';
//
// require_once($this->options['settlement_path'] . "paypal.php");
// paypal_submit();
}else if($acting_flg == 'epsilon.php'){
if( !file_exists($this->options['settlement_path'] . $acting_flg) )
return 'error';
if ( $this->use_ssl ) {
$redirect = str_replace('http://', 'https://', USCES_CART_URL);
}else{
$redirect = USCES_CART_URL;
}
usces_log('epsilon card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
$query .= '&settlement=epsilon&redirect_url=' . urlencode($redirect);
$query = $delim . ltrim($query, '&');
header("location: " . $redirect . $query);
exit;
}else if($acting_flg == 'acting_zeus_card' && 2 == $this->options['acting_settings']['zeus']['connection'] ){
if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] ){
if( !isset($_REQUEST['PaRes'])){
usces_log('zeus card entry data2 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
usces_zeus_3dsecure_enrol();
}else if( 1 == $this->options['acting_settings']['zeus']['3dsecur'] && isset($_REQUEST['PaRes'])){
usces_zeus_3dsecure_auth();
}
}else{
$res = usces_zeus_secure_payreq();
return $res;
}
}else if($acting_flg == 'acting_zeus_card' && 1 == $this->options['acting_settings']['zeus']['connection'] ){
$acting_opts = $this->options['acting_settings']['zeus'];
$interface = parse_url($acting_opts['card_url']);
//usces_log('zeus card ***** : '.print_r($entry, true), 'acting_transaction.log');
$vars = 'send=mall';
$vars .= '&clientip=' . $acting_opts['clientip'];
$vars .= '&cardnumber=' . $_POST['cardnumber'];
if( 1 == $this->options['acting_settings']['zeus']['security'] ){
$vars .= '&seccode=' . $_POST['securecode'];
}
$vars .= '&expyy=' . substr($_POST['expyy'], 2);
$vars .= '&expmm=' . $_POST['expmm'];
$vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
$vars .= '&email=' . $_POST['email'];
$vars .= '&sendid=' . $_POST['sendid'];
$vars .= '&username=' . $_POST['username'];
$vars .= '&money=' . $_POST['money'];
$vars .= '&sendpoint=' . $_POST['sendpoint'];
$vars .= '&printord=' . $_POST['printord'];
if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
$vars .= '&div=' . $_POST['div'];
}
//usces_log('zeus card *****vars : '.print_r($vars, true), 'acting_transaction.log');
$header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
$header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
//$header .= "Host: usctest.securesites.com\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($vars) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $vars;
$fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
if ($fp){
fwrite($fp, $header);
while ( !feof($fp) ) {
$scr = fgets($fp, 1024);
$page .= $scr;
}
fclose($fp);
//usces_log('zeus card *****2 : '.print_r($page, true), 'acting_transaction.log');
if( false !== strpos( $page, 'Success_order') ){
usces_log('zeus card entry data1 (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
$ordd = usces_get_order_number( $page );
//20120904ysk start 0000541
if ( !isset($_POST['cbrand']) || (isset($_POST['howpay']) && 1 == $_POST['howpay']) ) {
$args = '';
} else {
$div = 'div_'.$_POST['cbrand'];
$args = '&cbrand='.$_POST['cbrand'].'&howpay='.$_POST['howpay'].'&'.$div.'='.$_POST[$div];
}
$args .= '&order_number='.$ordd;
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=1'.$args);
//20120904ysk end
exit;
}else{
usces_log('zeus card : Certification Error', 'acting_transaction.log');
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
exit;
}
}else{
usces_log('zeus card : Socket Error', 'acting_transaction.log');
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_card&acting_return=0');
}
exit;
}else if($acting_flg == 'acting_zeus_conv'){
$acting_opts = $this->options['acting_settings']['zeus'];
$interface = parse_url($acting_opts['conv_url']);
$vars .= 'clientip=' . $acting_opts['clientip_conv'];
$vars .= '&act=' . $_POST['act'];
$vars .= '&money=' . $_POST['money'];
$vars .= '&username=' . mb_convert_encoding($_POST['username'], 'SJIS', 'UTF-8');
$vars .= '&telno=' . str_replace('-', '', $_POST['telno']);
$vars .= '&email=' . $_POST['email'];
$vars .= '&pay_cvs=' . $_POST['pay_cvs'];
$vars .= '&sendid=' . $_POST['sendid'];
$vars .= '&sendpoint=' . $_POST['sendpoint'];
if( !WCUtils::is_blank($acting_opts['testid_conv']) ){
$vars .= '&testid=' . $acting_opts['testid_conv'];
$vars .= '&test_type=' . $acting_opts['test_type_conv'];
}
$header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
$header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($vars) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $vars;
$fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
if ($fp){
fwrite($fp, $header);
while ( !feof($fp) ) {
$scr = fgets($fp, 1024);
$page .= $scr;
if( false !== strpos( $scr, 'order_no') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'pay_no1') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'pay_no2') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'pay_limit') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'pay_url') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'error_code') )
$qstr .= trim($scr) . '&';
if( false !== strpos( $scr, 'sendpoint') )
$qstr .= trim($scr) . '&';
}
$qstr .= 'pay_cvs=' . $_POST['pay_cvs'];
fclose($fp);
//usces_log('zeus page : '.$page, 'acting_transaction.log');
if( false !== strpos( $page, 'Success_order') ){
usces_log('zeus conv entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=1&' . $qstr);
exit;
}else{
usces_log('zeus data NG : '.$page, 'acting_transaction.log');
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
exit;
}
}else{
usces_log('zeus : sockopen NG', 'acting_transaction.log');
header("Location: " . USCES_CART_URL . $delim . 'acting=zeus_conv&acting_return=0');
}
exit;
//20110208ysk start
}else if($acting_flg == 'acting_paypal_ec') {
$acting_opts = $this->options['acting_settings']['paypal'];
$nvpstr = $query;
$nvpstr .= '&CURRENCYCODE='.$this->get_currency_code();
//$nvpstr .= '&ADDROVERRIDE=1';
$nvpstr .= '&PAYMENTACTION=' . apply_filters('usces_filter_paypal_ec_paymentaction', 'Sale');
//The returnURL is the location where buyers return to when a payment has been succesfully authorized.
$nvpstr .= '&RETURNURL='.urlencode(USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=1');
//The cancelURL is the location buyers are sent to when they hit the cancel button during authorization of payment during the PayPal flow
$nvpstr .= '&CANCELURL='.urlencode(USCES_CART_URL.$delim.'confirm=1');
$nvpstr .= '&NOTIFYURL='.urlencode(USCES_PAYPAL_NOTIFY_URL);
$this->paypal->setMethod('SetExpressCheckout');
$this->paypal->setData($nvpstr);
$res = $this->paypal->doExpressCheckout();
$resArray = $this->paypal->getResponse();
$ack = strtoupper($resArray["ACK"]);
if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
$token = urldecode($resArray["TOKEN"]);
$payPalURL = $acting_opts['paypal_url'].'?cmd=_express-checkout&token='.$token.'&useraction=commit';
header("Location: ".$payPalURL);
} else {
//Display a user friendly Error on the page using any of the following error information returned by PayPal
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
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');
header("Location: ".USCES_CART_URL.$delim.'acting=paypal_ec&acting_return=0');
}
exit;
//20110208ysk end
//20121030ysk start
} elseif( $acting_flg == 'acting_telecom_edy' ) {
$table_meta_name = $wpdb->prefix."usces_order_meta";
$value = array();
$value['usces_cart'] = $_SESSION['usces_cart'];
$value['usces_entry'] = $_SESSION['usces_entry'];
$value['usces_member'] = $_SESSION['usces_member'];
$mvalue = serialize( $value );
$mquery = $wpdb->prepare( "INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $_POST['option'], $_POST['option'], $mvalue );
$res = $wpdb->query( $mquery );
unset( $_SESSION['usces_cart'] );
unset( $_SESSION['usces_entry'] );
$acting_opts = $this->options['acting_settings']['telecom'];
header( "location: ".$acting_opts['send_url_edy'].'?acting=telecom_edy'.$query );
exit;
//20121030ysk end
//20121206ysk start
} else if( $acting_flg == 'acting_digitalcheck_card' ) {
$acting_opts = $this->options['acting_settings']['digitalcheck'];
$interface = parse_url($acting_opts['send_url_user_id']);
$kakutei = ( empty($acting_opts['card_kakutei']) ) ? '0' : $acting_opts['card_kakutei'];
$vars = 'IP='.$acting_opts['card_ip'];
$vars .= '&PASS='.$acting_opts['card_pass'];
$vars .= '&IP_USER_ID='.$_POST['IP_USER_ID'];
$vars .= '&SID='.$_POST['SID'];
$vars .= '&STORE=51';
$vars .= '&N1='.$_POST['N1'];
$vars .= '&K1='.$_POST['K1'];
$vars .= '&KAKUTEI='.$kakutei;
$vars .= '&FUKA='.$acting_flg;
$header = "POST ".$interface['path']." HTTP/1.1\r\n";
$header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($vars)."\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $vars;
$fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
if( $fp ) {
fwrite( $fp, $header );
$page = '';
while( !feof($fp) ) {
$line = fgets( $fp, 1024 );
if( strcmp($line, "\r\n") == 0 ) {
$headerdone = true;
} elseif( $headerdone ) {
$page .= $line;
}
}
fclose($fp);
$lines = explode("\n", $page);
if( false !== strpos( $lines[0], 'OK') ) {
usces_log('digitalcheck card entry data (acting_processing) : '.print_r($entry, true), 'acting_transaction.log');
//$args = '&SID='.$lines[1];
$args = '&SID='.$_POST['SID'].'&FUKA='.$acting_flg;
header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=1'.$args );
} else {
usces_log('digitalcheck card : Certification Error : '.$page, 'acting_transaction.log');
header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
}
} else {
usces_log('digitalcheck card : Socket Error', 'acting_transaction.log');
header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_card&acting_return=0' );
}
exit;
} else if( $acting_flg == 'acting_digitalcheck_conv' ) {
if( isset($_REQUEST['STORE']) and '99' != $_REQUEST['STORE'] ) {
$res = $this->order_processing();
if( 'ordercompletion' == $res ) {
$table_meta_name = $wpdb->prefix."usces_order_meta";
$mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $_REQUEST['SID'] );
$order_id = $wpdb->get_var($mquery);
if( $order_id ) {
$data = array( "settltment_status" => "未決済", "settltment_errmsg" => "決済が完了していません" );
$this->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
}
$this->cart->crear_cart();
$acting_opts = $this->options['acting_settings']['digitalcheck'];
header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
exit;
} else {
usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
header( "location: ".USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=0' );
}
} else {
$acting_opts = $this->options['acting_settings']['digitalcheck'];
header( "location: ".$acting_opts['send_url_conv'].'?acting=digitalcheck_conv'.$query );
exit;
}
//20121206ysk end
}
do_action('usces_action_acting_processing', $acting_flg, $query);
}
function inquiry_processing() {
$mail_res = usces_send_inquirymail();
if ( $mail_res )
return 'inquiry_comp';
else
return 'inquiry_error';
}
function lastprocessing() {
if ( $this->page == 'ordercompletion' )
$this->cart->crear_cart();
unset($_SESSION['usces_singleitem']);
}
function is_item_zaiko( $post_id, $sku ){
$status_num = (int)$this->getItemZaikoStatusId($post_id, $sku);
$zaiko_num = trim($this->getItemZaikoNum($post_id, $sku));
if( false !== $zaiko_num
&& ( 0 < (int)$zaiko_num || WCUtils::is_blank($zaiko_num) )
&& false !== $status_num
&& 2 > $status_num
){
return true;
}else{
return false;
}
}
// function for the cart ***********************************************************
function get_total_price( $cart = array() ) {
if( empty($cart) )
$cart = $this->cart->get_cart();
$total_price = 0;
if( !empty($cart) ) {
for($i=0; $icart->get_cart();
$total_quantity = 0;
if( !empty($cart) ) {
for($i=0; $ioptions['membersystem_state'] == 'deactivate' || $this->options['membersystem_point'] == 'deactivate') return 0;
if ( empty($cart) )
$cart = $this->cart->get_cart();
if ( empty($display_mode) )
$display_mode = $this->options['display_mode'];
$point = 0;
$total = $this->get_total_price( $cart );
if ( $display_mode == 'Promotionsale' ) {
if ( $this->options['campaign_privilege'] == 'discount' ) {
foreach ( $cart as $rows ) {
$cats = $this->get_post_term_ids($rows['post_id'], 'category');
if ( !in_array($this->options['campaign_category'], $cats) ){
$rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
$price = $rows['price'] * $rows['quantity'];
$point += $price * $rate / 100;
}
}
} elseif ( $this->options['campaign_privilege'] == 'point' ) {
foreach ( $cart as $rows ) {
$rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
//$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
$price = $rows['price'] * $rows['quantity'];
$cats = $this->get_post_term_ids($rows['post_id'], 'category');
if ( in_array($this->options['campaign_category'], $cats) )
$point += $price * $rate / 100 * $this->options['privilege_point'];
else
$point += $price * $rate / 100;
}
}
} else {
foreach ( $cart as $rows ) {
$rate = get_post_meta($rows['post_id'], '_itemPointrate', true);
//$price = $this->getItemPrice($rows['post_id'], $rows['sku']) * $rows['quantity'];
$price = $rows['price'] * $rows['quantity'];
$point += $price * $rate / 100;
}
}
//20130425ysk start 0000699
if( 0 < $point ) $point = ceil( $point );
$entry = $this->cart->get_entry();
$use_point = isset( $entry['order']['usedpoint'] ) ? (int)$entry['order']['usedpoint'] : 0;
if( 0 < $use_point ) {
$point = ceil( $point - ( $point * $use_point / $total ) );
if( 0 > $point )
$point = 0;
}
return apply_filters( 'usces_filter_get_order_point', $point, $mem_id, $display_mode, $cart );
//20130425ysk end
}
function get_order_discount( $display_mode = '', $cart = array() ) {
if ( empty($cart) )
$cart = $this->cart->get_cart();
if ( empty($display_mode) )
$display_mode = $this->options['display_mode'];
$discount = 0;
$total = $this->get_total_price( $cart );
if ( $display_mode == 'Promotionsale' ) {
if ( $this->options['campaign_privilege'] == 'discount' ){
if( 0 === (int)$this->options['campaign_category'] ){
$discount = $total * $this->options['privilege_discount'] / 100;
}else{
foreach($cart as $cart_row){
if( in_category((int)$this->options['campaign_category'], $cart_row['post_id']) ){
$discount += $cart_row['price'] * $cart_row['quantity'] * $this->options['privilege_discount'] / 100;
}
}
}
}else if ( $this->options['campaign_privilege'] == 'point' ){
$discount = 0;
}
}
$discount = ceil($discount * -1);
$discount = apply_filters('usces_order_discount', $discount, $cart);
return $discount;
}
function getShippingCharge( $pref, $cart = array(), $entry = array() ) {
if( empty($cart) )
$cart = $this->cart->get_cart();
if( empty($entry) )
$entry = $this->cart->get_entry();
//配送方法ID
$d_method_id = $entry['order']['delivery_method'];
//配送方法index
$d_method_index = $this->get_delivery_method_index($d_method_id);
//送料ID
$fixed_charge_id = ( isset($this->options['delivery_method'][$d_method_index]['charge']) ) ? $this->options['delivery_method'][$d_method_index]['charge'] : -1;
$individual_quant = 0;
$total_quant = 0;
$charges = array();
$individual_charges = array();
$country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
foreach ( $cart as $rows ) {
if( -1 == $fixed_charge_id ){
//商品送料ID
$s_charge_id = $this->getItemShippingCharge($rows['post_id']);
//商品送料index
$s_charge_index = $this->get_shipping_charge_index($s_charge_id);
//20120710ysk start 0000472
//$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
$charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
//20120710ysk end
}else{
$s_charge_index = $this->get_shipping_charge_index($fixed_charge_id);
//20120710ysk start 0000472
//$charge = isset($this->options['shipping_charge'][$s_charge_index]['value'][$pref]) ? $this->options['shipping_charge'][$s_charge_index]['value'][$pref] : 0;
$charge = isset($this->options['shipping_charge'][$s_charge_index][$country][$pref]) ? $this->options['shipping_charge'][$s_charge_index][$country][$pref] : 0;
//20120710ysk end
}
if($this->getItemIndividualSCharge($rows['post_id'])){
$individual_quant += $rows['quantity'];
$individual_charges[] = $rows['quantity'] * $charge;
}else{
$charges[] = $charge;
}
$total_quant += $rows['quantity'];
}
if( count($charges) > 0 ){
rsort($charges);
$max_charge = $charges[0];
$charge = $max_charge + array_sum($individual_charges);
}else{
$charge = array_sum($individual_charges);
}
$charge = apply_filters('usces_filter_getShippingCharge', $charge, $cart, $entry);
return $charge;
}
function getCODFee($payment_name, $amount_by_cod) {
$payments = $this->getPayments($payment_name);
if( 'COD' != $payments['settlement'] ){
$fee = 0;
}else if( 'change' != $this->options['cod_type'] ){
//$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : '';
$fee = isset($this->options['cod_fee']) ? $this->options['cod_fee'] : 0;
}else{
$price = $amount_by_cod + $this->getTax( $amount_by_cod );
if( $price <= $this->options['cod_first_amount'] ){
$fee = $this->options['cod_first_fee'];
}else if( isset($this->options['cod_amounts']) ){
$last = count( $this->options['cod_amounts'] ) - 1;
if( $price > $this->options['cod_amounts'][$last] ){
$fee = $this->options['cod_end_fee'];
}else{
$fee = 0;
foreach( $this->options['cod_amounts'] as $key => $value ){
if( $price <= $value ){
$fee = $this->options['cod_fees'][$key];
break;
}
}
}
}else{
$fee = $this->options['cod_end_fee'];
}
}
$fee = apply_filters('usces_filter_getCODFee', $fee, $payment_name, $amount_by_cod);
return $fee;
}
function getTax( $total ) {
if( empty($this->options['tax_rate']) )
return 0;
if( $this->options['tax_method'] == 'cutting' )
$tax = floor($total * $this->options['tax_rate'] / 100);
elseif($this->options['tax_method'] == 'bring')
$tax = ceil($total * $this->options['tax_rate'] / 100);
elseif($this->options['tax_method'] == 'rounding')
$tax = round($total * $this->options['tax_rate'] / 100);
return $tax;
}
function set_cart_fees( $member, &$entries ) {
$carts = $this->cart->get_cart();
$total_items_price = $this->get_total_price();
if ( empty($this->options['postage_privilege']) || $total_items_price < $this->options['postage_privilege'] ) {
$shipping_charge = $this->getShippingCharge( $entries['delivery']['pref'] );
} else {
$shipping_charge = 0;
}
$shipping_charge = apply_filters('usces_filter_set_cart_fees_shipping_charge', $shipping_charge, $carts, $entries);
$payments = $this->getPayments( $entries['order']['payment_name'] );
$discount = $this->get_order_discount();
$use_point = $entries['order']['usedpoint'];
$amount_by_cod = $total_items_price - $use_point + $discount + $shipping_charge;
$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);
$cod_fee = $this->getCODFee($entries['order']['payment_name'], $amount_by_cod);
$cod_fee = apply_filters('usces_filter_set_cart_fees_cod', $cod_fee, $entries, $total_items_price, $use_point, $discount, $shipping_charge);
$total_price = $total_items_price - $use_point + $discount + $shipping_charge + $cod_fee;
$total_price = apply_filters('usces_filter_set_cart_fees_total_price', $total_price, $total_items_price, $use_point, $discount, $shipping_charge, $cod_fee);
$tax = $this->getTax( $total_price );
$total_full_price = $total_price + $tax;
$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);
$get_point = $this->get_order_point( $member['ID'] );
//20130425ysk start 0000699
//if(0 < (int)$use_point){
// $get_point = ceil( $get_point - ($get_point * $use_point / $total_items_price) );
// if(0 > $get_point)
// $get_point = 0;
//}
//20130425ysk end
$array = array(
'total_items_price' => $total_items_price,
'total_price' => $total_price,
'total_full_price' => $total_full_price,
'getpoint' => $get_point,
'usedpoint' => $use_point,
'discount' => $discount,
'shipping_charge' => $shipping_charge,
'cod_fee' => $cod_fee,
'tax' => $tax
);
$this->cart->set_order_entry( $array );
//$entries = $this->cart->get_entry();
//var_dump($entries);
}
function getPayments( $payment_name ) {
if( '#none#' == $payment_name )
return NULL;
$payments = usces_get_system_option( 'usces_payment_method', 'name' );
if( isset($payments[$payment_name]) )
return $payments[$payment_name];
return NULL;
}
function is_maintenance() {
if ( $this->options['display_mode'] == 'Maintenancemode' )
return true;
else
return false;
}
// function maintenance_mode() {
// if ( $this->is_maintenance() && !is_user_logged_in() && (!strstr($_SERVER['REQUEST_URI'], 'wp-admin') || !strstr($_SERVER['REQUEST_URI'], 'wp-login') ) ) {
// include ( TEMPLATEPATH . '/maintenance.php ');
// exit;
// } elseif ( isset($_GET['uscesmode']) && $_GET['uscesmode'] == 'lostpassword' ) {
// $error = isset($_GET['error']) ? '?error='.$_GET['error'] : '';
// include ( TEMPLATEPATH . '/member/changepassword.php ');
// exit;
// }
// }
function get_member_history($mem_id) {
global $wpdb;
$order_table = $wpdb->prefix . "usces_order";
$query = $wpdb->prepare("SELECT * FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
// $query = $wpdb->prepare("SELECT ID, order_cart, order_condition, order_date, order_usedpoint, order_getpoint,
// order_discount, order_shipping_charge, order_cod_fee, order_tax, order_status
// FROM $order_table WHERE mem_id = %d ORDER BY order_date DESC", $mem_id);
$results = $wpdb->get_results( $query );
$i=0;
$res = array();
foreach ( $results as $value ) {
if(strpos($value->order_status, 'cancel') === false && strpos($value->order_status, 'estimate') === false){
$res[] = array(
'ID' => $value->ID,
'cart' => unserialize($value->order_cart),
'condition' => unserialize($value->order_condition),
'getpoint' => $value->order_getpoint,
'usedpoint' => $value->order_usedpoint,
'discount' => $value->order_discount,
'shipping_charge' => $value->order_shipping_charge,
'payment_name' => $value->order_payment_name,
'cod_fee' => $value->order_cod_fee,
'tax' => $value->order_tax,
'order_status' => $value->order_status,
'date' => mysql2date(__('Y/m/d'), $value->order_date),
'order_date' => $value->order_date
);
$i++;
}
}
return $res;
}
function get_post_term_ids( $post_id, $taxonomy ){
global $wpdb;
$query = $wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_relationships AS tr
INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tt.taxonomy = %s AND tr.object_id = %d", $taxonomy, $post_id);
$ids = $wpdb->get_col( $query );
return $ids;
}
function get_tag_names($post_id) {
global $wpdb;
$tag = 'post_tag';
$query = $wpdb->prepare("SELECT t.name FROM $wpdb->term_relationships AS tr
INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
INNER JOIN $wpdb->terms AS t ON t.term_id = tt.term_id
WHERE tt.taxonomy = %s AND tr.object_id = %d", $tag, $post_id);
$names = $wpdb->get_col( $query );
return apply_filters('usces_filter_get_tag_names', $names, $post_id);
}
function get_ID_byItemName($itemname, $status = 'publish') {
global $wpdb;
$meta_key = '_itemCode';
$query = $wpdb->prepare("SELECT p.ID FROM $wpdb->posts AS p
INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id
WHERE p.post_status = %s AND pm.meta_key = %s AND meta_value = %s ", $status, $meta_key, $itemname);
$id = $wpdb->get_var( $query );
// $wpdb->show_errors();
// $wpdb->print_error();
return $id;
}
function uscescv( $sessid, $flag ) {
$chars = '';
$i=0;
$h=0;
$usces_cookie = $this->get_cookie();
if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
$cid = $usces_cookie['id'];
}elseif( isset($_SESSION['usces_cookieid']) && !empty($_SESSION['usces_cookieid']) ){
$cid = $_SESSION['usces_cookieid'];
}else{
$cid = 0;
}
while($hget_cookie();
// if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI']))){
// if( isset($usces_cookie['sslid']) && !empty($usces_cookie['sslid']) ){
// $cid = $usces_cookie['sslid'];
// }else{
// $cid = 0;
// }
// }else{
// if( isset($usces_cookie['id']) && !empty($usces_cookie['id']) ){
// $cid = $usces_cookie['id'];
// }else{
// $cid = 0;
// }
// }
$sessid = base64_decode(urldecode($sessid));
list($sess, $addr, $cookieid, $none) = explode('_', $sessid, 4);
$postfix = ( isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : 'REMOTE_ADDR';
$postfix = apply_filters('usces_sessid_force', $postfix);
//usces_log('cid : '.$cid, 'acting_transaction.log');
//usces_log('cookieid : '.$cookieid, 'acting_transaction.log');
//usces_log('postfix : '.$postfix, 'acting_transaction.log');
//usces_log('addr : '.$addr, 'acting_transaction.log');
if( 'acting' !== $addr && 'mobile' !== $addr && $postfix !== $addr ) {
$sessid = '';
return NULL;
}
$chars = '';
$h=0;
while($hprefix . 'usces_access';
$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);
$res = $wpdb->get_row($query, ARRAY_A);
if( $res == NULL )
return 0;
else
return $res['ct1']+$res['ct2'];
}
function get_fvisiter( $period ) {
global $wpdb;
$datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
$yearstr = substr($datestr, 0, 4);
$monthstr = substr($datestr, 5, 2);
$daystr = substr($datestr, 8, 2);
if($period == 'today') {
$date = $datestr;
$today = $datestr;
}else if($period == 'thismonth') {
$date = date('Y-m-01');
$today = $datestr;
}else if($period == 'lastyear') {
$date = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
$today = date('Y-m-01', mktime(0, 0, 0, (int)$monthstr, (int)$daystr, (int)$yearstr-1));
}
$table_name = $wpdb->prefix . 'usces_access';
$query = $wpdb->prepare("SELECT SUM(acc_num2) AS ct FROM $table_name WHERE acc_date >= %s AND acc_date <= %s", $date, $today);
$res = $wpdb->get_var($query);
if( $res == NULL )
return 0;
else
return $res;
}
function get_order_num( $period ) {
global $wpdb;
$datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
$yearstr = substr($datestr, 0, 4);
$monthstr = substr($datestr, 5, 2);
$daystr = substr($datestr, 8, 2);
if($period == 'today') {
$date = date('Y-m-d 00:00:00', current_time('timestamp'));
$today = date('Y-m-d 23:59:59', current_time('timestamp'));
}else if($period == 'thismonth') {
$date = date('Y-m-01 00:00:00', current_time('timestamp'));
$today = date('Y-m-d 23:59:59', current_time('timestamp'));
}else if($period == 'lastyear') {
$date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
$today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
}
$table_name = $wpdb->prefix . 'usces_order';
$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');
$res = $wpdb->get_var($query);
if( $res == NULL )
return 0;
else
return $res;
}
function get_order_amount( $period ) {
global $wpdb;
$datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
$yearstr = substr($datestr, 0, 4);
$monthstr = substr($datestr, 5, 2);
$daystr = substr($datestr, 8, 2);
if($period == 'today') {
$date = date('Y-m-d 00:00:00', current_time('timestamp'));
$today = date('Y-m-d 23:59:59', current_time('timestamp'));
}else if($period == 'thismonth') {
$date = date('Y-m-01 00:00:00', current_time('timestamp'));
$today = date('Y-m-d 23:59:59', current_time('timestamp'));
}else if($period == 'lastyear') {
$date = date('Y-m-01 00:00:00', mktime(0, 0, 0, (int)$monthstr, 1, (int)$yearstr-1));
$today = date('Y-m-d 23:59:59', mktime(0, 0, 0, (int)$monthstr+1, 0, (int)$yearstr-1));
}
$table_name = $wpdb->prefix . 'usces_order';
$query = $wpdb->prepare("SELECT
SUM(order_item_total_price) AS price,
SUM(order_usedpoint) AS point,
SUM(order_discount) AS discount,
SUM(order_shipping_charge) AS shipping,
SUM(order_cod_fee) AS cod,
SUM(order_tax) AS tax
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');
$res = $wpdb->get_row($query, ARRAY_A);
if( $res == NULL )
return 0;
else
return $res['price'] - $res['point'] + $res['discount'] + $res['shipping'] + $res['cod'] + $res['tax'];
}
function is_status($need, $str){
$array = explode(',', $str);
return in_array($need, $array);
}
function make_status( $taio='', $receipt='', $admin='' ){
$str = '';
if($taio != '' && $taio != '#none#')
$str .= $taio . ',';
if($receipt != '' && $receipt != '#none#')
$str .= $receipt . ',';
if($admin != '' && $admin != '#none#')
$str .= $admin . ',';
return $str;
}
function get_memberid_by_email($email){
global $wpdb;
$table_name = $wpdb->prefix . "usces_member";
$query = $wpdb->prepare("SELECT ID FROM $table_name WHERE mem_email = %s", $email);
$res = $wpdb->get_var($query);
return $res;
}
function get_condition(){
//20120807ysk start 0000544
$order_conditions = array(
'display_mode' => $this->options['display_mode'],
'campaign_privilege' => $this->options['campaign_privilege'],
'campaign_category' => $this->options['campaign_category'],
'privilege_point' => $this->options['privilege_point'],
'privilege_discount' => $this->options['privilege_discount']);
return $order_conditions;
//20120807ysk end
}
function get_bestseller_ids( $days = "" ){
global $wpdb;
$datestr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 10);
$yearstr = substr($datestr, 0, 4);
$monthstr = substr($datestr, 5, 2);
$daystr = substr($datestr, 8, 2);
$res = array();
$order_table_name = $wpdb->prefix . "usces_order";
$where = "";
if($days != ''){
$order_date = date('Y-m-d H:i:s', mktime(0, 0, 0, (int)$monthstr, ((int)$daystr-$days), (int)$yearstr));
$where = " WHERE order_date >= '{$order_date}'";
}
$query = "SELECT order_cart FROM {$order_table_name}" . $where;
$dbres = $wpdb->get_col($query);
if(!$dbres) return false;
foreach((array)$dbres as $carts){
$rows = unserialize($carts);
foreach((array)$rows as $carts){
if( 'publish' != get_post_status($carts['post_id']) )
continue;
$id = $carts['post_id'];
$qu = $carts['quantity'];
if(array_key_exists($id, $res)){
$res[$id] = $res[$id] + $qu;
}else{
$res[$id] = $qu;
}
}
}
arsort($res);
$results = array_keys($res);
return $results;
}
function get_items_num(){
global $wpdb;
$query = $wpdb->prepare("SELECT COUNT(ID) AS ct FROM {$wpdb->posts}
WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
'item', 'post', 'trush');
$res = $wpdb->get_var($query);
return $res;
}
function is_gptekiyo( $post_id, $sku, $quant ) {
$skus = $this->get_skus( $post_id, 'code' );
if( !isset($skus[$sku]['gp']) || !$skus[$sku]['gp'] ) return false;
$GpN1 = $this->getItemGpNum1($post_id);
$GpN2 = $this->getItemGpNum2($post_id);
$GpN3 = $this->getItemGpNum3($post_id);
if( empty($GpN1) ) {
return false;
}else if( !empty($GpN1) && empty($GpN2) ) {
if( $quant >= $GpN1 ) {
return true;
}else{
return false;
}
}else if( !empty($GpN1) && !empty($GpN2) && empty($GpN3) ) {
if( $quant >= $GpN2 ) {
return true;
}else if( $quant >= $GpN1 && $quant < $GpN2 ) {
return true;
}else{
return false;
}
}else if( !empty($GpN1) && !empty($GpN2) && !empty($GpN3) ) {
if( $quant >= $GpN3 ) {
return true;
}else if( $quant >= $GpN2 && $quant < $GpN3 ) {
return true;
}else if( $quant >= $GpN1 && $quant < $GpN2 ) {
return true;
}else{
return false;
}
}
}
function get_available_delivery_method() {
if($this->cart->num_row() > 0) {
$cart = $this->cart->get_cart();
$before_deli = array();
$intersect = array();
$integration = array();
$temp = array();
$in = 0;
foreach($cart as $key => $row){
$deli = $this->getItemDeliveryMethod($row['post_id']);
//usces_p($deli);
if( empty($deli))
continue;
//usces_log('deli : '.print_r($deli, true), 'acting_transaction.log');
if( 0 === $in ){
$intersect = $deli;
}
$intersect = array_intersect($deli, $intersect);
$before_deli = $deli;
foreach($deli as $value){
$integration[] = $value;
}
$in++;
}
$integration = array_unique($integration);
foreach($integration as $id){
$index = $this->get_delivery_method_index($id);
$temp[$index] = $id;
}
ksort($temp);
//20120820ysk start 0000546
//$force = array($temp[0]);
$force = array(array_shift($temp));
//20120820ysk end
if( empty($intersect) ){
return $force;
}else{
return $intersect;
}
}
return array();
}
function get_delivery_method_index($id) {
$index = false;
for($i=0; $ioptions['delivery_method']); $i++){
if( $this->options['delivery_method'][$i]['id'] === (int)$id ){
$index = $i;
}
}
if($index === false)
return -1;
else
return $index;
}
function get_shipping_charge_index($id) {
$index = false;
for($i=0; $ioptions['shipping_charge']); $i++){
//20120710ysk start 0000472
//if( $this->options['shipping_charge'][$i]['id'] === $id ){
if( (int)$this->options['shipping_charge'][$i]['id'] == (int)$id ){
//20120710ysk end
$index = $i;
}
}
if($index === false)
return -1;
else
return $index;
}
function get_initial_data($xml){
$buf = file_get_contents($xml);
preg_match_all('@.*?(.*?).*?(.*?).*?(.*?).*?(.*?).*?@s', $buf, $match, PREG_SET_ORDER);
return $match;
}
function getCurrencySymbol(){
global $usces_settings;
$cr = $this->options['system']['currency'];
list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
return $symbol;
}
function getCartItemName($post_id, $sku){
$name_arr = array();
$name_str = '';
foreach($this->options['indi_item_name'] as $key => $value){
if($value){
$pos = (int)$this->options['pos_item_name'][$key];
$ind = ($pos === 0) ? 'A' : $pos;
switch($key){
case 'item_name':
$name_arr[$ind][$key] = $this->getItemName($post_id);
break;
case 'item_code':
$name_arr[$ind][$key] = $this->getItemCode($post_id);
break;
case 'sku_name':
$name_arr[$ind][$key] = $this->getItemSkuDisp($post_id, $sku);
break;
case 'sku_code':
$name_arr[$ind][$key] = $sku;
break;
}
}
}
ksort($name_arr);
foreach($name_arr as $vals){
foreach($vals as $key => $value){
$name_str .= $value . ' ';
}
}
$name_str = apply_filters('usces_admin_order_item_name_filter', $name_str);
return trim($name_str);
}
function set_reserve_pre_order_id(){
$entry = $this->cart->get_entry();
$id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : uniqid('');
$this->cart->set_pre_order_id($id);
}
function get_current_pre_order_id(){
$entry = $this->cart->get_entry();
$id = ( isset($entry['reserve']['pre_order_id']) && !empty($entry['reserve']['pre_order_id']) ) ? $entry['reserve']['pre_order_id'] : NULL;
return $id;
}
function get_reserve($order_id, $key){
global $wpdb;
$order_meta_table_name = $wpdb->prefix . "usces_order_meta";
$query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
$order_id, $key);
$res = $wpdb->get_var($query);
return $res;
}
//20100818ysk start
//20100816ysk start
//function get_order_meta($order_id, $key) {
function get_order_meta_value($key, $order_id) {
global $wpdb;
$order_meta_table_name = $wpdb->prefix . "usces_order_meta";
$query = $wpdb->prepare("SELECT meta_value FROM $order_meta_table_name WHERE order_id = %d AND meta_key = %s",
$order_id, $key);
$res = $wpdb->get_var($query);
return $res;
}
//20100816ysk end
function set_order_meta_value($key, $meta_value, $order_id) {
global $wpdb;
//if( empty($meta_value) ) return;
if( empty($order_id) ) return;
$table_name = $wpdb->prefix . "usces_order_meta";
$query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE order_id = %d AND meta_key = %s",
$order_id, $key);
$res = $wpdb->get_var($query);
if(0 < $res) {
$query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s",
$meta_value,
$order_id,
$key
);
$res2 = $wpdb->query($query);
} else {
$query = $wpdb->prepare("INSERT INTO $table_name (order_id, meta_key, meta_value)
VALUES(%d, %s, %s)",
$order_id,
$key,
$meta_value
);
$res2 = $wpdb->query($query);
}
return $res2;
}
//20130524ysk start
function del_order_meta( $key, $order_id ) {
global $wpdb;
$table_name = $wpdb->prefix."usces_order_meta";
$query = $wpdb->prepare( "DELETE FROM $table_name WHERE order_id = %d AND meta_key = %s", $order_id, $key );
$res = $wpdb->query( $query );
return $res;
}
//20130524ysk end
function set_session_custom_member($member_id) {
unset($_SESSION['usces_member']['custom_member']);
$meta = usces_has_custom_field_meta('member');
if(is_array($meta)) {
$keys = array_keys($meta);
foreach($keys as $key) {
$csmb_key = 'csmb_'.$key;
$_SESSION['usces_member']['custom_member'][$key] = maybe_unserialize($this->get_member_meta_value($csmb_key, $member_id));
}
}
}
function reg_custom_member($member_id) {
//20130524ysk start 0000712
$csmb_meta = usces_has_custom_field_meta( 'member' );
if( is_array($csmb_meta) ) {
foreach( $csmb_meta as $key => $entry ) {
if( '4' == $entry['means'] ) {
$this->del_member_meta( 'csmb_'.$key, $member_id );
}
}
}
//20130524ysk end
if( !empty($_POST['custom_member']) ) {
foreach( $_POST['custom_member'] as $key => $value ) {
$csmb_key = 'csmb_'.$key;
if( is_array($value) )
$value = serialize($value);
$res = $this->set_member_meta_value($csmb_key, $value, $member_id);
if(false === $res)
return false;
}
}elseif( isset($_POST['custom_customer']) ){
foreach( $_POST['custom_customer'] as $key => $value ) {
$csmb_key = 'csmb_'.$key;
if( is_array($value) )
$value = serialize($value);
$res = $this->set_member_meta_value($csmb_key, $value, $member_id);
if(false === $res)
return false;
}
}
}
//20100818ysk end
function save_order_acting_data($rand){
global $wpdb;
$data = serialize(array( 'cart' => $this->cart->get_cart(), 'entry' => $this->cart->get_entry() ));
$table_name = $wpdb->prefix . "usces_access";
$query = $wpdb->prepare("INSERT INTO $table_name (acc_type, acc_str1, acc_date, acc_key, acc_value)
VALUES(%s, %s, now(), %s, %s)",
'acting_data',
$this->get_uscesid(false),
$rand,
$data
);
$res = $wpdb->query($query);
return $res;
}
//20100818ysk start
function set_member_meta_value($key, $meta_value, $member_id = ''){
global $wpdb;
//if( empty($meta_value) ) return;
if( WCUtils::is_blank($member_id) ) {
if( !$this->is_member_logged_in() ) return;
$member = $this->get_member();
$member_id = $member['ID'];
}
$table_name = $wpdb->prefix . "usces_member_meta";
//$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
$query = $wpdb->prepare("SELECT count(*) FROM $table_name WHERE member_id = %d AND meta_key = %s",
$member_id, $key);
$res = $wpdb->get_var($query);
//if($res != NULL){
if(0 < $res){
$query = $wpdb->prepare("UPDATE $table_name SET meta_value = %s WHERE member_id = %d AND meta_key = %s",
$meta_value,
$member_id,
$key
);
$res2 = $wpdb->query($query);
}else{
$query = $wpdb->prepare("INSERT INTO $table_name (member_id, meta_key, meta_value)
VALUES(%d, %s, %s)",
$member_id,
$key,
$meta_value
);
$res2 = $wpdb->query($query);
}
return $res2;
}
//20100818ysk end
function get_member_meta_value($key, $member_id){
global $wpdb;
$table_name = $wpdb->prefix . "usces_member_meta";
$query = $wpdb->prepare("SELECT meta_value FROM $table_name WHERE member_id = %d AND meta_key = %s",
$member_id, $key);
$res = $wpdb->get_var($query);
return $res;
}
function del_member_meta($key, $member_id){
global $wpdb;
$table_name = $wpdb->prefix . "usces_member_meta";
$query = $wpdb->prepare("DELETE FROM $table_name WHERE member_id = %d AND meta_key = %s",
$member_id, $key);
$res = $wpdb->query($query);
return $res;
}
function get_member_meta($member_id){
global $wpdb;
$table_name = $wpdb->prefix . "usces_member_meta";
$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_%');
$res = $wpdb->get_results($query, ARRAY_A);
return $res;
}
function get_settle_info_field( $order_id ){
global $wpdb;
$fields = array();
$table_name = $wpdb->prefix . "usces_order_meta";
$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)",
$order_id, 'acting_%', 'settlement_id', 'order_number', 'res_tracking_id', 'SID');
$res = $wpdb->get_results($query, ARRAY_A);
if( !$res )
return $fields;
foreach( $res as $value ){
if( 'settlement_id' == $value['meta_key'] ){
$meta_values = maybe_unserialize($value['meta_value']);
if( is_array($meta_values) ){
foreach( $meta_values as $key => $meta_value ){
$fields[$key] = $meta_value;
}
}else{
$fields['settlement_id'] = $meta_values;
}
}elseif( 'order_number' == $value['meta_key'] ){
$fields['order_number'] = $value['meta_value'];
}elseif( 'res_tracking_id' == $value['meta_key'] ){
$fields['res_tracking_id'] = $value['meta_value'];
}elseif( 'SID' == $value['meta_key'] ){
$fields['SID'] = $value['meta_value'];
}elseif( 'acting_' == substr($value['meta_key'], 0, 7) ){
$meta_values = unserialize($value['meta_value']);
if(is_array($meta_values)){
foreach( $meta_values as $key => $meta_value ){
$fields[$key] = $meta_value;
}
}
}
}
return $fields;
}
function get_post_custom($post_id, $orderby='meta_id', $order='ASC'){
global $wpdb;
$table = $wpdb->prefix . "postmeta";
$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 );
if ( !empty($meta_list) ) {
foreach ( $meta_list as $metarow) {
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
$res[$mkey][] = $mval;
}
}
return $res;
}
function get_post_user_custom($post_id, $orderby='meta_id', $order='ASC'){
global $wpdb;
$res = array();
$table = $wpdb->prefix . "postmeta";
$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 );
if ( !empty($meta_list) ) {
foreach ( $meta_list as $metarow) {
if( 0 === strpos($metarow['meta_key'], '_') )
continue;
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
if( array_key_exists($mkey, $res) ){
$cval = $res[$mkey];
$cval = (array)$cval;
$cval[] = $mval;
$res[$mkey] = $cval;
}else{
$res[$mkey] = $mval;
}
}
}
return $res;
}
function get_currency($amount, $symbol_pre = false, $symbol_post = false, $seperator_flag = true ){
global $usces_settings;
$cr = $this->options['system']['currency'];
list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
if( !$seperator_flag ){
$seperator = '';
}
$price = number_format((double)$amount, $decimal, $point, $seperator);//0000652
if( $symbol_pre )
$price = ( usces_is_entity($symbol) ? mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES') : $symbol ) . $price;
if( $symbol_post )
$price = $price . __($code, 'usces');
return $price;
}
function get_currency_code(){
global $usces_settings;
$cr = $this->options['system']['currency'];
list($code, $decimal, $point, $seperator, $symbol) = $usces_settings['currency'][$cr];
return $code;
}
//shortcode-----------------------------------------------------------------------------
function sc_company_name() {
return htmlspecialchars($this->options['company_name']);
}
function sc_zip_code() {
return htmlspecialchars($this->options['zip_code']);
}
function sc_address1() {
return htmlspecialchars($this->options['address1']);
}
function sc_address2() {
return htmlspecialchars($this->options['address2']);
}
function sc_tel_number() {
return htmlspecialchars($this->options['tel_number']);
}
function sc_fax_number() {
return htmlspecialchars($this->options['fax_number']);
}
function sc_inquiry_mail() {
return htmlspecialchars($this->options['inquiry_mail']);
}
function sc_payment() {
$payments = usces_get_system_option( 'usces_payment_method', 'sort' );
$htm = "\n";
foreach ( (array)$payments as $payment ) {
$htm .= "- " . htmlspecialchars($payment['name']) . "
\n";
$htm .= nl2br(htmlspecialchars($payment['explanation'])) . " \n";
}
$htm .= "
\n";
return $htm;
}
function sc_payment_title() {
$payments = $this->options['payment_method'];
$htm = "\n";
foreach ( (array)$payments as $payment ) {
$htm .= "- " . esc_html($payment['name']) . "
\n";
}
$htm .= "
\n";
return $htm;
}
function sc_cod_fee() {
return number_format($this->options['cod_fee']);
}
function sc_start_point() {
return number_format($this->options['start_point']);
}
function sc_postage_privilege() {
if(empty($this->options['postage_privilege']))
return;
return number_format($this->options['postage_privilege']);
}
function sc_shipping_charge() {
//20120710ysk start 0000472
$entry = $this->cart->get_entry();
$country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
//20120710ysk end
$arr = array();
foreach ( (array)$this->options['shipping_charge'] as $charges ) {
//20120710ysk start 0000472
//foreach ( (array)$charges['value'] as $value ) {
foreach ( (array)$charges[$country] as $value ) {
//20120710ysk end
$arr[] = $value;
}
}
sort($arr);
$min = $arr[0];
rsort($arr);
$max = $arr[0];
if($min == $max){
$res = number_format($min);
}else{
$res = number_format($min) . __(' - ', 'usces') . number_format($max);
}
return $res;
}
function sc_site_url() {
return get_option('home');
}
function sc_button_to_cart($atts) {
extract(shortcode_atts(array(
'item' => '',
'sku' => '',
'value' => __('to the cart', 'usces'),
'force' => 0,
'quant' => 0,
'opt' => 1,
), $atts));
$post_id = $this->get_ID_byItemName($item);
$datas = $this->get_skus( $post_id, 'code' );
$zaikonum = $datas[$sku]['stocknum'];
$zaiko = $datas[$sku]['stock'];
$gptekiyo = $datas[$sku]['gp'];
$skuPrice = $datas[$sku]['price'];
$sku_enc = urlencode($sku);
$mats = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
if( ! $this->is_item_zaiko( $post_id, $sku ) ){
return '' . esc_html($this->zaiko_status[$zaiko]) . '
';
}
$html = "";
$html .= '' . usces_singleitem_error_message($post_id, $sku, 'return') . '
'."\n";
return $html;
}
function filter_itemPage($content){
global $post;
$html = '';
if( ($post->post_mime_type != 'item' || !is_single()) ) return $content;
if( post_password_required($post) ) return $content;
$temp_path = apply_filters('usces_template_path_single_item', USCES_PLUGIN_DIR . '/templates/single_item.php');
include( $temp_path );
$content = apply_filters('usces_filter_itemPage', $html, $post->ID);
return $content;
}
function filter_cartContent($content) {
global $post;
$html = '';
switch($this->page){
case 'cart':
$temp_path = apply_filters('usces_template_path_cart', USCES_PLUGIN_DIR . '/templates/cart/cart.php');
include( $temp_path );
break;
case 'customer':
$temp_path = apply_filters('usces_template_path_customer', USCES_PLUGIN_DIR . '/templates/cart/customer_info.php');
include( $temp_path );
break;
case 'delivery':
$temp_path = apply_filters('usces_template_path_delivery', USCES_PLUGIN_DIR . '/templates/cart/delivery_info.php');
include( $temp_path );
break;
case 'confirm':
$temp_path = apply_filters('usces_template_path_confirm', USCES_PLUGIN_DIR . '/templates/cart/confirm.php');
include( $temp_path );
break;
case 'ordercompletion':
$temp_path = apply_filters('usces_template_path_ordercompletion', USCES_PLUGIN_DIR . '/templates/cart/completion.php');
include( $temp_path );
break;
case 'error':
$temp_path = apply_filters('usces_template_path_carterror', USCES_PLUGIN_DIR . '/templates/cart/error.php');
include( $temp_path );
break;
case 'maintenance':
$temp_path = apply_filters('usces_template_path_maintenance', USCES_PLUGIN_DIR . '/templates/cart/maintenance.php');
include( $temp_path );
break;
case 'search_item':
$temp_path = apply_filters('usces_template_path_search_item', USCES_PLUGIN_DIR . '/templates/search_item.php');
include( $temp_path );
break;
case 'wp_search':
if($post->post_mime_type == 'item'){
$temp_path = apply_filters('usces_template_path_wp_search', USCES_PLUGIN_DIR . '/templates/wp_search_item.php');
include( $temp_path );
}else{
$html = $content;
}
break;
default:
$html = $content;
}
if( $this->use_ssl && ($this->is_cart_or_member_page($_SERVER['REQUEST_URI']) || $this->is_inquiry_page($_SERVER['REQUEST_URI'])) )
$html = str_replace('src="'.get_option('siteurl'), 'src="'.USCES_SSL_URL_ADMIN, $html);
$html = apply_filters('usces_filter_cartContent', $html);
$content = $html;
remove_filter('the_title', array($this, 'filter_cartTitle'));
return $content;
}
function filter_cartTitle($title) {
if( $title == 'Cart' || $title == __('Cart', 'usces') ){
switch($this->page){
case 'cart':
$newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces'));
break;
case 'customer':
$newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces'));
break;
case 'delivery':
$newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces'));
break;
case 'confirm':
$newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces'));
break;
case 'ordercompletion':
$newtitle = apply_filters('usces_filter_title_ordercompletion', __('Completion', 'usces'));
break;
case 'error':
$newtitle = apply_filters('usces_filter_title_carterror', __('Error', 'usces'));
break;
case 'search_item':
$newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces'));
break;
case 'maintenance':
$newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces'));
break;
case 'login':
$newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
break;
default:
$newtitle = apply_filters('usces_filter_title_cart_default', $title);
}
}else{
$newtitle = $title;
}
$newtitle = apply_filters('usces_filter_cartTitle', $newtitle);
return $newtitle;
}
function action_cartFilter(){
add_filter('the_title', array($this, 'filter_cartTitle'),20);
add_filter('the_content', array($this, 'filter_cartContent'),20);
}
function action_search_item(){
include(TEMPLATEPATH . '/page.php');
exit;
}
function filter_memberContent($content) {
global $post;
$html = '';
if($this->options['membersystem_state'] == 'activate'){
if( $this->is_member_logged_in() ) {
$member_regmode = 'editmemberform';
$temp_path = apply_filters('usces_template_path_member', USCES_PLUGIN_DIR . '/templates/member/member.php');
include( $temp_path );
} else {
switch($this->page){
case 'login':
$temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
include( $temp_path );
break;
case 'lostmemberpassword':
$temp_path = apply_filters('usces_template_path_lostpassword', USCES_PLUGIN_DIR . '/templates/member/lostpassword.php');
include( $temp_path );
break;
case 'changepassword':
$temp_path = apply_filters('usces_template_path_changepassword', USCES_PLUGIN_DIR . '/templates/member/changepassword.php');
include( $temp_path );
break;
case 'newcompletion':
case 'editcompletion':
case 'lostcompletion':
case 'changepasscompletion':
$temp_path = apply_filters('usces_template_path_membercompletion', USCES_PLUGIN_DIR . '/templates/member/completion.php');
include( $temp_path );
break;
case 'newmemberform':
$member_form_title = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
$member_regmode = 'newmemberform';
$temp_path = apply_filters('usces_template_path_member_form', USCES_PLUGIN_DIR . '/templates/member/member_form.php');
include( $temp_path );
break;
default:
$temp_path = apply_filters('usces_template_path_login', USCES_PLUGIN_DIR . '/templates/member/login.php');
include( $temp_path );
}
}
}else{
$html .= "只今会員サービスは提供いたしておりません。
";
}
$content = $html;
remove_filter('the_title', array($this, 'filter_memberTitle'));
return $content;
}
function filter_memberTitle($title) {
if( $this->options['membersystem_state'] == 'activate' && ($title == 'Member' || $title == __('Membership', 'usces')) ){
switch($this->page){
case 'login':
$newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces'));
break;
case 'newmemberform':
$newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces'));
break;
case 'lostmemberpassword':
$newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces'));
break;
case 'changepassword':
$newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces'));
break;
case 'newcompletion':
case 'editcompletion':
case 'lostcompletion':
case 'changepasscompletion':
$newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Completion', 'usces'));
break;
case 'error':
$newtitle = apply_filters('usces_filter_title_membererror', __('Error', 'usces'));
break;
default:
$newtitle = apply_filters('usces_filter_title_member_default', $title);
}
}else{
$newtitle = $title;
}
$newtitle = apply_filters('usces_filter_memberTitle', $newtitle);
return $newtitle;
}
function action_memberFilter(){
add_filter('the_title', array($this, 'filter_memberTitle'),20);
add_filter('the_content', array($this, 'filter_memberContent'),20);
}
function filter_usces_cart_css(){
$path = get_stylesheet_directory_uri() . '/usces_cart.css';
return $path;
}
function filter_divide_item(){
global $wp_query;
if( ($this->options['divide_item'] && !is_category() && !is_search() && !is_singular() && !is_admin()) ){
$ids = $this->getItemIds( 'front' );
$wp_query->query_vars['post__not_in'] = $ids;
}
if( is_admin() ){
$ids = $this->getItemIds( 'back' );
//$wp_query->query_vars['category__not_in'] = array(USCES_ITEM_CAT_PARENT_ID);
$wp_query->query_vars['post__not_in'] = $ids;
}
do_action( 'usces_action_divide_item');
}
function load_upload_template(){
$post_id = $_POST['post_id'];
$file = 'upload_template01.php';
include(TEMPLATEPATH . '/' . $file);
exit;
}
function filter_itemimg_anchor_rel($html){
if( is_single() ){
$str = ' rel="' . $this->options['itemimg_anchor_rel'] . '"';
}else{
$str = '';
}
return $html . $str;
}
function filter_permalink( $link ) {
if(false !== strpos('?page_id=4', $link) || false !== strpos('?page_id=3', $link) || false !== strpos('usces-cart', $link) || false !== strpos('usces-member', $link) )
$link = str_replace('http://', 'https://', $link);
return $link;
}
function filter_cart_page_header($html){
if( !empty($this->options['cart_page_data']['header']['cart']) ){
$html = $this->options['cart_page_data']['header']['cart'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_cart_page_footer($html){
if( !empty($this->options['cart_page_data']['footer']['cart']) ){
$html = $this->options['cart_page_data']['footer']['cart'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_customer_page_header($html){
if( !empty($this->options['cart_page_data']['header']['customer']) ){
$html = $this->options['cart_page_data']['header']['customer'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_customer_page_footer($html){
if( !empty($this->options['cart_page_data']['footer']['customer']) ){
$html = $this->options['cart_page_data']['footer']['customer'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_delivery_page_header($html){
if( !empty($this->options['cart_page_data']['header']['delivery']) ){
$html = $this->options['cart_page_data']['header']['delivery'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_delivery_page_footer($html){
if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
$html = $this->options['cart_page_data']['footer']['delivery'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_confirm_page_header($html){
if( !empty($this->options['cart_page_data']['header']['confirm']) ){
$html = $this->options['cart_page_data']['header']['confirm'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_confirm_page_footer($html){
if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
$html = $this->options['cart_page_data']['footer']['confirm'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_cartcompletion_page_header($html){
if( !empty($this->options['cart_page_data']['header']['completion']) ){
$html = $this->options['cart_page_data']['header']['completion'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_cartcompletion_page_footer($html){
if( !empty($this->options['cart_page_data']['footer']['completion']) ){
$html = $this->options['cart_page_data']['footer']['completion'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_login_page_header($html){
if( !empty($this->options['member_page_data']['header']['login']) ){
$html = $this->options['member_page_data']['header']['login'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_login_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['login']) ){
$html = $this->options['member_page_data']['footer']['login'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_newmember_page_header($html){
if( !empty($this->options['member_page_data']['header']['newmember']) ){
$html = $this->options['member_page_data']['header']['newmember'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_newmember_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['newmember']) ){
$html = $this->options['member_page_data']['footer']['newmember'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_newpass_page_header($html){
if( !empty($this->options['member_page_data']['header']['newpass']) ){
$html = $this->options['member_page_data']['header']['newpass'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_newpass_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['newpass']) ){
$html = $this->options['member_page_data']['footer']['newpass'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_changepass_page_header($html){
if( !empty($this->options['member_page_data']['header']['changepass']) ){
$html = $this->options['member_page_data']['header']['changepass'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_changepass_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['changepass']) ){
$html = $this->options['member_page_data']['footer']['changepass'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_memberinfo_page_header($html){
if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
$html = $this->options['member_page_data']['header']['memberinfo'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_memberinfo_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
$html = $this->options['member_page_data']['footer']['memberinfo'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_membercompletion_page_header($html){
if( !empty($this->options['member_page_data']['header']['completion']) ){
$html = $this->options['member_page_data']['header']['completion'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function filter_membercompletion_page_footer($html){
if( !empty($this->options['member_page_data']['footer']['completion']) ){
$html = $this->options['member_page_data']['footer']['completion'];
}
return do_shortcode( stripslashes(nl2br($html)) );
}
function action_cart_page_header(){
if( !empty($this->options['cart_page_data']['header']['cart']) ){
$html = $this->options['cart_page_data']['header']['cart'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_cart_page_footer(){
if( !empty($this->options['cart_page_data']['footer']['cart']) ){
$html = $this->options['cart_page_data']['footer']['cart'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_customer_page_header(){
if( !empty($this->options['cart_page_data']['header']['customer']) ){
$html = $this->options['cart_page_data']['header']['customer'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_customer_page_footer(){
if( !empty($this->options['cart_page_data']['footer']['customer']) ){
$html = $this->options['cart_page_data']['footer']['customer'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_delivery_page_header(){
if( !empty($this->options['cart_page_data']['header']['delivery']) ){
$html = $this->options['cart_page_data']['header']['delivery'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_delivery_page_footer(){
if( !empty($this->options['cart_page_data']['footer']['delivery']) ){
$html = $this->options['cart_page_data']['footer']['delivery'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_confirm_page_header(){
if( !empty($this->options['cart_page_data']['header']['confirm']) ){
$html = $this->options['cart_page_data']['header']['confirm'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_confirm_page_footer(){
if( !empty($this->options['cart_page_data']['footer']['confirm']) ){
$html = $this->options['cart_page_data']['footer']['confirm'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_cartcompletion_page_header(){
if( !empty($this->options['cart_page_data']['header']['completion']) ){
$html = $this->options['cart_page_data']['header']['completion'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_cartcompletion_page_footer(){
if( !empty($this->options['cart_page_data']['footer']['completion']) ){
$html = $this->options['cart_page_data']['footer']['completion'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_login_page_header(){
if( !empty($this->options['member_page_data']['header']['login']) ){
$html = $this->options['member_page_data']['header']['login'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_login_page_footer(){
if( !empty($this->options['member_page_data']['footer']['login']) ){
$html = $this->options['member_page_data']['footer']['login'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_newmember_page_header(){
if( !empty($this->options['member_page_data']['header']['newmember']) ){
$html = $this->options['member_page_data']['header']['newmember'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_newmember_page_footer(){
if( !empty($this->options['member_page_data']['footer']['newmember']) ){
$html = $this->options['member_page_data']['footer']['newmember'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_newpass_page_header(){
if( !empty($this->options['member_page_data']['header']['newpass']) ){
$html = $this->options['member_page_data']['header']['newpass'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_newpass_page_footer(){
if( !empty($this->options['member_page_data']['footer']['newpass']) ){
$html = $this->options['member_page_data']['footer']['newpass'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_changepass_page_header(){
if( !empty($this->options['member_page_data']['header']['changepass']) ){
$html = $this->options['member_page_data']['header']['changepass'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_changepass_page_footer(){
if( !empty($this->options['member_page_data']['footer']['changepass']) ){
$html = $this->options['member_page_data']['footer']['changepass'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_memberinfo_page_header(){
if( !empty($this->options['member_page_data']['header']['memberinfo']) ){
$html = $this->options['member_page_data']['header']['memberinfo'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_memberinfo_page_footer(){
if( !empty($this->options['member_page_data']['footer']['memberinfo']) ){
$html = $this->options['member_page_data']['footer']['memberinfo'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_membercompletion_page_header(){
if( !empty($this->options['member_page_data']['header']['completion']) ){
$html = $this->options['member_page_data']['header']['completion'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
function action_membercompletion_page_footer(){
if( !empty($this->options['member_page_data']['footer']['completion']) ){
$html = $this->options['member_page_data']['footer']['completion'];
echo do_shortcode( stripslashes(nl2br($html)) );
}
}
}
?>