WordPress at Your Fingertips
function is not described

WC_Checkout::create_order_fee_lines() public WC 1.0

Add fees to the order.

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

Return

null. Nothing.

Usage

$WC_Checkout = new WC_Checkout();
$WC_Checkout->create_order_fee_lines( $order, $cart );
$order(WC_Order) (required) (passed by reference — &)
Order instance.
$cart(WC_Cart) (required)
Cart instance.

Code of WC_Checkout::create_order_fee_lines() WC 5.9.0

public function create_order_fee_lines( &$order, $cart ) {
	foreach ( $cart->get_fees() as $fee_key => $fee ) {
		$item                 = new WC_Order_Item_Fee();
		$item->legacy_fee     = $fee; // @deprecated 4.4.0 For legacy actions.
		$item->legacy_fee_key = $fee_key; // @deprecated 4.4.0 For legacy actions.
		$item->set_props(
			array(
				'name'      => $fee->name,
				'tax_class' => $fee->taxable ? $fee->tax_class : 0,
				'amount'    => $fee->amount,
				'total'     => $fee->total,
				'total_tax' => $fee->tax,
				'taxes'     => array(
					'total' => $fee->tax_data,
				),
			)
		);

		/**
		 * Action hook to adjust item before save.
		 *
		 * @since 3.0.0
		 */
		do_action( 'woocommerce_checkout_create_order_fee_item', $item, $fee_key, $fee, $order );

		// Add item to order and save.
		$order->add_item( $item );
	}
}