I was reviewing the post titled “Extra fee not in the pdf invoice” by @troglos and see that this missing line item has probably always been missing. Is the fix for this as simple as replacing the two lines
add_action( 'woocommerce_review_order_before_order_total', array( $this, 'add_payment_gateway_extra_charges_row'));
add_action( 'woocommerce_cart_totals_before_order_total', array( $this, 'add_payment_gateway_extra_charges_row'));
with something like
$woocommerce->cart->add_fee( 'Extra Charges', $this -> current_gateway_extra_charges, true, '' );
I know that it’s not exactly this, since you have two types of extra charges (percentage and flat fee), but is this the right idea?
If so, when do you think you would have a fix for this?
Thank you very much for your support.
We will look into it and shall post a release with fixes this weekend.
Hi,
I have followed the approach as specified and published it with new updates and it should work as expected. Thanks
@hemsingh1 – Thank you for the update! I have more testing, but so far, it looks like it’s working as it should. I’m not an expert, so forgive some remedial questions to help me learn (if you don’t mind):
- Why do you use
add_action( 'woocommerce_cart_calculate_fees', array( $this, 'calculate_totals' ), 10, 1 );
instead of
add_action( 'woocommerce_cart_calculate_fees', 'calculate_totals' , 10, 1 );
- What is the purpose of $t3?
Thank you and thanks again for a great plugin!
Hi,
The reason, I use the action hook in this manner is because the function is declare in a class. Also $t3 is used to for gateway name variable.
Thanks & Regards,
hemsingh1
Hi, @hemsingh1. Thank you for taking the time to respond – it helps me to learn. And thanks again for your hard work on this plugin. It is working well for me.
Hi, @hemsingh1. After further testing, your update is working perfectly. Thank you! One of the great things about your plugin is that the extra charge updates automatically/dynamically when selecting different payment methods at checkout. Was there anything special that you needed to do to have the extra charge update automatically (when selecting different payment methods) or did this just happen when you added the action
add_action( 'woocommerce_cart_calculate_fees', array( $this, 'calculate_totals' ), 10, 1 );
I’m learning WordPress and WooCommerce, so your answer would help me to understand, but not urgent. Whenever you have time.
Thanks again for a great plugin. Nice work.
-
This reply was modified 9 years, 2 months ago by
deeveedee.
Hi, @hemsingh1.
Please disregard my previous question. I figured it out. Thanks again for a great plugin.