billing_email, $subject, $message ); } /** * Completed order notification email template - this one includes download links for downloadable products **/ add_action('woocommerce_order_status_completed', 'woocommerce_completed_order_customer_notification'); function woocommerce_completed_order_customer_notification( $id ) { global $order_id, $email_heading; $order_id = $id; $order = &new woocommerce_order( $order_id ); if ($order->has_downloadable_item()) : $subject = __('[%s] Order Complete/Download Links', 'woothemes'); $email_heading = __('Order Complete/Download Links', 'woothemes'); else : $subject = __('[%s] Order Complete', 'woothemes'); $email_heading = __('Order Complete', 'woothemes'); endif; $email_heading = apply_filters('woocommerce_completed_order_customer_notification_subject', $email_heading); $subject = sprintf($subject, get_bloginfo('name')); // Buffer ob_start(); // Get mail template woocommerce_get_template('emails/customer_completed_order.php', false); // Get contents $message = ob_get_clean(); // Send the mail woocommerce_mail( $order->billing_email, $subject, $message ); } /** * Pay for order notification email template - this one includes a payment link **/ function woocommerce_pay_for_order_customer_notification( $id ) { global $order_id, $email_heading; $order_id = $id; $order = &new woocommerce_order( $order_id ); $email_heading = __('Pay for Order', 'woothemes'); $subject = sprintf(__('[%s] Pay for Order', 'woothemes'), get_bloginfo('name')); // Buffer ob_start(); // Get mail template woocommerce_get_template('emails/customer_pay_for_order.php', false); // Get contents $message = ob_get_clean(); // Send the mail woocommerce_mail( $order->billing_email, $subject, $message ); } /** * Low stock notification email **/ function woocommerce_low_stock_notification( $product ) { $_product = &new woocommerce_product($product); $subject = '[' . get_bloginfo('name') . '] ' . __('Product low in stock', 'woothemes'); $message = '#' . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('is low in stock.', 'woothemes'); $message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 ); wp_mail( get_option('woocommerce_stock_email_recipient'), $subject, $message ); } /** * No stock notification email **/ function woocommerce_no_stock_notification( $product ) { $_product = &new woocommerce_product($product); $subject = '[' . get_bloginfo('name') . '] ' . __('Product out of stock', 'woothemes'); $message = '#' . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('is out of stock.', 'woothemes'); $message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 ); wp_mail( get_option('woocommerce_stock_email_recipient'), $subject, $message ); } /** * Backorder notification email **/ function woocommerce_product_on_backorder_notification( $product, $amount ) { $_product = &new woocommerce_product($product); $subject = '[' . get_bloginfo('name') . '] ' . __('Product Backorder', 'woothemes'); $message = $amount . __(' units of #', 'woothemes') . $_product->id .' '. $_product->get_title() . ' ('. $_product->sku.') ' . __('have been backordered.', 'woothemes'); $message = wordwrap( html_entity_decode( strip_tags( $message ) ), 70 ); wp_mail( get_option('woocommerce_stock_email_recipient'), $subject, $message ); } /** * Preview Emails **/ add_action('admin_init', 'woocommerce_preview_emails'); function woocommerce_preview_emails() { if (isset($_GET['preview_woocommerce_mail'])) : $nonce = $_REQUEST['_wpnonce']; if (!wp_verify_nonce($nonce, 'preview-mail') ) die('Security check'); global $email_heading; $email_heading = __('Email preview', 'woothemes'); do_action('woocommerce_email_header'); echo '

WooCommerce sit amet

'; echo wpautop('Ut ut est qui euismod parum. Dolor veniam tation nihil assum mazim. Possim fiant habent decima et claritatem. Erat me usus gothica laoreet consequat. Clari facer litterarum aliquam insitam dolor. Gothica minim lectores demonstraverunt ut soluta. Sequitur quam exerci veniam aliquip litterarum. Lius videntur nisl facilisis claritatem nunc. Praesent in iusto me tincidunt iusto. Dolore lectores sed putamus exerci est. '); do_action('woocommerce_email_footer'); exit; endif; } /** * Add order meta to email templates **/ add_action('woocommerce_email_after_order_table', 'woocommerce_email_order_meta', 10, 2); function woocommerce_email_order_meta( $order, $sent_to_admin ) { $meta = array(); $show_fields = apply_filters('woocommerce_email_order_meta_keys', array('coupons'), $sent_to_admin); if ($order->customer_note) : $meta[__('Note:', 'woothemes')] = wptexturize($order->customer_note); endif; if ($show_fields) foreach ($show_fields as $field) : $value = get_post_meta( $order->id, $field, true ); if ($value) $meta[ucwords(esc_attr($field))] = wptexturize($value); endforeach; if (sizeof($meta)>0) : echo '

'.__('Order information', 'woothemes').'

'; foreach ($meta as $key=>$value) : echo '

'.$key.': '.$value.'

'; endforeach; endif; }