Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Shipping Question – limit countries sold to for vendors
- This topic has 4 replies, 2 voices, and was last updated 4 years, 11 months ago by WCFM Forum.
- AuthorPosts
- November 17, 2019 at 3:31 pm #92640sdel_nevoParticipant
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
- November 17, 2019 at 4:39 pm #92645sdel_nevoParticipant
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 logsSteve
- November 23, 2019 at 10:00 am #93530WCFM ForumMember
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
- November 26, 2019 at 10:15 pm #94139sdel_nevoParticipant
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
- December 7, 2019 at 8:10 pm #96513WCFM ForumMember
Sorry, vendors are not allowed to define new zones.
- AuthorPosts
- The topic ‘Shipping Question – limit countries sold to for vendors’ is closed to new replies.