Skip to content

Instantly share code, notes, and snippets.

@j2machado
Created November 7, 2023 16:49
Show Gist options
  • Save j2machado/e726ae8f0ffdc5fc04572373b7f2aa06 to your computer and use it in GitHub Desktop.
Save j2machado/e726ae8f0ffdc5fc04572373b7f2aa06 to your computer and use it in GitHub Desktop.
Add an icon to any individual shipping method in WooCommerce checkout page.
<?php
/*
* Compatible with CheckoutWC Lite and CheckoutWC premium version.
*
* Snippet: Add a custom icon to any shipping method one by one in WooCommerce.
* Full Explanation: Coming soon.
* Author: Obi Juan
* Author URI: https://obijuan.dev
* License: GPL V2 or later.
*/
add_filter( 'woocommerce_cart_shipping_method_full_label', 'filter_woocommerce_cart_shipping_method_full_label', 10, 2 );
function filter_woocommerce_cart_shipping_method_full_label( $label, $method ) {
// Use the condition here with $method to apply the image to a specific method.
switch($method->method_id){
case 'free_shipping':
$label = $label . '<img src="https://www.bcwsupplies.com/pub/media/images/free_shipping/Free_Shipping_RTL_2020.png" width="10%">';
break;
case 'flat_rate':
$label = $label . '<span>Icon</span>';
break;
}
return $label;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment