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


PHP FixtureInterface::getCustomOptions方法代码示例

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


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

示例1: assertOnShoppingCart

 /**
  * Assert prices on the shopping cart
  *
  * @param FixtureInterface $product
  * @param CheckoutCart $checkoutCart
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
 {
     $checkoutCart->open();
     /** @var CatalogProductSimple $product */
     $customOptions = $product->getCustomOptions();
     $checkoutData = $product->getCheckoutData();
     $checkoutCartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     $fixturePrice = $product->getPrice();
     $specialPrice = $product->getSpecialPrice();
     $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
     $formPrice = $cartItem->getPrice();
     if ($specialPrice) {
         $fixturePrice = $specialPrice;
     }
     if (isset($checkoutCartItem['price'])) {
         $fixturePrice = $checkoutCartItem['price'];
     }
     $fixtureActualPrice = $fixturePrice;
     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']) {
             $fixtureActualPrice += $option['price'];
         } else {
             $fixtureActualPrice += $fixturePrice / 100 * $option['price'];
         }
     }
     \PHPUnit_Framework_Assert::assertEquals($fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.');
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:40,代码来源:AssertProductInCart.php

示例2: prepareOptions

 /**
  * Prepare options
  *
  * @param FixtureInterface $product
  * @return array
  */
 protected function prepareOptions(FixtureInterface $product)
 {
     $productOptions = [];
     $checkoutData = $product->getCheckoutData()['options'];
     $customOptions = $product->getCustomOptions();
     if (isset($checkoutData['custom_options'])) {
         foreach ($checkoutData['custom_options'] as $option) {
             $optionKey = str_replace('attribute_key_', '', $option['title']);
             $valueKey = str_replace('option_key_', '', $option['value']);
             $productOptions[] = ['option_name' => $customOptions[$optionKey]['title'], 'value' => isset($customOptions[$optionKey]['options'][$valueKey]['title']) ? $customOptions[$optionKey]['options'][$valueKey]['title'] : $valueKey];
         }
     }
     return $productOptions;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:AssertProductInCustomerWishlistOnBackendGrid.php

示例3: __construct

 /**
  * @constructor
  * @param FixtureInterface $product
  */
 public function __construct(FixtureInterface $product)
 {
     /** @var CatalogProductSimple $product */
     $checkoutData = $product->getCheckoutData();
     $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
     $customOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : [];
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     foreach ($checkoutCustomOptions as $key => $checkoutCustomOption) {
         $attribute = str_replace('attribute_key_', '', $checkoutCustomOption['title']);
         $option = str_replace('option_key_', '', $checkoutCustomOption['value']);
         $checkoutCustomOptions[$key] = ['title' => isset($customOptions[$attribute]['title']) ? $customOptions[$attribute]['title'] : $attribute, 'value' => isset($customOptions[$attribute]['options'][$option]['title']) ? $customOptions[$attribute]['options'][$option]['title'] : $option];
     }
     $cartItem['options'] = $checkoutCustomOptions;
     $cartItem['qty'] = isset($checkoutData['qty']) ? $checkoutData['qty'] : 1;
     $this->data = $cartItem;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:20,代码来源:Item.php


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