public function updateOrderNotes($em, $order, $wcOrderNotes) { $timezone = new \DateTimeZone('UTC'); foreach ($wcOrderNotes as $note) { $orderComment = new OrderComments(); $orderComment->setWcId($note['id']); if ($note['customer_note']) { $orderComment->setComment($note['note'] . "-- Customer: " . $order->getCustomer()->getName()); } else { $orderComment->setComment($note['note']); } $orderComment->setCreatedAt(new \DateTime($note['created_at'], $timezone)); $order->addOrderComment($orderComment); } }
public function updateOrderNotes($em, $order, $wcOrderNotes) { $timezone = new \DateTimeZone('UTC'); foreach ($wcOrderNotes as $note) { $ExistingOrderComment = $em->getRepository('MeVisaERPBundle:OrderComments')->findOneBy(array('wcId' => $note['id'])); if (!$ExistingOrderComment) { $orderComment = new OrderComments(); $orderComment->setWcId($note['id']); if ($note['customer_note']) { $orderComment->setComment($note['note'] . "-- Customer: " . $order->getCustomer()->getName()); } else { $orderComment->setComment($note['note']); } $orderComment->setCreatedAt(new \DateTime($note['created_at'], $timezone)); $order->addOrderComment($orderComment); } } }