I figured I would start a feature request for shipping so there is a clear place to post patches, discuss solutions, etc. I know you are aware of this issue already.

I'm going to take a look at your code, but honestly I just followed a couple of links and just got here now. I've noticed you have been discussing your shipping concerns so I will let you know if I see any glaring solutions while looking.

In the meanwhile, could you describe the issue a bit more in detail to make sure I understand the roadblock you're running into? As far as I can tell it seems like you're saying the orders are combined and so shipping is also being combined(?) Once the orders are processed, can you not split the orders into line items based on seller id and associate shipping with that id and order id? Like a view that separates them into line items on the customer account/previous transactions page?

Comments

farhadhf’s picture

Hey, Thanks for your interest in this!

In a multi-seller store, each seller should be able to set the shipping methods that he/she uses for sending the products. The problem is that I can't find a way to use multiple shipping methods on one order.

For example a user has added a T-Shirt from seller A and a book from seller B to his cart. Seller A wants use UPS and seller B wants to use Fedex for sending the product to the buyer.
The problem is that I can't find a way to allow each seller to define his/her own shipping methods and use those methods in an order for their products..

I'm thinking of writing a custom shipping method for doing this, which just calculates the shipping rate based on sellers supported shipping methods (a proxy for the default commerce shipping module). But I'm not sure if its possible.

Regards
Farhad

P.S. The code in this project is too messy, please don't run off when you see it! I just put this together to as a proof of concept. I've created the order report tables in code, which is not good, It's probably better to create them using Views. (I might do a complete rewrite of the module once I know what exactly I should do for the shipping problem)

RKS’s picture

Ahh. I understand your problem now. I think your solution is good and one that might be beneficial to a larger group other than just marketplace. So I think a separate module would be a good idea. Basically you need to have shipping attached to a product instead of an order so a 'Shipping Per Product' module might be the best way.

However, it might also be possible to add a new field to the product displays/product entities and then create a rule that calculates the shipping based on what's in that field.

For example, you add a field for selecting USPS or UPS. When seller creates a product, they choose the shipping method. Then the Rule finds the product and adds, multiplies a percentage, or whatever to the line item. (Or to the order if taxes aren't applied to shipping.) You might be able add a second field for flat rate shipping if the seller so chooses and then have the rule add that field to the line item instead.

Essentially you'd be bypassing the shipping aspect of commerce altogether. You can also create rules that will update orders based on seller input so you can alert customers to when items have shipped.

What are your thoughts on that workflow?

A 'Shipping Per Product' module would also help others where the rates are better for certain items and the site owner would like to say USPS for these, UPS for those, etc.

farhadhf’s picture

Well, IMO bypassing commerce shipping is not a good idea, We will need it for calculating shipping rates for different shipping methods, we will just need a shipping method which for each item in the order looks for the shipping method field value of the product, and uses commerce shipping to calculate the shipping rate of that item based on that value..

So, what we need is a new shipping method (e.g. commerce_marketplace_shipping) to calculate the shipping price of each product in the order based on the shipping method selected by the seller in the 'shippping_method' field of the product. But I haven't actually written any shipping methods, and I'm not sure how the shipping rate calculation function is called - once for the whole order? once per product line_item?

Do you know how it works?

RKS’s picture

Are you talking zip code based calculations?

farhadhf’s picture

Yes.

RKS’s picture

Ok. I don't really think about that since I always use flat rates so I think I know where you're going now.

I did look at shipping awhile back but it has been several months. I will take a look at that module again for a refresher but I think I remember that it calls it for the entire order. I remember there was a problem with tax since shipping was going in first and the tax was taking that charge in the tax calculation but that's all fixed now. So I'm thinking shipping comes last after everything is completed. But I will look again to make sure.

I do know it's something like hook_commerce_shipping_method() to set up a shipping method, but there will have to be hooks for the submodule methods. I think there's also something like hook_commerce_shipping_alter() that will change how preexisting methods work. So the shipping method gets defined, searches for the line item, locates the shipping method field, then runs hook...alter to call and change that specific shipping method.

Now, should the seller be able to select multiple shipping methods and allow the user to choose?

farhadhf’s picture

Now, should the seller be able to select multiple shipping methods and allow the user to choose?

Hmm... Good question! But I'm not sure how we could implement it... any idea?