Magento 2 - Custom additional checkout field validation not working when customer is logged invalidation not working - magento 2Checkout shipping additional hidden field validationHow to clear billing form validation errors when using Magento UI componentsMagento 2 checkout input field validation possibilityCE v1.9.3.4 (v2) did NOT fix the “Enable Form Key Validation On Checkout” Was released July 12,2017Magento 2 checkout custom field validationMagento 2.2.1: Add Custom Upload file attribute in CheckoutAdding custom validation to checkout fieldCustom validation not working in checkoutHow to add custom validation to checkout phone field
Create two random teams from a list of players
What does 「ちんちんかいかい」 mean?
How do I respond appropriately to an overseas company that obtained a visa for me without hiring me?
How and when is the best time to reveal to new hires you are trans?
Russian pronunciation of /etc (a directory)
Was Donald Trump at ground zero helping out on 9-11?
Numerically Stable IIR filter
How do I make my photos have more impact?
What is the full text of the song about the failed battle of Kiska?
What is the term for completing a route uncleanly?
How did Biff return to 2015 from 1955 without a lightning strike?
When did J.K. Rowling decide to make Ron and Hermione a couple?
Gold Battle KoTH
Derivative is just speed of change?
Applications of pure mathematics in operations research
Why “deal 6 damage” is a legit phrase?
How to calculate points under the curve?
If I buy and download a game through second Nintendo account do I own it on my main account too?
Help me, I hate squares!
Avoiding Implicit Conversion in Constructor. Explicit keyword doesn't help here
Password management for kids - what's a good way to start?
Planting Trees in Outer Space
Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?
May a hotel provide accommodation for fewer people than booked?
Magento 2 - Custom additional checkout field validation not working when customer is logged in
validation not working - magento 2Checkout shipping additional hidden field validationHow to clear billing form validation errors when using Magento UI componentsMagento 2 checkout input field validation possibilityCE v1.9.3.4 (v2) did NOT fix the “Enable Form Key Validation On Checkout” Was released July 12,2017Magento 2 checkout custom field validationMagento 2.2.1: Add Custom Upload file attribute in CheckoutAdding custom validation to checkout fieldCustom validation not working in checkoutHow to add custom validation to checkout phone field
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've added a custom checkout field with validation in additional shipping area using a layout processor plugin.
VendorModuleModelCheckoutLayoutProcessorPlugin.php
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;
In my phtml template file i have custom select that i wan't to validate:
<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>
And I added custom validation mixin for this field.
require-config.js
var config = {
config:
mixins:
'Magento_Ui/js/lib/validation/validator':
'Vendor_Module/js/validation-mixin': true
,
validation-mixin.js
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;
);
My approach is that when a customer tries to go to the payment step without selecting any value it would fire a validation error. And it does until the customer is logged in and added his shipping address to he's address book. And it fires when a customer tries to change the address information inside checkout. I need validation that fires when a customer tries to go to the next step of checkout. Does anyone know any solution for this?
magento2 checkout validation
add a comment |
I've added a custom checkout field with validation in additional shipping area using a layout processor plugin.
VendorModuleModelCheckoutLayoutProcessorPlugin.php
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;
In my phtml template file i have custom select that i wan't to validate:
<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>
And I added custom validation mixin for this field.
require-config.js
var config = {
config:
mixins:
'Magento_Ui/js/lib/validation/validator':
'Vendor_Module/js/validation-mixin': true
,
validation-mixin.js
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;
);
My approach is that when a customer tries to go to the payment step without selecting any value it would fire a validation error. And it does until the customer is logged in and added his shipping address to he's address book. And it fires when a customer tries to change the address information inside checkout. I need validation that fires when a customer tries to go to the next step of checkout. Does anyone know any solution for this?
magento2 checkout validation
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00
add a comment |
I've added a custom checkout field with validation in additional shipping area using a layout processor plugin.
VendorModuleModelCheckoutLayoutProcessorPlugin.php
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;
In my phtml template file i have custom select that i wan't to validate:
<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>
And I added custom validation mixin for this field.
require-config.js
var config = {
config:
mixins:
'Magento_Ui/js/lib/validation/validator':
'Vendor_Module/js/validation-mixin': true
,
validation-mixin.js
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;
);
My approach is that when a customer tries to go to the payment step without selecting any value it would fire a validation error. And it does until the customer is logged in and added his shipping address to he's address book. And it fires when a customer tries to change the address information inside checkout. I need validation that fires when a customer tries to go to the next step of checkout. Does anyone know any solution for this?
magento2 checkout validation
I've added a custom checkout field with validation in additional shipping area using a layout processor plugin.
VendorModuleModelCheckoutLayoutProcessorPlugin.php
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;
In my phtml template file i have custom select that i wan't to validate:
<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>
And I added custom validation mixin for this field.
require-config.js
var config = {
config:
mixins:
'Magento_Ui/js/lib/validation/validator':
'Vendor_Module/js/validation-mixin': true
,
validation-mixin.js
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;
);
My approach is that when a customer tries to go to the payment step without selecting any value it would fire a validation error. And it does until the customer is logged in and added his shipping address to he's address book. And it fires when a customer tries to change the address information inside checkout. I need validation that fires when a customer tries to go to the next step of checkout. Does anyone know any solution for this?
magento2 checkout validation
magento2 checkout validation
edited Jul 22 at 11:49
Žygimantas Baranauskas
asked Jul 22 at 10:56
Žygimantas BaranauskasŽygimantas Baranauskas
821 silver badge11 bronze badges
821 silver badge11 bronze badges
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00
add a comment |
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282840%2fmagento-2-custom-additional-checkout-field-validation-not-working-when-custome%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282840%2fmagento-2-custom-additional-checkout-field-validation-not-working-when-custome%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You need to validate only on When the customer clicks next button ?
– aravind
Jul 22 at 11:52
@aravind - Yes. Basically i need it to function the same way as this working when customer is not logged in.
– Žygimantas Baranauskas
Jul 22 at 12:00