I cannot get the order ID in a custom woocommerce email template by shortcode. It does work directly.
Working code in admin-new-order.php
template:
echo $order->get_id();
My shortcode below does not work and I don't know why. My goal is to eventually insert text variables like "Hello Firstname" by shortcode into the email template.
function custom_first_name($order, $order_id){
global $woocommerce, $post;
global $order_id, $order;
$order = new WC_Order( $order_id );
return $order->get_id();
}
add_shortcode( 'custom-woocommerce-name' , 'custom_first_name' );
I add the shortcode to the in admin-new-order.php template via this code:
echo do_shortcode('[custom-woocommerce-name]');
$order->get_id()
and the shortcode should both be outputting the order id.