get_total_refunded() публичный Метод

Get amount already refunded.
С версии: 2.2
public get_total_refunded ( ) : string
Результат string
 /**
  * Get the total amount with or without refunds
  * @return string
  */
 public function get_total()
 {
     $total = '';
     if ($this->order->get_total_refunded() > 0) {
         $total_after_refund = $this->order->get_total() - $this->order->get_total_refunded();
         $total = '<del class="total-without-refund">' . strip_tags($this->order->get_formatted_order_total()) . '</del> <ins>' . wc_price($total_after_refund, array('currency' => $this->order->get_order_currency())) . '</ins>';
     } else {
         $total = $this->order->get_formatted_order_total();
     }
     return $total;
 }
Пример #2
0
 /**
  * Test: get_total_refunded
  */
 function test_get_total_refunded()
 {
     $object = new WC_Order();
     $object->set_total(400);
     $id = $object->save();
     wc_create_refund(array('order_id' => $id, 'amount' => '100', 'line_items' => array()));
     wc_create_refund(array('order_id' => $id, 'amount' => '100', 'line_items' => array()));
     $this->assertEquals(200, $object->get_total_refunded());
 }
Пример #3
0
/**
 * Insert a order in sync table once a order is created
 *
 * @global object $wpdb
 * @param int $order_id
 * @since 2.4
 */
function dokan_sync_order_table($order_id)
{
    global $wpdb;
    $order = new WC_Order($order_id);
    $seller_id = dokan_get_seller_id_by_order($order_id);
    $percentage = dokan_get_seller_percentage($seller_id);
    //Total calculation
    $order_total = $order->get_total();
    if ($total_refunded = $order->get_total_refunded()) {
        $order_total = $order_total - $total_refunded;
    }
    //Shipping calculation
    $order_shipping = $order->get_total_shipping();
    foreach ($order->get_items() as $item) {
        $total_shipping_refunded = 0;
        if ($shipping_refunded = $order->get_total_refunded_for_item($item['product_id'], 'shipping')) {
            $total_shipping_refunded += $shipping_refunded;
        }
    }
    $order_shipping = $order_shipping - $total_shipping_refunded;
    //Tax calculation
    $order_tax = $order->get_total_tax();
    if ($tax_refunded = $order->get_total_tax_refunded()) {
        $order_tax = $order_tax - $tax_refunded;
    }
    $extra_cost = $order_shipping + $order_tax;
    $order_cost = $order_total - $extra_cost;
    $order_status = $order->post_status;
    $net_amount = $order_cost * $percentage / 100 + $extra_cost;
    $net_amount = apply_filters('dokan_sync_order_net_amount', $net_amount, $order);
    $wpdb->insert($wpdb->prefix . 'dokan_orders', array('order_id' => $order_id, 'seller_id' => $seller_id, 'order_total' => $order_total, 'net_amount' => $net_amount, 'order_status' => $order_status), array('%d', '%d', '%f', '%f', '%s'));
}