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 🙂
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
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.
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.
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
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.
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?