Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Renderer Class Reference
Inheritance diagram for Renderer:
Renderer Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Helper\Data $taxHelper, PriceCurrencyInterface $priceCurrency, \Magento\Weee\Helper\Data $weeeHelper, array $data=[])
 
 displayPriceWithWeeeDetails ()
 
 getIncludeWeeeFlag ()
 
 getUnitDisplayPriceInclTax ()
 
 getBaseUnitDisplayPriceInclTax ()
 
 getRowDisplayPriceInclTax ()
 
 getBaseRowDisplayPriceInclTax ()
 
 getUnitDisplayPriceExclTax ()
 
 getBaseUnitDisplayPriceExclTax ()
 
 getRowDisplayPriceExclTax ()
 
 getBaseRowDisplayPriceExclTax ()
 
 getFinalUnitDisplayPriceInclTax ()
 
 getBaseFinalUnitDisplayPriceInclTax ()
 
 getFinalRowDisplayPriceInclTax ()
 
 getBaseFinalRowDisplayPriceInclTax ()
 
 getFinalUnitDisplayPriceExclTax ()
 
 getBaseFinalUnitDisplayPriceExclTax ()
 
 getFinalRowDisplayPriceExclTax ()
 
 getBaseFinalRowDisplayPriceExclTax ()
 
 displayFinalPrice ()
 
 getTotalAmount ($item)
 
 getBaseTotalAmount ($item)
 
- Public Member Functions inherited from Renderer
 __construct (Context $context, TaxHelper $taxHelper, PriceCurrencyInterface $priceCurrency, array $data=[])
 
 setItem ($item)
 
 getZone ()
 
 setZone ($zone)
 
 getStoreId ()
 
 getItem ()
 
 displayPriceInclTax ()
 
 displayPriceExclTax ()
 
 displayBothPrices ()
 
 formatPrice ($price)
 
 getItemDisplayPriceExclTax ()
 
 getTotalAmount ($item)
 
 getBaseTotalAmount ($item)
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Protected Attributes

 $weeeHelper
 
- Protected Attributes inherited from Renderer
 $taxHelper
 
 $item
 
 $storeId = null
 
 $zone = null
 
 $priceCurrency
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Item price render block

@api

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m
Since
100.0.2

Definition at line 21 of file Renderer.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Template\Context  $context,
\Magento\Tax\Helper\Data  $taxHelper,
PriceCurrencyInterface  $priceCurrency,
\Magento\Weee\Helper\Data  $weeeHelper,
array  $data = [] 
)
Parameters
\Magento\Framework\View\Element\Template\Context$context
\Magento\Tax\Helper\Data$taxHelper
PriceCurrencyInterface$priceCurrency
\Magento\Weee\Helper\Data$weeeHelper
array$data

Definition at line 35 of file Renderer.php.

41  {
42  $this->weeeHelper = $weeeHelper;
43  parent::__construct($context, $taxHelper, $priceCurrency, $data);
44  $this->_isScopePrivate = true;
45  }

Member Function Documentation

◆ displayFinalPrice()

displayFinalPrice ( )

Whether to display final price that include Weee amounts

Returns
bool

Definition at line 401 of file Renderer.php.

402  {
403  $flag = $this->weeeHelper->typeOfDisplay(
404  WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL,
405  $this->getZone(),
406  $this->getStoreId()
407  );
408 
409  if (!$flag) {
410  return false;
411  }
412 
413  if ($this->weeeHelper->getWeeeTaxAppliedAmount($this->getItem()) <= 0) {
414  return false;
415  }
416  return true;
417  }

◆ displayPriceWithWeeeDetails()

displayPriceWithWeeeDetails ( )

Whether to display weee details together with price

Returns
bool

Definition at line 52 of file Renderer.php.

53  {
54  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
55  return false;
56  }
57 
58  $displayWeeeDetails = $this->weeeHelper->typeOfDisplay(
59  [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL],
60  $this->getZone(),
61  $this->getStoreId()
62  );
63  if (!$displayWeeeDetails) {
64  return false;
65  }
66  if ($this->weeeHelper->getWeeeTaxAppliedAmount($this->getItem()) <= 0) {
67  return false;
68  }
69 
70  return true;
71  }

◆ getBaseFinalRowDisplayPriceExclTax()

getBaseFinalRowDisplayPriceExclTax ( )

Get base final row display price excluding tax, this will add Weee amount to rowTotal

Returns
float

Definition at line 385 of file Renderer.php.

386  {
387  $baseRowTotalExclTax = $this->getItem()->getBaseRowTotal();
388 
389  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
390  return $baseRowTotalExclTax;
391  }
392 
393  return $baseRowTotalExclTax + $this->getItem()->getBaseWeeeTaxAppliedRowAmnt();
394  }

◆ getBaseFinalRowDisplayPriceInclTax()

getBaseFinalRowDisplayPriceInclTax ( )

Get base final row display price including tax, this will add weee amount to rowTotalInclTax

Returns
float

Definition at line 315 of file Renderer.php.

316  {
317  $baseRowTotalInclTax = $this->getItem()->getBaseRowTotalInclTax();
318 
319  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
320  return $baseRowTotalInclTax;
321  }
322 
323  return $baseRowTotalInclTax + $this->weeeHelper->getBaseRowWeeeTaxInclTax($this->getItem());
324  }

◆ getBaseFinalUnitDisplayPriceExclTax()

getBaseFinalUnitDisplayPriceExclTax ( )

Get base final unit display price excluding tax

Returns
float

Definition at line 347 of file Renderer.php.

348  {
349  $orderItem = $this->getItem();
350  if ($orderItem instanceof InvoiceItem || $orderItem instanceof CreditMemoItem) {
351  $orderItem = $orderItem->getOrderItem();
352  }
353 
354  $qty = $orderItem->getQtyOrdered();
355  $basePriceExclTax = $orderItem->getBaseRowTotal() / $qty;
356 
357  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
358  return $basePriceExclTax;
359  }
360 
361  return $basePriceExclTax + $this->getItem()->getBaseWeeeTaxAppliedAmount();
362  }
$orderItem
Definition: order.php:30

◆ getBaseFinalUnitDisplayPriceInclTax()

getBaseFinalUnitDisplayPriceInclTax ( )

Get base final unit display price including tax, this will add Weee amount to unit price include tax

Returns
float

Definition at line 283 of file Renderer.php.

284  {
285  $basePriceInclTax = $this->getItem()->getBasePriceInclTax();
286 
287  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
288  return $basePriceInclTax;
289  }
290 
291  return $basePriceInclTax + $this->weeeHelper->getBaseWeeeTaxInclTax($this->getItem());
292  }

◆ getBaseRowDisplayPriceExclTax()

getBaseRowDisplayPriceExclTax ( )

Get base price for row total excluding tax. The Weee amount will be added to row total depending on Weee display setting

Returns
float

Definition at line 247 of file Renderer.php.

248  {
249  $baseRowTotalExclTax = $this->getItem()->getBaseRowTotal();
250 
251  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
252  return $baseRowTotalExclTax;
253  }
254 
255  if ($this->getIncludeWeeeFlag()) {
256  return $baseRowTotalExclTax + $this->getItem()->getBaseWeeeTaxAppliedRowAmnt();
257  }
258 
259  return $baseRowTotalExclTax;
260  }

◆ getBaseRowDisplayPriceInclTax()

getBaseRowDisplayPriceInclTax ( )

Get base price for row total including tax. The Weee amount will be added to row total including tax depending on Weee display setting

Returns
float

Definition at line 157 of file Renderer.php.

158  {
159  $baseRowTotalInclTax = $this->getItem()->getBaseRowTotalInclTax();
160 
161  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
162  return $baseRowTotalInclTax;
163  }
164 
165  if ($this->getIncludeWeeeFlag()) {
166  return $baseRowTotalInclTax + $this->weeeHelper->getBaseRowWeeeTaxInclTax($this->getItem());
167  }
168 
169  return $baseRowTotalInclTax;
170  }

◆ getBaseTotalAmount()

getBaseTotalAmount (   $item)

Return the total amount minus discount

Parameters
OrderItem | InvoiceItem | CreditMemoItem$item
Returns
mixed

Definition at line 442 of file Renderer.php.

443  {
444  $totalAmount = $item->getBaseRowTotal()
445  - $item->getBaseDiscountAmount()
446  + $item->getBaseTaxAmount()
447  + $item->getBaseDiscountTaxCompensationAmount()
448  + $this->weeeHelper->getBaseRowWeeeTaxInclTax($item);
449 
450  return $totalAmount;
451  }

◆ getBaseUnitDisplayPriceExclTax()

getBaseUnitDisplayPriceExclTax ( )

Get base price for unit price excluding tax. The Weee amount will be added to unit price depending on Weee display setting

Returns
float

Definition at line 199 of file Renderer.php.

200  {
201  $orderItem = $this->getItem();
202  if ($orderItem instanceof InvoiceItem || $orderItem instanceof CreditMemoItem) {
203  $orderItem = $orderItem->getOrderItem();
204  }
205 
206  $qty = $orderItem->getQtyOrdered();
207  $basePriceExclTax = $orderItem->getBaseRowTotal() / $qty;
208 
209  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
210  return $basePriceExclTax;
211  }
212 
213  if ($this->getIncludeWeeeFlag()) {
214  return $basePriceExclTax + $this->getItem()->getBaseWeeeTaxAppliedAmount();
215  }
216 
217  return $basePriceExclTax;
218  }
$orderItem
Definition: order.php:30

◆ getBaseUnitDisplayPriceInclTax()

getBaseUnitDisplayPriceInclTax ( )

Get base price for unit price including tax. The Weee amount will be added to unit price including tax depending on Weee display setting

Returns
float

Definition at line 115 of file Renderer.php.

116  {
117  $basePriceInclTax = $this->getItem()->getBasePriceInclTax();
118 
119  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
120  return $basePriceInclTax;
121  }
122 
123  if ($this->getIncludeWeeeFlag()) {
124  return $basePriceInclTax + $this->weeeHelper->getBaseWeeeTaxInclTax($this->getItem());
125  }
126 
127  return $basePriceInclTax;
128  }

◆ getFinalRowDisplayPriceExclTax()

getFinalRowDisplayPriceExclTax ( )

Get final row display price excluding tax, this will add Weee amount to rowTotal

Returns
float

Definition at line 369 of file Renderer.php.

370  {
371  $rowTotalExclTax = $this->getItem()->getRowTotal();
372 
373  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
374  return $rowTotalExclTax;
375  }
376 
377  return $rowTotalExclTax + $this->weeeHelper->getWeeeTaxAppliedRowAmount($this->getItem());
378  }

◆ getFinalRowDisplayPriceInclTax()

getFinalRowDisplayPriceInclTax ( )

Get final row display price including tax, this will add weee amount to rowTotalInclTax

Returns
float

Definition at line 299 of file Renderer.php.

300  {
301  $rowTotalInclTax = $this->getItem()->getRowTotalInclTax();
302 
303  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
304  return $rowTotalInclTax;
305  }
306 
307  return $rowTotalInclTax + $this->weeeHelper->getRowWeeeTaxInclTax($this->getItem());
308  }

◆ getFinalUnitDisplayPriceExclTax()

getFinalUnitDisplayPriceExclTax ( )

Get final unit display price excluding tax

Returns
float

Definition at line 331 of file Renderer.php.

332  {
333  $priceExclTax = $this->getItemDisplayPriceExclTax();
334 
335  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
336  return $priceExclTax;
337  }
338 
339  return $priceExclTax + $this->weeeHelper->getWeeeTaxAppliedAmount($this->getItem());
340  }

◆ getFinalUnitDisplayPriceInclTax()

getFinalUnitDisplayPriceInclTax ( )

Get final unit display price including tax, this will add Weee amount to unit price include tax

Returns
float

Definition at line 267 of file Renderer.php.

268  {
269  $priceInclTax = $this->getItem()->getPriceInclTax();
270 
271  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
272  return $priceInclTax;
273  }
274 
275  return $priceInclTax + $this->weeeHelper->getWeeeTaxInclTax($this->getItem());
276  }

◆ getIncludeWeeeFlag()

getIncludeWeeeFlag ( )

Return the flag whether to include weee in the price

Returns
bool|int

Definition at line 78 of file Renderer.php.

79  {
80  $includeWeee = $this->weeeHelper->typeOfDisplay(
81  [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL],
82  $this->getZone(),
83  $this->getStoreId()
84  );
85  return $includeWeee;
86  }

◆ getRowDisplayPriceExclTax()

getRowDisplayPriceExclTax ( )

Get display price for row total excluding tax. The Weee amount will be added to row total depending on Weee display setting

Returns
float

Definition at line 226 of file Renderer.php.

227  {
228  $rowTotalExclTax = $this->getItem()->getRowTotal();
229 
230  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
231  return $rowTotalExclTax;
232  }
233 
234  if ($this->getIncludeWeeeFlag()) {
235  return $rowTotalExclTax + $this->weeeHelper->getWeeeTaxAppliedRowAmount($this->getItem());
236  }
237 
238  return $rowTotalExclTax;
239  }

◆ getRowDisplayPriceInclTax()

getRowDisplayPriceInclTax ( )

Get display price for row total including tax. The Weee amount will be added to row total including tax depending on Weee display setting

Returns
float

Definition at line 136 of file Renderer.php.

137  {
138  $rowTotalInclTax = $this->getItem()->getRowTotalInclTax();
139 
140  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
141  return $rowTotalInclTax;
142  }
143 
144  if ($this->getIncludeWeeeFlag()) {
145  return $rowTotalInclTax + $this->weeeHelper->getRowWeeeTaxInclTax($this->getItem());
146  }
147 
148  return $rowTotalInclTax;
149  }

◆ getTotalAmount()

getTotalAmount (   $item)

Return the total amount minus discount

Parameters
OrderItem | InvoiceItem | CreditMemoItem$item
Returns
mixed

Definition at line 425 of file Renderer.php.

426  {
427  $totalAmount = $item->getRowTotal()
428  - $item->getDiscountAmount()
429  + $item->getTaxAmount()
430  + $item->getDiscountTaxCompensationAmount()
431  + $this->weeeHelper->getRowWeeeTaxInclTax($item);
432 
433  return $totalAmount;
434  }

◆ getUnitDisplayPriceExclTax()

getUnitDisplayPriceExclTax ( )

Get display price for unit price excluding tax. The Weee amount will be added to unit price depending on Weee display setting

Returns
float

Definition at line 178 of file Renderer.php.

179  {
180  $priceExclTax = $this->getItemDisplayPriceExclTax();
181 
182  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
183  return $priceExclTax;
184  }
185 
186  if ($this->getIncludeWeeeFlag()) {
187  return $priceExclTax + $this->weeeHelper->getWeeeTaxAppliedAmount($this->getItem());
188  }
189 
190  return $priceExclTax;
191  }

◆ getUnitDisplayPriceInclTax()

getUnitDisplayPriceInclTax ( )

Get display price for unit price including tax. The Weee amount will be added to unit price including tax depending on Weee display setting

Returns
float

Definition at line 94 of file Renderer.php.

95  {
96  $priceInclTax = $this->getItem()->getPriceInclTax();
97 
98  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
99  return $priceInclTax;
100  }
101 
102  if ($this->getIncludeWeeeFlag()) {
103  return $priceInclTax + $this->weeeHelper->getWeeeTaxInclTax($this->getItem());
104  }
105 
106  return $priceInclTax;
107  }

Field Documentation

◆ $weeeHelper

$weeeHelper
protected

Definition at line 26 of file Renderer.php.


The documentation for this class was generated from the following file: