Skip Navigation

[Resolved] Conditional redirect on submit with cred commerce form

This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 7 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#575923

I have a cred commerce form setup with a single radio field named "application-fee-waiver". I'd like to use some logic to determine where the form redirects based on the value of the "application-fee-waiver" field. For instance:

if "application-fee-waiver" has value 1, save and display the post
if "application-fee-waiver" has value 2, save and continue to checkout page

I've started with the submit filter like below but don't know how get the url to display the post or continue to the checkout if the value is "2":

=====================================
add_filter('cred_success_redirect', 'step7_waived_redirect_func',10,3);
function step7_waived_redirect_func($url, $post_id, $form_data)
{
if ($form_data['id']==25377){
$url = '?????';
if(isset($_REQUEST['application-fee-waiver']) && $_REQUEST['application-fee-waiver'] == 1){
$url = '?????';
}
}
return $url;
}
=====================================

any ideas?

Thanks in advance

#575941

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Could you please tell me how you setup your filed "application-fee-waiver" as well as the problem URL where I can see the problem.

#575947
Screen Shot 2017-10-04 at 1.42.01 AM.png

The filed "application-fee-waiver" is a Toolset custom field, radio type (see attachment).

The page is a protected so I can't share a link, but here's the markup validation script:

=====================================
<div class="card">
<div class="card-header bg-gce-primary inverse">
Application Fee
</div>
<div class="card-block">
<div class="cred-group cred-group-appfee-waivercode row">
<div class="col-xs-12 col-lg-6 form-group cred-field-appfee-waivercode">
<label for="waivercode">Waiver Code:</label>
<input type="text" name="waivercode" id="waivercode" class="form-control wpt-form-textfield form-textfield textfield" value="" />
</div>
<div id="valid" class="col-xs-12 col-lg-6 valid" style="display:none;margin-bottom:1rem;">
<div class="alert alert-success">
<span class=""><i class="fa fa-check-circle fa-2" aria-hidden="true"></span>
<p>Great! Your waiver code is valid. <br />Click "Continue" to review your application.</p>
</div>
</div>
<div id="notvalid" class="col-xs-12 col-lg-6 notvalid" style="display:none;margin-bottom:1rem;">
<div class="alert alert-warning">
<p class="">Sorry, that's not a valid code. <br />Please continue to the checkout page.</p>
</div>
</div>
</div>

<div class="row" style="display:none;">

[cred_field field='application-fee-waiver' post='applications' value='' urlparam='' output='bootstrap']

</div>
<div class="card-footer">
<div class="row">
<div id="container2" style="display:none;">Return to Application</div>  
[cred_field field='form_submit' class="pull-right" value='Continue' urlparam='']
</div>
</div>
</div>

<script>
jQuery(function( $ ) {

var validcode = "appfeeWaiver-0";
$("#waivercode").keyup(function () {
var code = $(this).val();
if (code === validcode) {
$("#valid").show();
$("#notvalid").hide();
$("input[name=wpcf-application-fee-waiver][value='1']").prop("checked", true);
$(".ico-valid").show();
$(".wpt-form-textfield").addClass('ico-alert');
} else {
$("#valid").hide();
$("#notvalid").show();
$("input[name=wpcf-application-fee-waiver][value='2']").prop("checked", true);
$(".ico-valid").hide();
}
});
});
</script>

#575958

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks for the information - Please note that for the redirection hooks to work, the form must be set to redirect to a "specific page" or a "post" after the submission. If for example, the form options are set to “Keep displaying this form” or “Display a message instead of the form” after submission, the redirection hook will not work.

Also, I would like to have problem URL as I need to check what URL param its passing. Is it possible for you to send me access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.