//選択可能な配送方法 $default_deli = array_values( apply_filters( 'wc2_filter_get_available_delivery_method', wc2_get_available_delivery_method() ) ); if( !isset($entry_data['order']['delivery_method']) || '' == $entry_data['order']['delivery_method'] ) { $selected_delivery_method = $default_deli[0]; } else { $selected_delivery_method = $entry_data['order']['delivery_method']; } ?> selected_delivery_method = "<?php echo $selected_delivery_method; ?>"; <?php if( isset($entry_data['order']['delivery_date']) ) : ?> selected_delivery_date = "<?php echo $entry_data['order']['delivery_date']; ?>"; <?php endif; ?> <?php //カートに入っている商品の発送日目安 $shipping = 0; $cart = wc2_get_cart(); foreach( $cart as $key => $cart_row ) { $shipment = wc2_get_item_value_by_item_id( $cart_row['item_id'], ITEM_PREPARATIONS_SHIPMENT ); if( $shipment == 0 or $shipment == 9 ) { $shipping = 0; break; } if( $shipping < $shipment ) $shipping = $shipment; } ?> var shipping = "<?php echo $shipping; ?>"; <?php //配送業務締時間 $hour = ( !empty($delivery['delivery_time_limit']['hour']) ) ? $delivery['delivery_time_limit']['hour'] : '00'; $min = ( !empty($delivery['delivery_time_limit']['min']) ) ? $delivery['delivery_time_limit']['min'] : '00'; //配送希望日を何日後まで表示するか
public function cart_js() { if( $this->current_page_type == 'cart' ) { $url = wc2_cart_top_url().'&'; } else { $parse_url = parse_url( $_SERVER['REQUEST_URI'] ); $url = $parse_url['path'].'?'; } ob_start(); ?> <script type="text/javascript"> jQuery( function($) { <?php //if( is_singular( 'item' ) or 'top' == $current_page ) : ?> cart = { numcheck: function( val ) { var mes = ""; if( val == "" || !val.match(/^[0-9]+$/) ) { mes += "<?php _e('半角数字で入力してください。', 'wc2'); ?>\n"; } return mes; }, update: function() { $('input[name="wcaction"]').val("update_cart"); $("#cart-form-top").attr( "action", $('input[name="wcreferer"]').val() ); $("#cart-form-top").submit(); }, remove: function( cart_key ) { location.href = "<?php echo $url; ?>wcaction=remove_cart&cart_key="+cart_key; } }; $(".quantity").blur(function() { if( $(this).val() == "" ) return; var mes = ""; mes += cart.numcheck( $(this).val() ); if( mes != "" ) { alert(mes); $(this).focus(); } }); <?php //endif; ?> <?php if( is_singular( 'item' ) ) : ?> $(".add2cartbutton").click(function() { var idname = $(this).attr("id"); var ids = idname.split("-"); var item_id = ids[1]; var sku_id = ids[2]; var mes = cart.numcheck( $("#quantity-"+item_id+"-"+sku_id).val() ); if( mes != "" ) { alert(mes); $("#quantity-"+item_id+"-"+sku_id).focus(); return false; } <?php self::js_add2cart_click(); ?> }); <?php endif; ?> <?php if( 'top' == $this->current_page ) : $cart = wc2_get_cart(); if( 0 == count($cart) ): ?> $("#go2customer").attr("disabled", true); <?php else: ?> $("#cart-update").click(function() { cart.update(); }); $(".cart-remove").click(function() { var idname = $(this).attr("id"); var ids = idname.split("-"); var idx = ids[2]; cart.remove(idx); }); <?php endif; ?> <?php endif; ?> }); </script> <?php $scripts = ob_get_contents(); ob_end_clean(); $scripts = apply_filters( 'wc2_filter_cart_scripts', $scripts, $this->current_page_type, $this->current_page, $url ); echo $scripts; }
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); //-------------------------------------------------------------------------- }
function wc2_get_send_out_date() { $general = wc2_get_option( 'general' ); $delivery = wc2_get_option( 'delivery' ); $shipping_rule = wc2_get_option( 'shipping_rule' ); $bus_day_arr = (isset($general['business_days'])) ? $general['business_days'] : false; list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', current_time('mysql') ); if( !is_array($bus_day_arr) ) { $today_bus_flag = 1; } else { $today_bus_flag = isset($bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day]) ? (int)$bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day] : 1; } // get the time limit addition $limit_hour = (!empty($delivery['delivery_time_limit']['hour'])) ? $delivery['delivery_time_limit']['hour'] : false; $limit_min = (!empty($delivery['delivery_time_limit']['min'])) ? $delivery['delivery_time_limit']['min'] : false; if( false === $hour || false === $minute ) { $time_limit_addition = false; } elseif( ($hour.':'.$minute.':'.$second) > ($limit_hour.':'.$limit_min.':00') ) { $time_limit_addition = 1; } else { $time_limit_addition = 0; } // get the shipping indication in cart $cart = wc2_get_cart(); $shipping_indication = apply_filters( 'wc2_filter_shipping_indication', $shipping_rule['indication'] ); $shipping = 0; $indication_flag = true; foreach( $cart as $key => $cart_row ) { $shipment = wc2_get_item_value_by_item_id( $cart_row['item_id'], ITEM_PREPARATIONS_SHIPMENT ); if( $shipment === 0 or $shipment === 9 ) { $indication_flag = false; break; } if( $shipping < $shipment ) $shipping = $shipment; } $indication_incart = ( $indication_flag ) ? $shipping_indication[$shipping] : false; $indication_incart = apply_filters( 'wc2_filter_indication_incart', $indication_incart, $shipping_indication, $shipping, $cart ); // get the send out date $sendout_num = 0; if( $today_bus_flag ) { if( $time_limit_addition ) { $sendout_num += 1; } if( false !== $indication_incart ) { $sendout_num += $indication_incart; } } else { if( false !== $indication_incart ) { $sendout_num += $indication_incart; } } $holiday = 0; for( $i = 0; $i <= $sendout_num; $i++ ) { list($yyyy, $mm, $dd) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $i),(int)$today_year))); if( isset($bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd]) && !$bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd] ) { $holiday++; $sendout_num++; } if( 100 < $sendout_num ) break; } list($send_y, $send_m, $send_d) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $sendout_num),(int)$today_year))); $sendout = array( 'today_bus_flag' => $today_bus_flag, 'time_limit_addition' => $time_limit_addition, 'indication_incart' => $indication_incart, 'holiday' => $holiday, 'sendout_num' => $sendout_num, 'sendout_date' => array('year' => $send_y, 'month' => $send_m, 'day' => $send_d) ); return $sendout; }
function wc2_get_available_delivery_method() { $cart = wc2_get_cart(); if (0 < count($cart)) { $delivery = wc2_get_option('delivery'); $delivery_limit_option = isset($delivery['delivery_limit_option']) ? $delivery['delivery_limit_option'] : ''; $intersect = array(); $integration = array(); $temp = array(); $in = 0; $total_quantity = 0; foreach ($cart as $key => $cart_row) { $total_quantity += (int) $cart_row['quantity']; $item_delivery = maybe_unserialize(wc2_get_item_value_by_item_id($cart_row['item_id'], ITEM_DELIVERY_METHOD)); if (empty($item_delivery)) { continue; } if (0 === $in) { $intersect = $item_delivery; } $intersect = array_intersect($item_delivery, $intersect); foreach ($item_delivery as $value) { $integration[] = $value; } $in++; } $integration = array_unique($integration); foreach ($integration as $id) { $index = self::get_delivery_method_index($id); $temp[$index] = $id; } ksort($temp); $force = array(array_shift($temp)); if (empty($intersect)) { $available = $force; } else { $available = $intersect; } if ('item' == $delivery_limit_option) { $available_delivery = array(); foreach ($available as $id) { $index = wc2_get_delivery_method_index($id); $limit_num = !empty($delivery_options['delivery_method'][$index]['limit_num']) ? $delivery_options['delivery_method'][$index]['limit_num'] : 0; if (0 < $limit_num and $limit_num <= $total_quantity) { } else { $available_delivery[$index] = $id; } } return $available_delivery; } else { return $available; } } return array(); }