Example #1
0
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">&nbsp;&nbsp;</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;
}
Example #2
0
	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;
				}
			}
		}
	}
Example #3
0
    public function member_history_rows()
    {
        $wc2_db_member = WC2_DB_Member::get_instance();
        $wc2_order = WC2_DB_Order::get_instance();
        $wc2_item = WC2_DB_Item::get_instance();
        if (is_admin()) {
            $member_id = $wc2_db_member->get_member_id();
        } else {
            if (wc2_is_login() && 0 != $_SESSION[WC2]['member']['ID']) {
                $member_id = $_SESSION[WC2]['member']['ID'];
            } else {
                return false;
            }
        }
        $member_history = $wc2_order->get_member_history($member_id);
        $colspan = wc2_is_membersystem_point() ? 9 : 7;
        $html = '<div class="history-area">
					<table>';
        if (!count($member_history)) {
            $html .= '<tr>
			<td>' . __('There is no your purchase history.', 'wc2') . '</td>
			</tr>';
        }
        foreach ($member_history as $umhs) {
            $cart = $umhs['cart'];
            $history_member_head = '<tr>
				<th class="historyrow">' . __('Order number', 'wc2') . '</th>
				<th class="historyrow">' . __('Order status', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase date', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase amount', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Used points', 'wc2') . '</th>';
            }
            $history_member_head .= '<th class="historyrow">' . apply_filters('wc2_filter_discount_label', __('Discount', 'wc2'), $umhs) . '</th>
				<th class="historyrow">' . __('Shipping charges', 'wc2') . '</th>
				<th class="historyrow">' . apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2')) . '</th>
				<th class="historyrow">' . __('Consumption tax', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'wc2') . '</th>';
            }
            $history_member_head .= '</tr>
				<tr>
				<td class="rightnum"><a href="' . WC2_ADMIN_URL . '?page=wc2_order&action=edit&target=' . $umhs['ID'] . '">' . $umhs['dec_order_id'] . '</a></td>
				<td class="aleft">' . wc2_get_order_status_name($umhs['order_status']) . '</td>
				<td class="date">' . $umhs['order_date'] . '</td>
				<td class="rightnum">' . wc2_crform($umhs['item_total_price'] - $umhs['usedpoint'] + $umhs['discount'] + $umhs['shipping_charge'] + $umhs['cod_fee'] + $umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
            }
            $history_member_head .= '<td class="rightnum">' . wc2_crform($umhs['discount'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['shipping_charge'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['cod_fee'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
            }
            $history_member_head .= '</tr>';
            $html .= apply_filters('wc2_filter_history_member_head', $history_member_head, $umhs);
            $html .= apply_filters('wc2_filter_member_history_header', NULL, $umhs);
            $html .= '<tr>
				<td class="retail" colspan="' . $colspan . '">
					<table id="retail_table_' . $umhs['ID'] . '" class="retail">';
            $history_cart_head = '<tr>
					<th scope="row" class="num">No.</th>
					<th class="thumbnail">&nbsp;</th>
					<th>' . __('Items', 'wc2') . '</th>
					<th class="price ">' . __('Unit price', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					<th class="quantity">' . __('Quantity', 'wc2') . '</th>
					<th class="subtotal">' . __('Amount', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					</tr>';
            $html .= apply_filters('wc2_filter_history_cart_head', $history_cart_head, $umhs);
            $i = 1;
            foreach ($cart as $cart_row) {
                $ordercart_id = $cart_row['cart_id'];
                $post_id = $cart_row['post_id'];
                $item_id = $cart_row['item_id'];
                $sku_id = $cart_row['sku_id'];
                $quantity = $cart_row['quantity'];
                $options = isset($cart_row['options']) ? $cart_row['options'] : '';
                //$options = wc2_get_ordercart_meta_value( 'option', $ordercart_id );
                //$options = wc2_get_ordercart_meta( 'option', $ordercart_id );
                $item_name = $cart_row['item_name'];
                $item_code = $cart_row['item_code'];
                $sku_name = $cart_row['sku_name'];
                $sku_code = $cart_row['sku_code'];
                $cart_item_name = wc2_get_cart_item_name($item_name, $item_code, $sku_name, $sku_code);
                $skuPrice = $cart_row['price'];
                $pictid = (int) $wc2_item->get_mainpictid($item_code);
                $optstr = '';
                if (is_array($options) && count($options) > 0) {
                    $optstr = '';
                    foreach ($options as $key => $value) {
                        if (!empty($key)) {
                            $key = urldecode($key);
                            $value = maybe_unserialize($value);
                            if (is_array($value)) {
                                $c = '';
                                $optstr .= esc_html($key) . ' : ';
                                foreach ($value as $v) {
                                    $optstr .= $c . nl2br(esc_html(urldecode($v)));
                                    $c = ', ';
                                }
                                $optstr .= "<br />\n";
                            } else {
                                $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
                            }
                        }
                    }
                    $optstr = apply_filters('wc2_filter_option_history', $optstr, $options);
                }
                $optstr = apply_filters('wc2_filter_option_info_history', $optstr, $umhs, $cart_row, $i);
                $permalink = apply_filters('wc2_filter_link_item_history', get_permalink($post_id), $cart_row);
                $history_cart_row = '<tr>
					<td>' . $i . '</td>
					<td>';
                if ($pictid) {
                    $cart_thumbnail = '<a href="' . esc_url($permalink) . '">' . wp_get_attachment_image($pictid, array(60, 60), true) . '</a>';
                } else {
                    $cart_thumbnail = '<p>' . wc2_no_image() . '</p>';
                }
                $history_cart_row .= apply_filters('wc2_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
                $history_cart_row .= '</td>
					<td class="aleft"><a href="' . esc_url($permalink) . '">' . esc_html($cart_item_name) . '<br />' . $optstr . '</a>' . apply_filters('wc2_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice, true, false) . '</td>
					<td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice * $cart_row['quantity'], true, false) . '</td>
					</tr>';
                $materials = compact('cart_thumbnail', 'post_id', 'pictid', 'cart_item_name', 'optstr');
                $html .= apply_filters('wc2_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials);
                $i++;
            }
            $html .= '</table>
				</td>
				</tr>';
        }
        $html .= '</table>
		</div>';
        $html = apply_filters('wc2_filter_member_history_rows', $html, $member_id, $member_history, $colspan);
        return $html;
    }
Example #4
0
	static function get_loginout(){

		if( !wc2_is_login() ) {
			$res = '<a href="'. apply_filters('wc2_filter_login_url', WC2_LOGIN_URL) .'" class="wc2_login_a">' . apply_filters('wc2_filter_loginlink_label', __('ログイン','wc2')) . '</a>';
		}else{
			$res = '<a href="' . apply_filters('wc2_filter_logout_uri', WC2_LOGOUT_URL) . '" class="wc2_logout_a">' . apply_filters('wc2_filter_logoutlink_label', __('ログアウト','wc2')) . '</a>';
		}
		return $res;
	}