In the checkout page, the user can select the installment for the credit card payment method and for each installment there is a fee to be added in the order total.
I'm using javascript to update the totals visually everytime the user changes the installment selected, but I need to update the order total in the backend aswell.
So far I've found some ways to update the totals. One of them envolves the woocommerce_checkout_create_order action.
add_action( 'woocommerce_checkout_create_order', 'change_total', 20, 1 );
function change_total_on_checking( $order ) {
$order->set_total(); // Add rules here
According to this answer: Change order total after checkout in Woocommerce
This action is performed right before the $order->save() method. Here I have the instance of the order.
To complete my case scenario, I need the installment value passed by the checkout form, but I don't know how to access it from this action. I don't know if is possible at all.
Another way would use the woocommerce_checkout_update_order_review according to this answer: handle payment methode change event
But I didn't understand how make that work in the PHP side.
So any ideas? How can I change the order total in the checkout page reading the installment value and applying some rules to change it's value?