Exemplo n.º 1
0
function wc2_manage_posts_custom_column($column_name, $post_id)
{
    $wc2_item = WC2_DB_Item::get_instance();
    if (is_post_type_archive(ITEM_POST_TYPE)) {
        switch ($column_name) {
            case 'thumbnail':
                $item_code = wc2_get_item_code_by_post_id($post_id);
                $pictid = wc2_get_mainpictid($item_code);
                $cart_thumbnail = !empty($pictid) ? wc2_the_item_image(0, 60, 60, $post_id) : '<img src="' . WC2_PLUGIN_URL . '/common/assets/images/no-image.gif" width="60" height="60" alt="no image">';
                echo $cart_thumbnail;
                break;
            case 'title':
                break;
            case 'skucode':
                echo $wc2_item->get_list_item_sku_code($post_id);
                break;
            case 'skuprice':
                echo $wc2_item->get_list_item_sku_price($post_id);
                break;
            case 'stock':
                echo $wc2_item->get_list_item_sku_stock($post_id);
                break;
            case 'stock_status':
                echo $wc2_item->get_list_item_sku_status($post_id);
                break;
            case 'category':
                $search_genre = apply_filters('wc2_filter_item_search_genre', 'item');
                $terms = get_the_terms($post_id, $search_genre);
                if (!empty($terms)) {
                    $out = array();
                    foreach ($terms as $term) {
                        $out[] = $term->name;
                    }
                    echo join(', ', $out);
                } else {
                    _e('Uncategorized');
                }
                break;
        }
        do_action('wc2_action_manage_posts_custom_column');
    }
}
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_the_item_image_e($number = 0, $width = 60, $height = 60, $post_id = '')
{
    echo wc2_the_item_image($number, $width, $height, $post_id);
}
Exemplo n.º 4
0
function wc2_get_add_item($item_code)
{
    $wc2_item = WC2_DB_Item::get_instance();
    $wc2_item->set_the_code($item_code);
    $item_data = $wc2_item->get_item_data('item_code');
    if (empty($item_data)) {
        die;
    }
    $sku_format = $wc2_item->get_item_sku_format();
    $sku_column = $wc2_item->get_item_sku_column();
    $sku_meta_column = $wc2_item->get_item_sku_meta_column();
    $item_sku = $wc2_item->get_item_sku();
    $pictid = wc2_get_mainpictid($item_code);
    $cart_thumbnail = !empty($pictid) ? wc2_the_item_image(0, 60, 60, $item_data[ITEM_POST_ID]) : wc2_no_image();
    $item_name = $item_data[ITEM_NAME];
    ob_start();
    ?>
	<div id="additem-img"><?php 
    echo $cart_thumbnail;
    ?>
</div>
	<div id="additem-name"><?php 
    esc_html_e($item_name);
    ?>
</div>
<?php 
    foreach ((array) $item_sku as $id => $sku) {
        ?>
	<div id="additem-sku-table-<?php 
        echo $id;
        ?>
">
	<table>
		<thead><tr>
<?php 
        foreach ($sku_format as $sku) {
            foreach ($sku as $key) {
                $label = (array_key_exists($key, $sku_column) and $sku_column[$key]['display'] == '') ? esc_attr($wc2_item->get_the_item_label($key)) : '';
                ?>
			<th><?php 
                echo $label;
                ?>
</th>
<?php 
            }
        }
        ?>
			<th>&nbsp;</th>
		</tr></thead>
		<?php 
        wc2_admin_order_additem_sku_table_e($id);
        do_action('wc2_action_admin_order_additem_sku', $sku, $id);
        ?>
	</table>
	<table>
<?php 
        if (0 < count($sku_meta_column)) {
            foreach ((array) $sku_meta_column as $key => $column) {
                wc2_admin_order_additem_sku_field_e($key, $column, (string) $id);
            }
        }
        do_action('wc2_action_admin_order_additem_sku_meta', $sku, $id);
        ?>
	</table>
	</div>
<?php 
    }
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}