Advertisement

06.24.2008 at 08:07AM PDT, ID: 23511293
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.9

add to cart button should create new entry/line in the cart - how to?

Asked by bede123 in Hypertext Markup Language (HTML), Miscellaneous Web Development, Cold Fusion Markup Language

Tags:

Hi all,

i'm using a very simple shopping cart for use with PayPal. I only have a couple of items for sale. One of these items (a t-shirt) has a choice of colour and size. its all working ok however ive noticed that if the customer chooses the t-shirt this is added to the shopping cart but if the customer then goes back to the it-shirt and chooses a different color and or size the shopping cart increases in quantity but has no mention of the different size/color.

what i need is that is that if the customer wants the same item more than once in different sizes/colors for this to create a new entry in the cart instead of just adding to the quantity.

sorry its a bit wordy but hopefully ive got my point across.

so anyone got any ideas? i have posted ALL of the code below:


<!--- this is the cart/basket page--->

<cfsilent>
<cfif not isdefined("session.cart")>
<cfset session.cart=createObject("component","cart")>
</cfif>

<cfparam name="request.item_number" default="" >
<cfparam name="request.item_name" default="" >
<cfparam name="request.amount" default="0" >
<cfparam name="request.quantity" default="0" >
<cfparam name="request.shipping" default="0" >
<cfparam name="request.shipping2" default="0" >
<cfparam name="request.handling" default="0" >
<cfparam name="request.on0" default="" >
<cfparam name="request.os0" default="" >
<cfparam name="request.on1" default="" >
<cfparam name="request.os1" default="" >

<cfif not isNumeric(request.quantity)>
      <cfset request.quantity=1>
</cfif>

<cfif request.doaction eq 'addToCart'>
 <cfset session.cart.add(
      request.item_number,
      request.item_name,
      request.amount,
      request.quantity,
      request.shipping,
      request.shipping2,
      request.handling,
      request.on0,
      request.os0,
      request.on1,
      request.os1) >
</cfif>

<cfif request.doaction eq 'updateCart'>
  <cfloop list="#request.item_number#" index="thisItem">
        <cfif not isNumeric(request['quant_#thisItem#'])>
            <cfset request['quant_#thisItem#']=1>
      </cfif>
    <cfset session.cart.update(thisItem,request['quant_#thisItem#']) >
  </cfloop>
</cfif>
</cfsilent>
<cfswitch expression="#request.doaction#">
<cfcase value="completeCart">
<cfset session.cart.empty()>
<cfinclude template="dsp_complete.cfm">
</cfcase>
<cfcase value="cancelCart">
<!---<cfset session.cart.empty()>--->
<cfinclude template="dsp_cancel.cfm">
</cfcase>
<cfdefaultcase>
<cfset getCart = session.cart.List()>
<cfinclude template="dsp_basket.cfm">
</cfdefaultcase>
</cfswitch>



<div id="svPayPalCart">

<cfif getCart.recordcount>
<cfoutput>
<form action="#application.configBean.getIndexFile()#" onSubmit="return validate(this)" method="post">
<cfset grandTotal = 0 >

<table>


  <td colspan="6"><div align="left"><strong>Your Shopping Cart</strong></div></td>
  </tr>
<tr>
  <th>Item</th>
  <th>Value each</th>
  <th>Colour</th>
  <th>Size</th>
  <th>Qty</th>
  <th>Subtotal</th>
</tr>
<cfloop query="getCart">
  <tr>
    <td>
         #getCart.item_name#    </td>
    <td>#getCart.amount#</td>
    <td>#getCart.on0#</td>
    <td>#getCart.on1#</td>
    <td>
      <input type="hidden" name="item_number" value="#getCart.item_number#" />
      <input type="text" size="3" name="quant_#getCart.item_number#"
           value="#getCart.Quantity#" /></td>
           <cfset itemTotal = getCart.amount * getCart.Quantity >
    <cfset grandTotal = grandTotal + itemTotal >

    <td align="right">£#NumberFormat(itemTotal,"0.99")#</td>
  </tr>
</cfloop>
<tr>
    <td colspan="4">&nbsp;</td>
    <th>Total:</th>
    <td align="right">£#NumberFormat(grandTotal,"0.99")#</td>
  </tr>
</table>
<input type="hidden" name="doaction" value="updateCart" />
<input type="submit" name="submit" value="Update Quantities">
</form>



<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="submit" name="submit" value="Check Out">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="xxxxx@xxxx.com">
<cfloop query="getCart">
<input type="hidden" name="item_name_#getCart.currentrow#" value="#getCart.item_name#">
<input type="hidden" name="item_number_#getCart.currentrow#" value="#getCart.item_number#">
<input type="hidden" name="quantity_#getCart.currentrow#" value="#getCart.quantity#">
<input type="hidden" name="amount_#getCart.currentrow#" value="#getCart.amount#">
<input type="hidden" name="handling_#getCart.currentrow#" value="#getCart.handling#">
<input type="hidden" name="shipping_#getCart.currentrow#" value="#getCart.shipping#">
<input type="hidden" name="shipping2_#getCart.currentrow#" value="#getCart.shipping2#">
<input type="hidden" name="on0_#getCart.currentrow#" value="#getCart.on0#">
<input type="hidden" name="os0_#getCart.currentrow#" value="#getCart.os0#">
<input type="hidden" name="on1_#getCart.currentrow#" value="#getCart.on1#">
<input type="hidden" name="os1_#getCart.currentrow#" value="#getCart.os1#">
</cfloop>
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="return" value="http://#cgi.server_name##request.path#?doaction=completeCart">
<input type="hidden" name="cancel_return" value="http://#cgi.server_name##request.path#?doaction=cancelCart">
<input type="hidden" name="cn" value="Comments">
<input type="hidden" name="currency_code" value="GBP">
</form>
</cfoutput>
<cfelse>

<p>Your shopping cart is currently empty.</p>
<p>&nbsp;</p>
</cfif>
</div>



<!--- this is the product --->


<p>
<form action="/xxxx/index.cfm/cart/&quot;" name="&quot;PurchaseTshirts&quot;&gt;&lt;/p">
      <table height="100" cellspacing="5" cellpadding="5" width="200" align="left" border="1">
            <tbody>
                  <tr>
                        <td width="200" height="200">
                        <p>Select a colour: <select name="on0">
                        <option value="White">White</option>
                        <option value="Black">Black</option>
                        <option value="Green" selected="selected">Green</option>
                        <option value="Blue">Blue</option>
                        <option value="Red">Red</option>
                        <option value="Yellow">Yellow</option>
                        </select></p>
                        <p>Select a size: <select name="on1">
                        <option value="Small" selected="selected">Small</option>
                        <option value="Medium">Medium</option>
                        <option value="Large">Large</option>
                        <option value="X-Large">X-Large</option>
                        </select></p>
                        <p>Quantity: <input onBlur="if(this.value==''){this.value='1';}" onClick="this.value='';" name="quantity" value="1" type="text" /></p>
                        <input type="hidden" name="item_name" value="T-Shirt" /> <input type="hidden" name="amount" value="10.00" /> <input type="hidden" name="item_number" value="3" /> <input type="hidden" name="doaction" value="addToCart" /> <input type="submit" value="Add to Cart" /></td>
                        <td width="200" height="200">&nbsp;
                        <p><img height="135" alt="" width="201" border="0" src="/tasks/sites/xxxx/assets/Image/cart_images/tshirt.jpg" /> Lovely T-shirts</p>
                        </td>
                  </tr>
            </tbody>
      </table>
</form>
</p>
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
<!--- this is the cart/basket page--->
 
<cfsilent>
<cfif not isdefined("session.cart")>
<cfset session.cart=createObject("component","cart")> 
</cfif>
 
<cfparam name="request.item_number" default="" >
<cfparam name="request.item_name" default="" >
<cfparam name="request.amount" default="0" >
<cfparam name="request.quantity" default="0" >
<cfparam name="request.shipping" default="0" >
<cfparam name="request.shipping2" default="0" >
<cfparam name="request.handling" default="0" >
<cfparam name="request.on0" default="" >
<cfparam name="request.os0" default="" >
<cfparam name="request.on1" default="" >
<cfparam name="request.os1" default="" >
 
<cfif not isNumeric(request.quantity)>
	<cfset request.quantity=1>
</cfif>
 
<cfif request.doaction eq 'addToCart'>
 <cfset session.cart.add(
	request.item_number,
	request.item_name,
	request.amount,
	request.quantity,
	request.shipping,
	request.shipping2,
	request.handling,
	request.on0,
	request.os0,
	request.on1,
	request.os1) >
</cfif>
 
<cfif request.doaction eq 'updateCart'>
  <cfloop list="#request.item_number#" index="thisItem">
  	<cfif not isNumeric(request['quant_#thisItem#'])>
		<cfset request['quant_#thisItem#']=1>
	</cfif>
    <cfset session.cart.update(thisItem,request['quant_#thisItem#']) >
  </cfloop>
</cfif>
</cfsilent>
<cfswitch expression="#request.doaction#">
<cfcase value="completeCart">
<cfset session.cart.empty()>
<cfinclude template="dsp_complete.cfm">
</cfcase>
<cfcase value="cancelCart">
<!---<cfset session.cart.empty()>--->
<cfinclude template="dsp_cancel.cfm">
</cfcase>
<cfdefaultcase>
<cfset getCart = session.cart.List()>
<cfinclude template="dsp_basket.cfm">
</cfdefaultcase>
</cfswitch>
 
 
 
<div id="svPayPalCart">
 
<cfif getCart.recordcount> 
<cfoutput>
<form action="#application.configBean.getIndexFile()#" onSubmit="return validate(this)" method="post">
<cfset grandTotal = 0 >
 
<table>
 
 
  <td colspan="6"><div align="left"><strong>Your Shopping Cart</strong></div></td>
  </tr>
<tr>
  <th>Item</th>
  <th>Value each</th>
  <th>Colour</th>
  <th>Size</th>
  <th>Qty</th>
  <th>Subtotal</th>
</tr>
<cfloop query="getCart">
  <tr>
    <td>
   	#getCart.item_name#    </td> 
    <td>#getCart.amount#</td>
    <td>#getCart.on0#</td>
    <td>#getCart.on1#</td>
    <td>
      <input type="hidden" name="item_number" value="#getCart.item_number#" />
      <input type="text" size="3" name="quant_#getCart.item_number#" 
           value="#getCart.Quantity#" /></td>
           <cfset itemTotal = getCart.amount * getCart.Quantity >
    <cfset grandTotal = grandTotal + itemTotal >
 
    <td align="right">£#NumberFormat(itemTotal,"0.99")#</td>
  </tr>
</cfloop>
<tr>
    <td colspan="4">&nbsp;</td>
    <th>Total:</th>
    <td align="right">£#NumberFormat(grandTotal,"0.99")#</td>
  </tr>
</table>
<input type="hidden" name="doaction" value="updateCart" />
<input type="submit" name="submit" value="Update Quantities">
</form>
 
 
 
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="submit" name="submit" value="Check Out">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="xxxxx@xxxx.com">
<cfloop query="getCart">
<input type="hidden" name="item_name_#getCart.currentrow#" value="#getCart.item_name#">
<input type="hidden" name="item_number_#getCart.currentrow#" value="#getCart.item_number#">
<input type="hidden" name="quantity_#getCart.currentrow#" value="#getCart.quantity#">
<input type="hidden" name="amount_#getCart.currentrow#" value="#getCart.amount#">
<input type="hidden" name="handling_#getCart.currentrow#" value="#getCart.handling#">
<input type="hidden" name="shipping_#getCart.currentrow#" value="#getCart.shipping#">
<input type="hidden" name="shipping2_#getCart.currentrow#" value="#getCart.shipping2#">
<input type="hidden" name="on0_#getCart.currentrow#" value="#getCart.on0#">
<input type="hidden" name="os0_#getCart.currentrow#" value="#getCart.os0#">
<input type="hidden" name="on1_#getCart.currentrow#" value="#getCart.on1#">
<input type="hidden" name="os1_#getCart.currentrow#" value="#getCart.os1#">
</cfloop>
<input type="hidden" name="page_style" value="PayPal">
<input type="hidden" name="return" value="http://#cgi.server_name##request.path#?doaction=completeCart">
<input type="hidden" name="cancel_return" value="http://#cgi.server_name##request.path#?doaction=cancelCart">
<input type="hidden" name="cn" value="Comments">
<input type="hidden" name="currency_code" value="GBP">
</form>
</cfoutput>
<cfelse>
 
<p>Your shopping cart is currently empty.</p>
<p>&nbsp;</p>
</cfif>
</div>
 
 
 
<!--- this is the product --->
 
 
<p>
<form action="/xxxx/index.cfm/cart/&quot;" name="&quot;PurchaseTshirts&quot;&gt;&lt;/p">
	<table height="100" cellspacing="5" cellpadding="5" width="200" align="left" border="1">
		<tbody>
			<tr>
				<td width="200" height="200">
				<p>Select a colour: <select name="on0">
				<option value="White">White</option>
				<option value="Black">Black</option>
				<option value="Green" selected="selected">Green</option>
				<option value="Blue">Blue</option>
				<option value="Red">Red</option>
				<option value="Yellow">Yellow</option>
				</select></p>
				<p>Select a size: <select name="on1">
				<option value="Small" selected="selected">Small</option>
				<option value="Medium">Medium</option>
				<option value="Large">Large</option>
				<option value="X-Large">X-Large</option>
				</select></p>
				<p>Quantity: <input onBlur="if(this.value==''){this.value='1';}" onClick="this.value='';" name="quantity" value="1" type="text" /></p>
				<input type="hidden" name="item_name" value="T-Shirt" /> <input type="hidden" name="amount" value="10.00" /> <input type="hidden" name="item_number" value="3" /> <input type="hidden" name="doaction" value="addToCart" /> <input type="submit" value="Add to Cart" /></td>
				<td width="200" height="200">&nbsp;
				<p><img height="135" alt="" width="201" border="0" src="/tasks/sites/xxxx/assets/Image/cart_images/tshirt.jpg" /> Lovely T-shirts</p>
				</td>
			</tr>
		</tbody>
	</table>
</form>
</p>
[+][-]06.24.2008 at 02:15PM PDT, ID: 21860483

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 02:19PM PDT, ID: 21860513

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 02:51PM PDT, ID: 21860729

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 03:19PM PDT, ID: 21860985

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 04:36PM PDT, ID: 21861524

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.24.2008 at 05:11PM PDT, ID: 21861678

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Hypertext Markup Language (HTML), Miscellaneous Web Development, Cold Fusion Markup Language
Tags: HTML - Coldfusion
Sign Up Now!
Solution Provided By: scrathcyboy
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628