Support » Plugin: Product Country Restrictions » Not compatible with WordPress 5.1.1

  • Hi,
    I know that Product Country Restrictions v0.4.3 informs that it is tested up to WP v4.9.10.
    Is there any plans to update the compatibility to include WP v5.1?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am wondering this as well. I just downloaded the free version and can’t do anything at all..? I’m now wondering if this is the case.

    Any news with this?
    IS there an alternative free plugin that does the same function?

    Thread Starter kal0

    (@kal0)

    At the moment I am testing https://wordpress.org/plugins/woo-country-restrictions-advanced/ without upgrading/unlocking to the premium version, but all I need is what Product Country Restrictions managed to do.

    This plugin work in half.
    You can set restrictions into product edit window, but this not work on checkout page, after click order submit button.
    Solution:

    function fnc_woocommerce_after_checkout_validation( $data, $errors ) {
    	
    	global $woocommerce;
    	
    	$cart_contents = $woocommerce->cart->get_cart_contents();
     
    	$fz_shipping_is_disabled = false;
    	
    	if ( is_countable( $cart_contents ) === true && is_array( $cart_contents ) === true ) {
    		
    		foreach ( $cart_contents as $cart_item ) {
    			
    			$fz_country_restriction_type = get_post_meta( $cart_item[ 'product_id' ], '_fz_country_restriction_type', true );
    			
    			$fz_restricted_countries = get_post_meta( $cart_item[ 'product_id' ], '_fz_restricted_countries', true );
    			
    			if ( empty( $fz_restricted_countries ) === false && is_array( $fz_restricted_countries ) === true ) {
    				
    				if ( $fz_country_restriction_type === 'excluded' ) {
    					
    					if ( in_array( $data[ 'shipping_country' ], $fz_restricted_countries ) === true ) {
    						
    						$fz_shipping_is_disabled = true;
    					}
    				}
    				
    				if ( $fz_country_restriction_type === 'specific' ) {
    					
    					if ( in_array( $data[ 'shipping_country' ], $fz_restricted_countries ) === false ) {
    						
    						$fz_shipping_is_disabled = true;
    					}
    				}
    			}
    		}
    	}
    	
    	if ( $fz_shipping_is_disabled === true ) {
    		
    		wc_add_notice( 'We do not send certain products to selected country. Please, remove restricted products from cart, or change shipping country.', 'error' );
    	}
    }
    
    add_action( 'woocommerce_after_checkout_validation', 'fnc_woocommerce_after_checkout_validation', 10, 2 );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not compatible with WordPress 5.1.1’ is closed to new replies.