galloba
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Forum: Plugins
In reply to: [Multiple Packages for WooCommerce] Group by Vendor optionGlad to hear that. Thank you
Forum: Plugins
In reply to: [Multiple Packages for WooCommerce] Group by Vendor optionHi,
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; }
OK,
Thank youHi,
Thank you. I have done this. My issue is I am using another plugin for table rate shipping to set rates for different cities. And, I want the vendor to have access to the methods I created with the admin using that plugin. But, only “Flat-rate Shipping”, “Free Shipping” and “Local Pickup” are appearing to the vendor.
Viewing 4 replies - 1 through 4 (of 4 total)