0

Now i added custom field checkout shipping page but issue add custom module custom.js and define layout checkout_index_index.xml but it's not working

checkout_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
     <link src="VendorName_ModuleName::js/custom.js"/>
</head>

app/code/Vendor/Module/view/frontend/web/js/custom.js

require([
"jquery"
], function($){
    $('.dropdown select').on('change',function(){
        $('.dropdown select').find(":selected").text();
        if ($('.dropdown select').find(":selected").text() === 'Test'){
            $('.customfields').show();
        } else {
            $('.customfields').hide();
            console.log($('.dropdown select').find(":selected").text());
            $('.customfields input').val($('.dropdown select').find(":selected").text())
        }
    });
  });

custom.js code not working checkout page knockout js issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.