1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
| public static function send_email() {
$email = get_option('dvin_wcql_admin_email', 'req_email');
$subject = get_option('dvin_wcql_email_subject');
$message = get_option('dvin_wcql_email_msg');
$quote_list ='<table cellspacing="0" cellpadding="15"><tr><td>'.__('Afbeelding','dvinwcql').'</td><d>'.__('Product Name','dvinwcql').'</td><td>'.__('Quantity','dvinwcql').'</td><td>'.__('','dvinwcql').'</td><td>'.__('','dvinwcql').'</td></tr>';
$row_str = '<tr><td align="left">%s</td><td align="left">%s</td><td align="left">%s</td><td align="left">%s</td><td align="left">%s</td></tr>';
$qlist = array();
if(isset($_SESSION['dvin_qlist_products'])) {
$qlist_count[0]['cnt'] = count($_SESSION['dvin_qlist_products']);
$qlist = $_SESSION['dvin_qlist_products'];
}
foreach($qlist as $values) {
//initialize to avoid notices
if(!isset($values['variation_id']))
$values['variation_id']=0;
if (isset($values['add-to-quotelist']) && is_numeric($values['add-to-quotelist'])) {
$values['prod_id'] = $values['ID'] = $values['add-to-quotelist'];
$values['ID'] = $values['add-to-quotelist'];
}else{
$values['prod_id'] = $values['ID'] = $values['product_id'];
if(!empty($values['variation_id']))
$values['ID'] = $values['product_id'].'_'.$values['variation_id'];
}
if ( version_compare( WOOCOMMERCE_VERSION, "2.0.0" ) >= 0 ) {
// WC 2.0
$product_obj = !empty($values['variation_id'])?get_product($values['variation_id'],array('parent_id'=>$values['product_id'])): get_product($values['prod_id']);
}else{
if(!empty($values['variation_id'])) {
$product_obj = new WC_Product_Variation($values['variation_id'],$values['product_id']);
}else{
$product_obj = new WC_product($values['prod_id']);
}
}
if ($product_obj->exists()) {
$image_str = $product_obj->get_image();
}
$product_name_str = apply_filters('woocommerce_in_cartproduct_obj_title', $product_obj->get_sku(), $product_obj);
if(!empty($values['variation_id'])){
$product_name_str .= woocommerce_get_formatted_variation(unserialize($values['variation_data']),false);
}
$quantity = $values['quantity'];
$quote_list .= sprintf($row_str,$image_str,$product_name_str,$quantity,$unit_price_str,$total_price_str );
$overall_tot_price += $total_price;
}
$quote_list .='</table>';
$overall_tot_price_str = apply_filters('woocommerce_cart_item_price_html', woocommerce_price( $overall_tot_price));
$needle_arr = array('[%req_name%]','[%req_email%]','[%req_bedrijf%]','[%req_telefoon%]','[%quotelist%]','[%total_price%]','[%comments%]');
$replace_with_arr = array(ucwords($_POST['req_name']),$_POST['req_email'],$_POST['req_bedrijf'],$_POST['req_telefoon'],$quote_list,$overall_tot_price_str,$_POST['req_details']);
$subject = str_replace($needle_arr,$replace_with_arr,$subject);
$message = str_replace($needle_arr,$replace_with_arr,$message);
$message ='<html><body><style>table, th, td{border: 1px solid black;}</style>'.$message.'</body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To:'.$email . "\r\n";
$headers .= 'From: '.$_POST['req_email']."\r\n";
//send the email
return mail($email, $subject, nl2br($message),$headers); |