Skip to content

feat(business): add support for fetching order details#967

Open
salman0ansari wants to merge 5 commits into
tulir:mainfrom
salman0ansari:main
Open

feat(business): add support for fetching order details#967
salman0ansari wants to merge 5 commits into
tulir:mainfrom
salman0ansari:main

Conversation

@salman0ansari
Copy link
Copy Markdown
Contributor

  • added function GetOrderDetails to fetch order details
  • a new business.go file is introduced to house this and other business-related logic.
  • data structures for the order details are defined in types/business.go.

Usage

// you can get order id and token from the OrderMessage
orderDetails, err := client.GetOrderDetails(context.Background(), "order-id-here", "order-token-here")
if err != nil {
    // handle error
}
fmt.Printf("Order %s has %d products\n", orderDetails.ID, len(orderDetails.Products))

Response

{
  "id": "order-id-here",
  "created_at": "YYYY-MM-DDTHH:MM:SS+TZ",
  "catalog_id": "catalog-id-here",
  "price": {
    "subtotal": 1,
    "total": 1,
    "currency": "USD",
    "price_status": "provided"
  },
  "products": [
    {
      "id": "product-id-here",
      "image_id": "image-id-here",
      "image_url": "https://example.com/product-image.jpg",
      "price": 1,
      "currency": "USD",
      "name": "Product Name",
      "quantity": 1,
      "variant_info": {}
    }
  ]
}

@hrizal
Copy link
Copy Markdown

hrizal commented Oct 12, 2025

nice ...

@Diden05
Copy link
Copy Markdown

Diden05 commented Nov 12, 2025

@tulir merge?

Copy link
Copy Markdown
Contributor

@purpshell purpshell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified working on whatsapp business android

Comment thread business.go
Comment on lines +56 to +64
// Helper to get the string content of a child node.
func getStringChild(node waBinary.Node, tag string) string {
child, ok := node.GetOptionalChildByTag(tag)
if !ok {
return ""
}
content, _ := child.Content.([]byte)
return string(content)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the right place for a helper like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should be done?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i keep this scoped to the order-details parser instead ??

func parseOrderDetailsNode(orderNode waBinary.Node) (*types.OrderDetails, error) {
	getStringChild := func(node waBinary.Node, tag string) string {
		child, ok := node.GetOptionalChildByTag(tag)
		if !ok {
			return ""
		}
		content, _ := child.Content.([]byte)
		return string(content)
	}

	ag := orderNode.AttrGetter()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants