Totals footer item
The following Totals Footer Item filter are available:
totalLabeltotalValue
totalLabel
The following object is used in the filter:
Description
The totalLabel filter allows to change the label of the total item in the footer of the Cart and Checkout blocks.
Parameters
- defaultValue
string(default:Total) - The total label. - extensions
object(default:{}) - The extensions object. - args
object- The arguments object with the following keys:- cart
object- The cart object fromwc/store/cart, see Cart object.
- cart
Returns
string- The updated total label.
Code example
const { registerCheckoutFilters } = window.wc.blocksCheckout;
const modifyTotalLabel = ( defaultValue, extensions, args ) => {
return 'Deposit due today';
};
registerCheckoutFilters( 'example-extension', {
totalLabel: modifyTotalLabel,
} );
Filters can be also combined. See Combined filters for an example.
Screenshots
| Before | After |
|---|---|
totalValue
The following object is used in the filter:
Description
The totalValue filter allows to format the total price in the footer of the Cart and Checkout blocks.
Parameters
- defaultValue
string(default:Total) - The total label. - extensions
object(default:{}) - The extensions object. - args
object- The arguments object with the following keys:- cart
object- The cart object fromwc/store/cart, see Cart object.
- cart
- validation
boolean- Checks if the return value contains the substring<price/>.
Returns
string- The modified format of the total price, which must contain the substring<price/>, or the original price format.
Code example
const { registerCheckoutFilters } = window.wc.blocksCheckout;
const modifyTotalsPrice = ( defaultValue, extensions, args, validation ) => {
return 'Pay <price/> now';
};
registerCheckoutFilters( 'my-extension', {
totalValue: modifyTotalsPrice,
} );
Filters can be also combined. See Combined filters for an example.
Screenshots
| Before | After |
|---|---|
Cart object
The Cart object of the filters above has the following keys:
- billingAddress
object- The billing address object with the following keys:- address_1
string- The first line of the address. - address_2
string- The second line of the address. - city
string- The city of the address. - company
string- The company of the address. - country
string- The country of the address. - email
string- The email of the address. - first_name
string- The first name of the address. - last_name
string- The last name of the address. - phone
string- The phone of the address. - postcode
string- The postcode of the address. - state
string- The state of the address.
- address_1
billingDataobject- The billing data object with the same keys as thebillingAddressobject.- cartCoupons
array- The cart coupons array. - cartErrors
array- The cart errors array. - cartFees
array- The cart fees array. - cartHasCalculatedShipping
boolean- Whether the cart has calculated shipping. - cartIsLoading
boolean- Whether the cart is loading. - cartItemErrors
array- The cart item errors array. - cartItems
array- The cart items array with cart item objects, see Cart Item object. - cartItemsCount
number- The cart items count. - cartItemsWeight
number- The cart items weight. - cartNeedsPayment
boolean- Whether the cart needs payment. - cartNeedsShipping
boolean- Whether the cart needs shipping. - cartTotals
object- The cart totals object with the following keys:- currency_code
string- The currency code. - currency_decimal_separator
string- The currency decimal separator. - currency_minor_unit
number- The currency minor unit. - currency_prefix
string- The currency prefix. - currency_suffix
string- The currency suffix. - currency_symbol
string- The currency symbol. - currency_thousand_separator
string- The currency thousand separator. - tax_lines
array- The tax lines array with tax line objects with the following keys:- name
string- The name of the tax line. - price
number- The price of the tax line. - rate
string- The rate ID of the tax line.
- name
- total_discount
string- The total discount. - total_discount_tax
string- The total discount tax. - total_fees
string- The total fees. - total_fees_tax
string- The total fees tax. - total_items
string- The total items. - total_items_tax
string- The total items tax. - total_price
string- The total price. - total_shipping
string- The total shipping. - total_shipping_tax
string- The total shipping tax. - total_tax
string- The total tax.
- currency_code
- crossSellsProducts
array- The cross sells products array with cross sells product objects. - extensions
object(default:{}) - The extensions object. - isLoadingRates
boolean- Whether the cart is loading shipping rates. - paymentRequirements
array- The payment requirements array. - shippingAddress
object- The shipping address object with the same keys as thebillingAddressobject. - shippingRates
array- The shipping rates array.
Cart Item object
The Cart Item object of the filters above has the following keys:
- backorders_allowed
boolean- Whether backorders are allowed. - catalog_visibility
string- The catalog visibility. - decsription
string- The cart item description. - extensions
object(default:{}) - The extensions object. - id
number- The item ID. - images
array- The item images array. - item_data
array- The item data array. - key
string- The item key. - low_stock_remaining
number- The low stock remaining. - name
string- The item name. - permalink
string- The item permalink. - prices
object- The item prices object with the following keys:- currency_code
string- The currency code. - currency_decimal_separator
string- The currency decimal separator. - currency_minor_unit
number- The currency minor unit. - currency_prefix
string- The currency prefix. - currency_suffix
string- The currency suffix. - currency_symbol
string- The currency symbol. - currency_thousand_separator
string- The currency thousand separator. - price
string- The price. - price_range
string- The price range. - raw_prices
object- The raw prices object with the following keys:- precision
number- The precision. - price
number- The price. - regular_price
number- The regular price. - sale_price
number- The sale price.
- precision
- regular_price
string- The regular price. - sale_price
string- The sale price.
- currency_code
- quantity
number- The item quantity. - quantity_limits
object- The item quantity limits object with the following keys:- editable
boolean- Whether the quantity is editable. - maximum
number- The maximum quantity. - minimum
number- The minimum quantity. - multiple_of
number- The multiple of quantity.
- editable
- short_description
string- The item short description. - show_backorder_badge
boolean- Whether to show the backorder badge. - sku
string- The item SKU. - sold_individually
boolean- Whether the item is sold individually. - totals
object- The item totals object with the following keys:- currency_code
string- The currency code. - currency_decimal_separator
string- The currency decimal separator. - currency_minor_unit
number- The currency minor unit. - currency_prefix
string- The currency prefix. - currency_suffix
string- The currency suffix. - currency_symbol
string- The currency symbol. - currency_thousand_separator
string- The currency thousand separator. - line_subtotal
string- The line subtotal. - line_subtotal_tax
string- The line subtotal tax. - line_total
string- The line total. - line_total_tax
string- The line total tax.
- currency_code
- type
string- The item type. - variation
array- The item variation array.