本文整理汇总了PHP中Magento\Framework\Object::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getPrice方法的具体用法?PHP Object::getPrice怎么用?PHP Object::getPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getPrice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAllItems
public function testGetAllItems()
{
$totals = $this->_prepareValidModelData();
$this->assertEquals([new \Magento\Framework\Object(['name' => $this->_validItem->getName(), 'qty' => $this->_validItem->getQty(), 'amount' => $this->_validItem->getPrice()])], $this->_model->getAllItems());
$this->assertEquals($totals['subtotal'], $this->_model->getSubtotal());
$this->assertEquals($totals['tax'], $this->_model->getTax());
$this->assertEquals($totals['shipping'], $this->_model->getShipping());
$this->assertEquals($totals['discount'], $this->_model->getDiscount());
}
示例2: render
/**
* Render minimal price for downloadable products
*
* @param \Magento\Framework\Object $row
* @return string
*/
public function render(\Magento\Framework\Object $row)
{
if ($row->getTypeId() == 'downloadable') {
$row->setPrice($row->getPrice());
}
return parent::render($row);
}
示例3: validate
/**
* Validate Product Rule Condition
*
* @param \Magento\Framework\Object $object
* @return bool
*/
public function validate(\Magento\Framework\Object $object)
{
//@todo reimplement this method when is fixed MAGETWO-5713
/** @var \Magento\Catalog\Model\Product $product */
$product = $object->getProduct();
if (!$product instanceof \Magento\Catalog\Model\Product) {
$product = $this->_productFactory->create()->load($object->getProductId());
}
$product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal());
return parent::validate($product);
}
示例4: testGetPrice
/**
* @param \Magento\Framework\Object $input
* @param float $expectOutputPrice
* @param string[] $configs
* @param string $productClassName
*
* @magentoDataFixture Magento/Catalog/_files/products.php
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Customer/_files/customer_address.php
* @magentoDbIsolation enabled
* @dataProvider getPriceDataProvider
*/
public function testGetPrice($input, $expectOutputPrice, $configs = [], $productClassName = 'DefaultProductClass')
{
$this->setUpDefaultRules();
$fixtureProductId = 1;
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->objectManager->create('Magento\\Catalog\\Model\\Product')->load($fixtureProductId);
$product->setTaxClassId($this->taxClasses[$productClassName]);
$shippingAddress = $this->getCustomerAddress();
$billingAddress = $shippingAddress;
foreach ($configs as $config) {
$this->scopeConfig->setValue($config['path'], $config['value'], ScopeInterface::SCOPE_STORE, 'default');
}
$price = $this->helper->getPrice($product, $input->getPrice(), $input->getIncludingTax(), $shippingAddress, $billingAddress, $this->taxClasses['DefaultCustomerClass'], $input->getStore(), $input->getPriceIncludesTax(), $input->getRoundPrice());
$this->assertEquals($expectOutputPrice, $price);
}
示例5: renderShippingRateOption
/**
* Get shipping rate code title and its price or error message
*
* @param \Magento\Framework\Object $rate
* @param string $format
* @param string $inclTaxFormat
* @return string
*/
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
{
$renderedInclTax = '';
if ($rate->getErrorMessage()) {
$price = $rate->getErrorMessage();
} else {
$price = $this->_getShippingPrice($rate->getPrice(), $this->_taxHelper->displayShippingPriceIncludingTax());
$incl = $this->_getShippingPrice($rate->getPrice(), true);
if ($incl != $price && $this->_taxHelper->displayShippingBothPrices()) {
$renderedInclTax = sprintf($inclTaxFormat, __('Incl. Tax'), $incl);
}
}
return sprintf($format, $this->escapeHtml($rate->getMethodTitle()), $price, $renderedInclTax);
}
示例6: displayPriceInclTax
/**
* Retrieve include tax html formatted content
*
* @param \Magento\Framework\Object $item
* @return string
*/
public function displayPriceInclTax(\Magento\Framework\Object $item)
{
$qty = $item->getQtyOrdered() ? $item->getQtyOrdered() : ($item->getQty() ? $item->getQty() : 1);
$baseTax = $item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : ($item->getTaxAmount() ? $item->getTaxAmount() : 0);
$tax = $item->getBaseTaxBeforeDiscount() ? $item->getBaseTaxBeforeDiscount() : ($item->getBaseTaxAmount() ? $item->getBaseTaxAmount() : 0);
$basePriceTax = 0;
$priceTax = 0;
if (floatval($qty)) {
$basePriceTax = $item->getBasePrice() + $baseTax / $qty;
$priceTax = $item->getPrice() + $tax / $qty;
}
return $this->displayPrices($this->getOrder()->getStore()->roundPrice($basePriceTax), $this->getOrder()->getStore()->roundPrice($priceTax));
}
示例7: _getInitialItem
/**
* Create and return new order item based on payment item data and $itemInfo
* for initial payment
*
* @param \Magento\Framework\Object $itemInfo
* @return \Magento\Sales\Model\Order\Item
*/
protected function _getInitialItem($itemInfo)
{
$price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getInitAmount();
$shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : 0;
$taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : 0;
$item = $this->_orderItemFactory->create()->setStoreId($this->getStoreId())->setProductType(\Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL)->setIsVirtual(1)->setSku('initial_fee')->setName(__('Recurring Payment Initial Fee'))->setDescription('')->setWeight(0)->setQtyOrdered(1)->setPrice($price)->setOriginalPrice($price)->setBasePrice($price)->setBaseOriginalPrice($price)->setRowTotal($price)->setBaseRowTotal($price)->setTaxAmount($taxAmount)->setShippingAmount($shippingAmount);
$option = array('label' => __('Payment type'), 'value' => __('Initial period payment'));
$this->_addAdditionalOptionToItem($item, $option);
return $item;
}