Support » Plugin: Price Based on Country for WooCommerce » Wrong price for variable products

  • Resolved passatgt

    (@passatgt)


    If i have variations set with a fixed price for a zone generated by this plugin, the original product price will be displayed as the main price on the single product page template, not the lowest variation price set by the plugin. Any ideas how to fix this?

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi!
    I don’t understand the issue 🙁

    could you give more details? an example with prices, the result that you get and what result you expected would be great.

    Also, a link with to a product with the issue would help me.

    Thank you.

    passatgt

    (@passatgt)

    Sure, i understand its a bit confusing and i just found out its tricky to replicate, because its related to theme issue too. But:

    1. Create a variable product with two variations: variation A costs $10, variation B costs $20
    2. Setup a zone with your plugin
    3. Change the variation’s zone price to a fixed value, A costs $15, B costs $25
    4. If you print the product’s cost using $product->get_price() (which would show the lowest variation price), it will show $10 instead of $15.

    So, in short, i think the $product->get_price() function is not returning the value set by your plugin.

    Plugin Author Oscar Gare

    (@oscargare)

    Hi,
    the plugin load the product zone pricing in the frontend after the ‘woocommerce_init’ hook.
    Make sure you are place the code after woocommerce_init has been loaded.

    When the zone pricing is initiated, PBC runs the action ‘wc_price_based_country_frontend_princing_init’, place code here and run another test.

    passatgt

    (@passatgt)

    I’m using the get_price function inside the ‘woocommerce_variable_price_html’ filter, so that definitely runs after WC is initialized.

    Plugin Author Oscar Gare

    (@oscargare)

    By default, it works 🙂 , so for your should work too.

    Try to use:

    $prices    = $variable_product->get_variation_prices();
    $min_price = current( $prices['price'] );

    This is the way that WooCommerce uses for variable products since 3.0

    Plugin Author Oscar Gare

    (@oscargare)

    Hi again,
    You should check that the zone pricing is load. You can do it by:

    if ( WCPBC()->current_zone ) {
    error_log( ‘zone load’ );
    else {
    error_log( ‘no zone’ );
    }

    It’s possible that you are seeing a wrong price because no there “zone pricing”.

    • This reply was modified 1 year ago by  Oscar Gare.
    passatgt

    (@passatgt)

    Thanks

    global $product;
    if ( WCPBC()->current_zone ) {
        echo 'zone-loaded';
        echo 'get_price: '.$product->get_price();
    } else {
        echo 'no-zone-loaded';
    }

    This is the one i’m trying. So the zone loads up fine, but the get_price shows me the “zoneless” lowest price 🙂 I’m trying this inside the single-product/title.php template. And i just checked, get_price works fine with a simple product, so the issue only appears with variable products.

    • This reply was modified 1 year ago by  passatgt.
    Plugin Author Oscar Gare

    (@oscargare)

    Hi, I think that I found the cause of the issue..I need to know, is the exchange rate of the zone 1??
    Thanks

    passatgt

    (@passatgt)

    Yes! I don’t use exchange rates, as i define custom fixed price for each product.

    Plugin Author Oscar Gare

    (@oscargare)

    Ok, thank you. I’ll do tests.
    Thanks for your feedback.

    Plugin Author Oscar Gare

    (@oscargare)

    Hi!
    version 1.7.13 includes the fix for this issue.

    You have to update the plugin and after re-update the variable product (edit the product and click on update) to launch the product synchronization. Then the get_price() function will return the lowest variation price.

    Thanks for your feedback 🙂

    passatgt

    (@passatgt)

    Awesome, thanks! Great plugin 🙂

    • This reply was modified 1 year ago by  passatgt.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Wrong price for variable products’ is closed to new replies.