1

I have added an extra column, by using custom module (upgradeScheme), into the table quote. How can I save my custom value into this column when quote is created? The value I want to add to this extra column can I get from the session. I just don't know how I can save this value into the quote. Please give a step by step instruction.

If I sum up my situation, it would be,

  1. I have added an extra column in the table quote.
  2. I can get the value I want to add to the custom column from session.
  3. I know how to convert/copy data from Quote to Order.
  4. I don't know how to save my custom value to the extra column I created in Quote.
2

You can Use Event checkout_cart_product_add_after.

in your frontend/events.xml

<event name="checkout_cart_product_add_after">
        <observer name="after_add_to_cart" instance="your\module\Observer\AddToCartAfter" />
</event>

in observer file AddToCartAfter.php

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

    $quoteItem = ( $quoteItem->getParentItem() ? $quoteItem->getParentItem() : $quoteItem );

    $quoteItem->setCustomField("Custom Value");
    //here u set value of your field of quote

}
  • i want save custom value for quote_item table – Hitesh Balpande Jun 10 at 14:33
  • If you have any idea please guide me – Hitesh Balpande Jun 10 at 14:34
  • 1
    You can follow my answer for that. – Rizwan Khan Jun 12 at 3:04

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.