Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach($items as $item){
- if($item->getParentItemId() == '' || $item->getParentItemId() == null){
- $product_id = $item->getProductId();
- if($product_id == $booking_product_id){
- // this item have to be deleted
- }
- }
- }
- $base_grand_total = $order->getBaseGrandTotal();
- $base_subtotal = $order->getBaseSubtotal();
- $grand_total = $order->getGrandTotal();
- $subtotal = $order->getSubtotal();
- $base_subtotal_incl_tax = $order->getBaseSubtotalInclTax();
- $subtotal_incl_tax = $order->getSubtotalInclTax();
- $total_item_count = $order->getTotalItemCount();
- $items = $order->getAllItems();
- foreach($items as $item){
- if($item->getParentItemId() == '' || $item->getParentItemId() == null){
- $product_id = $item->getProductId();
- if($product_id == $booking_product_id){
- //remove item price from total price of order
- $item_price = $item->getPrice();
- $item->delete();
- $order->setBaseGrandTotal($base_grand_total-$item_price);
- $order->setBaseSubtotal($base_subtotal-$item_price);
- $order->setGrandTotal($grand_total-$item_price);
- $order->setSubtotal($subtotal-$item_price);
- $order->setBaseSubtotalInclTax($base_subtotal_incl_tax-$item_price);
- $order->setSubtotalInclTax($subtotal_incl_tax-$item_price);
- $order->setTotalItemCount($total_item_count-1);
- $order->save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement