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

How to Add Custom Shipping Radio Button in WooCommerce Cart?

If you want to improve the shipping options presented to customers during the WooCommerce checkout process, the provided code will add custom shipping radio buttons to the Cart Totals section.

// Add custom shipping radio buttons along with existing methods in WooCommerce Cart Totals
function ts_add_custom_shipping_radio_buttons() {
    if (is_cart()) {
        ?>
        <tr class="custom-shipping-options">
            <th><?php _e('Select Handling Fees:', 'your-text-domain'); ?></th>
            <td>
                <label for="express_shipping">
                    <input type="radio" name="shipping_method" id="express_shipping" value="express_shipping" checked>
                    <?php _e('Express Shipping - $10.00', 'your-text-domain'); ?>
                </label>
                <br>
                <label for="standard_shipping">
                    <input type="radio" name="shipping_method" id="standard_shipping" value="standard_shipping">
                    <?php _e('Standard Shipping - $5.00', 'your-text-domain'); ?>
                </label>
            </td>
        </tr>
        <?php
    }
}
add_action('woocommerce_cart_totals_before_shipping', 'ts_add_custom_shipping_radio_buttons');

Output

The below output shows that the two custom radio button has been added between the subtotal and shipping options.

How to Add Custom Shipping Radio Button in WooCommerce Cart?

You can also customize the selected shipping methods title in WooCommerce cart which will change the color of the text based on the selected shipping method radio buttons. This can be achieved by using CSS code to target the specific shipping method and change its title color.

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