We have products that are defined as "Kits". They are products that have a list of other products that constitute a kit. The data defining the kit is stored in an array as metadata. I created a hook that displays the metadata on the product page and in the cart. I need to do something similar for the "completed order email" and the "admin order page" but I can't figure out how to go about doing that. Here is the hook that I created:
add_filter( 'bis_show_kit_meta', 'bis_show_kit_meta_contents', 10, 3 );
function bis_show_kit_meta_contents($productID)
{
global $wpdb;
$postMeta = get_post_meta($productID,'',true);
if ((isset($postMeta['bis_kit_id'])) and ($postMeta['bis_kit_id'][0] > 1)) {
echo 'This is a Kit containing the following items:<br>';
echo $postMeta['bis_kit_type'][0].'<br>';
foreach($postMeta as $kititem) {
foreach ($kititem as $value) {
$newvalue = unserialize($value);
if ($newvalue) {
$newvalue2 = unserialize($newvalue);
if($newvalue2['type']=="kititem"){
echo '<li>' .$newvalue2['quantity']. ' -> ' .chr(9). $newvalue2['name']. '</li>';
}
}
}
}
}
}
The current function is hooked to the respective templates in my child theme.
I can't figure out how to apply a similar function to the customer-completed-email.php
file and I have no idea where to hook in the admin edit order pages.
I found some code in another post which looks similar to what I need to do but I can't figure out what file the modifications for the admin order is in.
The code I found is:
add_action('woocommerce_before_order_itemmeta','woocommerce_before_order_itemmeta',10,3);
function woocommerce_before_order_itemmeta($item_id, $item, $product){
...
}
Any suggestions would be greatly appreciated.
source https://stackoverflow.com/questions/76900861/add-order-detail-metadata-to-the-checkout-email-and-the-admin-order-page-in-wooc
No comments:
Post a Comment