| 1 |
<?php |
| 2 |
|
| 3 |
function usces_filter_get_post_metadata( $null, $object_id, $meta_key, $single){ |
| 4 |
global $wpdb; |
| 5 |
$query = $wpdb->prepare("SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = %s", $object_id, $meta_key); |
| 6 |
$metas = $wpdb->get_col($query); |
| 7 |
if ( !empty($metas) ) { |
| 8 |
return array_map('maybe_unserialize', $metas); |
| 9 |
} |
| 10 |
|
| 11 |
if ($single) |
| 12 |
return ''; |
| 13 |
else |
| 14 |
return array(); |
| 15 |
} |
| 16 |
|
| 17 |
function usces_action_reg_orderdata( $args ){ |
| 18 |
global $wpdb, $usces; |
| 19 |
$options = get_option('usces'); |
| 20 |
extract($args); |
| 21 |
|
| 22 |
/* Register decorated order id ***************************************************/ |
| 23 |
$olimit = 0; |
| 24 |
if( ! $options['system']['dec_orderID_flag'] ){ |
| 25 |
$dec_order_id = str_pad($order_id, $options['system']['dec_orderID_digit'], "0", STR_PAD_LEFT); |
| 26 |
}else{ |
| 27 |
$otable = $wpdb->prefix . 'usces_order_meta'; |
| 28 |
while( $ukey = usces_get_key( $options['system']['dec_orderID_digit'] ) ){ |
| 29 |
$ores = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $otable WHERE meta_key = %s AND meta_value = %s LIMIT 1", 'dec_order_id', $ukey)); |
| 30 |
if( !$ores || 100 < $olimit ) |
| 31 |
break; |
| 32 |
$olimit++; |
| 33 |
} |
| 34 |
$dec_order_id = $ukey; |
| 35 |
} |
| 36 |
$dec_order_id = apply_filters( 'usces_filter_dec_order_id_prefix', $options['system']['dec_orderID_prefix'], $args ) . apply_filters( 'usces_filter_dec_order_id', $dec_order_id, $args ); |
| 37 |
|
| 38 |
if( 100 < $olimit ){ |
| 39 |
$usces->set_order_meta_value('dec_order_id', uniqid(), $order_id); |
| 40 |
}else{ |
| 41 |
$usces->set_order_meta_value('dec_order_id', $dec_order_id, $order_id); |
| 42 |
} |
| 43 |
unset($dec_order_id, $otable, $olimit, $ukey, $ores); |
| 44 |
/***********************************************************************************/ |
| 45 |
} |
| 46 |
|
| 47 |
function usces_action_reg_orderdata_stocks($args){ |
| 48 |
global $usces; |
| 49 |
extract($args); |
| 50 |
|
| 51 |
foreach($cart as $cartrow){ |
| 52 |
$sku = urldecode($cartrow['sku']); |
| 53 |
$zaikonum = $usces->getItemZaikoNum( $cartrow['post_id'], $sku ); |
| 54 |
if($zaikonum == '') continue; |
| 55 |
$zaikonum = $zaikonum - $cartrow['quantity']; |
| 56 |
$usces->updateItemZaikoNum( $cartrow['post_id'], $sku, $zaikonum ); |
| 57 |
if($zaikonum <= 0) $usces->updateItemZaiko( $cartrow['post_id'], $sku, 2 ); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
function usces_action_ogp_meta(){ |
| 62 |
global $usces, $post; |
| 63 |
if( empty($post) || !$usces->is_item($post) || !is_single() ) |
| 64 |
return; |
| 65 |
|
| 66 |
$item = $usces->get_item( $post->ID ); |
| 67 |
$pictid = $usces->get_mainpictid($item['itemCode']); |
| 68 |
$image_info = wp_get_attachment_image_src( $pictid, 'thumbnail' ); |
| 69 |
|
| 70 |
$ogs['title'] = $item['itemName']; |
| 71 |
$ogs['type'] = 'product'; |
| 72 |
$ogs['description'] = strip_tags( get_the_title($post->ID) ); |
| 73 |
$ogs['url'] = get_permalink($post->ID); |
| 74 |
$ogs['image'] = $image_info[0]; |
| 75 |
$ogs['site_name'] = get_option('blogname'); |
| 76 |
$ogs = apply_filters( 'usces_filter_ogp_meta', $ogs, $post->ID ); |
| 77 |
|
| 78 |
foreach( $ogs as $key => $value ){ |
| 79 |
echo "\n" . '<meta property="og:' . $key . '" content="' . $value . '">'; |
| 80 |
} |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
function wc_purchase_nonce($html, $payments, $acting_flag, $rand, $purchase_disabled){ |
| 85 |
if( strpos($html, 'wc_nonce') || !in_array( $payments['settlement'], array('COD', 'installment', 'transferAdvance', 'transferDeferred', 'acting_zeus_card')) ) |
| 86 |
return $html; |
| 87 |
$wc_nonce = wp_create_nonce('wc_purchase_nonce'); |
| 88 |
$html .= wp_nonce_field( 'wc_purchase_nonce', 'wc_nonce', false, false )."\n"; |
| 89 |
return $html; |
| 90 |
} |
| 91 |
|
| 92 |
function wc_purchase_nonce_check(){ |
| 93 |
global $usces; |
| 94 |
$entry = $usces->cart->get_entry(); |
| 95 |
if( !isset($entry['order']['payment_name']) || empty($entry['order']['payment_name']) ){ |
| 96 |
wp_redirect( home_url() ); |
| 97 |
exit; |
| 98 |
} |
| 99 |
|
| 100 |
$payments = usces_get_payments_by_name($entry['order']['payment_name']); |
| 101 |
if( !in_array( $payments['settlement'], array('COD', 'installment', 'transferAdvance', 'transferDeferred' )) ) |
| 102 |
return true; |
| 103 |
|
| 104 |
$nonce = isset($_REQUEST['wc_nonce']) ? $_REQUEST['wc_nonce'] : ''; |
| 105 |
if( wp_verify_nonce($nonce, 'wc_purchase_nonce') ) |
| 106 |
return true; |
| 107 |
|
| 108 |
wp_redirect( home_url() ); |
| 109 |
exit; |
| 110 |
} |
| 111 |
|
| 112 |
function wc_mkdir(){ |
| 113 |
global $usces; |
| 114 |
if( is_admin() && !WCUtils::is_blank($usces->options['logs_path']) && false !== strpos($_SERVER['SERVER_SOFTWARE'],'Apache')){ |
| 115 |
$welcart_file_dir = $usces->options['logs_path'] . '/welcart'; |
| 116 |
$logs_dir = $welcart_file_dir . '/logs'; |
| 117 |
if( !file_exists($welcart_file_dir) ){ |
| 118 |
$res = @mkdir($welcart_file_dir, 0700); |
| 119 |
if(!$res){ |
| 120 |
$msg = '<div class="error"><p>下記のディレクトリーを、所有� |
| 121 |
:' . get_current_user() . '、パーミッション:700 で作成してください。 <br />' . $welcart_file_dir . '</p></div>'; |
| 122 |
add_action('admin_notices', $c = create_function('', 'echo "' . addcslashes($msg,'"') . '";')); |
| 123 |
} |
| 124 |
} |
| 125 |
$stat = stat($welcart_file_dir); |
| 126 |
print_r($stat); |
| 127 |
die(); |
| 128 |
if( is_writable($welcart_file_dir) ){ |
| 129 |
$res = @mkdir($logs_dir, 0700); |
| 130 |
if(!$res){ |
| 131 |
$msg = '<div class="error"><p>下記のディレクトリーを、所有� |
| 132 |
:' . get_current_user() . '、パーミッション:700 で作成してください。 <br />' . $welcart_file_dir . '</p></div>'; |
| 133 |
add_action('admin_notices', $c = create_function('', 'echo "' . addcslashes($msg,'"') . '";')); |
| 134 |
} |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
function usces_reg_ordercartdata( $args ){ |
| 140 |
global $usces, $wpdb; |
| 141 |
/* |
| 142 |
$args = array( |
| 143 |
'cart'=>$cart, 'entry'=>$entry, 'order_id'=>$order_id, 'member_id'=>$member['ID'], |
| 144 |
'payments'=>$set, 'charging_type'=>$charging_type); |
| 145 |
*/ |
| 146 |
extract($args); |
| 147 |
|
| 148 |
if( !$order_id ) |
| 149 |
return; |
| 150 |
|
| 151 |
$cart_table = $wpdb->prefix . "usces_ordercart"; |
| 152 |
$cart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; |
| 153 |
foreach( $cart as $row_index => $value ){ |
| 154 |
$item_code = get_post_meta( $value['post_id'], '_itemCode', true); |
| 155 |
$item_name = get_post_meta( $value['post_id'], '_itemName', true); |
| 156 |
$skus = $usces->get_skus($value['post_id'], 'code'); |
| 157 |
$sku_encoded = $value['sku']; |
| 158 |
$skucode = urldecode($value['sku']); |
| 159 |
$sku = $skus[$skucode]; |
| 160 |
if( empty($usces->option['tax_rate']) ){ |
| 161 |
$tax = 0; |
| 162 |
|
| 163 |
}else{ |
| 164 |
$tax = ($value['price'] * $value['quantity']) * $usces->options['tax_rate'] / 100; |
| 165 |
$cr = $usces->options['system']['currency']; |
| 166 |
$decimal = $usces_settings['currency'][$cr][1]; |
| 167 |
$decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT ); |
| 168 |
switch( $usces->options['tax_method'] ){ |
| 169 |
case 'cutting': |
| 170 |
$tax = floor($tax*$decipad)/$decipad; |
| 171 |
break; |
| 172 |
case 'bring': |
| 173 |
$tax = ceil($tax*$decipad)/$decipad; |
| 174 |
break; |
| 175 |
case 'rounding': |
| 176 |
if( 0 < $decimal ){ |
| 177 |
$tax = round($tax, (int)$decimal); |
| 178 |
}else{ |
| 179 |
$tax = round($tax); |
| 180 |
} |
| 181 |
break; |
| 182 |
} |
| 183 |
} |
| 184 |
$query = $wpdb->prepare("INSERT INTO $cart_table |
| 185 |
( |
| 186 |
order_id, row_index, post_id, item_code, item_name, |
| 187 |
sku_code, sku_name, cprice, price, quantity, |
| 188 |
unit, tax, destination_id, cart_serial |
| 189 |
) VALUES ( |
| 190 |
%d, %d, %d, %s, %s, |
| 191 |
%s, %s, %f, %f, %d, |
| 192 |
%s, %d, %d, %s |
| 193 |
)", |
| 194 |
$order_id, $row_index, $value['post_id'], $item_code, $item_name, |
| 195 |
$skucode, $sku['name'], $sku['cprice'], $value['price'], $value['quantity'], |
| 196 |
$sku['unit'], $tax, NULL, $value['serial'] |
| 197 |
); |
| 198 |
$wpdb->query($query); |
| 199 |
|
| 200 |
$cart_id = $wpdb->insert_id ; |
| 201 |
$opt_fields = usces_get_opts($value['post_id'], 'name'); |
| 202 |
if($value['options']){ |
| 203 |
|
| 204 |
foreach((array)$value['options'] as $okey => $ovalue){ |
| 205 |
|
| 206 |
$okey = urldecode($okey); |
| 207 |
$means = $opt_fields[$okey]['means']; |
| 208 |
|
| 209 |
if( 3 == $means ){ |
| 210 |
|
| 211 |
if( '' == $ovalue ) { |
| 212 |
$ovalue = $ovalue; |
| 213 |
} else { |
| 214 |
$ovalue = urldecode($ovalue); |
| 215 |
} |
| 216 |
|
| 217 |
}elseif( 4 == $means ){ |
| 218 |
|
| 219 |
if(is_array($ovalue)) { |
| 220 |
|
| 221 |
$temp = array(); |
| 222 |
foreach( $ovalue as $v ){ |
| 223 |
$temp[] = urldecode($v); |
| 224 |
} |
| 225 |
$ovalue = serialize($temp); |
| 226 |
|
| 227 |
} elseif( '' == $ovalue ) { |
| 228 |
|
| 229 |
$ovalue = $ovalue; |
| 230 |
|
| 231 |
} else { |
| 232 |
|
| 233 |
$ovalue = urldecode($ovalue); |
| 234 |
|
| 235 |
} |
| 236 |
|
| 237 |
}else{ |
| 238 |
|
| 239 |
if(is_array($ovalue)) { |
| 240 |
$temp = array(); |
| 241 |
foreach( $ovalue as $k => $v ){ |
| 242 |
$temp[$k] = urldecode($v); |
| 243 |
} |
| 244 |
$ovalue = serialize($temp); |
| 245 |
} else { |
| 246 |
$ovalue = urldecode($ovalue); |
| 247 |
} |
| 248 |
|
| 249 |
} |
| 250 |
$oquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 251 |
( cart_id, meta_type, meta_key, meta_value ) VALUES (%d, %s, %s, %s)", |
| 252 |
$cart_id, 'option', $okey, $ovalue |
| 253 |
); |
| 254 |
$wpdb->query($oquery); |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
if( $value['advance'] ) { |
| 259 |
foreach( (array)$value['advance'] as $akey => $avalue ) { |
| 260 |
$advance = maybe_unserialize( $avalue ); |
| 261 |
if( is_array($advance) ) { |
| 262 |
$post_id = $value['post_id']; |
| 263 |
if( isset($advance[$post_id][$sku_encoded]) && is_array( $advance[$post_id][$sku_encoded] ) ) { |
| 264 |
$akeys = array_keys( $advance[$post_id][$sku_encoded] ); |
| 265 |
foreach( (array)$akeys as $akey ) { |
| 266 |
$avalue = serialize( $advance[$post_id][$sku_encoded][$akey] ); |
| 267 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 268 |
( cart_id, meta_type, meta_key, meta_value ) VALUES ( %d, 'advance', %s, %s )", |
| 269 |
$cart_id, $akey, $avalue |
| 270 |
); |
| 271 |
$wpdb->query( $aquery ); |
| 272 |
} |
| 273 |
} else { |
| 274 |
$akeys = array_keys( $advance ); |
| 275 |
$akey = ( empty($akeys[0]) ) ? 'advance' : $akeys[0]; |
| 276 |
$avalue = serialize( $advance ); |
| 277 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 278 |
( cart_id, meta_type, meta_key, meta_value ) VALUES ( %d, 'advance', %s, %s )", |
| 279 |
$cart_id, $akey, $avalue |
| 280 |
); |
| 281 |
$wpdb->query( $aquery ); |
| 282 |
} |
| 283 |
} else { |
| 284 |
$avalue = urldecode( $avalue ); |
| 285 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 286 |
( cart_id, meta_type, meta_key, meta_value ) VALUES ( %d, 'advance', %s, %s )", |
| 287 |
$cart_id, $akey, $avalue |
| 288 |
); |
| 289 |
$wpdb->query( $aquery ); |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
do_action( 'usces_action_reg_ordercart_row', $cart_id, $row_index, $value, $args ); |
| 295 |
} |
| 296 |
} |
| 297 |
function fiter_mainTitle($title, $sep){ |
| 298 |
global $usces; |
| 299 |
|
| 300 |
if( empty($title) ){ |
| 301 |
$newtitle = $title; |
| 302 |
}else{ |
| 303 |
$title = trim( str_replace( $sep, '', $title ) ); |
| 304 |
switch($usces->page){ |
| 305 |
case 'cart': |
| 306 |
$newtitle = apply_filters('usces_filter_title_cart', __('In the cart', 'usces')); |
| 307 |
break; |
| 308 |
|
| 309 |
case 'customer': |
| 310 |
$newtitle = apply_filters('usces_filter_title_customer', __('Customer Information', 'usces')); |
| 311 |
break; |
| 312 |
|
| 313 |
case 'delivery': |
| 314 |
$newtitle = apply_filters('usces_filter_title_delivery', __('Shipping / Payment options', 'usces')); |
| 315 |
break; |
| 316 |
|
| 317 |
case 'confirm': |
| 318 |
$newtitle = apply_filters('usces_filter_title_confirm', __('Confirmation', 'usces')); |
| 319 |
break; |
| 320 |
|
| 321 |
case 'ordercompletion': |
| 322 |
$newtitle = apply_filters('usces_filter_title_ordercompletion', __('Order Complete', 'usces')); |
| 323 |
break; |
| 324 |
|
| 325 |
case 'error': |
| 326 |
$newtitle = apply_filters('usces_filter_title_error', __('Error', 'usces')); //new fitler name |
| 327 |
break; |
| 328 |
|
| 329 |
case 'search_item': |
| 330 |
$newtitle = apply_filters('usces_filter_title_search_item', __("'AND' search by categories", 'usces')); |
| 331 |
break; |
| 332 |
|
| 333 |
case 'maintenance': |
| 334 |
$newtitle = apply_filters('usces_filter_title_maintenance', __('Under Maintenance', 'usces')); |
| 335 |
break; |
| 336 |
|
| 337 |
case 'login': |
| 338 |
$newtitle = apply_filters('usces_filter_title_login', __('Log-in for members', 'usces')); |
| 339 |
break; |
| 340 |
|
| 341 |
case 'member': |
| 342 |
$newtitle = apply_filters('usces_filter_title_member', __('Membership information', 'usces')); |
| 343 |
break; |
| 344 |
|
| 345 |
case 'newmemberform': |
| 346 |
$newtitle = apply_filters('usces_filter_title_newmemberform', __('New enrollment form', 'usces')); |
| 347 |
break; |
| 348 |
|
| 349 |
case 'newcompletion': |
| 350 |
$newtitle = apply_filters('usces_filter_title_newcompletion', __('New enrollment complete', 'usces'));//new fitler name |
| 351 |
break; |
| 352 |
|
| 353 |
case 'editmemberform': |
| 354 |
$newtitle = apply_filters('usces_filter_title_editmemberform', __('Member information editing', 'usces'));//new fitler name |
| 355 |
break; |
| 356 |
|
| 357 |
case 'editcompletion': |
| 358 |
$newtitle = apply_filters('usces_filter_title_editcompletion', __('Membership information change is completed', 'usces'));//new fitler name |
| 359 |
break; |
| 360 |
|
| 361 |
case 'lostmemberpassword': |
| 362 |
$newtitle = apply_filters('usces_filter_title_lostmemberpassword', __('The new password acquisition', 'usces')); |
| 363 |
break; |
| 364 |
|
| 365 |
case 'lostcompletion': |
| 366 |
$newtitle = apply_filters('usces_filter_title_lostcompletion', __('New password procedures for obtaining complete', 'usces'));//new fitler name |
| 367 |
break; |
| 368 |
|
| 369 |
case 'changepassword': |
| 370 |
$newtitle = apply_filters('usces_filter_title_changepassword', __('Change password', 'usces')); |
| 371 |
break; |
| 372 |
|
| 373 |
case 'changepasscompletion': |
| 374 |
$newtitle = apply_filters('usces_filter_title_changepasscompletion', __('Password change is completed', 'usces')); |
| 375 |
break; |
| 376 |
|
| 377 |
default: |
| 378 |
$newtitle = apply_filters('usces_filter_title_main_default', $title);//new fitler name |
| 379 |
} |
| 380 |
$newtitle = $newtitle .' '.$sep.' '; |
| 381 |
} |
| 382 |
return $newtitle; |
| 383 |
} |
| 384 |
|
| 385 |
//Univarsal Analytics( Dashboard ) |
| 386 |
function usces_Universal_trackPageview(){ |
| 387 |
global $usces; |
| 388 |
|
| 389 |
switch($usces->page){ |
| 390 |
case 'cart': |
| 391 |
$push = array(); |
| 392 |
$push[] = "'page' : '/wc_cart'"; |
| 393 |
break; |
| 394 |
|
| 395 |
case 'customer': |
| 396 |
$push = array(); |
| 397 |
$push[] = "'page' : '/wc_customer'"; |
| 398 |
break; |
| 399 |
|
| 400 |
case 'delivery': |
| 401 |
$push = array(); |
| 402 |
$push[] = "'page' : '/wc_delivery'"; |
| 403 |
break; |
| 404 |
|
| 405 |
case 'confirm': |
| 406 |
$push = array(); |
| 407 |
$push[] = "'page' : '/wc_confirm'"; |
| 408 |
break; |
| 409 |
|
| 410 |
case 'ordercompletion': |
| 411 |
$sesdata = $usces->cart->get_entry(); |
| 412 |
$order_id = $sesdata['order']['ID']; |
| 413 |
$data = $usces->get_order_data($order_id, 'direct'); |
| 414 |
$cart = unserialize($data['order_cart']); |
| 415 |
$total_price = $usces->get_total_price( $cart ) + $data['order_discount'] - $data['order_usedpoint']; |
| 416 |
$push =array(); |
| 417 |
$push[] = "'page' : '/wc_ordercompletion'"; |
| 418 |
$push[] = "'require', 'ecommerce', 'ecommerce.js'"; |
| 419 |
$push[] = "'ecommerce:addTransaction', { |
| 420 |
id: '". $order_id ."', |
| 421 |
affiliation: '". get_option('blogname') ."', |
| 422 |
revenue: '". $total_price ."', |
| 423 |
shipping: '". $data['order_shipping_charge'] ."', |
| 424 |
tax: '". $data['order_tax'] ."' }"; |
| 425 |
for( $i=0; $i<count($cart); $i++ ){ |
| 426 |
$cart_row = $cart[$i]; |
| 427 |
$post_id = $cart_row['post_id']; |
| 428 |
$sku = urldecode($cart_row['sku']); |
| 429 |
$quantity = $cart_row['quantity']; |
| 430 |
$itemName = $usces->getItemName($post_id); |
| 431 |
$skuPrice = $cart_row['price']; |
| 432 |
$cats = $usces->get_item_cat_genre_ids( $post_id ); |
| 433 |
if( is_array($cats) ) |
| 434 |
sort($cats); |
| 435 |
$category = ( isset($cats[0]) ) ? get_cat_name($cats[0]): ''; |
| 436 |
|
| 437 |
$push[] = "'ecommerce:addItem', { |
| 438 |
id: '". $order_id ."', |
| 439 |
sku: '". $sku ."', |
| 440 |
name: '". $itemName."', |
| 441 |
category: '". $category."', |
| 442 |
price: '". $skuPrice."', |
| 443 |
quantity: '". $quantity."' }"; |
| 444 |
} |
| 445 |
$push[] = "'ecommerce:send'"; |
| 446 |
break; |
| 447 |
|
| 448 |
case 'error': |
| 449 |
$push = array(); |
| 450 |
$push[] = "'page' : '/wc_error'"; |
| 451 |
break; |
| 452 |
|
| 453 |
case 'search_item': |
| 454 |
$push = array(); |
| 455 |
$push[] = "'page' : '/wc_search_item'"; |
| 456 |
break; |
| 457 |
|
| 458 |
case 'maintenance': |
| 459 |
$push = array(); |
| 460 |
$push[] = "'page' : '/wc_maintenance'"; |
| 461 |
break; |
| 462 |
|
| 463 |
case 'login': |
| 464 |
$push = array(); |
| 465 |
$push[] = "'page' : '/wc_login'"; |
| 466 |
break; |
| 467 |
|
| 468 |
case 'member': |
| 469 |
$push = array(); |
| 470 |
$push[] = "'page' : '/wc_member'"; |
| 471 |
break; |
| 472 |
|
| 473 |
case 'newmemberform': |
| 474 |
$push = array(); |
| 475 |
$push[] = "'page' : '/wc_newmemberform'"; |
| 476 |
break; |
| 477 |
|
| 478 |
case 'newcompletion': |
| 479 |
$push = array(); |
| 480 |
$push[] = "'page' : '/wc_newcompletion'"; |
| 481 |
break; |
| 482 |
|
| 483 |
case 'editmemberform': |
| 484 |
$push = array(); |
| 485 |
$push[] = "'page' : '/wc_editmemberform'"; |
| 486 |
break; |
| 487 |
|
| 488 |
case 'editcompletion': |
| 489 |
$push = array(); |
| 490 |
$push[] = "'page' : '/wc_editcompletion'"; |
| 491 |
break; |
| 492 |
|
| 493 |
case 'lostmemberpassword': |
| 494 |
$push = array(); |
| 495 |
$push[] = "'page' : '/wc_lostmemberpassword'"; |
| 496 |
break; |
| 497 |
|
| 498 |
case 'lostcompletion': |
| 499 |
$push = array(); |
| 500 |
$push[] = "'page' : '/wc_lostcompletion'"; |
| 501 |
break; |
| 502 |
|
| 503 |
case 'changepassword': |
| 504 |
$push = array(); |
| 505 |
$push[] = "'page' : '/wc_changepassword'"; |
| 506 |
break; |
| 507 |
|
| 508 |
case 'changepasscompletion': |
| 509 |
$push = array(); |
| 510 |
$push[] = "'page' : '/wc_changepasscompletion'"; |
| 511 |
break; |
| 512 |
|
| 513 |
default: |
| 514 |
$push = array(); |
| 515 |
break; |
| 516 |
} |
| 517 |
return $push; |
| 518 |
} |
| 519 |
|
| 520 |
//Classic Analytics ( Dashboard ) |
| 521 |
function usces_Classic_trackPageview(){ |
| 522 |
global $usces; |
| 523 |
|
| 524 |
switch($usces->page){ |
| 525 |
case 'cart': |
| 526 |
$push = array(); |
| 527 |
$push = usces_trackPageview_cart($push); |
| 528 |
break; |
| 529 |
|
| 530 |
case 'customer': |
| 531 |
$push = array(); |
| 532 |
$push = usces_trackPageview_customer($push); |
| 533 |
break; |
| 534 |
|
| 535 |
case 'delivery': |
| 536 |
$push = array(); |
| 537 |
$push = usces_trackPageview_delivery($push); |
| 538 |
break; |
| 539 |
|
| 540 |
case 'confirm': |
| 541 |
$push = array(); |
| 542 |
$push = usces_trackPageview_confirm($push); |
| 543 |
break; |
| 544 |
|
| 545 |
case 'ordercompletion': |
| 546 |
$push =array(); |
| 547 |
$push = usces_trackPageview_ordercompletion($push); |
| 548 |
break; |
| 549 |
|
| 550 |
case 'error': |
| 551 |
$push = array(); |
| 552 |
$push = usces_trackPageview_error($push); |
| 553 |
break; |
| 554 |
|
| 555 |
case 'login': |
| 556 |
$push = array(); |
| 557 |
$push = usces_trackPageview_login($push); |
| 558 |
break; |
| 559 |
|
| 560 |
case 'member': |
| 561 |
$push = array(); |
| 562 |
$push = usces_trackPageview_member($push); |
| 563 |
break; |
| 564 |
|
| 565 |
case 'newmemberform': |
| 566 |
$push = array(); |
| 567 |
$push = usces_trackPageview_newmemberform($push); |
| 568 |
break; |
| 569 |
|
| 570 |
case 'newcompletion': |
| 571 |
$push = array(); |
| 572 |
$push = usces_trackPageview_newcompletion($push); |
| 573 |
break; |
| 574 |
|
| 575 |
case 'editmemberform': |
| 576 |
$push = array(); |
| 577 |
$push = usces_trackPageview_editmemberform($push); |
| 578 |
break; |
| 579 |
|
| 580 |
case 'search_item': |
| 581 |
$push = array(); |
| 582 |
$push = usces_trackPageview_search_item($push); |
| 583 |
break; |
| 584 |
|
| 585 |
case 'maintenance': |
| 586 |
case 'editcompletion': |
| 587 |
case 'lostmemberpassword': |
| 588 |
case 'lostcompletion': |
| 589 |
case 'changepassword': |
| 590 |
case 'changepasscompletion': |
| 591 |
default: |
| 592 |
$push = array(); |
| 593 |
break; |
| 594 |
} |
| 595 |
return $push; |
| 596 |
} |
| 597 |
|
| 598 |
//Univarsal Analytics( Yoast ) |
| 599 |
function usces_Universal_trackPageview_by_Yoast($push){ |
| 600 |
global $usces; |
| 601 |
|
| 602 |
foreach($push as $p_key => $p_val){ |
| 603 |
$pos1 = strpos($p_val, "'send'"); |
| 604 |
$pos2 = strpos($p_val, "'pageview'"); |
| 605 |
if( $pos1 !== false && $pos2 !== false ){ |
| 606 |
unset($push[$p_key]); |
| 607 |
} |
| 608 |
} |
| 609 |
switch($usces->page){ |
| 610 |
case 'cart': |
| 611 |
$push[] = "'send', 'pageview', {'page' : '/wc_cart'}"; |
| 612 |
break; |
| 613 |
|
| 614 |
case 'customer': |
| 615 |
$push[] = "'send', 'pageview', {'page' : '/wc_customer'}"; |
| 616 |
break; |
| 617 |
|
| 618 |
case 'delivery': |
| 619 |
$push[] = "'send', 'pageview', {'page' : '/wc_delivery'}"; |
| 620 |
break; |
| 621 |
|
| 622 |
case 'confirm': |
| 623 |
$push[] = "'send', 'pageview', {'page' : '/wc_confirm'}"; |
| 624 |
break; |
| 625 |
|
| 626 |
case 'ordercompletion': |
| 627 |
$sesdata = $usces->cart->get_entry(); |
| 628 |
$order_id = $sesdata['order']['ID']; |
| 629 |
$data = $usces->get_order_data($order_id, 'direct'); |
| 630 |
$cart = unserialize($data['order_cart']); |
| 631 |
$total_price = $usces->get_total_price( $cart ) + $data['order_discount'] - $data['order_usedpoint']; |
| 632 |
$push[] = "'send', 'pageview', {'page' : '/wc_ordercompletion'}"; |
| 633 |
$push[] = "'require', 'ecommerce', 'ecommerce.js'"; |
| 634 |
$push[] = "'ecommerce:addTransaction', { |
| 635 |
id: '". $order_id ."', |
| 636 |
affiliation: '". get_option('blogname') ."', |
| 637 |
revenue: '". $total_price ."', |
| 638 |
shipping: '". $data['order_shipping_charge'] ."', |
| 639 |
tax: '". $data['order_tax'] ."' |
| 640 |
}"; |
| 641 |
for( $i=0; $i<count($cart); $i++ ){ |
| 642 |
$cart_row = $cart[$i]; |
| 643 |
$post_id = $cart_row['post_id']; |
| 644 |
$sku = urldecode($cart_row['sku']); |
| 645 |
$quantity = $cart_row['quantity']; |
| 646 |
$itemName = $usces->getItemName($post_id); |
| 647 |
$skuPrice = $cart_row['price']; |
| 648 |
$cats = $usces->get_item_cat_genre_ids( $post_id ); |
| 649 |
if( is_array($cats) ) |
| 650 |
sort($cats); |
| 651 |
$category = ( isset($cats[0]) ) ? get_cat_name($cats[0]): ''; |
| 652 |
|
| 653 |
$push[] = "'ecommerce:addItem', { |
| 654 |
id: '". $order_id ."', |
| 655 |
sku: '". $sku ."', |
| 656 |
name: '". $itemName."', |
| 657 |
category: '". $category."', |
| 658 |
price: '". $skuPrice."', |
| 659 |
quantity: '". $quantity."' |
| 660 |
}"; |
| 661 |
} |
| 662 |
$push[] = "'ecommerce:send'"; |
| 663 |
break; |
| 664 |
|
| 665 |
case 'error': |
| 666 |
$push[] = "'send', 'pageview', {'page' : '/wc_error'}"; |
| 667 |
break; |
| 668 |
|
| 669 |
case 'search_item': |
| 670 |
$push[] = "'send', 'pageview', {'page' : '/wc_search_item'}"; |
| 671 |
break; |
| 672 |
|
| 673 |
case 'maintenance': |
| 674 |
$push[] = "'send', 'pageview', {'page' : '/wc_maintenance'}"; |
| 675 |
break; |
| 676 |
|
| 677 |
case 'login': |
| 678 |
$push[] = "'send', 'pageview', {'page' : '/wc_login'}"; |
| 679 |
break; |
| 680 |
|
| 681 |
case 'member': |
| 682 |
$push[] = "'send', 'pageview', {'page' : '/wc_member'}"; |
| 683 |
break; |
| 684 |
|
| 685 |
case 'newmemberform': |
| 686 |
$push[] = "'send', 'pageview', {'page' : '/wc_newmemberform'}"; |
| 687 |
break; |
| 688 |
|
| 689 |
case 'newcompletion': |
| 690 |
$push[] = "'send', 'pageview', {'page' : '/wc_newcompletion'}"; |
| 691 |
break; |
| 692 |
|
| 693 |
case 'editmemberform': |
| 694 |
$push[] = "'send', 'pageview', {'page' : '/wc_editmemberform'}"; |
| 695 |
break; |
| 696 |
|
| 697 |
case 'editcompletion': |
| 698 |
$push[] = "'send', 'pageview', {'page' : '/wc_editcompletion'}"; |
| 699 |
break; |
| 700 |
|
| 701 |
case 'lostmemberpassword': |
| 702 |
$push[] = "'send', 'pageview', {'page' : '/wc_lostmemberpassword'}"; |
| 703 |
break; |
| 704 |
|
| 705 |
case 'lostcompletion': |
| 706 |
$push[] = "'send', 'pageview', {'page' : '/wc_lostcompletion'}"; |
| 707 |
break; |
| 708 |
|
| 709 |
case 'changepassword': |
| 710 |
$push[] = "'send', 'pageview', {'page' : '/wc_changepassword'}"; |
| 711 |
break; |
| 712 |
|
| 713 |
case 'changepasscompletion': |
| 714 |
$push[] = "'send', 'pageview', {'page' : '/wc_changepasscompletion'}"; |
| 715 |
break; |
| 716 |
|
| 717 |
default: |
| 718 |
$push[] = "'send', 'pageview'"; |
| 719 |
break; |
| 720 |
} |
| 721 |
return $push; |
| 722 |
} |
| 723 |
|
| 724 |
//Classic Analytics ( Yoast ) |
| 725 |
function usces_Classic_trackPageview_by_Yoast($push){ |
| 726 |
global $usces; |
| 727 |
|
| 728 |
foreach($push as $p_key => $p_val){ |
| 729 |
$pos1 = strpos($p_val, "'_trackPageview"); |
| 730 |
if( $pos1 !== false ){ |
| 731 |
unset($push[$p_key]); |
| 732 |
} |
| 733 |
} |
| 734 |
switch($usces->page){ |
| 735 |
case 'cart': |
| 736 |
$push[] = "'_trackPageview', '/wc_cart'"; |
| 737 |
break; |
| 738 |
|
| 739 |
case 'customer': |
| 740 |
$push[] = "'_trackPageview', '/wc_customer'"; |
| 741 |
break; |
| 742 |
|
| 743 |
case 'delivery': |
| 744 |
$push[] = "'_trackPageview', '/wc_delivery'"; |
| 745 |
break; |
| 746 |
|
| 747 |
case 'confirm': |
| 748 |
$push[] = "'_trackPageview', '/wc_confirm'"; |
| 749 |
break; |
| 750 |
|
| 751 |
case 'ordercompletion': |
| 752 |
global $usces; |
| 753 |
$sesdata = $usces->cart->get_entry(); |
| 754 |
$order_id = $sesdata['order']['ID']; |
| 755 |
$data = $usces->get_order_data($order_id, 'direct'); |
| 756 |
$cart = unserialize($data['order_cart']); |
| 757 |
$total_price = $usces->get_total_price( $cart ) + $data['order_discount'] - $data['order_usedpoint']; |
| 758 |
|
| 759 |
$push[] = "'_trackPageview','/wc_ordercompletion'"; |
| 760 |
$push[] = "'_addTrans', '" . $order_id . "', '" . get_option('blogname') . "', '" . $total_price . "', '" . $data['order_tax'] . "', '" . $data['order_shipping_charge'] . "', '" . $data['order_address1'].$data['order_address2'] . "', '" . $data['order_pref'] . "', '" . get_locale() . "'"; |
| 761 |
for($i=0; $i<count($cart); $i++) { |
| 762 |
$cart_row = $cart[$i]; |
| 763 |
$post_id = $cart_row['post_id']; |
| 764 |
$sku = urldecode($cart_row['sku']); |
| 765 |
$quantity = $cart_row['quantity']; |
| 766 |
$itemName = $usces->getItemName($post_id); |
| 767 |
$skuPrice = $cart_row['price']; |
| 768 |
$cats = $usces->get_item_cat_genre_ids( $post_id ); |
| 769 |
if( is_array($cats) ) |
| 770 |
sort($cats); |
| 771 |
$category = ( isset($cats[0]) ) ? get_cat_name($cats[0]): ''; |
| 772 |
$push[] = "'_addItem', '" . $order_id . "', '" . $sku . "', '" . $itemName . "', '" . $category . "', '" . $skuPrice . "', '" . $quantity . "'"; |
| 773 |
} |
| 774 |
$push[] = "'_trackTrans'"; |
| 775 |
break; |
| 776 |
|
| 777 |
case 'error': |
| 778 |
$push[] = "'_trackPageview', '/wc_error'"; |
| 779 |
break; |
| 780 |
|
| 781 |
case 'login': |
| 782 |
$push[] = "'_trackPageview', '/wc_login'"; |
| 783 |
break; |
| 784 |
|
| 785 |
case 'member': |
| 786 |
$push[] = "'_trackPageview', '/wc_member'"; |
| 787 |
break; |
| 788 |
|
| 789 |
case 'newmemberform': |
| 790 |
$push[] = "'_trackPageview', '/wc_newmemberform'"; |
| 791 |
break; |
| 792 |
|
| 793 |
case 'newcompletion': |
| 794 |
$push[] = "'_trackPageview', '/wc_newcompletion'"; |
| 795 |
break; |
| 796 |
|
| 797 |
case 'editmemberform': |
| 798 |
$push[] = "'_trackPageview', '/wc_editmemberform'"; |
| 799 |
break; |
| 800 |
|
| 801 |
case 'search_item': |
| 802 |
$push[] = "'_trackPageview', '/wc_search_item'"; |
| 803 |
break; |
| 804 |
|
| 805 |
case 'maintenance': |
| 806 |
$push[] = "'_trackPageview', '/wc_maintenance'"; |
| 807 |
break; |
| 808 |
|
| 809 |
case 'editcompletion': |
| 810 |
$push[] = "'_trackPageview', '/wc_editcompletion'"; |
| 811 |
break; |
| 812 |
|
| 813 |
case 'lostmemberpassword': |
| 814 |
$push[] = "'_trackPageview', '/wc_lostmemberpassword'"; |
| 815 |
break; |
| 816 |
|
| 817 |
case 'lostcompletion': |
| 818 |
$push[] = "'_trackPageview', '/wc_lostcompletion'"; |
| 819 |
break; |
| 820 |
|
| 821 |
case 'changepassword': |
| 822 |
$push[] = "'_trackPageview', '/wc_changepassword'"; |
| 823 |
break; |
| 824 |
|
| 825 |
case 'changepasscompletion': |
| 826 |
$push[] = "'_trackPageview', '/wc_changepasscompletion'"; |
| 827 |
break; |
| 828 |
|
| 829 |
default: |
| 830 |
$push[] = "'_trackPageview'"; |
| 831 |
break; |
| 832 |
} |
| 833 |
return $push; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
function usces_use_point_nonce(){ |
| 838 |
wp_nonce_field( 'use_point', 'wc_nonce'); |
| 839 |
} |
| 840 |
|
| 841 |
function usces_post_member_nonce(){ |
| 842 |
wp_nonce_field( 'post_member', 'wc_nonce'); |
| 843 |
} |
| 844 |
|
| 845 |
function usces_order_memo_form_detail_top( $data, $csod_meta ){ |
| 846 |
global $usces; |
| 847 |
|
| 848 |
$order_memo = ''; |
| 849 |
if( !empty($data['ID']) ){ |
| 850 |
$order_memo = $usces->get_order_meta_value('order_memo', $data['ID']); |
| 851 |
} |
| 852 |
$res = '<tr> |
| 853 |
<td class="label border">'. __('Administrator Note', 'usces') .'</td> |
| 854 |
<td colspan="5" class="col1 border memo"> |
| 855 |
<textarea name="order_memo" class="order_memo">'.esc_html($order_memo).'</textarea> |
| 856 |
</td> |
| 857 |
</tr>'; |
| 858 |
echo $res; |
| 859 |
} |
| 860 |
|
| 861 |
function usces_update_order_memo($new_orderdata){ |
| 862 |
global $usces; |
| 863 |
|
| 864 |
$usces->set_order_meta_value('order_memo', $_POST['order_memo'], $new_orderdata->ID); |
| 865 |
} |
| 866 |
|
| 867 |
function usces_action_lostmail_inform(){ |
| 868 |
$mem_mail = urldecode($_REQUEST['mem']); |
| 869 |
$lostkey = urldecode($_REQUEST['key']); |
| 870 |
$html = ' |
| 871 |
<input type="hidden" name="lostmail" value="' . esc_attr($mem_mail) . '" /> |
| 872 |
<input type="hidden" name="lostkey" value="' . esc_attr($lostkey) . '" />' . "\n"; |
| 873 |
echo $html; |
| 874 |
} |
| 875 |
function usces_filter_lostmail_inform($html){ |
| 876 |
$mem_mail = urldecode($_REQUEST['mem']); |
| 877 |
$lostkey = urldecode($_REQUEST['key']); |
| 878 |
$html .= ' |
| 879 |
<input type="hidden" name="lostmail" value="' . esc_attr($mem_mail) . '" /> |
| 880 |
<input type="hidden" name="lostkey" value="' . esc_attr($lostkey) . '" />' . "\n"; |
| 881 |
return $html; |
| 882 |
} |
| 883 |
|
| 884 |
function usces_admin_enqueue_scripts( $hook_suffix ){ |
| 885 |
if( false !== strpos($hook_suffix, 'usc-e-shop') |
| 886 |
|| false !== strpos($hook_suffix, 'welcart') |
| 887 |
|| false !== strpos($hook_suffix, 'usces') |
| 888 |
){ |
| 889 |
$style_jqueryuiUrl = USCES_FRONT_PLUGIN_URL.'/css/jquery/jquery-ui-1.10.3.custom.min.css'; |
| 890 |
wp_enqueue_style( 'jquery-ui-welcart', $style_jqueryuiUrl, array(), '1.10.3', 'all' ); |
| 891 |
} |
| 892 |
} |
| 893 |
|
| 894 |
function admin_settlement_footer(){ |
| 895 |
?> |
| 896 |
<script type="text/javascript"> |
| 897 |
jQuery(function($) { |
| 898 |
ppset = { |
| 899 |
get_key : function( pptype ) { |
| 900 |
|
| 901 |
var defer = $.Deferred(); |
| 902 |
|
| 903 |
$.ajax({ |
| 904 |
url: 'https://paypal-demo.ebay.jp/listeners/welcart/listener.php', |
| 905 |
data: 'paypal=1&type=' + pptype, |
| 906 |
type: 'POST', |
| 907 |
dataType: 'xml', |
| 908 |
cache: false, |
| 909 |
success:defer.resolve, |
| 910 |
error:defer.reject, |
| 911 |
}); |
| 912 |
|
| 913 |
return defer.promise(); |
| 914 |
}, |
| 915 |
|
| 916 |
put_data : function() { |
| 917 |
|
| 918 |
var defer = $.Deferred(); |
| 919 |
|
| 920 |
$.ajax({ |
| 921 |
url: 'https://paypal-demo.ebay.jp/listeners/welcart/listener.php', |
| 922 |
type: 'POST', |
| 923 |
cache: false, |
| 924 |
success:defer.resolve, |
| 925 |
error:defer.reject, |
| 926 |
}); |
| 927 |
|
| 928 |
return defer.promise(); |
| 929 |
} |
| 930 |
}; |
| 931 |
$("#paypal_wpp").click( function(){ |
| 932 |
|
| 933 |
ppset.get_key( 'ppwp' ).then( |
| 934 |
function(data) { |
| 935 |
console.log(data);//debug |
| 936 |
}, |
| 937 |
function(data) { |
| 938 |
console.log(data);//debug |
| 939 |
} |
| 940 |
); |
| 941 |
return false; |
| 942 |
}); |
| 943 |
}); |
| 944 |
</script> |
| 945 |
<?php |
| 946 |
|
| 947 |
} |