本文整理匯總了PHP中Magento\Mtf\Fixture\FixtureInterface::getCheckoutData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::getCheckoutData方法的具體用法?PHP FixtureInterface::getCheckoutData怎麽用?PHP FixtureInterface::getCheckoutData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::getCheckoutData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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.');
}
示例2: configProduct
/**
* Fill in the option specified for the product
*
* @param FixtureInterface $product
* @return void
*/
public function configProduct(FixtureInterface $product)
{
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();
$this->fillOptions($product);
if (isset($checkoutData['qty'])) {
$this->setQty($checkoutData['qty']);
}
$this->clickOk();
}
示例3: 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;
}
示例4: prepareOptions
/**
* Prepare options
*
* @param FixtureInterface $product
* @return array
*/
protected function prepareOptions(FixtureInterface $product)
{
/** @var GroupedProduct $product */
$productOptions = [];
$checkoutData = $product->getCheckoutData()['options'];
if (count($checkoutData)) {
$associated = $product->getAssociated();
foreach ($checkoutData as $optionData) {
$productKey = str_replace('product_key_', '', $optionData['name']);
$productOptions[] = ['option_name' => $associated['assigned_products'][$productKey]['name'], 'value' => $optionData['qty']];
}
}
return $productOptions;
}
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:20,代碼來源:AssertGroupedProductInCustomerWishlistOnBackendGrid.php
示例5: getProductPrice
/**
* Get configurable product price
*
* @param FixtureInterface $product
* @throws \Exception
* @return int
*/
protected function getProductPrice(FixtureInterface $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
if (!$product instanceof ConfigurableProduct) {
throw new \Exception("Product '{$product->getName}()' is not configurable product.");
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
return $price;
}
示例6: __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;
}
示例7: fillOptions
/**
* Fill specified option for the product
*
* @param FixtureInterface $product
* @return void
*/
public function fillOptions(FixtureInterface $product)
{
/** @var DownloadableProduct $product */
$productData = $product->getData();
$downloadableLinks = isset($productData['downloadable_links']['downloadable']['link']) ? $productData['downloadable_links']['downloadable']['link'] : [];
$checkoutData = $product->getCheckoutData();
if (isset($checkoutData['options'])) {
// Replace link key to label
foreach ($checkoutData['options']['links'] as $key => $linkData) {
$linkKey = str_replace('link_', '', $linkData['label']);
$linkData['label'] = isset($downloadableLinks[$linkKey]['title']) ? $downloadableLinks[$linkKey]['title'] : $linkData['label'];
$checkoutData['options']['links'][$key] = $linkData;
}
$this->getDownloadableLinksBlock()->fill($checkoutData['options']['links']);
}
}
示例8: fillOptions
/**
* Fill in the option specified for the product
*
* @param FixtureInterface $product
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function fillOptions(FixtureInterface $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();
$checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
$customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : [];
$checkoutCustomOptions = $this->prepareCheckoutData($customOptions, $checkoutCustomOptions);
$this->getCustomOptionsBlock()->fillCustomOptions($checkoutCustomOptions);
}
示例9: selectItem
/**
* Select order item.
*
* @param FixtureInterface $product
* @return void
*/
public function selectItem(FixtureInterface $product)
{
/** @var BundleProduct $product */
$checkoutData = $product->getCheckoutData();
$bundleSelection = $product->getBundleSelections();
$bundleOptions = isset($checkoutData['options']['bundle_options']) ? $checkoutData['options']['bundle_options'] : [];
$labels = [];
foreach ($bundleOptions as $optionKey => $option) {
$optionKey = substr($optionKey, -1);
$productKey = substr($option['value']['name'], -1);
$labels[] = $bundleSelection[$optionKey]['assigned_products'][$productKey]['name'];
}
$this->searchAndSelect(['name' => $product->getName()]);
$this->getTemplateBlock()->waitLoader();
$this->getSelectItemsBlock()->fill($labels);
$this->getTemplateBlock()->waitLoader();
}
示例10: fillOptions
/**
* Fill in the option specified for the product
*
* @param FixtureInterface $product
* @return void
*/
public function fillOptions(FixtureInterface $product)
{
/** @var ConfigurableProduct $product */
$attributesData = $product->getConfigurableAttributesData()['attributes_data'];
$checkoutData = $product->getCheckoutData();
// Prepare attribute data
foreach ($attributesData as $attributeKey => $attribute) {
$attributesData[$attributeKey] = ['type' => $attribute['frontend_input'], 'title' => $attribute['label'], 'options' => []];
foreach ($attribute['options'] as $optionKey => $option) {
$attributesData[$attributeKey]['options'][$optionKey] = ['title' => $option['label']];
}
$attributesData[$attributeKey]['options'] = array_values($attributesData[$attributeKey]['options']);
}
$attributesData = array_values($attributesData);
$configurableCheckoutData = isset($checkoutData['options']['configurable_options']) ? $checkoutData['options']['configurable_options'] : [];
$checkoutOptionsData = $this->prepareCheckoutData($attributesData, $configurableCheckoutData);
$this->getCustomOptionsBlock()->fillCustomOptions($checkoutOptionsData);
parent::fillOptions($product);
}
示例11: fill
/**
* Fill product options on view page.
*
* @param FixtureInterface $product
* @return void
*/
public function fill(FixtureInterface $product)
{
/** @var GroupedProduct $product */
$associatedProducts = $product->getAssociated()['products'];
$checkoutData = $product->getCheckoutData();
if (isset($checkoutData['options'])) {
// Replace link key to label
foreach ($checkoutData['options'] as $key => $productData) {
$productKey = str_replace('product_key_', '', $productData['name']);
$checkoutData['options'][$key]['name'] = $associatedProducts[$productKey]->getName();
}
// Fill
foreach ($checkoutData['options'] as $productData) {
$this->browser->selectWindow();
$subProduct = $this->_rootElement->find(sprintf($this->subProductByName, $productData['name']), Locator::SELECTOR_XPATH);
$subProduct->find($this->qty)->setValue($productData['qty']);
$this->_rootElement->click();
}
}
}
示例12: getProductPrice
/**
* Get configurable product price
*
* @param FixtureInterface $product
* @throws \Exception
* @return int
*/
protected function getProductPrice(FixtureInterface $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
if (!$product instanceof ConfigurableProduct) {
throw new \Exception("Product '{$product->getName}()' is not configurable product.");
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
$attributesData = $product->getConfigurableAttributesData()['attributes_data'];
foreach ($checkoutData['options']['configurable_options'] as $option) {
$itemOption = $attributesData[$option['title']]['options'][$option['value']];
$itemPrice = $itemOption['is_percent'] == 'No' ? $itemOption['pricing_value'] : $product->getPrice() / 100 * $itemOption['pricing_value'];
$price += $itemPrice;
}
return $price;
}
示例13: __construct
/**
* @constructor
* @param FixtureInterface $product
*/
public function __construct(FixtureInterface $product)
{
/** @var GroupedProduct $product */
$checkoutData = $product->getCheckoutData();
$this->data = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
$associatedProducts = [];
$cartItem = [];
foreach ($product->getAssociated()['products'] as $key => $product) {
$key = 'product_key_' . $key;
$associatedProducts[$key] = $product;
}
// Replace key in checkout data
foreach ($this->data as $fieldName => $fieldValues) {
foreach ($fieldValues as $key => $value) {
$product = $associatedProducts[$key];
$cartItem[$fieldName][$product->getSku()] = $value;
}
}
// Add empty "options" field
foreach ($associatedProducts as $product) {
$cartItem['options'][] = ['title' => $product->getName(), 'value' => $cartItem['qty'][$product->getSku()]];
}
$this->data = $cartItem;
}
示例14: prepareSimpleData
/**
* Prepare data for simple product.
*
* @param FixtureInterface $product
* @return array
*/
protected function prepareSimpleData(FixtureInterface $product)
{
return ['qty' => $product->getCheckoutData()['qty']];
}
示例15: fillOptions
/**
* Fill in the option specified for the product.
*
* @param FixtureInterface $product
* @return void
*/
public function fillOptions(FixtureInterface $product)
{
/** @var \Magento\Bundle\Test\Fixture\BundleProduct $product */
$checkoutData = $product->getCheckoutData();
$bundleCheckoutData = isset($checkoutData['options']['bundle_options']) ? $checkoutData['options']['bundle_options'] : [];
if (!$this->getBundleBlock()->isVisible()) {
$this->clickCustomize();
}
$this->getBundleBlock()->fillBundleOptions($bundleCheckoutData);
}