Saltar navegación

[Resuelto] Reload same page after Cred WC submission

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Reload same page after Cred WC submission

Solution:
You can use the Toolset Form's Commerce hook "cred_commerce_form_action"

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/reload-same-page-after-cred-wc-submission/#post-1220405

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_form_action

This support ticket is created hace 5 años, 10 meses. 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
- 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)

Etiquetado: 

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Pat hace 5 años, 9 meses.

Asistido por: Minesh.

Autor
Mensajes
#1219827

Pat

Hello,

I have a site with Toolset and WC and have created a WC Cred.
Now, I would like this Cred to reload the same page after submission.
I have not found this kind of possibility in the list of the potential actions after submission.

Is there a way to make it work like this?
Regards
Pat

#1220139

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - what if you try to use the Toolset Form's Commerce hook cred_commerce_form_action

For example:

add_action( 'cred_commerce_form_action', 'my_hook', 10, 4 );
function my_hook( $action, $form_id, $post_id, $form_data ) {
    if ( $post_id == 123 ) {
        wp_redirect( '<em><u>enlace oculto</u></em>' );
        exit();
    }
}

Is this is the hook you were looking for?

More info:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_form_action

#1220199

Pat

Hi Minesh,

Thanks for the answer.

Does that means that if I need to have the same behavior on all WC Creds, I can use it without the if function?

Second remark, I need to reload the same page where the current Cred is displayed (Creds could be displayed on different pages depending on where we are on the site).
How can I manage this inside this function? (I cannot use a fixed url in the wp_redirect( 'enlace oculto' ); ).

Regards
Pat

#1220395

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Does that means that if I need to have the same behavior on all WC Creds, I can use it without the if function?
=> Yes, that is correct then it will be applicable to all the WC CREDs.

Second remark, I need to reload the same page where the current Cred is displayed (Creds could be displayed on different pages depending on where we are on the site).
How can I manage this inside this function? (I cannot use a fixed url in the wp_redirect( 'enlace oculto' ); ).
=> That part you need to manage on your own by adding your custom logic within that hook. The redirect sample given is just for example.

Please do not forget to read everything related to that hook with the following link:
=> https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_form_action

#1220405

Pat

Hi Minesh,

I'm OK with this. Here is the code I have used :

add_action( 'cred_commerce_form_action', 'my_hook', 10, 4 );
function my_hook( $action, $form_id, $post_id, $form_data ) {
$referer = $_SERVER['HTTP_REFERER'];
        wp_redirect( $referer );
        exit();
 
} 

The only issue I have with that is the url I'm getting has all info like : enlace oculto

I would like to get only the page without te info linked to success message.

Regards
Pat

#1220606

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok - please feel free to close the ticket as I have split the ticket with your new question. This will help other users searching on the forum.

#1221621

Pat

The issue is transferred to another ticket