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


PHP InjectableFixture::getCustomOptions方法代碼示例

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


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

示例1: prepareOptions

 /**
  * Preparation options before comparing.
  *
  * @param InjectableFixture $product
  * @return array
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function prepareOptions(InjectableFixture $product)
 {
     $result = [];
     $customOptions = $product->getCustomOptions();
     $actualPrice = $this->getProductActualPrice($product);
     foreach ($customOptions as $customOption) {
         $customOptionsPriceType = isset($customOption['options']['price_type']) ? $customOption['options']['price_type'] : null;
         if ($customOptionsPriceType) {
             if ($customOptionsPriceType === 'Percent') {
                 $customOptionPrice = $customOption['options']['price'];
                 $customOption['options']['price'] = $this->calculatePrice($actualPrice, $customOptionPrice);
             }
             $customOption['options'] = array_diff_key($customOption['options'], array_flip($this->skippedFieldOptions));
         } else {
             foreach ($customOption['options'] as &$option) {
                 if ('Percent' === $option['price_type']) {
                     $option['price'] = $this->calculatePrice($actualPrice, $option['price']);
                 }
                 $option = array_diff_key($option, array_flip($this->skippedFieldOptions));
             }
         }
         $customOption['type'] = explode('/', $customOption['type'])[1];
         $result[$customOption['title']] = $customOption;
     }
     return $result;
 }
開發者ID:hientruong90,項目名稱:ee_14_installer,代碼行數:34,代碼來源:AssertProductCustomOptionsOnProductPage.php

示例2: prepareFixturePrice

 /**
  * Prepare product price from fixture.
  *
  * @param InjectableFixture $product
  * @return float
  */
 protected function prepareFixturePrice(InjectableFixture $product)
 {
     /** @var CatalogProductSimple $product */
     $customOptions = $product->getCustomOptions();
     $checkoutData = $product->getCheckoutData();
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     if (isset($checkoutData['cartItem'])) {
         $fixturePrice = $checkoutData['cartItem']['price'];
     } else {
         $fixturePrice = $product->getPrice();
         $groupPrice = $product->getGroupPrice();
         $specialPrice = $product->getSpecialPrice();
         if ($groupPrice) {
             $groupPrice = reset($groupPrice);
             $fixturePrice = $groupPrice['price'];
         }
         if ($specialPrice) {
             $fixturePrice = $specialPrice;
         }
         foreach ($checkoutCustomOptions as $checkoutOption) {
             $attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
             $optionKey = str_replace('option_key_', '', $checkoutOption['value']);
             $option = $customOptions[$attributeKey]['options'][$optionKey];
             if ('Fixed' == $option['price_type']) {
                 $fixturePrice += $option['price'];
             } else {
                 $fixturePrice += $fixturePrice / 100 * $option['price'];
             }
         }
     }
     return $fixturePrice;
 }
開發者ID:hientruong90,項目名稱:ee_14_installer,代碼行數:38,代碼來源:AssertProductInCart.php

示例3: fillOptions

 /**
  * Fill in the option specified for the product.
  *
  * @param InjectableFixture $product
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function fillOptions(InjectableFixture $product)
 {
     $dataConfig = $product->getDataConfig();
     $typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
     $checkoutData = null;
     /** @var CatalogProductSimple $product */
     if ($this->hasRender($typeId)) {
         $this->callRender($typeId, 'fillOptions', ['product' => $product]);
     }
     /** @var CatalogProductSimple $product */
     $checkoutData = $product->getCheckoutData();
     if (!isset($checkoutData['options']['custom_options'])) {
         return;
     }
     $customOptions = $product->getCustomOptions();
     if (isset($customOptions)) {
         $checkoutCustomOptions = $this->prepareCheckoutData($customOptions, $checkoutData['options']['custom_options']);
         $this->getCustomOptionsBlock()->fillCustomOptions($checkoutCustomOptions);
     }
 }
開發者ID:hientruong90,項目名稱:ee_14_installer,代碼行數:28,代碼來源:View.php

示例4: getOptions

 /**
  * Get product options.
  *
  * @param InjectableFixture $product
  * @return array
  * @throws \Exception
  */
 public function getOptions(InjectableFixture $product)
 {
     $dataOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : [];
     if (empty($dataOptions)) {
         return $dataOptions;
     }
     $listCustomOptions = $this->getListOptions();
     $result = [];
     foreach ($dataOptions as $option) {
         $title = $option['title'];
         if (!isset($listCustomOptions[$title])) {
             throw new \Exception("Can't find option: \"{$title}\"");
         }
         /** @var Element $optionElement */
         $optionElement = $listCustomOptions[$title];
         $option['type'] = explode('/', $option['type'])[1];
         $typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['type']);
         $getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data';
         $optionData = $this->{$getTypeData}($optionElement);
         $optionData['title'] = $title;
         $optionData['type'] = $option['type'];
         $optionData['is_require'] = $optionElement['title']->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No';
         $result[$title] = $optionData;
     }
     return ['custom_options' => $result];
 }
開發者ID:QiuLihua83,項目名稱:magento-ee,代碼行數:33,代碼來源:CustomOptions.php


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