本文整理匯總了PHP中Mtf\Fixture\FixtureInterface::getPrice方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::getPrice方法的具體用法?PHP FixtureInterface::getPrice怎麽用?PHP FixtureInterface::getPrice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::getPrice方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$cartBlock = $checkoutCart->getCartBlock();
$productName = $product->getName();
$productOptions = $product->getCustomOptions();
$priceComparing = $product->getPrice();
if ($groupPrice = $product->getGroupPrice()) {
$groupPrice = reset($groupPrice);
$priceComparing = $groupPrice['price'];
}
if ($specialPrice = $product->getSpecialPrice()) {
$priceComparing = $specialPrice;
}
if (!empty($productOptions)) {
$productOption = reset($productOptions);
$optionsData = reset($productOption['options']);
$optionName = $cartBlock->getCartItemOptionsNameByProductName($productName);
$optionValue = $cartBlock->getCartItemOptionsValueByProductName($productName);
\PHPUnit_Framework_Assert::assertTrue(trim($optionName) === $productOption['title'] && trim($optionValue) === $optionsData['title'], 'In the cart wrong option product.');
if ($optionsData['price_type'] === 'Percent') {
$priceComparing = $priceComparing * (1 + $optionsData['price'] / 100);
} else {
$priceComparing += $optionsData['price'];
}
}
$price = $checkoutCart->getCartBlock()->getProductPriceByName($productName);
\PHPUnit_Framework_Assert::assertEquals(number_format($priceComparing, 2), $price, 'Product price in shopping cart is not correct.');
}
示例2: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$customOptions = $product->getCustomOptions();
$checkoutData = $product->getCheckoutData();
$checkoutCustomOptions = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : [];
$fixturePrice = $product->getPrice();
$groupPrice = $product->getGroupPrice();
$specialPrice = $product->getSpecialPrice();
$cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
$formPrice = $cartItem->getPrice();
if ($groupPrice) {
$groupPrice = reset($groupPrice);
$fixturePrice = $groupPrice['price'];
}
if ($specialPrice) {
$fixturePrice = $specialPrice;
}
$fixtureActualPrice = $fixturePrice;
foreach ($checkoutCustomOptions as $checkoutOption) {
$attributeKey = $checkoutOption['title'];
$optionKey = $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(number_format($fixtureActualPrice, 2), $formPrice, 'Product price in shopping cart is not correct.');
}
示例3: processAssert
/**
* Assert that duplicated product is found by sku and has correct product type, product template,
* product status disabled and out of stock
*
* @param FixtureInterface $product
* @param CatalogProductIndex $productGrid
* @return void
*/
public function processAssert(FixtureInterface $product, CatalogProductIndex $productGrid)
{
$config = $product->getDataConfig();
$filter = ['name' => $product->getName(), 'visibility' => $product->getVisibility(), 'status' => 'Disabled', 'sku' => $product->getSku() . '-1', 'type' => ucfirst($config['create_url_params']['type']) . ' Product', 'price_to' => number_format($product->getPrice(), 2)];
$productGrid->open()->getProductGrid()->search($filter);
$filter['price_to'] = '$' . $filter['price_to'];
\PHPUnit_Framework_Assert::assertTrue($productGrid->getProductGrid()->isRowVisible($filter, false), 'Product duplicate is absent in Products grid.');
}
示例4: assertOnProductView
/**
* Assert prices on the product view page
*
* @param CatalogProductView $catalogProductView
* @return void
*/
protected function assertOnProductView(CatalogProductView $catalogProductView)
{
$viewBlock = $catalogProductView->getViewBlock();
$price = $viewBlock->getProductPriceBlock()->getPrice();
$errorsMessages = ['name' => '- product name on product view page is not correct.', 'sku' => '- product sku on product view page is not correct.', 'regular_price' => '- product regular price on product view page is not correct.', 'short_description' => '- product short description on product view page is not correct.', 'description' => '- product description on product view page is not correct.'];
$dataOnPage = ['name' => $viewBlock->getProductName(), 'sku' => $viewBlock->getProductSku(), 'regular_price' => $price['price_regular_price']];
$compareData = ['name' => $this->product->getName(), 'sku' => $this->product->getSku(), 'regular_price' => number_format($this->product->getPrice(), 2)];
if ($productShortDescription = $this->product->getShortDescription()) {
$compareData['short_description'] = $productShortDescription;
$dataOnPage['short_description'] = $viewBlock->getProductShortDescription();
}
if ($productDescription = $this->product->getDescription()) {
$compareData['description'] = $productDescription;
$dataOnPage['description'] = $viewBlock->getProductDescription();
}
$badValues = array_diff($dataOnPage, $compareData);
$errorsMessages = array_merge($this->assertSpecialPrice($price), array_intersect_key($errorsMessages, array_keys($badValues)));
\PHPUnit_Framework_Assert::assertTrue(empty($errorsMessages), PHP_EOL . 'Found the following errors:' . PHP_EOL . implode(' ' . PHP_EOL, $errorsMessages));
}
示例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 ConfigurableProductInjectable) {
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['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;
}
示例6: prepareOptionArray
/**
* Preparation options before comparing
*
* @param array $options
* @return array
*/
protected function prepareOptionArray(array $options)
{
$result = [];
$productPrice = $this->product->hasData('group_price') ? $this->product->getGroupPrice()[0]['price'] : $this->product->getPrice();
$placeholder = ['Yes' => true, 'No' => false];
foreach ($options as $option) {
$result[$option['title']]['is_require'] = $placeholder[$option['is_require']];
$result[$option['title']]['title'] = $option['title'];
$result[$option['title']]['price'] = [];
foreach ($option['options'] as $optionValue) {
if ($optionValue['price_type'] === 'Percent') {
$optionValue['price'] = $productPrice / 100 * $optionValue['price'];
}
$result[$option['title']]['price'][] = number_format($optionValue['price'], 2);
}
}
return $result;
}
示例7: prepareOptions
/**
* Preparation options before comparing
*
* @param FixtureInterface $product
* @param int|null $actualPrice
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function prepareOptions(FixtureInterface $product, $actualPrice = null)
{
$result = [];
$customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : null;
$actualPrice = $actualPrice ? $actualPrice : $product->getPrice();
foreach ($customOptions as $customOption) {
$skippedField = isset($this->skippedFieldOptions[$customOption['type']]) ? $this->skippedFieldOptions[$customOption['type']] : [];
foreach ($customOption['options'] as &$option) {
// recalculate percent price
if ('Percent' == $option['price_type']) {
$option['price'] = $actualPrice * $option['price'] / 100;
$option['price'] = round($option['price'], 2);
}
$option = array_diff_key($option, array_flip($skippedField));
}
$result[$customOption['title']] = $customOption;
}
return $result;
}
示例8: assertPrice
/**
* Verify product price on category view page
*
* @param FixtureInterface $product
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
protected function assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
{
$price = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($product->getName())->getRegularPrice();
\PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $price, 'Product regular price on category page is not correct.');
}
示例9: preparePrice
/**
* Prepare Price data
*
* @param array $price
* @return array
*/
protected function preparePrice($price)
{
return [['regular_price' => $price['price_regular_price']], ['regular_price' => number_format($this->product->getPrice(), 2)]];
}