當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ShoppingCart::current_order方法代碼示例

本文整理匯總了PHP中ShoppingCart::current_order方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShoppingCart::current_order方法的具體用法?PHP ShoppingCart::current_order怎麽用?PHP ShoppingCart::current_order使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ShoppingCart的用法示例。


在下文中一共展示了ShoppingCart::current_order方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: memberLoggedIn

 /**
  * Member login hook
  */
 function memberLoggedIn()
 {
     if (self::$associate_to_current_order && ShoppingCart::order_started() && ($order = ShoppingCart::current_order())) {
         $order->MemberID = $this->owner->ID;
         $order->write();
     }
 }
開發者ID:riddler7,項目名稱:silverstripe-ecommerce,代碼行數:10,代碼來源:EcommerceRole.php

示例2: testProductVersionDoesNotExist

 /**
  * Tries to create an order item with a non-existent version.
  */
 function testProductVersionDoesNotExist()
 {
     $currentorder = ShoppingCart::current_order();
     $brokenitem = new Product_OrderItem(array("ProductID" => $productSocks->ID, "ProductVersion" => 99999));
     $this->assertEquals($brokenitem->UnitPrice(), null);
     //TODO: what should happen here???
 }
開發者ID:riddler7,項目名稱:silverstripe-ecommerce,代碼行數:10,代碼來源:ProductOrderItemTest.php

示例3: testCalculations

 function testCalculations()
 {
     $mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->get(ShoppingCart::add_item_link($mp3player->ID));
     $cart = ShoppingCart::current_order();
     $this->assertEquals($cart->Total(), 215);
 }
開發者ID:riddler7,項目名稱:silverstripe-ecommerce,代碼行數:7,代碼來源:FlatTaxModifierTest.php

示例4: addmembertocartform_add

 function addmembertocartform_add($data, $form)
 {
     $member = Member::currentUser();
     if ($member && $member->IsShopAdmin()) {
         $order = ShoppingCart::current_order();
         $member = Member::get()->byID(intval($data["MemberID"]));
         if ($member) {
             if ($member->ID != $order->MemberID) {
                 $order->MemberID = $member->ID;
                 $order->BillingAddressID = 0;
                 $order->ShippingAddressID = 0;
                 $order->write();
                 $response = $member->getTitle() . " " . _t("AddToCartPage.ADDED", "customer has been added to order.");
                 $status = "good";
             } else {
                 $response = _t("AddToCartPage.NOCHANGE", "The order has not been changed.");
                 $status = "good";
             }
         } else {
             $response = _t("AddToCartPage.CUSTOMERNOTADDED", "Customer could not be added.");
             $status = "bad";
         }
         if (Director::is_ajax()) {
             return $response;
         } else {
             $form->setMessage($response, $status);
             $this->redirectBack();
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce-quick-add,代碼行數:30,代碼來源:AddToCartPage.php

示例5: Order

 /**
  * @TODO Where is this method used?
  * @return Order
  */
 function Order()
 {
     if ($this->ID) {
         return DataObject::get_by_id('Order', $this->OrderID);
     } else {
         return ShoppingCart::current_order();
     }
 }
開發者ID:nicolaas,項目名稱:silverstripe-ecommerce,代碼行數:12,代碼來源:OrderAttribute.php

示例6: Order

 function Order()
 {
     if ($orderID = Director::urlParam('Action')) {
         return DataObject::get_by_id('Order', $orderID);
     } else {
         return ShoppingCart::current_order();
     }
 }
開發者ID:riddler7,項目名稱:silverstripe-ecommerce,代碼行數:8,代碼來源:CartPage.php

示例7: orderToUse

 /**
  * returns the order to use.... You can provide one
  * which basically just checks that it is a real order
  * @param Order | Int
  * @return Order
  */
 protected function orderToUse($order = null)
 {
     if ($order && $order instanceof $order) {
         return $order;
     }
     if (intval($order)) {
         return Order::get()->byID(intval($order));
     } else {
         return ShoppingCart::current_order();
     }
     user_error("Can't find an order to use");
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:18,代碼來源:EcommercePaymentSupportedMethodsProvider.php

示例8: Item

 function Item()
 {
     $currentOrder = ShoppingCart::current_order();
     if ($items = $currentOrder->Items()) {
         foreach ($items as $item) {
             if ($item instanceof ProductVariation_OrderItem && ($itemProductVariation = $item->ProductVariation())) {
                 if ($itemProductVariation->ID == $this->ID && $itemProductVariation->Version == $this->Version) {
                     return $item;
                 }
             }
         }
     } else {
         return null;
     }
 }
開發者ID:nicolaas,項目名稱:silverstripe-ecommerce,代碼行數:15,代碼來源:ProductVariation.php

示例9: OrderFormBeforeFinalCalculation

 /**
  *
  * extension check
  * return NULL if there is no problem and return true if there is a problem.
  */
 function OrderFormBeforeFinalCalculation($data, $form, $request)
 {
     if ($data["PaymentMethod"] != "BuckarooPayment") {
         return null;
     }
     $order = ShoppingCart::current_order();
     //this is the standard way for getting a specific Order Modifier, allowing
     //you to work on multiple modifiers of the same kind .
     if (!isset($data['BuckarooMethod']) || !$data["BuckarooMethod"]) {
         return "ERROR";
     }
     $modifiers = $order->Modifiers('BuckarooPaymentModifier');
     if ($modifiers) {
         foreach ($modifiers as $modifier) {
             $modifier->updateName(Convert::raw2sql($data['BuckarooMethod'], $write = true));
         }
     } else {
         return "ERROR";
     }
     return null;
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-payment-buckaroo,代碼行數:26,代碼來源:BuckarooPaymentOrderFormExtension.php

示例10: submit

 public function submit(array $data, Form $form, $message = "order updated", $status = "good")
 {
     $order = ShoppingCart::current_order();
     if ($order) {
         $modifier = $order->Modifiers('DonationModifier');
         if ($modifier) {
             $modifier = $modifier->First();
             $modifier->updateAddDonation($data['DonationID']);
             $msg = $data['DonationID'] ? _t("AnyPriceRoundUpDonationModifier.UPDATED", "Round up donation added - THANK YOU.") : _t("AnyPriceRoundUpDonationModifier.UPDATED", "Round up donation removed.");
             if (isset($data['OtherValue'])) {
                 $modifier->updateOtherValue(floatval($data['OtherValue']));
                 if (floatval($data['OtherValue']) > 0) {
                     $msg .= _t("AnyPriceRoundUpDonationModifier.UPDATED", "Added donation - THANK YOU.");
                 }
             } else {
                 $modifier->updateOtherValue(0);
             }
             $modifier->write();
             return ShoppingCart::singleton()->setMessageAndReturn($msg, "good");
         }
     }
     return ShoppingCart::singleton()->setMessageAndReturn(_t("AnyPriceRoundUpDonationModifier.NOTUPDATED", "Could not update the round up donation status.", "bad"));
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce-anypriceproduct,代碼行數:23,代碼來源:DonationModifier.php

示例11: php

 /**
  * Ensures member unique id stays unique and other basic stuff...
  * @param array $data = Form Data
  * @return Boolean
  */
 function php($data)
 {
     $valid = parent::php($data);
     $checkoutPage = DataObject::get_one("CheckoutPage");
     if ($checkoutPage->TermsAndConditionsMessage) {
         if (isset($data["ReadTermsAndConditions"])) {
             if (!$data["ReadTermsAndConditions"]) {
                 $this->validationError("ReadTermsAndConditions", $checkoutPage->TermsAndConditionsMessage, "required");
                 $valid = false;
             }
         }
     }
     $order = ShoppingCart::current_order();
     if (!$order) {
         $this->validationError("Order", _t("OrderForm.ORDERNOTFOUND", "There was an error in processing your order, please try again or contact the administrator."), "required");
         $valid = false;
     }
     $billingAddress = DataObject::get_by_id("BillingAddress", intval($order->BillingAddressID) - 0);
     if (!$billingAddress) {
         $this->validationError("BillingAddress", _t("OrderForm.MUSTHAVEBILLINGADDRESS", "All orders must have a billing address."), "required");
         $valid = false;
     }
     return $valid;
 }
開發者ID:nieku,項目名稱:silverstripe-ecommerce,代碼行數:29,代碼來源:OrderForm.php

示例12: canView

 /**
  * Standard SS method - can the current member view this order?
  *
  *@return Boolean
  **/
 public function canView($member = null)
 {
     if (!$this->exists()) {
         return true;
     }
     $member = $this->getMemberForCanFunctions($member);
     //check if this has been "altered" in a DataObjectDecorator
     $extended = $this->extendedCan('canView', $member->ID);
     //if this method has been extended in a data object decorator then use this
     if ($extended !== null) {
         return $extended;
     }
     //is the member is a shop admin they can always view it
     if (EcommerceRole::current_member_is_shop_admin($member)) {
         return true;
     }
     //if the current member OWNS the order, (s)he can always view it.
     if ($member->exists() && $this->MemberID == $member->ID) {
         return true;
     }
     //it is the current order
     $currentOrder = ShoppingCart::current_order();
     if ($currentOrder && $currentOrder->ID == $this->ID) {
         //we do some additional CHECKS for session hackings!
         if ($member->exists()) {
             //must be the same member!
             if ($this->MemberID == $member->ID) {
                 return true;
             } elseif ($this->MemberID) {
                 return false;
             } else {
                 //we do NOT add the member here, because this is done in shopping cart
                 //$this->MemberID = $member->ID;
                 //$this->write();
                 return true;
             }
         } else {
             //order belongs to someone, but current user is NOT logged in...
             if ($this->MemberID) {
                 return false;
             } else {
                 return true;
             }
         }
     }
     //if the session ID matches, we can always view it.
     //SECURITYL RISK: if you know someone else his/her session
     //OR you can view the sessions on the server
     //OR you can guess the session
     //THEN you can view the order.
     //by viewing the order you can also access some of the member details.
     //NB: this MUST be the last resort! If all other methods fail.
     //That is, if we are working with the current order then it is a good idea
     //to deny non-matching members.
     if ($this->SessionID && $this->SessionID == session_id()) {
         return true;
     }
     return false;
 }
開發者ID:nieku,項目名稱:silverstripe-ecommerce,代碼行數:64,代碼來源:Order.php

示例13: get_region

 /**
  * This function works out the most likely region for the current order
  * @return Int
  **/
 public static function get_region()
 {
     $regionID = 0;
     if ($order = ShoppingCart::current_order()) {
         if ($region = $order->Region()) {
             $regionID = $region->ID;
         }
     }
     //3. check GEOIP information
     if (!$regionID) {
         $regionArray = self::list_of_allowed_entries_for_dropdown();
         if (is_array($regionArray) && count($regionArray)) {
             foreach ($regionArray as $regionID => $regionName) {
                 //we stop at the first one... as we have no idea which one is the best.
                 break;
             }
         }
     }
     return $regionID;
 }
開發者ID:nieku,項目名稱:silverstripe-ecommerce,代碼行數:24,代碼來源:EcommerceRegion.php

示例14: Cart

 /**
  * Returns the shopping cart.
  * @todo Does HTTP::set_cache_age() still need to be set here?
  * 
  * @return Order
  */
 function Cart()
 {
     HTTP::set_cache_age(0);
     return ShoppingCart::current_order();
 }
開發者ID:nicolaas,項目名稱:silverstripe-ecommerce,代碼行數:11,代碼來源:ProductGroup.php

示例15: creatememberandaddtoorder

 /**
  * create a member and add it to the order
  * then redirect back...
  *
  * @param Array $data
  * @param Form $form
  */
 function creatememberandaddtoorder($data, $form)
 {
     $member = new Member();
     $order = ShoppingCart::current_order();
     if ($order && $order->exists()) {
         $form->saveInto($member);
         $password = ShopAccountForm_PasswordValidator::clean_password($data);
         if ($password) {
             $member->changePassword($password);
             if ($member->validate()->valid()) {
                 $member->write();
                 if ($member->exists()) {
                     if (!$order->MemberID) {
                         $order->MemberID = $member->ID;
                         $order->write();
                     }
                     $member->login();
                     $this->sessionMessage(_t("ShopAccountForm.SAVEDDETAILS", "Your details has been saved."), "good");
                 } else {
                     $this->sessionMessage(_t("ShopAccountForm.COULD_NOT_CREATE_RECORD", "Could not save create a record for your details."), "bad");
                 }
             } else {
                 $this->sessionMessage(_t("ShopAccountForm.COULD_NOT_VALIDATE_MEMBER", "Could not save your details."), "bad");
             }
         }
     } else {
         $this->sessionMessage(_t("ShopAccountForm.COULDNOTFINDORDER", "Could not find order."), "bad");
     }
     $this->controller->redirectBack();
 }
開發者ID:helpfulrobot,項目名稱:sunnysideup-ecommerce,代碼行數:37,代碼來源:ShopAccountForm.php


注:本文中的ShoppingCart::current_order方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。