Created
April 26, 2022 20:56
-
-
Save reandimo/57948c6184690436e8bd371d0e198fdb to your computer and use it in GitHub Desktop.
Hide Cart Item Subscription Options for Free Products - All Products for WooCommerce Subscriptions
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
<?php | |
/** | |
* Plugin Name: All Products for WooCommerce Subscriptions - Hide Cart Item Subscription Options for Free Products | |
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/ | |
* Description: Use this snippet to hide cart item subscription options for free products. | |
* Version: 1.0 | |
* Author: Renan Diaz | |
* Author URI: https://nativo.team/ | |
* Developer: Renan Diaz | |
*/ | |
add_filter( 'wcsatt_show_cart_item_options', 'hide_free_item_options', 99999999, 3 ); | |
// Prevent free products have subscription options | |
function hide_free_item_options( $show, $cart_item, $cart_item_key ) { | |
$product = $cart_item['data']; | |
$total_item = WC()->cart->get_product_subtotal( $product, $cart_item['quantity'] ); | |
if ( $cart_item['line_total'] == 0 ) { | |
$show = false; | |
} | |
return $show; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment