Skip to main content

woocommerce_checkout_order_processed hook

add_action( 'woocommerce_checkout_order_processed', 'thrd_party_mails',  1, 1  );
function thrd_party_mails( $order_id ){

$order = new WC_Order( $order_id );
if (isset($order) && !empty($order)) {
$items = $order->get_items();
$admin_email = get_option( 'admin_email' );
foreach ( $items as $item ) {
    $product_name = $item->get_name();
    $product_id = $item->get_product_id();
    $product_variation_id = $item->get_variation_id();
    $is_3rd_party = get_field( "is_3rd_party", $product_id );
    if (isset($is_3rd_party) && $is_3rd_party=='yes') {
     $th_party_email = get_field( "3rd_party_email", $product_id );
     $is_th_party_mail_subject = get_field( "is_3rd_party_mail_subject", $product_id );
     $th_party_content = get_field( "3rd_party_content", $product_id );
     $th_party_bottom_content = get_field( "3rd_party_bottom_content", $product_id );
     $th_party_admin_mail = get_field( "3rd_party_admin_mail", $product_id );

     if (isset($th_party_admin_mail) && $th_party_admin_mail==1) {
      $thtomail =$admin_email.' ,'.$th_party_email;
     }else {
     $thtomail = $th_party_email;
     }

     $ordrfirstname =  $order->get_billing_first_name();
     $ordrlastname = $order->get_billing_last_name();
     $ordremail =  $order->get_billing_email();

$headers[] = 'From: PM Champion <info@pmchampion.com>';
    $headers[] = 'Content-Type: text/html; charset=UTF-8';
$thcontent="<table style='text-align: left;''>
<tr> <th style=' padding-bottom: 15px;' colspan='2'>New Order Mail #".$order_id."</th></tr>
<tr><td  style=' padding-bottom: 15px;' colspan='2'>".$th_party_content."</td></tr>
<tr> <th>Client Info:</th> </tr>
<tr><th>First Name</th> <td>".$ordrfirstname."</td> </tr>
<tr><th>Last  Name</th> <td>".$ordrlastname."</td> </tr>
<tr><th>E-Mail: </th> <td>".$ordremail."</td> </tr>
<tr><th style=' padding-bottom: 15px;'>Order iD </th> <td style=' padding-bottom: 15px;'>#".$order_id."</td> </tr>
<tr><td colspan='2'>".$th_party_bottom_content."</td></tr>
</table>";
wp_mail( $thtomail, $is_th_party_mail_subject, $thcontent, $headers );

    } 

   }

}
}

Comments

Popular posts from this blog

High light Search Result In Wordpress

High light Search Result In Wordpress add this function in your themes function.php function highlight_results ( $ text ) {      if ( is_search ( ) ) { $ keys = implode ( '|' , explode ( ' ' , get_search_query ( ) ) ) ; $ text = preg_replace ( '/(' . $ keys . ')/iu' , '<span class="search-highlight">\0</span>' , $ text ) ;      }      return $ text ; } add_filter ( 'the_content' , 'highlight_results' ) ; add_filter ( 'the_excerpt' , 'highlight_results' ) ; add_filter ( 'the_title' , 'highlight_results' ) ;   function highlight_results_css ( ) { ? > <style> .search-highlight { background-color : #FF0 ; font-weight : bold ; } </style> < ? php } add_action ( 'wp_head' , 'highlight_results_css' ) ;

Redirect In contact form 7

add_action( 'wp_footer' , 'redirect_cf7' ); function redirect_cf7() { ?> < script type = "text/javascript" > document.addEventListener( 'wpcf7mailsent' , function ( event ) { if ( '1377' == event.detail.contactFormId ) { // Sends sumissions on form 947 to the first thank you page location = 'https://www.panelesyceldassolares.com/regreso' ; } else { // Sends submissions on all unaccounted for forms to the third thank you page location = 'https://www.panelesyceldassolares.com/regreso-2/' ; } }, false ); </ script > <?php }

Get Single Product By ID in Opencart

<?php if(!empty($_POST["country_id"])) {     $query ="SELECT * FROM oc_product WHERE product_id = '" . $_POST["country_id"] . "'";     $results = $this->db->query($query);   $query2 ="SELECT * FROM oc_product_description WHERE product_id = '" . $_POST["country_id"] . "'";   $results2 = $this->db->query($query2);   $rowresults2 = $results2->row;   $rowresults = $results->row;   $name1 = $rowresults['model'];   $name2 = $rowresults2['name'];   $name3 = $rowresults['price'];   $name4 = 'Exe.' ?>