Question

im building a small store using opencart. i currently allow only 1 product to be added to the cart, so when a user adds different products it replaces with the new product. but allows to change the quantity of that product.

what i need to do is once a person has successfully purchased an item with a quantity of eg; 3 the product needs to be saved as 3 different orders.

is this possible to do in OC? if yes can someone please guide me how to do it?

Was it helpful?

Solution

The solution is quite simple - when creating and confirming order instead of creating one order for a product with quantity XYZ, do a loop and store XYZ orders for just one product quantity.

Basically You'll be changing mostly catalog/model/checkout/order.php::addOrder() - here the loop will take place basically around the whole function body, e.g.:

for ($i = 0; $i < $data['products'][0]['quantity']; $i++) {
   // the rest of the method, but removing
   // foreach ($data['products'] as $product) - this is not needed anymore
}

Also return an array of newly created order IDs so that you can confirm them afterwards...

Then You'll need to modify all the used payment controllers as these are confirming order - You'll need to change them to confirm all of the orders (which IDs You have returned when adding them - they may be stored in a session).

Though it may take some time (depending on how many payment options You use) it is not that difficult.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top