I would like to retain/restore cart items after order is placed & add them in cart for both Guest & Login user, how can I achieve this?

I am using Hosted Paypal, so when the user sees the reloaded frame, on refresh I want user to see the last items added in cart which got removed when user click on continue button of paypal.


In your events.xml add new observer sales_order_place_after

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_place_after">
        <observer name="refill_quote_items" instance="Vendor\Module\Observer\DataAssignObserver" />

in your observer file app\code\Vendor\Module\Observer\DataAssignObserver.php


namespace Venddor\Module\Observer;

class DataAssignObserver implements \Magento\Framework\Event\ObserverInterface
    protected $checkoutSession;
    public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession
        $this->checkoutSession = $checkoutSession;

    public function execute(\Magento\Framework\Event\Observer $observer)

        return $this;

I haven't tried this code, but logically it should be like this.

| improve this answer | |

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.