0

In my current magento shop project each product has a single validity_date as additional attribute, which will get set while product creation.

As a customer you can fill in your cart with different products and when you want to buy them, it should create not a single order with all products. It should create an order for each day.

I would like to know now what event is best to cancel the order and create instead of it several ones. Also how can I delete the old order? And is there a way to duplicate the order object and just change the products of it?

1 Answer 1

1

The event you are looking for is

checkout_submit_all_after

Here you have:

public function checkoutSubmitAfter($observer)
{

    $event = $observer->getEvent();
    $quote = $event->getQuote();
    $quote_id = $quote->getId();
    $order = $event->getOrder();

    //add here your logic to create new orders from current order products..
}

$quote_items = $quote->getAllItems();

Starting here you can create a function to create custom orders for each product, and remove products from your initial order. No point in deleting the entire order, just consider that your first order..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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