• Resolved brozra

    (@brozra)


    I am developing a site with this plugin and my customer doesn’t ship worldwide – only to the US and Canada.

    I added some code to the includes/class-wc-advanced-shipment-tracking-admin.php file in the woocommerce_advanced_shipment_tracking_page_callback function just before the $default_shipment_providers database query on line 668 of version 2.0.7. This code limits the providers returned in the list to only the countries specified in the default WooCommerce settings under the General options.

    The code is also configured to detect if the user selects differing countries for selling to and shipping to so it should be pretty universal.

    I’d like to ask @zorem to consider adding this as a permanent feature since there is no other way to remove unused shipping providers or hide them from the admin settings page view right now.

    It’s not fully tested but it does work for my purposes. Hope this helps someone else if they are looking for the same solution.

    The code:

    
    /** BEGIN limit to countries set in WooCommerce settings for countries that this seller sells to or specifies for shipping to **/
    $limit_countries = false; $shipping_countries = null; $country_limitations = '';
    $woocommerce_ship_to_countries = get_option( 'woocommerce_ship_to_countries' );
    if (empty($woocommerce_ship_to_countries)) { $limit_countries = true; $shipping_countries = get_option( 'woocommerce_specific_allowed_countries' ); }
    if ($woocommerce_ship_to_countries==="specific") { $limit_countries = true; $shipping_countries = get_option( 'woocommerce_specific_ship_to_countries' ); }
    if ($limit_countries === true) {
    	if (is_array($shipping_countries)) {
    		$woo_shipping_zones_count = count($shipping_countries);
    		if ($woo_shipping_zones_count>0) {
    			$country_limitations = " WHERE ("; $cl_count = 1;
    			foreach ($shipping_countries as $key=>$country_code){
    				$country_limitations .= "shipping_country='".$country_code."'";
    				if ($cl_count < $woo_shipping_zones_count) {  $country_limitations .= " OR "; }
    				$cl_count++;
    			} $country_limitations .= ")"; $woo_shippment_table_name .= $country_limitations;
    		}
    	}
    } /** END limitations **/
    
    • This topic was modified 5 years, 5 months ago by brozra. Reason: errant code markup
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Zorem

    (@zorem)

    Hi @brozra, thanks!

    Please check out the Shipping Provider list in our plugin settings, there is a “Status” column which you can use to hide shipping providers which are not relevant to you. you can enable/disable it in bulk from the header toggle or you can do it manually.
    The enabled shipping providers are the ones that will be available when you add tracking info to orders.

    Let me know if this solves your problem and maybe you can remove your code which I guess currently is hardcoded.

    Thread Starter brozra

    (@brozra)

    I understand what you are saying but what I have provided is a way to eliminate the super long list of unused providers from the admin interface. That is what I have a problem with. I know that the toggle buttons turn the providers on / off for display under an order and I have done that.

    What I was looking for was a way to not show the unused shipping providers from your plugin’s primary admin interface (e.g. wp-admin/admin.php?page=woocommerce-advanced-shipment-tracking).

    The code I provided would allow a WooCommerce admin to change their “Sell to specific countries” or “Shipping location(s)” countries to affect this list and show only what they need.

    In addition to restricting the amount of providers shown whenever you add new providers they should be disabled by default. I am not a fan of going through the list and disabling unused shipping providers every time you update the plugin.

    Plugin Author Zorem

    (@zorem)

    Hi, the list of providers is a valuable asset, 99.9% of our users do need them,We plan to make a better user interface for that in the future but for now, we have no plan on changing that and adding this code. Usually, shop owners only setup their carrier settings once and this does not change often, so i guess we will stick with the current way it works.
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hiding countries you don’t want to see in the plugin admin settings’ is closed to new replies.