static function methodFields() { //generate a select field from all enum values $shippingMethods = singleton("ShopShipping")->dbObject('Method')->enumValues(); $order = ShopOrder::orderSession(); $ship = array(); //fw $ship = array("Standard" => "Standardversand (" . $order->shippingCosts("Standard") . " " . ShopOrder::getLocalCurrency() . ")"); return $ship; //fw foreach ($shippingMethods as $name => $value) { $price = ShopShipping::$priceInMethods ? " (" . $order->calcShippingCosts($name) . " " . ShopOrder::getLocalCurrency() . ")" : ""; $ship[$name] = _t("Shop.Shipping.{$value}", "%{$value}%") . $price; } return $ship; }
static function methodFields() { //generate a select field from all enum values $paymentMethods = singleton("ShopPayment")->dbObject('Method')->enumValues(); $order = ShopOrder::orderSession(); $pay = array(); //fw $pay = array("Prepayment" => "Vorkasse (Pflichtfeld außer bei DE)"); if (strtoupper($order->InvoiceAddress()->Country) == "DE") { $pay = array_merge($pay, array("Invoice" => "Auf Rechnung")); } return $pay; //fw foreach ($paymentMethods as $name => $value) { $price = ShopPayment::$priceInMethods ? " (" . $order->calcPaymentCosts($name) . " " . ShopOrder::getLocalCurrency() . ")" : ""; $pay[$name] = _t("Shop.Payment.{$value}", "%{$value}%") . $price; } return $pay; }
private static function setCheckoutStep($value) { if ($value == 0) { $value = "0"; } Session::set('Shop.CheckoutStep.' . ShopOrder::orderSession()->Hash, (int) $value); return (int) $value; }
static function addItem($id, $quantity = 1, $optionID = null) { $id = (int) $id; if ($item = DataObject::get_by_id("ShopItem", $id)) { //select first option, if none option is selected if ($item->Options()->Count() && $optionID == null) { $optionID = $item->Options() ? $item->Options()->First()->ID : (int) $optionID; } $optionSQL = $optionID > 0 ? " AND OptionID = {$optionID} " : ""; //map item to orderitem, similar to a quick snapshot of the soled item for later $orderSession = self::orderSession(); if (!($orderItem = DataObject::get_one("ShopOrderItem", "OrderID = " . $orderSession->ID . " AND OriginalItemID = " . $item->ID . " " . $optionSQL))) { $orderItem = new ShopOrderItem(); } if ($orderSession->Status == "Unsubmitted") { $orderItem->Version = $item->Version; $orderItem->Price = $item->Price; $orderItem->Title = $item->Title; $orderItem->ProductKey = $item->ProductKey; $orderItem->Currency = $item->Currency; $orderItem->Quantity = $orderItem->Quantity + $quantity; $orderItem->OriginalItemID = $item->ID; $orderItem->OriginalItem = $item; $orderItem->OrderID = ShopOrder::orderSession()->ID; $orderItem->VAT = $item->VATType(); //if option is selected if ($optionID) { foreach ($item->Options() as $option) { $optionFound = true; if ($option->ID == $optionID) { //if option belongs to item, add option $orderItem->OptionID = $option->ID; } } if (!$optionFound) { $orderItem->OptionID = $item->Options()->First()->ID; } } if ($orderItem->Quantity < 1) { $orderItem->Quantity = 0; } $orderItem->write(); return $orderItem; } else { user_error("You are not allowed to change an already submitted order."); } } }
function Cart() { return ShopOrder::orderSession(); }