• Resolved Demian

    (@demian85)


    Hi Karolina,

    I have been searching through the threads here, but can’t find anyone to ask this question before. I am trying to call the fees from your plugin, but the simple $order->get_fees(); doesn’t seem to work. It shows me always an amount of 1.

    What is the best way to call the fees from your plugin?

    With thanks,
    Demian

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    What are you trying to achieve? I add fees the standard WooCommerce way, so you should be able to get them by:

    $order->get_items(['fee'])

    Good luck!
    Karolina

    Thread Starter Demian

    (@demian85)

    Thank you, it’s part of a shortcode for emails. But yours seems the same as mine and the result always gives value 1. Not sure why this is.

    Edit: I think what is going on. I’m expecting 1,74 and it gives 1,00. I have in your plugin set (1,21 + 2.99%)(incl vat of 21%) and it seems to give only the 1,21 – VAT. It’s missing the 2.99%.

    • This reply was modified 3 years, 6 months ago by Demian.
    • This reply was modified 3 years, 6 months ago by Demian.
    Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    Could you replicate it for example on tastewp.com? There do have free WP servers for testing.

    If you go through standard checkout – does it behave as one would expect?

    Thread Starter Demian

    (@demian85)

    @vyskoczilova this is an environment where I would not be able to set up custom functions for emails.

    Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    I mean, you don’t need to replicate the custom emails – just replicating the bug – var_dump your wrong taxes would be enough.

    Something like:

    add_action('wp_head', function() {
    $order = wc_get_order(123);
    var_dump( $order->get_items(['fee']));
    });

    There is no necessity to add the complexity with emails etc. If it works with the example above, you need to check for priorities/actions you use for hooking (but that’s out of the scope of the plugin).

    Thread Starter Demian

    (@demian85)

    I did the following:

    add_action( 'init', 'show_order_tax' );
    function show_order_tax() {
    	$order = wc_get_order(123);
    	var_dump( $order->get_items(['fee']));
    }

    and it seems to load correct totals, I need to look further into the problem coming from somewhere else. Thanks!

    Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    @demian85 Good, happy I could help. My fingers crossed.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘get_fees()’ is closed to new replies.