Skip Navigation

[Resolved] CRED Notification is sent when back-end “Purchase status changes to: Processing”

This thread is resolved. Here is a description of the problem and solution.

Problem: I have set up an email notification on a CRED Commerce form that should be sent at certain Order status changes. The email notification does not seem to respect the Order status settings, the email is sent regardless of the Order status.

Solution: This issue has been resolved in the latest version of CRED Commerce.

This support ticket is created 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 20 replies, has 3 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#602927

I have a CRED form using CRED Commerce that works fine and generates a notification on condition "When the purchase status changes to: Processing". However, sometimes we change purchase status to processing at the back-end rather than through user form submission, and this notification is still sent, but of course all of the notification fields are blank because there is no current CPT. Is it possible to prevent the notification being generated when a back-end order status change is made?

#603055

Hi, if the order status is changed to "Processing" on the backend, your notification should still be able to access fields of the CPT using shortcodes. For example you can place this in the body of the notification:

Post title: %%POST_TITLE%%
Post custom field: [wpv-post-field name='wpcf-customfieldslug' id='%%POST_ID%%']
Product name: %%PRODUCT_NAME%%

You will see the CPT's post title, custom post field value, and the name of the product linked to the CRED form in your notification. Is there a specific field that isn't working for you, or am I misunderstanding how you manage the posts created by this CRED Commerce form?

#603512

Okay, so the process is as follows:
Customer fills in a CRED Commerce form and submits it, then is taken to checkout to buy the related product. They select 'pay by bank transfer', which means the order goes to 'On hold' status. The CRED form sends a notification. Later (perhaps days later), the financial controller checks bank statements and determines payment has been received, so changes the order to 'Completed'. Another notification is sent out, and I believe it's this one that goes out blank.

#603543

The CRED notification should contain information from the original post in the scenario you described. The only way I can think this notification would show blank fields is if the original post was deleted manually from the backend of your site. Otherwise, a notification triggered by changing the post status from "On Hold" to "Complete" should be able to access those fields just as I described before. Can you try these troubleshooting steps?
- Temporarily deactivate all plugins except WooCommerce, Types, Views, CRED, and CRED Commerce. Activate a default theme like Twenty Seventeen. If you need to activate a plugin like Maintenance Mode during these tests that's fine.
- Test again. If the notification is sent as expected now when you complete a bank transfer order, you may have a conflict in one of your plugins or your theme. Reactivate your parent theme, then child theme, then other plugins, testing one by one until the conflict is revealed.
- If the notification was not sent as expected, then I'll have to take a closer look.

Please let me know the results and we can go from there.

#605508

Hi Christian,
I'm not clear how changing the status of a WooCommerce order in the back-end results in access to the fields in a CPT created by the CRED form originally? Is the link between WooCommerce order and CPT item stored somewhere in the database then?
N

#605520

Is the link between WooCommerce order and CPT item stored somewhere in the database then?
Yes, that's correct. CRED Commerce tracks these relationships this with a hidden custom field applied to the post it creates or edits. That field references the WooCommerce Order so when the Order status changes CRED Commerce can hook into that event.l

#605751

I think I may be getting a little closer, and I think this effect may be caused by my implementation as follows. Let's call the CPT 'Advert'.
1. The Advert is created using a form in which the customer can fill in all the fields. This is NOT the CRED Commerce form.
2. The user can see/edit the advert when they are logged in using another form - also NOT the CRED Commerce form, but the advert isn't published to general use until they've paid.
3. The CRED commerce form that publishes the advert has almost no data fields in it - just one hidden custom field that identifies the product to be used, and a 'Submit' button.
4. A change is made to a custom field AFTER the form is successfully submitted, using the cred_commerce_after_payment_completed hook - 'Status' is changed to 'Live' - and it's this that defines which adverts are publicly visible...
So...If the CRED Commerce 'link' stores only the data from the submitted form, there'll be nothing stored, so nothing populated when the administrator changes order status. However, when submitted by the customer, the correct post is still in memory and available to populate the email. Does that make sense...?

#606070

4. A change is made to a custom field AFTER the form is successfully submitted, using the cred_commerce_after_payment_completed hook - 'Status' is changed to 'Live'
A change is made to which post - the Advert, or the post created/edited by CRED? What post is created or edited by the CRED form you described in step 3? How is that post related to the Advert - is there a custom field, or is it a parent/child relationship, etc?

#606178

Step 3 uses an 'edit CPT Advert' CRED form with no fields except the product identifier. Step 4 edits one custom field ("Advert status") in the current CPT Advert record (i.e. the one for which the form has just been submitted) using the hook mentioned.

#606541

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neil,

Christian is currently on holidays but will be back tomorrow to assist further with this.

Thanks,
Shane

#606843

So...If the CRED Commerce 'link' stores only the data from the submitted form, there'll be nothing stored, so nothing populated when the administrator changes order status.
The Order created when the customer uses the CRED Commerce form to publish an Advert contains a custom field that links to the related Advert by ID. This ID is then used to populate information about the related Advert when the "Order Completed" notification is sent out. The hidden field that associates the Order and the Advert is not affected by the CRED form, it's handled on the backend automatically. So the fact that the CRED Commerce form only includes the product field is irrelevant here. All the notification needs is the Order -> Advert ID link hidden field, and that's automatically included. So something else is going on here if a notification does not include the correct Advert information.

Is it possible for me to take a look in your wp-admin panel to see how things are set up? If I need to run tests, I will install the Duplicator Pro plugin to create a clone of your site so I can run tests locally without affecting your live site. If that's okay with you, please provide login credentials in the private reply fields here.

#606923

Okay that's fine for now, I can run some tests on the staging site. If I need more information, I'll send you an update here in the forum to discuss our options. I will activate the private reply fields here for login information to staging wp-admin.

Please let me know what I can do to test out the notifications. Be aware that notifications may be sent, so if I need to change any addresses or disable any notifications during testing, I need specific instructions on those. Thanks!

#607649

I have discovered that if you 'Edit' the order and change the status from within the order screen (rather than using the buttons on the summary screen), then the data is included in the email. However, it still seems to be sending the email when status is changed to Completed.

#607697

Okay thanks, I think we can fix this by specifying the context using 'id="%%POST_ID%%"' in each field shortcode. Here's the updated subject:

New [types field='timeshare-ad-type' output='raw' id="%%POST_ID%%"][/types] Advert [wpv-post-id id="%%POST_ID%%"] by Member [wpv-post-author format="meta" meta="ID" id="%%POST_ID%%"], [wpv-post-author id="%%POST_ID%%"]

Here's the updated body:

Member advertising: [wpv-post-author format="meta" meta="ID" id="%%POST_ID%%"]; [wpv-post-author format="meta" meta="first_name" id="%%POST_ID%%"] [wpv-post-author format="meta" meta="last_name" id="%%POST_ID%%"]; [wpv-post-author format="meta" meta="user_email" id="%%POST_ID%%"]

Advert type: [types field='timeshare-ad-type' output='raw' id="%%POST_ID%%"][/types]

Advert [wpv-post-id id="%%POST_ID%%"]: [wpv-post-title id="%%POST_ID%%"]

Year: [types field='timeshare-ad-year' output='raw' id="%%POST_ID%%"][/types]

Club: [types field='timeshare-club' output='raw' id="%%POST_ID%%"][/types] / [types field='timeshare-type' output='raw' id="%%POST_ID%%"][/types]

Apartment [types field='tshr-apartment-no' output='raw' id="%%POST_ID%%"][/types]: [types field='timeshare-ap-type' output='raw' id="%%POST_ID%%"][/types]

Weeks: [types field='tshr-fixed-weeks' separator=', ' id="%%POST_ID%%"][/types]

Changeover: [types field='timeshare-change-day2' separator=', ' id="%%POST_ID%%"][/types]

Price: £[types field='timeshare-ad-price' output='raw' id="%%POST_ID%%"][/types]

Expiry: [types field='tshr-ad-end-date' style='text' format='d/m/Y' id="%%POST_ID%%"][/types]

I made these changes on your staging site and used the "..." button to change the order to "Processing". The email came through with what seems to be the correct information in both the subject and email body. Please take a look and confirm this is working as expected, or let me know what is failing.

#607700

Thanks Christian - this needs to go into the notifications documentation, I reckon....
Also, perhaps you could advise on why the email is being sent when it's set to 'On hold' and 'Complete' ?