I would like to know how I go about this. Let's say I have some items in my checkout page in woocommerce. I want to apply a gift card to the order, I can't use a gift card plugin because it is implemented already by a third party gift card service. Someone is building the connection for me to hit to connect to the third pary gift card service.
Now what I would like to do is on the checkout page, have a custom field where I can enter a gift card. with a submit button, that through I assume ajax run a php function that submits to the thrid party gift card service, with the amount of the total price and will return to me the amount it can cover.
Basically I want to know what would I hook into in woocomerce after this function is run to update the price in the checkout (cart), and I guess where would I hookinto to also add this custom field (or I guess custom form)
So far I have done this, what I am wondering is how do I update the total price from submitting a function before checking out?
add_action( 'woocommerce_after_checkout_billing_form', 'gift_card_redeem' );
// select
function gift_card_redeem( $checkout ){
// you can also add some custom HTML here
woocommerce_form_field( 'contactmethod', array(
'type' => 'text', // text, textarea, select, radio, checkbox, password, about custom validation a little later
'required' => false, // actually this parameter just adds "*" to the field
'class' => array('gift-card-redeem'), // array only, read more about classes and styling in the previous step
'label' => 'gift-card-redeem',
'label_class' => 'gift-card-redeem', // sometimes you need to customize labels, both string and arrays are supported
), $checkout->get_value( 'contactmethod' ) );
// you can also add some custom HTML here
}