Support » Plugin: Multiple Packages for WooCommerce » Group by Vendor option

  • Hi,

    Could you please add Group By Vendor option, to group products in cart based on vendors of those products, this will enable support all multivendor marketplaces

    Regards,
    Murali

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author hystericallyme

    (@hystericallyme)

    Group By Vendors is currently possible for Dokan, with more marketplaces in the works. The vendor role is not a WooCommerce/WordPress specific feature, it is added by third party plugins. Because of that there is no one solution that will work for all of them. Each has to be created and tested separately.

    Check back soon for new marketplace plugins compatibility!

    Hi,
    It will be very welcomed.
    I was trying to use some code I found somewhere, but it did not work. If you could add this in the future edition it will be very helpful, as some marketplaces, like Woocommerce Product vendors do not allow vendors add shipping classes.

    				function generate_packages( $packages ) {
    					if( get_option( 'multi_packages_enabled' ) ) {
    						// Reset the packages
    	    				$packages = array();
                  $vendor_items_map = array();
                  $cart_items = WC()->cart->get_cart();
    
          				foreach ( $cart_items as $item ) {
          					$product_id = $item['product_id'];
          					$vendors = get_product_vendors( $product_id  );
          					if ( $item['data']->needs_shipping() ) {
          						if($vendors) {
          							foreach( $vendors as $vendor ) {
          								// Expecting/assuming there is only one Vendor assigned per product. Hm.
          								$vendor_items_map[$vendor->ID][] = $item;
          								break;
          							}
          						}
          						// No product vendor associated with item.
          						else {
          							$vendor_items_map['0'][] = $item;
          						}
          					}
          				}
    
          				foreach($vendor_items_map as $key => $vendor_items) {
          					$packages[] = array(
          						//'ship_via' => array( 'flat_rate' ),
          						'contents' => $vendor_items,
          						'contents_cost' => array_sum( wp_list_pluck( $vendor_items, 'line_total' ) ),
          						'applied_coupons' => WC()->cart->applied_coupons,
          						'destination' => array(
          							'country' => WC()->customer->get_shipping_country(),
          							'state' => WC()->customer->get_shipping_state(),
          							'postcode' => WC()->customer->get_shipping_postcode(),
          							'city' => WC()->customer->get_shipping_city(),
          							'address' => WC()->customer->get_shipping_address(),
          							'address_2' => WC()->customer->get_shipping_address_2()
          						)
          					);
          				}
    
    	    				}
    
        					return $packages;
    	    			}
    Plugin Author hystericallyme

    (@hystericallyme)

    We definitely have something in the works with future updates, but new features are being developed first to enhance this plugin’s basic functionality. Then focus will be shifted back to compatibility again 🙂

    Glad to hear that. Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Group by Vendor option’ is closed to new replies.