Created
April 22, 2024 12:01
-
-
Save xlplugins/c2b619be8ab7f38c93b2975bf360645f to your computer and use it in GitHub Desktop.
Funnelkit Cart: Display Free Text when cart item price is zero
This file contains 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
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