I am trying to add an additional, hidden field to my simplecart items when using the simpleCart_shelfItem div. I've tried hidden inputs, additional spans, and can't get my attribute to show up in the JSON that's passed by Simplecarts form checkout.
Nothing fancy when I init simplecart:
// Init shopping cart
script(type='text/javascript')
simpleCart({
checkout: {
type: "SendForm",
url: "/cart/checkout"
},
currency: "USD",
cartStyle: "table"
});
Here's where I load a shelf item (note that this is using the Jade engine, but HTML is as expected):
div.simpleCart_shelfItem
p.item_name My Special Item
input.item_Quantity(type='text', value='1')
input.item_secretId(type='hidden', value='A hidden identifier')
br
span.item_price $0.99
br
a.item_add(href="javascript:;") Add to Cart
I've also tried using:
span.item_secretId A hidden identifier
And when I pass the cart to /cart/checkout secretId is nowhere to be found when I do a console log of req.body in my server-side code:
Checkout passed with: {"currency":"USD","shipping":"0","tax":"0","taxRate":"0","itemCount":"1","item_name_1":"4x6 Print","item_quantity_1":"4","item_price_1":"0.99","item_options_1":""}
I've seen the ability to add custom columns to the cart in the API docs, but I don't want this field to show up in the cart, it's strictly internal to facilitate server-side processing.
It's not particularly pretty, but I solved this by using div tags around my new data elements, and then hiding them in a stylesheet like this
HTML:
input(class="item_internalId", type='text', value='1234')
CSS:
input.item_internalId {
display: none;
}