/** * Order items meta box * * Displays the order items meta box - for showing individual items in the order * * @since 1.0 */ function jigoshop_order_items_meta_box($post) { $order_items = (array) maybe_unserialize(get_post_meta($post->ID, 'order_items', true)); ?> <div class="jigoshop_order_items_wrapper"> <table cellpadding="0" cellspacing="0" class="jigoshop_order_items"> <thead> <tr> <?php do_action('jigoshop_admin_order_item_header_before_prod_id'); ?> <th class="product-id"><?php _e('ID', 'jigoshop'); ?> </th> <th class="variation-id"><?php _e('Variation ID', 'jigoshop'); ?> </th> <th class="product-sku"><?php _e('SKU', 'jigoshop'); ?> </th> <th class="name"><?php _e('Name', 'jigoshop'); ?> </th> <th class="variation"><?php _e('Variation', 'jigoshop'); ?> </th> <!--<th class="meta"><?php _e('Order Item Meta', 'jigoshop'); ?> </th>--> <?php do_action('jigoshop_admin_order_item_headers'); ?> <th class="quantity"><?php _e('Quantity', 'jigoshop'); ?> </th> <th class="cost"><?php _e('Cost', 'jigoshop'); ?> </th> <th class="tax"><?php _e('Tax Rate', 'jigoshop'); ?> </th> <th class="center" width="1%"><?php _e('Remove', 'jigoshop'); ?> </th> </tr> </thead> <tbody id="order_items_list"> <?php if (sizeof($order_items) > 0 && isset($order_items[0]['id'])) { foreach ($order_items as $item_no => $item) { if (isset($item['variation_id']) && $item['variation_id'] > 0) { $_product = new jigoshop_product_variation($item['variation_id']); if (is_array($item['variation'])) { $_product->set_variation_attributes($item['variation']); } } else { $_product = new jigoshop_product($item['id']); } ?> <tr class="item"> <?php do_action('jigoshop_admin_order_item_before_prod_id', $item_no); ?> <td class="product-id"><?php echo $item['id']; ?> </td> <td class="variation-id"><?php if (isset($item['variation_id'])) { echo $item['variation_id']; } else { echo '-'; } ?> </td> <td class="product-sku"><?php if ($_product->sku) { echo $_product->sku; } ?> </td> <td class="name"><a href="<?php echo esc_url(admin_url('post.php?post=' . $_product->id . '&action=edit')); ?> "><?php echo $item['name']; ?> </a> <?php if (!empty($item['customization'])) { $custom = $item['customization']; $label = apply_filters('jigoshop_customized_product_label', __(' Personal: ', 'jigoshop')); ?> <div class="customization"> <span class="customized_product_label"><?php echo $label; ?> </span> <span class="customized_product"><?php echo $custom; ?> </span> </div> <?php } ?> </td> <td class="variation"><?php if (isset($_product->variation_data)) { echo jigoshop_get_formatted_variation($_product, $item['variation'], true); } else { echo '-'; } ?> </td> <?php do_action('jigoshop_admin_order_item_values', $_product, $item, $post->ID); ?> <td class="quantity"> <input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'jigoshop'); ?> " value="<?php echo esc_attr($item['qty']); ?> " /> </td> <td class="cost"> <input type="text" name="item_cost[]" placeholder="<?php _e('Cost per unit ex. tax e.g. 2.99', 'jigoshop'); ?> " value="<?php echo esc_attr($item['cost']); ?> " /> </td> <td class="tax"> <input type="text" name="item_tax_rate[]" placeholder="<?php _e('Tax Rate e.g. 20.0000', 'jigoshop'); ?> " value="<?php echo esc_attr($item['taxrate']); ?> " /> </td> <td class="center"> <input type="hidden" name="item_id[]" value="<?php echo esc_attr($item['id']); ?> " /> <input type="hidden" name="item_name[]" value="<?php echo esc_attr($item['name']); ?> " /> <input type="hidden" name="item_variation_id[]" value="<?php if ($item['variation_id']) { echo $item['variation_id']; } else { echo ''; } ?> " /> <button type="button" class="remove_row button">×</button> </td> </tr> <?php } } ?> </tbody> </table> </div> <p class="buttons"> <input type='text' class='item_id' name='order_product_select' id='order_product_select' value='' placeholder="<?php _e('Choose a Product', 'jigoshop'); ?> " /> <script type="text/javascript"> /*<![CDATA[*/ jQuery(function() { jQuery("#order_product_select").select2({ minimumInputLength: 3, multiple: false, closeOnSelect: true, ajax: { url: "<?php echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php'); ?> ", dataType: 'json', quietMillis: 100, data: function(term, page) { return { term: term, action: 'jigoshop_json_search_products_and_variations', security: '<?php echo wp_create_nonce("search-products"); ?> ' }; }, results: function( data, page ) { return { results: data }; } }, initSelection: function( element, callback ) { var stuff = { action: 'jigoshop_json_search_products_and_variations', security: '<?php echo wp_create_nonce("search-products"); ?> ', term: element.val() }; jQuery.ajax({ type: 'GET', url: "<?php echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php'); ?> ", dataType: "json", data: stuff, success: function( result ) { callback( result ); } }); } }); }); /*]]>*/ </script> <button type="button" class="button button-primary add_shop_order_item"><?php _e('Add item', 'jigoshop'); ?> </button> </p> <p class="buttons buttons-alt"> <button type="button" class="button button calc_totals"><?php _e('Calculate totals', 'jigoshop'); ?> </button> </p> <div class="clear"></div> <?php }
<?php } ?> </tfoot> <tbody> <?php if (sizeof($order->items) > 0) { ?> <?php foreach ($order->items as $item) { ?> <?php if (isset($item['variation_id']) && $item['variation_id'] > 0) { $product = new jigoshop_product_variation($item['variation_id']); if (is_array($item['variation'])) { $product->set_variation_attributes($item['variation']); } } else { $product = new jigoshop_product($item['id']); } ?> <tr> <td><?php echo $product->get_sku(); ?> </td> <td class="product-name"> <?php echo $item['name']; ?> <?php