get_formatted_shipping_full_name() public method

Get a formatted shipping full name.
Beispiel #1
0
 /**
  * Test: get_formatted_shipping_full_name
  */
 function test_get_formatted_shipping_full_name()
 {
     $object = new WC_Order();
     $object->set_shipping_first_name('Barney');
     $object->set_shipping_last_name('Rubble');
     $this->assertEquals('Barney Rubble', $object->get_formatted_shipping_full_name());
 }
Beispiel #2
0
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);
            //return;
            $To = get_option('admin_email') . ",dev_support@soixanteseize.com";
            $Objet = $email_heading = "Votre lien pour lancer la livraison Couriier";
            ob_start();
            include COURIIERPATH . 'views/mails/woo-couriier-order-ready.php';
            $Body = ob_get_clean();
            //trace($Body);
            sendCC($To, $Objet, $Body);
            //return;
        }
    } else {
        $To = get_option('admin_email') . ",dev_support@soixanteseize.com";
        $Objet = $email_heading = "U+026A0 Vérifiez la commande " . $order_id;
        $message = $response[1];
        ob_start();
        include COURIIERPATH . 'views/mails/woo-couriier-blank.php';
        $Body = ob_get_clean();
        //trace($Body);
        sendCC($To, $Objet, $Body);
    }
    //sendCC($To, $Objet, $Body);
}
function _woocommercecivicrm_customer_orders($uid)
{
    $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('meta_key' => '_customer_user', 'meta_value' => $uid, 'post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses()))));
    $site_url = get_site_url();
    $orders = array();
    foreach ($customer_orders as $customer_order) {
        $order = new WC_Order();
        $order->populate($customer_order);
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        //$items = $order->get_items();
        //print_r ($items);
        $item_count = $order->get_item_count();
        $total = $order->get_total();
        $orders[$customer_order->ID]['order_number'] = $order->get_order_number();
        $orders[$customer_order->ID]['order_date'] = date('Y-m-d', strtotime($order->order_date));
        $orders[$customer_order->ID]['order_billing_name'] = $order->get_formatted_billing_full_name();
        $orders[$customer_order->ID]['order_shipping_name'] = $order->get_formatted_shipping_full_name();
        $orders[$customer_order->ID]['item_count'] = $item_count;
        $orders[$customer_order->ID]['order_total'] = $total;
        $orders[$customer_order->ID]['order_link'] = $site_url . "/wp-admin/post.php?action=edit&post=" . $order->get_order_number();
        //$orders['order_total'] = $order->get_order_number();
    }
    return $orders;
}