Exemplo n.º 1
0
	/**
	 * Customer information check
	 *
	 */
	public function customer_process() {
		$nonce = ( isset($_POST['wc2_nonce']) ) ? $_POST['wc2_nonce'] : '0';
		if( !wp_verify_nonce( $nonce, 'wc2_customer' ) ) {
			$this->set_error( __( 'Security error.' ), 'customer_process' );
			$this->current_page_type = 'cart';
			$this->current_page = 'error';
			$this->page_redirect();
		}

		wc2_set_entry();
		if( isset($_POST['member_regmode']) and $_POST['member_regmode'] == 'newmemberfromcart' ) {
			$mes = wc2_member_check('customer');
			if( 0 < count($mes) ) {
				foreach($mes as $error){
					$this->set_error( $error, 'customer_process' );
				}
				$this->current_page_type = 'cart';
				$this->current_page = 'customer';
				$this->page_redirect();
			}
			$res = wc2_new_member_data( 'customer' );
			if( 1 === $res ) {
				$wc2_db_member = WC2_DB_Member::get_instance();
				$mem_id = $wc2_db_member->get_member_id();
				$member = $wc2_db_member->get_member_data($mem_id);
				//SET SESSION
				wc2_set_session_current_member($member);
				wc2_set_entry_member_regmode('editmemberfromcart');
				//登録完了メール送信
				$user = $_POST['customer'];
				$user['ID'] = $mem_id;
				wc2_send_regmembermail($user);
			}else{
				$this->set_error( __('登録に失敗しました。', 'wc2'), 'newmemberfromcart' );
				$this->current_page_type = 'cart';
				$this->current_page = 'customer';
				$this->page_redirect();
			}
		}elseif( isset($_POST['member_regmode']) and $_POST['member_regmode'] == 'editmemberfromcart' ){
			$mem_id = wc2_memberinfo('ID');
			$mes = wc2_member_check('customer', $mem_id);
			if( 0 < count($mes) ) {
				foreach($mes as $error){
					$this->set_error( $error, 'customer_process' );
				}
				$this->current_page_type = 'cart';
				$this->current_page = 'customer';
				$this->page_redirect();
			}
			$res = wc2_edit_member_data($mem_id, 'customer');
			if( 1 === $res ) {
				$wc2_db_member = WC2_DB_Member::get_instance();
				$mem_id = $wc2_db_member->get_member_id();
				$member = $wc2_db_member->get_member_data($mem_id);
				//SET SESSION
				wc2_set_session_current_member($member);
				wc2_set_entry_member_regmode('editmemberfromcart');
				//登録完了メール送信
				$user = $_POST['customer'];
				$user['ID'] = $mem_id;
				wc2_send_regmembermail($user);
			}else{
				$this->set_error( __('登録に失敗しました。', 'wc2'), 'newmemberfromcart' );
				$this->current_page_type = 'cart';
				$this->current_page = 'customer';
				$this->page_redirect();
			}
		}else{
			$mes = $this->customer_check();
			if( 0 < count($mes) ) {
				foreach( $mes as $error )
					$this->set_error( $error, 'customer_process' );
				$this->current_page_type = 'cart';
				$this->current_page = 'customer';
				$this->page_redirect();
			}
		}
	}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
function wc2_memberinfo_e( $key = '' ){
	echo wc2_memberinfo( $key );
}