Source of file OrderStepFeefo.php
Size: 3,174 Bytes - Last Modified: 2021-12-23T10:40:59+00:00
/var/www/docs.ssmods.com/process/src/code/model/process/OrderStepFeefo.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 | <?php class OrderStepFeefo extends OrderStep { /** * The OrderStatusLog that is relevant to the particular step. * * @var string */ protected $relevantLogEntryClassName = 'OrderStatusLog_FeefoLog'; private static $db = array( 'SendData' => 'Boolean', 'FeedbackDelay' => 'Int' ); private static $defaults = array( 'CustomerCanEdit' => 0, 'CustomerCanCancel' => 0, 'CustomerCanPay' => 0, 'Name' => 'Send Order To Feefo', 'Code' => 'FEEFO', "ShowAsInProcessOrder" => true, "HideStepFromCustomer" => true ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('FeedbackDelay'); $fields->addFieldsToTab( 'Root.Feefo', [ CheckboxField::create( 'SendData', 'Send Data' )->setDescription('If checked then the order data will be sent to Feefo, once this order step is reached.'), NumericField::create( 'FeedbackDelay', 'Feedback Delay' )->setRightTitle('The amount of after the order has been sent before Feefo should send the feedback request email.') ] ); return $fields; } public function initStep(Order $order) { return true; } public function doStep(Order $order) { if ($this->SendData && $order->IsPaid()) { $api = Injector::inst()->get('EntersaleremotelyAPIConnector'); $result = $api->sendOrderDataToFeefo($order, $this->FeedbackDelay); $result = $this->convertArrayToHTMLList($result); $className = $this->getRelevantLogEntryClassName(); if (class_exists($className)) { $obj = $className::create(); if (is_a($obj, Object::getCustomClass('OrderStatusLog'))) { $obj->OrderID = $order->ID; $obj->Title = $this->Name; $obj->DetailedInfo = $result; $obj->write(); } } } return true; } /** * can continue if emails has been sent or if there is no need to send a receipt. * @param DataObject $order Order * @return DataObject | Null - DataObject = next OrderStep **/ public function nextStep(Order $order) { return parent::nextStep($order); } /** * For some ordersteps this returns true... * @return Boolean **/ protected function hasCustomerMessage() { return false; } /** * Explains the current order step. * @return String */ protected function myDescription() { return "The customer and order data is sent to Feefo via the Entersaleremotely API."; } public function convertArrayToHTMLList($array) { $html = '<ul>'; foreach ($array as $arrayItem) { $html .= '<li>' . $arrayItem . '</li>'; } $html .= '</ul>'; return $html; } } |