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


PHP WC_Order::get_user方法代码示例

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


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

示例1: order_status_changed

 public static function order_status_changed($id, $status = '', $new_status = '')
 {
     $rules = get_option('woorule_rules', array());
     foreach ($rules as $k => $rule) {
         $enabled = get_option($rule['enabled']['id']) === 'yes' ? true : false;
         if ($enabled) {
             $which_event = get_option($rule['occurs']['id']);
             $is_opt_in_rule = false;
             $want_in = true;
             if (isset($rule['show_opt_in'])) {
                 $is_opt_in_rule = get_option($rule['show_opt_in']['id']) === 'yes' ? true : false;
             }
             if ($is_opt_in_rule) {
                 $want_in = get_post_meta($id, 'woorule_opt_in_' . $k, false);
                 if (!empty($want_in)) {
                     $want_in = $want_in[0] === 'yes' ? true : false;
                 }
             }
             if ($want_in && $new_status === $which_event) {
                 $integration = new WC_Integration_RuleMailer();
                 $order = new WC_Order($id);
                 $user = $order->get_user();
                 $currency = $order->get_order_currency();
                 $order_subtotal = $order->order_total - ($order->order_shipping_tax + $order->order_shipping) - $order->cart_discount;
                 $items = $order->get_items();
                 $brands = array();
                 $categories = array();
                 $tags = array();
                 foreach ($items as $item) {
                     $p = new WC_Product_Simple($item['product_id']);
                     $brands[] = $p->get_attribute('brand');
                     // this is bullshit
                     $cat = strip_tags($p->get_categories(''));
                     $tag = strip_tags($p->get_tags(''));
                     if (!empty($cat)) {
                         $categories[] = $cat;
                     }
                     if (!empty($tag)) {
                         $tags[] = $tag;
                     }
                 }
                 $subscription = array('apikey' => $integration->api_key, 'update_on_duplicate' => get_option($rule['update_on_duplicate']['id']) === 'yes' ? true : false, 'auto_create_tags' => get_option($rule['auto_create_tags']['id']) === 'yes' ? true : false, 'auto_create_fields' => get_option($rule['auto_create_fields']['id']) === 'yes' ? true : false, 'tags' => explode(',', get_option($rule['tags']['id'])), 'subscribers' => array('email' => $order->billing_email, 'phone_number' => $order->billing_phone, 'fields' => array(array('key' => 'Order.Number', 'value' => $order->get_order_number()), array('key' => 'Order.Date', 'value' => $order->order_date), array('key' => 'Order.FirstName', 'value' => $order->billing_first_name), array('key' => 'Order.LastName', 'value' => $order->billing_last_name), array('key' => 'Order.Street1', 'value' => $order->billing_address_1), array('key' => 'Order.Street2', 'value' => $order->billing_address_2), array('key' => 'Order.City', 'value' => $order->billing_city), array('key' => 'Order.Country', 'value' => $order->billing_country), array('key' => 'Order.State', 'value' => $order->billing_state), array('key' => 'Order.Subtotal', 'value' => $order_subtotal), array('key' => 'Order.Discount', 'value' => $order->cart_discount), array('key' => 'Order.Shipping', 'value' => $order->order_shipping + $order->order_shipping_tax), array('key' => 'Order.Total', 'value' => $order->order_total), array('key' => 'Order.Vat', 'value' => $order->order_tax))));
                 if (!empty($categories)) {
                     $subscription['subscribers']['fields'][] = array('key' => 'Order.Categories', 'value' => $categories, 'type' => 'multiple');
                 }
                 if (!empty($tags)) {
                     $subscription['subscribers']['fields'][] = array('key' => 'Order.Tags', 'value' => array($tags), 'type' => 'multiple');
                 }
                 if (!empty($brands)) {
                     $subscription['subscribers']['fields'][] = array('key' => 'Order.Brands', 'value' => $brands, 'type' => 'multiple');
                 }
                 $api = WP_RuleMailer_API::get_instance();
                 $api::subscribe($integration->api_url, $subscription);
             }
         }
     }
 }
开发者ID:rulecom,项目名称:woorule,代码行数:57,代码来源:class-wc-admin-settings-woorule.php

示例2: mysite_woocommerce_order_status_completed

function mysite_woocommerce_order_status_completed($order_id) {

    //Ajouter un suivi de pack lorsque la commande a été complété
    $order = new WC_Order($order_id);
    $items = $order->get_items();
    $user = $order->get_user();
    
    foreach ($items as $item) {
        if ($item["duree"]) {
            $pack_name = '--pack_name "'.$item["name"].'"';
            $pack_type_id = ' --pack_type_id '.$item["item_meta"]["_product_id"][0];
            $user_id = ' --user_id '.$user->ID;
            $nb_days = ' --nb_days "'.$item["duree"].'"';
            $ebook = '';
            if($item["item_meta"]["souhaitez-vous-ajouter-loption-e-book"][0] == 'Oui'){
                $ebook = ' --ebook';
            }
            $videos = '';
            if ($item["item_meta"]["souhaitez-vous-ajouter-loption-videos"][0] == 'Oui') {
                $videos = ' --videos';
            } 
            $ebook_double = '';
            if ($item["item_meta"]["souhaitez-vous-ajouter-loption-double-e-book"][0] == 'Oui') {
                $ebook_double = ' --ebook_double';
            }
            $ebook_tips = '';
            if ($item["item_meta"]["souhaitez-vous-ajouter-le-e-book-dastuces-et-menus-types"][0] == 'Oui') {
                $ebook_tips = ' --ebook_tips';
            }
            $ebook_recipes = '';
            if ($item["item_meta"]["souhaitez-vous-ajouter-le-e-book-de-recettes"][0] == 'Oui') {
                $ebook_recipes = ' --ebook_recipes';
            }
            shell_exec(PATH_CMS.' costa:pack:start '.$pack_name.$pack_type_id.$user_id.$nb_days.$ebook.$videos.$ebook_double.$ebook_recipes.$ebook_tips);
        }
    }
}
开发者ID:simonsays88,项目名称:costa,代码行数:37,代码来源:functions.php

示例3:

 /**
  * Test: get_user
  */
 function test_get_user()
 {
     $object = new WC_Order();
     $this->assertEquals(false, $object->get_user());
     $set_to = '1';
     $object->set_customer_id($set_to);
     $this->assertInstanceOf('WP_User', $object->get_user());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:11,代码来源:crud.php

示例4: get_order_user

 /**
  * Get the user for an order
  *
  * @since 3.0.0
  * @param \WC_Order $order
  * @return bool|WP_User
  */
 public static function get_order_user(WC_Order $order)
 {
     if (self::is_wc_version_gte_2_2()) {
         return $order->get_user();
     } else {
         return self::get_order_user_id($order) ? get_user_by('id', self::get_order_user_id($order)) : false;
     }
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:15,代码来源:class-sv-wc-plugin-compatibility.php

示例5: orderpost

function orderpost($orderId)
{
    global $wpdb;
    $testMode = get_option('linksync_test');
    $LAIDKey = get_option('linksync_laid');
    $apicall = new linksync_class($LAIDKey, $testMode);
    //Checking for already sent Order
    $sentOrderIds = get_option('linksync_sent_order_id');
    if (isset($sentOrderIds)) {
        if (!empty($sentOrderIds)) {
            $order_id_array = unserialize($sentOrderIds);
        } else {
            $order_id_array = array();
        }
        if (!in_array($orderId, $order_id_array)) {
            $order = new WC_Order($orderId);
            if ($order->post_status == get_option('order_status_wc_to_vend')) {
                update_option('linksync_sent_order_id', serialize(array_merge($order_id_array, array($orderId))));
                $order_no = $order->get_order_number();
                if (strpos($order_no, '#') !== false) {
                    $order_no = str_replace('#', '', $order_no);
                }
                $get_total = $order->get_total();
                $get_user = $order->get_user();
                $comments = $order->post->post_excerpt;
                $primary_email_address = $get_user->data->user_email;
                $currency = $order->get_order_currency();
                $shipping_method = $order->get_shipping_method();
                $order_total = $order->get_order_item_totals();
                $transaction_id = $order->get_transaction_id();
                $taxes_included = false;
                $total_discount = $order->get_total_discount();
                $total_quantity = 0;
                $registerDb = get_option('wc_to_vend_register');
                $vend_uid = get_option('wc_to_vend_user');
                $total_tax = $order->get_total_tax();
                // Geting Payment object details
                if (isset($order_total['payment_method']['value']) && !empty($order_total['payment_method']['value'])) {
                    $wc_payment = get_option('wc_to_vend_payment');
                    if (isset($wc_payment) && !empty($wc_payment)) {
                        $total_payments = explode(",", $wc_payment);
                        foreach ($total_payments as $mapped_payment) {
                            $exploded_mapped_payment = explode("|", $mapped_payment);
                            if (isset($exploded_mapped_payment[1]) && !empty($exploded_mapped_payment[1]) && isset($exploded_mapped_payment[0]) && !empty($exploded_mapped_payment[0])) {
                                if ($exploded_mapped_payment[1] == $order_total['payment_method']['value']) {
                                    $vend_payment_data = explode("%%", $exploded_mapped_payment[0]);
                                    if (isset($vend_payment_data[0])) {
                                        $payment_method = $vend_payment_data[0];
                                    }
                                    if (isset($vend_payment_data[1])) {
                                        $payment_method_id = $vend_payment_data[1];
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    $payment = array("retailer_payment_type_id" => isset($payment_method_id) ? $payment_method_id : null, "amount" => isset($get_total) ? $get_total : 0, "method" => isset($payment_method) ? $payment_method : null, "transactionNumber" => isset($transaction_id) ? $transaction_id : null);
                }
                $export_user_details = get_option('wc_to_vend_export');
                if (isset($export_user_details) && !empty($export_user_details)) {
                    if ($export_user_details == 'customer') {
                        //woocommerce filter
                        $billingAddress_filter = apply_filters('woocommerce_order_formatted_billing_address', array('firstName' => $order->billing_first_name, 'lastName' => $order->billing_last_name, 'phone' => $order->billing_phone, 'street1' => $order->billing_address_1, 'street2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postalCode' => $order->billing_postcode, 'country' => $order->billing_country, 'company' => $order->billing_company, 'email_address' => $order->billing_email), $order);
                        $billingAddress = array('firstName' => $billingAddress_filter['firstName'], 'lastName' => $billingAddress_filter['lastName'], 'phone' => $billingAddress_filter['phone'], 'street1' => $billingAddress_filter['street1'], 'street2' => $billingAddress_filter['street2'], 'city' => $billingAddress_filter['city'], 'state' => $billingAddress_filter['state'], 'postalCode' => $billingAddress_filter['postalCode'], 'country' => $billingAddress_filter['country'], 'company' => $billingAddress_filter['company'], 'email_address' => $billingAddress_filter['email_address']);
                        $deliveryAddress_filter = apply_filters('woocommerce_order_formatted_shipping_address', array('firstName' => $order->shipping_first_name, 'lastName' => $order->shipping_last_name, 'phone' => $order->shipping_phone, 'street1' => $order->shipping_address_1, 'street2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postalCode' => $order->shipping_postcode, 'country' => $order->shipping_country, 'company' => $order->shipping_company), $order);
                        $deliveryAddress = array('firstName' => $deliveryAddress_filter['firstName'], 'lastName' => $deliveryAddress_filter['lastName'], 'phone' => $deliveryAddress_filter['phone'], 'street1' => $deliveryAddress_filter['street1'], 'street2' => $deliveryAddress_filter['street2'], 'city' => $deliveryAddress_filter['city'], 'state' => $deliveryAddress_filter['state'], 'postalCode' => $deliveryAddress_filter['postalCode'], 'country' => $deliveryAddress_filter['country'], 'company' => $deliveryAddress_filter['company']);
                        $primary_email = isset($primary_email_address) ? $primary_email_address : $billingAddress['email_address'];
                        unset($billingAddress['email_address']);
                    }
                }
                $vend_user_detail = get_option('wc_to_vend_user');
                if (isset($vend_user_detail) && !empty($vend_user_detail)) {
                    $user = explode('|', $vend_user_detail);
                    $vend_uid = isset($user[0]) ? $user[0] : null;
                    $vend_username = isset($user[1]) ? $user[1] : null;
                }
                //Ordered product(s)
                $items = $order->get_items();
                $taxes = $order->get_taxes();
                foreach ($items as $item) {
                    foreach ($taxes as $tax_label) {
                        $sql = mysql_query("SELECT  tax_rate_id FROM  `" . $wpdb->prefix . "woocommerce_tax_rates` WHERE  tax_rate_name='" . $tax_label['label'] . "' AND tax_rate_class='" . $item['item_meta']['_tax_class'][0] . "'");
                        if (mysql_num_rows($sql) != 0) {
                            $tax_classes = linksync_tax_classes($tax_label['label'], $item['item_meta']['_tax_class'][0]);
                            if ($tax_classes['result'] == 'success') {
                                $vend_taxes = explode('/', $tax_classes['tax_classes']);
                            }
                        }
                    }
                    $taxId = isset($vend_taxes[0]) ? $vend_taxes[0] : null;
                    $taxName = isset($vend_taxes[1]) ? $vend_taxes[1] : null;
                    $taxRate = isset($vend_taxes[2]) ? $vend_taxes[2] : null;
                    if (isset($item['variation_id']) && !empty($item['variation_id'])) {
                        $product_id = $item['variation_id'];
                    } else {
                        $product_id = $item['product_id'];
                    }
                    $pro_object = new WC_Product($product_id);
                    $itemtotal = (double) $item['item_meta']['_line_subtotal'][0];
//.........这里部分代码省略.........
开发者ID:amanpreet8333,项目名称:linksync,代码行数:101,代码来源:linksync_add_action_order.php

示例6: maybe_create_subscription

 public function maybe_create_subscription($order_id)
 {
     if (empty(MP_Integration::$api_key)) {
         return;
     }
     $is_subscription = WC()->session->get('mp_is_sub');
     if ($is_subscription) {
         update_post_meta($order_id, 'mp_order_type', 'new');
         $renewal_frequency = WC()->session->get('mp_sub_freq');
         update_post_meta($order_id, 'mp_frequency', $renewal_frequency);
         $order = new WC_Order($order_id);
         $customer = $order->get_user();
         $order_items = $order->get_items();
         $subscription_items = array();
         foreach ($order_items as $item_id => $item) {
             $subscription_items[] = array('productId' => (int) $item['product_id'], 'variationId' => (int) $item['variation_id'], 'quantity' => (int) $item['qty'], 'discountPercent' => 0);
         }
         $first_name = $customer->first_name;
         if (empty($first_name)) {
             $first_name = $order->billing_first_name;
         }
         $last_name = $customer->last_name;
         if (empty($last_name)) {
             $last_name = $order->billing_last_name;
         }
         $shipping_methods = $order->get_shipping_methods();
         $shipping_method_id = null;
         $shipping_method_name = null;
         $shipping_cost = 0;
         if (!empty($shipping_methods)) {
             $shipping_method_id = key($shipping_methods);
             $shipping_method = $shipping_methods[$shipping_method_id];
             $shipping_method_name = $shipping_method['name'];
             $shipping_cost = $shipping_method['cost'];
         }
         $data = array('apiKey' => MP_Integration::$api_key, 'subscription' => array('renewalFrequencyId' => $renewal_frequency, 'shippingMethodId' => $shipping_method_id, 'shippingMethodName' => $shipping_method_name, 'shippingCost' => $shipping_cost), 'customer' => array('externalId' => $customer->ID, 'email' => $customer->user_email, 'firstName' => $first_name, 'lastName' => $last_name), 'order' => array('orderId' => $order_id, 'orderTypeId' => 'new', 'orderDate' => $order->order_date), 'subscriptionItems' => $subscription_items);
         $data_json = json_encode(array($data));
         $ch = curl_init(MP_Environment::MP_URL . '/methods/api_CreateNewSubscription');
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_json)));
         $subscription_id = null;
         $response = json_decode(curl_exec($ch));
         if (curl_errno($ch)) {
             // TODO - error handling
             echo curl_error($ch);
             exit;
         } else {
             if (is_object($response)) {
                 // TODO - error handling
                 var_dump($response);
                 exit;
             } else {
                 $subscription_id = $response;
             }
         }
         curl_close($ch);
         if (!empty($subscription_id)) {
             update_post_meta($order_id, 'mp_subscription_id', $subscription_id);
             update_user_meta($customer->ID, 'mp_subscription_id', $subscription_id);
         }
     }
 }
开发者ID:hwillson,项目名称:woocommerce-moreplease,代码行数:64,代码来源:class-mp-checkout.php

示例7: order_delivery

 public function order_delivery($order_id = 0)
 {
     if (!$order_id || !$this->settings['pickup_location'] || !$this->settings['pickup_name'] || !$this->settings['pickup_phone']) {
         return false;
     }
     // Get order object
     $order = new WC_Order($order_id);
     if (!$order) {
         return false;
     }
     // Get customer user ID
     $user = $order->get_user();
     if (!$user) {
         return false;
     }
     $delivery_address = str_replace('<br/>', ', ', $order->get_formatted_shipping_address());
     if (!$delivery_address) {
         return false;
     }
     if (!$order->billing_phone) {
         return false;
     }
     $delivery_address_data = $this->get_address_data($delivery_address);
     $args = array('pickup_address' => (string) $this->settings['pickup_location'], 'pickup_contact_name' => (string) $this->settings['pickup_name'], 'pickup_contact_phone' => (string) $this->settings['pickup_phone'], 'customer_identifier' => (string) $user->user_login, 'dropoff_contact_name' => (string) $user->display_name, 'dropoff_contact_phone' => (string) $order->billing_phone, 'dropoff_address' => (string) $delivery_address_data['address'], 'dropoff_coordinates' => (string) $delivery_address_data['location']);
     if ($this->settings['pickup_coords']) {
         $args['pickup_coordinates'] = (string) $this->settings['pickup_coords'];
     }
     if ($this->settings['pickup_remarks']) {
         $args['pickup_remarks'] = (string) $this->settings['pickup_remarks'];
     }
     if ($this->settings['city']) {
         $args['city'] = (string) $this->settings['city'];
     }
     $delivery_notes = $order->customer_note;
     if ($delivery_notes) {
         $args['dropoff_remarks'] = (string) $this->settings['delivery_notes'];
     }
     $delivery = $this->api('deliveries', $args, 'post');
     if ($delivery && isset($delivery->id)) {
         update_post_meta($order_id, '_wumdrop_delivery_id', $delivery->id);
         if (isset($delivery->distance_estimate)) {
             update_post_meta($order_id, '_wumdrop_distance_estimate', $delivery->distance_estimate);
         }
         if (isset($delivery->time_estimate)) {
             update_post_meta($order_id, '_wumdrop_time_estimate', $delivery->time_estimate);
         }
         if (isset($delivery->message)) {
             update_post_meta($order_id, '_wumdrop_delivery_message', $delivery->message);
         }
         if (isset($delivery->time_estimate)) {
             update_post_meta($order_id, '_wumdrop_delivery_price', $delivery->price);
         }
         $order_note = __('WumDrop delivery order placed.', 'woocommerce-wumdrop');
         if ('completed' != $order->get_status()) {
             $order->update_status('completed', $order_note);
         } else {
             $order->add_order_note($order_note);
         }
         return true;
     }
     return false;
 }
开发者ID:WumDrop,项目名称:WumDrop-for-WooCommerce,代码行数:62,代码来源:class-wc-wumdrop.php


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