Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Created July 23, 2018 22:48
Show Gist options
  • Save NickGreen/e87cd1bafdce99f357cf9e167e7d6d6b to your computer and use it in GitHub Desktop.
Save NickGreen/e87cd1bafdce99f357cf9e167e7d6d6b to your computer and use it in GitHub Desktop.
turn_off_switching_per_product
<?php
add_filter('woocommerce_subscriptions_can_item_be_switched','turn_off_switching_per_product', 10, 3);
function turn_off_switching_per_product(){
$turn_off_switching_for_these_products = array(10,24,438); // change this for whatever products you want to make not switchable
$product_id = wcs_get_canonical_product_id( $item );
if (in_array($product_id, $turn_off_switching_for_these_products)) {
$item_can_be_switch = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment