Search code examples
javascriptshopping-cartsimplecart

SimpleCart additional information with custom columns


I am using the SimpleCart Javascript Library.

I want to add an id to each product and when the user proceeds to checkout, these id's would be sent as well.

Instead of these columns, for example:

Name   Price
book   5$

I want to have a Product Id column include as well:

Id   Name   Price
3    book   5$

I've tried inserting the id into the options, but I had no luck doing so.

Can someone show me a detailed example doing so?


Solution

  • This can be set up like this:

    In your simplecart set up under "cartColumns" add

    { attr: "id" , label: "ID" }
    

    Like this:

    cartColumns: [
            { attr: "image", label: "Item", view: "image"},
            //Name of the item
            { attr: "name" , label: "Name" },
            { attr: "id" , label: "ID" },
                        //etc………
    

    Then you can use either:

    <span class="item_id">ID:1</span>
    

    or like this:

    simpleCart.add({ name: "Shirt" , price: 4, id: 1 });
    

    and it should show up in your columns.