Is it possible that we can change product type in quote. We dont want to change product type in database but only for specific quote. When user add any configurable product to cart then based on some conditions (we will define them in event) we will flip product type from configurable physical to virtual.

  • I think it can be done, as far as i remember quote and quote_item have is_virtual field in case quote has virtual products. Try to set this field as true in both tables. – Ramkishan Suthar Jan 22 '19 at 17:43

You need to create Observer to update product type. If you have created module then Mageseller/UpdateProduct/etc/event.xml

<?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="checkout_cart_product_add_after">
        <observer name="custom_update_product_type" instance="Mageseller\UpdateProduct\Observer\UpdateProductType" />

Now create below file Mageseller/UpdateProduct/Observer/UpdateProductType.php in Observer folder.

    namespace Mageseller\UpdateProduct\Observer;

    use Magento\Framework\Event\ObserverInterface;
    use Magento\Framework\App\RequestInterface;

    class UpdateProductType implements ObserverInterface
        public function execute(\Magento\Framework\Event\Observer $observer) {
            $item = $observer->getEvent()->getData('quote_item');         
            $item = ( $item->getParentItem() ? $item->getParentItem() : $item );
            $productType = 'virtual'; //set your price here
            // condition starts
            // condition ends

| 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.