本文整理汇总了PHP中Magento\Mtf\Fixture\InjectableFixture::getCheckoutData方法的典型用法代码示例。如果您正苦于以下问题:PHP InjectableFixture::getCheckoutData方法的具体用法?PHP InjectableFixture::getCheckoutData怎么用?PHP InjectableFixture::getCheckoutData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\InjectableFixture
的用法示例。
在下文中一共展示了InjectableFixture::getCheckoutData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrice
/**
* Returns the item price for the specified product.
*
* @param InjectableFixture $product
* @return array|string
*/
public function getPrice(InjectableFixture $product)
{
$productName = $product->getName();
if ($product instanceof ConfigurableProduct) {
// Find the price for the specific configurable product that was purchased
$attributesData = $product->getConfigurableAttributesData()['attributes_data'];
$matrix = $product->getConfigurableAttributesData()['matrix'];
$checkoutOptions = $product->getCheckoutData()['options']['configurable_options'];
$optionsDetails = [];
$matrixKey = [];
$optionsPrice = 0;
foreach ($checkoutOptions as $checkoutOption) {
$titleKey = $checkoutOption['title'];
$valueKey = $checkoutOption['value'];
$attributeName = $attributesData[$titleKey]['frontend_label'];
$optionLabel = $attributesData[$titleKey]['options'][$valueKey]['label'];
$optionsDetails[] = "{$attributeName}{$optionLabel}";
$matrixKey[] = "{$titleKey}:{$valueKey}";
$optionsPrice += $attributesData[$titleKey]['options'][$valueKey]['pricing_value'];
}
$optionsDetails = implode(' ', $optionsDetails);
$matrixKey = implode(' ', $matrixKey);
$productDisplay = $productName . 'SKU: ' . $matrix[$matrixKey]['sku'] . $optionsDetails;
} else {
$productDisplay = $productName . 'SKU: ' . $product->getSku();
}
$selector = '//tr[normalize-space(td)="' . $productDisplay . '"]' . $this->priceSelector;
return $this->escapeCurrency($this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText());
}
示例2: paypalCheckout
/**
* Check out with PayPal.
*
* @param InjectableFixture $product
* @return void
*/
public function paypalCheckout(InjectableFixture $product)
{
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();
if (isset($checkoutData['options'])) {
$this->fillOptions($product);
}
if (isset($checkoutData['qty'])) {
$this->setQty($checkoutData['qty']);
}
$this->_rootElement->find($this->paypalCheckout)->click();
}
示例3: fillOptions
/**
* Filling the options specified for the product.
*
* @param InjectableFixture $product
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function fillOptions(InjectableFixture $product)
{
/** @var DownloadableProduct $product */
$downloadableLinks = isset($product->getDownloadableLinks()['downloadable']['link']) ? $product->getDownloadableLinks()['downloadable']['link'] : [];
$checkoutData = $product->getCheckoutData();
if (isset($checkoutData['options'])) {
foreach ($checkoutData['options']['links'] as $key => $linkData) {
$linkKey = str_replace('link_', '', $linkData['label']);
$linkData['label'] = $downloadableLinks[$linkKey]['title'];
$checkoutData['options']['links'][$key] = $linkData;
}
$this->getDownloadableLinksBlock()->fill($checkoutData['options']['links']);
}
parent::fillOptions($product);
}
示例4: getProductPrice
/**
* Get configurable product price.
*
* @param InjectableFixture $product
* @return int
*/
protected function getProductPrice(InjectableFixture $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
$attributesData = $product->getConfigurableOptions()['attributes_data'];
foreach ($checkoutData['options']['configurable_options'] as $option) {
$itemOption = $attributesData[$option['title']]['options'][$option['value']];
$price += $itemOption['price_type'] == 'Fixed' ? $itemOption['price'] : $product->getPrice() / 100 * $itemOption['price'];
}
return $price;
}
示例5: fillOptions
/**
* Fill in the option specified for the product.
*
* @param InjectableFixture $product
* @return void
*/
public function fillOptions(InjectableFixture $product)
{
/** @var ConfigurableProduct $product */
$attributesData = $product->getConfigurableOptions()['attributes_data'];
$checkoutData = $product->getCheckoutData();
// Prepare attribute data
foreach ($attributesData as $attributeKey => $attribute) {
$attributesData[$attributeKey] = ['type' => $attribute['frontend_input'], 'title' => $attribute['frontend_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->getConfigurableOptionsBlock()->fillOptions($checkoutOptionsData);
}
示例6: getPrice
/**
* Returns the item price for the specified product.
*
* @param InjectableFixture $product
* @return array|string
*/
public function getPrice(InjectableFixture $product)
{
$productName = $product->getName();
if ($product instanceof ConfigurableProduct) {
// Find the price for the specific configurable product that was purchased
$configurableAttributes = $product->getConfigurableAttributes();
$productOptions = $product->getCheckoutData()['options']['configurable_options'];
$checkoutOption = reset($productOptions);
$attributeKey = $checkoutOption['title'];
$optionKey = $checkoutOption['value'];
$attributeValue = $configurableAttributes[$attributeKey]['label']['value'];
$optionValue = $configurableAttributes[$attributeKey][$optionKey]['option_label']['value'];
$productDisplay = $productName . ' SKU: ' . $product->getVariationSku($checkoutOption);
$productDisplay .= ' ' . $attributeValue . ' ' . $optionValue;
} else {
$productDisplay = $productName . ' SKU: ' . $product->getSku();
}
$selector = '//tr[normalize-space(td)="' . $productDisplay . '"]' . $this->priceSelector;
return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText();
}
示例7: addToWishlist
/**
* Add product to Wishlist.
*
* @param InjectableFixture $product
* @return void
*/
public function addToWishlist(InjectableFixture $product)
{
$checkoutData = $product->getCheckoutData();
$this->fillOptions($product);
if (isset($checkoutData['qty'])) {
$this->setQty($checkoutData['qty']);
}
$this->clickAddToWishlist();
}
示例8: fillOptions
/**
* Fill grouped product options.
*
* @param InjectableFixture $product
* @return void
*/
public function fillOptions(InjectableFixture $product)
{
$checkoutData = $checkoutData = $product->getCheckoutData();
$associatedProducts = $product->getAssociated();
if (isset($checkoutData['options'])) {
$groupedBlock = $this->getGroupedProductBlock();
foreach ($checkoutData['options'] as $key => $option) {
$groupedBlock->getGroupedItemForm($associatedProducts[$key]['name'])->fillOption($option);
}
}
}
示例9: 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);
}
}
示例10: 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;
}
示例11: getDefaultItemData
/**
* Get default item data.
*
* @param InjectableFixture $product
* @param array|null $verifyData
* @return array
*/
protected function getDefaultItemData(InjectableFixture $product, array $verifyData = null)
{
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();
$defaultData['item_qty'] = isset($verifyData['qty']) ? $verifyData['qty'] : $checkoutData['qty'];
$defaultData = array_merge($defaultData, $this->getProductData($product));
return $defaultData;
}
示例12: getCheckoutDataOptions
/**
* Get checkout data options.
*
* @param InjectableFixture $product
* @param string $optionKey
* @return array
*/
protected function getCheckoutDataOptions(InjectableFixture $product, $optionKey = '')
{
$checkoutData = $product->getCheckoutData();
return $optionKey == '' ? isset($checkoutData['options']) ? $checkoutData['options'] : [] : (isset($checkoutData['options'][$optionKey]) ? $checkoutData['options'][$optionKey] : []);
}
示例13: fillCheckoutData
/**
* Fill checkout data.
*
* @param InjectableFixture $product
* @return void
*/
protected function fillCheckoutData(InjectableFixture $product)
{
$qty = $product->getCheckoutData()['qty'];
$this->catalogProductView->getViewBlock()->fillOptions($product);
$this->catalogProductView->getViewBlock()->setQty($qty);
}
示例14: getProductPrice
/**
* Get product price.
*
* @param InjectableFixture $product
* @return int
*/
protected function getProductPrice(InjectableFixture $product)
{
return isset($product->getCheckoutData()['cartItem']['price']) ? $product->getCheckoutData()['cartItem']['price'] : $product->getPrice();
}