<?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 fflcommerce_product_variation($item['variation_id']); if (is_array($item['variation'])) { $product->set_variation_attributes($item['variation']); } } else { $product = new fflcommerce_product($item['id']); } ?> <tr> <td><?php echo $product->get_sku(); ?> </td> <td class="product-name"> <?php echo $item['name']; ?> <?php
/** * Order items meta box * * Displays the order items meta box - for showing individual items in the order * * @since 1.0 */ function fflcommerce_order_items_meta_box($post) { $order_items = (array) maybe_unserialize(get_post_meta($post->ID, 'order_items', true)); ?> <div class="fflcommerce_order_items_wrapper"> <table cellpadding="0" cellspacing="0" class="fflcommerce_order_items"> <thead> <tr> <?php do_action('fflcommerce_admin_order_item_header_before_prod_id'); ?> <th class="product-id"><?php _e('ID', 'fflcommerce'); ?> </th> <th class="variation-id"><?php _e('Variation ID', 'fflcommerce'); ?> </th> <th class="product-sku"><?php _e('SKU', 'fflcommerce'); ?> </th> <th class="name"><?php _e('Name', 'fflcommerce'); ?> </th> <th class="variation"><?php _e('Variation', 'fflcommerce'); ?> </th> <!--<th class="meta"><?php _e('Order Item Meta', 'fflcommerce'); ?> </th>--> <?php do_action('fflcommerce_admin_order_item_headers'); ?> <th class="quantity"><?php _e('Quantity', 'fflcommerce'); ?> </th> <th class="cost"><?php _e('Cost', 'fflcommerce'); ?> </th> <th class="tax"><?php _e('Tax Rate', 'fflcommerce'); ?> </th> <th class="center" width="1%"><?php _e('Remove', 'fflcommerce'); ?> </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 fflcommerce_product_variation($item['variation_id']); if (is_array($item['variation'])) { $_product->set_variation_attributes($item['variation']); } } else { $_product = new fflcommerce_product($item['id']); } ?> <tr class="item"> <?php do_action('fflcommerce_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('fflcommerce_customized_product_label', __(' Personal: ', 'fflcommerce')); ?> <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 fflcommerce_get_formatted_variation($_product, $item['variation'], true); } else { echo '-'; } ?> </td> <?php do_action('fflcommerce_admin_order_item_values', $_product, $item, $post->ID); ?> <td class="quantity"> <input type="text" name="item_quantity[]" placeholder="<?php _e('Quantity e.g. 2', 'fflcommerce'); ?> " 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', 'fflcommerce'); ?> " 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', 'fflcommerce'); ?> " 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', 'fflcommerce'); ?> " /> <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: 'fflcommerce_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: 'fflcommerce_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', 'fflcommerce'); ?> </button> </p> <p class="buttons buttons-alt"> <button type="button" class="button button calc_totals"><?php _e('Calculate totals', 'fflcommerce'); ?> </button> </p> <div class="clear"></div> <?php }