using ubercart for cart only: problems with authenticated users

Posts: 23
Joined: 01/16/2008

Hi,

I'm using ubercart as a cart only connected with a flash site.

I found out that the following lines are fine to go directly to cart (the following code refers to product contained in node 18):

<html>
<body>

<form action="/my_site/node/18"  accept-charset="UTF-8" method="post" id="uc-product-add-to-cart-form-18">

<label for="edit-attributes-2">Size: </label>
<select name="attributes[2]" class="form-select" id="edit-attributes-2" >
<option value="5">46</option>
<option value="6">48</option>
<option value="7">50</option>
<option value="8">52</option>
<option value="9">54</option>
<option value="10">56</option>
</select>



<label for="edit-attributes-3">Length: </label>
<select name="attributes[3]" class="form-select" id="edit-attributes-3" >
<option value="12">Long</option>
<option value="11">Regular</option>
<option value="13">Short</option>
</select>

<input type="hidden" name="qty" id="edit-qty" value="1"  />
<input type="submit" name="op" id="edit-submit" value="Add to cart"  class="form-submit" />
<input type="hidden" name="form_id" id="edit-uc-product-add-to-cart-form-18" value="uc_product_add_to_cart_form_18"  />

</form>
</body>
</html>

However this is fine for non authenticated users only.
As soon as one user log into my drupal site with username and passwd, I'd need the following string as well in order to add a product to the cart:

<input type="hidden" name="form_token" id="edit-uc-product-add-to-cart-form-18-form-token" value="c2548dcac25acd9c340027ea3bbf0939"  />

P.S: the value "c2548dcac25acd9c340027ea3bbf0939" changes for every product and every user.

I thought of instructing the flash/asp site to inquire the ubercart product page just before adding it to the cart to get that variable value.

Has anyone found an easier workaround?

cheers

Posts: 924
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

I'm sure this won't be your only problem! But if you get it working I'd be very interested to hear all the steps you took.

For the token, it is generated by drupal_get_token() using just the form_id and session_id. Because you have access to both of those values on the server side you can use drupal_get_token() to generate the proper token before you send your page to the user.

--

<tr>.

Posts: 5245
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

You might look into this session presented at Drupalcon... these guys may have the expertise you need for this sort of question:

http://boston2008.drupalcon.org/session/druplash-and-druplex-content-man...

Posts: 23
Joined: 01/16/2008

Ryan wrote:
You might look into this session presented at Drupalcon... these guys may have the expertise you need for this sort of question:

http://boston2008.drupalcon.org/session/druplash-and-druplex-content-managed-flash-and-flex-sites-powered-drupal

Many thanks for your tip!
After watching http://www.stevenmerrilltenor.com
I just landed on this site which is quite illuminating (drupal+flash+swfaddress)
http://modern-carpentry.com/talk/?p=32