Order Anywhere post products and go to cart

General ShopSite user discussion

Order Anywhere post products and go to cart

Postby JCGrafted » Wed Oct 29, 2014 1:00 pm

I use the Order Anywhere feature to make my own store pages. I am making a secondary store that uses the same shopping cart. I do not want to change setting on our main store.

I use javascript to submit items to my cart. I load the following empty form and post the items:

Code: Select all
<form name="mySubmitForm" id="mySubmitForm" action="https://our-store.org/cgi-bin/sc/order.cgi" method="post">
  <input type="hidden" name="storeid" value="*zzzzz00000zzzzzz">
  <input type="hidden" name="dbname" value="products" />
  <input type="hidden" name="function" value="add" />
</form><!--     End of mySubmitForm Form      -->

It will not go to the cart at the same time, so I have a second form with a second button to go to cart:
Code: Select all
<form name="goToStore" id="goToStore" action="https://our-store.org/cgi-bin/sc/order.cgi" name="formAddToCart" method="post">
  <input type="hidden" name="storeid" value="*zzzzz00000zzzzzz">
    <table width="100%">
      <tr>
          <td align="right">   <input type="submit" value="View Shopping Cart" /></td>
      </tr>
    </table>
</form><!--     End of goToStore Form      -->

This is sloppy. I want one button to do both. Help!!!
JCGrafted
 
Posts: 29
Joined: Wed Sep 21, 2011 2:41 pm
Location: Houston, TX

Re: Order Anywhere post products and go to cart

Postby Jim » Wed Oct 29, 2014 2:02 pm

I'm not sure what you are exactly trying to do. Can't you just add the
Code: Select all
<input type="submit" value="View Shopping Cart" /></td>
to the first form?
I'm assuming that you also include the product record number, sku etc in the data that you summit?
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Order Anywhere post products and go to cart

Postby JCGrafted » Wed Oct 29, 2014 2:26 pm

That doesn't work.

I have a button higher on the page that says:
Code: Select all
onclick="runMyJavascript();"

The Javascript does all the calculations and checks it needs to do and then fills in an empty hidden form "mySubmitForm" with all of the products and then submits it. Adding the input type="submit" to this form only give a button (one that does not work as the form has not been filled in yet) and does not help to take the user to the shopping cart after submitting the filled in items.

The "mySubmitForm" works fine for submitting the items.
JCGrafted
 
Posts: 29
Joined: Wed Sep 21, 2011 2:41 pm
Location: Houston, TX

Re: Order Anywhere post products and go to cart

Postby Jim » Wed Oct 29, 2014 3:05 pm

So the items are getting added to the cart by your javascript and you just want the shopper to see the cart after they are added?

The default action of an add to cart is to display the shopping cart to the shopper. So they should be left on the shopping cart when they submit the form.

This behavior can be changed by settings on the Commerce Setup > Order System > Shopping cart screen

Default for the "Show me my shopping cart" checkbox
Do not display the "Show me my shopping cart" check box

This can also be affected if the shopping cart template does not contain the tag which includes the checkbox (and associated text) on the shopping cart so the box can't be checked.

So check those settings and see if that might be the issue.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Order Anywhere post products and go to cart

Postby JCGrafted » Wed Oct 29, 2014 3:31 pm

That would change the behavior for my primary store as well. We have a mini cart on the right hand side of our store pages on our primary store. I do not want to mess that up.

I found a kludge. Sloppy, but it works.

- OnSubmit sets a cookie
- the 1st form loads and submits
- the page re-loads
- an onload event looks for the cookie
- if found:
- - delete the cookie
- - submit the 2nd form that takes you to the shopping cart

What I do not like about this solution is that the page blinks as it reloads and then goes to the cart.
JCGrafted
 
Posts: 29
Joined: Wed Sep 21, 2011 2:41 pm
Location: Houston, TX

Re: Order Anywhere post products and go to cart

Postby Jim » Wed Oct 29, 2014 3:41 pm

Glad you got something to work even if it isn't the best.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 86 guests