Solved

Delete a row from and Array

Posted on 2009-05-13
23
1,745 Views
Last Modified: 2013-12-20
Hello, I am trying to delete a row from an array with refrence to a value from a query, I am trying to use ArrayDeleteat but unable to do  , I am really in need of an good example to do this PLEASE ....


the Query will return a value called Order_Id, I need to look for this in the array which is two dimensional and delete all data in the array pertained to the value. 
 

<cfoutput>

                                   <cfset length=Arraylen(session.orderTotalsArray)>--->

                                     <cfloop from="1" to="Arraylen(#session.orderTotalsArray#)" index="i">

                                              <cfset #ArrayDeleteAt(session.orderTotalsArray,i)#>

                                     </cfloop>

                                     </cfoutput>

Open in new window

0
Comment
Question by:coventri
  • 12
  • 11
23 Comments
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Multi-dimensional arrays are less intuitive than using an array of structures.  But see the attached example.  Also, you may want to use cflock to avoid possible race conditions.
<!---

	To demonstrate, create fake array with Order_Id in the first position

--->

<cfset orderTotalsArray = arrayNew(1)>

<cfset orderTotalsArray[1] = [ 99, "stuff"]>

<cfset orderTotalsArray[2] = [ 2, "computers"]>

<cfset orderTotalsArray[3] = [ 99, "stuff"]>

<cfset orderTotalsArray[4] = [ 3, "books"]>

<cfset orderTotalsArray[5] = [ 99, "stuff"]>
 

<cfdump var="#orderTotalsArray#" label="Before Delete">
 

<!--- search for Order_id "99" --->

<cfset searchForThisOrderId = 99>
 

<!--- loop through the array in reverse order --->

<cfloop from="#Arraylen(session.orderTotalsArray)#" to="1" index="i" step="-1">

	<!--- get the current element --->

	<cfset order = session.orderTotalsArray[i]>

	<!--- check the order_id. if it matches, delete it --->

	<cfif order[1] eq searchForThisOrderId>

		<cfset ArrayDeleteAt(session.orderTotalsArray, i)>		

	</cfif>

</cfloop>
 

<cfdump var="#orderTotalsArray#" label="After Delete">

Open in new window

0
 
LVL 1

Author Comment

by:coventri
Comment Utility
thanks for the help ,
but i am getting an error Object of type class coldfusion.runtime.Struct cannot be used as an array

at <cfloop from="#Arraylen(session.orderTotalsArray)#" to="1" index="i" step="-1">
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
That sounds like session.orderTotalsArray is actually a structure and not an array.  Can you provide a sample of the data in this variable?
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
... ie:  

1. Is session.orderTotalsArray an array or structure
2. What does it contain (arrays or structures) and what is an example of the contents?
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Thank you for the quick response sir, i just attached a file which is my answer.
The-dump-of-session-array.docx
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Also i did an forward, loop in the attachment, as I could not get the code working,
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Looking at the cfdump you are actually working with a structure of structures, not arrays at all.  (That is why arrayLen(..) did not work).  

The keys seem to be numbers 1,2,3, ... In the inner structure, is key 2 a comma delimited list of numbers?  ie:

             2 -  1708863,1708864,1708865

.. and if so, you want to delete the entire item if that list contains the order_id, correct?
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Yes sir, thats right
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
.... Actually, a better question is this:

          The inner structure seems to contain 3 keys.  What do those keys represent and how do
          you identify #1708862? Do you need to search all of the keys, and delete the entire entry
          if any of them contain 1708862 ..

          orderData[1] =   struct
                                    [1] 999999
                                    [2] 1708863,1708864,1708865
                                    [3] 1708862,1708864       <!---  order_id found --->


        ...      or only delete it if 1708862 is found in a specific position (like #2)

          orderData[2] =   struct
                                    [1] 999999
                                    [2] 1708863,1708864,1708865  <-- do not delete. [2] does not contain 1708862
                                    [3] 1708862,1708864    
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
This is constructed by
   <cfset session.orderTotalsArray[itemX][1] = "#orderTotal#">
  <cfset session.orderTotalsArray[itemX][2] ="#getIdentifiedSplitOrdersArray[itemX][2]#">
<cfset session.orderTotalsArray[itemX][3] = "#getDetailRecordsQry.Product_id#">

The structure  contains 1 . OrderTotal Price eg 85.97
                                       2. TemporderDetail_ID's of an order eg. 1708863,1708864,1708865
                                       3. Product_Id,
in  this structure i am getting the value  #1708862 , its price , its product id . the price , productId, and the TemporderDetail_ID should be deleted, I am able to find the value #1708862  from and other query,
I need to make cf look for the TemporderDetail_ID in the struct, matching to the one in orderId in the Query and do the delete
If you take a look at  the dump, the #1708862 always comes in a saperate row.

Sir I am hitting on this issue from 3 days,   Please Help

0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Here try this.  It will search the TemporderDetail_ID's list for the #OrdertoDelete# and delete any entries that contain that value.
...

<cfset OrdertoDelete = getnondropshipid.ORDERDETAIL_ID>
 

<!--- loop through the keys in the outer structure --->

<cfloop array="#structKeyArray(session.orderTotalsArray)#" index="key">

	<!--- get the current order information --->

	<cfset order = session.orderTotalsArray[key]>

	<!--- check the list of order_ids for the specified value --->

	<cfif listFind(order[2], orderToDelete)>

		<!--- if the order_id is found, delete the whole entry --->

		<cfset structDelete(session.orderTotalsArray, key)>		

	</cfif>

</cfloop>

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:coventri
Comment Utility
I am hitting an error
"Error Occurred While Processing Request
You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members."

at Line

<cfloop  array="#structKeyArray(session.orderTotalsArray)#" index="key">
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Now I am _very_ confused.  Originally you were getting an error because the session object was a structure and not an array. (Your dump confirmed that).  Now you are getting an error because it is an array not a structure.

1. Did you change the session object ?

2. Can you post the code used to create the session object?  Then I can provide you with the correct answer for your current structure.
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
No I haven't changed the session object

I have attached the file paymentview.cfm

Line # 239 I am queryin for the ORDERDETAIL_ID which needs to be deleted
Line # 798 I am doing an ARRAYNEW(2)
Line # 812 setting values to the dimensions in the arrays
Line # 813 Code to delete the particular row in the structure
<cfif IsDefined("Cookie.tempOrderid")>       

   <cfset temporderdetail=Cookie.temporderid>

   <cfset temporderid=GetToken(#temporderdetail#, 2 ,'-')>

<cfelse>

	<cfset temporderid=0>

</cfif>
 
 

<cfparam name="promotionTypeIDs" default="8,9,10,21,22,13"><!--- When you change promotionTypeIDs please change them in redeemGiftCardCoupons.cfm as well. --->

<cfparam name="CLIENT.userloggedin" default="false">

<!--- IF temporderid IS 0 MOST LIKELY THE USER HIT THE BACK BUTTON ON THE CONFIRMATION PAGE. SINCE THE PAGE WILL NOT FUNCTION WITHOUT A VALID

COOKIE ID LETS SEND THEM TO THE HOME PAGE IF THE COOKIE VALUE IS 0.  --->

	<cfif temporderid EQ 0>

        <cflocation url="/#CurrentPage#/" addtoken="no"> 

    </cfif>

	

    <script type="text/javascript" language="javascript" src="/scripts/paymentViewPopup.js"></script>

    <link rel="stylesheet" type="text/css" href="/css/popup.css"  />

    

	<cfset DataSourceID = #APPLICATION.configStruct.DataSourcesID#>

    <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.payment" method="getnCCValidationLevel" returnvariable="getnCCValidationLevelQry">

        <cfinvokeargument name="DataSourceID" value="#DataSourceID#">

    </cfinvoke>
 

<cfoutput><img src="/images/testbar/register_sc.gif" width="137" height="31"><a href="/#CurrentPage#/login/true/myaccount/true" title="Go back to Login"><img src="/images//testbar/login_up.gif"  border="0"></a><a href="/#CurrentPage#/billing/true" title="Go back to Shipping and Billing"><img src="/images/testbar/shippingbilling_up.gif"  border="0"></a><a href="/#CurrentPage#/payment/true"><img src="/images/testbar/paymentinfo_down.gif"  border="0"></a></cfoutput>
 

	<!--- invoke method to get all of the cart items --->

	<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.cart.cart" method="viewcart" returnvariable="cartItems"></cfinvoke>

	<!--- get the list of acceptable payment methods. --->

	<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.payment" method="GetPaymentMethodsQry" returnvariable="qryPaymentMethods"></cfinvoke>

		<CFloop QUERY="qryPaymentMethods">

	       <cfswitch expression="#sMethodName#">

                <cfcase value="Visa">

                    <cfset visapic = true>

                </cfcase>

                <cfcase value="MasterCard">

                    <cfset mcpic = true>

                </cfcase>

                <cfcase value="American Express">

                    <cfset amxpic = true>

                </cfcase>

                <cfcase value="Discover">

                    <cfset discoverpic = true>

                </cfcase>

        	</cfswitch>

     	</CFloop>   

    

	<!--- get states for form --->

    <cfinvoke component="checkout" method="selectStates" returnvariable="states"></cfinvoke>

    <!--- get countries for form --->

    <cfinvoke component="checkout" method="selectCountries" returnvariable="countries"></cfinvoke>
 

    <cfset bContinueEnabled = "TRUE">

   	<!--- URL variables coming from billing page --->

    <cfparam name="url.pg" default="">

    <cfparam name="user_ID" default="0">

    <cfparam name="url.shipID" default="0">

    <cfparam name="url.billID" default="0">

    <cfparam name="couponAmount" default="0">

    <cfparam name="couponAmountFormat" default="0">

    <cfparam name="dropShipItemTotalAmount" default="0">

	<cfset ThisShippingState = "">

	<cfset ThisBillingState = "">

    <cfset ThisShippingCountry = "">

    <cfset ThisBillingCountry = "">

    <cfparam name="ThisDefaultShippingMethod" default="1">

    <cfif isdefined("CLIENT.userloggedin") and CLIENT.userloggedin EQ 1>

		<cfset user_ID = CLIENT.userid>

    <cfelse>

    	<cfset user_ID = 0>

    </cfif>
 

<cfoutput>

<script>

var bSubmitted = false;

// *********************** Function to validate whether all the payment fields are entered and check for validation errors *****************//

function submitForm()

{ 

	ccNum = document.paymentInfo3.sCardNumber.value;

	totalAmount = document.paymentInfo3.totalAmount.value;

	//alert(totalAmount);

	if(totalAmount > 0)

	{

		if( document.paymentInfo3.nPaymentMethod_ID.value == 0 ) {

			alert( "You must select a payment method to continue." );

			document.paymentInfo3.nPaymentMethod_ID.focus();

			return false;

		}
 

		if( document.paymentInfo3.nPaymentMethod_ID.value < 3 ) {

			if( !isCreditCard(ccNum) || ccNum.length < 16 ) {

				alert( "The Credit Card number entered is not valid\nPlease make sure your credit card number does not contain\nspaces or dashes." );

				document.paymentInfo3.sCardNumber.style.border="1px solid red";

				document.paymentInfo3.sCardNumber.focus();

				document.paymentInfo3.sCardNumber.select();

				return false;

			}

		}

		else if( document.paymentInfo3.nPaymentMethod_ID.value ==3) {

			if( !isCreditCard(ccNum) || ccNum.length < 15 ) {

				alert( "The Credit Card number entered is not valid\nPlease make sure your credit card number does not contain\nspaces or dashes." );

				document.paymentInfo3.sCardNumber.style.border="1px solid red";

				document.paymentInfo3.sCardNumber.focus();

				document.paymentInfo3.sCardNumber.select();

				return false;

			}

		}

	

		<CFloop QUERY="qryPaymentMethods">

			if (document.paymentInfo3.nPaymentMethod_ID.value == #nMethodID# && #bCVV2Required#) {

				if (document.paymentInfo3.sCVV2.value.length == 0) {

					alert('The payment method you have choosen requires a Credit Card Identification Number.');

					document.paymentInfo3.sCVV2.style.border="1px solid red";

					document.paymentInfo3.sCVV2.focus();

					return false;

				}

				else if (document.paymentInfo3.sCVV2.value.length < 3 || document.paymentInfo3.sCVV2.value.length > 4) {

					alert('The Credit Card Identification Number is not valid\nMastercard/Visa: The Credit Card Identification Number is the 3-digit number located on the back of your card');		

					document.paymentInfo3.sCVV2.style.border="1px solid red";

					document.paymentInfo3.sCVV2.focus();

					return false;

				}

			}

		</CFloop>	

	}

	if(!bSubmitted)

	{

		bSubmitted = true;

		return true;

	}

	else

	{

		alert("The Form is currently Processing.\nPlease Wait...");

		return false;

	}
 

}
 

function popUp(url) {

	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');

	self.name = "mainWin"; 

}
 

// CHECK CREDIT CARD INFORMATION *******************************

function isCreditCard(st) {

  // Encoding only works on cards with less than 19 digits

  if (st.length > 19)

    return (false);
 

  sum = 0; mul = 1; l = st.length;

  for (i = 0; i < l; i++) {

    digit = st.substring(l-i-1,l-i);

    tproduct = parseInt(digit ,10)*mul;

    if (tproduct >= 10)

      sum += (tproduct % 10) + 1;

    else

      sum += tproduct;

    if (mul == 1)

      mul++;

    else

      mul--;

  }
 

  if ((sum % 10) == 0)

    return (true);

  else

    return (false);
 

}

// END FUNCTION isCreditCard()*****************************************

</script>

</cfoutput>

<style type="text/css">

<!--

.style1 {font-size: 14px}

-->

</style>
 

<cfif isDefined("FORM.purchasenow") and FORM.purchasenow eq "PURCHASE NOW">

<cfinclude template="/views/checkout/ccardPaymentProcessing.cfm">        

</cfif>
 

<cfif isDefined("URL.shipID")>

	<cfset shippingUserAddressId = url.shipID>

</cfif>

<cfif isDefined("URL.shipID")>

	<cfset billingUserAddressId = url.billID>

</cfif>
 

<!--- Get any promotions for the promotion types and any sitewide ones --->	

<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.discounts.discounts" method="getActivePromotions" returnvariable="promotionsQry">

	<cfinvokeargument name="companyID" value="#APPLICATION.configStruct.teamID#">

	<cfinvokeargument name="promotionTypeIDs" value="#promotionTypeIDs#">

</cfinvoke>
 

<!--- Loop through and set addresses for any products that might not have a shipping address set --->

<cfloop query="cartItems">

	<cfif cartItems.SHIPPINGADDRESS_ID eq "" or cartItems.BILLINGADDRESS_ID eq "">

		<cfif shippingUserAddressId NEQ 0 AND billingUserAddressId NEQ 0>

			<!--- Updates tempOrderDetails and temporders table with default address --->

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="UpdateShipBillAddress">

				<cfinvokeargument name="OrderDetailID" value="#ORDERDETAIL_ID#">

				<cfinvokeargument name="OrderID" value="#Order_ID#">

				<cfinvokeargument name="UserAddressID" value="#shippingUserAddressId#">

				<cfinvokeargument name="UserBillingAddressID" value="#billingUserAddressId#">

				<cfinvokeargument name="UserID" value="#user_ID#">

			</cfinvoke>

		</cfif>

	</cfif>

  <cfif cartItems.SHIPPINGMETHOD_ID eq "">

  

  <!--- if there is no shipping method set it to default shipping method ground --->

   		<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.shipping" method="getAllShippingMethods" returnvariable="ShippingMethods">

            <cfinvokeargument name="defaultNumOfItems" value="0">	

        </cfinvoke>

          <cfoutput query="ShippingMethods">

             <cfif ShippingMethods.shippingGroupType eq "ground">

             	<cfset SHIPPINGMETHOD_ID = "#shippingMethod_id#" >

             </cfif>

 		  </cfoutput>       

          

  	<!--- Updates tempOrderDetails table with default shipMethod --->

  		<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="UpdateShippingMethodIDInTempOrderDetails">

        	<cfinvokeargument name="OrderDetailID" value="#ORDERDETAIL_ID#">

            <cfinvokeargument name="ShippingMethodID" value="#SHIPPINGMETHOD_ID#">

        </cfinvoke>

  </cfif>

</cfloop>
 
 

  <!--- Below query of queries to identify products which has same productID and same shippingAddressID --->

  <cfquery name="duplicateRecordsForSameProducts" dbtype="query">

    SELECT     order_id, product_id ,shippingAddress_id ,count(product_id) 

    FROM      cartItems

    WHERE     Order_ID = cartItems.order_id  AND CUSTOMTYPE = 0 AND ISGIFTCARD = 0

    GROUP BY  order_id ,product_id ,shippingAddress_id

    HAVING    count(PRODUCT_ID) > 1

  </cfquery>

  <cfquery name="getnondropshipid" dbtype="query">

   SELECT <!---order_id , --->product_id,ORDERDETAIL_ID  <!---order_id, product_id ,shippingAddress_id ,count(product_id)--->

    FROM    cartItems

   	   where cartItems.DROPSHIPITEM <>0   

  </cfquery>

  

  <cfdump var="#getnondropshipid#" label="dropship">

 <!--- <cfdump var="#cartItems#"--->>

 									

								

									

    			

                       

                       

                       

                       

                       

    <!--- Below code is to group same products and same shippingaddressID into single tempOrderDetail and delete duplicate records --->

  <cfloop query="duplicateRecordsForSameProducts">

    <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="UpdateQtyDeleteDuplicateRecordsTempOrderDetails">

        <cfinvokeargument name="OrderID" value="#duplicateRecordsForSameProducts.Order_ID#">

        <cfinvokeargument name="ProductID" value="#duplicateRecordsForSameProducts.Product_ID#">

        <cfinvokeargument name="shippingAddressID" value="#duplicateRecordsForSameProducts.SHIPPINGADDRESS_ID#">

    </cfinvoke>

  </cfloop>
 
 

<div id="PaymentBox">
 

<!---<cfif isDefined("session.userloggedin") and session.userloggedin EQ "true">--->

	<div id="paymentShipCartInfo">

    <cfform name="paymentInfo" action="/#CurrentPage#/payment/true" onsubmit="return submitForm();">
 

	<cfif url.pg EQ "guest" or url.pg EQ "rgd">

    <!--- Loop through and set same ship addresses for all products if they have come from rgd user page because if the user been to multiple ship and went back to billing&shipping by changing his mind to ship only to one address this allows to do that. --->

    <cfloop query="cartItems">

                <!--- Updates tempOrderDetails and temporders table with default address --->

                <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="UpdateShipBillAddress">

                    <cfinvokeargument name="OrderDetailID" value="#ORDERDETAIL_ID#">

                    <cfinvokeargument name="OrderID" value="#Order_ID#">

                    <cfinvokeargument name="UserAddressID" value="#shippingUserAddressId#">

                    <cfinvokeargument name="UserBillingAddressID" value="#billingUserAddressId#">

                    <cfinvokeargument name="UserID" value="#user_ID#">

                </cfinvoke>

    </cfloop>

    

   		<cfset comboDetailIDList = "">
 

		<!--- Check to see if any of the products are combos. If there are some then we need to exclude the main combo product

		from being added to any child orders and put it on the parent order.  --->

		<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="checkForCombos" returnvariable="getComboProductsQry">

			<cfinvokeargument name="tempOrderID" value="#temporderid#">

		 </cfinvoke>
 

		<cfif getComboProductsQry.recordCount GT 0>

			<!--- There are combos in the order so lets add them to the order --->

			<!--- First create a list of the order detail records that need to be added --->

			<cfset comboDetailIDList = ValueList(getComboProductsQry.orderDetail_ID)>

		</cfif>

<cfinput type="hidden" name="comboDetailIDList" value ="#ValueList(getComboProductsQry.orderDetail_ID)#">

		<!--- While we do not allow split shipments for guest users we do have to split any orders that have drop shipped products --->

		<!--- Main function to generate split shipments. Function returns a 2-dimensional array with shippingaddress group with shipping details. --->

		 <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="identifySplitOrders" returnvariable="getIdentifiedSplitOrdersArray">

			<cfinvokeargument name="tempOrderID" value="#temporderid#">

			<cfinvokeargument name="allowSplitShipment" value="#APPLICATION.configStruct.shipToMultipleAddresses#">		

			<cfinvokeargument name="excludeDetailList" value="#comboDetailIDList#">

			<cfinvokeargument name="shipAsAvailable" value="#COOKIE.shipAsAvailable#">				

		 </cfinvoke>
 

 

        <cfoutput>

        <cfset shippingUserAddressId = url.shipID>

	    <cfset billingUserAddressId = url.billID>

		<!--- Invoke component to retrieve Shipping Address for a guest Checkout process --->

        <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.checkout" method="getGuestBillingShippingAddress" 

                  returnvariable="getShippingAddressQry" >

            <cfinvokeargument name="userAddressID" value="#shippingUserAddressId#">

        </cfinvoke>

        <!--- Invoke component to retrieve Billing Address for a guest Checkout process --->

         <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.checkout" method="getGuestBillingShippingAddress" 

                   returnvariable="getBillingAddressQry" >

            <cfinvokeargument name="userAddressID" value="#billingUserAddressId#">

        </cfinvoke>
 

        <cfset ThisDefaultShippingMehtod = 1>        

        <cfset ThisShippingStateID = #getShippingAddressQry.state#>

        <cfset ThisBillingStateID =  #getBillingAddressQry.state#>

        <cfset ThisShippingCountryID = #getShippingAddressQry.countryID#>

        <cfset ThisBillingCountryID =  #getBillingAddressQry.countryID#>
 

        <cfloop query="states">

            <cfif ThisShippingStateID EQ states.state_id>

                <cfset ThisShippingState = states.state_2>

            </cfif>

            <cfif ThisBillingStateID EQ states.state_id>

                <cfset ThisBillingState = states.state_2>

            </cfif>

        </cfloop>

        <cfloop query="countries">

            <cfif ThisShippingCountryID EQ countries.Country_ID>

                <cfset ThisShippingCountry = countries.ShortName>

            </cfif>

            <cfif ThisBillingCountryID EQ countries.Country_ID>

                <cfset ThisBillingCountry = countries.ShortName>

            </cfif>

        </cfloop> 

        <!--- canada --->

        <cfif ThisBillingCountryID eq  124>

         <cfinvoke component="checkout" method="selectExtraStates" returnvariable="extrastates"></cfinvoke>

          <cfloop query="extrastates">

                <cfif ThisBillingStateID EQ extrastates.id>

                <cfset ThisBillingState = extrastates.stateabbrev>

            </cfif>

        </cfloop>

        </cfif>

         <cfif #ThisShippingCountryID# eq  124>

         <cfinvoke component="checkout" method="selectExtraStates" returnvariable="extrastates"></cfinvoke>

          <cfloop query="extrastates">

                <cfif ThisShippingStateID EQ extrastates.id>

                <cfset ThisShippingState = extrastates.stateabbrev> 

            </cfif>

        </cfloop>

        </cfif>

		<!--- canada--->

        

        <!--- Hidden variable for processeing creditcard information --->

        <cfinput type="hidden" name="firstName" value="#getBillingAddressQry.firstname#">

        <cfinput type="hidden" name="lastName" value="#getBillingAddressQry.lastname#">

        <cfinput type="hidden" name="shipaddress" value="#getShippingAddressQry.address1#">

        <cfinput type="hidden" name="address1" value="#getBillingAddressQry.address1#">

        <cfinput type="hidden" name="city" value="#getShippingAddressQry.city#">

        <cfinput type="hidden" name="state" value="#ThisShippingState#">

        <cfinput type="hidden" name="shipZip" value="#getShippingAddressQry.postalcode#">

        <cfinput type="hidden" name="zip" value="#getBillingAddressQry.postalcode#">

        <cfinput type="hidden" name="country" value="#getShippingAddressQry.countryID#">

        <cfinput type="hidden" name="userID" value="#user_ID#">

        <cfinput type="hidden" name="shipID" value="#shippingUserAddressId#">

        <cfinput type="hidden" name="billID" value="#billingUserAddressId#">

   		

         &nbsp;

               

			  

            <table width="700" border="0" cellpadding="3" cellspacing="0" class="itemTable">

              <tr>

                <td width="29%" nowrap="nowrap"><strong>Billing Address: </strong></td>

                <td width="42%" nowrap="nowrap"><strong>Contact Information:</strong></td>

              </tr>
 

              <tr>

                <td width="29%" valign="top">#getBillingAddressQry.firstname#&nbsp;#getBillingAddressQry.lastname#<br/>

                                             #getBillingAddressQry.address1#<br/>

                                             <cfif getBillingAddressQry.address2 neq "">

                                                #getBillingAddressQry.address2#<br/>

                                             </cfif>

                                             <cfif ThisBillingCountryID eq 840 or ThisBillingCountryID eq 124 or ThisBillingCountryID eq 484>

                                             #getBillingAddressQry.city#,#ThisBillingState#&nbsp;#getBillingAddressQry.postalcode#<br/>

                                             </cfif>

							                  #ThisBillingCountry#<br/>

                                             <a href="/#CurrentPage#/billing/true">Edit</a> </td>

                <td width="42%" valign="top"><p>Email: #getBillingAddressQry.EMAIL#<br />

                  <!---Daytime Phone: #getBillingAddressQry.PHONE1#---><br />

                  <!---Yes, please send me email updates about #APPLICATION.configStruct.teamName# sales and specials.---></p>

                  </td>

              </tr>

            </table>

		</cfoutput>

	  

    	<cfset sumOforderTotal = 0>

		<cfset cartTotalMiscAmount = 0>

		<!---<cfdump var="#getIdentifiedSplitOrdersArray#">--->

        

		<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="updateTempOrderDetailPrices">

			<cfinvokeargument name="tempOrder_id" value="#tempOrderID#">

		</cfinvoke>      

		

      <!--- ################# Handle Split Order In other Page################################# --->

        

  

   		

   

   

   

		<cfloop from="1" to="#ArrayLen(getIdentifiedSplitOrdersArray)#" index="itemX">

        

        <!--- create the ordertotals array --->-

        	

        

			<!--- Get the order detail records that we need to show --->

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="getOrderDetailsForDetailIDs" returnvariable="getDetailRecordsQry">

				<cfinvokeargument name="orderDetailIDs" value="#getIdentifiedSplitOrdersArray[itemX][2]#">

			</cfinvoke>

           

           <!--- get only the drop ship vendor ID <>0 

            <cfdump var="#getDetailRecordsQry#">--->

            <!--- Now display the details of order--->     

			<table width="700" border="0" cellpadding="3" cellspacing="0" class="itemTable">		

			<cfoutput>

				<tr><td>&nbsp;</td></tr>

				<tr>

					<td colspan="3"><strong>Items Shipping to #getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#</strong></td>

				</tr>

				<tr>

					<td width="29%" nowrap="nowrap"><!---<strong>Shipping Address: </strong>---></td>		

				</tr>

				<tr>

					<td width="29%" valign="top">#getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#<br/>

												 #getShippingAddressQry.address1#<br/>

												 <cfif getShippingAddressQry.address2 neq "">

													#getShippingAddressQry.address2#<br/>

												 </cfif>

                                                 <cfif ThisShippingCountryID eq 840 or ThisShippingCountryID eq 124 or ThisShippingCountryID eq 484>

												 #getShippingAddressQry.city#,#ThisShippingState#&nbsp;#getShippingAddressQry.postalcode#<br/>

                                                 </cfif>

												  #ThisShippingCountry#<br/>

												 <a href="/#CurrentPage#/billing/true">Edit</a>

					</td>    

				</tr>						

	

			</cfoutput>

			</table>

				

			<table width="700" border="0" cellpadding="5" cellspacing="0" class="itemTable">

				<tr>

					<th scope="col">Item</th>

					<th scope="col">Product Details</th>

					<th scope="col">Qty</th>

					<th scope="col">Availability</th>

					<th scope="col">Price</th>

                    <th scope="col">Total</th>

				</tr>
 

			<cfset cartSubTotal = 0>

            <cfset count = 1>
 

			<cfoutput query="getDetailRecordsQry">  

				<cfif getDetailRecordsQry.ShippingMethod_ID neq "">

					<cfset ThisDefaultShippingMethod = getDetailRecordsQry.ShippingMethod_ID>

                    <cfset 'ThisDefaultShippingAddressID_#itemX#' = getDetailRecordsQry.ShippingAddress_ID><!--- this declaration is required for Gift coupon when using redeem button. pl dont take it away --->

                    <cfset 'ThisDefaultShippingMethod_#itemX#' = getDetailRecordsQry.ShippingMethod_ID><!--- this declaration is required for Gift coupon when using redeem button. pl dont take it away --->

                <cfelse>

					<cfset ThisDefaultShippingMethod = 1>

                    <cfset 'ThisDefaultShippingMethod_#itemX#' = 1><!--- this declaration is required for Gift coupon when using redeem button. pl dont take it away --->

                </cfif>

      			  <tr>

					<td width="70" valign="top" nowrap="nowrap" class="cartItem">

						<cfset imageFile = Replace(Replace('#APPLICATION.configStruct.imageURL#/' & getDetailRecordsQry.stdimage,'.jpg','XS.jpg'),'http://','https://')>																																						

						<p><img src="#imageFile#" width="52" height="60" hspace="5" align="right" /></p></td>

					<td>#getDetailRecordsQry.productTitle#</td>

					<td align="center">#getDetailRecordsQry.Qty#</td>

					<cfif #getDetailRecordsQry.IsInStock# EQ true>

						<td><center>In Stock</center></td>

					<cfelse>

						<td><center>Pre-Order</center></td>

					</cfif> 

					<span id="CurPrice"><td align="center">$#NumberFormat(getDetailRecordsQry.price, '99.99')#</td></span>

                    <cfset totalItemPrice = getDetailRecordsQry.price * getDetailRecordsQry.Qty>
 

				<!--- 	<cfif not isDefined("session.DiscountStruct.couponNumber")> --->

				<cfif not isDefined("CLIENT.discountCouponNumber")>

					<td align="center">

                    <span id="TotalPrice_#count#" style='font-size:11px; color:##000000; font-weight:bold;'>$#NumberFormat(totalItemPrice, '99.99')#</span>

                    <span id="strikeCurPrice_#count#"></span>

                    <span id="CouponAppliedAmount_#count#"></span></td>

				   <!--- Below component is to set DiscountPrice and CouponAmount to $0 if coupon is not existing in Session--->

					<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.checkout.checkout" method="UpdateTempOrderDetailsPrice">

                        <cfinvokeargument name="tempOrder_id" value="#tempOrderid#">

                        <cfinvokeargument name="OrderDetail_id" value="#getDetailRecordsQry.OrderDetail_ID#">

                        <cfinvokeargument name="couponAmount" value="0">

                        <cfinvokeargument name="priceAfterCouponApplied" value="0">

                    </cfinvoke>

				<cfelseif isDefined("CLIENT.discountCouponValueType") and CLIENT.discountCouponValueType EQ "percent">

                    <td align="center">

                    <cfif getDetailRecordsQry.DiscountPrice neq 0>

                    <span id="strikeCurPrice_#count#" style='font-size:11px; color:##000000; text-decoration:line-through; font-weight:bold;'>$#NumberFormat(totalItemPrice, '99.99')#</span><br/>

                    <span id="CouponAppliedAmount_#count#" style='font-size:11px; color:##000000; font-weight:bold;'>$#NumberFormat(getDetailRecordsQry.DiscountPrice, '99.99')#</span>

                    <cfelse>

                    <span id="TotalPrice_#count#" style='font-size:11px; color:##000000; font-weight:bold;'>$#NumberFormat(totalItemPrice, '99.99')#</span>

                    </cfif>

                    </td>

				<cfelseif isDefined("CLIENT.discountCouponValueType") and CLIENT.discountCouponValueType EQ "dollar">

					<td align="center">

                    <span id="TotalPrice_#count#" style='font-size:11px; color:##000000; font-weight:bold;'>$#NumberFormat(totalItemPrice, '99.99')#</span>

                    <span id="strikeCurPrice_#count#"></span>

                    <span id="CouponAppliedAmount_#count#"></span></td>

				</cfif>

                    

					<!--- Keep a running total of our cart subTotal --->

					<cfset cartSubTotal = cartSubTotal + (getDetailRecordsQry.price * getDetailRecordsQry.qty)>										

				</tr>

                <cfset count = count + 1>

			</cfoutput>

			</table>

			

			<!--- Figure out what the gift wrap/note total is --->

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.checkout" method="getTempOrderGiftWrapNoteTotal" returnvariable="giftTotal" >

				<cfinvokeargument name="tempOrderID" value="#temporderid#">

			</cfinvoke>

	

			<cfset orderDetailIDList = ValueList(getDetailRecordsQry.orderDetail_ID)>
 

			<!---Get ShippingGroupType ID Method ---> 

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="getShippingMethodType" returnvariable="getShippingMethodTypeIDQry">

				<cfinvokeargument name="ShippingCountryID" value="#ThisShippingCountryID#">

			</cfinvoke>

			<!--- This below if block is to set correct Shipping Method Id by verifying if it is international shipping, canada or mexico or USA shipping --->

            <cfset shipMethodIDFrmCtrID = valuelist(getShippingMethodTypeIDQry.shippingMethod_ID)>

			<cfif listContains(shipMethodIDFrmCtrID,ThisDefaultShippingMethod)>

            	<cfset shipMethodIDFrmCtrID = ThisDefaultShippingMethod>

            <cfelseif shipMethodIDFrmCtrID neq "">

            	<cfset shipMethodIDFrmCtrID = ListFirst(shipMethodIDFrmCtrID)>

                <!--- Update shipping method in tempOrderDetails --->

                <cfoutput query="cartItems">  

                     <cfinvoke component="checkoutprocess" method="updateShipMethod">

                        <cfinvokeargument name="OrderDetailId" value="#ORDERDETAIL_ID#">

                        <cfinvokeargument name="shipMethodId" value="#shipMethodIDFrmCtrID#">

                    </cfinvoke>      

                </cfoutput>

            <cfelse>

            	<cfset availCountryIDforShipping = '840,124,484'>

            	<cfif not listContains(availContryIDforShipping,ThisShippingCountryID)>

                	<cfset shipMethodIDFrmCtrID = 4> <!--- 4 is for International shipping otherthan Mexico and Canada --->

                    <!--- update the table with international shipping incase if they selected other shipping and changed country in Billing Shipping Page--->

                    <cfoutput query="cartItems">  

                        <cfinvoke component="checkoutprocess" method="updateShipMethod">

                            <cfinvokeargument name="OrderDetailId" value="#ORDERDETAIL_ID#">

                            <cfinvokeargument name="shipMethodId" value="#shipMethodIDFrmCtrID#">

                        </cfinvoke>      

               		 </cfoutput>

                <cfelse>

            		<cfset shipMethodIDFrmCtrID = ThisDefaultShippingMethod>

                </cfif>    

			</cfif>

			<!---Get ShippingGroupType Method ---> 

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="getShippingGroupType" returnvariable="getShippingMethodID">

				<cfinvokeargument name="shippingMethodID" value="#shipMethodIDFrmCtrID#"> <!---ThisDefaultShippingMethod#"--->

			</cfinvoke>

            <!--- Get Flat Rate shipping Details --->

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.checkout.shipping" method="getTeamFlatShipping" returnvariable="teamFlatShippingQry">

				<cfinvokeargument name="teamID" value="#APPLICATION.configStruct.teamID#">

			</cfinvoke>
 

			<cfquery name="groundShippingQry" dbtype="query">

				SELECT * 

				FROM teamFlatShippingQry

				WHERE shippingGroupType = '#getShippingMethodID.ShippingGroupType#'

				ORDER BY shippingLevel ASC

			</cfquery>
 

			<!--- Below emailGiftCardItemCount is to deduct the item from the cart if it is emailGiftCard --->

			<cfset emailGiftCardItemCount = 0>

			<cfloop query="getDetailRecordsQry">

				<cfif productTitle EQ "Email Gift Card" or productTitle EQ "Gift Card">

					<cfset emailGiftCardItemCount = emailGiftCardItemCount + 1>

				</cfif>

			</cfloop>
 

	

			<cfquery name="numOfItemsForHandlingCharges" dbtype="query">

				SELECT SUM(Qty) AS totalItems 

				FROM   getDetailRecordsQry

			</cfquery>

				

			<cfquery name="numOfItemsForShippingCharges" dbtype="query">

				SELECT SUM(Qty) AS totalItems 

				FROM   getDetailRecordsQry

				WHERE  priceAsShipped <> 1

			</cfquery>

			

			<!--- Since we cannot do an isNull(sum(Qty),0) for numOfTotalItems lets do this cheesy workaround --->

			<cfif numOfItemsForShippingCharges.totalItems EQ "">

				<cfset totalItems = 0>

			<cfelse>

				<cfset totalItems = numOfItemsForShippingCharges.totalItems>	   	

			</cfif>

		

			<cfset numOfcartItems = totalItems - emailGiftCardItemCount>

			<cfset ThisShippingFee = 0>

			<cfset ThisShippingAndHandlingFee =  0>

		

            <cfoutput query="groundShippingQry">

            	<cfif getShippingMethodID.SHIPPINGGROUPTYPE eq SHIPPINGGROUPTYPE>

					<cfif getShippingMethodID.SHIPPINGGROUPTYPE eq "ground">

                    	<cfif numOfcartItems GE ITEMSTART>

                        	<cfif numOfcartItems LE ITEMEND or ItemEnd EQ "">

                            	<cfset ThisShippingFee = SHIPPINGFEE>

								 <!--- <cfset ThisShippingAndHandlingFee =  SHIPPINGANDHANDLINGFEE > --->

                            </cfif>

                        </cfif>

                    <cfelse>

                    	<cfset ThisShippingFee = SHIPPINGFEE>

						<!--- <cfset ThisShippingAndHandlingFee =  SHIPPINGANDHANDLINGFEE > --->

					</cfif>

                </cfif>

            </cfoutput>

			

			<!--- Figure out what the handling fee is.  The fee is strictly based on how many items are in the cart regardless of what they are per Moira. --->

			<cfquery name="getHandlingChargesQry" dbtype="query">

				SELECT shippingAndHandlingFee

				FROM   groundShippingQry

				WHERE  itemStart <= #numOfItemsForHandlingCharges.totalItems#

				AND    itemEnd >= #numOfItemsForHandlingCharges.totalItems#

			</cfquery>

			

			<!--- Set the handling fee --->

			<cfset ThisShippingAndHandlingFee = getHandlingChargesQry.shippingAndHandlingFee>

					

            <!--- Below if statement is for single item in cart containing Email Gift card, we are making their shipping and handling to 0 --->

            <cfif getDetailRecordsQry.recordcount EQ 1>

            	<cfif emailGiftCardItemCount GT 0>

                	<cfset ThisShippingFee = 0>

					<cfset ThisShippingAndHandlingFee =  0>

            	</cfif>

            </cfif>
 

			<!--- The business now wants to charge a flat ground shipping rate for gift cards.  The rule is if there is 1 to x number of gift cards in the cart then the shipping is $x.

			If there is any other products in the cart aside from a gift card then the flat shipping rate does not apply.  Normal shipping rates apply when another option is selected aside

			from ground.  --->

			

			<cfif getShippingMethodID.shippingGroupType EQ 'ground' AND emailGiftCardItemCount GT 0>

			

				<cfquery name="numOfNonGiftCardItemsQry" dbtype="query">

					SELECT SUM(qty) AS totalItems

					FROM   CARTITEMS

					WHERE  productTitle NOT IN ('Email Gift Card', 'Gift Card')

				</cfquery>		

				

				<cfif numOfNonGiftCardItemsQry.recordCount EQ 0>	

					<!--- Since we know now that we need special pricing for just the gift cards in the cart lets get the parent product.  Then we will go

						  get the price that we need to use from ACBMASTER.promo_products.   --->

					<cfquery name="giftCardProductIDQry" dbtype="query">

						SELECT product_id

						FROM   CARTITEMS

						WHERE  productTitle IN ('Email Gift Card', 'Gift Card')

					</cfquery>		

						  

					<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.product.product" method="getProductParentByProductID" returnvariable="productParentQry">

						<cfinvokeargument name="productID" value="#giftCardProductIDQry.product_ID#">

					</cfinvoke>

			

					<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.product.product" method="getPromoProductDetails" returnvariable="promoProductQry">

						<cfinvokeargument name="productID" value="#productParentQry.product_ID#">

					</cfinvoke>

					<cfif promoProductQry.shippingRate eq "">

						<cfset ThisDefaultShippingRate = 0>

                    <cfelse>                    

                        <cfset ThisDefaultShippingRate = promoProductQry.shippingRate>	

                    </cfif>	

				</cfif>

			</cfif>
 

			<cfset otherTaxables = ThisShippingFee + ThisShippingAndHandlingFee>
 

			<!--- Figure out what the Tax is --->

			<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.taxes" method="calculateTaxes" returnvariable="taxArray" >

				<cfinvokeargument name="tempOrderID" value="#temporderid#">

				<cfinvokeargument name="orderDetail_ids" value="#orderDetailIDList#">					

				<cfinvokeargument name="shippingAddress_ID" value="#shippingUserAddressId#">			

				<cfinvokeargument name="otherTaxables" value="#otherTaxables#">							

			</cfinvoke>

				

			<cfif ArrayLen(taxArray) EQ 1>

				<cfset orderTaxAmount = taxArray[1][2]>

			<cfelse>

				<cfset orderTaxAmount = 0>		

			</cfif>			

			

            <cfif isDefined("CLIENT.discountCouponamount") AND LEN(CLIENT.discountCouponamount)>

            	<cfif itemX EQ 1>

            		<cfset couponAmount = CLIENT.discountCouponamount>

                <cfelse>

                	<cfset couponAmount = 0>

				</cfif>

            </cfif>

			

            <cfif isDefined("CLIENT.discountBOGODiscountSavings") AND LEN(CLIENT.discountBOGODiscountSavings)>

            	<cfif itemX EQ 1>

                    <cfset DiscountSavings = CLIENT.discountBOGODiscountSavings>

                    <cfset couponAmount = couponAmount - DiscountSavings>

                <cfelse>

                    <cfset DiscountSavings = 0>

                </cfif> 

            </cfif>    
 

 			<!--- Add up the items to get the order total --->

			<cfset orderTotal = cartSubTotal + giftTotal + ThisShippingFee + ThisShippingAndHandlingFee + orderTaxAmount - couponAmount>		

			<cfset cartTotalMiscAmount = giftTotal + ThisShippingFee + ThisShippingAndHandlingFee + orderTaxAmount - couponAmount >

            <cfset sumOforderTotal = sumOforderTotal + orderTotal>			

	

            <cfoutput>

            <table width="700" border="0" cellpadding="5" cellspacing="0" class="totalsTable">

                  <tr>

                    <td align="right" scope="col"><strong>Merchandise Subtotal: </strong></td>

                    <td width="10%" align="right" nowrap="nowrap" scope="col">

                    	<cfinput type="text" readonly="readonly" name="cartBottomSubTotalAmount_#itemX#" style="font-weight:bold" value="#DollarFormat(cartSubTotal)#" size="5" >

                    	<cfinput type="hidden" name="SubTotalAmount_#itemX#" value="#cartSubTotal#">

						<!---#DollarFormat(cartSubTotal)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Gift Wrap: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomGiftWrapAmount_#itemX#" value="#DollarFormat(giftTotal)#" size="5" >

                        <cfinput type="hidden" name="GiftWrapAmount_#itemX#" value="#giftTotal#">

                        <!---#DollarFormat(giftTotal)#--->

                    </td>

                  </tr>

                 

                 

                 

                 <cfif ThisShippingAndHandlingFee eq 0 and ThisShippingFee gt 0>

                <tr>

                <td align="right">Shipping &amp; Handling:</td>

                 <td width="10%" align="right" nowrap="nowrap">#DollarFormat(ThisShippingFee+ThisShippingAndHandlingFee)#&nbsp;&nbsp;&nbsp;</td>                       	<cfinput type="hidden" readonly="readonly" name="cartBottomShippingAmount_#itemX#" value="#DollarFormat(ThisShippingFee)#" >

                        <cfinput type="hidden" name="ShippingAmount_#itemX#" value="#ThisShippingFee#"> 

                       <cfinput type="hidden" readonly="readonly" name="cartBottomHandlingAmount_#itemX#" value="#DollarFormat(ThisShippingAndHandlingFee)#">

                        <cfinput type="hidden" name="HandlingAmount_#itemX#" value="#ThisShippingAndHandlingFee#">

                   </tr>

                 <cfelse>

                 <tr>

                    <td align="right">Shipping: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomShippingAmount_#itemX#" value="#DollarFormat(ThisShippingFee)#" size="5" >

                        <cfinput type="hidden" name="ShippingAmount_#itemX#" value="#ThisShippingFee#">

                    	<!---#DollarFormat(ThisShippingFee)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Handling:</td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomHandlingAmount_#itemX#" value="#DollarFormat(ThisShippingAndHandlingFee)#" size="5" >

                        <cfinput type="hidden" name="HandlingAmount_#itemX#" value="#ThisShippingAndHandlingFee#">

                        <!---#DollarFormat(ThisShippingAndHandlingFee)#--->

                    </td>

                  </tr>

                 </cfif>

                              

                  <tr>

                    <td align="right">Tax: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomOrderTaxAmount_#itemX#" value="#DollarFormat(orderTaxAmount)#" size="5" >

                         <cfinput type="hidden" name="OrderTaxAmount_#itemX#" value="#orderTaxAmount#">		 	

                        <!---#DollarFormat(orderTaxAmount)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Discount/promo: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<!---#DollarFormat(couponAmount)#--->

                    	<cfset couponAmountFormat = '-' & '#DollarFormat(couponAmount)#'>

                        <cfinput type="text" readonly="readonly" name="cartBottomCouponAmount_#itemX#" value="#couponAmountFormat#" size="5" >

                    </td>

                  </tr>

                  <tr>

                    <td align="right"><strong>Total for Items Shipping to #getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#

                    </strong></td>

                    <td align="right" width="10%">

                    	<cfinput type="text"readonly="readonly" name="cartBottomTotal_#itemX#" style="font-weight:bold" value="#DollarFormat(orderTotal)#" size="5" >

                       <!--- <cfif getDetailRecordsQry.DropshipvendorId ge 0>--->

                       

                         <cfif isdefined("getIdentifiedSplitOrdersArray") and ArrayLen(getIdentifiedSplitOrdersArray) GE 0>

                           	<CFLOCK TIMEOUT="30" NAME="session.orderTotalsArray" TYPE="Exclusive">

                            	<cfset session.orderTotalsArray=ArrayNew(2)>  

                            </CFLOCK>    

                            </cfif> 

                            

                       																 

                       

                      

                     

                      

                      

                

                      

                        <!--- insert code to add this total to the orderTotals array --->

                           <cfset session.orderTotalsArray[itemX][1] = "#orderTotal#"> 

                         <cfset session.orderTotalsArray[itemX][2] ="#getIdentifiedSplitOrdersArray[itemX][2]#"> 

                       <!--- <cfset session.orderTotalsArray[itemX][3] = "#getDetailRecordsQry.Product_id#"> --->  

                       

					   

									<cfset OrdertoDelete = #getnondropshipid.ORDERDETAIL_ID#>

                                    

                                    <!--- loop through the keys in the outer structure --->

                                    

                                    <cfloop array="#structKeyArray(session.orderTotalsArray)#" index="key">

                                    

                                        <!--- get the current order information --->

                                        <cfset order = session.orderTotalsArray[key]>

                                        

                                        <!--- check the list of order_ids for the specified value --->

                                       

                                        <cfif listFind(order[2], orderToDelete)>

                                       

                                            <!--- if the order_id is found, delete the whole entry --->

                                            <cfset structDelete(session.orderTotalsArray, key)>		

                                        </cfif>

                                    </cfloop>

					   

					   

					   <!--- <cfif getnondropshipid.recordcount GT 1>

                    

                      		<cfloop query="getnondropshipid">

                             

							  <cfset x=ArrayAppend(session.orderTotalsArray,#getnondropshipid.ORDERDETAIL_ID#)> 

                              

                             

                      	  	</cfloop>   

                      </cfif>

                      <cfloop list="#orderTotal#">

                      <cfset y = ArrayNew(2)>

                              <cfset Y = (#orderTotal#)>

                      </cfloop>--->

                      

                      

                          <!--- <cfset ArrayInsertAt(session.orderTotalsArray, 1,#orderTotal#)> --->

                    

                    </td>

                    <!--- Below code is to identify DropshipItem and if found send orderTotal to ccard Processing to do sale on this amount instead of authorization --->

					<cfset dropShipCount = 0>

		            <cfloop query="getDetailRecordsQry">

						<cfif getDetailRecordsQry.DropShipItem Eq 1>

                           <cfset dropShipCount = dropShipCount + 1>

                        </cfif>

                    </cfloop>

                    <cfif dropShipCount ge 1>

                    	<cfset dropShipItemTotalAmount = orderTotal>

                      <!---  Identify the Drop ship Item and delete It from the array  --->

					</cfif>

                    <!---<td width="10%" align="right" nowrap="nowrap"><strong>#DollarFormat(orderTotal)#</strong></td> class="totalAmount"--->

                  </tr>

            </table>

            </cfoutput>

		</cfloop>

       <!---  <cfdump var="#application#"> --->

                                                            <!---  <cfdump var="#Y#" label="assiging values">   --->                                                        

                                                         

                                                         <!---  <cfif getnondropshipid.recordcount GT 0 >

                                                            <cfset OrdertoDelete = "#getnondropshipid.ORDERDETAIL_ID#">

                                                               

                                                               <cfloop from="#Arraylen(session.orderTotalsArray)#"to="1" index="i" step="-1">

                                                                	<cfset order = session.orderTotalsArray[i]>

																<cfif order[i] eq OrdertoDelete>

																		<cfset ArrayDeleteAt(session.orderTotalsArray,order[i])>		

															

                                                               	</cfif>

                                                               

                                                          	 </cfloop> 

															</cfif>

                                                            

                                                             <cfdump var="#session.orderTotalsArray#" label="after delete"><cfabort>

                                                             

                                                             <!---

	To demonstrate, create fake array with Order_Id in the first position

--->

<cfset orderTotalsArray = arrayNew(1)>

<cfset orderTotalsArray[1] = [ 99, "stuff"]>

<cfset orderTotalsArray[2] = [ 2, "computers"]>

<cfset orderTotalsArray[3] = [ 99, "stuff"]>

<cfset orderTotalsArray[4] = [ 3, "books"]>

<cfset orderTotalsArray[5] = [ 99, "stuff"]>

 

<cfdump var="#orderTotalsArray#" label="Before Delete">

 

<!--- search for Order_id "99" --->

<cfset searchForThisOrderId = 99>

 

<!--- loop through the array in reverse order --->

<cfloop from="#Arraylen(session.orderTotalsArray)#" to="1" index="i" step="-1">

	<!--- get the current element --->

	<cfset order = session.orderTotalsArray[i]>

	<!--- check the order_id. if it matches, delete it --->

	<cfif order[1] eq searchForThisOrderId>

		<cfset ArrayDeleteAt(session.orderTotalsArray, i)>		

	</cfif>

</cfloop> --->

 

 <cfdump var="#session.orderTotalsArray#" label="After Delete">  
 

        

  <!--- ################# Handle Split Order In other Page#END################################ --->

    &nbsp;

    <cfelse>      
 

	    	<cfif isdefined("CLIENT.userloggedin") and CLIENT.userloggedin EQ true>  

            <!--- invoke method to get User Addresses --->

            <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Account.myAccount" method="getUserAddresses" returnvariable="addressbook">

                <cfinvokeargument name="UserID" value="#CLIENT.UserID#">

            </cfinvoke>
 

            <cfquery name="getBillingAddressQry" dbtype="query">

                SELECT * FROM addressbook WHERE useraddresstype_ID = 1 and userID = #CLIENT.UserID#

            </cfquery>
 

			<cfset ThisBillingStateID =  #getBillingAddressQry.state#>

            <cfset ThisBillingCountryID =  #getBillingAddressQry.countryID#>

            <cfloop query="states">

            <!---<cfif ThisShippingStateID EQ states.state_id>

                <cfset ThisShippingState = states.state_2>

            </cfif>--->

            <cfif ThisBillingStateID EQ states.state_id>

                <cfset ThisBillingState = states.state_2>

            </cfif>

        </cfloop>

        <cfloop query="countries">

           <!--- <cfif ThisShippingCountryID EQ countries.Country_ID>

                <cfset ThisShippingCountry = countries.ShortName>

            </cfif>--->

            <cfif ThisBillingCountryID EQ countries.Country_ID>

                <cfset ThisBillingCountry = countries.ShortName>

            </cfif>

        </cfloop>

        

        <!--- Hidden variable for processeing creditcard information --->

         <cfinput type="hidden" name="address1" value="#getBillingAddressQry.address1#">

         <cfinput type="hidden" name="state" value="#ThisShippingState#">

         <cfinput type="hidden" name="zip" value="#getBillingAddressQry.postalcode#">

         <cfinput type="hidden" name="userID" value="#user_ID#">

         <cfinput type="hidden" name="billID" value="#getBillingAddressQry.USERADDRESS_ID#">

          

        <cfoutput>

    		<table width="700" border="0" cellpadding="3" cellspacing="0" class="itemTable">

              <tr>

                <td width="29%" nowrap="nowrap"><strong>Billing Address: </strong></td>

                <td width="42%" nowrap="nowrap"><strong>Contact Information: </strong></td>

              </tr>

              <tr>   

                <td width="29%" valign="top">#getBillingAddressQry.firstname#&nbsp;#getBillingAddressQry.lastname#<br/>

                                             #getBillingAddressQry.address1#<br/>

                                             <cfif getBillingAddressQry.address2 neq "">

                                                #getBillingAddressQry.address2#<br/>

                                             </cfif>

                                             <cfif ThisBillingCountryID eq 840 or ThisBillingCountryID eq 124 or ThisBillingCountryID eq 484>

                                             #getBillingAddressQry.city#,#ThisBillingState#&nbsp;#getBillingAddressQry.postalcode#<br/>

                                             </cfif>

                  							 #ThisBillingCountry#<br/>

                                             <a href="/#CurrentPage#/billing/true">Edit</a>

                </td>

                <td width="42%" valign="top"><p>Email: #getBillingAddressQry.EMAIL#<br />

                  <!---Daytime Phone: #getBillingAddressQry.PHONE1#---><br />

                <!---Yes, please send me email updates about #APPLICATION.configStruct.teamName# sales and specials.---></p>

                  </td>

              </tr>

            </table>

        </cfoutput>

    		<cfset comboDetailIDList = "">

            <cfset allowSplitShipment = 0>

			<cfset allowSplitShipment = #APPLICATION.configStruct.shipToMultipleAddresses#>

            <cfif allowSplitShipment EQ 1>

				<!--- Check to see if any of the products are combos. If there are some then we need to exclude the main combo product

				from being added to any child orders and put it on the parent order.  --->

				<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="checkForCombos" returnvariable="getComboProductsQry">

					<cfinvokeargument name="tempOrderID" value="#temporderid#">

    	         </cfinvoke>

                 			

				<cfif getComboProductsQry.recordCount GT 0>

					<!--- There are combos in the order so lets add them to the order --->

					<!--- First create a list of the order detail records that need to be added --->

					<cfset comboDetailIDList = ValueList(getComboProductsQry.orderDetail_ID)>

				</cfif>

			</cfif>

    		<!--- Main function to generate split shipments. Function returns a 2-dimensional array with shippingaddress group with shipping details. --->

             <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="identifySplitOrders" returnvariable="getIdentifiedSplitOrdersQry">

             	<cfinvokeargument name="tempOrderID" value="#temporderid#">

				<cfinvokeargument name="allowSplitShipment" value="#allowSplitShipment#">		

				<cfinvokeargument name="excludeDetailList" value="#comboDetailIDList#">

				<cfinvokeargument name="shipAsAvailable" value="#COOKIE.shipAsAvailable#">					

             </cfinvoke>

			<cfset numOfMultiSplitOrders = #Arraylen(getIdentifiedSplitOrdersQry)#>

       		<cfset sumOforderTotal = 0>

            <cfset cartTotalMiscAmount = 0>

          

		   

		   <!--- Loop over the array to display shipping information --->

<cfloop from="1" to="#Arraylen(getIdentifiedSplitOrdersQry)#" index="i">

             	<cfset shippingAddress_ID = getIdentifiedSplitOrdersQry[i][1]>

                <cfset OrderDetailID = getIdentifiedSplitOrdersQry[i][2]>

				<cfquery name="getShippingAddressQry" dbtype="query">

					SELECT * FROM addressbook WHERE useraddresstype_ID = 2 and useraddress_ID = #shippingAddress_ID#

				</cfquery>
 

                <cfset ThisShippingStateID =  #getShippingAddressQry.state#>

                <cfset ThisShippingCountryID =  #getShippingAddressQry.countryID#>

                <cfloop query="states">

					<cfif ThisShippingStateID EQ states.state_id>

                        <cfset ThisShippingState = states.state_2>

                    </cfif>				

                </cfloop>

                <cfloop query="countries">

					<cfif ThisShippingCountryID EQ countries.Country_ID>

                        <cfset ThisShippingCountry = countries.ShortName>

                    </cfif>

                </cfloop>
 

				<cfset ThisShippingStateID = #getShippingAddressQry.state#>

			   	<cfset ThisShippingCountryID = #getShippingAddressQry.countryID#>

				<cfinput type="hidden" name="firstName" value="#getShippingAddressQry.firstname#">

				<cfinput type="hidden" name="lastName" value="#getShippingAddressQry.lastname#">

				<cfinput type="hidden" name="shipaddress" value="#getShippingAddressQry.address1#">

				<cfinput type="hidden" name="city" value="#getShippingAddressQry.city#">

				<cfinput type="hidden" name="shipZip" value="#getShippingAddressQry.postalcode#">

				<cfinput type="hidden" name="country" value="#getShippingAddressQry.countryID#">

				<cfinput type="hidden" name="shipID" value="#shippingAddress_ID#">

				

				<cfoutput>

                  <table width="700" border="0" cellpadding="3" cellspacing="0" class="itemTable">

                      <tr>

                        <td colspan="3"><h3><strong>Items Shipping to #getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#</strong></h3></td>

                        </tr>

                      <tr>

                        <td width="29%" nowrap="nowrap"><strong>Shipping Address: </strong></td>

                        <td width="42%" nowrap="nowrap"><!---<strong>Contact Information: </strong>---></td>

                      </tr>

                      <tr>

                        <td width="29%" valign="top">#getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#<br/>

                                                     #getShippingAddressQry.address1#<br/>

                                                     <cfif getShippingAddressQry.address2 neq "">

                                                        #getShippingAddressQry.address2#<br/>

                                                     </cfif>

                                                     <cfif ThisShippingCountryID eq 840 or ThisShippingCountryID eq 124 or ThisShippingCountryID eq 484>

                                                     #getShippingAddressQry.city#,#ThisShippingState#&nbsp;#getShippingAddressQry.postalcode#<br/>

                                                     </cfif>

                          #ThisShippingCountry#<br/>

                                                     <a href="/#CurrentPage#/billing/true">Edit</a>

                        </td>    

                        <td width="42%" valign="top"><!---<p>Email: #getShippingAddressQry.EMAIL#<br />

                         <!--- Daytime Phone: #getShippingAddressQry.PHONE1#<br />

                        Yes, please send me email updates about #APPLICATION.configStruct.teamName# sales and specials.---></p>--->

                          </td>

                      </tr>

                </table>

	            </cfoutput>

				

                <table width="526" border="0" cellpadding="5" cellspacing="0" class="itemTable">

                  <tr>

                    <th scope="col">Item</th>

                    <th scope="col">Product Details</th>

                    <th scope="col">Qty</th>

                    <th scope="col">Availability</th>

                    <th scope="col">Price</th>

                  </tr>

				  

				<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="updateTempOrderDetailPrices">

					<cfinvokeargument name="tempOrder_id" value="#tempOrderID#">

				</cfinvoke>      

				  

				 <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.Checkout" method="getOrderDetailsForDetailIDs" returnvariable="getDetailRecordsQry">

					<cfinvokeargument name="orderDetailIDs" value="#getIdentifiedSplitOrdersQry[i][2]#">

				 </cfinvoke>

   

				<cfoutput query="getDetailRecordsQry">	

                    <tr>

                        <td width="70" valign="top" nowrap="nowrap" class="cartItem">

                            <cfset imageFile = Replace(Replace('#APPLICATION.configStruct.imageURL#/' & getDetailRecordsQry.stdimage,'.jpg','XS.jpg'),'http://','https://')>																																

                            <p><img src="#imageFile#" width="52" height="60" hspace="5" align="right" /></p></td>

                        <td>#getDetailRecordsQry.productTitle#</td>

                        <td align="center">#getDetailRecordsQry.Qty#</td>

                        <cfif getDetailRecordsQry.IsInStock EQ true>

                            <td>In Stock</td>

                        <cfelse>

                            <td>Pre-Order</td>

                        </cfif> 
 

                        <!--- Since we are pulling price now from the products table member combo products will have a price set. We need to ignore them and set them to 0 --->

                        <cfif getDetailRecordsQry.comboProduct_ID GT 1>

                            <cfset getDetailRecordsQry.price = 0>

                        </cfif>
 

                        <td align="center">#DollarFormat(getDetailRecordsQry.price)#</td>

                      </tr>

                      	<cfif not isDefined("CLIENT.discountCouponamount")>     

                            <!--- Below component is to set DiscountPrice and CouponAmount to $0 if coupon is not existing in Session--->

                            <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.checkout.checkout" method="UpdateTempOrderDetailsPrice">

                                <cfinvokeargument name="tempOrder_id" value="#tempOrderid#">

                                <cfinvokeargument name="OrderDetail_id" value="#getDetailRecordsQry.OrderDetail_ID#">

                                <cfinvokeargument name="couponAmount" value="0">

                                <cfinvokeargument name="priceAfterCouponApplied" value="0">

                            </cfinvoke>

                        </cfif>

                  </cfoutput>

                </table>

            	

				<!--- Calculate shipping method --->

                <cfquery name="getShippingMethodQry" dbtype="query">

                    SELECT Distinct ShippingMethod_ID FROM getDetailRecordsQry

                </cfquery>

                <cfset ThisDefaultShippingMethod = getShippingMethodQry.ShippingMethod_ID>

                <cfset 'ThisDefaultShippingMethod_#i#' = getDetailRecordsQry.ShippingMethod_ID><!--- this declaration is required for Gift coupon when using redeem button. pl dont take it away --->

                <cfset 'ThisDefaultShippingAddressID_#i#' = getDetailRecordsQry.ShippingAddress_ID><!--- this declaration is required for Gift coupon when using redeem button. pl dont take it away --->

                

				<!--- Calculate the order sub-total --->

                <cfquery name="getCartSubTotalQry" dbtype="query">

                    SELECT SUM(qty*price) AS subTotal

                    FROM   getDetailRecordsQry

                </cfquery>
 
 

				<!--- Figure out what the gift wrap/note total is --->

                <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.checkout" method="getTempOrderGiftWrapNoteTotal" returnvariable="giftTotal" >

                    <cfinvokeargument name="tempOrderID" value="#temporderid#">

					<cfinvokeargument name="orderDetail_IDs" value="#getIdentifiedSplitOrdersQry[i][2]#">

                </cfinvoke>

                    

                 <!---Get ShippingGroupType Method ---> 

                 <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.CheckOut.Shipping" method="getShippingGroupType" returnvariable="getShippingMethodID">

                        <cfinvokeargument name="shippingMethodID" value="#ThisDefaultShippingMethod#">

                  </cfinvoke>

                  

				 <cfinvoke component="#APPLICATION.configStruct.componentPath#.model.checkout.shipping" method="getTeamFlatShipping" returnvariable="teamFlatShippingQry">

                        <cfinvokeargument name="teamID" value="#APPLICATION.configStruct.teamID#">

                 </cfinvoke>

				 

                 <cfquery name="groundShippingQry" dbtype="query">

                    SELECT * 

                    FROM teamFlatShippingQry

                    WHERE shippingGroupType = '#getShippingMethodID.ShippingGroupType#'

                    ORDER BY shippingLevel ASC

                 </cfquery>
 

                <cfset emailGiftCardItemCount = 0>

                <cfoutput query="getDetailRecordsQry">

					<cfif productTitle EQ "Email Gift Card" or productTitle EQ "Gift Card">

                        <cfset emailGiftCardItemCount = emailGiftCardItemCount + 1>

                    </cfif>

                </cfoutput>

				

				<!---

                <cfquery name="numOfTotalItems" dbtype="query">

	                select sum(Qty) as totalItems from getDetailRecordsQry

                </cfquery>

				--->

				

				<cfquery name="numOfItemsForHandlingCharges" dbtype="query">

					SELECT SUM(Qty) AS totalItems 

					FROM   getDetailRecordsQry

				</cfquery>

					

				<cfquery name="numOfItemsForShippingCharges" dbtype="query">

					SELECT SUM(Qty) AS totalItems 

					FROM   getDetailRecordsQry

					WHERE  priceAsShipped <> 1

				</cfquery>

				

				<!--- Since we cannot do an isNull(sum(Qty),0) for numOfTotalItems lets do this cheesy workaround --->

				<cfif numOfItemsForShippingCharges.totalItems EQ "">

					<cfset totalItems = 0>

				<cfelse>

					<cfset totalItems = numOfItemsForShippingCharges.totalItems>	   	

				</cfif>

				

                <cfquery name="numOfTotalComboItemsQry" dbtype="query">

	                SELECT COUNT(1) AS totalComboItems 

					FROM   getDetailRecordsQry

					WHERE  qty = 0

					AND    comboProduct_ID IS NOT NULL

                </cfquery>
 

				<cfif numOfTotalComboItemsQry.totalComboItems GT 0>

					<cfset totalComboItemCount = numOfTotalComboItemsQry.totalComboItems>

				<cfelse>

					<cfset totalComboItemCount = 0>

				</cfif>					

					

                <cfset numOfcartItems = totalItems - emailGiftCardItemCount + totalComboItemCount>

				

				<cfset ThisShippingFee = 0>

				<cfset ThisShippingAndHandlingFee = 0>
 

				<cfoutput query="groundShippingQry">

				<cfif getShippingMethodID.SHIPPINGGROUPTYPE eq SHIPPINGGROUPTYPE>

					<cfif getShippingMethodID.SHIPPINGGROUPTYPE eq "ground">

						<cfif numOfcartItems GE ITEMSTART>

							<cfif numOfcartItems LE ITEMEND or ItemEnd EQ "">

								<cfset ThisShippingFee = SHIPPINGFEE>

								<!--- <cfset ThisShippingAndHandlingFee =  SHIPPINGANDHANDLINGFEE >  --->

							</cfif>

						</cfif>

					<cfelse>

						<cfset ThisShippingFee = SHIPPINGFEE>

						<!--- <cfset ThisShippingAndHandlingFee =  SHIPPINGANDHANDLINGFEE > --->

					</cfif>

				</cfif>

				</cfoutput>

				

				<!--- Figure out what the handling fee is.  The fee is strictly based on how many items are in the cart regardless of what they are per Moira. --->

				<cfquery name="getHandlingChargesQry" dbtype="query">

					SELECT shippingAndHandlingFee

					FROM   groundShippingQry

					WHERE  itemStart <= #numOfItemsForHandlingCharges.totalItems#

					AND    itemEnd >= #numOfItemsForHandlingCharges.totalItems#

				</cfquery>

				

				<!--- Set the handling fee --->

				<cfset ThisShippingAndHandlingFee = getHandlingChargesQry.shippingAndHandlingFee>

				

				<!--- Below if statement is for single item in cart containing Email Gift card, we are making their shipping and handling to 0 --->

				<cfif cartitems.recordcount EQ 1>

                    <cfif emailGiftCardItemCount GT 0>

                        <cfset ThisShippingFee = 0>

                        <cfset ThisShippingAndHandlingFee =  0>

                    </cfif>

                </cfif>
 
 

				<!--- The business now wants to charge a flat ground shipping rate for gift cards.  The rule is if there is 1 to x number of gift cards in the cart then the shipping is $x.

				If there is any other products in the cart aside from a gift card then the flat shipping rate does not apply.  Normal shipping rates apply when another option is selected aside

				from ground.  --->

				

				<cfif getShippingMethodID.shippingGroupType EQ 'ground' AND emailGiftCardItemCount GT 0>

				

					<cfquery name="numOfNonGiftCardItemsQry" dbtype="query">

						SELECT SUM(qty) AS totalItems

						FROM   getDetailRecordsQry

						WHERE  productTitle NOT IN ('Email Gift Card', 'Gift Card')

					</cfquery>		

					

					<cfif numOfNonGiftCardItemsQry.recordCount EQ 0>	

						<!--- Since we know now that we need special pricing for just the gift cards in the cart lets get the parent product.  Then we will go

							  get the price that we need to use from ACBMASTER.promo_products.   --->

						<cfquery name="giftCardProductIDQry" dbtype="query">

							SELECT product_id

							FROM   getDetailRecordsQry

							WHERE  productTitle IN ('Email Gift Card', 'Gift Card')

						</cfquery>		

							  

						<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.product.product" method="getProductParentByProductID" returnvariable="productParentQry">

							<cfinvokeargument name="productID" value="#giftCardProductIDQry.product_ID#">

						</cfinvoke>

				

						<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.product.product" method="getPromoProductDetails" returnvariable="promoProductQry">

							<cfinvokeargument name="productID" value="#productParentQry.product_ID#">

						</cfinvoke>

						<cfif promoProductQry.shippingRate eq "">

							<cfset ThisDefaultShippingRate = 0>

                        <cfelse>                    

                            <cfset ThisDefaultShippingRate = promoProductQry.shippingRate>	

                        </cfif>

					</cfif>

				</cfif>
 

		

				<cfset otherTaxables = ThisShippingFee + ThisShippingAndHandlingFee>

							

				<!--- Figure out what the Tax is --->

				<cfinvoke component="#APPLICATION.configStruct.componentPath#.model.Checkout.taxes" method="calculateTaxes" returnvariable="taxArray" >

					<cfinvokeargument name="tempOrderID" value="#temporderid#">

					<cfinvokeargument name="orderDetail_ids" value="#getIdentifiedSplitOrdersQry[i][2]#">					

					<cfinvokeargument name="shippingAddress_ID" value="#getIdentifiedSplitOrdersQry[i][1]#">					

					<cfinvokeargument name="otherTaxables" value="#otherTaxables#">							

				</cfinvoke>
 

				<cfif ArrayLen(taxArray) GT 0>

					<cfset orderTaxAmount = taxArray[1][2]>

				<cfelse>

					<cfset orderTaxAmount = 0>		

				</cfif>

                

				<!--- Below section is to set couponAmount when coupon is applied and couponAmount is in Session --->

				<cfif isDefined("CLIENT.discountCouponamount")>               		

                    <cfquery name="getCouponAmt" dbtype="query">

                    	Select couponAmount from getDetailRecordsQry where getDetailRecordsQry.couponAmount > 0

                    </cfquery>    

				   <cfif getCouponAmt.couponAmount GT 0>

	                    <cfset couponAmount = CLIENT.discountCouponamount>

				   <cfelseif (CLIENT.discountCouponValueType eq "dollar") and (i eq 1)>

                        <cfset couponAmount = CLIENT.discountCouponamount>

				   </cfif>

				</cfif>    

                        

				<!--- Add up the items to get the order total --->

				<cfset orderTotal = getCartSubTotalQry.subTotal + giftTotal + ThisShippingFee + ThisShippingAndHandlingFee + orderTaxAmount - couponAmount>

				

                <cfoutput>

            <table width="526" border="0" cellpadding="5" cellspacing="0" class="totalsTable">

                  <tr>

                    <td align="right" scope="col"><strong>Merchandise Subtotal: </strong></td>

                    <td width="10%" align="right" nowrap="nowrap" scope="col">

                    	<cfinput type="text" readonly="readonly" name="cartBottomSubTotalAmount_#i#" style="font-weight:bold" value="#DollarFormat(getCartSubTotalQry.subTotal)#" size="5" >

                    	<cfinput type="hidden" name="SubTotalAmount_#i#" value="#getCartSubTotalQry.subTotal#">

                     	<!---<strong>#DollarFormat(getCartSubTotalQry.subTotal)#</strong>--->

                     </td>

                  </tr>

                  <tr>

                    <td align="right">Gift Wrap: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomGiftWrapAmount_#i#" value="#DollarFormat(giftTotal)#" size="5" >

                       	<cfinput type="hidden" name="GiftWrapAmount_#i#" value="#giftTotal#">

                        <!---#DollarFormat(giftTotal)#--->

                    </td>

                  </tr>

                <!---  <tr>

                    <td align="right">Shipping: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomShippingAmount_#i#" value="#DollarFormat(ThisShippingFee)#" size="5" >

                        <cfinput type="hidden" name="ShippingAmount_#i#" value="#ThisShippingFee#">

                        <!---#DollarFormat(ThisShippingFee)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Handling: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomHandlingAmount_#i#" value="#DollarFormat(ThisShippingAndHandlingFee)#" size="5" >

                        <cfinput type="hidden" name="HandlingAmount_#i#" value="#ThisShippingAndHandlingFee#">

                        <!---#DollarFormat(ThisShippingAndHandlingFee)#--->

                    </td>

                  </tr>--->

                  

                  

                  <cfif ThisShippingAndHandlingFee eq 0 and ThisShippingFee gt 0>

                <tr>

                <td align="right">Shipping &amp; Handling:</td>

                 <td width="10%" align="right" nowrap="nowrap">#DollarFormat(ThisShippingFee+ThisShippingAndHandlingFee)#&nbsp;&nbsp;&nbsp;</td>                       <cfinput type="hidden" readonly="readonly" name="cartBottomShippingAmount_#i#" value="#DollarFormat(ThisShippingFee)#" >

                        <cfinput type="hidden" name="ShippingAmount_#i#" value="#ThisShippingFee#">

                		 <cfinput type="hidden" readonly="readonly" name="cartBottomHandlingAmount_#i#" value="#DollarFormat(ThisShippingAndHandlingFee)#" >

                        	<cfinput type="hidden" name="HandlingAmount_#i#" value="#ThisShippingAndHandlingFee#">

                 </tr>

                 <cfelse>

                 <tr>

                    <td align="right">Shipping: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomShippingAmount_#i#" value="#DollarFormat(ThisShippingFee)#"  >

                        <cfinput type="hidden" name="ShippingAmount_#i#" value="#ThisShippingFee#">

                    	<!---#DollarFormat(ThisShippingFee)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Handling:</td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomHandlingAmount_#i#" value="#DollarFormat(ThisShippingAndHandlingFee)#">

                        <cfinput type="hidden" name="HandlingAmount_#i#" value="#ThisShippingAndHandlingFee#">

                        <!---#DollarFormat(ThisShippingAndHandlingFee)#--->

                    </td>

                  </tr>

                 </cfif>

                   <tr>

                    <td align="right">Tax: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<cfinput type="text" readonly="readonly" name="cartBottomOrderTaxAmount_#i#" value="#DollarFormat(orderTaxAmount)#" size="5" >

                        <cfinput type="hidden" name="OrderTaxAmount_#i#" value="#orderTaxAmount#">

                        <!---#DollarFormat(orderTaxAmount)#--->

                    </td>

                  </tr>

                  <tr>

                    <td align="right">Discount/promo: </td>

                    <td width="10%" align="right" nowrap="nowrap">

                    	<!---#DollarFormat(couponAmount)#--->

                       <!--- <cfif getDetailRecordsQry.couponAmount GT 0>

                    		<cfset couponAmountFormat = '-' & '#DollarFormat(couponAmount)#'>

                        <cfelseif (couponAmount gt 0) and (i eq 1)>

                        	<cfset couponAmountFormat = '-' & '#DollarFormat(couponAmount)#'>

						<cfelse>

                        	<cfset couponAmountFormat = '-' & '#DollarFormat(0)#'>

                        </cfif>--->

                        <cfset couponAmountFormat = '-' & '#DollarFormat(couponAmount)#'>

                        <cfinput type="text" readonly="readonly" name="cartBottomCouponAmount_#i#" value="#couponAmountFormat#" size="5" >

                    </td>

                  </tr>

                  <tr>

                    <td align="right"><strong>Total for Items Shipping to #getShippingAddressQry.firstname#&nbsp;#getShippingAddressQry.lastname#

                    </strong></td>

                    <td align="right" width="10%">

                    	<cfinput type="text" readonly="readonly" name="cartBottomTotal_#i#" style="font-weight:bold" value="#DollarFormat(orderTotal)#" size="5" >

                    </td>

                    <!---<td width="10%" align="right" nowrap="nowrap"><strong>#DollarFormat(orderTotal)#</strong></td>--->

                    <cfset sumOforderTotal = sumOforderTotal + orderTotal>

                    <!--- Below cartTotalMiscAmount is for coupon Redeemption --->

                    <cfset cartTotalMiscAmount = cartTotalMiscAmount + (giftTotal + ThisShippingFee + ThisShippingAndHandlingFee + orderTaxAmount - couponAmount)> 

                  </tr>

					<!--- Below code is to identify Dropship Multi Item and if found send orderTotal to ccard Processing to do sale on this amount instead of authorization --->

                    <cfset 'dropShipCount_#i#' = 0>

                    <cfset 'dropShipItemTotalAmount_#i#' = 0>

		            <cfloop query="getDetailRecordsQry">

						<cfif getDetailRecordsQry.DropShipItem Eq 1>

                           <cfset 'dropShipCount_#i#' = #Evaluate('dropShipCount_#i#')# + 1>

                        </cfif>

                    </cfloop>

                    <cfif #Evaluate('dropShipCount_#i#')# ge 1>

                    	<cfset 'dropShipItemTotalAmount_#i#' = orderTotal>

					</cfif>

                   

            </table>

            	<cfset couponAmount = 0>

            </cfoutput>

</cfloop>
 
 

	  <cfelse> 

        	<cfif url.pg neq 'guest'><!--- for guest checkout session should not expired --->

                  <span class="style1">Your Session has been expired. Please</span>

                  <cfoutput><a href="/#CurrentPage#/login/true" class="style1">click here</a></cfoutput><span class="style1"> to login.</span><cfabort>

            </cfif>

      </cfif>

    </cfif>

    

<!--- create hidden fields for orderTotals array --->

	

	<!---<cfloop from="1" to="arraylen(orderTotals)" index="orderX"	>

		<cfinput type="hidden" name="ordertotalarray#orderX#" value ="#ValueList(getComboProductsQry.orderDetail_ID)#">  

    </cfloop>    

    --->

    		

    

   </cfform>

 <!---    <cfdump var="#getDetailRecordsQry#"><cfdump var="#dropShipCount#"> --->

     </div>

     	<!--- Below div is for processing the payment using Gift cards, Promo Card or Credit Card --->

        <div id="paymentInfo">

             <cfloop query="countries">

                <cfif getBillingAddressQry.countryID EQ countries.Country_ID>

                    <cfset ThisBillCountry = countries.abbreviation>

                </cfif>

            </cfloop>

            

           <cfform name="paymentInfo3" action="/#CurrentPage#/payment/true" onsubmit="return submitForm();">

				<cfinput type="hidden" name="firstName" value="#getBillingAddressQry.firstname#">

				<cfinput type="hidden" name="lastName" value="#getBillingAddressQry.lastname#">

				<cfinput type="hidden" name="shipaddress" value="#getShippingAddressQry.address1#">

				<cfinput type="hidden" name="address1" value="#getBillingAddressQry.address1#">

				<cfinput type="hidden" name="city" value="#getShippingAddressQry.city#">

				<cfinput type="hidden" name="state" value="#ThisShippingState#">

				<cfinput type="hidden" name="shipZip" value="#getShippingAddressQry.postalcode#">

				<cfinput type="hidden" name="zip" value="#getBillingAddressQry.postalcode#">

				<cfinput type="hidden" name="billcountry" value="#ThisBillCountry#">

				<cfinput type="hidden" name="userID" value="#user_ID#">

				<cfif url.pg EQ "guest" or url.pg EQ "rgd">

	                <cfinput type="hidden" name="shipID" value="#shippingUserAddressId#">

					<cfinput type="hidden" name="billID" value="#billingUserAddressId#">

                    <cfinput type="hidden" name="pg" value="guest">

				<cfelse>

                	<cfinput type="hidden" name="shipID" value="#shippingAddress_ID#">

                	<cfinput type="hidden" name="billID" value="#getBillingAddressQry.USERADDRESS_ID#">

                    <cfinput type="hidden" name="pg" value="multiship">

                </cfif>

                <cfif isDefined("CLIENT.discountGiftCardAmount") AND CLIENT.discountGiftCardAmount GT 0>

                	<cfset giftCardRedeemedAmount = CLIENT.discountGiftCardAmount>

					<cfset orderTotal = sumOforderTotal - giftCardRedeemedAmount>

                    <cfif orderTotal Lt 0>

                    	<cfset orderTotal = 0>

                    </cfif>

                <cfelse>

                    <cfset orderTotal = sumOforderTotal>

				</cfif>

                <cfset cartMiscAmount = cartTotalMiscAmount>   

                <h2><center>Payment Information</center></h2>

                    <p><strong>1. Redeem Coupons and Gift Cards</strong>(optional)

                <cfoutput>

				<cfif url.pg EQ "guest" or url.pg EQ "rgd">

                <center>

				<cfinput type="button" class="btn_redeem" style="border:0px solid ##000;" name="dummyData" border="0" value=" " onClick="showPopWin('/views/Checkout/redeemGiftcardCoupons.cfm?orderTotal=#orderTotal#&cartMiscAmount=#cartMiscAmount#&pg=#url.pg#&shipID=#ThisDefaultShippingAddressID_1#&billID=#billingUserAddressId#&shipMethod=#ThisDefaultShippingMethod_1#', 450, 470, null);">

					<!---<cfif isDefined("CLIENT.userid") and CLIENT.userid eq 7187331>

                        <cfinput type="button" class="btn_redeem" style="border:0px solid ##000;" name="dummyData" border="0" value=" " onClick="showPopWin('/views/oldblackhawk/bh_test.cfm', 450, 470, null);">

                    </cfif>--->

                </center>

                <input type="hidden" name="dropShipCount" value="#dropShipCount#" />

                <input type="hidden" name="dropShipItemTotalAmount" value="#dropShipItemTotalAmount#" />
 

				<cfelse> <!--- Below else part is for multiship --->

                	<cfif url.pg EQ "">

                    	<cfset url.pg = 0>

                    </cfif>

                    <cfset dropShipCount = 0>

					<cfset dropShipItemTotalAmount = 0>

                    <cfloop from="1" to="#numOfMultiSplitOrders#" index="numOfSplits">

                    	<cfset dropShipCount = dropShipCount + #Evaluate('dropShipCount_#numOfSplits#')# >

                    	<cfset dropShipItemTotalAmount = dropShipItemTotalAmount + #Evaluate('dropShipItemTotalAmount_#numOfSplits#')# >

                    </cfloop>

                    <input type="hidden" name="dropShipCount" value="#dropShipCount#" />

                	<input type="hidden" name="dropShipItemTotalAmount" value="#dropShipItemTotalAmount#" />

				<cfinput type="button" class="btn_redeem" style="border:0px solid ##000;" name="dummyData" border="0" value=" " onClick="showPopWin('/views/Checkout/redeemGiftcardCoupons.cfm?orderTotal=#orderTotal#&cartMiscAmount=#cartMiscAmount#&pg=#url.pg#&shipID=#ThisDefaultShippingAddressID_1#&billID=#getBillingAddressQry.USERADDRESS_ID#&shipMethod=#ThisDefaultShippingMethod_1#', 450, 470, null);">

                </cfif>

                </cfoutput>

                    <br /><strong>2. Enter Credit Card Information</strong><br />

                	<div id="ErrorMsg" style="padding-top:10px;"></div>

		            Card Type:<br />

                    <cfselect name="nPaymentMethod_ID" query="qryPaymentMethods" queryPosition="below" value="nMethodID" display="sMethodName" 

                    								    onChange="document.getElementById('ErrorMsg').style.display = 'none';">

                        <option value="0">Select Payment Method</option>

                        <option value="0">---------------------</option>

                     </cfselect><br />

                    Card Number: <br />

                    <cfinput type="text" name="sCardNumber" size="20" value="" onFocus="document.getElementById('ErrorMsg').style.display = 'none';">

                    <br />Security Number: <br />

                    <cfinput type="text" name="sCVV2" size="5" style="background-color:##FFFFFF"><br/>

                    <a href="javascript:;" onclick="MM_openBrWindow('/views/checkout/cvv2.cfm','contactus','width=750,height=750');">Where is my security number?</a><br />

                    Exp Date: <br />

                    <cfselect name="nExpMonth">

                        <cfloop from="1" to="12" index="i">

                            <cfoutput><option value="#NumberFormat(i,'09')#" style="background-color:##FFFFFF">#NumberFormat(i,'09')#</option></cfoutput>

                        </cfloop>

                        </cfselect>

                        <cfselect name="nExpYear">

                            <cfset startYear = DateFormat(Now(), 'YY')>

                            <cfset endYear = startYear + 10>

                                <cfloop from="#startYear#" to="#endYear#" index="i">

                                <cfoutput><option value="#NumberFormat(i,'09')#" style="background-color:##FFFFFF">#NumberFormat(i,'09')#</option></cfoutput>

                            </cfloop>

                         </cfselect>

                    

                    <p>

                    <cfoutput>

                    	<cfif isDefined("CLIENT.discountGiftCardAmount")>

                    		<span id="applyGiftCard" style='color:##AC1A2F; font:11px Arial; font-weight:bold;'>Gift Card Redeemed: #DollarFormat(CLIENT.discountGiftCardAmount)#</span>

                        <cfelse>

                    		<span id="applyGiftCard" style="padding-top:10px;"></span>

                        </cfif>

                    <br/>Balance to be applied to credit card:<br />

                      <cfinput type="text" readonly="readonly" name="cartBottomTotal" class="totalAmount" value="#DollarFormat(orderTotal)#" size="7" >

						<!---<strong>#DollarFormat(orderTotal)#</strong>---></p>

						<cfinput type="hidden" name="totalAmount" value="#orderTotal#">

					</cfoutput>

                    <p><center> By pressing the Purchase Now button, this will complete your order.</center></p>

                    <p><center>

                	<!---<cfinput name="purchasenow" type="submit" value="PURCHASE NOW" class="b-shopping">--->

					<cfinput type="submit" class="btn_purchasenow" style="border:0px solid ##000;" name="dummyData" border="0" value=" ">

					<cfinput type="hidden" name="purchasenow" value="PURCHASE NOW">

                    </center><br />                

                    <!---BILL ME LATER or<br />BUY IT NOW INFORMATION.--->

            </p>     

            </cfform>

				    

     <!--- End of processing creditcard information --->

   <!---<cfelse>

        <font size="+1" color="#FF0000" style="font-weight:bold">Your Session has been expired!! Please 

                                        <cfoutput><a href="/#CurrentPage#/login/true">click here</a></cfoutput> to login.</font>

  </cfif>--->

</div>

  

<!--- Message to display depending on the url returned from ccpaymentprocess page <!---#request.strctCompany.sCustPhone#--->--->

<cfif isDefined("url.err")>

	<cfif url.err eq 'msgAVSCVVZIP_N'>

       <cfset msg="Were sorry.  We are having a problem processing your order based on the information provided. The following error occurred: The address or zip code you entered does not match the address or zip code on your credit card.  Please check the address or zip code and click on Purchase to complete your order. If this error persists, please contact customer service at.">

    <cfelseif url.err eq 'msgCVV_N' >

        <cfset msg="Were sorry.  We are having a problem processing your order based on the information provided.<br/>The following error occurred:The Credit Card Identification Number you entered is incorrect.  Please check the number and click on Purchase.<br/>If this error persists, please contact customer service at.">

    <cfelseif url.err eq 'msgAVS_N'>

        <cfset msg="Were sorry.  We are having a problem processing your order based on the information provided.<br/>The following error occurred:The address or zip code you entered does not match the address or zip code on your credit card.  Please check the address or zip code and click on Purchase to complete your order. If this error persists, please contact customer service at.">

    <cfelseif url.err eq 'msgAVSZIP_N'>

        <cfset msg="Were sorry.  We are having a problem processing your order based on the information provided. The following error occurred:The address or zip code you entered does not match the address on your credit card.  Please check the address or zip code and click on Purchase to complete your order.<br/>If this error persists, please contact customer service at.">

    <cfelseif url.err eq 'msgBillAdd_N'>

        <cfset msg='Your Billing Address does not match the credit card bank records.  This may delay the sending out of your order. Please check the address and click on Purchase to complete your order.<br/>If this error persists, please contact customer service at.'>

    <cfelseif url.err eq 'ccID_N'>

        <cfset msg="Were sorry.  We are having a problem processing your order based on the information provided. The following error occurred: The Credit Card Identification Number you entered is incorrect. Please check the number and click on Purchase. If this error persists, please contact customer service at.">

    </cfif>

</cfif>

<cfif isDefined("url.CreditErr")>

    <cfset ErrMsg="Were sorry.  We are having a problem processing your order based on the information provided.  The following error occurred:#url.CreditErr#. Please check your credit card number and expiration date.<br/>If this error persists, please contact customer service.">

</cfif>

<cfif isDefined("url.err")>

	<script language="javascript" type="text/javascript">

                <cfoutput>

                    //document.getElementById('ReportMsg').style.display='none';

                    document.getElementById('ErrorMsg').style.display = 'block'; 

                    document.getElementById('ErrorMsg').innerHTML = "<span style='color:Red;'>#msg#</span>";

                </cfoutput>

    </script>

<cfelseif isDefined("url.CreditErr")>

	<script language="javascript" type="text/javascript">

                <cfoutput>

                    //alert('ErrMsg test');

                    document.getElementById('ErrorMsg').style.display = 'block'; 

                    document.getElementById('ErrorMsg').innerHTML = "<span style='color:Red;'>#ErrMsg#</span>";

                </cfoutput>

    </script>

</cfif>

<!--- End of error msg for cc processing --->  
 
 

<!--- ********************************************* Below code is for google checkout. Will implement when asked for 08/15/2008 ******************************** --->

				  <!---<cfif not structKeyExists(session,"GoogleCart") or structkeyexists(url,"reinit")>

					<cfset session.GoogleCart =  createObject("component","#APPLICATION.configStruct.componentpath#.model.checkout.googlecheckout")> 

                    <cfoutput query="getDetailRecordsQry">

                    	<cfset session.GoogleCart.AddCartItem(item='#product_id#',description='#producttitle#',cost='#price#',quantity='#qty#')>

                        <cfinvoke component="#APPLICATION.configStruct.componentpath#.model.checkout.googlecheckout" method="session.GoogleCart.AddCartItem" returnvariable="getGoogleCartItems">

                            <cfinvokeargument name="item" value="#product_id#">

                            <cfinvokeargument name="description" value="#producttitle#">

                            <cfinvokeargument name="cost" value="#price#">

                            <cfinvokeargument name="quantity" value="#qty#">

                        </cfinvoke>

						<cfset session.GoogleCart.AddCartItem(item='#YourItemID#',description='#Your Description#',cost='#yourCost#',quantity='#YourQTY#')>

					</cfoutput>

				</cfif>--->

                <!--- Get the cart contents ---->

				<!---<cfset Cart = session.GoogleCart.GetCartItems()>>--->

                

                 <!---<form name="googleCheckout" action="https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/362105290694817">

                   

                   <p>

                     <input type="image" name="Google Checkout" alt="Fast checkout through Google" 

                	 src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=362105290694817&w=180&h=46&style=white&variant=text&loc=en_US" height="46"  

                     width="180">

                   </p>

                 </form>--->

   				 <!--- ********************************************* Below code is for google checkout. Will implement when asked for 08/15/2008 ******************************** --->    

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
I created a test using the same code to create the session object and the original array code works perfectly.   One thing I did notice is you are not using any array index in this line of the code:

     <cfset x=ArrayAppend(session.orderTotalsArray (no index here) ,#getnondropshipid.ORDERDETAIL_ID#)>

Though it is a lot of code (too much for a single page) :)

<!--- initialize the session object --->

<cfset session.orderTotalsArray=ArrayNew(2)>  
 

<!--- add a test item --->

<cfset itemX = 1>

<cfset session.orderTotalsArray[itemX] = arrayNew(1)>

<cfset session.orderTotalsArray[itemX][1] = 89.56>  <!--- price ---> 

<cfset session.orderTotalsArray[itemX][2] = "1708863,1708864,1708865">

<cfset session.orderTotalsArray[itemX][3] = "ProductID A"> <!--- fake product id --->
 

<!--- add another test item --->

<cfset itemX = itemX + 1>

<cfset session.orderTotalsArray[itemX][1] = 105.68> 

<cfset session.orderTotalsArray[itemX][2] = "1708862,1708864" >

<cfset session.orderTotalsArray[itemX][3] = "ProductID B">
 

<!--- add one more test item --->

<cfset itemX = itemX + 1>

<cfset session.orderTotalsArray[itemX][1] = 88.65>  

<cfset session.orderTotalsArray[itemX][2] = "999999,1708862,1708864" >

<cfset session.orderTotalsArray[itemX][3] = "ProductID C">

 

<cfdump var="#session.orderTotalsArray#" label="Before Delete">

                      

<!--- try and delete item 1708862 --->

<cfset OrdertoDelete = "1708862">
 

<!--- loop through the array in reverse order --->

<cfloop from="#Arraylen(session.orderTotalsArray)#" to="1" index="i" step="-1">

	<!--- get the current element --->

	<cfset order = session.orderTotalsArray[i]>

	<!--- check the order_id. if it matches, delete it --->

	 <cfif listFind(order[2], orderToDelete)>

		<cfset ArrayDeleteAt(session.orderTotalsArray, i)>		

	</cfif>

</cfloop>
 

<cfdump var="#session.orderTotalsArray#" label="After Delete">

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
Here are the results
sessionOrderTotalsArrayResults.png
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Awe some Sir, works too good, Thanks for the support, will be in touch ..
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
I am glad it is fixed now :)
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Hello _agx_,
I was happy cause your guidance has solved my issue, but I went ahead and made some more developmet, and started getting some issues, I used the above struct which is genrated by the above code, and tried to assign some values from a query to the
TemporderDetail_ID  which has to be replaced and the results are not as expected

array-assign.docx
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
What were expected versus actual results:  

       ie Array position[2]  shows  "123456", but I expected it to show "12346, 456789"

Also, your dumps are very confusing :/  Sometimes you say you are working with "array" objects, yet your cfdumps show "structure" objects and you are using structure functions.   Very confusing ...
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
I am trying to replace the values in the Temp..OrderDetails ,part of the struct I am doing this by assigning values from a query.
<cfloop query="OrderDetailsQry2">
      <cfset session.orderTotalsArray[currentrow][2] = "#OrderDetailsQry2.Order_ID#">
                                                    </cfloop>
I am assuming that all the values in the ORDERDETAIL_ID (eg  the second row 176025) are replaced by the values from the query OrderDetailsQry2.Order_ID. the actual  scenario now happening is  in the  attachment  in  the word doc, may be I am not clear with my issue

 
array-assign2.doc
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Yes, the issue is not clear.  If you are trying to replace a specific value like 176025, you need to search the orderTotalsArray for it.  Right now you are using overwriting everything in position[2], regardless of what values it contains.
0
 
LVL 1

Author Comment

by:coventri
Comment Utility
Yes Sir, the Problem was , I did not understand the business logic and started to make fixes, when I went to the nex page I wrote a query which could do this stuff. and I could easily digest the code. Sorry for the trouble.
Thanks for the unltimate help I ever recieved
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now