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


PHP OrderItem::get_version方法代码示例

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


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

示例1: getVersionOfBuyable

 /**
  * Action to return specific version of a product variation.
  * This can be any product to enable the retrieval of deleted products.
  * This is really useful for sold products where you want to retrieve the actual version that you sold.
  * @param Int $id
  * @param Int $version
  * @return DataObject | Null
  */
 function getVersionOfBuyable($id = 0, $version = 0)
 {
     if (!$id) {
         $id = $this->ID;
     }
     if (!$version) {
         $version = $this->Version;
     }
     return OrderItem::get_version($this->ClassName, $id, $version);
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce_product_variation,代码行数:18,代码来源:ProductVariation.php

示例2: getVersionOfBuyable

 /**
  * Action to return specific version of a specific product.
  * This can be any product to enable the retrieval of deleted products.
  * This is really useful for sold products where you want to retrieve the actual version that you sold.
  * If the version can not be found then we retrieve the current one.
  * @param Int $id
  * @param Int $version
  * @return DataObject | Null
  */
 function getVersionOfBuyable($id = 0, $version = 0)
 {
     if (!$id) {
         $id = $this->ID;
     }
     if (!$version) {
         $version = $this->Version;
     }
     //not sure why this is running via OrderItem...
     $obj = OrderItem::get_version($this->ClassName, $id, $version);
     if (!$obj) {
         $className = $this->ClassName;
         $obj = $className::get()->byID($id);
     }
     return $obj;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:25,代码来源:Product.php

示例3: Buyable

 /**
  *
  * @return DataObject (Any type of Data Object that is buyable)
  * @param Boolean $current - is this a current one, or an older VERSION ?
  **/
 function Buyable($current = false)
 {
     if (!$this->BuyableID) {
         return null;
     }
     //start hack
     if (!$this->BuyableClassName) {
         $this->BuyableClassName = str_replace("_OrderItem", "", $this->ClassName);
     }
     $turnTranslatableBackOn = false;
     if (Object::has_extension($this->BuyableClassName, 'Translatable')) {
         Translatable::disable_locale_filter();
         $turnTranslatableBackOn = true;
     }
     //end hack!
     $obj = null;
     if ($current) {
         $obj = DataObject::get_by_id($this->BuyableClassName, $this->BuyableID);
     }
     //run if current not available or current = false
     if (!$obj && $this->Version) {
         /* @TODO: check if the version exists?? - see sample below
         			$versionTable = $this->BuyableClassName."_versions";
         			$dbConnection = DB::getConn();
         			if($dbConnection && $dbConnection instanceOf MySQLDatabase && $dbConnection->hasTable($versionTable)) {
         				$result = DB::query("
         					SELECT COUNT(\"ID\")
         					FROM \"$versionTable\"
         					WHERE
         						\"RecordID\" = ".intval($this->BuyableID)."
         						AND \"Version\" = ".intval($this->Version)."
         				");
         				if($result->value()) {
         			 */
         $obj = OrderItem::get_version($this->BuyableClassName, $this->BuyableID, $this->Version);
     }
     //our last resort
     if (!$obj) {
         $obj = Versioned::get_latest_version($this->BuyableClassName, $this->BuyableID);
     }
     if ($turnTranslatableBackOn) {
         Translatable::enable_locale_filter();
     }
     return $obj;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:50,代码来源:OrderItem.php

示例4: Buyable

 /**
  *
  * @param Boolean $current - is this a current one, or an older VERSION ?
  * @return DataObject (Any type of Data Object that is buyable)
  **/
 function Buyable($current = false)
 {
     $tempBuyableStoreType = $current ? "current" : "version";
     if (!isset($this->tempBuyableStore[$tempBuyableStoreType])) {
         if (!$this->BuyableID) {
             user_error("There was an error retrieving the product", E_USER_NOTICE);
             return null;
         }
         //start hack
         if (!$this->BuyableClassName) {
             $this->BuyableClassName = str_replace("_OrderItem", "", $this->ClassName);
         }
         $turnTranslatableBackOn = false;
         $className = $this->BuyableClassName;
         if ($className::has_extension($this->class, 'Translatable')) {
             Translatable::disable_locale_filter();
             $turnTranslatableBackOn = true;
         }
         //end hack!
         $obj = null;
         if ($current) {
             $obj = $className::get()->byID($this->BuyableID);
         }
         //run if current not available or current = false
         if (!$obj || !$current) {
             if ((!$obj || !$obj->exists()) && $this->Version) {
                 /* @TODO: check if the version exists?? - see sample below
                 			$versionTable = $this->BuyableClassName."_versions";
                 			$dbConnection = DB::getConn();
                 			if($dbConnection && $dbConnection instanceOf MySQLDatabase && $dbConnection->hasTable($versionTable)) {
                 				$result = DB::query("
                 					SELECT COUNT(\"ID\")
                 					FROM \"$versionTable\"
                 					WHERE
                 						\"RecordID\" = ".intval($this->BuyableID)."
                 						AND \"Version\" = ".intval($this->Version)."
                 				");
                 				if($result->value()) {
                 			 */
                 $obj = OrderItem::get_version($this->BuyableClassName, $this->BuyableID, $this->Version);
             }
             //our second to last resort
             if (!$obj || !$obj->exists()) {
                 $obj = Versioned::get_latest_version($this->BuyableClassName, $this->BuyableID);
             }
         }
         //our final backup
         if (!$obj || !$obj->exists()) {
             $obj = $className::get()->byID($this->BuyableID);
         }
         if ($turnTranslatableBackOn) {
             Translatable::enable_locale_filter();
         }
         $this->tempBuyableStore[$tempBuyableStoreType] = $obj;
     }
     return $this->tempBuyableStore[$tempBuyableStoreType];
 }
开发者ID:abhibavishi,项目名称:silverstripe-ecommerce,代码行数:62,代码来源:OrderItem.php


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