Skip Navigation

[Closed] Pass value from View to embedded CRED form – use value as post parameter

This support ticket is created 8 years, 2 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 8 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#364521
screenshot-2016-02-04 00-24-13.png

I have created a CRED form, which I have embedded in a View.

The View can show one or more instances of a particular post type.

I would like to take the ID of each instance of the post type being shown by the view and pass that into the CRED form in order to use the value as a post parameter in the form.

Is there any way I can do that in Views/CRED without any javascript tricks?

I have attached a graphic showing what I mean 🙂

#364558

Dear Jakob,

You use Views shortcode [wpv-post-id] to get the current post ID
https://toolset.com/documentation/views-shortcodes/#wpv-post-id

And you can use it as the default value of fields in CRED form, for example:
[cred_generic_field field="my-field" type="textfield" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-post-id]"
}
[/cred_generic_field]
More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred-generic-field

#364628

Thanks, Luoy, but when I do that, I get the ID of the post to be created by the CRED form and instead I need the ID of the post shown by the View, where the CRED form is embedded.

And I need to put that ID into the form as a post parameterm so I can catch that ID on the page, which the CRED form points to, which is WooCommerce Checkout.

#364850

I have found out, that the ID I need is already per default passed as a post parameter in the CRED form in the form of _cred_cred_prefix_cred_container_id

Example: _cred_cred_prefix_cred_container_id:1884

Now, my next learning experience is, that for some reason, post variables are purged on the WooCommerce Checkout page, so now I need to figure out how to catch it, before it's purged, because I need the ID in a View inserted at the top of the Checkout page.

#364896

If the variables are stored in PHP variable $_POST, you will need create a custom shortcode to catch it.
More help:
add_shortcode
http://codex.wordpress.org/Function_Reference/add_shortcode
$_POST
hidden link

#364972
cred-commerce-pass-value.png

That I know, but I need to find a way to pass the value as post parameter to the checkout page.

The situation here is that the embedded CRED form is connected to WooCommerce via CRED Commerce. In the setting for this CRED form, I've chosen to go directly to checkout.

As far as I understand now, the value that I want - _cred_cred_prefix_cred_container_id -, is put into an urlencoded GET variable, like what I show on the attached screenshot, taken from Firebug.

How do I get _cred_cred_prefix_cred_container_id out of that and into WooCommerce Checkout as a post parameter?

And why does it say "302 Moved Temporarily"? I guess that has some connection with how CRED Commerce interacts with WooCommerce?

I hope you can help me out.

#365330

Since it is a custom PHP codes problem, could you duplicate same problem in a test site, and fill below private detail box with login details and ftp access, also point out the problem page URL, and where I can edit your PHP codes, and where the parameter _cred_cred_prefix_cred_container_id should be display?

The topic ‘[Closed] Pass value from View to embedded CRED form – use value as post parameter’ is closed to new replies.