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.8.7.0

apply_filters('woocommerce_adjust_non_base_location_prices') is found 8 times:

  • /includes/class-wc-cart-totals.php line 427
    	 * @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 722
    	 */
    	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 1027
    			 * 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 1042
    			 * 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 1090
     
    	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.php line 1270
    			 *
    			 * @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
    			 *
    			 * @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 523
    			 *
    			 * @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 );