2015-12-17 3 views
1

Я пытаюсь достичь, как показано ниже.Уведомление электронной почты Woocommerce на другой адрес электронной почты в поле для отправки

Я хочу отправить продукт woocommerce в подарок моему другу или брату или тому подобное. Для этого я буду зависеть от поля «Корабль в другом адресе» на странице проверки. Поэтому, если кто-то хочет отправить этот товар в подарок, он может отправить товар другому адресу доставки, который является адресом получателя подарка.

Для этого я изменил страницу проверки, чтобы добавить поле электронной почты в раздел «Корабль в другой адрес».

Теперь то, что я хочу, что я хочу, чтобы отправить уведомление по электронной почте о порядке в дар приемник также так, что приемник знает, что кто-то подарил ему этот продукт ..

Как я могу отправить уведомление по электронной почте о заказе на адрес электронной почты получателя?

Благодаря

ответ

0

На самом деле мне не нужно это больше сделать. Но я думаю, что этот плагин http://codecanyon.net/item/woocommerce-checkout-field-editor/11725925 сделает все для вас в поле проверки, которое вы хотите сделать. Это то, что мне нужно.

Спасибо за усилие

+0

Я не думаю, что плагин отправит уведомления по электронной почте в новое добавленное поле электронной почты. По крайней мере, он не упоминается нигде в тексте продаж. Так что это некая плохая форма, чтобы отметить это как ответ, когда не подтверждено решение вопроса, как написано. – helgatheviking

0

Вот плагин, который я написал, чтобы добавить доставки электронной почты. Он должен работать, но я написал это некоторое время назад, поэтому никаких гарантий.

<?php 
/* 
Plugin Name: WooCommerce Shipping Email 
Plugin URI: http://www.kathyisawesome.com/ 
Description: Add a shipping email field to checkout and notify of new orders 
Version: 1.0 
Author: Kathy Darling 
Author URI: http://kathyisawesome.com 
Requires at least: 4.0 
Tested up to: 4.0 

Copyright: © 2014 Kathy Darling. 
License: GNU General Public License v3.0 
License URI: http://www.gnu.org/licenses/gpl-3.0.html 

*/ 


/** 
* The Main WC_Shipping_Email class 
**/ 
if (! class_exists('WC_Shipping_Email')) : 

class WC_Shipping_Email { 

    /** 
    * @var WC_Shipping_Email - the single instance of the class 
    * @since 1.0 
    */ 
    protected static $_instance = null;   

    /** 
    * Main WC_Shipping_Email Instance 
    * 
    * Ensures only one instance of WC_Shipping_Email is loaded or can be loaded. 
    * 
    * @static 
    * @see WC_Shipping_Email() 
    * @return WC_Shipping_Email - Main instance 
    * @since 1.0 
    */ 
    public static function instance() { 
     if (is_null(self::$_instance)) { 
      self::$_instance = new self(); 
     } 
     return self::$_instance; 
    } 

    /** 
    * Cloning is forbidden. 
    * 
    * @since 1.0 
    */ 
    public function __clone() { 
     _doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'woocommerce-mix-and-match'), '2.0'); 
    } 

    /** 
    * Unserializing instances of this class is forbidden. 
    * 
    * @since 1.0 
    */ 
    public function __wakeup() { 
     _doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'mix-and-match'), '2.0'); 
    } 

    /** 
    * WC_Shipping_Email Constructor 
    * 
    * @access public 
    * @return WC_Shipping_Email 
    * @since 1.0 
    */ 

    public function __construct() { 

     $this->id = 'email'; 
     $this->meta = '_shipping_email'; 
     $this->label = __('Shipping Email', 'woocommerce-shipping-email'); 

     // add email field to checkout 
     add_filter('woocommerce_shipping_fields' , array($this, 'add_shipping_fields')); 
     add_filter('woocommerce_admin_shipping_fields' , array($this, 'admin_shipping_fields')); 

     // add recipient to specific emails 
     add_filter('woocommerce_email_recipient_customer_processing_order' , array($this, 'add_recipient'), 20, 2); 
     add_filter('woocommerce_email_recipient_customer_completed_order' , array($this, 'add_recipient'), 20, 2); 
     add_filter('woocommerce_email_recipient_customer_note' , array($this, 'add_recipient'), 20, 2); 

     // display meta key in order overview 
     add_action('woocommerce_order_details_after_customer_details' , array($this, 'after_customer_details')); 

     // display meta key in email 
     add_action('woocommerce_before_template_part' , array($this, 'before_email_addresses'), 10, 4); 

    } 


    /*-----------------------------------------------------------------------------------*/ 
    /* Plugin Functions */ 
    /*-----------------------------------------------------------------------------------*/ 

    /** 
    * Add email to front-end shipping fields 
    * 
    * @var array $fields 
    * @return array 
    * @since 1.0 
    */ 

    function add_shipping_fields($fields) { 
     $fields['shipping_' . $this->id] = array(
      'label'   => $this->label, 
      'required'  => true, 
      'class'   => array('form-row-first'), 
      'validate'  => array('email'), 
     ); 
     return $fields; 
    } 

    /** 
    * Add email to Admin Order overview 
    * 
    * @var array $fields 
    * @return array 
    * @since 1.0 
    */ 

    function admin_shipping_fields($fields) { 
     $fields[$this->id] = array(
      'label'   => $this->label 
     ); 
     return $fields; 
    } 

    /** 
    * Add recipient to emails 
    * 
    * @var mixed $email 
    * @return mixed 
    * @since 1.0 
    */ 
    function add_recipient($email, $order) { 
     $additional_email = get_post_meta($order->id, $this->meta, true); 
     if($additional_email && is_email($additional_email)){ 
      $email = explode(',', $email); 
      array_push($email, $additional_email); 
     } 
     return $email; 
    } 

    /** 
    * Display meta in my-account area Order overview 
    * 
    * @var object $order 
    * @return null 
    * @since 1.0 
    */ 

    public function after_customer_details($order){ 

     $value = get_post_meta($order->id, $this->meta, true); 

     if($value){ 
      echo '<dt>' . $this->label . ':</dt><dd>' . $value . '</dd>'; 
     } 

    } 

    /** 
    * Display meta in my-account area Order overview 
    * 
    * @var array $fields 
    * @return array 
    * @since 1.0 
    */ 

    public function before_email_addresses($template_name, $template_path, $located, $args){ 

     if($template_name == 'emails/email-addresses.php' && isset($args['order' ]) && ($value = get_post_meta($args['order']->id, $this->meta, true))){ 

      if (isset($args['plain_text']) && $args['plain_text']){ 

       echo $this->label . ': ' . $value . "\n"; 

      } else { 

       echo '<p><strong>' . $this->label . ':</strong> ' . $value . '</p>'; 

      } 

     } 

    } 



} //end class: do not remove or there will be no more guacamole for you 

endif; // end class_exists check 


/** 
* Returns the main instance of WC_Shipping_Email to prevent the need to use globals. 
* 
* @since 2.0 
* @return WooCommerce 
*/ 
function WC_Shipping_Email() { 
    return WC_Shipping_Email::instance(); 
} 

// Launch the whole plugin 
WC_Shipping_Email(); 

Вот результат на странице оформления заказа, вы можете увидеть, что поле Email Доставка будет добавлен в «корабль на другой адрес» колонке.

Result in Twenty Sixteen

+0

Мне нужно это поле электронной почты в поле «Корабль в другую форму адреса». Пожалуйста, просмотрите этот снимок экрана http://prntscr.com/9fqutp и прокомментируйте на скриншоте –

+0

Я не понимаю ваших комментариев. На моем снимке экрана вы можете увидеть, что поле «Отправка электронной почты» добавляется под столбцом «судно в другой адрес». И он должен отправить уведомление по электронной почте на это письмо. В чем проблема? – helgatheviking

+0

На самом деле мне больше не нужно, чтобы это было сделано, поэтому я оставляю это. Но для вашего понимания я хочу второй адрес электронной почты, где уведомление о заказе может быть отправлено вместе с основным уведомлением –