Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. foreach($items as $item){
  2.  
  3. if($item->getParentItemId() == '' || $item->getParentItemId() == null){
  4.  
  5. $product_id = $item->getProductId();
  6. if($product_id == $booking_product_id){
  7.  
  8. // this item have to be deleted
  9.  
  10. }
  11.  
  12. }
  13.  
  14. }
  15.  
  16. $base_grand_total = $order->getBaseGrandTotal();
  17. $base_subtotal = $order->getBaseSubtotal();
  18. $grand_total = $order->getGrandTotal();
  19. $subtotal = $order->getSubtotal();
  20.  
  21. $base_subtotal_incl_tax = $order->getBaseSubtotalInclTax();
  22. $subtotal_incl_tax = $order->getSubtotalInclTax();
  23. $total_item_count = $order->getTotalItemCount();
  24.  
  25. $items = $order->getAllItems();
  26. foreach($items as $item){
  27.  
  28. if($item->getParentItemId() == '' || $item->getParentItemId() == null){
  29.  
  30. $product_id = $item->getProductId();
  31. if($product_id == $booking_product_id){
  32.  
  33. //remove item price from total price of order
  34. $item_price = $item->getPrice();
  35. $item->delete();
  36.  
  37. $order->setBaseGrandTotal($base_grand_total-$item_price);
  38. $order->setBaseSubtotal($base_subtotal-$item_price);
  39. $order->setGrandTotal($grand_total-$item_price);
  40. $order->setSubtotal($subtotal-$item_price);
  41.  
  42. $order->setBaseSubtotalInclTax($base_subtotal_incl_tax-$item_price);
  43. $order->setSubtotalInclTax($subtotal_incl_tax-$item_price);
  44. $order->setTotalItemCount($total_item_count-1);
  45. $order->save();
  46. }
  47.  
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement