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'; //配送希望日を何日後まで表示するか $delivery_after_days = ( !empty($delivery['delivery_after_days']) ) ? (int)$delivery['delivery_after_days'] : 15; $shortest_delivery_time = ( isset($delivery['shortest_delivery_time']) ) ? $delivery['shortest_delivery_time'] : '0';
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_item_charges_type($item_id) { $type = NULL; $charges = wc2_get_item_value_by_item_id($item_id, 'item_charges_type'); switch ($charges) { case 0: $type = 'once'; break; case 1: $type = 'continue'; break; case 2: $type = 'regular'; /* if( !empty($cart) ) { if( empty($cart['advance']) ) { $type = 'once'; } else { if( is_array($cart['advance']) and array_key_exists( 'regular', $cart['advance'] ) ) { $regular = maybe_unserialize( $cart['advance']['regular'] ); } else { $advance = $this->cart->wc_unserialize( $cart['advance'] ); $sku = urldecode( $cart['sku'] ); $sku_encoded = $cart['sku']; $regular = $advance[$post_id][$sku_encoded]['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 = 'once'; } return $type; }
function wc2_get_shipping_charge($d_method_id, $pref, $country = '', $cart = array()) { if (empty($country)) { $country = wc2_get_base_country(); } if (empty($cart) and !is_admin()) { $cart = wc2_get_cart(); } //if( empty($entry_data) ) // $entry_data = wc2_get_entry(); /* if( function_exists( 'dlseller_have_shipped' ) && !dlseller_have_shipped() ) { $charge = 0; $charge = apply_filters( 'wc2_filter_get_shipping_charge', $charge, $cart, $entry_data ); return $charge; } */ $delivery = wc2_get_option('delivery'); $delivery_method = isset($delivery['delivery_method']) ? $delivery['delivery_method'] : array(); $shipping_charge = wc2_get_option('shipping_charge'); //配送方法ID //$d_method_id = $entry_data['order']['delivery_method']; //配送方法index $d_method_index = wc2_get_delivery_method_index($d_method_id); //送料ID $fixed_charge_id = isset($delivery_method[$d_method_index]['charge']) ? $delivery_method[$d_method_index]['charge'] : -1; $individual_quant = 0; $charges = array(); $individual_charges = array(); foreach ($cart as $row) { if (-1 == $fixed_charge_id) { //商品送料ID $s_charge_id = wc2_get_item_value_by_item_id($row['item_id'], ITEM_SHIPPING_CHARGE); //商品送料index $s_charge_index = wc2_get_shipping_charge_index($s_charge_id); $charge = isset($shipping_charge[$s_charge_index][$country][$pref]) ? $shipping_charge[$s_charge_index][$country][$pref] : 0; } else { $s_charge_index = wc2_get_shipping_charge_index($fixed_charge_id); $charge = isset($shipping_charge[$s_charge_index][$country][$pref]) ? $shipping_charge[$s_charge_index][$country][$pref] : 0; } $item_individual_shipping_charges = wc2_get_item_value_by_item_id($row['item_id'], ITEM_INDIVIDUAL_SHIPPING_CHARGES); if ($item_individual_shipping_charges) { $individual_quant += $row['quantity']; $individual_charges[] = $row['quantity'] * $charge; } else { $charges[] = $charge; } } if (0 < count($charges)) { rsort($charges); $max_charge = $charges[0]; $charge = $max_charge + array_sum($individual_charges); } else { $charge = array_sum($individual_charges); } $charge = apply_filters('wc2_filter_get_shipping_charge', $charge, $cart); return $charge; }
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(); }