• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WooCommerce a2z

WooCommerce a2z

WooCommerce

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WC_Order_Item_Fee::get_tax_class_costs() – Get item costs grouped by tax class.

You appear to be a bot. Output may be restricted

Description

Get item costs grouped by tax class.

Usage

$array = WC_Order_Item_Fee::get_tax_class_costs( $order );

Parameters

$order
( WC_Order ) required – Order object.

Returns

array

Source

File name: woocommerce/includes/class-wc-order-item-fee.php
Lines:

1 to 21 of 21
  protected function get_tax_class_costs( $order ) {
    $order_item_tax_classes = $order->get_items_tax_classes();
    $costs                  = array_fill_keys( $order_item_tax_classes, 0 );
    $costs['non-taxable']   = 0;

    foreach ( $order->get_items( array( 'line_item', 'fee', 'shipping' ) ) as $item ) {
      if ( 0 > $item->get_total() ) {
        continue;
      }
      if ( 'taxable' !== $item->get_tax_status() ) {
        $costs['non-taxable'] += $item->get_total();
      } elseif ( 'inherit' === $item->get_tax_class() ) {
        $inherit_class            = reset( $order_item_tax_classes );
        $costs[ $inherit_class ] += $item->get_total();
      } else {
        $costs[ $item->get_tax_class() ] += $item->get_total();
      }
    }

    return array_filter( $costs );
  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: WC_Order_Item_Fee::get_tax_class_costs
Class ref: WC_Order_Item_Fee
Plugin ref: WooCommerce
Version: 4.8.0
Sourcefile: includes/class-wc-order-item-fee.php
File ref: includes/class-wc-order-item-fee.php
Deprecated?: No
API Letters: F,G,I,O,W

Footer

WooCommerce a2z
WooCommerce a2z
WooCommerce
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites