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


PHP WC_Order_Item_Meta::get_formatted方法代码示例

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


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

示例1: output_csv

 /**
  * Sort the data for CSV output first
  *
  * @param int   $product_id
  * @param array $headers
  * @param array $body
  * @param array $items
  */
 public static function output_csv($product_id, $headers, $body, $items)
 {
     $headers['quantity'] = __('Quantity', 'wcvendors');
     $new_body = array();
     foreach ($body as $i => $order) {
         // Remove comments
         unset($body[$i]['comments']);
         // Remove all numeric keys in each order (these are the meta values we are redoing into new lines)
         foreach ($order as $key => $col) {
             if (is_int($key)) {
                 unset($order[$key]);
             }
         }
         // New order row
         $new_row = $body[$i];
         // Remove order to redo
         unset($body[$i]);
         foreach ($items[$i]['items'] as $item) {
             $item_meta = new WC_Order_Item_Meta($item['item_meta']);
             $item_meta_options = $item_meta->get_formatted();
             // $item_meta = $item_meta->display( true, true );
             $new_row_with_meta = $new_row;
             if (sizeof($item_meta_options) > 0) {
                 $new_row_with_meta[] = $item['qty'];
                 foreach ($item_meta_options as $item_meta_option) {
                     if (!array_key_exists($item_meta_option['label'], $headers)) {
                         $headers[$item_meta_option['label']] = $item_meta_option['label'];
                     }
                     $new_row_with_meta[] = $item_meta_option['value'];
                 }
             } else {
                 $new_row_with_meta[] = $item['qty'];
             }
             $new_body[] = $new_row_with_meta;
         }
     }
     $headers = apply_filters('wcvendors_csv_headers', $headers, $product_id, $items);
     $body = apply_filters('wcvendors_csv_body', $new_body, $product_id, $items);
     WCV_Export_CSV::download($headers, $body, $product_id);
 }
开发者ID:oleggen,项目名称:wcvendors,代码行数:48,代码来源:class-export-csv.php

示例2: prepare_item_for_response

 /**
  * Prepare a single order output for response.
  *
  * @param WP_Post $post Post object.
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response $data
  */
 public function prepare_item_for_response($post, $request)
 {
     global $wpdb;
     $order = wc_get_order($post);
     $dp = $request['dp'];
     $data = array('id' => $order->id, 'parent_id' => $post->post_parent, 'status' => $order->get_status(), 'order_key' => $order->order_key, 'currency' => $order->get_order_currency(), 'version' => $order->order_version, 'prices_include_tax' => $order->prices_include_tax, 'date_created' => wc_rest_prepare_date_response($post->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($post->post_modified_gmt), 'customer_id' => $order->get_user_id(), 'discount_total' => wc_format_decimal($order->get_total_discount(), $dp), 'discount_tax' => wc_format_decimal($order->cart_discount_tax, $dp), 'shipping_total' => wc_format_decimal($order->get_total_shipping(), $dp), 'shipping_tax' => wc_format_decimal($order->get_shipping_tax(), $dp), 'cart_tax' => wc_format_decimal($order->get_cart_tax(), $dp), 'total' => wc_format_decimal($order->get_total(), $dp), 'total_tax' => wc_format_decimal($order->get_total_tax(), $dp), 'billing' => array(), 'shipping' => array(), 'payment_method' => $order->payment_method, 'payment_method_title' => $order->payment_method_title, 'transaction_id' => $order->get_transaction_id(), 'customer_ip_address' => $order->customer_ip_address, 'customer_user_agent' => $order->customer_user_agent, 'created_via' => $order->created_via, 'customer_note' => $order->customer_note, 'date_completed' => wc_rest_prepare_date_response($order->completed_date), 'date_paid' => $order->paid_date, 'cart_hash' => $order->cart_hash, 'line_items' => array(), 'tax_lines' => array(), 'shipping_lines' => array(), 'fee_lines' => array(), 'coupon_lines' => array(), 'refunds' => array());
     // Add addresses.
     $data['billing'] = $order->get_address('billing');
     $data['shipping'] = $order->get_address('shipping');
     // Add line items.
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         $product_id = 0;
         $variation_id = 0;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = $product->id;
             $variation_id = $product->variation_id;
             $product_sku = $product->get_sku();
         }
         $meta = new WC_Order_Item_Meta($item, $product);
         $item_meta = array();
         $hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
         foreach ($meta->get_formatted($hideprefix) as $meta_key => $formatted_meta) {
             $item_meta[] = array('key' => $formatted_meta['key'], 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
         }
         $line_item = array('id' => $item_id, 'name' => $item['name'], 'sku' => $product_sku, 'product_id' => (int) $product_id, 'variation_id' => (int) $variation_id, 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : '', 'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'subtotal' => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($order->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'taxes' => array(), 'meta' => $item_meta);
         $item_line_taxes = maybe_unserialize($item['line_tax_data']);
         if (isset($item_line_taxes['total'])) {
             $line_tax = array();
             foreach ($item_line_taxes['total'] as $tax_rate_id => $tax) {
                 $line_tax[$tax_rate_id] = array('id' => $tax_rate_id, 'total' => $tax, 'subtotal' => '');
             }
             foreach ($item_line_taxes['subtotal'] as $tax_rate_id => $tax) {
                 $line_tax[$tax_rate_id]['subtotal'] = $tax;
             }
             $line_item['taxes'] = array_values($line_tax);
         }
         $data['line_items'][] = $line_item;
     }
     // Add taxes.
     foreach ($order->get_items('tax') as $key => $tax) {
         $tax_line = array('id' => $key, 'rate_code' => $tax['name'], 'rate_id' => $tax['rate_id'], 'label' => isset($tax['label']) ? $tax['label'] : $tax['name'], 'compound' => (bool) $tax['compound'], 'tax_total' => wc_format_decimal($tax['tax_amount'], $dp), 'shipping_tax_total' => wc_format_decimal($tax['shipping_tax_amount'], $dp));
         $data['tax_lines'][] = $tax_line;
     }
     // Add shipping.
     foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
         $shipping_line = array('id' => $shipping_item_id, 'method_title' => $shipping_item['name'], 'method_id' => $shipping_item['method_id'], 'total' => wc_format_decimal($shipping_item['cost'], $dp), 'total_tax' => wc_format_decimal('', $dp), 'taxes' => array());
         $shipping_taxes = maybe_unserialize($shipping_item['taxes']);
         if (!empty($shipping_taxes)) {
             $shipping_line['total_tax'] = wc_format_decimal(array_sum($shipping_taxes), $dp);
             foreach ($shipping_taxes as $tax_rate_id => $tax) {
                 $shipping_line['taxes'][] = array('id' => $tax_rate_id, 'total' => $tax);
             }
         }
         $data['shipping_lines'][] = $shipping_line;
     }
     // Add fees.
     foreach ($order->get_fees() as $fee_item_id => $fee_item) {
         $fee_line = array('id' => $fee_item_id, 'name' => $fee_item['name'], 'tax_class' => !empty($fee_item['tax_class']) ? $fee_item['tax_class'] : '', 'tax_status' => 'taxable', 'total' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'total_tax' => wc_format_decimal($order->get_line_tax($fee_item), $dp), 'taxes' => array());
         $fee_line_taxes = maybe_unserialize($fee_item['line_tax_data']);
         if (isset($fee_line_taxes['total'])) {
             $fee_tax = array();
             foreach ($fee_line_taxes['total'] as $tax_rate_id => $tax) {
                 $fee_tax[$tax_rate_id] = array('id' => $tax_rate_id, 'total' => $tax, 'subtotal' => '');
             }
             foreach ($fee_line_taxes['subtotal'] as $tax_rate_id => $tax) {
                 $fee_tax[$tax_rate_id]['subtotal'] = $tax;
             }
             $fee_line['taxes'] = array_values($fee_tax);
         }
         $data['fee_lines'][] = $fee_line;
     }
     // Add coupons.
     foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) {
         $coupon_line = array('id' => $coupon_item_id, 'code' => $coupon_item['name'], 'discount' => wc_format_decimal($coupon_item['discount_amount'], $dp), 'discount_tax' => wc_format_decimal($coupon_item['discount_amount_tax'], $dp));
         $data['coupon_lines'][] = $coupon_line;
     }
     // Add refunds.
     foreach ($order->get_refunds() as $refund) {
         $data['refunds'][] = array('id' => $refund->id, 'refund' => $refund->get_refund_reason() ? $refund->get_refund_reason() : '', 'total' => '-' . wc_format_decimal($refund->get_refund_amount(), $dp));
     }
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($data, $request);
     $data = $this->filter_response_by_context($data, $context);
     // Wrap the data in a response object.
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($order));
     /**
      * Filter the data for a response.
      *
      * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being
//.........这里部分代码省略.........
开发者ID:coderkevin,项目名称:woocommerce,代码行数:101,代码来源:class-wc-rest-orders-controller.php

示例3: get_order_data

 /**
  * Get the order data for the given ID.
  *
  * @since  2.5.0
  * @param  WC_Order $order The order instance
  * @return array
  */
 protected function get_order_data($order)
 {
     $order_post = get_post($order->id);
     $dp = wc_get_price_decimals();
     $order_data = array('id' => $order->id, 'order_number' => $order->get_order_number(), 'created_at' => $this->format_datetime($order_post->post_date_gmt), 'updated_at' => $this->format_datetime($order_post->post_modified_gmt), 'completed_at' => $this->format_datetime($order->completed_date, true), 'status' => $order->get_status(), 'currency' => $order->get_order_currency(), 'total' => wc_format_decimal($order->get_total(), $dp), 'subtotal' => wc_format_decimal($order->get_subtotal(), $dp), 'total_line_items_quantity' => $order->get_item_count(), 'total_tax' => wc_format_decimal($order->get_total_tax(), $dp), 'total_shipping' => wc_format_decimal($order->get_total_shipping(), $dp), 'cart_tax' => wc_format_decimal($order->get_cart_tax(), $dp), 'shipping_tax' => wc_format_decimal($order->get_shipping_tax(), $dp), 'total_discount' => wc_format_decimal($order->get_total_discount(), $dp), 'shipping_methods' => $order->get_shipping_method(), 'payment_details' => array('method_id' => $order->payment_method, 'method_title' => $order->payment_method_title, 'paid' => isset($order->paid_date)), 'billing_address' => array('first_name' => $order->billing_first_name, 'last_name' => $order->billing_last_name, 'company' => $order->billing_company, 'address_1' => $order->billing_address_1, 'address_2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postcode' => $order->billing_postcode, 'country' => $order->billing_country, 'email' => $order->billing_email, 'phone' => $order->billing_phone), 'shipping_address' => array('first_name' => $order->shipping_first_name, 'last_name' => $order->shipping_last_name, 'company' => $order->shipping_company, 'address_1' => $order->shipping_address_1, 'address_2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postcode' => $order->shipping_postcode, 'country' => $order->shipping_country), 'note' => $order->customer_note, 'customer_ip' => $order->customer_ip_address, 'customer_user_agent' => $order->customer_user_agent, 'customer_id' => $order->get_user_id(), 'view_order_url' => $order->get_view_order_url(), 'line_items' => array(), 'shipping_lines' => array(), 'tax_lines' => array(), 'fee_lines' => array(), 'coupon_lines' => array());
     // add line items
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         $product_id = null;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
             $product_sku = $product->get_sku();
         }
         $meta = new WC_Order_Item_Meta($item, $product);
         $item_meta = array();
         foreach ($meta->get_formatted(null) as $meta_key => $formatted_meta) {
             $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
         }
         $order_data['line_items'][] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($order->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $item_meta);
     }
     // Add shipping.
     foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
         $order_data['shipping_lines'][] = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], $dp));
     }
     // Add taxes.
     foreach ($order->get_tax_totals() as $tax_code => $tax) {
         $order_data['tax_lines'][] = array('id' => $tax->id, 'rate_id' => $tax->rate_id, 'code' => $tax_code, 'title' => $tax->label, 'total' => wc_format_decimal($tax->amount, $dp), 'compound' => (bool) $tax->is_compound);
     }
     // Add fees.
     foreach ($order->get_fees() as $fee_item_id => $fee_item) {
         $order_data['fee_lines'][] = array('id' => $fee_item_id, 'title' => $fee_item['name'], 'tax_class' => !empty($fee_item['tax_class']) ? $fee_item['tax_class'] : null, 'total' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'total_tax' => wc_format_decimal($order->get_line_tax($fee_item), $dp));
     }
     // Add coupons.
     foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) {
         $order_data['coupon_lines'][] = array('id' => $coupon_item_id, 'code' => $coupon_item['name'], 'amount' => wc_format_decimal($coupon_item['discount_amount'], $dp));
     }
     $order_data = apply_filters('woocommerce_cli_order_data', $order_data);
     return $this->flatten_array($order_data);
 }
开发者ID:jgcopple,项目名称:drgaryschwantz,代码行数:48,代码来源:class-wc-cli-order.php

示例4: get_order_refund

 /**
  * Get an order refund for the given order ID and ID
  *
  * @since 2.2
  * @param string $order_id order ID
  * @param string|null $fields fields to limit response to
  * @return array
  */
 public function get_order_refund($order_id, $id, $fields = null)
 {
     try {
         // Validate order ID
         $order_id = $this->validate_request($order_id, $this->post_type, 'read');
         if (is_wp_error($order_id)) {
             return $order_id;
         }
         $id = absint($id);
         if (empty($id)) {
             throw new WC_API_Exception('woocommerce_api_invalid_order_refund_id', __('Invalid order refund ID', 'woocommerce'), 400);
         }
         $order = wc_get_order($id);
         $refund = wc_get_order($id);
         if (!$refund) {
             throw new WC_API_Exception('woocommerce_api_invalid_order_refund_id', __('An order refund with the provided ID could not be found', 'woocommerce'), 404);
         }
         $line_items = array();
         // Add line items
         foreach ($refund->get_items('line_item') as $item_id => $item) {
             $product = $order->get_product_from_item($item);
             $meta = new WC_Order_Item_Meta($item, $product);
             $item_meta = array();
             foreach ($meta->get_formatted() as $meta_key => $formatted_meta) {
                 $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
             }
             $line_items[] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item), 2), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], 2), 'total' => wc_format_decimal($order->get_line_total($item), 2), 'total_tax' => wc_format_decimal($order->get_line_tax($item), 2), 'price' => wc_format_decimal($order->get_item_total($item), 2), 'quantity' => (int) $item['qty'], 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => isset($product->variation_id) ? $product->variation_id : $product->id, 'sku' => is_object($product) ? $product->get_sku() : null, 'meta' => $item_meta, 'refunded_item_id' => (int) $item['refunded_item_id']);
         }
         $order_refund = array('id' => $refund->id, 'created_at' => $this->server->format_datetime($refund->date), 'amount' => wc_format_decimal($refund->get_refund_amount(), 2), 'reason' => $refund->get_refund_reason(), 'line_items' => $line_items);
         return array('order_refund' => apply_filters('woocommerce_api_order_refund_response', $order_refund, $id, $fields, $refund, $order_id, $this));
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
开发者ID:Geers,项目名称:woocommerce,代码行数:42,代码来源:class-wc-api-orders.php

示例5: get_legacy_import_one_column_per_line_item

 /**
  * Get the order data format for a single column per line item, compatible with the CSV Import Suite plugin
  *
  * @since 3.0
  * @param array $order_data an array of order data for the given order
  * @param WC_Order $order the WC_Order object
  * @return array modified order data
  */
 private function get_legacy_import_one_column_per_line_item($order_data, WC_Order $order)
 {
     $count = 1;
     // add line items
     foreach ($order->get_items() as $_ => $item) {
         // sku/qty/price
         $product = $order->get_product_from_item($item);
         if (!is_object($product)) {
             $product = new WC_Product(0);
         }
         $sku = $product->get_sku();
         // note that product ID must be prefixed with `product_id:` so the importer can properly parse it vs. the SKU
         $product_id = SV_WC_Plugin_Compatibility::product_get_id($product);
         $line_item = array($sku ? $sku : "product_id:{$product_id}", $item['qty'], $order->get_line_total($item));
         // Add item meta
         $item_meta = new WC_Order_Item_Meta($item);
         $formatted_meta = $item_meta->get_formatted();
         if (!empty($formatted_meta)) {
             foreach ($formatted_meta as $meta_key => $meta) {
                 // remove newlines
                 $label = str_replace(array("\r", "\r\n", "\n"), '', $meta['label']);
                 $value = str_replace(array("\r", "\r\n", "\n"), '', $meta['value']);
                 // escape reserved chars (:;|)
                 $label = str_replace(array(': ', ':', ';', '|'), array('\\: ', '\\:', '\\;', '\\|'), $meta['label']);
                 $value = str_replace(array(': ', ':', ';', '|'), array('\\: ', '\\:', '\\;', '\\|'), $meta['value']);
                 $line_item[] = wp_kses_post($label . ': ' . $value);
             }
         }
         $order_data["order_item_{$count}"] = implode('|', $line_item);
         $count++;
     }
     $count = 1;
     foreach ($order->get_items('shipping') as $_ => $shipping_item) {
         $order_data["shipping_method_{$count}"] = $shipping_item['method_id'];
         $order_data["shipping_cost_{$count}"] = wc_format_decimal($shipping_item['cost'], 2);
         $count++;
     }
     // fix order numbers
     $order_data['order_id'] = $order->id;
     $order_data['order_number_formatted'] = get_post_meta($order->id, '_order_number_formatted', true);
     $order_data['order_number'] = get_post_meta($order->id, '_order_number', true);
     // fix customer user
     $user = new WP_User($order_data['customer_id']);
     $order_data['customer_id'] = $user->user_email;
     return $order_data;
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:54,代码来源:class-wc-customer-order-csv-export-compatibility.php

示例6: get_formatted_item_meta

 /**
  * Return an array of formatted item meta in format:
  *
  * array(
  *   $meta_key => array(
  *     'label' => $label,
  *     'value' => $value
  *   )
  * )
  *
  * e.g.
  *
  * array(
  *   'pa_size' => array(
  *     'label' => 'Size',
  *     'value' => 'Medium',
  *   )
  * )
  *
  * Backports the get_formatted() method to WC 2.1
  *
  * @since 2.2.0
  * @see WC_Order_Item_Meta::get_formatted()
  * @param \WC_Order_Item_Meta $item_meta order item meta class instance
  * @param string $hide_prefix exclude meta when key is prefixed with this, defaults to `_`
  * @return array
  */
 public static function get_formatted_item_meta(WC_Order_Item_Meta $item_meta, $hide_prefix = '_')
 {
     if (self::is_wc_version_gte_2_2()) {
         return $item_meta->get_formatted($hide_prefix);
     } else {
         if (empty($item_meta->meta)) {
             return array();
         }
         $formatted_meta = array();
         foreach ((array) $item_meta->meta as $meta_key => $meta_values) {
             if (empty($meta_values) || !is_array($meta_values) || !empty($hide_prefix) && substr($meta_key, 0, 1) == $hide_prefix) {
                 continue;
             }
             foreach ($meta_values as $meta_value) {
                 // Skip serialised meta
                 if (is_serialized($meta_value)) {
                     continue;
                 }
                 $attribute_key = urldecode(str_replace('attribute_', '', $meta_key));
                 // If this is a term slug, get the term's nice name
                 if (taxonomy_exists($attribute_key)) {
                     $term = get_term_by('slug', $meta_value, $attribute_key);
                     if (!is_wp_error($term) && is_object($term) && $term->name) {
                         $meta_value = $term->name;
                     }
                     // If we have a product, and its not a term, try to find its non-sanitized name
                 } elseif ($item_meta->product) {
                     $product_attributes = $item_meta->product->get_attributes();
                     if (isset($product_attributes[$attribute_key])) {
                         $meta_key = wc_attribute_label($product_attributes[$attribute_key]['name']);
                     }
                 }
                 $formatted_meta[$meta_key] = array('label' => wc_attribute_label($attribute_key), 'value' => apply_filters('woocommerce_order_item_display_meta_value', $meta_value));
             }
         }
         return $formatted_meta;
     }
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:65,代码来源:class-sv-wc-plugin-compatibility.php

示例7: woo_vou_display_product_item_name

 /**
  * Display Product Item Name
  * 
  * Handles to display product item name
  * 
  * @package WooCommerce - PDF Vouchers
  * @since 2.2.2
  */
 public function woo_vou_display_product_item_name($item = array(), $product = array(), $filter_recipient = false)
 {
     $prefix = WOO_VOU_META_PREFIX;
     $product_item_meta = isset($item['item_meta']) ? $item['item_meta'] : array();
     $product_item_name = '';
     $product_id = isset($product_item_meta['_product_id']) ? $product_item_meta['_product_id'] : '';
     $product_recipient_lables = $this->woo_vou_get_product_recipient_meta($product_id);
     if (!empty($product_item_meta)) {
         // if not empty product meta
         // this is added due to skip depricted function get_formatted_legacy from woocommerce
         if (!defined('DOING_AJAX')) {
             define('DOING_AJAX', true);
         }
         //Item meta object
         //$item_meta_object	= new WC_Order_Item_Meta( $item, $product );
         $item_meta_object = new WC_Order_Item_Meta($product_item_meta);
         //Get product variations
         $product_variations = $item_meta_object->get_formatted();
         //$product_variations	= $this->woo_vou_get_formatted_legacy( '_', $item_meta_object );
         if ($filter_recipient) {
             // If you want to hide some of variations using filter
             $product_variations = apply_filters('woo_vou_hide_recipient_variations', $product_variations, $product_item_meta);
         } else {
             // Displaying old order variations
             //Get recipient name from old orders
             if (!empty($product_item_meta[$prefix . 'recipient_name']) && !empty($product_item_meta[$prefix . 'recipient_name'][0]) && !is_serialized($product_item_meta[$prefix . 'recipient_name'][0])) {
                 $recipient_name_lbl = $product_recipient_lables['recipient_name_lable'];
                 $product_variations[$recipient_name_lbl] = array('label' => $recipient_name_lbl, 'value' => $product_item_meta[$prefix . 'recipient_name'][0]);
             }
             //Get recipient email from old orders
             if (!empty($product_item_meta[$prefix . 'recipient_email']) && !empty($product_item_meta[$prefix . 'recipient_email'][0]) && !is_serialized($product_item_meta[$prefix . 'recipient_email'][0])) {
                 $recipient_email_lbl = $product_recipient_lables['recipient_email_label'];
                 $product_variations[$recipient_email_lbl] = array('label' => $recipient_email_lbl, 'value' => $product_item_meta[$prefix . 'recipient_email'][0]);
             }
             //Get recipient message from old orders
             if (!empty($product_item_meta[$prefix . 'recipient_message']) && !empty($product_item_meta[$prefix . 'recipient_message'][0]) && !is_serialized($product_item_meta[$prefix . 'recipient_message'][0])) {
                 $recipient_msg_lbl = $product_recipient_lables['recipient_message_label'];
                 $product_variations[$recipient_msg_lbl] = array('label' => $recipient_msg_lbl, 'value' => $product_item_meta[$prefix . 'recipient_message'][0]);
             }
         }
         //Hide variation from item
         $product_variations = apply_filters('woo_vou_hide_item_variations', $product_variations);
         // Create variations Html
         if (!empty($product_variations)) {
             //variation display format
             $variation_param_string = apply_filters('woo_vou_variation_name_string_format', '<br /><strong>%1$s</strong>: %2$s', $product_item_meta);
             foreach ($product_variations as $product_variation) {
                 $product_item_name .= sprintf($variation_param_string, $product_variation['label'], $product_variation['value']);
             }
         }
     }
     return apply_filters('woo_vou_display_product_item_name', $product_item_name, $product_item_meta, $filter_recipient);
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:61,代码来源:class-woo-vou-model.php

示例8: prepare_item_for_response

 /**
  * Prepare a single order refund output for response.
  *
  * @param WP_Post $post Post object.
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response $data
  */
 public function prepare_item_for_response($post, $request)
 {
     global $wpdb;
     $order = wc_get_order((int) $request['order_id']);
     if (!$order) {
         return new WP_Error('woocommerce_rest_invalid_order_id', __('Invalid order ID.', 'woocommerce'), 404);
     }
     $refund = wc_get_order($post);
     if (!$refund || intval($refund->post->post_parent) !== intval($order->id)) {
         return new WP_Error('woocommerce_rest_invalid_order_refund_id', __('Invalid order refund ID.', 'woocommerce'), 404);
     }
     $dp = $request['dp'];
     $data = array('id' => $refund->id, 'date_created' => wc_rest_prepare_date_response($refund->date), 'amount' => wc_format_decimal($refund->get_refund_amount(), $dp), 'reason' => $refund->get_refund_reason(), 'line_items' => array());
     // Add line items.
     foreach ($refund->get_items() as $item_id => $item) {
         $product = $refund->get_product_from_item($item);
         $product_id = 0;
         $variation_id = 0;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = $product->id;
             $variation_id = $product->variation_id;
             $product_sku = $product->get_sku();
         }
         $meta = new WC_Order_Item_Meta($item, $product);
         $item_meta = array();
         $hideprefix = 'true' === $request['all_item_meta'] ? null : '_';
         foreach ($meta->get_formatted($hideprefix) as $meta_key => $formatted_meta) {
             $item_meta[] = array('key' => $formatted_meta['key'], 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
         }
         $line_item = array('id' => $item_id, 'name' => $item['name'], 'sku' => $product_sku, 'product_id' => (int) $product_id, 'variation_id' => (int) $variation_id, 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : '', 'price' => wc_format_decimal($refund->get_item_total($item, false, false), $dp), 'subtotal' => wc_format_decimal($refund->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($refund->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'taxes' => array(), 'meta' => $item_meta);
         $item_line_taxes = maybe_unserialize($item['line_tax_data']);
         if (isset($item_line_taxes['total'])) {
             $line_tax = array();
             foreach ($item_line_taxes['total'] as $tax_rate_id => $tax) {
                 $line_tax[$tax_rate_id] = array('id' => $tax_rate_id, 'total' => $tax, 'subtotal' => '');
             }
             foreach ($item_line_taxes['subtotal'] as $tax_rate_id => $tax) {
                 $line_tax[$tax_rate_id]['subtotal'] = $tax;
             }
             $line_item['taxes'] = array_values($line_tax);
         }
         $data['line_items'][] = $line_item;
     }
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($data, $request);
     $data = $this->filter_response_by_context($data, $context);
     // Wrap the data in a response object.
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($refund));
     /**
      * Filter the data for a response.
      *
      * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being
      * prepared for the response.
      *
      * @param WP_REST_Response   $response   The response object.
      * @param WP_Post            $post       Post object.
      * @param WP_REST_Request    $request    Request object.
      */
     return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request);
 }
开发者ID:unfulvio,项目名称:woocommerce,代码行数:70,代码来源:class-wc-rest-order-refunds-controller.php

示例9: request


//.........这里部分代码省略.........
         $customer_xml = $xml->createElement("Customer");
         $this->xml_append($customer_xml, 'CustomerCode', $order->billing_email);
         $billto_xml = $xml->createElement("BillTo");
         $this->xml_append($billto_xml, 'Name', $order->billing_first_name . " " . $order->billing_last_name);
         $this->xml_append($billto_xml, 'Company', $order->billing_company);
         $this->xml_append($billto_xml, 'Phone', $order->billing_phone);
         $this->xml_append($billto_xml, 'Email', $order->billing_email);
         $customer_xml->appendChild($billto_xml);
         $shipto_xml = $xml->createElement("ShipTo");
         if (empty($order->shipping_country)) {
             $this->xml_append($shipto_xml, 'Name', $order->billing_first_name . " " . $order->billing_last_name);
             $this->xml_append($shipto_xml, 'Company', $order->billing_company);
             $this->xml_append($shipto_xml, 'Address1', $order->billing_address_1);
             $this->xml_append($shipto_xml, 'Address2', $order->billing_address_2);
             $this->xml_append($shipto_xml, 'City', $order->billing_city);
             $this->xml_append($shipto_xml, 'State', $order->billing_state);
             $this->xml_append($shipto_xml, 'PostalCode', $order->billing_postcode);
             $this->xml_append($shipto_xml, 'Country', $order->billing_country);
             $this->xml_append($shipto_xml, 'Phone', $order->billing_phone);
         } else {
             $this->xml_append($shipto_xml, 'Name', $order->shipping_first_name . " " . $order->shipping_last_name);
             $this->xml_append($shipto_xml, 'Company', $order->shipping_company);
             $this->xml_append($shipto_xml, 'Address1', $order->shipping_address_1);
             $this->xml_append($shipto_xml, 'Address2', $order->shipping_address_2);
             $this->xml_append($shipto_xml, 'City', $order->shipping_city);
             $this->xml_append($shipto_xml, 'State', $order->shipping_state);
             $this->xml_append($shipto_xml, 'PostalCode', $order->shipping_postcode);
             $this->xml_append($shipto_xml, 'Country', $order->shipping_country);
             $this->xml_append($shipto_xml, 'Phone', $order->billing_phone);
         }
         $customer_xml->appendChild($shipto_xml);
         $order_xml->appendChild($customer_xml);
         // Item data
         $found_item = false;
         $items_xml = $xml->createElement("Items");
         foreach ($order->get_items() as $item_id => $item) {
             $product = $order->get_product_from_item($item);
             if (!$product || !$product->needs_shipping()) {
                 continue;
             }
             $found_item = true;
             $item_xml = $xml->createElement("Item");
             $image_id = $product->get_image_id();
             if ($image_id) {
                 $image_url = current(wp_get_attachment_image_src($image_id, 'shop_thumbnail'));
             } else {
                 $image_url = '';
             }
             $this->xml_append($item_xml, 'LineItemID', $item_id);
             $this->xml_append($item_xml, 'SKU', $product->get_sku());
             $this->xml_append($item_xml, 'Name', $product->get_title());
             $this->xml_append($item_xml, 'ImageUrl', $image_url);
             $this->xml_append($item_xml, 'Weight', wc_get_weight($product->get_weight(), 'oz'), false);
             $this->xml_append($item_xml, 'WeightUnits', 'Ounces', false);
             $this->xml_append($item_xml, 'Quantity', $item['qty'], false);
             $this->xml_append($item_xml, 'UnitPrice', $order->get_item_subtotal($item, false, true), false);
             if ($item['item_meta']) {
                 if (version_compare(WC_VERSION, '2.4.0', '<')) {
                     $item_meta = new WC_Order_Item_Meta($item['item_meta']);
                 } else {
                     $item_meta = new WC_Order_Item_Meta($item);
                 }
                 $formatted_meta = $item_meta->get_formatted('_');
                 if (!empty($formatted_meta)) {
                     $options_xml = $xml->createElement("Options");
                     foreach ($formatted_meta as $meta_key => $meta) {
                         $option_xml = $xml->createElement("Option");
                         $this->xml_append($option_xml, 'Name', $meta['label']);
                         $this->xml_append($option_xml, 'Value', $meta['value']);
                         $options_xml->appendChild($option_xml);
                     }
                     $item_xml->appendChild($options_xml);
                 }
             }
             $items_xml->appendChild($item_xml);
         }
         if (!$found_item) {
             continue;
         }
         // Append cart level discount line
         if ($order->get_total_discount()) {
             $item_xml = $xml->createElement("Item");
             $this->xml_append($item_xml, 'SKU', "total-discount");
             $this->xml_append($item_xml, 'Name', __('Total Discount', 'woocommerce-shipstation'));
             $this->xml_append($item_xml, 'Adjustment', "true", false);
             $this->xml_append($item_xml, 'Quantity', 1, false);
             $this->xml_append($item_xml, 'UnitPrice', $order->get_total_discount() * -1, false);
             $items_xml->appendChild($item_xml);
         }
         // Append items XML
         $order_xml->appendChild($items_xml);
         $orders_xml->appendChild($order_xml);
         $exported++;
     }
     $orders_xml->setAttribute("page", $page);
     $orders_xml->setAttribute("pages", ceil($max_results / WC_SHIPSTATION_EXPORT_LIMIT));
     $xml->appendChild($orders_xml);
     echo $xml->saveXML();
     $this->log(sprintf(__("Exported %s orders", 'woocommerce-shipstation'), $exported));
 }
开发者ID:tccyp001,项目名称:onemore-wordpress,代码行数:101,代码来源:class-wc-shipstation-api-export.php

示例10: get_orders_csv_row

 /**
  * Get the order data for a single CSV row
  *
  * Note items are keyed according to the column header keys above so these can be modified using
  * the provider filter without needing to worry about the array order
  *
  * @since 3.0
  * @param int $order_id the WC_Order ID
  * @return array order data in the format key => content
  */
 private function get_orders_csv_row($order_id)
 {
     $order = wc_get_order($order_id);
     $is_json = 'import' == $this->order_format;
     $line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = array();
     // get line items
     foreach ($order->get_items() as $item_id => $item) {
         $product = $order->get_product_from_item($item);
         if (!is_object($product)) {
             $product = new WC_Product(0);
         }
         $item_meta = new WC_Order_Item_Meta($item);
         if ($is_json) {
             $meta = array();
             foreach ($item_meta->get_formatted('_') as $meta_key => $formatted_meta) {
                 $meta[$formatted_meta['key']] = $formatted_meta['value'];
             }
         } else {
             add_filter('woocommerce_attribute_label', array($this, 'escape_reserved_meta_chars'));
             add_filter('woocommerce_order_item_display_meta_value', array($this, 'escape_reserved_meta_chars'));
             $meta = $item_meta->display(true, true);
             remove_filter('woocommerce_attribute_label', array($this, 'escape_reserved_meta_chars'));
             remove_filter('woocommerce_order_item_display_meta_value', array($this, 'escape_reserved_meta_chars'));
             if ($meta) {
                 // replace key-value sperator (': ') with our own - equals sign (=)
                 $meta = str_replace(': ', '=', $meta);
                 // remove any newlines generated by WC_Order_Item_Meta::display()
                 $meta = str_replace(array(", \r\n", ", \r", ", \n"), ',', $meta);
                 // re-insert colons and newlines
                 $meta = str_replace(array('[INSERT_COLON_HERE]', '[INSERT_NEWLINE_HERE]'), array(':', "\n"), $meta);
             }
         }
         $product = $order->get_product_from_item($item);
         $product_id = null;
         $product_sku = null;
         // Check if the product exists.
         if (is_object($product)) {
             $product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
             $product_sku = $product->get_sku();
         }
         if ($is_json) {
             $line_item = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item), 2), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], 2), 'total' => wc_format_decimal($order->get_line_total($item), 2), 'total_tax' => wc_format_decimal($order->get_line_tax($item), 2), 'quantity' => (int) $item['qty'], 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $meta, 'tax_data' => isset($item['line_tax_data']) ? maybe_unserialize($item['line_tax_data']) : '');
         } else {
             $line_item = array('name' => html_entity_decode($item['name'], ENT_NOQUOTES, 'UTF-8'), 'sku' => $product_sku, 'quantity' => (int) $item['qty'], 'total' => wc_format_decimal($order->get_line_total($item), 2), 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2), 'refunded_qty' => $order->get_qty_refunded_for_item($item_id), 'meta' => is_string($meta) ? html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8') : $meta);
             // add line item tax
             $line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : array();
             $tax_data = maybe_unserialize($line_tax_data);
             $line_item['tax'] = isset($tax_data['total']) ? wc_format_decimal(wc_round_tax_total(array_sum((array) $tax_data['total'])), 2) : '';
         }
         /**
          * CSV Order Export Line Item.
          *
          * Filter the individual line item entry for the default export
          *
          * @since 3.0.6
          * @param array $line_item {
          *     line item data in key => value format
          *     the keys are for convenience and not used for exporting. Make
          *     sure to prefix the values with the desired line item entry name
          * }
          *
          * @param array $item WC order item data
          * @param WC_Product $product the product
          * @param WC_Order $order the order
          * @param \WC_Customer_Order_CSV_Export_Generator $this, generator instance
          */
         $line_item = apply_filters('wc_customer_order_csv_export_order_line_item', $line_item, $item, $product, $order, $this);
         if (!in_array($this->order_format, array('default_one_row_per_item', 'import')) && is_array($line_item)) {
             foreach ($line_item as $name => $value) {
                 $name = $this->escape_reserved_item_chars($name);
                 $value = $this->escape_reserved_item_chars($value);
                 $line_item[$name] = $name . ':' . $value;
             }
             $line_item = implode('|', $line_item);
         }
         if ($line_item) {
             $line_items[] = $line_item;
         }
     }
     foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) {
         $shipping_item = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], 2), 'taxes' => isset($shipping_item['taxes']) ? maybe_unserialize($shipping_item['taxes']) : '');
         if ($is_json) {
             $shipping_items[] = $shipping_item;
         } else {
             $shipping_items[] = implode('|', array('method:' . $this->escape_reserved_item_chars($shipping_item['method_title']), 'total:' . $shipping_item['total']));
         }
     }
     // get fee items & total
     $fee_total = 0;
     $fee_tax_total = 0;
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:class-wc-customer-order-csv-export-generator.php

示例11: api_show_shipping_line_meta

 /**
  * Add shipping line meta fields to the shipping line in the order API.
  */
 public static function api_show_shipping_line_meta($order_data, $order, $fields, $server)
 {
     if (!empty($order_data['shipping_lines'])) {
         $shipping_methods = $order->get_shipping_methods();
         //mail('jason@consil.co.uk', 'shipping methods', print_r($shipping_methods, true));
         foreach ($order_data['shipping_lines'] as $key => $shipping_line) {
             $shipping_line_id = $shipping_line['id'];
             $item_meta = array();
             if (isset($shipping_methods[$shipping_line_id])) {
                 $meta = new WC_Order_Item_Meta($shipping_methods[$shipping_line_id]);
                 $hideprefix = null;
                 foreach ($meta->get_formatted($hideprefix) as $meta_key => $formatted_meta) {
                     $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']);
                 }
             }
             $order_data['shipping_lines'][$key]['meta'] = $item_meta;
         }
     }
     return $order_data;
 }
开发者ID:quasel,项目名称:wc-multiple-packages,代码行数:23,代码来源:Academe_Multiple_Packages.php

示例12: date

 function __construct($plugin, $order, $cart = null)
 {
     global $woocommerce;
     $secretKey = $plugin->maksuturva_secretkey;
     $sellerId = $plugin->maksuturva_sellerid;
     $dueDate = date("d.m.Y");
     $id = $plugin->maksuturva_orderid_prefix . self::getMaksuturvaId($order->id);
     $pid = self::getMaksuturvaId($order->id);
     $products_rows = array();
     $discount_total = 0;
     $product_total = 0;
     $shipping_total = 0;
     foreach ($order->get_items() as $order_item_id => $item) {
         $product = $order->get_product_from_item($item);
         $desc = '';
         //$product->post->post_excerpt; // $product->get_title();
         if (defined('WOOCOMMERCE_VERSION') && version_compare(WOOCOMMERCE_VERSION, '2.4', '>')) {
             $woi = new WC_Order_Item_Meta($item);
         } else {
             $woi = new WC_Order_Item_Meta($order->get_item_meta($order_item_id, ''));
         }
         $gf = $woi->get_formatted();
         if ($gf) {
             foreach ($gf as $attr) {
                 $desc .= implode('=', $attr) . '|';
             }
         }
         $item_price_with_tax = $order->get_item_subtotal($item, true);
         $item_totalprice_with_tax = $order->get_item_total($item, true);
         $discount_pct = ($item_price_with_tax - $item_totalprice_with_tax) / $item_price_with_tax * 100.0;
         //( $line_price_with_tax - $line_totalprice_with_tax); //)) / $line_price_with_tax*100;
         if ($product->product_type == 'variable') {
             $desc .= implode(',', $product->get_variation_attributes()) . ' ';
         }
         $desc .= $product->post->post_excerpt;
         //apply_filters( 'woocommerce_short_description', $product->post->post_excerpt));
         //$product_total = $product_total + $item_totalprice_with_tax;
         //$discount_total = $discount_total - $line_price_with_tax - $item_totalprice_with_tax;
         $encoding = get_bloginfo('charset');
         //if($plugin->debug) {
         //	$plugin->log->add($plugin->id, $encoding.' Item total price='.$item_totalprice_with_tax." subtotal=".$item_price_with_tax." discount-%=".$discount_pct.":".$desc);
         //}
         $sku = '-';
         if ($product->get_sku()) {
             $sku = $product->get_sku();
         }
         $row = array('pmt_row_name' => $item['name'], 'pmt_row_desc' => strip_tags(html_entity_decode($desc)), 'pmt_row_quantity' => $item['qty'], 'pmt_row_articlenr' => $sku, 'pmt_row_deliverydate' => date("d.m.Y"), 'pmt_row_price_gross' => str_replace('.', ',', sprintf("%.2f", $order->get_item_subtotal($item, true))), 'pmt_row_vat' => str_replace('.', ',', sprintf("%.2f", $this->calc_tax_rate($product))), 'pmt_row_discountpercentage' => str_replace('.', ',', sprintf("%.2f", $discount_pct)), 'pmt_row_type' => 1);
         array_push($products_rows, $row);
     }
     //Coupons
     if ($cart) {
         foreach ($cart->get_coupons() as $code => $coupon) {
             $coupon_desc = $code;
             $coupon = new WC_Coupon($code);
             if ($coupon->apply_before_tax()) {
                 continue;
             }
             $coupon_post = get_post($coupon->id);
             $excerpt = $coupon_post->post_excerpt;
             if ($excerpt) {
                 $coupon_desc .= ' ' . $excerpt;
             }
             $row = array('pmt_row_name' => __('Discount', $plugin->td), 'pmt_row_desc' => strip_tags(html_entity_decode($coupon_desc)), 'pmt_row_quantity' => 1, 'pmt_row_deliverydate' => date("d.m.Y"), 'pmt_row_price_gross' => str_replace('.', ',', sprintf("-%.2f", $cart->get_coupon_discount_amount($code))), 'pmt_row_vat' => "0,00", 'pmt_row_discountpercentage' => "00,00", 'pmt_row_type' => 6);
             array_push($products_rows, $row);
         }
     } elseif ($order->get_total_discount()) {
         $discount = $order->get_total_discount();
         $coupon_desc = implode(',', $order->get_used_coupons());
         $row = array('pmt_row_name' => __('Discount', $plugin->td), 'pmt_row_desc' => strip_tags(html_entity_decode($coupon_desc)), 'pmt_row_quantity' => 1, 'pmt_row_deliverydate' => date("d.m.Y"), 'pmt_row_price_gross' => str_replace('.', ',', sprintf("-%.2f", $discount)), 'pmt_row_vat' => "0,00", 'pmt_row_discountpercentage' => "00,00", 'pmt_row_type' => 6);
         array_push($products_rows, $row);
     }
     //Shipping costs
     $shipping_cost = $order->get_total_shipping() + $order->get_shipping_tax();
     //- $order->get_shipping_tax( );
     if ($order->get_total_shipping() > 0) {
         $shipping_tax = 100 * $order->get_shipping_tax() / $order->get_total_shipping();
     } else {
         $shipping_tax = 0;
     }
     $row = array('pmt_row_name' => __('Shipping cost', $plugin->td), 'pmt_row_desc' => strip_tags(html_entity_decode($order->get_shipping_method())), 'pmt_row_quantity' => 1, 'pmt_row_deliverydate' => date("d.m.Y"), 'pmt_row_price_gross' => str_replace('.', ',', sprintf("%.2f", $shipping_cost)), 'pmt_row_vat' => str_replace('.', ',', sprintf("%.2f", $shipping_tax)), 'pmt_row_discountpercentage' => "0,00", 'pmt_row_type' => 2);
     array_push($products_rows, $row);
     $returnURL = $plugin->notify_url;
     if ($woocommerce->session && $woocommerce->session->id) {
         $sessionid = $woocommerce->session->id;
         $returnURL = add_query_arg('sessionid', $sessionid, $plugin->notify_url);
         //get_return_url( $order ));
         $returnURL = add_query_arg('orderid', $id, $returnURL);
     }
     //$returnURL = add_query_arg('gateway', 'wc_maksurva_emaksut', $returnURL);
     $billing_email = $order->billing_email;
     $billing_phone = $order->billing_phone;
     if (!empty($order->customer_user)) {
         $user = get_user_by('id', $order->customer_user);
         if (empty($order->billing_email)) {
             $billing_email = $user->user_email;
         }
         if (empty($order->billing_email)) {
             $billing_email = $user->user_phone;
         }
     }
//.........这里部分代码省略.........
开发者ID:jyrkih,项目名称:woocommerce_payment_module,代码行数:101,代码来源:MaksuturvaGatewayWCImpl.php


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