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 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 #3
0
function wc2_ordermail($data, $send = 'order')
{
    $cart = $data['cart'];
    $payment = wc2_get_payment($data['payment_method']);
    $general_options = wc2_get_option('general');
    $total_price = $data['item_total_price'] - $data['usedpoint'] + $data['discount'] + $data['shipping_charge'] + $data['cod_fee'] + $data['tax'];
    $msg_body = "";
    if ($data['order_type'] == 'estimate') {
        $msg_top = "\r\n\r\n\r\n" . __('【お見積】', 'wc2') . "\r\n";
        $msg_top .= wc2_mail_line(1, $data['email']);
        //********************
        $msg_top .= apply_filters('wc2_filter_ordermail_first', "", $data, $payment, $send);
        $msg_top .= wc2_get_mail_addressform($data, 'customer');
        $msg_top .= __('お見積番号', 'wc2') . " : " . $data['order_id'] . "\r\n";
    } else {
        $msg_top = "\r\n\r\n\r\n" . __('【ご注文内容】', 'wc2') . "\r\n";
        $msg_top .= wc2_mail_line(1, $data['email']);
        //********************
        $msg_top .= apply_filters('wc2_filter_ordermail_first', "", $data, $payment, $send);
        $msg_top .= wc2_get_mail_addressform($data, 'customer');
        $msg_top .= __('Order number', 'wc2') . " : " . $data['dec_order_id'] . "\r\n";
        $msg_top .= __('注文日時', 'wc2') . " : " . $data['order_date'] . "\r\n";
    }
    $msg_top .= "\r\n";
    $msg_body = apply_filters('wc2_filter_ordermail_top', $msg_top, $data, $payment, $send);
    $msg_detail = __('Items', 'wc2') . "\r\n";
    foreach ($cart as $idx => $cart_row) {
        //		$item_id = $cart_row['item_id'];
        //		$sku_id = $cart_row['sku_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);
        $cart_options = '';
        $msg_detail .= wc2_mail_line(2, $data['email']);
        //--------------------
        $msg_detail .= $cart_item_name . "\r\n";
        if (is_array($cart_options) && count($cart_options) > 0) {
            $optstr = '';
            foreach ($cart_options as $key => $value) {
                if (!empty($key)) {
                    $key = urldecode($key);
                    if (is_array($value)) {
                        $c = '';
                        $optstr .= $key . ' : ';
                        foreach ($value as $v) {
                            $optstr .= $c . urldecode($v);
                            $c = ', ';
                        }
                        $optstr .= "\r\n";
                    } else {
                        $optstr .= $key . ' : ' . urldecode($value) . "\r\n";
                    }
                }
            }
            $msg_detail .= apply_filters('wc2_filter_ordermail_cartrow_options', $optstr, $cart_options, $send);
        }
        $msg_detail .= __('単価', 'wc2') . " " . wc2_crform($cart_row['price'], true, false) . __(' * ', 'wc2') . $cart_row['quantity'] . "\r\n";
    }
    $msg_detail .= wc2_mail_line(3, $data['email']);
    //====================
    $msg_detail .= __('商品合計', 'wc2') . " : " . wc2_crform($data['item_total_price'], true, false) . "\r\n";
    if ($data['discount'] != 0) {
        $msg_detail .= apply_filters('wc2_filter_discount_label', __('値引', 'wc2'), $data['order_id']) . " : " . wc2_crform($data['discount'], true, false) . "\r\n";
    }
    if (0.0 < (double) $data['tax'] && 'products' == $general_options['tax_target']) {
        $msg_detail .= wc2_tax_label($data) . " : " . wc2_crform($data['tax'], true, false) . "\r\n";
    }
    $msg_detail .= __('送料', 'wc2') . " : " . wc2_crform($data['shipping_charge'], true, false) . "\r\n";
    if ($payment['settlement'] == 'COD') {
        $msg_detail .= apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2')) . " : " . wc2_crform($data['cod_fee'], true, false) . "\r\n";
    }
    if (0.0 < (double) $data['tax'] && 'all' == $general_options['tax_target']) {
        $msg_detail .= wc2_tax_label($data) . " : " . wc2_crform($data['tax'], true, false) . "\r\n";
    }
    if ($data['usedpoint'] != 0) {
        $msg_detail .= __('ご利用ポイント', 'wc2') . " : " . number_format($data['usedpoint']) . __('ポイント', 'wc2') . "\r\n";
    }
    $msg_detail .= wc2_mail_line(2, $data['email']);
    //--------------------
    $msg_detail .= __('お支払金額', 'wc2') . " : " . wc2_crform($total_price, true, false) . "\r\n";
    $msg_detail .= wc2_mail_line(2, $data['email']);
    //--------------------
    $msg_detail .= "(" . __('Currency', 'wc2') . ' : ' . __(wc2_crcode(), 'wc2') . ")\r\n\r\n\r\n";
    $msg_body .= apply_filters('wc2_filter_ordermail_detail', $msg_detail, $data, $payment, $send);
    $msg_shipping = __('【配送先】', 'wc2') . "\r\n";
    $msg_shipping .= wc2_mail_line(1, $data['email']);
    //********************
    $msg_shipping .= wc2_get_mail_addressform($data, 'delivery');
    $msg_shipping .= __('配送方法', 'wc2') . " : " . $data['delivery_name'] . "\r\n";
    $msg_shipping .= __('配送希望日', 'wc2') . " : " . $data['delivery_date'] . "\r\n";
    $msg_shipping .= __('配送希望時間', 'wc2') . " : " . $data['delivery_time'] . "\r\n";
    $msg_shipping .= "\r\n\r\n";
    $msg_body .= apply_filters('wc2_filter_ordermail_shipping', $msg_shipping, $data, $payment, $send);
    $msg_payment = __('【お支払方法】', 'wc2') . "\r\n";
    $msg_payment .= wc2_mail_line(1, $data['email']);
    //********************
    $msg_payment .= $payment['name'] . wc2_payment_detail($data) . "\r\n\r\n";
    if ($payment['settlement'] == 'BT') {
        $transferee = __('お振込先', 'wc2') . " : \r\n";
        $transferee .= wc2_get_option('transferee_info') . "\r\n\r\n";
        $transferee .= wc2_mail_line(2, $data['email']) . "\r\n";
        //--------------------
        $msg_payment .= apply_filters('wc2_filter_mail_transferee', $transferee, $data, $payment, $send);
    }
    $msg_payment .= "\r\n\r\n";
    $msg_body .= apply_filters('wc2_filter_ordermail_payment', $msg_payment, $data, $payment, $send);
    $msg_other = __('【その他】', 'wc2') . "\r\n";
    $msg_other .= wc2_mail_line(1, $data['email']);
    //********************
    $msg_other .= wc2_mail_custom_field_info($data, 'order', 'beforeremarks');
    $msg_other .= $data['note'] . "\r\n";
    $msg_other .= wc2_mail_custom_field_info($data, 'order', 'other');
    $msg_other .= "\r\n\r\n\r\n";
    $msg_body .= apply_filters('wc2_filter_ordermail_other', $msg_other, $data, $payment, $send);
    $msg_body = apply_filters('wc2_filter_ordermail_body', $msg_body, $data, $payment, $send);
    return $msg_body;
}
Example #4
0
 public function pdf_out($pdf, $data)
 {
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     //PDF出力基本設定
     //******************************************************
     $border = 0;
     //セルのボーダー初期値
     // テンプレートファイル
     //$tplfile = WC2_PLUGIN_DIR."/common/includes/pdf/templates/orderform_B5.pdf";
     //$tplfile = apply_filters( 'wc2_filter_pdf_template', $tplfile );
     //$pagecount = $pdf->setSourceFile($tplfile);
     //$tplidx = $pdf->importPage(1);
     $pdf->SetLeftMargin(0);
     $pdf->SetTopMargin(0);
     $pdf->addPage();
     $font = $this->font;
     // 文書情報設定
     $pdf->SetCreator('Welcart');
     $pdf->SetAuthor('Collne Inc.');
     switch ($_REQUEST['type']) {
         //見積書
         case 'estimate':
             $pdf->SetTitle(__('見積書', 'wc2'));
             $filename = 'estimate_' . $data['dec_order_id'] . '.pdf';
             break;
             //納品書
         //納品書
         case 'deliveryslip':
             $pdf->SetTitle(__('納品書', 'wc2'));
             $filename = 'deliveryslip' . $data['dec_order_id'] . '.pdf';
             break;
             //領収書
         //領収書
         case 'receipt':
             $pdf->SetTitle(__('領収書', 'wc2'));
             $filename = 'receipt_' . $data['dec_order_id'] . '.pdf';
             break;
             //請求書
         //請求書
         case 'invoice':
             $pdf->SetTitle(__('請求書', 'wc2'));
             $filename = 'invoice_' . $data['dec_order_id'] . '.pdf';
             break;
     }
     //表示モードを指定する。
     $pdf->SetDisplayMode('real', 'continuous');
     // 総ページ数のエイリアスを定義する。
     // エイリアスはドキュメントをクローズするときに置換する。
     // '{nb}' で総ページ数が得られる
     $pdf->getAliasNbPages();
     //自動改ページモード
     $pdf->SetAutoPageBreak(true, 5);
     $pdf->SetFillColor(255, 255, 255);
     //**************************************************************
     $page = 1;
     //ページ数の初期化
     //--------------------------------------------------------------
     $this->pdfSetHeader($pdf, $data, $page);
     //$pdf->SetDrawColor(255,0,0);
     $border = 0;
     $pdf->SetLeftMargin(19.8);
     $x = 15.8;
     $y = 101;
     $onep = apply_filters('wc2_filter_pdf_page_height', 190);
     $pdf->SetXY($x, $y);
     $next_y = $y;
     $line_x = array();
     $cart = $data['cart'];
     for ($index = 1; $index <= count($cart); $index++) {
         $cart_row = $cart[$index];
         //if ($cnt > $pageRec-1) {//ページが変わるときの処理
         if ($onep < $next_y) {
             //ページが変わるときの処理
             $pdf->addPage();
             //$pdf->useTemplate($tplidx);
             //-----------------------------------------------------
             $this->pdfSetHeader($pdf, $data, $page);
             $x = 15.8;
             $y = 101;
             $pdf->SetXY($x, $y);
             $next_y = $y;
         }
         //---------------------------------------------------------
         $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);
         $cart_row['options'] = isset($cart_row['options']) ? $cart_row['options'] : '';
         $optstr = '';
         if (is_array($cart_row['options']) && count($cart_row['options']) > 0) {
             foreach ($cart_row['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 . esc_html(urldecode($v));
                             $c = ', ';
                         }
                         $optstr .= "\n";
                     } else {
                         $optstr .= esc_html($key) . ' = ' . esc_html(urldecode($value)) . "\n";
                     }
                 }
             }
             $optstr = apply_filters('wc2_filter_option_pdf', $optstr, $cart_row['options']);
         }
         $optstr = apply_filters('wc2_filter_all_option_pdf', $optstr, $cart_row, $sku_code);
         $line_y[$index] = $next_y;
         list($fontsize, $lineheight, $linetop) = $this->set_font_size(8);
         //10->8
         $pdf->SetFont($font, '', $fontsize);
         $pdf->SetXY($x - 0.2, $line_y[$index] + 0.8);
         $pdf->MultiCell(4, $lineheight, '*', $border, 'C');
         $pdf->SetXY($x + 3.0, $line_y[$index]);
         $pdf->MultiCell(84.59999999999999, $lineheight, $this->conv_enc($cart_item_name), $border, 'L');
         if ('receipt' != $_REQUEST['type']) {
             list($fontsize, $lineheight, $linetop) = $this->set_font_size(8);
             $pdf->SetFont($font, '', $fontsize);
             $pdf->SetXY($x + 6.0, $pdf->GetY() + $linetop);
             $pdf->MultiCell(81.59999999999999, $lineheight - 0.2, $this->conv_enc($optstr), $border, 'L');
         }
         $pdf_args = compact('page', 'x', 'y', 'onep', 'next_y', 'line_x', 'border', 'index', 'cart_row');
         do_action('wc2_action_order_print_cart_row', $pdf, $data, $pdf_args);
         $next_y = $pdf->GetY() + 2;
         list($fontsize, $lineheight, $linetop) = $this->set_font_size(7);
         $pdf->SetFont($font, '', $fontsize);
         $pdf->SetXY($x + 88.0, $line_y[$index]);
         $pdf->MultiCell(11.5, $lineheight, $this->conv_enc($cart_row['quantity']), $border, 'R');
         list($fontsize, $lineheight, $linetop) = $this->set_font_size(7);
         $pdf->SetFont($font, '', $fontsize);
         $pdf->SetXY($x + 99.59999999999999, $line_y[$index]);
         $pdf->MultiCell(11.5, $lineheight, $this->conv_enc($cart_row['unit']), $border, 'C');
         $pdf->SetXY($x + 111.5, $line_y[$index]);
         list($fontsize, $lineheight, $linetop) = $this->set_font_size(7);
         $pdf->SetFont($font, '', $fontsize);
         $pdf->MultiCell(15.2, $lineheight, $this->conv_enc(wc2_get_currency($cart_row['price'])), $border, 'R');
         $pdf->SetXY($x + 126.9, $line_y[$index]);
         list($fontsize, $lineheight, $linetop) = $this->set_font_size(7);
         $pdf->SetFont($font, '', $fontsize);
         $pdf->MultiCell(22.8, $lineheight, apply_filters('wc2_filter_cart_row_price_pdf', $this->conv_enc(wc2_get_currency($cart_row['price'] * $cart_row['quantity'])), $cart_row), $border, 'R');
         if ($onep < $next_y && 0 < $index) {
             $pdf->Rect($x, $line_y[$index] - 0.4, 149.5, 197.4 - $line_y[$index], 'F');
             $pdf->SetXY($x, 193);
             $pdf->MultiCell(88, $lineheight, $this->conv_enc(__('Continued on next page.', 'wc2')), $border, 'C');
             $this->pdfSetLine($pdf);
             $this->pdfSetFooter($pdf, $data);
             $index--;
             $page++;
         }
     }
     $this->pdfSetLine($pdf);
     $this->pdfSetFooter($pdf, $data);
     @ob_end_clean();
     //error表示を取り除く
     // Output
     //*****************************************************************
     $pdf->Output($filename, 'I');
 }
Example #5
0
function wc2_get_admin_order_cart_row($order_id, $cart)
{
    $num = 0;
    ob_start();
    if (is_array($cart) and 0 < count($cart)) {
        foreach ($cart as $idx => $row) {
            if (isset($row['cart_id'])) {
                $cart_id = $row['cart_id'];
                $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'];
                $row_index = $row['row_index'];
                $meta_type = isset($row['meta_type']) ? $row['meta_type'] : array();
                $meta_key = isset($row['meta_key']) ? $row['meta_key'] : array();
                $pictid = wc2_get_mainpictid($item_code);
                $cart_thumbnail = !empty($pictid) ? wc2_the_item_image(0, 60, 60, $post_id) : wc2_no_image();
                $cart_item_name = wc2_get_cart_item_name($item_name, $item_code, $sku_name, $sku_code);
                $cart_options = '';
                $cart_options = apply_filters('wc2_filter_order_cart_row_options', $cart_options, $idx, $row);
                $stock_status = wc2_get_item_stock_status($item_id, $sku_id);
                $stock = wc2_get_item_stock($item_id, $sku_id);
                $stock_signal_red = apply_filters('wc2_filter_stock_signal_red', 20);
                $red = $stock_signal_red < $stock ? ' signal_red' : '';
                $num++;
                ?>
							<tr id="<?php 
                echo $row_index;
                ?>
">
								<td class="num"><?php 
                echo $num;
                ?>
</td>
								<td class="thumbnail"><?php 
                echo $cart_thumbnail;
                ?>
</td>
								<td class="name"><?php 
                esc_html_e($cart_item_name);
                echo $cart_options;
                ?>
</td>
								<td class="price"><input name="sku_price[<?php 
                echo $cart_id;
                ?>
]" id="sku_price-<?php 
                echo $cart_id;
                ?>
" class="text price right" type="text" value="<?php 
                wc2_crform_e($price, false, false, false);
                ?>
" /></td>
								<td class="quantity"><input name="quantity[<?php 
                echo $cart_id;
                ?>
]" id="quantity-<?php 
                echo $cart_id;
                ?>
" class="text quantity right" type="text" value="<?php 
                esc_attr_e($quantity);
                ?>
" /></td>
								<td id="subtotal-<?php 
                echo $cart_id;
                ?>
" class="subtotal">&nbsp;</td>
								<td class="stock<?php 
                echo $red;
                ?>
"><?php 
                echo esc_html($stock_status);
                ?>
</td>
								<td class="action">
								<input type="hidden" name="cart_id[]" id="cart_id-<?php 
                echo $cart_id;
                ?>
" value="<?php 
                esc_attr_e($cart_id);
                ?>
" />
								<input type="hidden" name="cart_post_id[<?php 
                echo $cart_id;
                ?>
]" value="<?php 
                esc_attr_e($post_id);
                ?>
" />
								<input type="hidden" name="item_id[<?php 
                echo $cart_id;
                ?>
]" value="<?php 
                esc_attr_e($item_id);
                ?>
" />
								<input type="hidden" name="sku_id[<?php 
                echo $cart_id;
                ?>
]" value="<?php 
                esc_attr_e($sku_id);
                ?>
" />
								<input type="hidden" name="row_index[<?php 
                echo $cart_id;
                ?>
]" value="<?php 
                esc_attr_e($row_index);
                ?>
" />
							<?php 
                foreach ((array) $meta_type as $type => $meta) {
                    ?>
								<?php 
                    foreach ((array) $meta as $key => $value) {
                        ?>
								<input type="hidden" name="meta_type[<?php 
                        echo $cart_id;
                        ?>
][<?php 
                        echo $type;
                        ?>
][<?php 
                        echo $key;
                        ?>
]" value="<?php 
                        esc_attr_e($value);
                        ?>
" />
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
							<?php 
                foreach ((array) $meta_key as $key => $value) {
                    ?>
								<input type="hidden" name="meta_key[<?php 
                    echo $cart_id;
                    ?>
][<?php 
                    echo $key;
                    ?>
]" value="<?php 
                    esc_attr_e($value);
                    ?>
" />
							<?php 
                }
                ?>
								<input type="button" id="cart-remove-<?php 
                echo $cart_id;
                ?>
" class="cart-remove button" value="<?php 
                _e('削除', 'wc2');
                ?>
" />
								<?php 
                do_action('wc2_action_admin_order_cart_row', $order_id, $cart, $idx);
                ?>
								</td>
							</tr>
<?php 
            }
        }
    }
    $row = ob_get_contents();
    ob_end_clean();
    return apply_filters('wc2_filter_admin_order_cart_row', $row, $order_id, $cart);
}