Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
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.

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
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x