I have an ecommerce store with a cart page that displays a custom shipping option called "Freight Quote (Email Us)". However, I would like to execute some short code on my site that will display a contact form so the user can easily fill out required details in order to get a freight quote. Below is what my page currently looks like:
After adding a code snippet in my plugin I managed to get the form to fire, but it is firing as soon as the page loads and then goes away whenever any of the other options are selected.
Here is the code snippet I added to get the above to show:
<?php
add_action( 'woocommerce_after_shipping_rate', 'checkout_shipping_additional_field', 20, 2 );
function checkout_shipping_additional_field( $method, $index )
{
if( $method->get_id() == 'request_shipping_quote' ){
echo do_shortcode('[ws_form id="1"]');
}
}
?>
To reiterate the problem, I am able to execute short code to get my contact form to show, but it only shows once the cart page loads and then immediately disappears whenever any of the shipping options are selected. I only want it to execute when "Freight Quote (Email Us)" is selected and re-show it everytime a user clicks off/back on again.