1. The condition should be like if the country is the UK then the text should not be shown. If the country is other than the UK then the text should be shown.

enter image description here enter image description here

  1. On the cart page, I achieved using the below shown two files where I simply add KO observable and made to show based on its condition.

enter image description here enter image description here enter image description here

  1. I am using Amasty one-page checkout. How to do the same feature in the checkout page country field? I don't want to add a new field because in the Amasty feature the fields can be placed in any sort of order from the back end. So adding a new field will be affected when sort order changes.

1 Answer 1

  1. After few debugging. I achieved this via Layout processor plugin but it can also be done via checkout_index_index.xml layout. I choose layout processor plugin as it loads after XML which will make sure my code to work at last. Let me explain step by step in detailed. [Also refer Create plugin LayoutProcessor::process vs Override checkout_index_index.xml for more information]
  2. As I am using layout processor plugin. I have a ability to give sort order. So here, I can set sort order as Amasty also used the layout processor plugin. enter image description here
  3. Using layout processor I made a custom component and template file for country field. enter image description here
  4. In template file, added p tag and did few more things to be shown based on KO observable value. enter image description here
  5. Recreated the actual select.js as it is and added the logic to show the text based on condition. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.