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


PHP WC_Order::get_address方法代码示例

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


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

示例1: get_shipping_data

 public function get_shipping_data()
 {
     $data = [];
     foreach ($this->get_fraktguiden_shipping_items() as $item_id => $method) {
         $pickup_point_id = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_id', true);
         $pickup_point = null;
         $pickup_point_cached = null;
         $pickup_point_postcode = null;
         if ($pickup_point_id) {
             $shipping_address = $this->order->get_address('shipping');
             $request = new WP_Bring_Request();
             $response = $request->get('https://api.bring.com/pickuppoint/api/pickuppoint/' . $shipping_address['country'] . '/id/' . $pickup_point_id . '.json');
             $pickup_point = $response->has_errors() ? null : json_decode($response->get_body())->pickupPoint[0];
             $pickup_point_cached = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_cached', true);
             $pickup_point_postcode = wc_get_order_item_meta($item_id, '_fraktguiden_pickup_point_postcode', true);
         }
         $data[] = ['item_id' => $item_id, 'pickup_point' => $pickup_point, 'pickup_point_info_cached' => $pickup_point_cached, 'postcode' => $pickup_point_postcode, 'packages' => json_encode($this->get_packages_for_order_item($item_id))];
     }
     return $data;
 }
开发者ID:drivdigital,项目名称:bring-fraktguiden-for-woocommerce,代码行数:20,代码来源:class-bring-wc-order-adapter.php

示例2: update_address

 /**
  * Update address.
  *
  * @param WC_Order $order
  * @param array $posted
  * @param string $type
  */
 protected function update_address($order, $posted, $type = 'billing')
 {
     $fields = $order->get_address($type);
     foreach (array_keys($fields) as $field) {
         if (isset($posted[$field])) {
             $fields[$field] = $posted[$field];
         }
     }
     // Set address.
     $order->set_address($fields, $type);
     // Update user meta.
     if ($order->get_user_id()) {
         foreach ($fields as $key => $value) {
             update_user_meta($order->get_user_id(), $type . '_' . $key, $value);
         }
     }
 }
开发者ID:coderkevin,项目名称:woocommerce,代码行数:24,代码来源:class-wc-rest-orders-controller.php

示例3: handlePaymentCompleted

function handlePaymentCompleted($order_id)
{
    echo "-- handlePaymentCompleted";
    $order = new WC_Order($order_id);
    $customer = new WC_Customer($order_id);
    $addresses = $order->get_address("shipping");
    /*
    $To = get_option('admin_email').",dev_support@soixanteseize.com";
        $Objet = $email_heading = "Vérifiez la commande ".$order_id;
        $message = $response[1];
        ob_start();
        include(COURIIERPATH.'views/mails/woo-couriier-order-ready.php');
        $Body = ob_get_clean();
        trace($Body);
        //sendCC($To, $Objet, $Body);
    
        return;
    */
    $adresse = $addresses["address_1"] . ", ";
    if ($addresses["address_2"] != "") {
        $adresse .= $addresses["address_2"] . ", ";
    }
    $adresse .= $addresses["city"] . " ";
    $adresse .= $addresses["postcode"] . " ";
    //$postcode = $addresses["postcode"];
    //trace($order);
    //trace($customer);
    //trace($order->get_address("shipping") );
    //trace($adresse);
    $chosen_methods = $order->get_shipping_methods();
    if (count($chosen_methods) > 0) {
        //$la_methode = object();
        foreach ($chosen_methods as $c_method) {
            //                trace($method);
            $chosen_method = $c_method['item_meta']['method_id'][0];
        }
        //trace($chosen_method);
        $available_methods = WC()->session->get('shipping_methods_' . $addresses["postcode"]);
        //trace($available_methods);
        $offerIdTarifs = '';
        foreach ($available_methods as $method) {
            //trace($method->speed);
            switch ($method->speed) {
                case 2:
                    if ($chosen_method == 'couriier_classic_shipping_method') {
                        $offerIdTarifs = $method->ref;
                    }
                    break;
                case 1:
                    if ($chosen_method == 'couriier_rapide_shipping_method') {
                        $offerIdTarifs = $method->ref;
                    }
                    break;
                case 0:
                    if ($chosen_method == 'couriier_flash_shipping_method') {
                        $offerIdTarifs = $method->ref;
                    }
                    break;
            }
        }
        //return;
        $adresse = $customer->get_address() . " " . $customer->get_postcode() . ", " . $customer->get_city();
        $recipientLatLng = geoloc($adresse);
        //trace($customer);
        //trace($recipientLatLng);
        //trace($offerIdTarifs);
        //return;
        $body = array(array('offerIdTarifs' => $offerIdTarifs, 'pickupName' => get_bloginfo("name"), 'pickupLatitude' => PICKUPLAT, 'pickupLongitude' => PICKUPLNG, 'pickupAddress' => PICKUPADRESSE, 'pickupAddress2' => "test", 'pickupTel' => PICKUPTEL, 'pickupZip' => PICKUPZIP, 'pickupCity' => PICKUPCITY, 'recipientName' => $order->get_formatted_shipping_full_name(), 'recipientLatitude' => $recipientLatLng["lat"], 'recipientLongitude' => $recipientLatLng["lng"], 'recipientAddress' => $addresses["address_1"], 'recipientAddress2' => $addresses["address_2"], 'recipientTel' => $order->billing_phone, 'recipientZip' => $addresses["postcode"], 'recipientCity' => $addresses["city"], 'timeManagement' => "2015-04-24 00:00:00", 'deliveryType' => "En main propre"));
        //trace($body);
        //return;
        $body = json_encode($body);
        $url = COURIIER_WS . '/orders';
        //trace($url);
        $response = api_call_post($url, $body);
        //trace($response);
        $response = json_decode($response['body']);
        //trace($response);
        $couriier_order_id = $response[0]->id;
        //trace($order_id);
        //return;
        if ($couriier_order_id) {
            /**
                url_order_follow
                    **/
            $url_order_follow = $response[0]->following_url;
            //trace($url_order_follow);
            if ($url_order_follow) {
                $To = $order->billing_email;
                $Objet = $email_heading = "Votre lien pour suivre la livraison Couriier";
                ob_start();
                include COURIIERPATH . 'views/mails/woo-couriier-order-follow.php';
                $Body = ob_get_clean();
                sendCC($To, $Objet, $Body);
            }
            /**
                url_order_ready
                    **/
            $url_rest_order_ready = get_bloginfo("url") . '/wc-api/couriier-order-ready?order_id=' . $order_id . '&couriier_order_id=' . $couriier_order_id;
            //$url_order_ready = COURIIER_WS.'/order/'.$couriier_order_id.'/ready';
            //trace($url_rest_order_ready);
//.........这里部分代码省略.........
开发者ID:ahmedghazi,项目名称:tpls,代码行数:101,代码来源:functions.php

示例4: array

 /**
  * Test: get_address
  */
 function test_get_address()
 {
     $object = new WC_Order();
     $billing = array('first_name' => 'Fred', 'last_name' => 'Flintstone', 'company' => 'Bedrock Ltd.', 'address_1' => '34 Stonepants avenue', 'address_2' => 'Rockville', 'city' => 'Bedrock', 'state' => 'Boulder', 'postcode' => '00001', 'country' => 'US', 'email' => '', 'phone' => '');
     $shipping = array('first_name' => 'Barney', 'last_name' => 'Rubble', 'company' => 'Bedrock Ltd.', 'address_1' => '34 Stonepants avenue', 'address_2' => 'Rockville', 'city' => 'Bedrock', 'state' => 'Boulder', 'postcode' => '00001', 'country' => 'US');
     $object->set_billing_first_name('Fred');
     $object->set_billing_last_name('Flintstone');
     $object->set_billing_company('Bedrock Ltd.');
     $object->set_billing_address_1('34 Stonepants avenue');
     $object->set_billing_address_2('Rockville');
     $object->set_billing_city('Bedrock');
     $object->set_billing_state('Boulder');
     $object->set_billing_postcode('00001');
     $object->set_billing_country('US');
     $object->set_shipping_first_name('Barney');
     $object->set_shipping_last_name('Rubble');
     $object->set_shipping_company('Bedrock Ltd.');
     $object->set_shipping_address_1('34 Stonepants avenue');
     $object->set_shipping_address_2('Rockville');
     $object->set_shipping_city('Bedrock');
     $object->set_shipping_state('Boulder');
     $object->set_shipping_postcode('00001');
     $object->set_shipping_country('US');
     $this->assertEquals($billing, $object->get_address());
     $this->assertEquals($shipping, $object->get_address('shipping'));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:29,代码来源:crud.php

示例5: maybe_update_subscription_address

 /**
  * Updates address on the subscription if one of them is changed.
  *
  * @param  WC_Order $order The new order
  * @param  WC_Subscription $subscription The original subscription
  */
 public static function maybe_update_subscription_address($order, $subscription)
 {
     if (method_exists($subscription, 'get_address')) {
         $order_billing = $order->get_address('billing');
         $order_shipping = $order->get_address();
         $subscription_billing = $subscription->get_address('billing');
         $subscription_shipping = $subscription->get_address();
     } else {
         $order_billing = wcs_get_order_address($order, 'billing');
         $order_shipping = wcs_get_order_address($order);
         $subscription_billing = wcs_get_order_address($subscription, 'billing');
         $subscription_shipping = wcs_get_order_address($subscription);
     }
     $subscription->set_address(array_diff_assoc($order_billing, $subscription_billing), 'billing');
     $subscription->set_address(array_diff_assoc($order_shipping, $subscription_shipping), 'shipping');
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:22,代码来源:class-wc-subscriptions-switcher.php

示例6: get_destination_address

 protected function get_destination_address(WC_Order $order)
 {
     $order_address = $order->get_address('shipping');
     $destination = $this->format_address_for_api($order_address);
     return $destination;
 }
开发者ID:Automattic,项目名称:woocommerce-connect-client,代码行数:6,代码来源:class-wc-connect-shipping-label.php

示例7: orders

 public function orders()
 {
     DABBA_API_Catch_Request::get()->check_params(array('user_id', 'page', 'limit'));
     $customer_orders = get_posts(array('posts_per_page' => $_POST['limit'], 'offset' => $_POST['limit'] * $_POST['page'], 'meta_key' => '_customer_user', 'meta_value' => $_POST['user_id'], 'post_type' => wc_get_order_types(), 'post_status' => array_keys(wc_get_order_statuses())));
     $orders = array();
     foreach ($customer_orders as $order) {
         $order = new WC_Order($order->ID);
         $order_info = array('order_id' => $order->id, "order_date" => $order->order_date, "total" => $order->get_total(), "status" => $order->get_status(), "items" => $order->get_items(), "payment_method" => $order->payment_method, "billing_address" => $order->get_address('billing'), "shipping_address" => $order->get_address('shipping'));
         $orders[] = $order_info;
     }
     DABBA_API_Output::get()->output(true, 200, '', $orders);
 }
开发者ID:pcuervo,项目名称:dabba,代码行数:12,代码来源:class-dabba_api-webservices.php


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