Exemplo n.º 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;
}
Exemplo n.º 2
0
 public function pdfSetFooter($pdf, $data)
 {
     global $wc2;
     $wc2_options = wc2_get_option();
     $font = $this->font;
     $border = 0;
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(9);
     $pdf->SetFont($font, '', $fontsize);
     // Body label
     $pdf->SetXY(15.5, 94.90000000000001);
     $pdf->MultiCell(87.8, $lineheight, $this->conv_enc(__('Item name', 'wc2')), $border, 'C');
     $pdf->SetXY(103.7, 94.90000000000001);
     $pdf->MultiCell(11.4, $lineheight, $this->conv_enc(__('Quantity', 'wc2')), $border, 'C');
     $pdf->SetXY(115.8, 94.90000000000001);
     $pdf->MultiCell(11.0, $lineheight, $this->conv_enc(__('Unit', 'wc2')), $border, 'C');
     $pdf->SetXY(127.2, 94.90000000000001);
     $pdf->MultiCell(15.0, $lineheight, $this->conv_enc(__('Price', 'wc2')), $border, 'C');
     $pdf->SetXY(142.9, 94.90000000000001);
     $pdf->MultiCell(22.4, $lineheight, $this->conv_enc(__('Amount', 'wc2') . '(' . __(wc2_crcode(), 'wc2') . ')'), $border, 'C');
     // Footer label
     $labeldata = array('order_condition' => $data['order_condition'], 'order_item_total_price' => $data['item_total_price'], 'order_discount' => $data['discount'], 'order_shipping_charge' => $data['shipping_charge'], 'order_cod_fee' => $data['cod_fee']);
     $pdf->SetXY(104.3, 198.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(__('Total amount of items', 'wc2')), $border, 'C');
     $pdf->SetXY(104.3, 204.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(apply_filters('wc2_filter_discount_label', __('Discount', 'wc2'), $data)), $border, 'C');
     if ('products' == wc2_get_tax_target()) {
         $data_1 = apply_filters('wc2_filter_tax_label', wc2_tax_label($labeldata));
         $data_2 = apply_filters('wc2_filter_shipping_label', __('Shipping charges', 'wc2'));
         $data_3 = apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2'));
     } else {
         $data_1 = apply_filters('wc2_filter_shipping_label', __('Shipping charges', 'wc2'));
         $data_2 = apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2'));
         $data_3 = apply_filters('wc2_filter_tax_label', wc2_tax_label($labeldata));
     }
     $pdf->SetXY(104.3, 210.8);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_1), $border, 'C');
     $pdf->SetXY(104.3, 216.7);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_2), $border, 'C');
     $pdf->SetXY(104.3, 222.7);
     $pdf->MultiCell(37.7, $lineheight, $this->conv_enc($data_3), $border, 'C');
     if (wc2_is_membersystem_point()) {
         $pdf->SetXY(104.3, 228.6);
         $pdf->MultiCell(37.7, $lineheight, $this->conv_enc(apply_filters('wc2_filter_point_label', __('Used points', 'wc2'))), $border, 'C');
         $pdf->SetXY(104.3, 235.8);
         $pdf->MultiCell(37.77, $lineheight, $this->conv_enc(__('Total Amount', 'wc2')), $border, 'C');
     } else {
         $pdf->SetXY(104.3, 235.8);
         $pdf->MultiCell(37.77, $lineheight * 2, $this->conv_enc(__('Total Amount', 'wc2')), $border, 'C');
     }
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(8);
     $pdf->SetFont($font, '', $fontsize);
     // Footer value
     $payment = wc2_get_payment($data['payment_method']);
     $transfers = apply_filters('wc2_filter_pdf_transfer', array('BT'), $data);
     if ('invoice' == $_REQUEST['type'] && in_array($payment['settlement'], $transfers)) {
         $transferee = __('Transfer', 'wc2') . " : \r\n";
         $transferee .= wc2_get_option('transferee_info') . "\r\n";
         $note_text = apply_filters('wc2_filter_mail_transferee', $transferee, $data, 'pdf', $payment);
     } else {
         $note_text = $data['note'];
     }
     $pdf->SetXY(16.1, 198.8);
     $pdf->MultiCell(86.59999999999999, $lineheight, $this->conv_enc(apply_filters('wc2_filter_pdf_note', $note_text, $data, $_REQUEST['type'])), $border, 'J');
     list($fontsize, $lineheight, $linetop) = $this->set_font_size(9);
     $pdf->SetFont($font, '', $fontsize);
     $pdf->SetXY(142.9, 198.8);
     $total_price = $data['item_total_price'] - $data['usedpoint'] + $data['discount'] + $data['shipping_charge'] + $data['cod_fee'] + $data['tax'];
     $pdf->MultiCell(22.6, $lineheight, wc2_get_currency($data['item_total_price']), $border, 'R');
     $materials = array('total_price' => $data['item_total_price'], 'discount' => $data['discount'], 'shipping_charge' => $data['shipping_charge'], 'cod_fee' => $data['cod_fee']);
     if ('include' == $wc2_options['general']['tax_mode']) {
         $tax = '(' . wc2_internal_tax($materials) . ')';
     } else {
         $tax = wc2_get_currency($data['tax']);
     }
     if ('products' == wc2_get_tax_target()) {
         $datav_1 = apply_filters('wc2_filter_tax_value', $tax, $data);
         $datav_2 = apply_filters('wc2_filter_shipping_value', wc2_get_currency($data['shipping_charge']), $data);
         $datav_3 = apply_filters('wc2_filter_cod_value', wc2_get_currency($data['cod_fee']), $data);
     } else {
         $datav_1 = apply_filters('wc2_filter_shipping_value', wc2_get_currency($data['shipping_charge']), $data);
         $datav_2 = apply_filters('wc2_filter_cod_value', wc2_get_currency($data['cod_fee']), $data);
         $datav_3 = apply_filters('wc2_filter_tax_value', $tax, $data);
     }
     $pdf->SetXY(142.9, 204.8);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc(apply_filters('wc2_filter_discount_value', wc2_get_currency($data['discount']), $data)), $border, 'R');
     $pdf->SetXY(142.9, 210.8);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_1), $border, 'R');
     $pdf->SetXY(142.9, 216.7);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_2), $border, 'R');
     $pdf->SetXY(142.9, 222.7);
     $pdf->MultiCell(22.6, $lineheight, $this->conv_enc($datav_3), $border, 'R');
     if (wc2_is_membersystem_point()) {
         $pdf->SetXY(142.9, 228.6);
         $pdf->MultiCell(22.6, $lineheight, $this->conv_enc(apply_filters('wc2_filter_point_value', wc2_get_currency($data['usedpoint']), $data)), $border, 'R');
         $pdf->SetXY(142.9, 235.8);
         $pdf->MultiCell(22.67, $lineheight, $this->conv_enc(wc2_get_currency($total_price)), $border, 'R');
     } else {
         $pdf->SetXY(142.9, 235.8);
         $pdf->MultiCell(22.67, $lineheight, $this->conv_enc(wc2_get_currency($total_price)), $border, 'R');
     }
     do_action('wc2_action_order_print_footer', $pdf, $data);
 }