I am trying to figure out a better and simpler way to have a basic form with checkbox fields for each plan on a "select your plan page" and then when the plans are selected and submit is hit the selected plans are displayed and the user fills in the remainder of the registration page. What would be the most direct way to do this. I have looked up info on using the CB Api but it seems like a lot of complexity to just submit only the plan and would the CB API be appropriate for submitting the CBSubs subscription plans to the registration page. As much information as possible would help thanks so much in advance
Check the plans links, and its info field at top of Edit Plan:
By adding an "s" after each selected plan number you can have the plan selected on the registration form.
This works fine for a plans page that has single plans selectable as a click, make the image/text an <a> link and that will get you straight to the registration page with the plan chosen selected.
Then to hide the others, set them to not "spontaneously show at registration", and you are done.
For multiple plans to choose from with checkboxes, I guess that your own HTML form with a small Javascript or with a small PHP redirection script (depending on your preferred language) could do the same, generating the required URL redirection string with the required parameter e.g. "1s-2s-4s".
CB Conditionals plugin (in incubator area) also be used to have a 2-steps registration, with first step being CBSubs plans and 2nd step being CB fields.
Then just do a CBSubs plans-presentation template override (CBSubs general settings / Templates has explanations for that) or adapt the supplied CBSubs Rounded template to your needs.
Thank you for the quick repies and great information!
I think adding some php or javascript should do the job but does anyone have a sample of what the php or javascript script would look like or what script they used to pass multiple plan selections via the url as described in the first option.
If anyone else has this need to create a custom form with checkboxes of their subscription plans submitting to the registration form I used the following javascript embedded before the form and it seems to do the job. In my case I had 54 subscription plans that caused a huge list in the registration page and this way the plans could be selected with a nicely formatted page submitting only the checked plans and displaying those selected in the standard registration page. Thank you Beat for all the help on directing me to the solution. I hope this is helpful to perhaps a newbie to extend the use of CBSubs. Also if anyone has improvements it would be much appreciated!
<script>
// JavaScript Document// function will loop through all input tags and create
// url string from checked checkboxes
function checkbox_test() {
var counter = 0, // counter for checked checkboxes
i = 0, // loop variable
url = '', // final url string
// get a collection of objects with the specified 'input' TAGNAME
input_obj = document.getElementsByTagName('input');
// loop through all collected objects
for (i = 0; i < input_obj.length; i++) {
// if input object is checkbox and checkbox is checked then ...
if (input_obj.type === 'checkbox' && input_obj.checked === true) {
// ... increase counter and concatenate checkbox value to the url string
counter++;
url = url + '-' + input_obj.value;
}
}
// display url string or message if there is no checked checkboxes
if (counter > 0) {
// remove first "&" from the generated url string
url = url.substr(1);
// display final url string
// alert(url);
// or you can send checkbox values
window.location.href = 'your root//index.php/component/comprofiler/pluginclass?plugin=cbpaidsubscriptions&do=displayplans&plans=' + url;
}
else {
alert('There is no checked checkbox');
}
}
</script>
I was wondering I ran a little javascript which I posted below and it is passing the url with the required parameters as shown below in example but the plans are not selected on the page. I have a parent plan but don't know if that is the cause of the plans not being preselected. Thank you for your help!
Example:
http://my site root/index.php/component/comprofiler/pluginclass?plugin=cbpaidsubscriptions&do=displayplans&plans=25s-8s-9s