Get started building your WooCommerce store or web application — Call us today at (206) 806.7809
Reading Time: 2 minutes

Shipping Insurance in WooCommerce

Shipping insurance is an optional feature you can add to WooCommerce. This insurance can be used to replace items that are damaged or lost during the shipping process.

There is no core option for setting up shipping insurance, but developers have created workarounds to make this possible!

Hidden Product Workaround

The first thing you’ll want to do is set up a product which will be associated with shipping insurance.

You can call this product “Shipping Insurance”, or whatever else you would like. Update the product’s visibility to “hidden” so that it doesn’t appear in your catalog or search results.

You’ll also set the price for shipping insurance in the product details area.

Take note of the product ID of your new product – this can be found on the All Product screen when you hover over the product.

Once your product has been created, you’ll need to update your functions.php file with some custom code.

We highly recommend installing a plugin that will manage any custom code rather than modifying functions.php directly. It is not recommended to modify the PHP file directly. In the video, we use the plugin Code Snippets.

Adding Custom Code to Functions.php

Custom code can be found at this excellent post on Stack Exchange. Here is the code from that post:

add_action(‘woocommerce_cart_totals_after_shipping’, ‘wc_shipping_insurance_note_after_cart’);
function wc_shipping_insurance_note_after_cart() {
global $woocommerce;
$product_id = 669;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values[‘data’];
if ( $_product->id == $product_id )
$found = true;
// if product not found, add it
if ( ! $found ):
<tr class=”shipping”>
<th><?php _e( ‘Shipping Insurance’, ‘woocommerce’ ); ?></th>
<td><a href=”<?php echo do_shortcode(‘[add_to_cart_url id=”669″]’); ?>”><?php _e( ‘Add shipping insurance (+$3)’ ); ?> </a></td>
<?php else: ?>
<tr class=”shipping”>
<th><?php _e( ‘Shipping Insurance’, ‘woocommerce’ ); ?></th>
<?php endif;

Make sure you add in the correct product ID for your hidden product, as well as the desired text you’d like your customer to see with the cost of the insurance.

Once the custom code is added to your functions.php file, customers will see the option to add shipping insurance once products are in their cart. 

Your team is about to get a whole lot mightier.

If it sounds like we might be a good fit, send us a message. We’ll get back to you within 24 hours. And then we can hit the ground running.