当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Emails::get_emails方法代码示例

本文整理汇总了PHP中WC_Emails::get_emails方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Emails::get_emails方法的具体用法?PHP WC_Emails::get_emails怎么用?PHP WC_Emails::get_emails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Emails的用法示例。


在下文中一共展示了WC_Emails::get_emails方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($order_id = 0)
 {
     $this->order_id = $order_id;
     $this->order = new WC_Order($this->order_id);
     $wc_emails = new WC_Emails();
     $this->emails = $wc_emails->get_emails();
 }
开发者ID:brutalenemy666,项目名称:wp-utils,代码行数:7,代码来源:class-email-templates.php

示例2: run_email_script

function run_email_script()
{
    // assign email address and order id variables
    if (get_option("wc_email_test_email", false)) {
        $wc_email_test_email = get_option("wc_email_test_email", false);
    } else {
        $wc_email_test_email = get_bloginfo('admin_email');
    }
    if (get_option("wc_email_test_order_id", false) == 'recent') {
        $wc_email_test_order_id = '';
    } else {
        $wc_email_test_order_id = get_option("wc_email_test_order_id", false);
    }
    if (!$wc_email_test_order_id) {
        // get a valid and most recent order_id ( if no order is has been selected )
        global $wpdb;
        $order_id_query = 'SELECT order_id FROM ' . $wpdb->prefix . 'woocommerce_order_items ORDER BY order_item_id DESC LIMIT 1';
        $order_id = $wpdb->get_results($order_id_query);
        if (empty($order_id)) {
            echo "No order within your WooCommerce shop. Please create a test order first to test the emails";
            return;
        } else {
            $wc_email_test_order_id = $order_id[0]->order_id;
        }
    }
    // the email type to send
    $email_class = get_query_var('woocommerce_email_test');
    $for_filter = strtolower(str_replace('WC_Email_', '', $email_class));
    // change email address within order to saved option
    add_filter('woocommerce_email_recipient_' . $for_filter, 'your_email_recipient_filter_function', 10, 2);
    function your_email_recipient_filter_function($recipient, $object)
    {
        global $wc_email_test_email;
        $recipient = $wc_email_test_email;
        return $recipient;
    }
    // change subject link
    add_filter('woocommerce_email_subject_' . $for_filter, 'change_admin_email_subject', 1, 2);
    function change_admin_email_subject($subject, $order)
    {
        global $woocommerce;
        $subject = "TEST EMAIL: " . $subject;
        return $subject;
    }
    if (isset($GLOBALS['wc_advanced_notifications'])) {
        unset($GLOBALS['wc_advanced_notifications']);
    }
    // load the email classs
    $wc_emails = new WC_Emails();
    $emails = $wc_emails->get_emails();
    // select the email we want & send
    $new_email = $emails[$email_class];
    // make sure email isn't sent
    apply_filters('woocommerce_email_enabled_' . $for_filter, false, $new_email->object);
    $new_email->trigger($wc_email_test_order_id);
    // echo the email content for browser
    echo $new_email->style_inline($new_email->get_content());
}
开发者ID:JaneJieYing,项目名称:HiFridays,代码行数:58,代码来源:functions.php

示例3: addOfferNoteCallback

 public function addOfferNoteCallback()
 {
     if (is_admin() && (defined('DOING_AJAX') || DOING_AJAX)) {
         $post_id = $_POST["targetID"];
         // Get current data for Offer
         $post_data = get_post($post_id);
         // Filter Post Status Label
         $post_status_text = strtolower($post_data->post_status) == 'publish' ? 'Pending' : $post_data->post_status;
         $post_status_text = ucwords(str_replace("-", " ", str_replace("offer", " ", strtolower($post_status_text))));
         $noteSendToBuyer = isset($_POST["noteSendToBuyer"]) && $_POST["noteSendToBuyer"] != '' ? '1' : '';
         $offer_notes = $_POST['noteContent'];
         $current_user = wp_get_current_user();
         // Insert WP comment
         $comment_text = "<span>" . __('Offer Note:', $this->plugin_slug) . "</span>";
         if ($noteSendToBuyer != '1') {
             $comment_text .= "&nbsp;" . __('(admin only)', $this->plugin_slug);
         } else {
             $comment_text .= "&nbsp;" . __('(sent to buyer)', $this->plugin_slug);
         }
         $comment_text .= "<br />" . $offer_notes;
         $data = array('comment_post_ID' => '', 'comment_author' => $current_user->user_login, 'comment_author_email' => $current_user->user_email, 'comment_author_url' => '', 'comment_content' => $comment_text, 'comment_type' => '', 'comment_parent' => 0, 'user_id' => get_current_user_id(), 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => '', 'comment_date' => date("Y-m-d H:i:s", current_time('timestamp', 0)), 'comment_approved' => 'post-trashed');
         $new_comment_id = wp_insert_comment($data);
         // insert comment meta
         if ($new_comment_id) {
             add_comment_meta($new_comment_id, 'angelleye_woocommerce_offer_id', $post_id, true);
         }
         if ($new_comment_id) {
             if ($noteSendToBuyer == '1') {
                 // Email buyer the offer note (not private admin note)
                 /**
                  * Offer note email template
                  * @since   0.1.0
                  */
                 // set recipient email
                 $recipient = get_post_meta($post_id, 'offer_email', true);
                 $offer_id = $post_id;
                 $offer_uid = get_post_meta($post_id, 'offer_uid', true);
                 $offer_name = get_post_meta($post_id, 'offer_name', true);
                 $offer_email = $recipient;
                 $product_id = get_post_meta($post_id, 'offer_product_id', true);
                 $variant_id = get_post_meta($post_id, 'offer_variation_id', true);
                 $_pf = new WC_Product_Factory();
                 $product = $variant_id ? $_pf->get_product($variant_id) : $_pf->get_product($product_id);
                 // if buyercountered-offer previous then use buyer counter values
                 $is_offer_buyer_countered_status = $post_data->post_status == 'buyercountered-offer' ? true : false;
                 $product_qty = $is_offer_buyer_countered_status ? get_post_meta($post_id, 'offer_buyer_counter_quantity', true) : get_post_meta($post_id, 'offer_quantity', true);
                 $product_price_per = $is_offer_buyer_countered_status ? get_post_meta($post_id, 'offer_buyer_counter_price_per', true) : get_post_meta($post_id, 'offer_price_per', true);
                 $product_total = $product_qty * $product_price_per;
                 $offer_args = array('recipient' => $recipient, 'offer_email' => $offer_email, 'offer_name' => $offer_name, 'offer_id' => $offer_id, 'offer_uid' => $offer_uid, 'product_id' => $product_id, 'product_url' => $product->get_permalink(), 'variant_id' => $variant_id, 'product' => $product, 'product_qty' => $product_qty, 'product_price_per' => $product_price_per, 'product_total' => $product_total, 'offer_notes' => $offer_notes);
                 if ($variant_id) {
                     if ($product->get_sku()) {
                         $identifier = $product->get_sku();
                     } else {
                         $identifier = '#' . $product->variation_id;
                     }
                     $attributes = $product->get_variation_attributes();
                     $extra_data = ' &ndash; ' . implode(', ', $attributes);
                     $offer_args['product_title_formatted'] = sprintf(__('%s &ndash; %s%s', 'woocommerce'), $identifier, $product->get_title(), $extra_data);
                 } else {
                     $offer_args['product_title_formatted'] = $product->get_formatted_name();
                 }
                 // the email we want to send
                 $email_class = 'WC_Offer_Note_Email';
                 // load the WooCommerce Emails
                 $wc_emails = new WC_Emails();
                 $emails = $wc_emails->get_emails();
                 // select the email we want & trigger it to send
                 $new_email = $emails[$email_class];
                 $new_email->recipient = $recipient;
                 // set plugin slug in email class
                 $new_email->plugin_slug = $this->plugin_slug;
                 // define email template/path (html)
                 $new_email->template_html = 'woocommerce-offer-note.php';
                 $new_email->template_html_path = plugin_dir_path(__FILE__) . 'includes/emails/';
                 // define email template/path (plain)
                 $new_email->template_plain = 'woocommerce-offer-note.php';
                 $new_email->template_plain_path = plugin_dir_path(__FILE__) . 'includes/emails/plain/';
                 $new_email->trigger($offer_args);
             }
             $redirect_url = admin_url('post.php?post=' . $post_id . '&action=edit&noheader=true&message=11');
             echo $redirect_url;
         } else {
             echo 'failed';
         }
         die;
         // this is required to return a proper result
     }
 }
开发者ID:tuvell,项目名称:wordpress-woocommerce-paypal-starter-kit,代码行数:88,代码来源:class-offers-for-woocommerce-admin.php

示例4: new_offer_form_submit


//.........这里部分代码省略.........
                 }
             }
             /**
              * Email Out - admin email notification of new or countered offer
              * @since   0.1.0
              */
             $offer_id = $parent_post_id;
             $offer_name = get_post_meta($parent_post_id, 'offer_name', true);
             $offer_phone = get_post_meta($parent_post_id, 'offer_phone', true);
             $offer_company_name = get_post_meta($parent_post_id, 'offer_company_name', true);
             $offer_email = get_post_meta($parent_post_id, 'offer_email', true);
             $product_id = get_post_meta($parent_post_id, 'offer_product_id', true);
             $variant_id = get_post_meta($parent_post_id, 'offer_variation_id', true);
             $_pf = new WC_Product_Factory();
             $product = $variant_id ? $_pf->get_product($variant_id) : $_pf->get_product($product_id);
             $product_qty = $formData['offer_quantity'];
             $product_price_per = $formData['offer_price_per'];
             $product_total = $formData['offer_amount'];
             $offer_args = array('offer_email' => $offer_email, 'offer_name' => $offer_name, 'offer_phone' => $offer_phone, 'offer_company_name' => $offer_company_name, 'offer_id' => $offer_id, 'product_id' => $product_id, 'product_url' => get_permalink($product_id), 'variant_id' => $variant_id, 'product' => $product, 'product_qty' => $product_qty, 'product_price_per' => $product_price_per, 'product_total' => $product_total, 'offer_notes' => $comments);
             if ($variant_id) {
                 if ($product->get_sku()) {
                     $identifier = $product->get_sku();
                 } else {
                     $identifier = '#' . $product->variation_id;
                 }
                 $attributes = $product->get_variation_attributes();
                 $extra_data = ' &ndash; ' . implode(', ', $attributes);
                 $offer_args['product_title_formatted'] = sprintf(__('%s &ndash; %s%s', 'woocommerce'), $identifier, $product->get_title(), $extra_data);
             } else {
                 if (!empty($product)) {
                     $identifier = $product->get_sku();
                 } else {
                     $identifier = '#' . $product_id;
                 }
                 $offer_args['product_title_formatted'] = sprintf(__('%s &ndash; %s', 'woocommerce'), $identifier, $product->get_title());
             }
             if ($is_counter_offer) {
                 $offer_args['is_counter_offer'] = true;
                 /**
                  * send admin 'New counter offer' email template
                  */
                 // the email we want to send
                 $email_class = 'WC_New_Counter_Offer_Email';
             } else {
                 $offer_args['is_counter_offer'] = false;
                 /**
                  * send admin 'New offer' email template
                  */
                 // the email we want to send
                 $email_class = 'WC_New_Offer_Email';
             }
             // load the WooCommerce Emails
             $wc_emails = new WC_Emails();
             $emails = $wc_emails->get_emails();
             // select the email we want & trigger it to send
             $new_email = $emails[$email_class];
             // set plugin slug in email class
             $new_email->plugin_slug = $this->plugin_slug;
             if ($is_counter_offer) {
                 // define email template/path (html)
                 $new_email->template_html = 'woocommerce-new-counter-offer.php';
                 $new_email->template_html_path = plugin_dir_path(__FILE__) . 'includes/emails/';
                 // define email template/path (plain)
                 $new_email->template_plain = 'woocommerce-new-counter-offer.php';
                 $new_email->template_plain_path = plugin_dir_path(__FILE__) . 'includes/emails/plain/';
             } else {
                 // define email template/path (html)
                 $new_email->template_html = 'woocommerce-new-offer.php';
                 $new_email->template_html_path = plugin_dir_path(__FILE__) . 'includes/emails/';
                 // define email template/path (plain)
                 $new_email->template_plain = 'woocommerce-new-offer.php';
                 $new_email->template_plain_path = plugin_dir_path(__FILE__) . 'includes/emails/plain/';
             }
             $new_email->trigger($offer_args);
             /**
              * Send buyer 'offer received' email notification
              */
             // the email we want to send
             $email_class = 'WC_Offer_Received_Email';
             // set recipient
             $recipient = $offer_email;
             $offer_args['recipient'] = $offer_email;
             // select the email we want & trigger it to send
             $new_email = $emails[$email_class];
             $new_email->recipient = $recipient;
             // set plugin slug in email class
             $new_email->plugin_slug = $this->plugin_slug;
             // define email template/path (html)
             $new_email->template_html = 'woocommerce-offer-received.php';
             $new_email->template_html_path = plugin_dir_path(__FILE__) . 'includes/emails/';
             // define email template/path (plain)
             $new_email->template_plain = 'woocommerce-offer-received.php';
             $new_email->template_plain_path = plugin_dir_path(__FILE__) . 'includes/emails/plain/';
             $new_email->trigger($offer_args);
             // Success
             echo json_encode(array("statusmsg" => 'success'));
             exit;
         }
     }
 }
开发者ID:elarson,项目名称:offers-for-woocommerce,代码行数:101,代码来源:class-offers-for-woocommerce.php

示例5: ofw_auto_decline_offer

 /**
  * 
  * @global type $wpdb
  * @param type $offer_id
  * @param type $emails
  * @since   1.2.0
  */
 public function ofw_auto_decline_offer($offer_id = null, $emails = null)
 {
     global $wpdb;
     if (isset($_POST["targetID"]) && !empty($_POST["targetID"])) {
         $post_id = $_POST["targetID"];
     } else {
         $post_id = $offer_id;
     }
     if (isset($post_id) && !empty($post_id)) {
         $post_data = get_post($post_id);
         $is_offer_buyer_countered_status = $post_data->post_status == 'buyercountered-offer' ? true : false;
         $table = $wpdb->prefix . "posts";
         $data_array = array('post_status' => 'declined-offer', 'post_modified' => date("Y-m-d H:i:s", current_time('timestamp', 0)), 'post_modified_gmt' => date("Y-m-d H:i:s", current_time('timestamp', 1)));
         $where = array('ID' => $post_id);
         $wpdb->update($table, $data_array, $where);
         $post_status_text = __('Declined', $this->plugin_slug);
         $offer_notes = isset($_POST['angelleye_woocommerce_offer_status_notes']) && $_POST['angelleye_woocommerce_offer_status_notes'] != '' ? $_POST['angelleye_woocommerce_offer_status_notes'] : '';
         $recipient = get_post_meta($post_id, 'offer_email', true);
         $offer_id = $post_id;
         $offer_uid = get_post_meta($post_id, 'offer_uid', true);
         $offer_name = get_post_meta($post_id, 'offer_name', true);
         $offer_email = $recipient;
         $product_id = get_post_meta($post_id, 'offer_product_id', true);
         $variant_id = get_post_meta($post_id, 'offer_variation_id', true);
         $_pf = new WC_Product_Factory();
         $product = $variant_id ? $_pf->get_product($variant_id) : $_pf->get_product($product_id);
         $product_qty = $is_offer_buyer_countered_status ? get_post_meta($post_id, 'offer_buyer_counter_quantity', true) : get_post_meta($post_id, 'offer_quantity', true);
         $product_price_per = $is_offer_buyer_countered_status ? get_post_meta($post_id, 'offer_buyer_counter_price_per', true) : get_post_meta($post_id, 'offer_price_per', true);
         $product_total = $product_qty * $product_price_per;
         if ($is_offer_buyer_countered_status) {
             update_post_meta($post_id, 'offer_quantity', $product_qty);
             update_post_meta($post_id, 'offer_price_per', $product_price_per);
             update_post_meta($post_id, 'offer_amount', $product_total);
         }
         $offer_args = array('recipient' => $recipient, 'offer_email' => $offer_email, 'offer_name' => $offer_name, 'offer_id' => $offer_id, 'offer_uid' => $offer_uid, 'product_id' => $product_id, 'product_url' => $product->get_permalink(), 'variant_id' => $variant_id, 'product' => $product, 'product_qty' => $product_qty, 'product_price_per' => $product_price_per, 'product_total' => $product_total, 'offer_notes' => $offer_notes);
         if ($variant_id) {
             if ($product->get_sku()) {
                 $identifier = $product->get_sku();
             } else {
                 $identifier = '#' . $product->variation_id;
             }
             $attributes = $product->get_variation_attributes();
             $extra_data = ' &ndash; ' . implode(', ', $attributes);
             $offer_args['product_title_formatted'] = sprintf(__('%s &ndash; %s%s', 'woocommerce'), $identifier, $product->get_title(), $extra_data);
         } else {
             $offer_args['product_title_formatted'] = $product->get_formatted_name();
         }
         $email_class = 'WC_Declined_Offer_Email';
         if (empty($emails)) {
             $wc_emails = new WC_Emails();
             $emails = $wc_emails->get_emails();
         }
         $new_email = $emails[$email_class];
         $new_email->recipient = $recipient;
         $new_email->plugin_slug = $this->plugin_slug;
         $new_email->template_html = 'woocommerce-offer-declined.php';
         $new_email->template_html_path = untrailingslashit(OFW_PLUGIN_URL) . '/admin/includes/emails/';
         $new_email->template_plain = 'woocommerce-offer-declined.php';
         $new_email->template_plain_path = untrailingslashit(OFW_PLUGIN_URL) . '/admin/includes/emails/plain/';
         $new_email->trigger($offer_args);
         $comment_text = "<span>Updated - Status: </span>";
         $comment_text .= $post_status_text;
         if (isset($offer_notes) && $offer_notes != '') {
             $comment_text .= '</br>' . nl2br($offer_notes);
         }
         $data = array('comment_post_ID' => '', 'comment_author' => 'admin', 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => $comment_text, 'comment_type' => '', 'comment_parent' => 0, 'user_id' => get_current_user_id(), 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => '', 'comment_date' => date("Y-m-d H:i:s", current_time('timestamp', 0)), 'comment_approved' => 'post-trashed');
         $new_comment_id = wp_insert_comment($data);
         if ($new_comment_id) {
             add_comment_meta($new_comment_id, 'angelleye_woocommerce_offer_id', $post_id, true);
         }
     }
 }
开发者ID:k2jysy,项目名称:kshop,代码行数:79,代码来源:class-offers-for-woocommerce.php


注:本文中的WC_Emails::get_emails方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。