Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. public function afterProcess (
  2. MagentoCheckoutBlockCheckoutLayoutProcessor $subject,
  3. array $jsLayout
  4. ) {
  5. $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
  6. ['shippingAddress']['children']['shippingAdditional'] = [
  7. 'component' => 'uiComponent',
  8. 'displayArea' => 'shippingAdditional',
  9. 'children' => [
  10. 'terminal' => [
  11. 'component' => 'Vendor_Module/js/methods/method',
  12. 'config' => [
  13. 'customScope' => 'shippingAddress',
  14. 'template' => 'ui/form/field',
  15. 'elementTmpl' => 'Vendor_Module/method',
  16. 'options' => [],
  17. ],
  18. 'dataScope' => 'shippingAddress.method_terminal',
  19. 'label' => '',
  20. 'provider' => 'checkoutProvider',
  21. 'visible' => true,
  22. 'validation' => [ 'select-terminal-required' => true ],
  23. 'sortOrder' => 200,
  24. ]
  25. ],
  26. ];
  27. return $jsLayout;
  28. }
  29.  
  30. <div data-bind="visible: selectedMethod () == 'vendor_terminal'">
  31. <label data-bind="i18n: 'Select'"></label>
  32. <select name="vendor-terminal" class="select-terminal-required" id="terminal-list" data-bind="html: getTerminalList ()">
  33. </select>
  34. </div>
  35.  
  36. var config = {
  37. config: {
  38. mixins: {
  39. 'Magento_Ui/js/lib/validation/validator': {
  40. 'Vendor_Module/js/validation-mixin': true
  41. },
  42. }
  43. }
  44.  
  45. define([
  46. 'jquery',
  47. 'Magento_Checkout/js/model/quote',
  48. 'Magento_Ui/js/lib/validation/utils'
  49. ], function ($, quote, utils) {
  50. "use strict";
  51. return function ( validator ) {
  52. validator.addRule ( 'select-terminal-required', function () {
  53. var method = quote.shippingMethod();
  54. var validation = method.method_code === 'vendor_terminal' && utils.isEmpty($( '.select-terminal-required' ).val ());
  55. return !validation;
  56. }, $.mage.__( 'Please select terminal.' ) );
  57.  
  58. return validator;
  59. }
  60. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement