update storeid stuff
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 4m12s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 51s

This commit is contained in:
matst80
2025-10-10 06:16:46 +00:00
parent 92ebb49b09
commit f735540c3d
3 changed files with 24 additions and 9 deletions

View File

@@ -62,6 +62,7 @@ type CartItem struct {
ArticleType string `json:"type,omitempty"`
Image string `json:"image,omitempty"`
Outlet *string `json:"outlet,omitempty"`
StoreId *string `json:"storeId,omitempty"`
}
type CartDelivery struct {
@@ -187,11 +188,12 @@ func getItemData(sku string, qty int, country string) (*messages.AddItem, error)
}, nil
}
func (c *CartGrain) AddItem(sku string, qty int, country string) (*FrameWithPayload, error) {
func (c *CartGrain) AddItem(sku string, qty int, country string, storeId *string) (*FrameWithPayload, error) {
cartItem, err := getItemData(sku, qty, country)
if err != nil {
return nil, err
}
cartItem.StoreId = storeId
return c.HandleMessage(&Message{
Type: 2,
Content: cartItem,
@@ -282,7 +284,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
c.Items = make([]*CartItem, 0, len(msg.Items))
c.mu.Unlock()
for _, item := range msg.Items {
c.AddItem(item.Sku, int(item.Quantity), item.Country)
c.AddItem(item.Sku, int(item.Quantity), item.Country, item.StoreId)
}
}
@@ -297,7 +299,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
existingItem.Quantity += int(msg.Quantity)
c.UpdateTotals()
} else {
return c.AddItem(msg.Sku, int(msg.Quantity), msg.Country)
return c.AddItem(msg.Sku, int(msg.Quantity), msg.Country, msg.StoreId)
}
}
@@ -349,6 +351,7 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa
SellerName: msg.SellerName,
Tax: int(taxAmount),
TaxRate: tax,
StoreId: msg.StoreId,
})
c.UpdateTotals()
c.mu.Unlock()