Check If User Has Subscription

0.0/5
<?php
function is_groomi_subscriber(){
	global $woocommerce;
	global $wpdb;
	
	$userid = get_current_user_id();
	$subscriptions = wcs_get_users_subscriptions($userid, '', 'active');
	
    if (count($subscriptions) > 0)
        return true;
		
	return apply_filters('groomi_subscriber', false);
}


//add_action( 'woocommerce_before_checkout_billing_form', 'wpd_tmp', 10 );

function wpd_tmp() {
	var_dump(is_groomi_subscriber());
}


add_filter("woocommerce_shipping_packages", "filter_packages_for_subscribers", 10, 1);

function filter_packages_for_subscribers($packages) {
	if(!is_groomi_subscriber())
		foreach ($packages as $i => $package)
			unset($packages[$i]["rates"]["free_shipping:17"]);
	return $packages;
}

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet was fetched automatically from WPDistro.cz projects.

Author

Tags

This snippet is untagged