0
public function aroundAddOrderItem(CheckoutCart $subject,
    \Closure $proceed,
    $item,
    $qtyFlag = null,
    $data = []
) {
    // Get Order Item
    $orderItem = $proceed($item, $data);
    if ($item->getParentItem() === null) {
        $storeId = $this->_storeManager->getStore()->getId();
        try {
            /**
             * We need to reload product in this place, because products
             * with the same id may have different sets of order attributes.
             */
            $product = $this->productRepository->getById($item->getProductId(), false, $storeId, true);
        } catch (NoSuchEntityException $e) {
            return $this;
        }


        $info = $item->getProductOptionByCode('info_buyRequest');

        $info = new \Magento\Framework\DataObject($info);
        if ($qtyFlag === null) {
            $info->setQty($item->getQtyOrdered());
        } else {
            $info->setQty(1);
        }
        $price = $item->getPrice(); 
        $product->setPrice($price);
        $product->setBasePrice($price);
        $product->addCustomOption('additional_options', $this->serializer->serialize($item->getProductOptionByCode('additional_options'))); 
        $subject->addProduct($product, $info);
    }
    return $this;
}

I added a function like this it add a custom options in Reorder Item. But another product added without additional option.How to overcome that

2
  • Hi! Do you want to add some product with custom option INSTEAD of product customer is adding to the cart or just add custom option to product customer adds? Your change should be fired for every product? – dudzio Jun 16 at 17:52
  • When I reorder the product it not show the additional options that I already selected. That's why I used like this.How to show additional options that I already selected when reorder. Kindly help t solve – Akshaya venkat Jun 17 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.