getGuidTax(); }else{ echo $usces->getGuidTax(); } } function usces_tax_label( $data = array(), $out = '' ){ global $usces; if( empty($data) || !array_key_exists('order_condition', $data) ){ $tax_mode = $usces->options['tax_mode']; }else{ $condition = maybe_unserialize($data['order_condition']); $tax_mode = isset($condition['tax_mode']) ? $condition['tax_mode'] : $usces->options['tax_mode']; } if( 'exclude' == $tax_mode ){ $label = __('consumption tax', 'usces'); }else{ if( isset($condition['tax_mode']) && !empty($data['ID']) ){ $materials = array( 'total_items_price' => $data['order_item_total_price'], 'discount' => $data['order_discount'], 'shipping_charge' => $data['order_shipping_charge'], 'cod_fee' => $data['order_cod_fee'], ); $label = __('Internal tax', 'usces') . '(' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return') . ')'; }else{ $label = __('Internal tax', 'usces'); } } $label = apply_filters( 'usces_filter_tax_label', $label); if( $out == 'return' ){ return $label; }else{ echo $label; } } function usces_tax( $usces_entries, $out = '' ){ global $usces; if( 'exclude' == $usces->options['tax_mode'] ){ $tax_str = usces_crform($usces_entries['order']['tax'], true, false,'return'); }else{ $materials = array( 'total_items_price' => $usces_entries['order']['total_items_price'], 'discount' => $usces_entries['order']['discount'], 'shipping_charge' => $usces_entries['order']['shipping_charge'], 'cod_fee' => $usces_entries['order']['cod_fee'], ); $tax_str = '(' . usces_crform(usces_internal_tax( $materials, 'return' ), true, false,'return') . ')'; } $tax_str = apply_filters( 'usces_filter_tax', $tax_str); if( $out == 'return' ){ return $tax_str; }else{ echo $tax_str; } } function usces_internal_tax( $materials, $out = '' ){ global $usces, $usces_settings; if( 'products' == $usces->options['tax_target'] ){ $total = $materials['total_items_price'] + $materials['discount']; }else{ $total = $materials['total_items_price'] + $materials['discount'] + $materials['shipping_charge'] + $materials['cod_fee']; } $total = apply_filters( 'usces_filter_internal_tax_total', $total, $materials); $tax = $total * $usces->options['tax_rate'] / 100; $tax = $total - $total / (1 + ($usces->options['tax_rate'] / 100)); $cr = $usces->options['system']['currency']; $decimal = $usces_settings['currency'][$cr][1]; $decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT ); switch( $usces->options['tax_method'] ){ case 'cutting': $tax = floor($tax*$decipad)/$decipad; break; case 'bring': $tax = ceil($tax*$decipad)/$decipad; break; case 'rounding': if( 0 < $decimal ){ $tax = round($tax, (int)$decimal); }else{ $tax = round($tax); } break; } $tax = apply_filters( 'usces_filter_internal_tax', $tax, $materials); if( $out == 'return' ){ return $tax; }else{ echo $tax; } } function usces_currency_symbol( $out = '' ) { global $usces; if( $out == 'return' ){ return $usces->getCurrencySymbol(); }else{ echo esc_html($usces->getCurrencySymbol()); } } function usces_is_error_message() { global $usces; if ( $usces->error_message != '' ) return true; else return false; } function usces_is_item( $post_id = NULL ) { if( NULL == $post_id ){ global $post; }else{ $post = get_post($post_id); } if ( isset($post->post_mime_type) && $post->post_mime_type == 'item' ) return true; else return false; } function usces_the_itemCode( $out = '' ) { global $post; $post_id = $post->ID; $str = get_post_meta($post_id, '_itemCode', true); if( $out == 'return' ){ return $str; }else{ echo esc_html($str); } } function usces_the_itemName( $out = '', $post = NULL ) { if($post == NULL) global $post; $post_id = $post->ID; $str = get_post_meta($post_id, '_itemName', true); if( $out == 'return' ){ return $str; }else{ echo esc_html($str); } } function usces_the_point_rate( $out = '' ){ global $post; $post_id = $post->ID; $str = get_post_meta($post_id, '_itemPointrate', true); $rate = (int)$str; if( $out == 'return' ){ return $rate; }else{ echo esc_html($rate); } } function usces_the_shipment_aim( $out = '' ){ global $post; $post_id = $post->ID; $str = get_post_meta($post_id, '_itemShipping', true); $no = (int)$str; if( 0 === $no ) return; $rules = get_option('usces_shipping_rule'); if( $out == 'return' ){ return $rules[$no]; }else{ echo esc_html($rules[$no]); } } function usces_the_item(){ global $usces, $post; $usces->itemskus = $usces->get_skus($post->ID, 'sort'); $usces->itemopts = usces_get_opts($post->ID, 'sort'); return; } function usces_get_itemMeta($metakey, $post_id, $out = ''){ $str = get_post_meta($post_id, $metakey, true); $value = $str; if( $out == 'return' ){ return $value; }else{ echo esc_html($value); } } function usces_sku_num() { global $usces; return count($usces->itemskus); } function usces_is_skus() { global $usces; if( 0 < count($usces->itemskus) ){ reset($usces->itemskus); $usces->itemsku = array(); return true; }else{ return false; } } function usces_reset_skus() { global $usces; reset($usces->itemskus); } function usces_have_skus() { global $usces; $res_each = each($usces->itemskus); $usces->itemsku = $res_each['value']; if($usces->itemsku) { return true; } else { return false; } } function usces_the_itemSku($out = '') { global $usces; if($out == 'return'){ return $usces->itemsku['code']; }else{ echo esc_attr($usces->itemsku['code']); } } function usces_the_itemPrice($out = '') { global $usces; if($out == 'return'){ return $usces->itemsku['price']; }else{ echo number_format($usces->itemsku['price']); } } function usces_the_itemCprice($out = '') { global $usces; if($out == 'return'){ return $usces->itemsku['cprice']; }else{ echo number_format($usces->itemsku['cprice']); } } function usces_the_itemPriceCr($out = '') { global $usces; $res = esc_html($usces->get_currency($usces->itemsku['price'], true, false )); if($out == 'return'){ return $res; }else{ echo $res; } } function usces_the_itemCpriceCr($out = '') { global $usces; $res = esc_html($usces->get_currency($usces->itemsku['cprice'], true, false )); if($out == 'return'){ return $res; }else{ echo $res; } } function usces_crcode( $out = '' ) { global $usces; $res = esc_html($usces->get_currency_code()); if($out == 'return'){ return $res; }else{ echo __($res, 'usces'); } } function usces_crsymbol( $out = '', $js = NULL ) { global $usces; $res = $usces->getCurrencySymbol(); if( 'js' === $js && '¥' == $res ){ $res = mb_convert_encoding($res, 'UTF-8', 'HTML-ENTITIES'); } if($out == 'return'){ return $res; }else{ echo esc_html($res); } } function usces_the_itemZaiko( $out = '' ) { global $usces; $num = (int)$usces->itemsku['stock']; if( 1 < $num || ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){ $res = $usces->zaiko_status[$num]; }elseif( 1 >= $num && ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){ $res = $usces->zaiko_status[2]; }else{ $res = $usces->zaiko_status[$num]; } if( $out == 'return' ){ return $res; }else{ echo esc_html($res); } } function usces_the_itemZaikoStatus( $out = '' ) { global $usces; if( $out == 'return' ){ return usces_get_itemZaiko( 'name' ); }else{ echo esc_html(usces_get_itemZaiko( 'name' )); } } function usces_get_itemZaiko( $field = 'name', $post_id=NULL, $sku=NULL ) { global $usces; if( empty($sku) ){ $num = (int)$usces->itemsku['stock']; }else{ $skus = $usces->get_skus( $post_id, 'code' ); $num = (int)$skus[$sku]['stock']; } if( 'id' == $field ){ $res = $num; }else{ $res = $usces->zaiko_status[$num]; } return $res; } function usces_the_itemZaikoNum( $out = '' ) { global $usces; $num = $usces->itemsku['stocknum']; if( $out == 'return' ){ return $num; }else{ echo number_format($num); } } function usces_the_itemSkuDisp( $out = '' ) { global $usces; if( $out == 'return' ){ return $usces->itemsku['name']; }else{ echo esc_html($usces->itemsku['name']); } } function usces_the_itemSkuUnit( $out = '' ) { global $usces; if( $out == 'return' ){ return $usces->itemsku['unit']; }else{ echo esc_html($usces->itemsku['unit']); } } function usces_the_firstSku( $out = '' ) { global $post, $usces; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); if($out == 'return'){ return $skus[0]['code']; }else{ echo esc_html($skus[0]['code']); } } function usces_the_firstPrice( $out = '', $post = NULL ) { global $usces; if($post == NULL) global $post; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); if($out == 'return'){ return $skus[0]['price']; }else{ echo number_format($skus[0]['price']); } } function usces_the_firstCprice( $out = '', $post = NULL ) { global $usces; if($post == NULL) global $post; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); if($out == 'return'){ return $skus[0]['cprice']; }else{ echo number_format($skus[0]['cprice']); } } function usces_the_firstPriceCr( $out = '', $post = NULL ) { global $usces; if($post == NULL) global $post; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); $res = esc_html($usces->get_currency($skus[0]['price'], true, false )); if($out == 'return'){ return $res; }else{ echo $res; } } function usces_the_firstCpriceCr( $out = '', $post = NULL ) { global $usces; if($post == NULL) global $post; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); $res = esc_html($usces->get_currency($skus[0]['cprice'], true, false )); if($out == 'return'){ return $res; }else{ echo $res; } } function usces_the_firstZaiko( $out = '' ) { global $post, $usces; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); if($out == 'return'){ return $skus[0]['stock']; }else{ echo esc_html($skus[0]['stock']); } } function usces_the_lastSku( $out = '' ) { global $post, $usces; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); $sku = end($skus); if($out == 'return'){ return $sku['code']; }else{ echo esc_html($sku['code']); } } function usces_the_lastPrice( $out = '' ) { global $post, $usces; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); $sku = end($skus); if($out == 'return'){ return $sku['price']; }else{ echo number_format($sku['price']); } } function usces_the_lastZaiko( $out = '' ) { global $post, $usces; $post_id = $post->ID; $skus = $usces->get_skus( $post_id ); $sku = end($skus); if($out == 'return'){ return $sku['stock']; }else{ echo esc_html($sku['stock']); } } function usces_have_zaiko(){ global $post, $usces; return $usces->is_item_zaiko( $post->ID, $usces->itemsku['code'] ); } function usces_have_zaiko_anyone( $post_id = NULL ){ global $post, $usces; if( NULL == $post_id ) $post_id = $post->ID; $skus = $usces->get_skus($post_id); $status = false; foreach($skus as $sku){ if( (WCUtils::is_blank($sku['stocknum']) || 0 < (int)$sku['stocknum']) && 2 > (int)$sku['stock']) { $status = true; break; } } return apply_filters( 'usces_have_zaiko_anyone', $status, $post_id, $skus ); } function usces_is_gptekiyo( $post_id, $sku, $quant ){ global $usces; return $usces->is_gptekiyo( $post_id, $sku, $quant ); } function usces_the_itemGpExp( $out = '' ) { global $post, $usces; $post_id = $post->ID; $sku = $usces->itemsku['code']; $GpN1 = $usces->getItemGpNum1($post_id); $GpN2 = $usces->getItemGpNum2($post_id); $GpN3 = $usces->getItemGpNum3($post_id); $GpD1 = $usces->getItemGpDis1($post_id); $GpD2 = $usces->getItemGpDis2($post_id); $GpD3 = $usces->getItemGpDis3($post_id); $unit = $usces->getItemSkuUnit($post_id, $sku); $price = $usces->getItemPrice($post_id, $sku); if( ($usces->itemsku['gp'] == 0) || empty($GpN1) || empty($GpD1) ){ return; } $html = "