add_action( 'woocommerce_add_to_cart', 'cwpai_woo_send_email_to_admin_on_add_to_cart', 10, 6 );
function cwpai_woo_send_email_to_admin_on_add_to_cart( $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ) {
$product = wc_get_product( $product_id );
$product_name = $product->get_name();
if ( isset( $_POST['add-to-cart']) ) {
$company_name = $_POST['membership_company_name'];
$contact_person = $_POST['membership_contact_person'];
$membership_address = $_POST['membership_address'];
$membership_city_town = $_POST['membership_city_town'];
$province = $_POST['province'];
$postal_code = $_POST['postal_code'];
$wcb = $_POST['wcb'];
$industry_code_s = $_POST['industry_code_s'];
$cor = $_POST['cor'];
$expiry_date = $_POST['expiry_date'];
$if_your = $_POST['if_your'];
}
$data = "<table style='width:50%' cellpadding='5'><tr>
<th>Item</th>
<th>Description</th>
</tr><tr>
<td>Name</td>
<td>$product_name</td>
</tr>
<tr>
<td>Company Name:</td>
<td>$company_name</td>
</tr>
<tr>
<td>Address</td>
<td>$membership_address</td>
</tr>
<tr>
<td>City/Town</td>
<td>$membership_city_town</td>
</tr>
<tr>
<td>Province</td>
<td>$province</td>
</tr>
<tr>
<td>Postal Code</td>
<td>$postal_code</td>
</tr>
<tr>
<td>WCB #</td>
<td>$wcb</td>
</tr>
<tr>
<td>Industry Code(s)</td>
<td>$industry_code_s</td>
</tr>
<tr>
<td>C.O.R #</td>
<td>$cor</td>
</tr>
<tr>
<td>Expiry Date</td>
<td>$expiry_date</td>
</tr>
<tr>
<td>If your company has ever registered with another Certifying Partner please name</td>
<td>$if_your</td>
</tr></table>";
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( 'example@gmail.com', 'New notification', $data, $headers );
}