本文整理汇总了PHP中Magento\Core\Helper\Data::currencyByStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::currencyByStore方法的具体用法?PHP Data::currencyByStore怎么用?PHP Data::currencyByStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Core\Helper\Data
的用法示例。
在下文中一共展示了Data::currencyByStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCurrencyByStore
/**
* @param string $amount
* @param string $store
* @param bool $format
* @param bool $includeContainer
* @param string $result
* @dataProvider currencyByStoreDataProvider
*/
public function testCurrencyByStore($amount, $store, $format, $includeContainer, $result)
{
if ($format) {
$this->priceCurrency->expects($this->once())->method('convertAndFormat')->with($amount, $includeContainer, PriceCurrencyInterface::DEFAULT_PRECISION, $store)->will($this->returnValue($result));
} else {
$this->priceCurrency->expects($this->once())->method('convert')->with($amount, $store)->will($this->returnValue($result));
}
$this->assertEquals($result, $this->model->currencyByStore($amount, $store, $format, $includeContainer));
}
示例2: getSelectionPrice
/**
* Get price for selection product
*
* @param \Magento\Catalog\Model\Product $selection
* @return int|float
*/
public function getSelectionPrice($selection)
{
$price = 0;
$store = $this->getProduct()->getStore();
if ($selection) {
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $selection, 1);
if (is_numeric($price)) {
$price = $this->_coreHelper->currencyByStore($price, $store, false);
}
}
return is_numeric($price) ? $price : 0;
}
示例3: getCurrencyPrice
/**
* Returns price converted to current currency rate
*
* @param float $price
* @return float
*/
public function getCurrencyPrice($price)
{
$store = $this->getProduct()->getStore();
return $this->_coreHelper->currencyByStore($price, $store, false);
}
示例4: getValuesHtml
/**
* Return html for control element
*
* @return string
*/
public function getValuesHtml()
{
$_option = $this->getOption();
$configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $_option->getId());
$store = $this->getProduct()->getStore();
$this->setSkipJsReloadPrice(1);
// Remove inline prototype onclick and onchange events
if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DROP_DOWN || $_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_MULTIPLE) {
$require = $_option->getIsRequire() ? ' required' : '';
$extraParams = '';
$select = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setData(array('id' => 'select_' . $_option->getId(), 'class' => $require . ' product-custom-option'));
if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DROP_DOWN) {
$select->setName('options[' . $_option->getid() . ']')->addOption('', __('-- Please Select --'));
} else {
$select->setName('options[' . $_option->getid() . '][]');
$select->setClass('multiselect' . $require . ' product-custom-option');
}
foreach ($_option->getValues() as $_value) {
$priceStr = $this->_formatPrice(array('is_percent' => $_value->getPriceType() == 'percent', 'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent')), false);
$select->addOption($_value->getOptionTypeId(), $_value->getTitle() . ' ' . $priceStr . '', array('price' => $this->_coreHelper->currencyByStore($_value->getPrice(true), $store, false)));
}
if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_MULTIPLE) {
$extraParams = ' multiple="multiple"';
}
if (!$this->getSkipJsReloadPrice()) {
$extraParams .= ' onchange="opConfig.reloadPrice()"';
}
$select->setExtraParams($extraParams);
if ($configValue) {
$select->setValue($configValue);
}
return $select->getHtml();
}
if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_RADIO || $_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_CHECKBOX) {
$selectHtml = '<div class="options-list nested" id="options-' . $_option->getId() . '-list">';
$require = $_option->getIsRequire() ? ' required' : '';
$arraySign = '';
switch ($_option->getType()) {
case \Magento\Catalog\Model\Product\Option::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio';
if (!$_option->getIsRequire()) {
$selectHtml .= '<div class="field choice"><input type="radio" id="options_' . $_option->getId() . '" class="' . $class . ' product-custom-option" name="options[' . $_option->getId() . ']"' . ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') . ' value="" checked="checked" /><label class="label" for="options_' . $_option->getId() . '"><span>' . __('None') . '</span></label></div>';
}
break;
case \Magento\Catalog\Model\Product\Option::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox';
$arraySign = '[]';
break;
}
$count = 1;
foreach ($_option->getValues() as $_value) {
$count++;
$priceStr = $this->_formatPrice(array('is_percent' => $_value->getPriceType() == 'percent', 'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent')));
$htmlValue = $_value->getOptionTypeId();
if ($arraySign) {
$checked = is_array($configValue) && in_array($htmlValue, $configValue) ? 'checked' : '';
} else {
$checked = $configValue == $htmlValue ? 'checked' : '';
}
$selectHtml .= '<div class="field choice ' . $require . '">' . '<input type="' . $type . '" class="' . $class . ' ' . $require . ' product-custom-option"' . ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') . ' name="options[' . $_option->getId() . ']' . $arraySign . '" id="options_' . $_option->getId() . '_' . $count . '" value="' . $htmlValue . '" ' . $checked . ' price="' . $this->_coreHelper->currencyByStore($_value->getPrice(true), $store, false) . '" />' . '<label class="label" for="options_' . $_option->getId() . '_' . $count . '"><span>' . $_value->getTitle() . '</span>' . $priceStr . '</label>';
$selectHtml .= '</div>';
}
$selectHtml .= '</div>';
return $selectHtml;
}
}