Join our new community forum for support & discussion
Join NowHome › Support › Extensions › Requests › Code snippet for sending notification emails to vendors
Code snippet for sending notification emails to vendors
-
AuthorPosts
-
ThomasB 2 years, 2 months ago
Hi Ihor and team
If possible, can you provide a codesnippet we can use to send notifications to vendors when new messages/requests from buyers appear on our site using the “Request” extension?
Thanks!
Please try using this one:
add_action( 'hivepress/v1/models/request/update_status', function( $request_id, $new_status, $old_status ) { if ( 'publish' === $new_status && in_array( $old_status, [ 'auto-draft', 'pending' ], true ) ) { $request_url = get_permalink( $request_id ); $users = get_users( [ 'role' => 'contributor', 'number' => 100, ] ); foreach ( $users as $user ) { wp_mail( $user->user_email, 'New Request', hivepress()->helper->replace_tokens( [ 'user_name' => $user->display_name, 'request_url' => $request_url, ], 'Hi, %user_name%! There is a new request, please follow this link to view it: %request_url%' ) ); } } }, 100, 3 );
It’s not tested, please let me know if you notice any issues. Also, it assumes that all vendors have the “contributor” role in WordPress/Users (HivePress sets this role by default).
ThomasB 2 years, 2 months agoThanks, we will let you know if we notice any issues 🙂
max 2 years, 1 month agoHello, I have a question regarding this code.
Could it be adjusted so that the email also contains the message text / text of an offer?
When a vendor receives an offer via the offer form on the request page I would want him to be able to read the offer text via Email already so that he doesnt necessarily need to go to the website to read it.
I am not using the marketplace extension.Thank you
Please try using this token in the “New Offer” email text:
%offer.text%
max 2 years, 1 month agoThank you. I mean actually vendors are already getting those emails without this script.
Therefore I tried to adjust the email under class-offer-submit but doesnt work.
Where and how to I have to make adjustments to show the offer text?
Sorry I am not an dev 🙂Thank you for your help
Maybe you mean the request text, not the offer? The code snippet above notifies vendors about a new request, while the offer is submitted by vendors themselves.
If you mean the email sent to users when vendors make an offer you can edit it in HivePress/Settings/Offers/Emails section, and use the
%offer.text%
token in the email text – this doesn’t require any code customizations.max 2 years, 1 month agoHello ihor,
Sorry, let me clarify this a bit better.User A: has posted a request: e.g. “Build me a WordPress Website”
Vendor V submits an offer: “Hello, My offer is XYZ, I have great experience because of…”When User A now gets the email notification that he received an offer: “You received an offer. View this link…” the text which the vendor submitted should be in that email (not only on the website)
–> “You received an offer:
“Hello, My offer is XYZ, I have great experience because of…”
View this link…”How could that be achieved?
Thank you
Best
Maxmax 2 years, 1 month agoTried to add the %offer.text% with loco translate but it stays: %offer.text% in the email
This is strange, please try adding it to the Offer Received email text (via HivePress/Settings/Offers) and try making an offer. If it doesn’t work please wait for the next Requests update (2-3 days), I’ll double-check this.
max 2 years, 1 month agoHello ihor. I am stupid. It works like that.
Thank you so much for your help.max 2 years, 1 month agoJust a little follow up question:
Is there a way to display the vendor’s email address and vendors username that gave the offer in that email as well (with a token or something?).Thank you
Sorry, it’s not possible yet, this token is not available in the New Offer email.
-
AuthorPosts
New Reply
This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.