Iterate through SC_Cart?

General ShopSite user discussion

Iterate through SC_Cart?

Postby OldSalt » Tue Aug 10, 2010 9:47 am

Hello,

I am trying to iterate through the array of values generated through [-- SC_Cart --] on the thankyou page.

Any idea how I can do this?

Ideally, I'd like to test for a string pattern in the products' SKU and write a form input below the product name if there is a match.

Thanks!
OldSalt
 
Posts: 23
Joined: Mon Sep 28, 2009 4:37 pm
Location: MA

Re: Iterate through SC_Cart?

Postby ShopSite Lauren » Tue Aug 10, 2010 10:04 am

I would suggest using the JavaScript variables for the cart. You can pull the SKUs from the order, and if there is a match, you can display a form. More information about the JavaScript Variables can be found at the following URL:
http://www.shopsite.com/help/current/en-US/sc/pro/cart.variables.html

Also, there is a previous forum post which addresses this question.
http://support.shopsite.com/forums/viewtopic.php?f=1&t=7862
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Iterate through SC_Cart?

Postby OldSalt » Tue Aug 10, 2010 10:15 am

Thanks, Lauren.

Yes, I know I can access the javascript variables, but I'd like to position the form inputs below each qualifying product. That is why I'd like to iterate though the products in [-- SC_Cart --] ... is this possible?
OldSalt
 
Posts: 23
Joined: Mon Sep 28, 2009 4:37 pm
Location: MA

Re: Iterate through SC_Cart?

Postby ShopSite Lauren » Tue Aug 10, 2010 10:26 am

I don't believe so. You do not have access to edit that tag directly, other than making changes to the order that the columns appear in...
[-- SC_Cart name sku quantity delete price total --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Iterate through SC_Cart?

Postby mjbrunelle » Tue Aug 10, 2010 7:33 pm

Yes you can,

Place the [-- SC_Cart --] inside a div statement with an ID, ie <div id="scCart">. This acts as the anchor for the Javascript

document.getElementById("scCart").getElementsByTagName("td");

This will give you a list of the table cells, then you sort through with a loop checking the className to locate the Table Cells that are the SKU's. Read the innerHTML test for your information, you then know the node offset to the Description for that record, so you can update the innerHTML by adding a <br /> to the end of the exiting text, and then your <input> statement.

I have done this before, except I added additional information on the product from the Javascript Variables.

My question is, you are in the Thankyou Page, what input do you need, and how do you plan on using the information.

MarkB
mjbrunelle
 
Posts: 147
Joined: Sun Jun 21, 2009 5:09 am


Return to User Forum

Who is online

Users browsing this forum: No registered users and 114 guests