8

When a customer comes to our store and goes to check out on multiple items, I need to write a module to calculate shipping based on several factors. I have determined from my research that the following should happen:

First, I need to separate the cart items into different orders for shipping calculation. I want the orders to be sorted by "vendor" attribute value. "Vendor" is an attribute that we added to the system that is applicable for all simple products. So say in the cart there is a pink shirt with "vendor" value "1", a pencil with "vendor" value "1", and a blue shirt with "vendor" value "2". All items with "vendor" value "1" need to be one order, while the item with "vendor" value "2" need to be a different order. I see this other question answers this dilemma, but then raises another. How do I do this but display the seperate orders as one order during checkout to customers and only collect payment once?

Second, I need to calculate shipping with Magento's default UPS and Fedex shipping functionalities but with an origin address that is determined by the "vendor" value number (stored in a separate database table). Any suggestions welcome!

I am using code snippets to get me started from here and here.

I will probably have several questions, but the first ones are those in bold above.

UPDATE I decided it would be best to override the multiple shipments magento core module to do what I'm trying to do. Please help me find where and what to put to manipulate the multishipping Magento functionality to break up an order's items into shipments based on the "vendor" attribute! I'm struggling with this.

  • 1
    Magento's multishipping does this natively. Perhaps you can utilize the multishipping functionality without displaying it to the customer? – philwinkle Aug 20 '13 at 21:25
  • Off topic: Would you mind accepting answers on, or closing out, your old open questions? We're trying hard to get the answer rate up during beta. Thanks. – philwinkle Aug 20 '13 at 21:26
  • 1
    I'll look into both the multishipping and unaccepted answers now. Often, I haven't accepted because I moved on to something else and will come back to it. Nevertheless I will look and see if I missed some – CaitlinHavener Aug 20 '13 at 21:28
  • Another alternative is to implement something like Unirgy uDropship which also incorporates the vendor-type functionality that you're currently writing; but it gives vendors a portal for shipment, generates shipping labels and much more. I do not work for, and am not endorsed by Unirgy. – philwinkle Aug 20 '13 at 21:31
  • 1
    I don't want to use a dropship extension. There are many factors why I cannot. – CaitlinHavener Aug 20 '13 at 21:33
3
+50

Something to consider here is that you may only need to apply some cosmetic front-end changes to the multishipping templates (template/checkout/multishipping/) so that the two orders simply appear as one order to the customer. The shipping.phtml and overview.phtml templates split the two orders, each with a header (Address 1 of 2, etc) and other copy to show it is two orders.

Instead of the default, I might suggest being a little creative on these templates so that the two orders are simply split so they simply appear as two separate line items.

The next bit would be to handle different shipping origins based on the vendor attribute. This could maybe be done in Mage_Shipping_Model_Shipping. You can see right at the top is where Magento is grabbing the shipping origin address from the config and then further down in the requestToShipment() method, the origin address elements are assigned to the shipping request (which I assume would be used later depending on the shipping method called).

That might at least be a direction to head in. Reading over your question and your update I get the impression that you are making this more difficult than is necessary. Always remember that it is generally best to let Magento do what it wants to do, and only modify small bits to handle your specific cases. A majority of what you require is already done in core, so it seems a bit silly to rewrite the multi-shipping components when there may be simpler options.

  • How then would it calculate shipping for each shipment that is bundled by vendor attribute? – CaitlinHavener Aug 29 '13 at 17:27
  • The shipping calculations would not change, as Mage_Shipping_Model_Shipping would simply replace the origin address in the shipping request with the origin assigned to that vendor. Magento would then continue about its business and pull any shipping rates that would apply to that order. I could possibly see one of WebShopApps shipping modules being useful here, as it allows you to assign shipping methods based on various criteria. -- again, this is all in theory, I haven't done something like this before, so there may be some caveats (there always are). -- – pspahn Aug 29 '13 at 20:11
  • I'm checking out those webshopapp extensions. I think what I am at this moment confused by... is what class/method tells the Mage_Shipping_Model_Shipping class "hey here is an order and these are the items in it". Where can I find that? – CaitlinHavener Aug 29 '13 at 20:16
  • 1
    Have a look at /app/code/core/Mage/Sales/Model/Quote.php - Keep in mind that Magento isn't quite as linear as other shopping carts. Go down the rabbit hole and look how quotes are changed to orders (and credits, etc). At some point you'll find the method(s) you'd like to alter. Again, as I said previously, it is often beneficial to simply invest in a quality backend module (and just as importantly, the support) that will accomplish what you need quickly. Some nuts and bolts don't like being changed. – pspahn Sep 1 '13 at 2:20
  • If your avail for more details, please help! Thank you so much for the help here too. Your saving me! This is the hardest Magento project I've had to date! magento.stackexchange.com/questions/7635/… – CaitlinHavener Sep 6 '13 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.