| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
how to update an order with tracking number programatically? | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() we are trying to update the orders with tracking number programmatically.
here is the order that we are using update shipping method update tracking number change shippingstatus pls see code below after we run this code - order updating sucessfully - but the shipping email we get do not have a linkg to track the order. the email has only tracking number with no link. Can someone help us to do it properly so we gwt a notification email with tracking link what is the order of events we have to follow is there a specific property that we have to update ? any specific API that should be used? in what conditions the tracking link gets into the email? // ------------------------------------------------------------- // UPDATE SHIPPING ID/ METHOD ID TO ORDER $model = \XLite\Core\Database::getRepo('XLite\Model\Shippin g\Method'); $qb = $model->createQueryBuilder(); $qb ->select('m.method_id') ->andWhere('translations.name = :name') ->andWhere('m.processor = :processor') ->setParameter('name', $carrier_subcode) ->setParameter('processor', $carrier_code); $methodId = $qb->getSingleScalarResult(); if ($methodId) : $this->_print($orderId . ': Shipping method id found ' . $methodId); $order->setLastShippingId($methodId); $order->setShippingId($methodId); $order->setShippingMethodName($carrier_subcode); else : $this->_print($orderId . ': Shipping method Id not found from carrier subcode: ' . $carrier_code); endif; \XLite\Core\Database::getEM()->persist($order); // ================================================== =========== // ----------------------------------------------------------------- // UPDATE TRACKING NUMBER // ================================================== =============== //var_dump($new_tracking_number); $order = $orderModel->findOneByOrderNumber($orderId); // findOneByOrderNumber foreach ($order->getTrackingNumbers() as $number) { //var_dump($number->getValue()); if ($new_tracking_number === $number->getValue()) { $trackingObject = $number; $this->_print($orderId . ': tracking number ' . $new_tracking_number . ' exists.'); break; } } if ($trackingObject) : //$trackingObject->setTrackingId($new_tracking_number); $trackingObject->setValue($new_tracking_number); $this->_print($orderId . ': setting up tracking number ' . $new_tracking_number); \XLite\Core\Database::getEM()->persist($trackingObject); else : $trackingObject = new XLite\Model\OrderTrackingNumber(); $trackingObject->setValue($new_tracking_number); $trackingObject->setOrder($order); $this->_print($orderId . ': new tracking number ' . $new_tracking_number . ''); \XLite\Core\Database::getEM()->persist($trackingObject); $this->_print($orderId . ': saved'); $order->addTrackingNumbers($trackingObject); \XLite\Core\Database::getEM()->persist($order); $this->_print($orderId . ': saved new tracking to order'); endif; // ----------------------------------------------------------------- // UPDATE SHIPPING STATUS // ================================================== =============== $order = $orderModel->findOneByOrderNumber($orderId); // findOneByOrderNumber $order->setShippingStatus(\XLite\Model\Order\Status\Shipp ing::STATUS_SHIPPED); $this->_print($orderId . ': shipping status is set to shipped'); \XLite\Core\Database::getEM()->persist($order); //\XLite\Core\Database::getEM()->persist($order); //\XLite\Core\Database::getEM()->persist($trackingObject); \XLite\Core\Database::getEM()->flush(); $this->_print($orderId . ': imported '); $this->xmllog->log($orderId, "success", ""); /* } catch (Exception $ex) { $this->_print($ex->getMessage()); $this->xmllog->log($orderNumber, "error", $ex->getMessage()); //continue; } */ unset($order); } //Next order to process for tracking.. //\XLite\Core\Database::getEM()->flush(); //\XLite\Core\Database::getEM()->clear(); }
__________________
ira |
|||||||
|
|||
X-Cart forums © 2001-2020
|