Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
00 Days
00 Hours
00 Minutes
00 Seconds

How to Add a Checkbox Below a Specific Shipping Method in WooCommerce?

Do you want to add a checkbox below a specific shipping method in the WooCommerce cart and checkout page? Here is the handy code snippet that will help you.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
add_action( 'woocommerce_after_shipping_rate', 'ts_checkout_shipping_additional_field', 20, 2 );
function ts_checkout_shipping_additional_field( $method, $index )
{
if( $method->get_id() == 'flat_rate:4' ){
echo '<br>
<input type="checkbox" name="shipping_custom_1" id="shipping_custom_1" value="1" class="shipping_method shipping_custom_1">
<label for="shipping_custom_1">Gift Wrapping</label>';
}
}
add_action( 'woocommerce_after_shipping_rate', 'ts_checkout_shipping_additional_field', 20, 2 ); function ts_checkout_shipping_additional_field( $method, $index ) { if( $method->get_id() == 'flat_rate:4' ){ echo '<br> <input type="checkbox" name="shipping_custom_1" id="shipping_custom_1" value="1" class="shipping_method shipping_custom_1"> <label for="shipping_custom_1">Gift Wrapping</label>'; } }
add_action( 'woocommerce_after_shipping_rate', 'ts_checkout_shipping_additional_field', 20, 2 );
function ts_checkout_shipping_additional_field( $method, $index )
{
    if( $method->get_id() == 'flat_rate:4' ){
        echo '<br>
        <input type="checkbox" name="shipping_custom_1" id="shipping_custom_1" value="1" class="shipping_method shipping_custom_1">
        <label for="shipping_custom_1">Gift Wrapping</label>';
    }
}

Output

In the following output, the checkbox is added below a specific flat-rate shipping method (‘flat_rate:4’) on the WooCommerce checkout page. This option gives customers the choice to add a special “Gift Wrapping” service to their order during the checkout process

How to Add a Checkbox Below a Specific Shipping Method in WooCommerce?

Similar to the above functionality, you can also add radio buttons to specific shipping method on WooCommerce checkout that will help you to place radio buttons for ‘local pickup’ to choose a pickup location.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of


0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.