I have the following code which has been working for a year:
add_action('cred_commerce_after_payment_completed','my_advert_update',10,1);
function my_advert_update($data)
{
// Extract relevant elements from data
$form_id = $data['extra_data'][0]['cred_form_id'];
$post_id = $data['extra_data'][0]['cred_post_id'];
// if form is the Advert Activation Form, set status to 'live' after payment and change end date
if ($form_id==928)
{
$ad_listing_status="Live";
$ad_status_field="wpcf-my-ad-status";
update_post_meta($post_id, $ad_status_field, $ad_listing_status);
$my_end_date = time() + (365 * 24 * 60 * 60);
$ad_end_field = "wpcf-my-ad-end-date";
update_post_meta($post_id, $ad_end_field, $my_end_date);
}
}
However, it stopped working a week or so ago (has only just been reported to me). Is this something to do with recent updates?
This is the document for the function, for reference:
https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_payment_completed
The thing is, that function does not exist, as you will see if you run a search for it in the CRED or Toolset Forms Commerce Plugins or any other Toolset Plugin.
This is true since and inclusive CRED Commerce 1.7, where supposedly something related to this exact function was fixed:
1.7
April 23, 2018
Fixed a compatibility issue with WooCommerce 3.2
Fixed an issue about notificationn on Order Payment status Change.
https://toolset.com/download/toolset-cred-commerce/#changelog
I found, that it was refactored, yes, and ported, yes, but the developers made a typo.
The filter now is cred_commerce_after_payment_complete, not anymore as previously cred_commerce_after_payment_completed
For now, this small edit should fix the issue, but of course, I will report this as a BUG and we will fix it.
Thanks a lot for the heads up!
Thanks Beda.
!!! So much for quality control... Do you think a review of dev controls might be in order?
Please leave this ticket open. When this bug is dealt with, I need to know if they put the d back on!
Thanks,
N