WordPress at Your Fingertips
function is not described

WC_Abstract_Legacy_Order::add_fee() public WC 1.0

Add a fee to the order. Order must be saved prior to adding items.

Fee is an amount of money charged for a particular piece of work or for a particular right or service, and not supposed to be negative.

{} It's a method of the class: WC_Abstract_Legacy_Order{}

No Hooks.

Return

Int. Updated order item ID.

Usage

$WC_Abstract_Legacy_Order = new WC_Abstract_Legacy_Order();
$WC_Abstract_Legacy_Order->add_fee( $fee );
$fee(object) (required)
Fee data.

Code of WC_Abstract_Legacy_Order::add_fee() WC 5.5.2

<?php
public function add_fee( $fee ) {
	wc_deprecated_function( 'WC_Order::add_fee', '3.0', 'a new WC_Order_Item_Fee object and add to order with WC_Order::add_item()' );

	$item = new WC_Order_Item_Fee();
	$item->set_props( array(
		'name'      => $fee->name,
		'tax_class' => $fee->taxable ? $fee->tax_class : 0,
		'total'     => $fee->amount,
		'total_tax' => $fee->tax,
		'taxes'     => array(
			'total' => $fee->tax_data,
		),
		'order_id'  => $this->get_id(),
	) );
	$item->save();
	$this->add_item( $item );
	wc_do_deprecated_action( 'woocommerce_order_add_fee', array( $this->get_id(), $item->get_id(), $fee ), '3.0', 'woocommerce_new_order_item action instead.' );
	return $item->get_id();
}