• Resolved mundial

    (@mundial)


    Hi,

    I’m using this filter to get the woocommerce product price:

    add_filter( ‘woocommerce_get_price_html’, ‘custom_price’, 100, 2 );
    function custom_price( $price, $product ) {
    $my_price = $product->get_price();

    With your plugin activated is possible to get the tiered price when changing prices?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author WP Developer

    (@bycrik)

    Hi!

    On frontend plugin changing prices using JS.

    But in the backend, you can get price rules using PriceManager.php

    Regards,
    Kolya

    Thread Starter mundial

    (@mundial)

    Hi Kolya,

    Thanks for your fast response.
    Please can you help me with the code? (I’m not a programmer)

    With $product->get_price(); I’m getting regular product price, is there something similar to get “tiered product price”?

    Thanks

    Plugin Author WP Developer

    (@bycrik)

    Hi!

    $rules = \TierPricingTable\PriceManager::getPriceRules( $product_id );

    Above you will get an array with min_needed_quantity (key) and tied to quantity price (value).

    Regards,
    Kolya

    Thread Starter mundial

    (@mundial)

    Thanks,
    I attach my complete code:

    add_filter( ‘woocommerce_get_price_html’, ‘custom_price’, 100, 2 );
    function custom_price( $price, $product ) {
    $my_price = $product->get_price();
    $euros = $my_price * 1.2;
    $euros = number_format($euros, 2);
    $price = ‘Price: ‘ . $price . ‘ (w/VAT: ‘ . $euros . ‘)’;
    return $price;

    }

    The code multiply regular price x 1.20 , the question is how this code can get the tiered price instead regular price, it works fine when 1 unit is selected, but if customer buy 2 units tiered price changes, but not regular, is it possible? how?

    Thanks in advance!

    Plugin Author WP Developer

    (@bycrik)

    Sorry, but the tiered price you cannot modify using woocommerce_get_price_html filter.

    You need to override the table template in your theme and change render logic.
    (THEME_NAME/PLUGIN_NAME/price-table-fixed.php file).

    Regards,
    Kolya

    Thread Starter mundial

    (@mundial)

    Hi Kolya,
    Is there any code that do the same of the code above for tiered price that I could include in functions.php?
    I only need to multiply price per a fixed quantity, works well with regular price but with your plugin activated regular price changes to tiered price depending on quantity and filter doesn’t work.
    Best

    Plugin Author WP Developer

    (@bycrik)

    Hi!

    Hmm, if you don’t need to modify prices at the table – you can just disable JS which changes the price when you change the quantity.

    try to remove the script enqueue – https://joxi.ru/EA4Ry0PTovwxjm. (change the plugin version to 999, because next update may wipe your fixes).

    BR,
    Kolya

    Thread Starter mundial

    (@mundial)

    Hi,
    Yes, I don’t need to modify prices at the table, I need that regular price shows tiered price, but keeping the multiplication.
    I’ve found and commented the code of the picture in src/frontend/frontend.php, without success because price x VAT is not changing when I change quantity.

    // Enqueue frontend assets
    /* add_action(
    ‘wp_enqueue_scripts’,
    [ $this, ‘enqueueAssets’ ],
    10,
    1
    );*/

    Which version is 999?
    Is there a workaround to solve it?

    Thanks!

    Plugin Author WP Developer

    (@bycrik)

    Hi!

    I didn’t think you need to changing the price when someone changes the quantity.
    This customization is more complicated than just add price filter.

    You need to override tiered price formation algorithms. Look in PriceManager.php

    If you are not able to do that, I can provide you paid development service.

    Email: [email protected]

    Thanks,
    Kolya

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filter to get tiered price’ is closed to new replies.