Highlighted

Very Simple Shopping Cart

Engaged ,
Apr 29, 2016

Copy link to clipboard

Copied

Hi. I am trying to understand how to use a very simple shopping cart in Cold Fusion, but am having a hard time. I've tried looking at information on web sites, but they all use a script like this below that fills in the info. into a cart.

<cfscript>

CartItems=4;

Cart = ArrayNew(1);

for ( i=1; i LE cartItems; i=i+1)

    Cart=StructNew();

    Cart.ID=i;

    Cart.Name="Product " & i;

    Cart.SKU=i*100+(2*i*10)+(3*i);

    Cart.Qty=3*i-2;

}

</cfscript>

I would rather use my own form that outputs info. into a table to display to the user and this table could be used as a shopping cart. I've created this very simple form below. Can someone please show me an example of how to make this form into a shopping cart so I can add, update, and delete the items in it? Thank you.

Andy

TOPICS
Getting started

Views

1.2K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Very Simple Shopping Cart

Engaged ,
Apr 29, 2016

Copy link to clipboard

Copied

Hi. I am trying to understand how to use a very simple shopping cart in Cold Fusion, but am having a hard time. I've tried looking at information on web sites, but they all use a script like this below that fills in the info. into a cart.

<cfscript>

CartItems=4;

Cart = ArrayNew(1);

for ( i=1; i LE cartItems; i=i+1)

    Cart=StructNew();

    Cart.ID=i;

    Cart.Name="Product " & i;

    Cart.SKU=i*100+(2*i*10)+(3*i);

    Cart.Qty=3*i-2;

}

</cfscript>

I would rather use my own form that outputs info. into a table to display to the user and this table could be used as a shopping cart. I've created this very simple form below. Can someone please show me an example of how to make this form into a shopping cart so I can add, update, and delete the items in it? Thank you.

Andy

TOPICS
Getting started

Views

1.2K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 29, 2016 0
Engaged ,
Apr 29, 2016

Copy link to clipboard

Copied

Hey,

Your question seems very broad.  Can you explain what difficulties you are having so we can help you better? 

--Dave

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 29, 2016 0
Engaged ,
Apr 29, 2016

Copy link to clipboard

Copied

Basically,

       A customer chooses that they want Product 1 and the price is $10.00. I want them to click a button that Adds the item to a shopping cart. Then if they want to continue to choose other products, they can add those items to the shopping cart also. So if they choose Product 2 and the price is $20.00, they click Add to Cart, the Cart total will show $30.00. Then they'll have the option to add more quantities or remove each product that is in their cart. Then later, I will set up a Checkout with Stripe.com that will handle the credit cart information. I need to set up a shopping cart this way because I have a page that is calculating the prices for parts on the fly, so I wouldn't be able to use anything like a CFWebstore or CartWeaver or anything like that since I don't have a database of parts to just output. If you want to see the page I have created, it's located here: Shin-Etsu Polymer Elastomer cut to size Just choose a part number and type in 10 for the Xmm and 10 for the Ymm. You'll notice that after you click one part number and fill in the info. and click update, and then click on a different part number, the table disappears for the first part you chose. I just have a Place Order button at the bottom after you click update that just opens up a pop up screen to call us for now. Can you show me how to get this to work so that if the customer wants to add the first part to shopping cart, they can and then continue ordering other parts? I'm pretty sure I need to use session variables to get this to work, correct? Some of the web sites I've been reading say to use Arrays and Structures too, but I don't understand how to use these. Thanks.

Andy

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 29, 2016 0
BKBK LATEST
Adobe Community Professional ,
May 14, 2016

Copy link to clipboard

Copied

You have a good start. I like your example, "Shin-Etsu Polymer Elastomer cut to size".

You should now

1) change the Update button to Add;

2) add the Delete button

3) use the session scope to maintain the user's shopping-cart across multiple requests.

You could emulate the code in Brian Kotek's article, Create a simple shopping cart using ColdFusion. If you do, note that the last comment in the code should be:

<!—- Add the specified item to the cart. —->

and not

<!—- Delete the specified item from the cart. —->

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 14, 2016 0