Shipping Question – limit countries sold to for vendors

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM Shipping Question – limit countries sold to for vendors

Viewing 4 reply threads
  • Author
    Posts
    • #92640
      Avatarsdel_nevo
      Participant

      Hi Guys

      I have a question from a vendor, that i’m struggling with

      he only wants to set shipping to the UK. is it possible for vendors to set which countries they deliver to?

      for example

      if vendor A only wants to sell products in the UK, then customer A who lives in the USA cannot purchase these

      there is a setting in Woo-commerce to set the countries sold to, but this is for the whole site, i cant find a way to set this at the vendor level

      in the zones setting we could set the UK with price information and then “everywhere else” to “DO NOT SELL TO”

      is this possible?

      as currently there appears no way to prevent customers purchasing purducts, that vendors physically cannot ship items to

      Steve

    • #92645
      Avatarsdel_nevo
      Participant

      Hi Guys

      After googling for a few hours i found this

      <strong>//disable checkout if no shipping methods</strong>
      function disable_checkout_button_no_shipping() {
          $package_counts = array();
           
          // get shipping packages and their rate counts
          $packages = WC()->shipping->get_packages();
          foreach( $packages as $key => $pkg )
              $package_counts[ $key ] = count( $pkg[ 'rates' ] );
       
          // remove button if any packages are missing shipping options
          if( in_array( 0, $package_counts ) )
              remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
      }
      add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button_no_shipping', 1 );
      
      function prevent_checkout_access_no_shipping() {
          // Check that WC is enabled and loaded
          if( function_exists( 'is_checkout' ) && is_checkout() ) {
           
              // get shipping packages and their rate counts
              $packages = WC()->cart->get_shipping_packages();
              foreach( $packages as $key => $pkg ) {
                  $calculate_shipping = WC()->shipping->calculate_shipping_for_package( $pkg );
                  if( empty( $calculate_shipping['rates'] ) ) {
                      wp_redirect( esc_url( WC()->cart->get_cart_url() ) );
                      exit;
                  }
              }
          }
      }
      add_action( 'wp', 'prevent_checkout_access_no_shipping' );

      it hides the checkout button if the country selected by the customer has no delivery options.

      it appears to work, as it prevents customers from purchasing if the vendor has not created a delivery method for the zone

      its not great but it does the job


      @WCFM

      can you see any issues with this code, its not creating any issues in the browser or my error logs

      Steve

    • #93530
      WCFM ForumWCFM Forum
      Keymaster

      HI,

      Well, which shipping option using by your vendors – Zone wise shipping or Country based shipping?

      Ask vendor to setup cost for only those zones or countries where they want to sell.

      Thank You

    • #94139
      Avatarsdel_nevo
      Participant

      Hi Guys

      thanks for getting back, and sorry for my late reply

      is it possible to allow vendors to add there own zones? like they can the counties

      currently, vendors can only add shipping to zones that we as site admins have added

      vendors have no way to add new zones

      sorry if it has been asked before

      Steve

    • #96513
      WCFM ForumWCFM Forum
      Keymaster

      Sorry, vendors are not allowed to define new zones.

Viewing 4 reply threads
  • The topic ‘Shipping Question – limit countries sold to for vendors’ is closed to new replies.