Support » Plugin: Order Approval for WooCommerce » Meta values are not working with woocommerce_email_after_order_table hook

  • Hello Thank you for a good plugin,

    I have one problem, I need to send event details with mail and I saved those details in the meta box and for that am using below code.

    add_action( 'woocommerce_email_after_order_table', 'add_coupon_to_admin_new_order', 10, 1 );
    function add_coupon_to_admin_new_order( $order)
    {
    	$order_id = $order->get_id();
    
    	$event_location = get_field( 'event_location', $order_id);//event_location
    	$event_date = get_field( 'event_date', $order_id); //event_date
    	$event_time = get_field( 'Event Time', $order_id); //Event Time
    	$first_name = get_field( 'first_name', $order_id); //first_name
    	$last_name = get_field( 'last_name', $order_id); //last_name
    
    	$company = get_field( 'company', $order_id);
    
    	$phone = get_field( 'field_6001429c3e0f8', $order_id);
    
    	$event_details .= "";
    	$event_details .= '<h2>Event Details</h2>';
    	$event_details .= '<ul>';
    	$event_details .= '<li><strong>Event Location:</strong> '.$event_location.'</li>';
    	$event_details .= '<li><strong>Event Date:</strong> ' . $event_date . '</li>';
    	$event_details .= '<li><strong>Event Time:</strong> ' . $event_time . '</li>';
    	$event_details .= '<li><strong>First Name:</strong> ' . $first_name . '</li>';
    	$event_details .= '<li><strong>Last Name:</strong> ' . $last_name . '</li>';
    	$event_details .= '<li><strong>Company:</strong> ' . $company . '</li>';
    	$event_details .= '<li><strong>Phone:</strong> ' . $phone . '</li>';
    	$event_details .= '</ul>';
    	echo $event_details;
    }

    It does not work only first-order mail but it works after the order approval and payment.

    Let me know what I did wrong.

    Thank you
    Yuvraj

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.