I'm trying to find a way to allow an order to be split for multiple shipping addresses, but to keep the charge to the customer as a one time payment rather than having to charge for each shipment separately. Is there a way to do this? Currently, customers are getting charged multiple times, corresponding to their "multiple orders", as magento splits the orders up into many smaller ones. This is a problem from the credit card company side since they are getting suspicious of so many consecutive charges to the card. Any ideas?
Well, I'm not going to be able to provide a full solution because to be honest, the solution would take quite a bit of time and testing but I'll give out comprehensive information that could you to the right direction instead.
Basically, upfront -- there isn't an option to do this in default Magento.
So instead, we are going to rewrite a certain model called Mage_Checkout_Model_Type_Multishipping
. If you're into the proper way of rewriting a model, please read this post by Inchoo.
But if you're lazy and looking into a quick way of rewriting, then please copy the whole file app/code/core/Mage/Checkout/Model/Type/Multishipping.php
to app/code/local/Mage/Checkout/Model/Type/Multishipping.php
Once you've finished either of the two above, you can move on to rewriting stuff we need into this class. Check out the function around line 498
:
public function createOrders()
{
$orderIds = array();
$this->_validate();
$shippingAddresses = $this->getQuote()->getAllShippingAddresses();
$orders = array();
if ($this->getQuote()->hasVirtualItems()) {
$shippingAddresses[] = $this->getQuote()->getBillingAddress();
}
try {
foreach ($shippingAddresses as $address) {
$order = $this->_prepareOrder($address);
$orders[] = $order;
....
}
foreach ($orders as $order) {
$order->place();
$order->save();
...
}
....
Mage::dispatchEvent('checkout_submit_all_after', array('orders' => $orders, 'quote' => $this->getQuote()));
return $this;
} catch (Exception $e) {
Mage::dispatchEvent('checkout_multishipping_refund_all', array('orders' => $orders));
throw $e;
}
}
So we can clearly see here that it's trying to create an order for each address and then (the most important part), triggering the checkout_submit_all_after
event which is monitored by the payment modules (order and quote information are passed to all of the available/active payment modules and the payment method set inside the quote will determine if a certain payment module receiving the dispatched event can process it or not).
With that in mind, you can have a couple of options now:
1.) if you can live with just one order, then try and rewrite the createOrders
routine to just combine all items again into one order, ->place()
it, then pass into dispatchEvent for good measure.
2.) if you need multiple orders, well -- this is where it becomes convoluted as there's a slim chance that you can do either of the following:
So yeah, you guys are pretty much asking for a lot here so the best I can do is to shed some light on where you can first do serious damage. I'd do it myself, but it's above my pay-grade here.
Some additional pointers:
Good luck!
Make sure this option is enabled:
If I'm not mistaken, when customer clicks one page checkout button, ship to multiple adresses option wouldn't be shown to him. But if he clicks on main checkout button it would.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With