Personalized checkout and custom promotions with Shopify Scripts
I have a script added below to get the value of the particular Note section. But note is returning blank. Is there a way to access note values? Or can I add the Note value in tags as well.
{%- if customer -%} <!-- Directly output the customer note for debugging --> {% assign customer_note = customer.note | default: 'No note available' %} <p>Customer Note: "{{ customer_note }}"</p> <!-- Split the note into lines and output each line --> {% assign lines = customer_note | split: '\n' %} <p>Lines:</p> <ul> {% for line in lines %} <li>{{ line }}</li> {% endfor %} </ul> <!-- Initialize specialization line --> {% assign specialization_line = '' %} <!-- Find the line containing 'specialization:' --> {% for line in lines %} {% if line contains 'specialization:' %} {% assign specialization_line = line %} {% endif %} {% endfor %} <!-- Output the identified specialization line for debugging --> <p>Specialization Line: "{{ specialization_line }}"</p> <!-- Extract the specialization value --> {% assign specialization_value = specialization_line | split: ':' | last | strip %} <!-- Output the extracted specialization value for debugging --> <p>Specialization Value: "{{ specialization_value }}"</p> <!-- Check specialization value and set sensitivity --> {% if specialization_value == 'Orthodontist' %} {% assign sensitivity = true %} {% else %} {% assign sensitivity = false %} {% endif %} <!-- Output the sensitivity value for debugging --> <p>Sensitivity: {{ sensitivity }}</p> <!-- JavaScript to alert the specialization value --> <div id="specialization-value" data-specialization="{{ specialization_value }}"></div> <script> document.addEventListener('DOMContentLoaded', function() { var specializationElement = document.getElementById('specialization-value'); if (specializationElement) { var specializationValue = specializationElement.getAttribute('data-specialization'); console.log('Specialization:', specializationValue); alert('Specialization: ' + specializationValue); } }); </script> {%- else -%} <p>No customer found.</p> {%- endif -%}
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025