Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created April 22, 2024 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlplugins/c2b619be8ab7f38c93b2975bf360645f to your computer and use it in GitHub Desktop.
Save xlplugins/c2b619be8ab7f38c93b2975bf360645f to your computer and use it in GitHub Desktop.
Funnelkit Cart: Display Free Text when cart item price is zero
class FKCART_Display_Free_When_Price_Zero {
private $instance = null;
public function __construct() {
add_filter( 'fkcart_enable_item_link', [ $this, 'add_item_meta' ] );
}
public function add_item_meta( $status ) {
add_filter( 'woocommerce_cart_item_subtotal', array( $this, 'cart_loaded' ), 99999, 3 );
return $status;
}
public function cart_loaded($price, $cart_item, $cart_item_key ) {
if ( $cart_item[ 'data' ]->price == 0 ) {
$price = __( 'Free', 'woocommerce' );
}
return $price;
}
}
new FKCART_Display_Free_When_Price_Zero();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment