WC_Cart::add_fee() – Add additional fee to the cart.

You appear to be a bot. Output may be restricted

Description

Add additional fee to the cart.

This method should be called on a callback attached to the woocommerce_cart_calculate_fees action during cart/checkout. Fees do not persist.

Usage

WC_Cart::add_fee( $name, $amount, $taxable, $tax_class );

Parameters

$name
( string ) required – Unique name for the fee. Multiple fees of the same name cannot be added.
$amount
( float ) required – Fee amount (do not enter negative amounts).
$taxable
( bool ) optional – Is the fee taxable? (default: false).
$tax_class
( string ) optional – The tax class for the fee if taxable. A blank string is standard tax class. (default: '').

Returns

void

Source

File name: woocommerce/includes/class-wc-cart.php
Lines:

1 to 10 of 10
  public function add_fee( $name, $amount, $taxable = false, $tax_class = '' ) {
    $this->fees_api()->add_fee(
      array(
        'name'      => $name,
        'amount'    => (float) $amount,
        'taxable'   => $taxable,
        'tax_class' => $tax_class,
      )
    );
  }
 

 View on GitHub View on Trac