<?php $entry_data = wc2_get_entry(); $system = wc2_get_option( 'system' ); $general = wc2_get_option( 'general' ); $delivery = wc2_get_option( 'delivery' ); $settlement = wc2_get_option( 'settlement' ); ?> var toDoubleDigits = function(num) { num += ""; if(num.length === 1) num = "0".concat(num); return num; }; var selected_delivery_method = ""; var selected_delivery_date = ""; var selected_delivery_time = ""; var add_shipping = new Array(); function addDate(year, month, day, add) { var date = new Date(Number(year), (Number(month) - 1), Number(day)); var baseSec = date.getTime(); var addSec = Number(add) * 86400000; var targetSec = baseSec + addSec; date.setTime(targetSec); var yy = date.getFullYear() + ""; var mm = toDoubleDigits(date.getMonth() + 1); var dd = toDoubleDigits(date.getDate()); var newdate = new Array(); newdate["year"] = yy; newdate["month"] = mm;
function wc2_cart_confirm_table( $slug = '' ) { $wc2_cart = WC2_Cart::get_instance( $slug ); $cart = $wc2_cart->get_cart( $slug ); $cart_num = count($cart); $entry_data = wc2_get_entry(); $num = 0; ob_start(); ?> <table class="cart-table"> <thead> <tr> <?php $cart_header = ' <th scope="row" class="num">No.</th> <th class="thumbnail"> </th> <th class="name">'.__('Items','wc2').'</th> <th class="price">'.__('Unit price','wc2').'</th> <th class="quantity">'.__('Quantity','wc2').'</th> <th class="subtotal">'.__('Amount','wc2').'</th>'; $cart_header = apply_filters( 'wc2_filter_cart_confirm_header', $cart_header, $cart, $slug ); echo $cart_header; ?> </tr> </thead> <tbody> <?php foreach( $cart as $idx => $row ): ?> <tr> <?php $post_id = $row['post_id']; $item_id = $row['item_id']; $item_name = $row['item_name']; $item_code = $row['item_code']; $sku_name = $row['sku_name']; $sku_code = $row['sku_code']; $sku_id = $row['sku_id']; $quantity = $row['quantity']; $price = $row['price']; $subtotal = $row['quantity'] * $row['price']; //$item_sku_data = wc2_get_item_sku_data( $item_id, $sku_id ); //$stock_status = $item_sku_data['stock_status']; //$stock = $item_sku_data['sku_stock']; $pictid = wc2_get_mainpictid( $item_code ); $cart_thumbnail = ( !empty($pictid ) ) ? wc2_the_item_image( 0, 60, 60, $post_id ) : wc2_no_image(); $cart_thumbnail = apply_filters( 'wc2_filter_cart_confirm_row_thumbnail', $cart_thumbnail, $post_id, $pictid, $idx, $row, $slug ); $cart_item_name = wc2_get_cart_item_name( $item_name, $item_code, $sku_name, $sku_code ); $cart_options = ''; $cart_options = apply_filters( 'wc2_filter_cart_confirm_row_options', $cart_options, $idx, $row, $slug ); $num++; $cart_row = ' <td class="num">'.$num.'</td> <td class="thumbnail">'.$cart_thumbnail.'</td> <td class="name">'.$cart_item_name.$cart_options.'</td> <td class="price">'.wc2_crform( $price, false, false ).'</td> <td class="quantity">'.wc2_crform( $quantity, false, false ).'</td> <td class="subtotal">'.wc2_crform( $subtotal, false, false ).'</td>'; $cart_row = apply_filters( 'wc2_filter_cart_confirm_row', $cart_row, $idx, $row ); echo $cart_row; ?> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr> <th colspan="5"><?php _e('Total amount of items', 'wc2'); ?></th> <th class="total-items-price"><?php wc2_crform_e( $entry_data['order']['item_total_price'], true, false ); ?></th> </tr> <?php if( !empty($entry_data['order']['discount']) ) : ?> <tr> <td colspan="5"><?php echo apply_filters( 'wc2_filter_discount_label', __('Discount', 'wc2') ); ?></td> <td class="discount"><?php wc2_crform_e($entry_data['order']['discount'], true, false); ?></td> </tr> <?php endif; ?> <?php if( 0.00 < (float)$entry_data['order']['tax'] && 'products' == wc2_get_tax_target() ) : ?> <tr> <td colspan="5"><?php wc2_tax_label_e(); ?></td> <td class="tax"><?php wc2_tax_e( $entry_data['order'] ) ?></td> </tr> <?php endif; ?> <tr> <td colspan="5"><?php _e('Shipping charges', 'wc2'); ?></td> <td class="aright"><?php wc2_crform_e( $entry_data['order']['shipping_charge'], true, false ); ?></td> </tr> <?php if( !empty($entry_data['order']['cod_fee']) ) : ?> <tr> <td colspan="5"><?php echo apply_filters( 'wc2_filter_cod_label', __('COD fee', 'wc2') ); ?></td> <td class="aright"><?php wc2_crform_e( $entry_data['order']['cod_fee'], true, false ); ?></td> </tr> <?php endif; ?> <?php if( 0.00 < (float)$entry_data['order']['tax'] && 'all' == wc2_get_tax_target() ) : ?> <tr> <td colspan="5"><?php wc2_tax_label_e(); ?></td> <td class="tax"><?php wc2_tax_e( $entry_data['order'] ) ?></td> </tr> <?php endif; ?> <?php if( wc2_is_membersystem_state() && wc2_is_membersystem_point() && !empty($entry_data['order']['usedpoint']) ) : ?> <tr> <td colspan="5"><?php _e('Used points', 'wc2'); ?></td> <td class="usedpoint"><?php echo number_format( $entry_data['order']['usedpoint'] ); ?></td> </tr> <?php endif; ?> <tr> <th colspan="5"><?php _e('Total amount', 'wc2'); ?></th> <th class="total_price"><?php wc2_crform_e( $entry_data['order']['total_price'], true, false ); ?></th> </tr> </tfoot> </table> <?php if( wc2_is_membersystem_state() && wc2_is_membersystem_point() && wc2_is_login() ) : $member_id = wc2_memberinfo( 'ID' ); $point = wc2_get_member_data_value( $member_id, $key ); ?> <form id="cart-form-confirm-point" action="<?php wc2_cart_url_e( 'point' ); ?>" method="post"> <table id="point-table"> <tr> <td><?php _e('Current holdings points', 'wc2'); ?></td> <td><span class="point"><?php echo $point; ?></span><?php _e('Points', 'wc2'); ?></td> </tr> <tr> <td><?php _e('Point to use', 'wc2'); ?></td> <td><input name="offer[usedpoint]" class="used_point" type="text" value="<?php esc_attr_e($entry_data['order']['usedpoint']); ?>" /><?php _e('Points', 'wc2'); ?></td> </tr> <tr> <td colspan="2"><input name="use_point" type="button" class="use_point_button" value="<?php _e('Use the points', 'wc2'); ?>" /></td> </tr> </table> <?php do_action( 'wc2_action_confirm_point_page_form_inside' ); ?> </form> <?php do_action( 'wc2_action_confirm_point_page_form_outside' ); ?> <?php endif; ?> <?php do_action( 'wc2_action_confirm_cart_footer' ); ?> <?php $html = ob_get_contents(); ob_end_clean(); $html = apply_filters( 'wc2_filter_cart_confirm_table', $html, $slug ); return $html; }
function wc2_Classic_trackPageview_by_Yoast($push){ $page_type = wc2_get_current_page_type(); $page = wc2_get_current_page(); $action = isset($_REQUEST['wcaction']) ? $_REQUEST['wcaction']: ''; $row = array(); if( 'cart' == $page_type && 'complete' == $page && 'purchase_process' == $action ){ $entry_data = wc2_get_entry(); $order_id = $entry_data['order']['ID']; $data = wc2_get_order_data( $order_id ); $cart = $data['cart']; $total_price = $data['item_total_price'] + $data['discount'] - $data['usedpoint']; $row[] = "'_addTrans', '" . $order_id . "', '" . get_option('blogname') . "', '" . $total_price . "', '" . $data['tax'] . "', '" . $data['shipping_charge'] . "', '" . $data['address1'] . $data['address2'] . "', '" . $data['pref'] . "', '" . get_locale() . "'"; foreach( $cart as $index => $cart_row ){ $skuName = urldecode($cart_row['sku_name']); $itemName = $cart_row['item_name']; $post_id = $cart_row['post_id']; $cats = wc2_get_item_cat_genre_ids($post_id); if( is_array($cats) ) sort($cats); $category = isset($cats[0]) ? get_term($cats[0], 'item'): ''; $catName = isset($category->name) ? $category->name: ''; $skuPrice = $cart_row['price']; $quantity = $cart_row['quantity']; $row[] = "'_addItem', '" . $order_id . "', '" . $skuName . "', '" . $itemName . "', '" . $catName . "', '" . $skuPrice . "', '" . $quantity . "'"; } $row[] = "'_trackTrans'"; } $row = apply_filters('wc2_filter_Classic_trackPageview_by_Yoast', $row, $page_type, $page, $action); $push = array_merge( $push, $row ); return $push; }
/** * Delivery input check * */ public function delivery_check() { $mes = array(); if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) { //氏名 if ( WC2_Utils::is_blank($_POST['delivery']['name1']) || WC2_Utils::is_blank($_POST['delivery']['name2']) ){ $mes[] = __('氏名を入力してください。', 'wc2'); } //郵便番号 if ( WC2_Utils::is_blank($_POST['delivery']['zipcode']) ){ $mes[] = __('郵便番号が入力されていません。', 'wc2'); }elseif( preg_match('/[^\d-]/', trim($_POST['delivery']['zipcode'])) ){ $mes[] = __('郵便番号は半角数字で入力してください。', 'wc2'); } //都道府県 if ( WC2_UNSELECTED == ($_POST['delivery']['pref']) ) $mes[] = __('都道府県が選択されていません。', 'wc2'); //市区町村・番地 if ( WC2_Utils::is_blank($_POST['delivery']['address1']) ) $mes[] = __('市区町村・番地が入力されていません。', 'wc2'); //電話番号 if( WC2_Utils::is_blank($_POST['delivery']['tel']) ){ $mes[] = __('電話番号が入力されていません。', 'wc2'); }elseif( !WC2_Utils::is_blank($_POST['delivery']['tel']) && preg_match('/[^\d]/', trim($_POST['delivery']['tel'])) ){ $mes[] = __('電話番号は半角数字で入力してください。', 'wc2'); } } if( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WC2_Utils::is_zero($_POST['offer']['delivery_method'])) ) $mes[] = __('配送方法を選択してください。', 'wc2'); if( !isset($_POST['offer']['payment_method']) ) { $mes[] = __('支払方法を選択してください。', 'wc2'); } else { $entry_data = wc2_get_entry(); $delivery = wc2_get_option( 'delivery' ); $general = wc2_get_option( 'general' ); $payment = wc2_get_payment( $_POST['offer']['payment_method'] ); if( 'COD' == $payment['settlement'] ) { $item_total_price = wc2_get_item_total_price(); $materials = array( 'total_price' => $item_total_price, 'discount' => $entry_data['order']['discount'], 'shipping_charge' => $entry_data['order']['shipping_charge'], 'cod_fee' => $entry_data['order']['cod_fee'], ); $item_total_price += wc2_get_tax( $materials ); $cod_limit_amount = ( isset($general['cod_limit_amount']) && 0 < (int)$general['cod_limit_amount'] ) ? $general['cod_limit_amount'] : 0; if( 0 < $cod_limit_amount && $item_total_price > $cod_limit_amount ) $mes[] = sprintf(__('商品合計金額が、代引きでご購入できる上限額(%s)を超えています。', 'wc2'), wc2_crform( $general['cod_limit_amount'], true, false )); } $d_method_index = wc2_get_delivery_method_index( (int)$_POST['offer']['delivery_method'] ); if( $delivery['delivery_method'][$d_method_index]['nocod'] == 1 ) { if('COD' == $payment['settlement']) $mes[] = __('この配送方法では、代引きはご利用できません。', 'wc2'); } $country = $entry_data['delivery']['country']; $local_country = wc2_get_base_country(); if( $country == $local_country ) { if( $delivery['delivery_method'][$d_method_index]['intl'] == 1 ) { $mes[] = __('配送方法が誤っています。国際便は指定できません。', 'wc2'); } } else { if( WC2_Utils::is_zero($delivery['delivery_method'][$d_method_index]['intl']) ) { $mes[] = __('配送方法が誤っています。国際便を指定してください。', 'wc2'); } } } //custom_delivery check $csde_mes = wc2_custom_field_enter_check('delivery'); foreach( $csde_mes as $csde_mes_val ){ $mes[] = $csde_mes_val; } //custom_order check $csod_mes = wc2_custom_field_enter_check('order'); foreach( $csod_mes as $csod_mes_val ){ $mes[] = $csod_mes_val; } $mes = apply_filters( 'wc2_filter_delivery_check', $mes ); return $mes; }
function wc2_set_order_price($cart = array(), $entry_data = array()) { $general = wc2_get_option('general'); if (empty($cart) and !is_admin()) { $cart = wc2_get_cart(); } if (empty($entry_data) and !is_admin()) { $entry_data = wc2_get_entry(); } //*** Delivery method name $delivery_name = wc2_get_delivery_method_name($entry_data['order']['delivery_method']); wc2_set_entry_order_value('delivery_name', $delivery_name); //-------------------------------------------------------------------------- //*** Payment method name $payment = wc2_get_payment($entry_data['order']['payment_method']); $payment_name = $payment['name']; wc2_set_entry_order_value('payment_name', $payment_name); //-------------------------------------------------------------------------- //*** Item total price $item_total_price = wc2_get_item_total_price($cart); wc2_set_entry_order_value('item_total_price', $item_total_price); //-------------------------------------------------------------------------- //*** Discount price $discount = wc2_get_order_discount($general['display_mode'], $cart); wc2_set_entry_order_value('discount', $discount); //-------------------------------------------------------------------------- //*** Shipping charge if (empty($general['postage_privilege']) || $item_total_price + $discount < $general['postage_privilege']) { $country = isset($entry_data['delivery']['country']) && !empty($entry_data['delivery']['country']) ? $entry_data['delivery']['country'] : $entry_data['customer']['country']; $shipping_charge = wc2_get_shipping_charge($entry_data['order']['delivery_method'], $entry_data['delivery']['pref'], $country, $cart); } else { $shipping_charge = 0; } $shipping_charge = apply_filters('wc2_filter_set_shipping_charge', $shipping_charge, $cart, $entry_data); wc2_set_entry_order_value('shipping_charge', $shipping_charge); //-------------------------------------------------------------------------- //*** COD fee $usedpoint = isset($entry_data['order']['usedpoint']) ? (int) $entry_data['order']['usedpoint'] : 0; $amount_by_cod = $item_total_price + $discount + $shipping_charge - $usedpoint; $amount_by_cod = apply_filters('wc2_filter_set_amount_by_cod', $amount_by_cod, $entry_data, $item_total_price, $discount, $shipping_charge, $usedpoint); $cod_fee = wc2_get_cod_fee($entry_data['order']['payment_method'], $amount_by_cod, $item_total_price, $discount, $shipping_charge); $cod_fee = apply_filters('wc2_filter_set_cod_fee', $cod_fee, $entry_data, $item_total_price, $discount, $shipping_charge, $usedpoint); wc2_set_entry_order_value('cod_fee', $cod_fee); //-------------------------------------------------------------------------- //*** Set materials $materials = array('entry_data' => $entry_data, 'cart' => $cart, 'total_price' => $item_total_price, 'discount' => $discount, 'shipping_charge' => $shipping_charge, 'usedpoint' => $usedpoint, 'cod_fee' => $cod_fee, 'payment' => $payment); //-------------------------------------------------------------------------- //*** Tax price $tax = wc2_get_tax($materials); wc2_set_entry_order_value('tax', $tax); //-------------------------------------------------------------------------- //*** Total price $total_price = $item_total_price + $discount + $shipping_charge - $usedpoint + $cod_fee + ('exclude' == $general['tax_mode'] ? $tax : 0); $total_price = apply_filters('wc2_filter_set_total_order_price', $total_price, $item_total_price, $discount, $shipping_charge, $usedpoint, $cod_fee); wc2_set_entry_order_value('total_price', $total_price); //-------------------------------------------------------------------------- //*** Get point $member = wc2_get_member(); $getpoint = wc2_get_order_point($member['ID'], $usedpoint); wc2_set_entry_order_value('getpoint', $getpoint); //-------------------------------------------------------------------------- }