ctyler Posted June 11, 2014 Share Posted June 11, 2014 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 11, 2014 Share Posted June 11, 2014 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 http://demo.whmcs.com/cart.php?a=add&pid=1&billingcycle=annually 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! 0 Quote Link to comment Share on other sites More sharing options...
ctyler Posted June 11, 2014 Author Share Posted June 11, 2014 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 11, 2014 Share Posted June 11, 2014 in fairness, I think they do get passed, but because it's not done in the URL as whmcs expects, it doesn't see them... I suspect you could modify the template to look for them, but it's probably just easier to tweak the form script! 0 Quote Link to comment Share on other sites More sharing options...
ctyler Posted June 16, 2014 Author Share Posted June 16, 2014 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. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Ryan Posted June 16, 2014 Share Posted June 16, 2014 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 0 Quote Link to comment Share on other sites More sharing options...
ctyler Posted June 16, 2014 Author Share Posted June 16, 2014 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? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.