...
Note |
---|
TODO - BE documentation and review of documentation is needed |
Adding an additional dropdown field with content type to the form
vendor/creativestyle/magesuite-business-checkout/Processor/Layout/CustomerTypeField.php:29
Code Block | ||
---|---|---|
| ||
class CustomerTypeField extends \Magento\Checkout\Model\Layout\AbstractTotalsProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcessorInterface
{
public function process($jsLayout)
{
if(!$this->configuration->isEnabled()){
return $jsLayout;
}
$customField = $this->getExtensionAttributeFieldAsArray();
$newJsLayout = [
'components' => [
'checkout' => [
'children' => [
'steps' => [
'children' => [
'shipping-step' => [
'children' => [
'shippingAddress' => [
'children' => [
'shipping-address-fieldset' => [
'children' => [
\MageSuite\BusinessCheckout\Helper\Configuration::CUSTOMER_TYPE_ATTRIBUTE => $customField
]
]
]
]
]
]
]
]
]
]
]
];
$jsLayout = array_merge_recursive($jsLayout, $newJsLayout);
return $jsLayout;
}
} |
vendor/creativestyle/magesuite-business-checkout/Model/Entity/Attribute/Source/CustomerType.php:10
Code Block |
---|
class CustomerType extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = [
['value' => self::PRIVATE, 'label' => __('Private')],
['value' => self::BUSINESS, 'label' => __('Business')]
];
}
return $this->_options;
}
} |
Saving address form
vendor/creativestyle/magesuite-business-checkout/Plugin/Checkout/Model/ShippingInformationManagement/SaveCustomerTypeInQuote.php:16
Code Block |
---|
class SaveCustomerTypeInQuote
{
public function beforeSaveAddressInformation(
\Magento\Checkout\Model\ShippingInformationManagement $subject,
$cartId,
\Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
)
{
$shippingAddress = $addressInformation->getShippingAddress();
.....
$customerType = $shippingAddress->getExtensionAttributes()->getCustomerType();
.....
$quote = $this->quoteRepository->getActive($cartId);
$quote->setCustomerType($customerType);
return [$cartId, $addressInformation];
}
} |
Frontend
With business checkout there is an additional dropdown field in the forms:
...