Jump to content

Sending form data from same domain website to cart


ctyler

Recommended Posts

Hello,

I am having an issue sending form data to the shopping cart. The website and the WHMCS share the same domain. This should be a pretty simple proposition but I am having difficult getting it to work. Here is the code:

 

<form method="POST" action="http://www.greatfxmedia.dev/clients/cart.php?a=add&pid=109>"
<ul class="pricing-table">
<li class="selector">
<select name="billingcycle">
<option value="quarterly">3 Month Price - $12.99/mo</option>
<option value="semiannually">6 Month Price - $9.99/mo</option>
<option selected="selected" value="annually">12 Month Price - $6.99/mo</option>
</select>
</li>
<li class="cta-button"><input class="button" type="submit" value="Sign up"></li>
</ul>
</form>

 

The URL to the form and WHMCS is correct. It is at http://www.greatfxmedia.dev/clients/. I end up on the form without a problem. I go through the Domain registration but when it comes to the confproduct page the billing cycle is incorrect. I think I may be missing something that I am not sending over with the form, maybe a hidden field with information?

Here is the direct link as specified in the admin section products/services->Links:

Direct Shopping Cart Link: http://www.greatfxmedia.dev/clients/cart.php?a=add&pid=109

I am using the Boxes order form template and the default WHMCS template.

The product ID is correct, I am missing something and I am thinking it is something simple. Sorry I cannot send you a link to the site, it is a local install with a DEV license. Any help would be appreciated.

 

Surely I don't need to use the API for something as simple as this?

Link to comment
Share on other sites

the problem will be that you aren't passing the billingcycle value in the form url, so when the user gets to WHMCS, it will ask them again for their billingcycle choice.

 

http://docs.whmcs.com/Linking_to_WHMCS

 

 

if this is the whole form, then you could change the dropdown to hyperlinks and just link them to the correct product and cycle in the cart; or you could use add some javascript to the form to manipulate the dropdown to send the correct url... there are probably many more ways to do this!

Link to comment
Share on other sites

Hi Brian!

Oh man. I don't know what I was thinking. I guess form variables just pass themselves from page to page in my world of magical web dev. Thanks for the reply.

 

I will probably set up a php script to process the form and redirect to the cart with the form variables. That should work aye?

Link to comment
Share on other sites

I ended up just building the url with the form Variables and using the header() redirect to the form like so:

 

$cart_url = $site_url . "/clients/cart.php?a=add&pid=" . $product . "&billingcycle=" . $cycle;

header('Location: ' . $cart_url );

 

Simple!

 

Just thought I would post in case someone was looking for the same thing.

Link to comment
Share on other sites

Hello ctyler,

 

Thank you for providing this solution!

 

As always, we appreciate user provided solutions but please know that this solution is not approved or tested by WHMCS. Please be sure to test this solution before implementing it on a production installation of WHMCS.

 

--Thanks

Link to comment
Share on other sites

Hi Ryan,

It is straight forward. I used the documentation as the inspiration for doing it that way.

 

There are many further options you can use, such as your own configurable options. The simplest way of formulating a url is to step through the order process as normal to the product configuration step, then right click > view source and get the field names and value IDS. These can then be used in your direct link URLs.

 

Do use see a potential issue with doing it this way?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated