top of page

Woo Commerce Order Complete Hook

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Dec 25, 2021
  • 1 min read

function lqorder_payment_complete( $order_id ){
    $order = wc_get_order( $order_id );
    $email = $order->get_billing_email();

    $voucher         = '';
    $flag            = false; 
    $message         = '';
    $message        .= '<table>
                        <tr>
                            <td colspan="2"><p>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. </p></td>
                        </tr>
                        <tr>
                            <td colspan="2"><p><strong>Thank you and enjoy your experience!</strong></p></td>
                        </tr>';

    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      .='<tr>
                            <td><strong>MOVIE NAME</strong></td><td>'.$product_name.'</td>
                        </tr>
                        <tr>
                            <td><strong>Voucher Code</strong></td><td>'.$cinesend_asset_id.'</td>
                        </tr>';
        }
    }

    $message      .= '<tr>
                            <td colspan="2">
                            <p>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.
                             </p>
                            <p>All films are geo-blocked to BC only.</p>
                            </td>
                     </tr>
                                     
    </table>';


    $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' );

 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page