Skip Navigation

[Resolved] NEED HELP TO FIGURE OUT CHECKOUT REDIRECT

This support ticket is created 4 years, 5 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by manishB-2 4 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1638067

Hi
I am creating a Post Edit/Renewal Form with Cred Commerce option. So It means, there will be a payment option involved when this edit form is submitted. And my exact requirement is something like below.

My edit form is designed in a way like, I have a taxonomy single select field which is auto-selected based on the post's exiting data. and I don't let user change the taxonomy categories in this edit form, and just ask users to renew the post by paying the appropriate amount. Now the renewal fee is applied based on the existing selected category. So to define the appropriate price for the renewal, I have assigned a custom field which is considered as a select field that has values with WooCommerce Product IDs, and I have created these product id's Option values with jquery. and previously this function was working perfectly but now for this edit form its not working. And it only works if I change the category field option.

But I want that my cost field "property-ad-cost" field should auto select the value based on the pre-selected category value when the edit form is loaded.

------------------------
Category Field:- property-ad-type[]
Cost assigning field:- wpcf-property-ad-cost
------------------------
Please see the code.

jQuery(document).ready(function($) {

$("[name='property-ad-type[]']").change(function() {
var val = $(this).val();
if (val == "106") {
$("[name='wpcf-property-ad-cost']").html("<option value='1105'>Featured Property Ad</option>");
} else if (val == "107") {
$("[name='wpcf-property-ad-cost']").html("<option value='1007'>Property Photo Ad (Free)</option>");

} else if (val == "105") {
$("[name='wpcf-property-ad-cost']").html("<option value='1519'>Slideshow Walk through Ad</option>");

} else if (val == "104") {
$("[name='wpcf-property-ad-cost']").html("<option value='1520'>Video Walkthrough Ad</option>");

} else if (val == "108") {
$("[name='wpcf-property-ad-cost']").html("<option value='2529'>Text Only Ad (Free)</option>");

}
});
});

Please help me to fix this code to work when the form is loaded successfully, So this "property-ad-cost" should automatically assign the value based on the current taxonomy field value.

Please watch the below video demonstration.
hidden link

So As you can see in the video, when page loads, it has a category already selected in taxonomy field, But property ad cost field was blank, but as per my requirements, the above jquery should auto-fill the selected category id based product id in the property ad cost field.

I know that this jquery is for the onChange event. But can you please make a quick tweak in this code so that It can work on page load event.

#1638693

Hi, have you tried triggering a change event manually at the end of the document ready callback?

$("[name='property-ad-type[]']").trigger('change');

There is no JavaScript API for Forms, so there is no reliable event you can hook into to know when the Form is completely initialized. At your own risk, you can try adding a small timeout to trigger the change event after a bit of time has passed, but it's not guaranteed to work consistently.

#1652849

My issue is resolved now. Thank you!