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


PHP WC_Order::get_billing_address方法代码示例

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


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

示例1: woocommerce_custom_order_columns

/**
 * Values for the custom columns on the orders page.
 *
 * @access public
 * @param mixed $column
 * @return void
 */
function woocommerce_custom_order_columns($column)
{
    global $post, $woocommerce, $the_order;
    if (empty($the_order) || $the_order->id != $post->ID) {
        $the_order = new WC_Order($post->ID);
    }
    switch ($column) {
        case "order_status":
            printf('<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title($the_order->status), esc_html__($the_order->status, 'woocommerce'), esc_html__($the_order->status, 'woocommerce'));
            break;
        case "order_title":
            if ($the_order->user_id) {
                $user_info = get_userdata($the_order->user_id);
            }
            if (!empty($user_info)) {
                $user = '<a href="user-edit.php?user_id=' . absint($user_info->ID) . '">';
                if ($user_info->first_name || $user_info->last_name) {
                    $user .= esc_html($user_info->first_name . ' ' . $user_info->last_name);
                } else {
                    $user .= esc_html($user_info->display_name);
                }
                $user .= '</a>';
            } else {
                $user = __('Guest', 'woocommerce');
            }
            echo '<a href="' . admin_url('post.php?post=' . absint($post->ID) . '&action=edit') . '"><strong>' . sprintf(__('Order %s', 'woocommerce'), esc_attr($the_order->get_order_number())) . '</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user;
            if ($the_order->billing_email) {
                echo '<small class="meta">' . __('Email:', 'woocommerce') . ' ' . '<a href="' . esc_url('mailto:' . $the_order->billing_email) . '">' . esc_html($the_order->billing_email) . '</a></small>';
            }
            if ($the_order->billing_phone) {
                echo '<small class="meta">' . __('Tel:', 'woocommerce') . ' ' . esc_html($the_order->billing_phone) . '</small>';
            }
            break;
        case "billing_address":
            if ($the_order->get_formatted_billing_address()) {
                echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_billing_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_billing_address())) . '</a>';
            } else {
                echo '&ndash;';
            }
            if ($the_order->payment_method_title) {
                echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>';
            }
            break;
        case "shipping_address":
            if ($the_order->get_formatted_shipping_address()) {
                echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_shipping_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_shipping_address())) . '</a>';
            } else {
                echo '&ndash;';
            }
            if ($the_order->shipping_method_title) {
                echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->shipping_method_title) . '</small>';
            }
            break;
        case "total_cost":
            echo esc_html(strip_tags($the_order->get_formatted_order_total()));
            break;
        case "order_date":
            if ('0000-00-00 00:00:00' == $post->post_date) {
                $t_time = $h_time = __('Unpublished', 'woocommerce');
            } else {
                $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post);
                $gmt_time = strtotime($post->post_date_gmt . ' UTC');
                $time_diff = current_time('timestamp', 1) - $gmt_time;
                if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                    $h_time = sprintf(__('%s ago', 'woocommerce'), human_time_diff($gmt_time, current_time('timestamp', 1)));
                } else {
                    $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post);
                }
            }
            echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('post_date_column_time', $h_time, $post)) . '</abbr>';
            break;
        case "order_actions":
            ?>
<p>
				<?php 
            do_action('woocommerce_admin_order_actions_start', $the_order);
            $actions = array();
            if (in_array($the_order->status, array('pending', 'on-hold'))) {
                $actions['processing'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-processing&order_id=' . $post->ID), 'woocommerce-mark-order-processing'), 'name' => __('Processing', 'woocommerce'), 'action' => "processing");
            }
            if (in_array($the_order->status, array('pending', 'on-hold', 'processing'))) {
                $actions['complete'] = array('url' => wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-complete&order_id=' . $post->ID), 'woocommerce-mark-order-complete'), 'name' => __('Complete', 'woocommerce'), 'action' => "complete");
            }
            $actions['view'] = array('url' => admin_url('post.php?post=' . $post->ID . '&action=edit'), 'name' => __('View', 'woocommerce'), 'action' => "view");
            $actions = apply_filters('woocommerce_admin_order_actions', $actions, $the_order);
            foreach ($actions as $action) {
                $image = isset($action['image_url']) ? $action['image_url'] : $woocommerce->plugin_url() . '/assets/images/icons/' . $action['action'] . '.png';
                printf('<a class="button tips" href="%s" data-tip="%s"><img src="%s" alt="%s" width="14" /></a>', esc_url($action['url']), esc_attr($action['name']), esc_attr($image), esc_attr($action['name']));
            }
            do_action('woocommerce_admin_order_actions_end', $the_order);
            ?>

			</p><?php 
//.........这里部分代码省略.........
开发者ID:joshquila,项目名称:demo2-youse,代码行数:101,代码来源:shop_order.php

示例2: custom_columns

        /**
         * Define our custom columns shown in admin.
         * @param  string $column
         */
        public function custom_columns($column)
        {
            global $post, $woocommerce, $the_order;
            if (empty($the_order) || $the_order->id != $post->ID) {
                $the_order = new WC_Order($post->ID);
            }
            switch ($column) {
                case 'order_status':
                    printf('<mark class="%s tips" data-tip="%s">%s</mark>', sanitize_title($the_order->status), esc_html__($the_order->status, 'woocommerce'), esc_html__($the_order->status, 'woocommerce'));
                    break;
                case 'order_date':
                    if ('0000-00-00 00:00:00' == $post->post_date) {
                        $t_time = $h_time = __('Unpublished', 'woocommerce');
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post);
                        $gmt_time = strtotime($post->post_date_gmt . ' UTC');
                        $time_diff = current_time('timestamp', 1) - $gmt_time;
                        $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post);
                    }
                    echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('post_date_column_time', $h_time, $post)) . '</abbr>';
                    break;
                case 'customer_message':
                    if ($the_order->customer_message) {
                        echo '<span class="note-on tips" data-tip="' . esc_attr($the_order->customer_message) . '">' . __('Yes', 'woocommerce') . '</span>';
                    } else {
                        echo '<span class="na">&ndash;</span>';
                    }
                    break;
                case 'billing_address':
                    if ($the_order->get_formatted_billing_address()) {
                        echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_billing_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_billing_address())) . '</a>';
                    } else {
                        echo '&ndash;';
                    }
                    if ($the_order->payment_method_title) {
                        echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->payment_method_title) . '</small>';
                    }
                    break;
                case 'order_items':
                    echo '<a href="#" class="show_order_items">' . apply_filters('woocommerce_admin_order_item_count', sprintf(_n('%d item', '%d items', $the_order->get_item_count(), 'woocommerce'), $the_order->get_item_count()), $the_order) . '</a>';
                    if (sizeof($the_order->get_items()) > 0) {
                        echo '<table class="order_items" cellspacing="0">';
                        foreach ($the_order->get_items() as $item) {
                            $_product = apply_filters('woocommerce_order_item_product', $the_order->get_product_from_item($item), $item);
                            $item_meta = new WC_Order_Item_Meta($item['item_meta']);
                            $item_meta_html = $item_meta->display(true, true);
                            ?>
						<tr class="<?php 
                            echo apply_filters('woocommerce_admin_order_item_class', '', $item);
                            ?>
">
							<td class="qty"><?php 
                            echo absint($item['qty']);
                            ?>
</td>
							<td class="name">
								<?php 
                            if (wc_product_sku_enabled() && $_product && $_product->get_sku()) {
                                echo $_product->get_sku() . ' - ';
                            }
                            echo apply_filters('woocommerce_order_item_name', $item['name'], $item);
                            ?>
								<?php 
                            if ($item_meta_html) {
                                ?>
									<a class="tips" href="#" data-tip="<?php 
                                echo esc_attr($item_meta_html);
                                ?>
">[?]</a>
								<?php 
                            }
                            ?>
							</td>
						</tr>
						<?php 
                        }
                        echo '</table>';
                    } else {
                        echo '&ndash;';
                    }
                    break;
                case 'shipping_address':
                    if ($the_order->get_formatted_shipping_address()) {
                        echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($the_order->get_shipping_address()) . '&z=16') . '">' . esc_html(preg_replace('#<br\\s*/?>#i', ', ', $the_order->get_formatted_shipping_address())) . '</a>';
                    } else {
                        echo '&ndash;';
                    }
                    if ($the_order->get_shipping_method()) {
                        echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($the_order->get_shipping_method()) . '</small>';
                    }
                    break;
                case 'order_notes':
                    if ($post->comment_count) {
                        // check the status of the post
                        $post->post_status !== 'trash' ? $status = '' : ($status = 'post-trashed');
                        $latest_notes = get_comments(array('post_id' => $post->ID, 'number' => 1, 'status' => $status));
//.........这里部分代码省略.........
开发者ID:phupx,项目名称:genco,代码行数:101,代码来源:class-wc-admin-cpt-shop_order.php

示例3: check_type_of_product

function check_type_of_product($order_id)
{
    create_xero_invoice($order_id);
    if (!is_Null) {
        $order = NULL;
    }
    global $post;
    $order = new WC_Order($order_id);
    $items = $order->get_items();
    $OrderItemIds = array_keys($items);
    $numberOfItems = $order->get_item_count();
    $counter = 0;
    foreach ($items as $item) {
        $orderItemId = $OrderItemIds[$counter];
        $product = $order->get_product_from_item($item);
        $productAttributes = $product->get_attributes();
        if (!is_null($productAttributes['webinarid']['value'])) {
            $webinarId = $productAttributes['webinarid']['value'];
        } else {
            $webinarId = NULL;
        }
        if (!is_null($webinarId)) {
            $billingAddress = $order->get_formatted_billing_address();
            $firstName = $item['item_meta']['firstName'][0];
            $lastName = $item['item_meta']['lastName'][0];
            $email = $item['item_meta']['email'][0];
            $citrix = new CitrixAPI('5d8ab3cea37233d7d97dc1db5994fc9c', '8876575418305764356');
            $registerAttendee = $citrix->createRegistrant($webinarId, $firstName, $lastName, $email);
        } else {
            $userID = $order->customer_user;
            $adviserEmail = $order->billing_email;
            $billingAddressFormatted = $order->get_formatted_billing_address();
            $billingAddress = $order->get_billing_address();
            $billingName = $order->billing_first_name . ' ' . $order->billing_last_name;
            //$billingFormatted;//
            $billingCompany = $order->billing_company;
            $billing_phone = $order->billing_phone;
            if (!is_null($order->billing_address_1)) {
                $billingAddress1 = $order->billing_address_1;
            } else {
                $billingAddress1 = '';
            }
            if (!is_null($order->billing_address_2)) {
                $billingAddress2 = $order->billing_address_2;
            } else {
                $billingAddress2 = '';
            }
            if (!is_null($order->billing_city)) {
                $billingCity = $order->billing_city;
            } else {
                $billingCity = '';
            }
            if (!is_null($order->billing_state)) {
                $billingState = $order->billing_state;
            } else {
                $billingState = '';
            }
            if (!is_null($order->billing_postcode)) {
                $billingPostcode = $order->billing_postcode;
            } else {
                $billingPostcode = '';
            }
            //if virtual product, post data to server as well.
            //$isVirtual = $product->is_virtual();
            //if($isVirtual){
            //$emailToAdmin = 0;
            //post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin);
            //}
            //24 April 2014 - Altered so that all orders post data when complete so that I can auto-complete all orders, not just electronic ones.
            post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin);
            generate_docs_on_data_server($order_id, $orderItemId, $product, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode);
        }
        $counter = $counter + 1;
    }
    $order = NULL;
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:76,代码来源:woo-functions.php

示例4: woocommerce_custom_order_columns

function woocommerce_custom_order_columns($column)
{
    global $post, $woocommerce;
    $order = new WC_Order($post->ID);
    switch ($column) {
        case "order_status":
            echo sprintf('<mark class="%s">%s</mark>', sanitize_title($order->status), __($order->status, 'woocommerce'));
            break;
        case "order_title":
            if ($order->user_id) {
                $user_info = get_userdata($order->user_id);
            }
            if (isset($user_info) && $user_info) {
                $user = '<a href="user-edit.php?user_id=' . esc_attr($user_info->ID) . '">';
                if ($user_info->first_name || $user_info->last_name) {
                    $user .= $user_info->first_name . ' ' . $user_info->last_name;
                } else {
                    $user .= esc_html($user_info->display_name);
                }
                $user .= '</a>';
            } else {
                $user = __('Guest', 'woocommerce');
            }
            echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '"><strong>' . sprintf(__('Order #%s', 'woocommerce'), $post->ID) . '</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user;
            if ($order->billing_email) {
                echo '<small class="meta">' . __('Email:', 'woocommerce') . ' ' . '<a href="' . esc_url('mailto:' . $order->billing_email) . '">' . esc_html($order->billing_email) . '</a></small>';
            }
            if ($order->billing_phone) {
                echo '<small class="meta">' . __('Tel:', 'woocommerce') . ' ' . esc_html($order->billing_phone) . '</small>';
            }
            break;
        case "billing_address":
            if ($order->get_formatted_billing_address()) {
                echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($order->get_billing_address()) . '&z=16') . '">' . preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_billing_address()) . '</a>';
            } else {
                echo '&ndash;';
            }
            if ($order->payment_method_title) {
                echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($order->payment_method_title) . '</small>';
            }
            break;
        case "shipping_address":
            if ($order->get_formatted_shipping_address()) {
                echo '<a target="_blank" href="' . esc_url('http://maps.google.com/maps?&q=' . urlencode($order->get_shipping_address()) . '&z=16') . '">' . preg_replace('#<br\\s*/?>#i', ', ', $order->get_formatted_shipping_address()) . '</a>';
            } else {
                echo '&ndash;';
            }
            if ($order->shipping_method_title) {
                echo '<small class="meta">' . __('Via', 'woocommerce') . ' ' . esc_html($order->shipping_method_title) . '</small>';
            }
            break;
        case "total_cost":
            echo woocommerce_price($order->order_total);
            break;
        case "order_date":
            if ('0000-00-00 00:00:00' == $post->post_date) {
                $t_time = $h_time = __('Unpublished', 'woocommerce');
            } else {
                $t_time = get_the_time(__('Y/m/d g:i:s A', 'woocommerce'), $post);
                $gmt_time = strtotime($post->post_date_gmt);
                $time_diff = current_time('timestamp', 1) - $gmt_time;
                if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                    $h_time = sprintf(__('%s ago', 'woocommerce'), human_time_diff($gmt_time, current_time('timestamp', 1)));
                } else {
                    $h_time = get_the_time(__('Y/m/d', 'woocommerce'), $post);
                }
            }
            echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post) . '</abbr>';
            break;
        case "order_actions":
            ?>
<p>
				<?php 
            if (in_array($order->status, array('pending', 'on-hold'))) {
                ?>
<a class="button" href="<?php 
                echo wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-processing&order_id=' . $post->ID), 'woocommerce-mark-order-processing');
                ?>
"><?php 
                _e('Processing', 'woocommerce');
                ?>
</a><?php 
            }
            ?>
				<?php 
            if (in_array($order->status, array('pending', 'on-hold', 'processing'))) {
                ?>
<a class="button" href="<?php 
                echo wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-mark-order-complete&order_id=' . $post->ID), 'woocommerce-mark-order-complete');
                ?>
"><?php 
                _e('Complete', 'woocommerce');
                ?>
</a><?php 
            }
            ?>
				<a class="button" href="<?php 
            echo admin_url('post.php?post=' . $post->ID . '&action=edit');
            ?>
"><?php 
//.........这里部分代码省略.........
开发者ID:rosslavery,项目名称:woocommerce,代码行数:101,代码来源:shop_order.php


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