// calculate order, func _calculateOrder(order *model.Order) { switch model.OrderType(order.Type) { case model.SubOrder, model.Wholesale: if order.Details != nil && len(order.Details) > 0 { order.CalculateOrder() } case model.ShippingInstead: // this type of order's total price is calculated by sub // orders, which is difficult to calculate, so I calclate sum // in page, and then submit to the parent order. // So, here does nothing. } }