Home Forums WoodMart support forum Tiered pricing – wrong

Tiered pricing – wrong

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #723991

    website-art.de
    Participant

    I have set up tiered pricing for three products. The price is calculated in either CHF or EUR using the FOX Currency Switcher plugin.
    For CHF, the price is calculated correctly at checkout. For EUR, however, VAT is added on top. However, this applies only to orders of 2 or more units.

    Attachments:
    You must be logged in to view attached files.
    #724008

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    Hello,

    I see all the prices in CHF on your website and there is no currency switcher available. Could you please clarify how to switch to EUR and reproduce the problem?

    Kind Regards

    #724060

    website-art.de
    Participant

    Hello, thanks for your reply.
    I installed the FOX plugin and received this response from support:

    What we suggest you do: ask WoodMart support where exactly the tiered price table is rendered and which filter or action hook is available for it. Once you know the hook name, replacing the printed values with the shortcode output is a small piece of code. If you send us that hook name, we can help you with the snippet.

    Could you please answer that for me?

    Kind Regards

    #724089

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    Hi,

    Thanks for your patience, and thanks to the FOX team for the clear question.

    The tiered pricing feature is our Dynamic Discounts module. There are two parts, and they’re worth separating:

    1. The pricing table on the product page is rendered by XTS\Modules\Dynamic_Discounts\Frontend::render_dynamic_discounts_table(), hooked to woocommerce_single_product_summary (priority 25). It loads the template woocommerce/single-product/price-table.php (overridable in a child theme). The prices there are produced with $product->get_price() and wc_price(), so FOX’s standard woocommerce_product_get_price and wc_price filters already apply to that table. For layout, there are also two action hooks around it: woodmart_before_dynamic_discounts_table and woodmart_after_dynamic_discounts_table.

    2. The actual price used at cart/checkout is where the currency issue comes from. Discounts are applied in woocommerce_before_calculate_totals, and the base price we start from is read with $product->get_price('edit'). The ‘edit’ context intentionally returns the raw stored price without running woocommerce_product_get_price which is the filter FOX uses to convert currency. So for the base currency (CHF) the result is correct, but for a converted currency (EUR) the tier is calculated on the unconverted base, which produces the wrong total.

    To integrate FOX cleanly, we expose two dedicated filters in that calculation:

    woodmart_pricing_before_calculate_discounts( float $price, array $cart_item ) runs before the tier discount is applied. Convert the base price to the active currency here.
    woodmart_pricing_after_calculate_discounts( float $price, array $cart_item ) runs after the tier discount, if a final adjustment is needed.

    A minimal example for the FOX team:

    add_filter( 'woodmart_pricing_before_calculate_discounts', function ( $price, $cart_item ) {
        // Convert WoodMart's base-currency price into the active FOX currency
        // using FOX's own conversion helper, then return it.
        return woocs_convert_to_active_currency( $price ); // pseudo — use FOX's real API
    }, 10, 2 );

    With the base price converted at woodmart_pricing_before_calculate_discounts, the tier discount and WooCommerce tax will both be calculated on the correct EUR amount, which should resolve the “VAT added on top for 2+ units” behaviour.

    Let us know if the FOX team needs anything else on our side.

    #724102

    website-art.de
    Participant

    Hello, thank you very much for the detailed response. I have forwarded it to FOX. Thanks again!

Viewing 5 posts - 1 through 5 (of 5 total)