本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}
示例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();
}
示例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));
}
}
示例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);
}
}
示例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);
}