Closed vyskoczilova closed 4 years ago
This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for contributing :)
Description
We have a checkout manager plugin (WooCommerce Checkout Field Editor) that can charge a fee whenever a certain option field is selected and that fee is then nicely added to the checkout total and its value can be retrieved using “WC()->cart->fee_total” or “WC()->cart->get_fee_total()”, which we need for a custom payment module.
However, when Pay for Payment is active, the variable
WC()->cart->fee_total
is zero even though a fee is added to the checkout total. Only when refreshing the page, the variable shows the correct value, but of course, then it’s no longer useful.We have also tried using another checkout manager plugin (WooCommerce Checkout Manager), but it’s the same issue (when Pay for Payment is active).
https://wordpress.org/support/topic/variable-fee_total-remains-zero-when-pay-for-payment-is-active/#post-12378363
The WC Checkout Field Editor Pro dev note
The fee adding functionality was handled by the default WooCommerce hook (
woocommerce_cart_calculate_fees
). Inpublic/class-thwcfe-public-checkout.php
file, line number 199, you can see action hook and itself callback function (woo_cart_calculate_fees
) is in the same file.When the user enters data in the checkout field, we save the additional fee in WordPress transient and as per the transient data, the fee will be added. All related functionalities are in
the public/class-thwcfe-public-checkout.php
file