Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created November 12, 2024 13:16
Show Gist options
  • Save xlplugins/d3ffe81635a5706e80c995101efd4143 to your computer and use it in GitHub Desktop.
Save xlplugins/d3ffe81635a5706e80c995101efd4143 to your computer and use it in GitHub Desktop.
Funnelkit Cart:Hide Child Product item of composite product like image and price
class FunnelKitWPCComposite1 {
public $tmp = [];
public function __construct() {
add_filter( 'fkcart_is_child_item', [ $this, 'check_free_item' ], 10, 2 );
add_filter( 'fkcart_item_hide_delete_icon', [ $this, 'check_free_item' ], 10, 2 );
add_filter( 'fkcart_cart_item_is_sold_individually', [ $this, 'check_free_item' ], 10, 2 );
add_action( 'fkcart_before_item_meta', [ $this, 'append_qty' ], 11 );
add_action( 'fkcart_variable_product_before_update', [ $this, 'fkcart_variable_product_before_update' ], 11 );
}
public function fkcart_variable_product_before_update() {
$instance = WC_CP_Cart::instance();
remove_action( 'woocommerce_remove_cart_item', array( $instance, 'cart_item_remove' ), 10, 2 );
}
public function append_qty( $cart_item ) {
$product_id = $cart_item['product_id'];
if ( isset( $cart_item['cart_item']['composite_item'] ) && ! empty( $cart_item['cart_item']['composite_item'] ) ) {
$status = true;
} else {
$status = false;
}
if ( $status == false ) {
return;
}
$k = $cart_item['is_cart_item'];
?>
<style>
#fkcart-modal .fkcart-slider-body .fkcart-item-wrap .fkcart--item[data-key="<?php echo $k; ?>"] a.fkcart-image-wrapper {
opacity: 0;
}
#fkcart-modal .fkcart-slider-body .fkcart-item-wrap .fkcart--item[data-key="<?php echo $k; ?>"] a.fkcart-item-title dl,
#fkcart-modal .fkcart-slider-body .fkcart-item-wrap .fkcart--item[data-key="<?php echo $k; ?>"] .fkcart-item-misc {
display: none;
}
</style>
<?php
}
}
new FunnelKitWPCComposite1();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment