set_total() public method

Set total.
public set_total ( string $value )
$value string
 /**
  * Create or update an order fee
  *
  * @since 2.2
  * @param \WC_Order $order
  * @param array $fee item data
  * @param string $action 'create' to add fee or 'update' to update it
  * @throws WC_API_Exception invalid data, server error
  */
 protected function set_fee($order, $fee, $action)
 {
     if ('create' === $action) {
         // fee title is required
         if (!isset($fee['title'])) {
             throw new WC_API_Exception('woocommerce_invalid_fee_item', __('Fee title is required', 'woocommerce'), 400);
         }
         $item = new WC_Order_Item_Fee();
         $item->set_name(sanitize_title($fee['title']));
         $item->set_total(isset($fee['total']) ? floatval($fee['total']) : 0);
         // if taxable, tax class and total are required
         if (!empty($fee['taxable'])) {
             if (!isset($fee['tax_class'])) {
                 throw new WC_API_Exception('woocommerce_invalid_fee_item', __('Fee tax class is required when fee is taxable', 'woocommerce'), 400);
             }
             $item->set_tax_status('taxable');
             $item->set_tax_class($fee['tax_class']);
             if (isset($fee['total_tax'])) {
                 $item->set_total_tax(isset($fee['total_tax']) ? wc_format_refund_total($fee['total_tax']) : 0);
             }
             if (isset($fee['tax_data'])) {
                 $item->set_total_tax(wc_format_refund_total(array_sum($fee['tax_data'])));
                 $item->set_taxes(array_map('wc_format_refund_total', $fee['tax_data']));
             }
         }
         $fee_id = $item->save();
         if (!$fee_id) {
             throw new WC_API_Exception('woocommerce_cannot_create_fee', __('Cannot create fee, try again', 'woocommerce'), 500);
         }
     } else {
         $item = new WC_Order_Item_Fee($fee['id']);
         if (isset($fee['title'])) {
             $item->set_name(sanitize_title($fee['title']));
         }
         if (isset($fee['tax_class'])) {
             $item->set_tax_class($fee['tax_class']);
         }
         if (isset($fee['total'])) {
             $item->set_total(floatval($fee['total']));
         }
         if (isset($fee['total_tax'])) {
             $item->set_total_tax(floatval($fee['total_tax']));
         }
         $fee_id = $item->save();
         if (!$fee_id) {
             throw new WC_API_Exception('woocommerce_cannot_update_fee', __('Cannot update fee, try again', 'woocommerce'), 500);
         }
     }
 }