mirror of
				https://github.com/KevinMidboe/planetposen-mail.git
				synced 2025-10-29 17:50:32 +00:00 
			
		
		
		
	Add customer struct, date and updated html template
This commit is contained in:
		| @@ -3,6 +3,7 @@ package mail | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| type OrderMailSender interface { | ||||
| @@ -10,25 +11,39 @@ type OrderMailSender interface { | ||||
| } | ||||
|  | ||||
| type Product struct { | ||||
| 	ProductNo   int | ||||
| 	Name        string | ||||
| 	Image       string | ||||
| 	Description string | ||||
| 	Quantity    int | ||||
| 	Price       float32 | ||||
| 	Currency    string | ||||
| } | ||||
|  | ||||
| type Customer struct { | ||||
| 	FirstName     string | ||||
| 	LastName      string | ||||
| 	StreetAddress string | ||||
| 	ZipCode       string | ||||
| 	City          string | ||||
| } | ||||
|  | ||||
| type OrderConfirmationData struct { | ||||
| 	// PageTitle string | ||||
| 	Email    string | ||||
| 	OrderId  string | ||||
| 	Customer Customer | ||||
| 	Products []Product | ||||
| 	Sum       float32 | ||||
| } | ||||
|  | ||||
| type EmailTemplateData struct { | ||||
| 	PageTitle string | ||||
| 	Site      string | ||||
| 	Date      string | ||||
| 	OrderId   string | ||||
| 	Customer  Customer | ||||
| 	Products  []Product | ||||
| 	Sum       float32 | ||||
| } | ||||
|  | ||||
| type OrderConfirmationEmailData struct { | ||||
| @@ -48,9 +63,13 @@ type Record struct { | ||||
|  | ||||
| func OrderConfirmation(payload OrderConfirmationData) (*OrderConfirmationEmailData, error) { | ||||
| 	var emailTemplate EmailTemplateData | ||||
| 	emailTemplate.PageTitle = "Planetposen purchase" | ||||
| 	emailTemplate.PageTitle = "Ordrebekreftelse fra planetposen.no" | ||||
| 	emailTemplate.Site = "https://planet.schleppe.cloud" | ||||
| 	emailTemplate.Date = time.Now().Format("2006-01-02") | ||||
| 	emailTemplate.Sum = payload.Sum | ||||
| 	emailTemplate.OrderId = payload.OrderId | ||||
| 	emailTemplate.Products = payload.Products | ||||
| 	emailTemplate.Customer = payload.Customer | ||||
|  | ||||
| 	orderConfirmationEmailData := buildOrderConfirmation(emailTemplate) | ||||
| 	if orderConfirmationEmailData == nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user