I am having a real difficulty in trying to filter some data that is going out into an e-mail after the customer places an order. The issue is that every line item is showing the shipping information (pickup location) even though it is the same as the final pickup location at the end of the order.
I have been able to look at the item_meta data which is given, but I am unsure of how to filter it to essentially remove the array portion which has the "Pickup Location' meta key and then still print the rest. Here is the area of the email-order-items.php file where the data is being generated (it is not custom...this is standard for WooCommerce):
if ( ! empty( $item_meta->meta ) ) {
echo '<br/><small>' . nl2br( $item_meta->display( true, true, '_', "\n" ) ) . '</small>';
}
Here is what I am able to see by simply doing:
foreach ($item_meta as $value) {
print_r($value);
}
Result:
Cookie → Cookie (One-Time)Array ( [_qty] => Array ( [0] => 1 ) [_tax_class] => Array ( [0] => ) [_product_id] => Array ( [0] => 5807 ) [_variation_id] => Array ( [0] => 0 ) [_line_subtotal] => Array ( [0] => 2.5 ) [_line_total] => Array ( [0] => 0 ) [_line_subtotal_tax] => Array ( [0] => 0.15 ) [_line_tax] => Array ( [0] => 0 ) [_line_tax_data] => Array ( [0] => a:2:{s:5:"total";a:1:{i:1;s:1:"0";}s:8:"subtotal";a:1:{i:1;s:4:"0.15";}} ) [_shipping_item_id] => Array ( [0] => 28795 ) [Pickup Location] => Array ( [0] => PICKUP ADDRESS HERE, City, State, Zip ) ) WC_Product_Simple Object ( [id] => 5807 [post] => WP_Post Object ( [ID] => 5807 [post_author] => 596 [post_date] => 2016-07-23 17:55:10 [post_date_gmt] => 2016-07-23 21:55:10 [post_content] => [post_title] => Power Protein Cookie (One-Time) [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => power-protein-cookie-one-time [to_ping] => [pinged] => [post_modified] => 2016-07-23 19:39:18 [post_modified_gmt] => 2016-07-23 23:39:18 [post_content_filtered] => [post_parent] => 5806 [menu_order] => 1 [post_type] => product [post_mime_type] => [comment_count] => 0 [filter] => raw ) [product_type] => simple [shipping_class:protected] => [shipping_class_id:protected] => 0 ) ]
How can I iterate through the item_meta data, unset (I think is the way to do it) the Pickup Location data and then still display the rest?
UPDATE: I went in and tried the following code:
if(is_array($item_meta->meta))
{
foreach($item_meta->meta as $key => $value)
{
echo $key . '<br />' . $value;
}
}
That gave me the following:
Cookie → Cookie (One-Time)_qty Array_tax_class Array_product_id Array_variation_id Array_line_subtotal Array_line_total Array_line_subtotal_tax Array_line_tax Array_line_tax_data Array_shipping_item_id ArrayPickup Location Array
I feel like I am fairly close but not understanding the structure of what is inside of item_meta very well...any help would be appreciated.
'; The question is now how do I actually remove it from the item_meta container appropriately? I've tried to set $value2 (which is what I want gone) to blank but it doesn't do anything. What would be the 'proper' way to eliminate that from the item_meta object? – user2018888 Aug 16 '16 at 22:02