本文整理汇总了PHP中WC_Order::populate方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::populate方法的具体用法?PHP WC_Order::populate怎么用?PHP WC_Order::populate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Order
的用法示例。
在下文中一共展示了WC_Order::populate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populate
/**
* Populates a subscription from the loaded post data.
*
* @param mixed $result
*/
public function populate($result)
{
parent::populate($result);
if ($this->post->post_parent > 0) {
$this->order = wc_get_order($this->post->post_parent);
}
}
示例2: foreach
?>
</span></th>
<th class="order-actions"> </th>
</tr>
</thead>
<tbody><?php
//echo "hiiiiiiii";
//print_r($order_ids);
//$user_product_bought=fused_has_user_bought(6,$order_userids);
//print_r($user_product_bought);
//$order = new WC_Order();
//print_r($order_userids);
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$status = get_term_by('slug', $order->status, 'shop_order_status');
$item_count = $order->get_item_count();
?>
<tr class="order">
<td class="order-number">
<a href="<?php
echo esc_url(add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))));
?>
">
<?php
echo $order->get_order_number();
?>
</a>
</td>
<td class="order-date">
示例3: array
//.........这里部分代码省略.........
?>
</span></th>
<th class="order-status"><span class="nobr"><?php
_e('Stato', 'woocommerce');
?>
</span></th>
<th class="order-total"><span class="nobr"><?php
_e('Totale', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Prodotti / Attributi / Totale', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Dettagli', 'woocommerce');
?>
</span></th>
<th class="order-actions"><span class="nobr"><?php
_e('Annullare', 'woocommerce');
?>
</span></th>
</tr>
</thead>
<style>
.hentry img { height: auto; max-width: 35%;}
.woocommerce-message { display:none;}
</style>
<tbody><?php
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$status = get_term_by('slug', $order->status, 'shop_order_status');
$item_count = $order->get_item_count();
?>
<tr class="order">
<td class="order-number">
<a href="<?php
echo $order->get_view_order_url();
?>
">
<?php
echo $order->get_order_number();
?>
</a>
</td>
<td class="order-date">
<time datetime="<?php
echo date('Y-m-d', strtotime($order->order_date));
?>
" title="<?php
echo esc_attr(strtotime($order->order_date));
?>
"><?php
echo date_i18n(get_option('date_format'), strtotime($order->order_date));
?>
</time>
</td>
<td class="order-status" style="text-align:left; text-transform:uppercase; white-space:nowrap; color:#0C0" >
<?php
echo ucfirst(__($status->name, 'woocommerce'));
?>
</td>
<td class="order-total">
示例4: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
global $woocommerce;
//$logged_out_title = (!empty()) ? $instance['logged_out_title'] : __('Customer Login', 'woocommerce-my-account-widget');
$logged_out_title = apply_filters('widget_title', empty($instance['logged_out_title']) ? __('Customer Login', 'woocommerce-my-account-widget') : $instance['logged_out_title'], $instance);
//$logged_in_title = (!empty()) ? $instance['logged_in_title'] : __('Welcome %s', 'woocommerce-my-account-widget');
$logged_in_title = apply_filters('widget_title', empty($instance['logged_in_title']) ? __('Welcome %s', 'woocommerce-my-account-widget') : $instance['logged_in_title'], $instance);
echo $before_widget;
$c = isset($instance['show_cartlink']) && $instance['show_cartlink'] ? '1' : '0';
$cart_page_id = get_option('woocommerce_cart_page_id');
//check if user is logged in
if (is_user_logged_in()) {
$it = isset($instance['show_items']) && $instance['show_items'] ? '1' : '0';
$u = isset($instance['show_upload']) && $instance['show_upload'] ? '1' : '0';
$unew = isset($instance['show_upload_new']) && $instance['show_upload_new'] ? '1' : '0';
$up = isset($instance['show_unpaid']) && $instance['show_unpaid'] ? '1' : '0';
$p = isset($instance['show_pending']) && $instance['show_pending'] ? '1' : '0';
$lo = isset($instance['show_logout_link']) && $instance['show_logout_link'] ? '1' : '0';
// redirect url after login / logout
if (is_multisite()) {
$woo_ma_home = network_home_url();
} else {
$woo_ma_home = home_url();
}
$user = get_user_by('id', get_current_user_id());
echo '<div class=login>';
if ($user->first_name != "") {
$uname = $user->first_name;
} else {
$uname = $user->display_name;
}
if ($logged_in_title) {
echo $before_title . sprintf($logged_in_title, ucwords($uname)) . $after_title;
}
if ($c) {
echo '<p><a class="woo-ma-button cart-link woo-ma-cart-link" href="' . get_permalink(wma_lang_id($cart_page_id)) . '" title="' . __('View your shopping cart', 'woocommerce-my-account-widget') . '">' . __('View your shopping cart', 'woocommerce-my-account-widget') . '</a></p>';
}
$notcompleted = 0;
$uploadfile = 0;
$uploadfile_new = 0;
$notpaid = 0;
$customer_id = get_current_user_id();
if (version_compare(WOOCOMMERCE_VERSION, "2.2") < 0) {
$customer_orders = get_posts(array('numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => 'shop_order', 'post_status' => 'publish'));
} else {
$customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => wc_get_order_types('view-orders'), 'post_status' => array_keys(wc_get_order_statuses()))));
}
if ($customer_orders) {
foreach ($customer_orders as $customer_order) {
$woocommerce1 = 0;
if (version_compare(WOOCOMMERCE_VERSION, "2.2") < 0) {
$order = new WC_Order();
$order->populate($customer_order);
} else {
$order = wc_get_order($customer_order->ID);
}
//$status = get_term_by('slug', $order->status, 'shop_order_status');
if ($order->status != 'completed' && $order->status != 'cancelled') {
$notcompleted++;
}
/* upload files */
if (function_exists('woocommerce_umf_admin_menu')) {
if (get_max_upload_count($order) > 0) {
$j = 1;
foreach ($order->get_items() as $order_item) {
$max_upload_count = get_max_upload_count($order, $order_item['product_id']);
$i = 1;
$upload_count = 0;
while ($i <= $max_upload_count) {
if (get_post_meta($order->id, '_woo_umf_uploaded_file_name_' . $j, true) != "") {
$upload_count++;
}
$i++;
$j++;
}
/* toon aantal nog aan te leveren bestanden */
$upload_count = $max_upload_count - $upload_count;
$uploadfile += $upload_count;
}
}
}
if (class_exists('WPF_Uploads')) {
// Uploads needed
$uploads_needed = WPF_Uploads::order_needs_upload($order, true);
$uploaded_count_new = WPF_Uploads::order_get_upload_count($order->id);
$uploads_needed_left = $uploads_needed - $uploaded_count_new;
$uploadfile_new = $uploadfile_new + $uploads_needed_left;
}
if (in_array($order->status, array('on-hold', 'pending', 'failed'))) {
$notpaid++;
}
}
}
$my_account_id = wma_lang_id(get_option('woocommerce_myaccount_page_id'));
echo '<ul class="clearfix woo-ma-list">';
if ($it) {
//$woocommerce->cart->get_cart_url()
echo '<li class="woo-ma-link item">
<a class="cart-contents-new" href="' . get_permalink(wma_lang_id($cart_page_id)) . '" title="' . __('View your shopping cart', 'woocommerce-my-account-widget') . '">
//.........这里部分代码省略.........
示例5: swr_profile_rewards
function swr_profile_rewards($user)
{
global $woocommerce, $swr_settings;
$rewards = swr_get_user_current_rewards(array('user_id' => $user->ID));
?>
<h3><?php
_e('Rewards', 'rewards');
?>
</h3>
<table class="form-table">
<tr>
<th>
<label for="gateways"><?php
echo sprintf(__('Current %s earned', 'rewards'), $swr_settings->get_title());
?>
</label>
</th>
<td>
<input type="text" name="swr_rewards" id="swr_rewards" value="<?php
echo $rewards;
?>
" class="regular-text">
</td>
</tr>
</table>
<?php
global $woocommerce, $recent_orders, $swr_settings;
/* $swr_settings = $woocommerce->rewards->rewards['rewards_settings']; */
$customer_id = $user->ID;
$args = array('numberposts' => $recent_orders, 'meta_key' => '_customer_user', 'meta_value' => $customer_id, 'post_type' => 'shop_order', 'post_status' => 'publish');
$customer_orders = get_posts($args);
$msg = sprintf(__('Current %s balance: %s', 'rewards'), $swr_settings->get_title(), swr_get_user_current_rewards(array('user_id' => $customer_id, 'formatted' => true)));
if ($customer_orders) {
?>
<h4><?php
_e("Orders", "rewards");
?>
</h4>
<table class="shop_table my_account_orders" style="width:50%;">
<thead>
<tr>
<th class="order-number" style="width:35%;"><span class="nobr"><?php
_e('Order', 'rewards');
?>
</span></th>
<th class="order-total rewards-earned" style="width:20%;"><span class="nobr"><?php
_e('Total earned', 'rewards');
?>
</span></th>
<th class="order-total rewards-used" style="width:20%;"><span class="nobr"><?php
_e('Total Used', 'rewards');
?>
</span></th>
<th class="order-total rewards-status" style="width:25%;"><span class="nobr"><?php
_e('Status', 'rewards');
?>
</span></th>
</tr>
</thead>
<tbody><?php
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$status = get_term_by('slug', $order->status, 'shop_order_status');
?>
<tr class="order">
<td class="order-number" width="1%">
<a href="<?php
echo admin_url('post.php?post=' . $order->id . '&action=edit');
?>
"><?php
echo $order->get_order_number();
?>
</a> – <time title="<?php
echo esc_attr(strtotime($order->order_date));
?>
"><?php
echo date_i18n(get_option('date_format'), strtotime($order->order_date));
?>
</time>
</td>
<td class="order-total rewards-earned" width="1%"><?php
echo $swr_settings->format_reward($order->rewards_earned);
?>
</td>
<td class="order-total rewards-used" width="1%"><?php
echo $swr_settings->format_reward($order->rewards_used);
?>
</td>
<td class="order-total rewards-status" width="1%"><?php
_e($status->name, 'woocommerce');
?>
</td>
</tr><?php
}
?>
</tbody>
//.........这里部分代码省略.........
示例6: _woocommercecivicrm_customer_orders
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;
}
开发者ID:rajeshrhino,项目名称:uk.co.vedaconsulting.module.woocommercecivicrm,代码行数:24,代码来源:woocommercecivicrm.php
示例7: array
function my_account_orders()
{
global $woocommerce;
$customer_id = get_current_user_id();
if (version_compare(WC_VERSION, '2.2.0', '<')) {
$args = array('numberposts' => 50, 'meta_key' => '_customer_user', 'meta_value' => $customer_id, 'post_type' => 'shop_order', 'meta_query' => array(array('key' => '_funds_deposited', 'value' => '1')));
} else {
$args = array('numberposts' => 50, 'meta_key' => '_customer_user', 'meta_value' => $customer_id, 'post_type' => 'shop_order', 'post_status' => array('wc-completed', 'wc-processing', 'wc-on-hold'), 'meta_query' => array(array('key' => '_funds_deposited', 'value' => '1')));
}
$deposits = get_posts($args);
?>
<h2><?php
_e('Recent Deposits', 'wc_account_funds');
?>
</h2>
<?php
if ($deposits) {
?>
<table class="shop_table my_account_deposits">
<thead>
<tr>
<th class="order-number"><span class="nobr"><?php
_e('Order', 'woocommerce');
?>
</span></th>
<th class="order-date"><span class="nobr"><?php
_e('Date', 'woocommerce');
?>
</span></th>
<th class="order-total"><span class="nobr"><?php
_e('Total', 'woocommerce');
?>
</span></th>
<th class="order-status" colspan="2"><span class="nobr"><?php
_e('Status', 'woocommerce');
?>
</span></th>
</tr>
</thead>
<tbody><?php
foreach ($deposits as $deposit) {
$order = new WC_Order();
$order->populate($deposit);
$status = get_term_by('slug', $order->status, 'shop_order_status');
?>
<tr class="order">
<td class="order-number" width="1%">
<a href="<?php
echo esc_url(add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))));
?>
"><?php
echo $order->get_order_number();
?>
</a>
</td>
<td class="order-date"><time title="<?php
echo esc_attr(strtotime($order->order_date));
?>
"><?php
echo date_i18n(get_option('date_format'), strtotime($order->order_date));
?>
</time></td>
<td class="order-total" width="1%"><?php
echo $order->get_formatted_order_total();
?>
</td>
<td class="order-status" style="text-align:left; white-space:nowrap;">
<?php
echo ucfirst(__($status->name, 'woocommerce'));
?>
<?php
if (in_array($order->status, array('pending', 'failed'))) {
?>
<a href="<?php
echo esc_url($order->get_cancel_order_url());
?>
" class="cancel" title="<?php
_e('Click to cancel this order', 'woocommerce');
?>
">(<?php
_e('Cancel', 'woocommerce');
?>
)</a>
<?php
}
?>
</td>
<td class="order-actions" style="text-align:right; white-space:nowrap;">
<?php
if (in_array($order->status, array('pending', 'failed'))) {
?>
<a href="<?php
echo esc_url($order->get_checkout_payment_url());
?>
" class="button pay"><?php
_e('Pay', 'woocommerce');
?>
//.........这里部分代码省略.........
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:101,代码来源:bigbosswoocommerce-deposit-funds.php
示例8: prepare_items
/**
* Prepare the list of pre-order items for display
*
* @see WP_List_Table::prepare_items()
* @since 1.0
*/
public function prepare_items()
{
$this->process_actions();
$per_page = $this->get_items_per_page('wc_pre_orders_edit_pre_orders_per_page');
// main query args
$args = array('post_type' => 'shop_order', 'post_status' => array('publish', 'trash'), 'posts_per_page' => $per_page, 'paged' => $this->get_pagenum(), 'orderby' => $this->get_current_orderby(), 'order' => $this->get_current_order(), 'meta_query' => array(array('key' => '_wc_pre_orders_is_pre_order', 'value' => 1)));
// Pre-order status view
$args = $this->add_view_args($args);
// Filter: pre-orders by customer
$args = $this->add_filter_args($args);
// handle search
$args = $this->add_search_args($args);
$args = apply_filters('wc_pre_orders_edit_pre_orders_request', $args);
$query = new WP_Query($args);
$this->items = array();
foreach ($query->posts as $order_post) {
$order = new WC_Order();
$order->populate($order_post);
$this->items[] = $order;
}
$this->set_pagination_args(array('total_items' => $query->found_posts, 'per_page' => $per_page, 'total_pages' => ceil($query->found_posts / $per_page)));
}
示例9: display_camp_emails
function display_camp_emails()
{
$terms = get_terms(array('camp'));
?>
<h1>Get Emails</h1>
<form action="" method="post">
<select name="camp" id="camp">
<option value="">-</option>
<?php
foreach ($terms as $term) {
?>
<?php
$selected = isset($_POST['camp']) ? selected($term->slug, $_POST['camp'], false) : '';
?>
<option value="<?php
echo $term->slug;
?>
" <?php
echo $selected;
?>
><?php
echo $term->name;
?>
</option>
<?php
}
?>
</select>
<input type="submit" value="Get Email List" />
</form>
<?php
if (isset($_POST['camp'])) {
$results = get_posts(array('post_type' => 'player', 'camp' => $_POST['camp'], 'meta_key' => 'guardian_email', 'posts_per_page' => -1));
$email_list = array();
foreach ($results as $player) {
$email_list[] = get_post_meta($player->ID, 'guardian_email', true);
}
$list = implode(', ', array_unique($email_list));
?>
<textarea name="list" id="list" cols="30" rows="10">
<?php
echo $list;
?>
</textarea>
<?php
}
?>
<h1>Orders on-hold</h1>
<form action="" method="post">
<input type="submit" value="Get On-hold emails" name="orders-on-hold" />
</form>
<?php
if (isset($_POST['orders-on-hold'])) {
$args = array('post_type' => 'shop_order', 'post_status' => 'publish', 'meta_key' => '_customer_user', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'shop_order_status', 'field' => 'slug', 'terms' => 'on-hold')));
$my_query = new WP_Query($args);
$customer_orders = $my_query->posts;
$email_list = array();
foreach ($customer_orders as $customer_order) {
$order = new WC_Order();
$order->populate($customer_order);
$email_list[] = $order->billing_email;
}
$list = implode(', ', array_unique($email_list));
?>
<textarea name="on-hold-list" id="on-hold-list" cols="30" rows="10"><?php
echo $list;
?>
</textarea>
<?php
}
//end if $_POST
}
示例10: update_user_rewards_used
public function update_user_rewards_used()
{
$rewards_used = array();
$orders = get_posts(array('numberposts' => -1, 'post_type' => 'shop_order', 'post_status' => 'publish'));
if ($orders) {
foreach ($orders as $corder) {
$order = new WC_Order();
$order->populate($corder);
$status = get_term_by('slug', $order->status, 'shop_order_status');
if ($order->status == 'completed') {
$used = $this->get_reward_used_for_order($order->id);
if (!isset($rewards_used[$order->customer_user])) {
$rewards_used[$order->customer_user] = 0;
}
$rewards_used[$order->customer_user] += $used;
}
}
}
if (!empty($rewards_used)) {
foreach ($rewards_used as $user_id => $used) {
update_user_meta($user_id, 'swr_rewards_used', $used);
}
}
}
示例11: get_users_pre_orders
/**
* Gets all pre-orders for the currently logged in user, or the user identified by $user_id
*
* @since 1.0
* @param int $user_id optional user id to return pre-orders for. Defaults to the currently logged in user.
* @return array of WC_Order objects
*/
public static function get_users_pre_orders($user_id = null)
{
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$args = array('post_type' => 'shop_order', 'post_status' => 'publish', 'nopaging' => true, 'meta_query' => array(array('key' => '_customer_user', 'value' => $user_id), array('key' => '_wc_pre_orders_is_pre_order', 'value' => 1)));
$posts = get_posts($args);
$orders = array();
foreach ($posts as $order_post) {
$order = new WC_Order();
$order->populate($order_post);
$orders[] = $order;
}
return apply_filters('wc_pre_orders_users_pre_orders', $orders, $user_id);
}