Created
November 7, 2023 16:49
-
-
Save j2machado/e726ae8f0ffdc5fc04572373b7f2aa06 to your computer and use it in GitHub Desktop.
Add an icon to any individual shipping method in WooCommerce checkout page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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