Woo Commerce Order Complete Hook

Woo Commerce Order Complete Hook
function lqorder_payment_complete( $order_id ){
    $order = wc_get_order( $order_id );
    $email = $order->get_billing_email();

    $voucher         = '';
    $flag            = false; 
    $message         = '';
    $message        .= '';

    foreach ( $order->get_items() as $item_id => $item ) {
       $product_id   = $item->get_product_id();
       $variation_id = $item->get_variation_id();
       $product      = $item->get_product();
       $product_name = $item->get_name();
       $quantity     = $item->get_quantity();
       $subtotal     = $item->get_subtotal();
       $total        = $item->get_total();
       $tax          = $item->get_subtotal_tax();
       $taxclass     = $item->get_tax_class();
       $taxstat      = $item->get_tax_status();
       $allmeta      = $item->get_meta_data();
       $product_type = $item->get_type();

       $cinesend_asset_id = get_post_meta($product_id, 'cinesend_asset_id',true);

      
       if($cinesend_asset_id){

       $flag         = true;  

       $message      .='';
        }
    }

    $message      .= '

Congratulations! You have purchased a ticket to watch a Victoria Film Festival 2022 film online. Please see the link and a voucher code below to watch your selected film online.

Thank you and enjoy your experience!

MOVIE NAME'.$product_name.'
Voucher Code'.$cinesend_asset_id.'

You can watch the film between February 4th 12:00 am and February 13th 10:00 pm. Please make sure you start watching all your purchased films by then because access to the Festival programming will be closed on February 13th at midnight.

All films are geo-blocked to BC only.

'; $from = 'info@filmfestival.com'; $headers[] = 'Content-Type: text/html; charset=UTF-8'; $headers[] = 'From: VFF <'.$from.'>'; if($flag == true){ wp_mail($email,'Virtual Ticket Confirmation', $message, $headers); } } add_action( 'woocommerce_payment_complete', 'lqorder_payment_complete' ); #add_action( 'woocommerce_thankyou', 'lqorder_payment_complete' );

Leave a Reply

Your email address will not be published. Required fields are marked *