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


PHP Option::getOptionGroupId方法代碼示例

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


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

示例1: verify

 public function verify()
 {
     if (!isset($this->data->price) || !is_numeric($this->data->price)) {
         throw new \Exception(Lang::txt('No SKU price set'));
     }
     if (!isset($this->data->pId) || !is_numeric($this->data->pId)) {
         throw new \Exception(Lang::txt('No SKU Product Set'));
     }
     // Verify that the SKU has all options set (one option from each option group assigned to the parent product)
     $product = new Product($this->getProductId());
     $productOptionGroups = $product->getOptionGroups();
     // Init the set options array()
     $optionGroupOptionsSet = array();
     // Init the flag whether the extra/useless options are set
     $extraOptionsSet = false;
     foreach ($this->getOptions() as $oId) {
         $option = new Option($oId);
         $optionGroupId = $option->getOptionGroupId();
         if (in_array($optionGroupId, $productOptionGroups)) {
             $optionGroupOptionsSet[] = $optionGroupId;
         } else {
             // There are some options set that are from option groups not applied to this product
             // (most likely due to the removal of the option group from the product.)
             $extraOptionsSet = true;
         }
     }
     // At this point option groups options set must be the same as the product options groups, throw exception if not
     $missingOptions = array_diff($productOptionGroups, $optionGroupOptionsSet);
     if (!empty($missingOptions)) {
         throw new \Exception(Lang::txt('Not all product options are set'));
     }
     if ($extraOptionsSet) {
         throw new \Exception(Lang::txt('Extra options are set'));
     }
     return true;
 }
開發者ID:mined-gatech,項目名稱:hubzero-cms,代碼行數:36,代碼來源:Sku.php

示例2: verify

 public function verify()
 {
     if (!isset($this->data->price) || !is_numeric($this->data->price)) {
         throw new \Exception(Lang::txt('No SKU price set'));
     }
     if (!isset($this->data->pId) || !is_numeric($this->data->pId)) {
         throw new \Exception(Lang::txt('No SKU Product Set'));
     }
     // Verify that the SKU has all options set (one option from each option group assigned to the parent product)
     $product = new Product($this->getProductId());
     $productOptionGroups = $product->getOptionGroups();
     // Init the set options array()
     $optionGroupOptionsSet = array();
     // Init the flag whether the extra/useless options are set
     $extraOptionsSet = false;
     foreach ($this->getOptions() as $oId) {
         $option = new Option($oId);
         $optionGroupId = $option->getOptionGroupId();
         if (in_array($optionGroupId, $productOptionGroups)) {
             $optionGroupOptionsSet[] = $optionGroupId;
         } else {
             // There are some options set that are from option groups not applied to this product
             // (most likely due to the removal of the option group from the product.) This should never happen.
             $extraOptionsSet = true;
         }
     }
     // At this point option groups options set must be the same as the product options groups, throw exception if not
     $missingOptions = array_diff($productOptionGroups, $optionGroupOptionsSet);
     if (!empty($missingOptions)) {
         throw new \Exception(Lang::txt('Not all product options are set'));
     }
     if ($extraOptionsSet) {
         throw new \Exception(Lang::txt('Extra options are set'));
     }
     // Integrity check
     require_once dirname(__DIR__) . DS . 'helpers' . DS . 'Integrity.php';
     $integrityCheck = \Integrity::skuIntegrityCheck($this);
     if ($integrityCheck->status != 'ok') {
         $errorMessage = "Integrity check error:";
         foreach ($integrityCheck->errors as $error) {
             $errorMessage .= '<br>' . $error;
         }
         throw new \Exception($errorMessage);
     }
     return true;
 }
開發者ID:kevinwojo,項目名稱:hubzero-cms,代碼行數:46,代碼來源:Sku.php


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