• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_get_order函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_get_order函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_order函数的具体用法?PHP wc_get_order怎么用?PHP wc_get_order使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: create_order

 /**
  * Create a order.
  *
  * @since 2.4
  *
  * @return WC_Order Order object.
  */
 public static function create_order()
 {
     // Create product
     $product = WC_Helper_Product::create_simple_product();
     WC_Helper_Shipping::create_simple_flat_rate();
     $order_data = array('status' => 'pending', 'customer_id' => 1, 'customer_note' => '', 'total' => '');
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     // Required, else wc_create_order throws an exception
     $order = wc_create_order($order_data);
     // Add order products
     $item_id = $order->add_product($product, 4);
     // Set billing address
     $billing_address = array('country' => 'US', 'first_name' => 'Jeroen', 'last_name' => 'Sormani', 'company' => 'WooCompany', 'address_1' => 'WooAddress', 'address_2' => '', 'postcode' => '123456', 'city' => 'WooCity', 'state' => 'NY', 'email' => '[email protected]', 'phone' => '555-32123');
     $order->set_address($billing_address, 'billing');
     // Add shipping costs
     $shipping_taxes = WC_Tax::calc_shipping_tax('10', WC_Tax::get_shipping_tax_rates());
     $order->add_shipping(new WC_Shipping_Rate('flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate'));
     // Set payment gateway
     $payment_gateways = WC()->payment_gateways->payment_gateways();
     $order->set_payment_method($payment_gateways['bacs']);
     // Set totals
     $order->set_total(10, 'shipping');
     $order->set_total(0, 'cart_discount');
     $order->set_total(0, 'cart_discount_tax');
     $order->set_total(0, 'tax');
     $order->set_total(0, 'shipping_tax');
     $order->set_total(40, 'total');
     // 4 x $10 simple helper product
     return wc_get_order($order->id);
 }
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:37,代码来源:class-wc-helper-order.php


示例2: process_refund

 /**
  * Process a refund if supported
  * @param  int $order_id
  * @param  float $amount
  * @param  string $reason
  * @return  bool|wp_error True or false based on success, or a WP_Error object
  */
 public function process_refund($order_id, $amount = null, $reason = '')
 {
     $order = wc_get_order($order_id);
     $transaction_id = null;
     $args = array('post_id' => $order->id, 'approve' => 'approve', 'type' => '');
     remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'));
     $comments = get_comments($args);
     foreach ($comments as $comment) {
         if (strpos($comment->comment_content, 'Transaction ID: ') !== false) {
             $exploded_comment = explode(": ", $comment->comment_content);
             $transaction_id = $exploded_comment[1];
         }
     }
     add_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'));
     if (!$order || !$transaction_id) {
         return false;
     }
     // Add transaction-specific details to the request
     $transaction_details = array('username' => $this->username, 'password' => $this->password, 'type' => 'refund', 'transactionid' => $transaction_id, 'ipaddress' => $_SERVER['REMOTE_ADDR']);
     if (!is_null($amount)) {
         $transaction_details['amount'] = number_format($amount, 2, '.', '');
     }
     // Send request and get response from server
     $response = $this->post_and_get_response($transaction_details);
     // Check response
     if ($response['response'] == 1) {
         // Success
         $order->add_order_note(__('Inspire Commerce refund completed. Refund Transaction ID: ', 'woocommerce') . $response['transactionid']);
         return true;
     } else {
         // Failure
         $order->add_order_note(__('Inspire Commerce refund error. Response data: ', 'woocommerce') . http_build_query($response));
         return false;
     }
 }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:42,代码来源:gateway-inspire.php


示例3: admin_order_item_values

        public function admin_order_item_values($_product, $item, $item_id)
        {
            if (is_object($_product)) {
                global $post_id;
                $wc_order = wc_get_order($post_id);
                if ($wc_order !== false) {
                    $fpd_data = $wc_order->get_item_meta($item_id, 'fpd_data', true);
                    if (!empty($fpd_data)) {
                        ?>
						<td class="fancy-product" width="100px">
							<button class='button button-secondary fpd-show-order-item' data-order_id='<?php 
                        echo $post_id;
                        ?>
' data-order_item_id='<?php 
                        echo $item_id;
                        ?>
'><?php 
                        _e('Load in Order Viewer', 'radykal');
                        ?>
</button>
						</td>
						<?php 
                    }
                }
            }
        }
开发者ID:woakes070048,项目名称:fancy-product-designer-extended,代码行数:26,代码来源:class-admin-order.php


示例4: bank_details

 /**
  * Get bank details and place into a list format.
  *
  * Note: Since this is declared as a private function in WC_Gateway_BACS, it needs
  * to be copied here 1:1
  *
  * @param int $order_id
  */
 private function bank_details($order_id = '')
 {
     if (empty($this->account_details)) {
         return;
     }
     // Get order and store in $order
     $order = wc_get_order($order_id);
     // Get the order country and country $locale
     $country = $order->billing_country;
     $locale = $this->get_country_locale();
     // Get sortcode label in the $locale array and use appropriate one
     $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort Code', 'woocommerce');
     $bacs_accounts = apply_filters('woocommerce_bacs_accounts', $this->account_details);
     if (!empty($bacs_accounts)) {
         echo '<h2>' . __('Our Bank Details', 'woocommerce') . '</h2>' . PHP_EOL;
         foreach ($bacs_accounts as $bacs_account) {
             $bacs_account = (object) $bacs_account;
             if ($bacs_account->account_name || $bacs_account->bank_name) {
                 echo '<h3>' . wp_unslash(implode(' - ', array_filter(array($bacs_account->account_name, $bacs_account->bank_name)))) . '</h3>' . PHP_EOL;
             }
             echo '<ul class="order_details bacs_details">' . PHP_EOL;
             // BACS account fields shown on the thanks page and in emails
             $account_fields = apply_filters('woocommerce_bacs_account_fields', array('account_number' => array('label' => __('Account Number', 'woocommerce'), 'value' => $bacs_account->account_number), 'sort_code' => array('label' => $sortcode, 'value' => $bacs_account->sort_code), 'iban' => array('label' => __('IBAN', 'woocommerce'), 'value' => $bacs_account->iban), 'bic' => array('label' => __('BIC', 'woocommerce'), 'value' => $bacs_account->bic)), $order_id);
             foreach ($account_fields as $field_key => $field) {
                 if (!empty($field['value'])) {
                     echo '<li class="' . esc_attr($field_key) . '">' . esc_attr($field['label']) . ': <strong>' . wptexturize($field['value']) . '</strong></li>' . PHP_EOL;
                 }
             }
             echo '</ul>';
         }
     }
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:40,代码来源:GatewayBACS.php


示例5: _add_recipient_partner

 function _add_recipient_partner($emails, $objects)
 {
     $order_id = isset($objects->id) ? $objects->id : false;
     if ($order_id) {
         // change order currency
         if ($currency = get_post_meta($order_id, '_order_currency', true)) {
             TravelHelper::change_current_currency($currency);
         }
         $order = wc_get_order($order_id);
         if (sizeof($order->get_items()) > 0) {
             $partner_email_array = array();
             foreach ($order->get_items() as $item_id => $item) {
                 if (!empty($item['item_meta']['_st_st_booking_id'][0]) and $st_booking_id = $item['item_meta']['_st_st_booking_id'][0]) {
                     $post_type = !empty($item['item_meta']['_st_st_booking_post_type']) ? $item['item_meta']['_st_st_booking_post_type'] : false;
                     $post_type = st_wc_parse_order_item_meta($post_type);
                     $partner_email = apply_filters('st_get_owner_email_' . $post_type, $st_booking_id);
                     if ($partner_email != $st_booking_id) {
                         if (!in_array($partner_email, $partner_email_array)) {
                             $partner_email_array[] = $partner_email;
                         }
                     }
                 }
             }
             if (!empty($partner_email_array)) {
                 $emails .= ',' . implode(',', $partner_email_array);
             }
         }
     }
     return $emails;
 }
开发者ID:DaddyFool,项目名称:travelTest,代码行数:30,代码来源:class.woocommerce.php


示例6: complete_order_if_admin

 public function complete_order_if_admin($order_id)
 {
     if (current_user_can('manage_options')) {
         $order = wc_get_order($order_id);
         $order->payment_complete();
     }
 }
开发者ID:darbymanning,项目名称:Family-Church,代码行数:7,代码来源:CheckoutController.php


示例7: get_endpoint_title

 /**
  * Get page title for an endpoint.
  * @param  string
  * @return string
  */
 public function get_endpoint_title($endpoint)
 {
     global $wp;
     switch ($endpoint) {
         case 'order-pay':
             $title = __('Pay for Order', 'woocommerce');
             break;
         case 'order-received':
             $title = __('Order Received', 'woocommerce');
             break;
         case 'view-order':
             $order = wc_get_order($wp->query_vars['view-order']);
             $title = $order ? sprintf(__('Order #%s', 'woocommerce'), $order->get_order_number()) : '';
             break;
         case 'edit-account':
             $title = __('Edit Account Details', 'woocommerce');
             break;
         case 'edit-address':
             $title = __('Edit Address', 'woocommerce');
             break;
         case 'add-payment-method':
             $title = __('Add Payment Method', 'woocommerce');
             break;
         case 'lost-password':
             $title = __('Lost Password', 'woocommerce');
             break;
         default:
             $title = '';
             break;
     }
     return $title;
 }
开发者ID:rchittock,项目名称:woocommerce,代码行数:37,代码来源:class-wc-query.php


示例8: save_downloadable_product_permissions

 /**
  * Save the download permissions on the individual subscriptions as well as the order. Hooked into
  * 'woocommerce_grant_product_download_permissions', which is strictly after the order received all the info
  * it needed, so we don't need to play with priorities.
  *
  * @param integer $order_id the ID of the order. At this point it is guaranteed that it has files in it and that it hasn't been granted permissions before
  */
 public static function save_downloadable_product_permissions($order_id)
 {
     global $wpdb;
     $order = wc_get_order($order_id);
     if (wcs_order_contains_subscription($order, 'any')) {
         $subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => array('any')));
     } else {
         return;
     }
     foreach ($subscriptions as $subscription) {
         if (sizeof($subscription->get_items()) > 0) {
             foreach ($subscription->get_items() as $item) {
                 $_product = $subscription->get_product_from_item($item);
                 if ($_product && $_product->exists() && $_product->is_downloadable()) {
                     $downloads = $_product->get_files();
                     $product_id = wcs_get_canonical_product_id($item);
                     foreach (array_keys($downloads) as $download_id) {
                         // grant access on subscription if it does not already exist
                         if (!$wpdb->get_var($wpdb->prepare("SELECT download_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE `order_id` = %d AND `product_id` = %d AND `download_id` = '%s'", $subscription->id, $product_id, $download_id))) {
                             wc_downloadable_file_permission($download_id, $product_id, $subscription, $item['qty']);
                         }
                         self::revoke_downloadable_file_permission($product_id, $order_id, $order->user_id);
                     }
                 }
             }
         }
         update_post_meta($subscription->id, '_download_permissions_granted', 1);
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:36,代码来源:class-wcs-download-handler.php


示例9: output

 /**
  * Output the shortcode.
  *
  * @param array $atts
  */
 public static function output($atts)
 {
     // Check cart class is loaded or abort
     if (is_null(WC()->cart)) {
         return;
     }
     extract(shortcode_atts(array(), $atts));
     global $post;
     if (!empty($_REQUEST['orderid']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-order_tracking')) {
         $order_id = empty($_REQUEST['orderid']) ? 0 : esc_attr($_REQUEST['orderid']);
         $order_email = empty($_REQUEST['order_email']) ? '' : esc_attr($_REQUEST['order_email']);
         if (!$order_id) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
         } elseif (!$order_email) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
         } else {
             $order = wc_get_order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
             if ($order && $order->get_id() && $order_email) {
                 if (strtolower($order->get_billing_email()) == strtolower($order_email)) {
                     do_action('woocommerce_track_order', $order->get_id());
                     wc_get_template('order/tracking.php', array('order' => $order));
                     return;
                 }
             } else {
                 echo '<p class="woocommerce-error">' . sprintf(__('Sorry, we could not find that order ID in our database.', 'woocommerce'), get_permalink($post->ID)) . '</p>';
             }
         }
     }
     wc_get_template('order/form-tracking.php');
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:35,代码来源:class-wc-shortcode-order-tracking.php


示例10: create_export_customers_tool

 /**
  * create_export_customers_tool.
  *
  * @version 2.3.9
  * @since   2.3.9
  */
 function create_export_customers_tool()
 {
     $html = '';
     $html .= '<pre>';
     $html .= __('Nr.', 'woocommerce-jetpack') . ',' . __('Email', 'woocommerce-jetpack') . ',' . __('First Name', 'woocommerce-jetpack') . ',' . __('Last Name', 'woocommerce-jetpack') . ',' . __('Order Date', 'woocommerce-jetpack') . PHP_EOL;
     $total_customers = 0;
     $orders = array();
     $offset = 0;
     $block_size = 96;
     while (true) {
         $args_orders = array('post_type' => 'shop_order', 'post_status' => 'any', 'posts_per_page' => $block_size, 'orderby' => 'date', 'order' => 'DESC', 'offset' => $offset);
         $loop_orders = new WP_Query($args_orders);
         if (!$loop_orders->have_posts()) {
             break;
         }
         while ($loop_orders->have_posts()) {
             $loop_orders->the_post();
             $order_id = $loop_orders->post->ID;
             $order = wc_get_order($order_id);
             if (isset($order->billing_email) && '' != $order->billing_email && !in_array($order->billing_email, $orders)) {
                 $emails_to_skip = array();
                 if (!in_array($order->billing_email, $emails_to_skip)) {
                     $total_customers++;
                     $html .= $total_customers . ',' . $order->billing_email . ',' . $order->billing_first_name . ',' . $order->billing_last_name . ',' . get_the_date('Y/m/d') . PHP_EOL;
                     $orders[] = $order->billing_email;
                 }
             }
         }
         $offset += $block_size;
     }
     $html .= '</pre>';
     echo $html;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:39,代码来源:class-wcj-general.php


示例11: wc_reduce_stock_levels

/**
 * Reduce stock levels for items within an order.
 * @since 2.7.0
 * @param int $order_id
 */
function wc_reduce_stock_levels($order_id)
{
    $order = wc_get_order($order_id);
    if ('yes' === get_option('woocommerce_manage_stock') && $order && apply_filters('woocommerce_can_reduce_order_stock', true, $order) && sizeof($order->get_items()) > 0) {
        foreach ($order->get_items() as $item) {
            if ($item->is_type('line_item') && ($product = $item->get_product()) && $product->managing_stock()) {
                $qty = apply_filters('woocommerce_order_item_quantity', $item->get_quantity(), $order, $item);
                $item_name = $product->get_formatted_name();
                $new_stock = wc_update_product_stock($product, $qty, 'decrease');
                if (!is_wp_error($new_stock)) {
                    /* translators: 1: item name 2: old stock quantity 3: new stock quantity */
                    $order->add_order_note(sprintf(__('%1$s stock reduced from %2$s to %3$s.', 'woocommerce'), $item_name, $new_stock + $qty, $new_stock));
                    if ('' !== get_option('woocommerce_notify_no_stock_amount') && $new_stock <= get_option('woocommerce_notify_no_stock_amount')) {
                        do_action('woocommerce_no_stock', $product);
                    } elseif ('' !== get_option('woocommerce_notify_low_stock_amount') && $new_stock <= get_option('woocommerce_notify_low_stock_amount')) {
                        do_action('woocommerce_low_stock', $product);
                    }
                    if ($new_stock < 0) {
                        do_action('woocommerce_product_on_backorder', array('product' => $product, 'order_id' => $order_id, 'quantity' => $qty_ordered));
                    }
                }
            }
        }
        do_action('woocommerce_reduce_order_stock', $order);
    }
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:31,代码来源:wc-stock-functions.php


示例12: trigger

 /**
  * Trigger.
  *
  * @version 2.4.0
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         if ($this->customer_email) {
             $this->recipient = $this->object->billing_email;
         }
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     if ($order_id) {
         global $post;
         $order = wc_get_order($order_id);
         $post = $order->post;
         setup_postdata($post);
     }
     $this->send($this->get_recipient(), $this->get_subject(), do_shortcode($this->get_content()), $this->get_headers(), $this->get_attachments());
     if ($order_id) {
         wp_reset_postdata();
     }
 }
开发者ID:bailoo,项目名称:10dollrWP,代码行数:31,代码来源:class-wc-email-wcj-custom.php


示例13: get_paypal_order

 /**
  * Get the order from the PayPal 'Custom' variable
  *
  * @param  string $raw_custom JSON Data passed back by PayPal
  * @return bool|WC_Order object
  */
 protected function get_paypal_order($raw_custom)
 {
     // We have the data in the correct format, so get the order
     if (($custom = json_decode($raw_custom)) && is_object($custom)) {
         $order_id = $custom->order_id;
         $order_key = $custom->order_key;
         // Fallback to serialized data if safe. This is @deprecated in 2.3.11
     } elseif (preg_match('/^a:2:{/', $raw_custom) && !preg_match('/[CO]:\\+?[0-9]+:"/', $raw_custom) && ($custom = maybe_unserialize($raw_custom))) {
         $order_id = $custom[0];
         $order_key = $custom[1];
         // Nothing was found
     } else {
         WC_Gateway_Paypal::log('Error: Order ID and key were not found in "custom".');
         return false;
     }
     if (!($order = wc_get_order($order_id))) {
         // We have an invalid $order_id, probably because invoice_prefix has changed
         $order_id = wc_get_order_id_by_order_key($order_key);
         $order = wc_get_order($order_id);
     }
     if (!$order || $order->order_key !== $order_key) {
         WC_Gateway_Paypal::log('Error: Order Keys do not match.');
         return false;
     }
     return $order;
 }
开发者ID:slavic18,项目名称:cats,代码行数:32,代码来源:class-wc-gateway-paypal-response.php


示例14: render_order_columns

 /**
  * Output custom columns for orders
  *
  * @param   string $column
  * @version 2.2.6
  * @since   2.2.4
  */
 public function render_order_columns($column)
 {
     if ('profit' === $column) {
         $total_profit = 0;
         $the_order = wc_get_order(get_the_ID());
         if ('completed' === $the_order->get_status()) {
             $is_forecasted = false;
             foreach ($the_order->get_items() as $item_id => $item) {
                 //					$product = $this->get_product_from_item( $item );
                 $the_profit = 0;
                 if (0 != ($purchase_price = wc_get_product_purchase_price($item['product_id']))) {
                     $the_profit = $item['line_total'] + $item['line_tax'] - $purchase_price * $item['qty'];
                     //						$total_profit += $the_profit;
                     //						echo $item['line_total'] . ' ~ ' . $purchase_price . ' ~ ' . $item['qty'];
                 } else {
                     //$the_profit = ( $item['line_total'] + $item['line_tax'] ) * 0.2;
                     $is_forecasted = true;
                 }
                 $total_profit += $the_profit;
             }
         }
         if (0 != $total_profit) {
             if (!$is_forecasted) {
                 echo '<span style="color:green;">';
             }
             echo wc_price($total_profit);
             if (!$is_forecasted) {
                 echo '</span>';
             }
         }
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:39,代码来源:class-wcj-purchase-data.php


示例15: get_order

 /**
  * Get parent order object.
  * @return int
  */
 public function get_order()
 {
     if (!$this->_order) {
         $this->_order = wc_get_order($this->get_order_id());
     }
     return $this->_order;
 }
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:11,代码来源:class-wc-order-item.php


示例16: trigger

 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order)
 {
     if (!is_object($order)) {
         $order = wc_get_order(absint($order));
     }
     if ($order) {
         $this->object = $order;
         $this->recipient = $this->object->billing_email;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->get_recipient()) {
         return;
     }
     if (version_compare(WOOCOMMERCE_VERSION, '2.2', '<')) {
         return;
     }
     $refunds = $order->get_refunds();
     if (empty($refunds)) {
         return;
     }
     $result = $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
     do_action('wpo_wcpdf_pro_email_sent', $result, $this->id, $order);
 }
开发者ID:baden03,项目名称:access48,代码行数:32,代码来源:email-customer-credit-note.php


示例17: export

 /**
  * Export the orders and display an admin notice showing the # of successful/failed exports and any error messages
  *
  * @since 1.0
  */
 public function export()
 {
     global $wc_sage_erp_connector;
     $success = $failure = 0;
     foreach ($this->order_ids as $order_id) {
         $order = wc_get_order($order_id);
         $export = $this->export_order($order);
         // keep track of the number of successful/failed exports
         if ($export) {
             $success++;
         } else {
             $failure++;
         }
     }
     // add an admin message displaying the number of successful exports
     if ($success) {
         $wc_sage_erp_connector->messages->add_message(sprintf(_n('Order exported to Sage ERP.', '%s orders exported to Sage ERP.', $success, WC_Sage_ERP_Connector::TEXT_DOMAIN), number_format_i18n($success)));
     }
     // add an admin error message displaying the number of failed exports
     if ($failure) {
         $wc_sage_erp_connector->messages->add_error(sprintf(_n('Order failed export to Sage ERP.', '%s orders failed export to Sage ERP.', $failure, WC_Sage_ERP_Connector::TEXT_DOMAIN), number_format_i18n($failure)));
     }
     // persist errors / messages to display on next page load
     $wc_sage_erp_connector->messages->set_messages();
 }
开发者ID:nikolov-tmw,项目名称:woocommerce-sage-erp-connector,代码行数:30,代码来源:class-wc-sage-erp-connector-exporter.php


示例18: render_order_columns

 /**
  * Output custom columns for orders
  *
  * @param   string $column
  * @version 2.5.9
  * @since   2.2.4
  * @todo    forecasted profit
  */
 function render_order_columns($column)
 {
     if ('profit' === $column) {
         $total_profit = 0;
         $the_order = wc_get_order(get_the_ID());
         if (!in_array($the_order->get_status(), array('cancelled', 'refunded', 'failed'))) {
             $is_forecasted = false;
             foreach ($the_order->get_items() as $item_id => $item) {
                 $the_profit = 0;
                 $product_id = isset($item['variation_id']) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'];
                 if (0 != ($purchase_price = wc_get_product_purchase_price($product_id))) {
                     //						$line_total = ( 'yes' === get_option('woocommerce_prices_include_tax') ) ? ( $item['line_total'] + $item['line_tax'] ) : $item['line_total'];
                     $line_total = $the_order->prices_include_tax ? $item['line_total'] + $item['line_tax'] : $item['line_total'];
                     $the_profit = $line_total - $purchase_price * $item['qty'];
                 } else {
                     //						$the_profit = ( $item['line_total'] + $item['line_tax'] ) * $average_profit_margin;
                     $is_forecasted = true;
                 }
                 $total_profit += $the_profit;
             }
         }
         if (0 != $total_profit) {
             if (!$is_forecasted) {
                 echo '<span style="color:green;">';
             }
             echo wc_price($total_profit);
             if (!$is_forecasted) {
                 echo '</span>';
             }
         }
     }
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:40,代码来源:class-wcj-purchase-data.php


示例19: get_order_tokens

 /**
  * Returns an array of payment token objects associated with the passed order ID.
  * @since 2.6.0
  * @param int $order_id Order ID
  * @return array Array of token objects
  */
 public static function get_order_tokens($order_id)
 {
     $order = wc_get_order($order_id);
     if (!$order) {
         return array();
     }
     $token_ids = get_post_meta($order_id, '_payment_tokens', true);
     if (empty($token_ids)) {
         return array();
     }
     global $wpdb;
     $token_ids_as_string = implode(',', array_map('intval', $token_ids));
     $token_results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token_id IN ( {$token_ids_as_string} )");
     if (empty($token_results)) {
         return array();
     }
     $tokens = array();
     foreach ($token_results as $token_result) {
         $_token = self::get($token_result->token_id, $token_result);
         if (!empty($_token)) {
             $tokens[$token_result->token_id] = $_token;
         }
     }
     return apply_filters('woocommerce_get_order_payment_tokens', $tokens, $order_id);
 }
开发者ID:jameztrue,项目名称:woocommerce,代码行数:31,代码来源:class-wc-payment-tokens.php


示例20: init_atts

 /**
  * init_atts.
  */
 function init_atts($atts)
 {
     $this->the_order = 'shop_order' === get_post_type($atts['order_id']) ? wc_get_order($atts['order_id']) : null;
     if (!$this->the_order) {
         return false;
     }
     return $atts;
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:11,代码来源:class-wcj-order-items-shortcodes.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_get_order_id_by_order_key函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_get_notices函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap