public function template_redirect() { global $wp_query; foreach( $this->page_type as $page_type ) { if( isset( $_GET[$page_type] ) ) { $slug = $_GET[$page_type]; if( is_array($slug) ) return; if( !array_key_exists( $slug, $this->templates[$page_type] ) ) return; if( empty($this->current_page_type) ) $this->current_page_type = $page_type; if( empty($this->current_page) ) $this->current_page = $slug; add_filter( 'wp_title', array( $this, 'wc2_title' ), 10, 3 ); add_filter( 'edit_post_link', create_function( '', 'return;' ) ); if( file_exists( $this->templates[$this->current_page_type][$this->current_page] ) ) { $entry_data = wc2_get_entry(); if( 'member' == $this->current_page_type ){ if( wc2_is_login() ){ //DBから会員データ取得 if( !array_key_exists('error', $_SESSION[WC2]) ){ $member_id = wc2_memberinfo( 'ID' ); $member = wc2_get_member_data( $member_id ); //SET SESSION wc2_set_session_current_member( $member ); } } $member_data = wc2_get_member(); } do_action( 'wc2_action_before_template_include', $this->current_page_type, $this->current_page, $this->templates ); if( 'member' == $this->current_page_type && 'memberform' == $this->current_page && !wc2_is_login() ){ $this->set_error( __('ログインしてください。', 'wc2'), 'purchase_process' ); $this->current_page_type = 'member'; $this->current_page = 'login'; $this->page_redirect(); } include( $this->templates[$this->current_page_type][$this->current_page] ); exit; } else { $wp_query->is_home = NULL; $wp_query->is_page = 1; $wp_query->posts = array( $wp_query->post ); $wp_query->post_count = 1; return; } } } }
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); //-------------------------------------------------------------------------- }