Hello.
configurable product generates 2 lines : one with the actual price and the other one with $0 price. this happens 1-2 out of 100 orders.
Can anyone help me with this duplicate issue? Thank you in advance.
By default this shouldn't happen.
It's true that when you add one configurable product to the cart there are actually 2 lines in there. One for the simple product and one for the configurable itself. These 2 lines are carried to the order and then invoice, shipping and credit memo, but only one of them should be visible.
Here is how the core code for the invoice items pdf looks like:
foreach ($invoice->getAllItems() as $item){
if ($item->getOrderItem()->getParentItem()) {
continue;
}
/* Draw item */
$this->_drawItem($item, $page, $order);
$page = end($pdf->pages);
}
The if
statement prevents the row with the price 0 from being shown.
Your problem might appear when the if
condition returns false or if you have a custom module installed that might affect the order or the invoice process.
If you don't have a specific scenario to reproduce this every time, I'm afraid no one may be able to answer this.
Take this. It might help
The best way:
$products = $request->getAllItems();
foreach($products as $product){
if ($product->getParentItem()) {
continue;
}
//more code here!
}