I am trying to:
Create a cpt using cred commerce while including cpt relationship in the form
Link to a page where the issue can be seen:
I expected to see:
cpt relationship saved as it was showing before
Instead, I got:
I noticed that the relationship is not saved on one of the CPTs, but now it's not saved all over all CPT that have other relationships included in other forms.
Hello,
The problem you mentioned above is abnormal, please try these:
1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again
2) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/
Thanks for the details, I can download the file, please describe detail steps to duplicate the problem:
Create a cpt using cred commerce while including cpt relationship in the form
Where and how can I create the CPT post in front-end? please point out the URL, where I can submit the form?
Which one is the problem post form for creating "Booking" post? is it post form "new Booking" (ID: 12322)?
Hello Luo,
Bothe CPTs: booking and pack are one to many relationships with WooCommerce products post type.
I already submitted the links to the pages where the forms are located. For the booking form, you’ll find it in the booking accordion that displays the form.
Thanks for the details, I am checking your database dump file in my localhost, will update here if there is anything found
Here are what I found:
1) I have tried the URL you mentioned above, for example:
hidden link
There isn't Toolset form, see screenshot: 11531965231.JPG
Then I have tried these:
2) Create a new wordpress page, display the post form "new Booking" directly:
[cred_form form="new-booking"]
in section "Template Layout", Selected template Layout: "Page", see screenshot new-booking.JPG
Then test the page in front-end, submit the form and complete the order, I can see the problem you mentioned above:
the relationship is not saved on one of the CPTs
After some debug, it seems the problem is in the layout "Page", I have edited above page, in section "Template Layout", and click "Stop using this Template Layout", then test the post form again, it works fine, the relationship is saved.
3) And I have checked the layout "page", there are lots of some wrong HTML codes in it, see screenshot page-layout.JPG
Please you test below steps in your website
1) Deactivate the Toolset Layouts plugin, test the post form directly
2) If the problem is fixed, please edit those problem layout, fix the codes in it, you might need to rebuild the layout "page" from scratch.
Hello Luo,
Thank you for your reply.
I checked the new booking form where It's located in a single product page as I recently included another form to approve the post on the same page. When I removed the recent form from the page, It seems that it works back again and saves the relationship. I'll try to find another way around with the packs forms as I have 3 cred forms on it's page that are displayed in a loop view.
If you have a solution for inserting more than a cred form on the same page, I'll appreciate it so much.
I assume the original question of this thread has been resolved, for the new question, please check the new thread here:
https://toolset.com/forums/topic/inserting-more-than-a-cred-form-on-the-same-page/
Hello Luo,
Thank you for creating the new ticket.
still the premium pack form not picking the relationship although I moved the form to a separate page and created a child post link in the products view loop. the parameter of the parent_product_id is appearing in the url and the relationship select field displays the correct product, but it's still not saved. the post parent id is displaying the page id that contains the cred form and not the product id that is coming from the child post link
Here is the code for the cred form:
[credform class='cred-form cred-keep-original']
[cred_field field='form_messages' value='' class='alert alert-warning']
<!-------------------------------------------------------------------------->
<div class="hiddenn">
[cred_field field='post_title' value='U[wpv-user field="ID"]P[wpv-post-id id="$parent_product_id"]T[wpv-post-date format="ymdgi"]' urlparam='' class='form-control' output='bootstrap']
[cred_field field='pack-product' value='[wpv-post-id id="$parent_product_id"]' readonly='true' class='form-control' output='bootstrap']
[cred_field field='pack-credit' value='[wpv-post-id id="$parent_product_id"]' urlparam='' readonly='true' class='form-control' output='bootstrap']
[cred_field field='@product-pack.parent' select_text='--- not set ---' value='' class='form-control' output='bootstrap']
</div>
<!-------------------------------------------------------------------------->
<div class="fa-3x text-primary" style="font-family: FontAwesome!important;">
[cred_field field='form_submit' value='' urlparam='my_id' class='btn btn-primary btn-lg' output='bootstrap']
</div>
[/credform]
Thanks for the details, I can see the problem you mentioned above, it seems to be a bug, I will escalate it, currently you can try the action hook "cred_save_data" to save the relationship, for example add below codes into your theme file functions.php:
add_action('cred_save_data','my_custom_func1',15,2);
function my_custom_func1($post_id,$form_data) {
// Toolset form ID
if ($form_data['id']==12215) {
// setup the post relationship
toolset_connect_posts('product-pack',$_POST['@product-pack_parent'], $post_id);
}
}
More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts