i have a script to send an email with attachments but i have a trouble, my script defaultly send 5 attachments and i add the "6th" attachment with this code :
$attachments[]=WP_CONTENT_DIR."/uploads/text_img/".$itemID['order_item_id'].".png";
as you guys see the "6th" attachment is :
".$itemID['order_item_id'].".png";
the "6th" attachment created by opening a script named image080515.php i open that script with a popup like this :
$loc ='http://118.96.90.225/rumahcustom/wp-content/image080515.php';
echo "window.open('$loc', '_blank'); window.focus();";
and the popup is late, the email already sent right before the image has created.
this is the email & 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();
$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://118.96.90.225/rumahcustom/wp-content','',$gfd['source']);
$attachments[]= WP_CONTENT_DIR.$pathImage;
}
}
}
$attachments[]=WP_CONTENT_DIR."/uploads/text_img/".$itemID['order_item_id'].".png";
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments);
}
i wonder can i hold this:
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments);
with something like while or any looping function
all i want is : before this code runs :
$loc ='http://118.96.90.225/rumahcustom/wp-content/image080515.php';
echo "window.open('$loc', '_blank'); window.focus();";
this code will hold (or stop maybe ?)
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments);
Please help and sorry for my bad english
0 comments:
Post a Comment