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


PHP WC_Order::get_refunds方法代码示例

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


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

示例1: pro_email_order_actions

 /**
  * Add credit note email to order actions list
  */
 public function pro_email_order_actions($available_emails)
 {
     global $post_id;
     $order_notification_settings = get_option('woocommerce_pdf_order_notification_settings');
     if (isset($order_notification_settings['recipient']) && !empty($order_notification_settings['recipient'])) {
         // only add order notification action when a recipient is set!
         $available_emails[] = 'pdf_order_notification';
     }
     if (version_compare(WOOCOMMERCE_VERSION, '2.2', '>=')) {
         $order = new WC_Order($post_id);
         $refunds = $order->get_refunds();
         if (!empty($refunds)) {
             $available_emails[] = 'customer_credit_note';
         }
     }
     return $available_emails;
 }
开发者ID:baden03,项目名称:access48,代码行数:20,代码来源:wcpdf-pro-writepanels.php

示例2: get_import_columns

 /**
  * Get the order data format for CSV Import JSON format
  *
  * @since 3.12.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_import_columns($order_data, WC_Order $order)
 {
     if (isset($order_data['refunded_total']) && $order_data['refunded_total']) {
         $refunds = array();
         foreach ($order->get_refunds() as $refund) {
             $line_items = array();
             // add line items
             foreach ($refund->get_items(array('line_item', 'fee', 'shipping')) as $item_id => $item) {
                 $refund_amount = abs(isset($item['line_total']) ? $item['line_total'] : (isset($item['cost']) ? $item['cost'] : null));
                 // skip empty refund lines
                 if (!$refund_amount) {
                     continue;
                 }
                 $refunded_item = array('refunded_item_id' => $item['refunded_item_id'], 'refund_total' => $refund_amount);
                 if (isset($item['taxes'])) {
                     $refunded_item['refund_tax'] = maybe_unserialize($item['taxes']);
                 }
                 if (isset($item['line_tax_data'])) {
                     $tax_data = maybe_unserialize($item['line_tax_data']);
                     $refunded_item['refund_tax'] = $tax_data['total'];
                 }
                 if (isset($item['qty'])) {
                     $refunded_item['qty'] = $item['qty'];
                 }
                 $line_items[] = $refunded_item;
             }
             $refund_data = array('id' => $refund->id, 'date' => $refund->date, 'amount' => wc_format_decimal($refund->get_refund_amount(), 2), 'reason' => $refund->get_refund_reason(), 'line_items' => $line_items);
             $refunds[] = $refund_data;
         }
         $order_data['refunds'] = !empty($refunds) ? json_encode($refunds) : '';
     }
     // 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,代码行数:48,代码来源:class-wc-customer-order-csv-export-compatibility.php

示例3: recalculate_order


//.........这里部分代码省略.........
     $_order_shipping = get_post_meta($order_id, '_order_shipping', true);
     update_post_meta($order_id, '_order_shipping', $this->back_convert($_order_shipping, $_woocs_order_rate));
     $_order_total = get_post_meta($order_id, '_order_total', true);
     update_post_meta($order_id, '_order_total', $this->back_convert($_order_total, $_woocs_order_rate));
     $_refund_amount = get_post_meta($order_id, '_refund_amount', true);
     update_post_meta($order_id, '_refund_amount', $this->back_convert($_refund_amount, $_woocs_order_rate));
     $_cart_discount_tax = get_post_meta($order_id, '_cart_discount_tax', true);
     update_post_meta($order_id, '_cart_discount_tax', $this->back_convert($_cart_discount_tax, $_woocs_order_rate));
     $_order_tax = get_post_meta($order_id, '_order_tax', true);
     update_post_meta($order_id, '_order_tax', $this->back_convert($_order_tax, $_woocs_order_rate));
     $_order_shipping_tax = get_post_meta($order_id, '_order_shipping_tax', true);
     update_post_meta($order_id, '_order_shipping_tax', $this->back_convert($_order_shipping_tax, $_woocs_order_rate));
     $_cart_discount = get_post_meta($order_id, '_cart_discount', true);
     update_post_meta($order_id, '_cart_discount', $this->back_convert($_cart_discount, $_woocs_order_rate));
     //***
     global $wpdb;
     $get_items_sql = $wpdb->prepare("SELECT order_item_id,order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d ", $order_id);
     $line_items = $wpdb->get_results($get_items_sql, ARRAY_N);
     if (!empty($line_items) and is_array($line_items)) {
         foreach ($line_items as $v) {
             $order_item_id = $v[0];
             $order_item_type = $v[1];
             switch ($order_item_type) {
                 case 'line_item':
                     $amount = wc_get_order_item_meta($order_item_id, '_line_subtotal', true);
                     wc_update_order_item_meta($order_item_id, '_line_subtotal', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_total', true);
                     wc_update_order_item_meta($order_item_id, '_line_total', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_subtotal_tax', true);
                     wc_update_order_item_meta($order_item_id, '_line_subtotal_tax', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $amount = wc_get_order_item_meta($order_item_id, '_line_tax', true);
                     wc_update_order_item_meta($order_item_id, '_line_tax', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $_line_tax_data = wc_get_order_item_meta($order_item_id, '_line_tax_data', true);
                     if (!empty($_line_tax_data) and is_array($_line_tax_data)) {
                         foreach ($_line_tax_data as $key => $values) {
                             if (!empty($values)) {
                                 if (is_array($values)) {
                                     foreach ($values as $k => $value) {
                                         if (is_numeric($value)) {
                                             $_line_tax_data[$key][$k] = $this->back_convert($value, $_woocs_order_rate, 2);
                                         }
                                     }
                                 } else {
                                     if (is_numeric($values)) {
                                         $_line_tax_data[$key] = $this->back_convert($values, $_woocs_order_rate, 2);
                                     }
                                 }
                             }
                         }
                     }
                     wc_update_order_item_meta($order_item_id, '_line_tax_data', $_line_tax_data);
                     break;
                 case 'shipping':
                     $amount = wc_get_order_item_meta($order_item_id, 'cost', true);
                     wc_update_order_item_meta($order_item_id, 'cost', $this->back_convert($amount, $_woocs_order_rate, 2));
                     $taxes = wc_get_order_item_meta($order_item_id, 'taxes', true);
                     if (!empty($taxes) and is_array($taxes)) {
                         foreach ($taxes as $key => $values) {
                             if (!empty($values)) {
                                 if (is_array($values)) {
                                     foreach ($values as $k => $value) {
                                         if (is_numeric($value)) {
                                             $taxes[$key][$k] = $this->back_convert($value, $_woocs_order_rate, 2);
                                         }
                                     }
                                 } else {
                                     if (is_numeric($values)) {
                                         $taxes[$key] = $this->back_convert($values, $_woocs_order_rate, 2);
                                     }
                                 }
                             }
                         }
                     }
                     wc_update_order_item_meta($order_item_id, 'taxes', $taxes);
                     break;
                 case 'tax':
                     $amount = wc_get_order_item_meta($order_item_id, 'tax_amount', true);
                     wc_update_order_item_meta($order_item_id, 'tax_amount', $this->back_convert($amount, $_woocs_order_rate, 3));
                     $amount = wc_get_order_item_meta($order_item_id, 'shipping_tax_amount', true);
                     wc_update_order_item_meta($order_item_id, 'shipping_tax_amount', $this->back_convert($amount, $_woocs_order_rate, 2));
                     break;
                 default:
                     break;
             }
         }
     }
     //***
     $order = new WC_Order($order_id);
     $refunds = $order->get_refunds();
     if (!empty($refunds)) {
         foreach ($refunds as $refund) {
             $post_id = $refund->id;
             $amount = get_post_meta($post_id, '_refund_amount', true);
             update_post_meta($post_id, '_refund_amount', $this->back_convert($amount, $_woocs_order_rate, 2));
             $amount = get_post_meta($post_id, '_order_total', true);
             update_post_meta($post_id, '_order_total', $this->back_convert($amount, $_woocs_order_rate, 2));
             update_post_meta($post_id, '_order_currency', $this->default_currency);
         }
     }
 }
开发者ID:benkhlifafahmi,项目名称:woocomerce-currency-switcher-fix,代码行数:101,代码来源:index.php

示例4: array

 /**
  * Test: get_refunds
  */
 function test_get_refunds()
 {
     $object = new WC_Order();
     $id = $object->save();
     $this->assertCount(0, $object->get_refunds());
     wc_create_refund(array('order_id' => $id, 'amount' => '100', 'line_items' => array()));
     $this->assertCount(1, $object->get_refunds());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:11,代码来源:crud.php

示例5: refunds_order_ids

 public function refunds_order_ids($order_ids, $template_type)
 {
     if ($template_type == 'credit-note') {
         $refunds_order_ids = array();
         foreach ($order_ids as $order_id) {
             $order = new WC_Order($order_id);
             $refunds = $order->get_refunds();
             foreach ($refunds as $key => $refund) {
                 $refunds_order_ids[] = $refund->id;
             }
         }
         // die(print_r($refunds_order_ids,true));
         return $refunds_order_ids;
     } else {
         return $order_ids;
     }
 }
开发者ID:baden03,项目名称:access48,代码行数:17,代码来源:wcpdf-pro-functions.php


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