woocommerce_adjust_non_base_location_prices

woocommerce_adjust_non_base_location_prices

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

apply_filters('woocommerce_adjust_non_base_location_prices') is found 8 times:

  • /includes/class-wc-cart-totals.php line 428
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    * @return object
     */
    protected function remove_item_base_taxes( $item ) {
        if ( $item->price_includes_tax && $item->taxable ) {
            if ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
                $base_tax_rates = WC_Tax::get_base_tax_rates( $item->product->get_tax_class( 'unfiltered' ) );
            } else {
                /**
                 * If we want all customers to pay the same price on this store, we should not remove base taxes from a VAT exempt user's price,
                 * but just the relevant tax rate. See issue #20911.
                 */
  • /includes/class-wc-cart-totals.php line 723
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    */
    protected function calculate_item_subtotals() {
        $merged_subtotal_taxes = array(); // Taxes indexed by tax rate ID for storage later.
     
        $adjust_non_base_location_prices = apply_filters( 'woocommerce_adjust_non_base_location_prices', true );
        $is_customer_vat_exempt          = $this->cart->get_customer()->get_is_vat_exempt();
     
        foreach ( $this->items as $item_key => $item ) {
            if ( $item->price_includes_tax ) {
                if ( $is_customer_vat_exempt ) {
                    $item = $this->remove_item_base_taxes( $item );
  • /includes/wc-product-functions.php line 1221
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    * If the customer is exempt from VAT, remove the taxes here.
     * Either remove the base or the user taxes depending on woocommerce_adjust_non_base_location_prices setting.
     */
    if ( ! empty( WC()->customer ) && WC()->customer->get_is_vat_exempt() ) { // @codingStandardsIgnoreLine.
        $remove_taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $line_price, $base_tax_rates, true ) : WC_Tax::calc_tax( $line_price, $tax_rates, true );
     
        if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
            $remove_taxes_total = array_sum( $remove_taxes );
        } else {
            $remove_taxes_total = array_sum( array_map( 'wc_round_tax_total', $remove_taxes ) );
        }
  • /includes/wc-product-functions.php line 1236
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    * The woocommerce_adjust_non_base_location_prices filter can stop base taxes being taken off when dealing with out of base locations.
     * e.g. If a product costs 10 including tax, all users will pay 10 regardless of location and taxes.
     * This feature is experimental @since 2.4.7 and may change in the future. Use at your risk.
     */
    } elseif ( $tax_rates !== $base_tax_rates && apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
        $base_taxes   = WC_Tax::calc_tax( $line_price, $base_tax_rates, true );
        $modded_taxes = WC_Tax::calc_tax( $line_price - array_sum( $base_taxes ), $tax_rates, false );
     
        if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
            $base_taxes_total   = array_sum( $base_taxes );
            $modded_taxes_total = array_sum( $modded_taxes );
  • /includes/wc-product-functions.php line 1288
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    if ( $product->is_taxable() && wc_prices_include_tax() ) {
        $order       = ArrayUtil::get_value_or_default( $args, 'order' );
        $customer_id = $order ? $order->get_customer_id() : 0;
        if ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
            $tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
        } else {
            $customer  = $customer_id ? wc_get_container()->get( LegacyProxy::class )->get_instance_of( WC_Customer::class, $customer_id ) : null;
            $tax_rates = WC_Tax::get_rates( $product->get_tax_class(), $customer );
        }
        $remove_taxes = WC_Tax::calc_tax( $line_price, $tax_rates, true );
  • /src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php line 934
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
         *
         * @param boolean $adjust_non_base_location_prices True by default.
         * @return boolean
         */
        $taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $price_filter, $base_tax_rates, true ) : WC_Tax::calc_tax( $price_filter, $tax_rates, true );
        return $price_filter - array_sum( $taxes );
    }
     
    // If prices are shown excl. tax, add taxes to match the prices stored in the DB.
    $taxes = WC_Tax::calc_tax( $price_filter, $tax_rates, false );
  • /src/Blocks/QueryFilters.php line 383
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
         *
         * @param boolean $adjust_non_base_location_prices True by default.
         * @return boolean
         */
        $taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $price_filter, $base_tax_rates, true ) : WC_Tax::calc_tax( $price_filter, $tax_rates, true );
        return $price_filter - array_sum( $taxes );
    }
     
    // If prices are shown excl. tax, add taxes to match the prices stored in the DB.
    $taxes = WC_Tax::calc_tax( $price_filter, $tax_rates, false );
  • /src/StoreApi/Utilities/ProductQuery.php line 530
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
         *
         * @param boolean $adjust_non_base_location_prices True by default.
         * @return boolean
         */
        $taxes = apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ? WC_Tax::calc_tax( $price_filter, $base_tax_rates, true ) : WC_Tax::calc_tax( $price_filter, $tax_rates, true );
        return $price_filter - array_sum( $taxes );
    }
     
    // If prices are shown excl. tax, add taxes to match the prices stored in the DB.
    $taxes = WC_Tax::calc_tax( $price_filter, $tax_rates, false );