function fflcommerce_add_order_item()
{
    $fflcommerce_options = FFLCommerce_Base::get_options();
    check_ajax_referer('add-order-item', 'security');
    global $wpdb;
    $item_to_add = trim(stripslashes($_POST['item_to_add']));
    $post = '';
    // Find the item
    if (is_numeric($item_to_add)) {
        $post = get_post($item_to_add);
    }
    if (!$post || $post->post_type !== 'product' && $post->post_type !== 'product_variation') {
        $post_id = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT post_id\n\t\t\tFROM {$wpdb->posts}\n\t\t\tLEFT JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)\n\t\t\tWHERE {$wpdb->postmeta}.meta_key = 'SKU'\n\t\t\tAND {$wpdb->posts}.post_status = 'publish'\n\t\t\tAND {$wpdb->posts}.post_type = 'shop_product'\n\t\t\tAND {$wpdb->postmeta}.meta_value = %s\n\t\t\tLIMIT 1\n\t\t", $item_to_add));
        $post = get_post($post_id);
    }
    if (!$post || $post->post_type !== 'product' && $post->post_type !== 'product_variation') {
        die;
    }
    if ($post->post_type == "product") {
        $_product = new fflcommerce_product($post->ID);
    } else {
        $_product = new fflcommerce_product_variation($post->ID);
    }
    $loop = 0;
    ?>
	<tr class="item">
		<?php 
    do_action('fflcommerce_admin_order_item_before_prod_id', intval($_POST['item_no']));
    ?>
		<td class="product-id">#<?php 
    echo $_product->id;
    ?>
</td>
		<td class="variation-id"><?php 
    if (isset($_product->variation_id)) {
        echo $_product->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 $_product->get_title();
    ?>
</a></td>
		<td class="variation"><?php 
    if (isset($_product->variation_data)) {
        echo fflcommerce_get_formatted_variation($_product, array(), true);
    } else {
        echo '-';
    }
    ?>
</td>
		
		<?php 
    do_action('fflcommerce_admin_order_item_values', $_product, array(), 0);
    ?>
		<td class="quantity"><input type="text" name="item_quantity[]" placeholder="<?php 
    _e('Quantity e.g. 2', 'fflcommerce');
    ?>
" value="1" /></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($fflcommerce_options->get('fflcommerce_prices_include_tax') == 'yes' ? $_product->get_price_excluding_tax() : $_product->get_price());
    ?>
" /></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(fflcommerce_tax::calculate_total_tax_rate($_product->get_tax_base_rate()));
    ?>
" /></td>
		<td class="center">
			<input type="hidden" name="item_id[]" value="<?php 
    echo esc_attr($_product->id);
    ?>
" />
			<input type="hidden" name="item_name[]" value="<?php 
    echo esc_attr($_product->get_title());
    ?>
" />
            <input type="hidden" name="item_variation_id[]" value="<?php 
    if ($_product instanceof fflcommerce_product_variation) {
        echo esc_attr($_product->variation_id);
    } else {
        echo '';
    }
    ?>
" />
			<button type="button" class="remove_row button">&times;</button>
		</td>
	</tr>
	<?php 
    // Quit out
    die;
}