/** * productPrice * Price to display in the GridField * * @return float The product price. */ public function productPrice() { /* Discounted CSS Class */ $discounted = $this->Discounted != 0 ? "GridFieldSaleNewPrice" : ""; /* Price of the Product * Quantity */ $price = StoreCurrency::convertToCurrency($this->Price * $this->Quantity); /* Field to Create */ $text = LiteralField::create($title = "Price", ""); $text->setValue("<span class='{$discounted}'>" . Product::getDefaultCurrency() . $price . "</span>"); return $text; }
/** * calculateRemainingBalance * Calculate Remaining Order Balance (Totals - Payment Total) * * @return float */ public function calculateRemainingBalance() { return StoreCurrency::convertToCurrency($this->calculateOrderTotal() - $this->calculatePaymentTotal()); }
public function customerOrderStatusUpdate($order_no, $status, $override = false) { //Get Store Settings $settings = StoreSettings::get_settings(); //Get the details of both the order, the customer who placed it and the status $order = DataObject::get_by_id("Order", $order_no); $customer = DataObject::get_by_id("Customer", $order->CustomerID); $status = DataObject::get_one("Order_Statuses", "(`SystemTitle`='" . $status . "')"); /** * If override is set, set the send flag to true. * Otherwise, check the store notification settings tpo * see if we're allowed to send this status update email. */ if ($override) { $send = true; } else { //Convert store notification settings to array $enabled_statuses = explode(",", $settings->EmailNotification_OrderStatuses); //Is the new status in this array, if yes, send send to true. $send = in_array($status->ID, $enabled_statuses) ? true : false; } /** * If $send is equal to true send the email notification. */ if ($send) { //Send The Email $email = new Email(); $email->setFrom($settings->EmailNotification_SendEmailsFrom)->setTo($customer->Email)->setSubject('Order [' . $order_no . '] has been updated')->setTemplate('Email_Order_StatusUpdate')->populateTemplate(new ArrayData(array('StoreName' => $settings->StoreSettings_StoreName, 'Customer' => $customer, 'Order' => $order, 'OrderStatus' => $status, 'OrderLink' => '', 'OrderItems' => DataObject::get("Order_Items", "(`OrderID`='" . $order->ID . "')"), 'OrderCourier' => DataObject::get_one("Courier", "(`id`='" . $order->Courier . "')")->Title, 'OrderTrackingNo' => $order->TrackingNo ? $order->TrackingNo : "No tracking number provided for this order", 'ProductTax' => StoreCurrency::convertToCurrency($order->calculateProductTax(1) + $order->calculateProductTax(2)), 'BillingAddress' => DataObject::get_one("Customer_AddressBook", "(`id`='" . $order->BillingAddressID . "')"), 'ShippingAddress' => DataObject::get_one("Customer_AddressBook", "(`id`='" . $order->BillingAddressID . "')"), 'CurrencySymbol' => Product::getDefaultCurrency()))); $email->send(); //Store the email in the order email log $this->SentTo = $customer->Email . " (CUSTOMER)"; $this->Subject = 'Order [' . $order_no . '] has been updated'; $this->Body = $email->body; $this->OrderID = $order_no; $this->write(); return true; } else { return false; } }