• Resolved knms5525

    (@knms5525)


    I need to know if there is a way to programatically check if a specific Tax Item / Name is being applied on the checkout page and apply a custom fee if so. Example IF GST or IF DUTY . I know how to apply a custom fee but I can not find away to see if a tax exists on the checkout page or not. Is there a woocommerce function that returns an array of the tax items in place on the checkout page?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter knms5525

    (@knms5525)

    Thanks to some help from a member of the Woocommerce Community Slack group this helped me identify Tax Items by Label.

    // Get all applied tax items
    // $cart is passed via my function for the woocommerce_cart_calculate_fees add_action
    $bs_tax_totals = $cart->get_tax_totals();
    $bs_duty_exists = false;
    // Check each tax item
    foreach ( $bs_tax_totals as $bs_tax ) {
    // Compare tax label (case-sensitive exact match)
    if ( ‘Duty’ === $bs_tax->label ) {
    $bs_duty_exists = true;
    break;
    }
    }

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @knms5525,

    I’m glad you found help through the community Slack channel! If you need any further assistance with other WooCommerce-related issues, feel free to create a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.