Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function afterProcess (
- MagentoCheckoutBlockCheckoutLayoutProcessor $subject,
- array $jsLayout
- ) {
- $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
- ['shippingAddress']['children']['shippingAdditional'] = [
- 'component' => 'uiComponent',
- 'displayArea' => 'shippingAdditional',
- 'children' => [
- 'terminal' => [
- 'component' => 'Vendor_Module/js/methods/method',
- 'config' => [
- 'customScope' => 'shippingAddress',
- 'template' => 'ui/form/field',
- 'elementTmpl' => 'Vendor_Module/method',
- 'options' => [],
- ],
- 'dataScope' => 'shippingAddress.method_terminal',
- 'label' => '',
- 'provider' => 'checkoutProvider',
- 'visible' => true,
- 'validation' => [ 'select-terminal-required' => true ],
- 'sortOrder' => 200,
- ]
- ],
- ];
- return $jsLayout;
- }
- <div data-bind="visible: selectedMethod () == 'vendor_terminal'">
- <label data-bind="i18n: 'Select'"></label>
- <select name="vendor-terminal" class="select-terminal-required" id="terminal-list" data-bind="html: getTerminalList ()">
- </select>
- </div>
- var config = {
- config: {
- mixins: {
- 'Magento_Ui/js/lib/validation/validator': {
- 'Vendor_Module/js/validation-mixin': true
- },
- }
- }
- define([
- 'jquery',
- 'Magento_Checkout/js/model/quote',
- 'Magento_Ui/js/lib/validation/utils'
- ], function ($, quote, utils) {
- "use strict";
- return function ( validator ) {
- validator.addRule ( 'select-terminal-required', function () {
- var method = quote.shippingMethod();
- var validation = method.method_code === 'vendor_terminal' && utils.isEmpty($( '.select-terminal-required' ).val ());
- return !validation;
- }, $.mage.__( 'Please select terminal.' ) );
- return validator;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement