本文整理汇总了PHP中Magento\Tax\Helper\Data::getDefaultCustomerTaxClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getDefaultCustomerTaxClass方法的具体用法?PHP Data::getDefaultCustomerTaxClass怎么用?PHP Data::getDefaultCustomerTaxClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Tax\Helper\Data
的用法示例。
在下文中一共展示了Data::getDefaultCustomerTaxClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareLayout
/**
* Prepare form for render
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var \Magento\Customer\Api\Data\GroupInterface $customerGroup */
if ($groupId === null) {
$customerGroup = $this->groupDataFactory->create();
$defaultCustomerTaxClass = $this->_taxHelper->getDefaultCustomerTaxClass();
} else {
$customerGroup = $this->_groupRepository->getById($groupId);
$defaultCustomerTaxClass = $customerGroup->getTaxClassId();
}
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Group Information')]);
$validateClass = sprintf('required-entry validate-length maximum-length-%d', \Magento\Customer\Model\GroupManagement::GROUP_CODE_MAX_LENGTH);
$name = $fieldset->addField('customer_group_code', 'text', ['name' => 'code', 'label' => __('Group Name'), 'title' => __('Group Name'), 'note' => __('Maximum length must be less then %1 symbols', \Magento\Customer\Model\GroupManagement::GROUP_CODE_MAX_LENGTH), 'class' => $validateClass, 'required' => true]);
if ($customerGroup->getId() == 0 && $customerGroup->getCode()) {
$name->setDisabled(true);
}
$fieldset->addField('tax_class_id', 'select', ['name' => 'tax_class', 'label' => __('Tax Class'), 'title' => __('Tax Class'), 'class' => 'required-entry', 'required' => true, 'values' => $this->_taxCustomer->toOptionArray()]);
if ($customerGroup->getId() !== null) {
// If edit add id
$form->addField('id', 'hidden', ['name' => 'id', 'value' => $customerGroup->getId()]);
}
if ($this->_backendSession->getCustomerGroupData()) {
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
} else {
// TODO: need to figure out how the DATA can work with forms
$form->addValues(['id' => $customerGroup->getId(), 'customer_group_code' => $customerGroup->getCode(), 'tax_class_id' => $defaultCustomerTaxClass]);
}
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('customer/*/save'));
$form->setMethod('post');
$this->setForm($form);
}
示例2: getDefaultCustomerTaxClass
/**
* Identify default customer tax class ID.
*
* @return int|null
*/
public function getDefaultCustomerTaxClass()
{
$configValue = $this->taxHelper->getDefaultCustomerTaxClass();
if (!empty($configValue)) {
return $configValue;
}
$taxClasses = $this->customerTaxClassSource->getAllOptions(false);
if (!empty($taxClasses)) {
$firstClass = array_shift($taxClasses);
return isset($firstClass['value']) ? $firstClass['value'] : null;
} else {
return null;
}
}
示例3: testGetDefaultCustomerTaxClass
/**
* @magentoConfigFixture default_store tax/classes/default_customer_tax_class 1
*/
public function testGetDefaultCustomerTaxClass()
{
$this->assertEquals(1, $this->helper->getDefaultCustomerTaxClass());
}