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