Skip Navigation

[Resolved] Redirect to created post after purchase is completed CRED

This support ticket is created 7 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
- 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 7 replies, has 2 voices.

Last updated by Minesh 7 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#491045

Have a CRED Commerce form that creates a post. It redirects to checkout.
Is there a way to redirect to the created post after payment is completed?

#491107

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please try to use CRED commerce API hook:

-cred_commerce_after_payment_completed

More info:
=> https://toolset.com/documentation/user-guides/cred-commerce-api/

#491275

I could if I knew php :):)
Can you help me?
Do you have an example somewhere in the documentation?

#491311

Minesh
Supporter

Languages: English (English )

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

Well - I already shared API Doc link:
=> https://toolset.com/documentation/user-guides/cred-commerce-api/

I do not have any other exact example that I can share with you. You may try to follow the CRED commerce Doc as well:
=> https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/

I need to know how you configured things and what exactly you would like to achieve. I can not able to provide solution without checking your site flow.

Can I have step by step information with your issue and to which product/page you want to redirect back?

#491321

I have a CRED commerce form that creates a new post. Post type Bookings.
I've chosen to charge for this form.
The product is specified in Cred commerce settings.
Redirect is set to checkout.
When payment is complete, the user is redirected to the Woocommerce order.
Instead, I would like them to be redirected to the post that was created with the CRED form.

#492033

Minesh
Supporter

Languages: English (English )

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

Could you please try to use following hook:

add_action('cred_commerce_after_order_completed','func_my_custom_order_completed',10,1);
function func_my_custom_order_completed($data) {
$post_id = $data['extra_data']['cred_post_id'];
$url = get_permalink( $post_id );
wp_redirect( $url ) ;
exit;
}

More info:
=> https://toolset.com/documentation/user-guides/cred-commerce-api/
[Section: "cred_commerce_after_order_completed"]
=> https://developer.wordpress.org/reference/functions/get_permalink/
=> https://developer.wordpress.org/reference/functions/wp_redirect/

#493371

Hello Minesh.
Nope that didn't redirect me to the post edited in CRED it took me to the Cart.
hidden link

Thanks to you I was able to make it work with a small change
If anyone else needs the same:

// Redirected to CRED created/edited post after Woocommerce payment
add_action('cred_commerce_after_order_completed','func_my_custom_order_completed',10,1);
function func_my_custom_order_completed($data) {
$post_id = $data['extra_data'][0]['cred_post_id']; //Post ID that was created/edited with the form
$url = get_permalink( $post_id );
wp_redirect( $url );
exit;
}
#493380

Minesh
Supporter

Languages: English (English )

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

Great!! Thanks for sharing the working solution.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.