Order split with online transaction on checkout in magento 2.4 enterprise

Order split with online transaction on checkout in magento 2.4 enterprise

August 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Order split with online transaction on checkout in magento 2.4 enterprise

Splitting Orders with Online Transactions on Checkout in Magento 2.4 Enterprise

You’re facing an issue while trying to split orders during checkout in Magento 2.4 Enterprise edition, specifically when using online payment methods like credit cards. You’ve explored solutions involving offline payment methods such as check/mo and Cash on delivery, which work fine for order splitting.

However, you’re encountering errors or unexpected behavior when attempting to split orders with the ‘nmi_directpost’ (credit card) payment method. Let’s troubleshoot this issue step by step.

Identifying the Problem

The core of your problem lies in properly associating the credit card details with the split quotes during the order placement process. In your current implementation, you’re attempting to assign the payment method and card details manually, which is not being handled correctly.

Understanding the Magento Checkout Process

When a customer checks out, Magento first creates new child quotes from the original quote for each item in the cart that needs to be split. These child quotes are then processed individually as separate orders.

The key here is that each child quote must have its own payment method and associated card details before being submitted for order placement.

Correcting the Payment Method Assignment

Here’s how you can correct this:

  1. Capture the Original Quote’s Payment Method: Instead of manually setting the payment method to ‘nmi_directpost’, capture the original payment method from the active quote using $quote->getPayment()->getMethod().

  2. Transfer Payment Details to the Split Quotes: After separating items into new quotes, transfer the necessary payment details (including card information) from the original quote to each split quote.

Here’s an example of how you can modify your aroundPlaceOrder function:

public function aroundPlaceOrder(QuoteManagement $subject, callable $proceed, $cartId, $payment = null)
{
    // ... (existing code for separating items and creating new quotes)

    foreach ($quotes as $items) {
        /** @var \Magento\Quote\Model\Quote $split */
        $split = $this->quoteFactory->create();

        // Set all customer definition data.
        $this->quoteHandler->setCustomerData($currentQuote, $split);
        $this->toSaveQuote($split);

        // Map quote items (existing code remains the same)

        // Capture original payment method
        $originalPaymentMethod = $currentQuote->getPayment()->getMethod();

        // Transfer payment details to split quote
        $split->getPayment()->setMethod($originalPaymentMethod);
        $split->getPayment()->importData($currentQuote->getPayment()->getData());

        $this->quoteHandler->populateQuote($quotes, $split, $items, $addresses, $payment);

        // ... (remaining code for order placement and event dispatching)
    }
}

Ensuring Successful Order Placement

After making these changes:

  1. The split quotes will now have the correct payment method (in this case, ‘nmi_directpost’) assigned to them.
  2. The associated card details from the original quote are transferred to each new child quote.

When you call submit($split), Magento should successfully process the order with the credit card payment for each split quote without encountering any validation errors or redirection issues.

Conclusion

Splitting orders in Magento 2.4 Enterprise with online transactions requires careful handling of payment methods and associated card details during the checkout process.

By correctly capturing the original payment method from the active quote and transferring it (along with necessary data) to each split quote, you can ensure that the order placement process works seamlessly for both offline and online payment methods.

Remember to thoroughly test this implementation in a development environment before deploying changes to your live Magento site.

Magento 2 Checkout Configuration Orders

Our network