当前位置: 首页>>代码示例>>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;未经允许,请勿转载。