I want to somehow intercept the "Buy Now" button and store an additional piece of data in a hidden field in the order.
I assume there is some way, using JQuery, to prevent to default action of the "buy now" button to do this before it submits?
So, somehow I need to be able to
I am new to Shopify development so apologies for my lack of knowledge.
Any help would be greatly appreciated.
Look into cart[attributes] field.
Two ways you can get data in this field, which then gets stored on the cart / checkout / order object and shows up in the shopify admin
Here's an example of the field you need to populate in your add to cart form, or on your /cart page form. This data will get passed into order.
<input id="attr-myfield" type="hidden" name="attributes[myfield]" value="my fields value" />