guys can you help me i was trying to add an image into email attachments but the image that i want to add still doesn't appear in the attachments pls help here is my attachments code
function trigger( $order_id ) {
global $wpdb;
if ( $order_id ) {
$this->object = wc_get_order( $order_id );
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
$this->replace['order-number'] = $this->object->get_order_number();
}
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
return;
}
$attachments=array();
$html = '<img border="0" src="your-product.png" alt="Image" width="100" height="100" />';
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$src = $xpath->evaluate("string(//img/@src)");
$getItemID = $wpdb->get_results("SELECT * FROM `wp_woocommerce_order_items` where order_id='".$order_id."' and order_item_type='line_item'",ARRAY_A);
foreach ( $getItemID as $itemID ) {
$getImage = $wpdb->get_results("SELECT * FROM `wp_woocommerce_order_itemmeta` where order_item_id='".$itemID['order_item_id']."' and meta_key='fpd_data'",ARRAY_A);
foreach ( $getImage as $imageID ) {
$unser = unserialize($imageID['meta_value']);
$asd=json_decode($unser['fpd_product'],true);
foreach($asd as $dsa){
foreach($dsa['elements'] as $gfd){
$pathImage=str_replace('http://ift.tt/1KVjj4O','',$gfd['source']);
//$tempat= WP_CONTENT_DIR."uploads/text_img/".$itemID['order_item_id'].".png";
$attachments[]= WP_CONTENT_DIR.$pathImage;
array_push($attachments[],$src);
}
}
}
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments);
}
the image i want to add is "your-product.png" pls help and sorry for my bad english.
this is the send method
public function send( $to, $subject, $message, $headers, $attachments ) {
sleep(10);
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
$message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) );
$return = wp_mail( $to, $subject, $message, $headers, $attachments );
remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
return $return;
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire