예제 #1
0
 public function add()
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required|unique:{$this->table}', 'content' => 'required|min:100', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/{$this->name}/{$this->action}")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new ShopOrder();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = Input::get('content');
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = ShopOrder::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['name' => $this->name, 'action' => $this->action]);
 }
예제 #2
0
 function calculate($shippingMethod)
 {
     try {
         $this->Price = parent::calculate($shippingMethod);
     } catch (Exception $e) {
         ShopOrder::displayExtensionNoticeFor("ShopShipping::calculate");
     }
 }
예제 #3
0
 function isComplete()
 {
     //define your own isComplete rules with MyShopAddress.php
     try {
         return parent::isComplete();
     } catch (Exception $e) {
         //no extension found
         ShopOrder::displayExtensionNoticeFor("ShopAddress::isComplete");
         foreach (self::$required_fields as $field) {
             if (!(strlen($this->{$field}) > 0)) {
                 return false;
             }
         }
         return true;
     }
 }
예제 #4
0
 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;
 }
예제 #5
0
 function add()
 {
     if ($id = Director::urlParam("ID")) {
         $quantity = Director::urlParam("OtherID") ? (int) Director::urlParam("OtherID") : 1;
         if ($item = DataObject::get_by_id("ShopItem", $id)) {
             if ($item->StockQuantity >= 0) {
                 if ($item->StockQuantity - $quantity < 0) {
                     exit(_t("Shop.OutOfStock", "%Out Of Stock%"));
                 }
             }
         }
         $optionID = isset($_REQUEST['optionid']) ? (int) $_REQUEST['optionid'] : null;
         if (ShopOrder::addItem((int) $id, $quantity, $optionID)) {
             $this->Message = "OK";
             return array();
         }
     }
 }
예제 #6
0
 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;
 }
예제 #7
0
 function VATType()
 {
     //if items is set to INHERIT returns the (global) default value set in ShopOrder
     return $this->VAT == "INHERIT" ? ShopOrder::getVATType() : $this->VAT;
 }
예제 #8
0
<?php

// ShopOrder::$currency = array(
// 	"de_DE"=>"EUR"
// );
// ShopOrder::$currencyDefault = "EUR";
// ShopOrder::$vatType = "EXCL";
// ShopOrder::$tax = array(
// 	"de_DE"=>"19"
// 	);
// ShopOrder::$taxDefault = 0;
// ShopPayment::$priceInMethods = false;
// ShopShipping::$priceInMethods = true;
// ShopCheckoutPage::$termsAndConditionsAgreementRequired = true;
// ShopOrder::$emailUserAccount="shop@127.0.0.1";
// ShopOrder::$emailOrderConfirmation="shop@127.0.0.1";
const SHOPSYSTEM_DIR = "shopsystem";
const SHOPUSER_PATH = "user";
Director::addRules(100, array('order/$Action/$ID/$OtherID' => 'ShopOrder_Controller', 'cart/$Action/$ID/$OtherID' => 'ShopCart_Controller', 'invoice/$Action/$ID/$OtherID' => 'ShopInvoice_Controller', SHOPUSER_PATH . '/$Action/$ID/$OtherID/$Filename' => 'ShopUser_Controller'));
Object::add_extension("Float", "FloatExtension");
Object::add_extension("Int", "IntExtension");
//optional
ShopOrder::dontDisplayExtensionNotice();
// Object::add_extension("ShopOrder", "MyShopOrder");
// Object::add_extension("ShopPayment", "MyShopPayment");
// Object::add_extension("ShopShipping", "MyShopShipping");
// Object::add_extension("ShopItem", "MyShopItem");
// Object::add_extension("ShopAddress", "MyShopAddress");
// Object::add_extension("ShopClient", "MyShopClient");
예제 #9
0
 private static function setCheckoutStep($value)
 {
     if ($value == 0) {
         $value = "0";
     }
     Session::set('Shop.CheckoutStep.' . ShopOrder::orderSession()->Hash, (int) $value);
     return (int) $value;
 }
예제 #10
0
 function add($request = null, $id = null)
 {
     if (!$id) {
         $id = Director::urlParam("ID");
     }
     if ($id) {
         if (isset($_REQUEST['quantity'])) {
             $quantity = (int) $_REQUEST['quantity'];
         }
         $item = ShopOrder::addItem($id, $quantity);
         if (isset($_REQUEST['ref'])) {
             if ($_REQUEST['ref'] == "item") {
                 //redirect to product page
                 Director::redirect($item->OriginalItem->Link());
             }
         }
     }
 }
예제 #11
0
 function VAT()
 {
     return ShopOrder::getVATType();
 }