Skip Navigation

[Resolved] Cred commerce Api not firing actions

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

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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by masanariS 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1240245

I am trying to:
Change post title after order is complete however, most of the action hooks for cred commerce are not firing even after manual status update of order.

#1240251
#1240434

Hi Masanari,

Thank you for waiting, while I performed some tests on my website.

To test the "cred_commerce_after_order_completed" hook, I attached a simple function that updates the "Tagline" option, at WP Admin -> Settings -> General.
( screenshot: hidden link )

add_action( 'cred_commerce_after_order_completed', 'my_hook_custom_action', 10, 1 );
function my_hook_custom_action( $data ) {

	// update the "Tagline" option in the General settings
	update_option( 'blogdescription ', 'some text');
	
}

Note: the above code was added into the active theme's "functions.php" file.

I created a post form to add a new custom post in "Draft" status and set the form to have the exact same settings, like the one on your website.

A product was also attached to the form so that it automatically gets added to the cart and visitor is redirected to the checkout page, after the form is submitted.

As I submitted the form and completed the checkout, a new post was added in draft status and order was also generated in the "Processing" state.

Once, I completed the order manually from the order edit screen, the "Tagline" option was automatically updated with the "some text", confirming that the hooked function fired successfully.

Also, the status of the connected post also updated to "Published".

To troubleshoot why this isn't working on your website, I'll recommend testing this with all extra plugins disabled ( other than the Toolset and WooCommerce ) and also with a default theme like Twenty Nineteen. This will help in narrowing down to a possible conflicting plugin or custom code.

Please also test the hooked function, by adding it directly in the active theme's "functions.php" file and not through "Dynamik > Custom > Functions". The way some themes or plugins include custom code can also affect the order or priority of hook execution.

I hope these points will help and please let me know if you need any further assistance around this.

regards,
Waqar

#1242851

The issue was a woocommerce plugin. I moved the hook functions to inside toolsets custom functions area in the settings page. It is now working. Thank you!