How to email the purchased information from the databse?

Hello, im currently trying to figure out how to after the purchase is made the buyer will recive and email saying "Hello, you purchased product APPLES and here are APPLES info: “RED”, “ROUND” etc and other info about the apples in the database?

I know how to display that info on repeating groups, Add to cart etc but now how to do it in an email?

If I were you I’d do the following…

Set up a webhook in Stripe and point it to the URL of a backend workflow in your app.

Initialize the backend workflow/webhook as explained in the Bubble docs and elsewhere in this forum.

Once initialized, configure that workflow to send an email to the User containing all the order details.

The way I would do that would be to create a database entry of ‘Order’ before sending the User to the Stripe checkout page, pass the unique ID of the Order into the checkout API call as metadata, and then retrieve the Order from the database using the unique ID that will now be received in the webhook.

Hmm seems very complecated? There is no way to do it in the workflow “send email”?

There is no way to do it in the workflow “send email”?

Sure, you can use the ‘Send Email’ action i your backend workflow if you don’'t have your own email API calls set up, or aren’t using a third-paryty plugin…

Okey thank you! Do you know what command/string i should use? To display the information that they purchase from the database?

Description Item Image Price
Item 1 Item 1 Image $10
Item 2 Item 2 Image $20
<table>
  <tr>
<td>Description</td>
<td><img src="image_url.jpg" alt="Item Image"></td>
<td>Price</td>
  </tr>
  <tr>
<td>Item 1</td>
<td><img src="item1_image.jpg" alt="Item 1 Image"></td>
<td>$10</td>
  </tr>
  <tr>
<td>Item 2</td>
<td><img src="item2_image.jpg" alt="Item 2 Image"></td>
<td>$20</td>
  </tr>
</table>

Just get the data from wherever you store it (e.g an Order entry in your database)… or you could retrieve it directly from the Stripe response/webhook.

These are the data i have from my database that i display on the website:
Current cells product’s name | Current cells product’s info | Current cells product’s color

Can i just use the same command in the email?

i don’t really understand how i can implement that to my databse?

You put that in your email body and replace the image src to the order image, and then the price, and then the description

You’ll want to use the :Format as Text operator on the list of order-items from the order to produce the required html…

But i have over 100 different products and info?

Hmm how would that look in an email if you could show?

For example:
Hello Current user's name! You have ordered Current cells product’s name… etc

You only need the items you sold.

You can’t access Current cells products name so you’re going to have to create some kind of “Order” entry for the items that were bought. And then use the :format as text operator as suggested with the table i provided. That should work.

Hmm how would that look in an email if you could show?
For example:
Hello Current user's name! You have ordered Current cells product’s name… etc

To stick with that simple example:

Hello Order's User's Name,

You have ordered Order's Order Item's Product's Name.

That will just put the names of the products from the order into a list separated by a comma and a space. e.g.

You have ordered product 1, product 2, product 3…

If you want to format then in some other way (i.e. one per line, or into some html) you’ll need to use :Format as text

e.g.

Hello Order's User's Name,

You have ordered:
Order's Order Item's: Formatted as Text.

Then for each item you can use something like:

This Order Item's Product's Name x This Order Item's Quantity - $This Order Item's Price

That will give you:

You have ordered:
Product 1 x 1 - $10
Product 2 x 10 - $200
Product 3 x 2 - $30

Obviously, if you want to use that as html you’ll need to do the same thing but format it in the correct way.

e.g.

<table>
  Order's Order Items: Format as Text
</table>

And for each Order item use:

  <tr>
<td>This Order Item's Product's Name</td>
<td><img src="This Order Item's Product's Image" alt="Item Image"></td>
<td>This Order Item's Sub Total</td>
  </tr>

Separated by a line-break…

2 Likes

Ah i think i understand now! thank you so much! :grinning_face_with_smiling_eyes:

1 Like

Great! Thank you!

1 Like