How can I send cart attributes as notes using JavaScript?

Hi there,

In my cart I have two cart attrbutes, gift-note-to, and gift-note-from. This is for inputting who a gift is to and from when adding a gift card to cart.

However, I need both these values to be processed as cart notes, including the attribute name, so our Fulfilment company get the note on the order sheet.

Currently this is how it is set out (using some minor changes to the shopify guide). But I need to use Javascript to make cartNotes = “TO” + attribute[gift-card-to] + “FROM” + attribute[gift-card-from]

Any help would be great.

Here is the code im using for sending cart attributes to cart at the moment:

{% if linklists.gift-card.links.size > 0 and linklists.gift-card.links.first.type == 'product_link' %}

  

    
    
  

  
  
    

  
  

  

  

{% assign id = linklists.gift-card.links.first.object.variants.first.id %}

{% assign gift_cards_in_cart = 0 %}
{% for item in cart.items %}
{% if item.id == id %}
  {% assign gift_cards_in_cart = item.quantity %}
{% endif %}
{% endfor %}

    
    {% else %}
    
    {% endif %}