Skip to content

Create order for bundle product with custom Price as parent price Magento2 Programatically

I have a requirement in magento2.4.6 as we know when we create a order for bundle product order price is calculated based on child product price, Here i need to add a custom price for the Bundle parent product(that i have added using catalog eav attribute) and when we create an order with this product the calculation should take place with this custom price no need to consider the child product price i have write the code to create order but cant replace the bundle cart price with custom price

foreach($orderData['items'] as $item){
            if (isset($item['bundle_options'])) {
                $product = $this->productRepository->getById($item['product_id']);
                $params = [
                    'product' => $item['product_id'],
                    'bundle_option' => $item['bundle_options'],
                    'qty' => $item['qty']
                ];
                $this->cart->addProduct($product,$params);
            }
            $cart = $this->cart->save();
            $quoteId = $cart->getQuote()->getId();
        }

Can anyone Help me on this