You haven’t given us much to go on. If all else fails, the ‘wp_mail’ filter will allow you to alter any email message that goes out using the wp_mail()
function. The trick would be identifying the order email amongst all the other emails that go out.
If your e-commerce system is WooCommerce (is it?) there are likely a few filter options that are more specific. It’d be a matter of digging through Woo code to identify the best filter. Having dug through Woo code before, try finding something in their documentation or even asking their support staff is a better option — they know their product better than anyone here.
As for attaching the data to an order, orders in Woo are just custom post types, you can store the data with the associated post meta. Where to display the data in admin would depend on where you want to see it. For this you can override default Woo templates to include the value, it’s a matter of identifying the proper template. More digging!
Thread Starter
Tidan
(@tidan)
Sorry for the ambiguity. Yes, using woocommerce.
I’ve hacked into the code so many times and tried so many different things I’ve lost track of what I’ve tried so far.
Currently I’m working on a mod to the themes function.php file to see if that will work:
add_action( ‘woocommerce_checkout_update_order_meta’, ‘platoon_add_order_meta’, 10, 2 );
if(!empty($_SESSION[‘kioskID’])) $kID = “SESSION “.$_SESSION[‘kioskID’];
else $kID = “NoSessVar”;
function platoon_add_order_meta( $order_id, $posted ) {
update_post_meta( $order_id, ‘kioskIDPT’, $kID );
}
AND this mod:
add_filter( ‘woocommerce_new_order_data’ , ‘add_params_details_to_order’ );
// Our hooked in function – $fields is passed via the filter!
function add_params_details_to_order( $fields ) {
$fields[‘post_excerpt’] = $fields[‘post_excerpt’] . “\n ——————- \n kioskIDtest2: “.$_SESSION[‘kioskID’].” \n” . params_details(true);
return $fields;
}
Not sure if this is what I need, but it does append the kioskID to the customer email under the ‘notes’ section. But we need the business copy to include this as well – or possibly some better method?!
I’m afraid I don’t have anything more to add that hasn’t been said 🙁
I can see now you know as well as I do that hooks are required, but they can be difficult to find. We’re not the Woo experts here, and I know Woo support for free products is weak. Finding the right hook in Woo is best, but you could make ‘wp_mail’ work by having your callback check for unique content that would identify the email of interest and modify accordingly. Not the best approach, but it will work if you can’t find the right hook.
Thread Starter
Tidan
(@tidan)
Thanks bcworkz. I’ll look into those options as well.