$script_days .= ' delivery_days['.$id.'].push("'.$delivery['delivery_method'][$index]['days'].'");'; } } //配達日数に設定されている県毎の日数 $target_market = ( isset($system['target_market']) && !empty($system['target_market']) ) ? $system['target_market'] : wc2_get_local_target_market(); $prefs = array(); foreach( (array)$target_market as $tm ) { $prefs[$tm] = $system['province'][$tm]; } $delivery_days = wc2_get_option( 'delivery_days' ); $script_days .= ' var delivery_days_value = [];'; foreach( (array)$default_deli as $id ) { $index = wc2_get_delivery_method_index( $id ); if( 0 <= $index ) { $days = (int)$delivery['delivery_method'][$index]['days']; if( 0 <= $days ) { for( $i = 0; $i < count((array)$delivery_days); $i++ ) { if( (int)$delivery_days[$i]['id'] == $days ) { $script_days .= ' delivery_days_value['.$days.'] = [];'; foreach( (array)$target_market as $tm ) { $script_days .= ' delivery_days_value['.$days.']["'.$tm.'"] = [];'; foreach( (array)$prefs[$tm] as $pref ) { $pref = esc_js($pref); $script_days .= ' delivery_days_value['.$days.']["'.$tm.'"]["'.$pref.'"] = [];'; if( isset($delivery_days[$i][$tm][$pref]) )
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; }
/** * 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_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(); }