update
All checks were successful
Build and Publish / Metadata (push) Successful in 9s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m13s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m26s

This commit is contained in:
matst80
2025-10-16 18:01:32 +02:00
parent 15089862d5
commit c060680768
8 changed files with 263 additions and 181 deletions

View File

@@ -43,31 +43,41 @@ func GetItemAddMessage(sku string, qty int, country string, storeId *string) (*m
if err != nil {
return nil, err
}
return ToItemAddMessage(item, storeId, qty, country), nil
return ToItemAddMessage(item, storeId, qty, country)
}
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) *messages.AddItem {
func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country string) (*messages.AddItem, error) {
orgPrice, _ := getInt(item.GetNumberFieldValue(5)) // getInt(item.Fields[5])
price, err := getInt(item.GetNumberFieldValue(4)) //Fields[4]
if err != nil {
return nil
return nil, err
}
stock := cart.StockStatus(0)
centralStockValue, ok := item.GetStringFieldValue(3)
if storeId == nil {
if ok {
if !item.Buyable {
return nil, fmt.Errorf("item not available")
}
pureNumber := strings.Replace(centralStockValue, "+", "", -1)
if centralStock, err := strconv.ParseInt(pureNumber, 10, 64); err == nil {
stock = cart.StockStatus(centralStock)
}
if stock == cart.StockStatus(0) && item.SaleStatus == "TBD" {
return nil, fmt.Errorf("no items available")
}
}
} else {
if !item.BuyableInStore {
return nil, fmt.Errorf("item not available in store")
}
storeStock, ok := item.Stock.GetStock()[*storeId]
if ok {
stock = cart.StockStatus(storeStock)
}
}
articleType, _ := item.GetStringFieldValue(1) //.Fields[1].(string)
@@ -109,7 +119,8 @@ func ToItemAddMessage(item *index.DataItem, storeId *string, qty int, country st
Country: country,
Outlet: outlet,
StoreId: storeId,
}
SaleStatus: item.SaleStatus,
}, nil
}
func getTax(articleType string) int32 {