Skip to content

Instantly share code, notes, and snippets.

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 reandimo/57948c6184690436e8bd371d0e198fdb to your computer and use it in GitHub Desktop.
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
<?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