当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::get_by_id_if_can_view方法代码示例

本文整理汇总了PHP中Order::get_by_id_if_can_view方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::get_by_id_if_can_view方法的具体用法?PHP Order::get_by_id_if_can_view怎么用?PHP Order::get_by_id_if_can_view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order::get_by_id_if_can_view方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dopayment

 function dopayment($data, $form)
 {
     $SQLData = Convert::raw2sql($data);
     if (isset($SQLData['OrderID'])) {
         if ($orderID = intval($SQLData['OrderID'])) {
             $order = Order::get_by_id_if_can_view($orderID);
             if ($order && $order->canPay()) {
                 if (EcommercePayment::validate_payment($order, $form, $data)) {
                     $payment = EcommercePayment::process_payment_form_and_return_next_step($order, $form, $data);
                 }
                 if ($payment) {
                     ShoppingCart::singleton()->submit();
                     $order->tryToFinaliseOrder();
                     return $payment;
                 } else {
                     //error messages are set in validation
                     return $this->controller->redirectBack();
                 }
             } else {
                 $form->sessionMessage(_t('OrderForm.NO_PAYMENTS_CAN_BE_MADE_FOR_THIS_ORDER', 'No payments can be made for this order.'), 'bad');
                 return $this->controller->redirectBack();
             }
         }
     }
     $form->sessionMessage(_t('OrderForm.COULDNOTPROCESSPAYMENT', 'Sorry, we could not find the Order for payment.'), 'bad');
     $this->controller->redirectBack();
     return false;
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce,代码行数:28,代码来源:OrderForm_Payment.php

示例2: init

 function init()
 {
     parent::init();
     Requirements::themedCSS("typography");
     Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js");
     //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
     $id = intval($this->request->param("ID"));
     if (!$id && isset($_REQUEST["OrderID"])) {
         $id = intval($_REQUEST["OrderID"]);
     }
     if ($id) {
         $order = Order::get_by_id_if_can_view($id);
         if ($order) {
             $this->currentOrder = $order;
         }
     }
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:18,代码来源:EcommercePaymentController.php

示例3: dopayment

 function dopayment($data, $form)
 {
     $SQLData = Convert::raw2sql($data);
     if (isset($SQLData['OrderID'])) {
         if ($orderID = intval($SQLData['OrderID'])) {
             $order = Order::get_by_id_if_can_view($orderID);
             if ($order && $order->canPay()) {
                 return EcommercePayment::process_payment_form_and_return_next_step($order, $form, $data);
             }
         }
     }
     $form->sessionMessage(_t('OrderForm.COULDNOTPROCESSPAYMENT', 'Sorry, we could not process your payment.'), 'bad');
     Director::redirectBack();
     return false;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:15,代码来源:OrderForm.php

示例4: copyorder

 function copyorder($request)
 {
     $orderID = intval($request->param('ID'));
     if ($order = Order::get_by_id_if_can_view($orderID)) {
         $this->cart->copyOrder($order);
     }
     $this->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:8,代码来源:ShoppingCart_Controller.php

示例5: __construct

 public function __construct($controller, $name, $repeatOrderID = 0, $originatingOrder = 0)
 {
     $order = null;
     //create vs edit
     if ($repeatOrderID) {
         $repeatOrder = DataObject::get_by_id('RepeatOrder', $repeatOrderID);
         $items = $repeatOrder->OrderItems();
     } else {
         $repeatOrder = null;
         if ($originatingOrder) {
             $order = Order::get_by_id_if_can_view($originatingOrder);
         }
         if (!$order) {
             $order = ShoppingCart::current_order();
         }
         if ($order) {
             $items = $order->Items();
         } else {
             $items = null;
         }
     }
     //build fields
     $fields = new FieldSet();
     //products!
     if ($items) {
         $fields->push(new HeaderField('ProductsHeader', 'Products'));
         $products = DataObject::get('Product', "\"AllowPurchase\" = 1");
         $productsMap = $products->map('ID', 'Title');
         $this->array_unshift_assoc($productsMap, 0, "--- Please select ---");
         foreach ($productsMap as $id => $title) {
             if ($product = DataObject::get_by_id("Product", $id)) {
                 if (!$product->canPurchase()) {
                     unset($productsMap[$id]);
                 }
             }
         }
         $j = 0;
         foreach ($items as $key => $item) {
             $j++;
             $alternativeItemsMap = $productsMap;
             $defaultProductID = $item->ProductID ? $item->ProductID : $item->BuyableID;
             $itemID = $defaultProductID;
             unset($alternativeItemsMap[$defaultProductID]);
             $fields->push(new DropdownField('Product[ID][' . $itemID . ']', "Preferred Product #{$j}", $productsMap, $defaultProductID));
             $fields->push(new NumericField('Product[Quantity][' . $itemID . ']', " ... quantity", $item->Quantity));
             for ($i = 1; $i < 6; $i++) {
                 $alternativeField = "Alternative" . $i . "ID";
                 $fields->push(new DropdownField('Product[' . $alternativeField . '][' . $itemID . ']', " ... alternative {$i}", $alternativeItemsMap, isset($item->{$alternativeField}) ? $item->{$alternativeField} : 0));
             }
         }
     } else {
         $fields->push(new HeaderField('items', 'There are no products in this repeating order'));
     }
     //other details
     $fields->push(new HeaderField('DetailsHeader', 'Repeat Order Details'));
     $fields->push(new ListboxField('PaymentMethod', 'Payment Method', RepeatOrder::get_payment_methods(), null, count(RepeatOrder::get_payment_methods())));
     $startField = new DateField('Start', 'Start Date');
     $startField->setConfig('showcalendar', true);
     $fields->push($startField);
     $endField = new DateField('End', 'End Date');
     $endField->setConfig('showcalendar', true);
     $fields->push($endField);
     $fields->push(new ListboxField('Period', 'Period', RepeatOrder::get_period_fields(), null, count(RepeatOrder::get_period_fields())));
     $fields->push(new ListboxField('DeliveryDay', 'Delivery day', $source = array_combine(RepeatOrder::get_delivery_days(), RepeatOrder::get_delivery_days()), null, count(RepeatOrder::get_delivery_days()), false));
     $fields->push(new TextareaField('Notes', 'Notes'));
     //hidden field
     if (isset($order->ID)) {
         $fields->push(new HiddenField('OrderID', 'OrderID', $order->ID));
     }
     if ($repeatOrder) {
         $fields->push(new HiddenField('RepeatOrderID', 'RepeatOrderID', $repeatOrder->ID));
     }
     //actions
     $actions = new FieldSet();
     if ($repeatOrder) {
         $actions->push(new FormAction('doSave', 'Save'));
     } else {
         $actions->push(new FormAction('doCreate', 'Create'));
     }
     //required fields
     $requiredArray = array('Start', 'End', 'Period', 'DeliveryDay');
     $requiredFields = new RequiredFields($requiredArray);
     //make form
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     //load data
     if ($repeatOrder) {
         $this->loadDataFrom(array('Start' => $repeatOrder->Start, 'End' => $repeatOrder->End, 'Period' => $repeatOrder->Period, 'Notes' => $repeatOrder->Notes, 'DeliveryDay' => $repeatOrder->DeliveryDay, 'PaymentMethod' => $repeatOrder->PaymentMethod));
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-repeatorders,代码行数:89,代码来源:RepeatOrderForm.php

示例6: init

    /**
     * Standard SS function
     * if set to false, user can edit order, if set to true, user can only review order
     **/
    public function init()
    {
        parent::init();
        Requirements::themedCSS('CheckoutPage', 'ecommerce');
        $ajaxifyArray = EcommerceConfig::get("CheckoutPage_Controller", "ajaxify_steps");
        if (count($ajaxifyArray)) {
            foreach ($ajaxifyArray as $js) {
                Requirements::javascript($js);
            }
        }
        Requirements::javascript('ecommerce/javascript/EcomPayment.js');
        Requirements::customScript('
			if (typeof EcomOrderForm != "undefined") {
				EcomOrderForm.set_TermsAndConditionsMessage(\'' . convert::raw2js($this->TermsAndConditionsMessage) . '\');
			}', "TermsAndConditionsMessage");
        $this->steps = EcommerceConfig::get("CheckoutPage_Controller", "checkout_steps");
        $this->currentStep = $this->request->Param("ID");
        if ($this->currentStep && in_array($this->currentStep, $this->steps)) {
            //do nothing
        } else {
            $this->currentStep = array_shift($this->steps);
        }
        //redirect to current order -
        // this is only applicable when people submit order (start to pay)
        // and then return back
        if ($checkoutPageCurrentOrderID = Session::get("CheckoutPageCurrentOrderID")) {
            if (!$this->currentOrder || $this->currentOrder->ID != $checkoutPageCurrentOrderID) {
                if ($order = Order::get_by_id_if_can_view(intval($checkoutPageCurrentOrderID))) {
                    Session::clear("CheckoutPageCurrentOrderID");
                    Session::set("CheckoutPageCurrentOrderID", 0);
                    Session::save();
                    return $this->redirect($order->Link());
                }
            }
        }
        if ($this->currentOrder) {
            //we make sure all the OrderModifiers are up to date....
            Session::set("CheckoutPageCurrentOrderID", $this->currentOrder->ID);
        }
    }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:44,代码来源:CheckoutPage.php

示例7: createorder

 function createorder($request)
 {
     $orderID = intval($request->param("ID"));
     $order = null;
     if ($orderID) {
         $order = Order::get_by_id_if_can_view($orderID);
     }
     if (!$order) {
         $order = ShoppingCart::current_order();
     }
     //TODO: move items to order
     $params = array('Order' => $order);
     return $this->renderWith(array('RepeatOrdersPage_edit', 'Page'), $params);
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-repeatorders,代码行数:14,代码来源:StandingOrdersPage.php


注:本文中的Order::get_by_id_if_can_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。