The cred_commerce_form_action action is executed only if Go to cart page or Go to checkout page options is selected in the Settings->After visitors submit this form section. If an another option is seleted, for example Go to a page then the hook does not run. The documentation doesn't say anything about it, so it seems it's a bug.
Dear Lapala,
I can not duplicate same problem, are you using the latest version of CRED commerce plugin?
please check the source codes of CRED commerce plugin, file \cred-commerce\classes\Form_Handler.php, line 131~133:
if ($this->form->ID == $form_data['id'] && $this->form->isCommerce) {
// HOOKS API
do_action('cred_commerce_form_action', $action, $this->form->ID, $post_id, $form_data, $is_ajax);
The action "cred_commerce_form_action" is triggered when it is a CRED form with option " Charge payment with this form" enabled.
And you can debug your own codes here manually.
This is what I did before posting on forums. onFormSuccessAction() is called only if either Go to cart page or Go to checkout page option is selected.
CRED 1.8.2, CRED Commerce 1.2. I didn't try to update the plugins yet. I'll update this topic after the plugins update. Maybe the bug is already fixed.
Thanks for the details, I can duplicate same problem, and put it into our todo list, our developers will take care of it.
Here is the feedback from our developers:
in CRED Legacy onFormSuccessAction callback that contains cred_commerce_form_action
is called only when cred_custom_success_action is triggered
and it is triggered only when we have the redirection on cart/checkout
So you have just confirmed what I said in the first post. If it's intentional behavior then it should be mentioned in the API documentation.
The documentation says clearly that:
"Action to be executed after CRED Commerce form has been submitted"
According to the documentation, this hook should be triggered when the form is submitted not when the form is submitted AND when we have the redirection on cart/checkout.
SO either there's a bug in the documentation or there's a bug in the code.
Thanks for the feedback, I forward your comment to our developers.