Documentation ¶
Index ¶
- Constants
- func GetTaxAmount(price float64) float64
- func GetTaxPercent() float64
- type Address
- type Cart
- func (c *Cart) AddItem(db *gorm.DB, item CartItem) (*CartItem, error)
- func (c *Cart) CalculateCart(db *gorm.DB, cartID string) (*Cart, error)
- func (c *Cart) CreateCart(db *gorm.DB, cartID string) (*Cart, error)
- func (c *Cart) GetCart(db *gorm.DB, cartID string) (*Cart, error)
- func (c *Cart) GetItems(db *gorm.DB, cartID string) ([]CartItem, error)
- func (c *Cart) RemoveItemByID(db *gorm.DB, itemID string) error
- func (c *Cart) UpdateItemQty(db *gorm.DB, itemID string, qty int) (*CartItem, error)
- type CartItem
- type Category
- type Model
- type Order
- type OrderCustomer
- type OrderItem
- type Payment
- type Product
- func (entity *Product) BeforeCreate(db *gorm.DB) error
- func (entity *Product) BeforeUpdate(db *gorm.DB) error
- func (p *Product) FindByID(db *gorm.DB, productID string) (*Product, error)
- func (p *Product) FindBySlug(db *gorm.DB, slug string) (*Product, error)
- func (p *Product) GetProducts(db *gorm.DB, perPage int, page int) (*[]Product, int64, error)
- type ProductCategories
- type ProductImage
- type Shipment
- type User
Constants ¶
View Source
const (
TaxPercent = 10
)
Variables ¶
This section is empty.
Functions ¶
func GetTaxAmount ¶
func GetTaxPercent ¶
func GetTaxPercent() float64
Types ¶
type Address ¶
type Address struct { ID string `gorm:"primaryKey;not null"` User User UserID string `gorm:"type:varchar(255);not null;unique;index"` Name string `gorm:"type:varchar(255);not null"` IsPrimary bool CityID string `gorm:"type:varchar(255);not null"` ProvinceID string `gorm:"type:varchar(255);not null"` Address1 string `gorm:"type:varchar(255);not null"` Address2 string `gorm:"type:varchar(255);not null"` Phone string `gorm:"type:varchar(255);not null"` Email string `gorm:"type:varchar(255);not null"` PostCode string `gorm:"type:varchar(255);not null"` CreatedAt time.Time UpdatedAt time.Time }
type Cart ¶
type Cart struct { ID string `gorm:"primaryKey;not null;unique"` CartItems []CartItem BaseTotalPrice decimal.Decimal `gorm:"type:decimal(16,2)"` TaxAmount decimal.Decimal `gorm:"type:decimal(16,2)"` TaxPercent decimal.Decimal `gorm:"type:decimal(10,2)"` DiscountAmount decimal.Decimal `gorm:"type:decimal(16,2)"` DiscountPercent decimal.Decimal `gorm:"type:decimal(10,2)"` GrandTotal decimal.Decimal `gorm:"type:decimal(16,2)"` }
func (*Cart) CalculateCart ¶
type CartItem ¶
type CartItem struct { ID string `gorm:"primaryKey;not null;unique"` Cart Cart CartID string `gorm:"index;not null"` Product Product ProductID string `gorm:"index;not null"` Qty int BasePrice decimal.Decimal `gorm:"type:decimal(16,2)"` BaseTotal decimal.Decimal `gorm:"type:decimal(16,2)"` TaxAmount decimal.Decimal `gorm:"type:decimal(16,2)"` TaxPercent decimal.Decimal `gorm:"type:decimal(10,2)"` DiscountAmount decimal.Decimal `gorm:"type:decimal(16,2)"` DiscountPercent decimal.Decimal `gorm:"type:decimal(10,2)"` SubTotal decimal.Decimal `gorm:"type:decimal(16,2)"` CreatedAt time.Time UpdatedAt time.Time }
type Category ¶
type Model ¶
type Model struct {
Model interface{}
}
func RegisterModels ¶
func RegisterModels() []Model
type Order ¶
type Order struct { ID string `gorm:"primaryKey;not null;unique"` UserID string `gorm:"index;not null"` User User OrderItems []OrderItem OrderCustomer *OrderCustomer Code string `gorm:"type:varchar(50);index"` Status int OrderDate time.Time PaymentDue time.Time PaymentStatus string `gorm:"type:varchar(50);index;not null"` PaymentToken string `gorm:"type:varchar(100);index"` BaseTotalPrice decimal.Decimal `gorm:"type:decimal(16,2)"` TaxAmount decimal.Decimal `gorm:"type:decimal(16,2)"` TaxPercent decimal.Decimal `gorm:"type:decimal(10,2)"` DiscountAmount decimal.Decimal `gorm:"type:decimal(16,2)"` DiscountPercent decimal.Decimal `gorm:"type:decimal(10,2)"` ShippingCost decimal.Decimal `gorm:"type:decimal(16,2)"` GrandTotal decimal.Decimal `gorm:"type:decimal(16,2)"` Note string `gorm:"type:text"` ShippingCourier string `gorm:"type:varchar(100);not null"` ShippingServiceName string `gorm:"type:varchar(100);not null"` ApprovedBy string `gorm:"size:36"` ApprovedAt time.Time CancelledBy string `gorm:"size:36"` CancelledAt time.Time CancellationNote string `gorm:"size:255"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt }
type OrderCustomer ¶
type OrderCustomer struct { ID string `gorm:"primaryKey;not null;unique"` User User UserID string `gorm:"index;not null"` Order Order OrderID string `gorm:"index;not null"` FirstName string `gorm:"type:varchar(100);not null"` LastName string `gorm:"type:varchar(100);not null"` CityID string `gorm:"type:varchar(100);"` ProvinceID string `gorm:"type:varchar(100);"` Address1 string `gorm:"type:varchar(100);"` Address2 string `gorm:"type:varchar(100);"` Phone string `gorm:"type:varchar(50);"` Email string `gorm:"type:varchar(100);"` PostCode string `gorm:"type:varchar(100);"` CreatedAt time.Time UpdatedAt time.Time }
type OrderItem ¶
type OrderItem struct { ID string `gorm:"primaryKey;not null;unique"` Order Order OrderID string `gorm:"index;not null"` Product Product ProductID string `gorm:"index;not null"` Qty int BasePrice decimal.Decimal `gorm:"type:decimal(16,2)"` BaseTotal decimal.Decimal `gorm:"type:decimal(16,2)"` TaxAmount decimal.Decimal `gorm:"type:decimal(16,2)"` TaxPercent decimal.Decimal `gorm:"type:decimal(10,2)"` DiscountAmount decimal.Decimal `gorm:"type:decimal(16,2)"` DiscountPercent decimal.Decimal `gorm:"type:decimal(10,2)"` SubTotal decimal.Decimal `gorm:"type:decimal(16,2)"` Sku string `gorm:"size:36;index"` Name string `gorm:"size:255"` Weight decimal.Decimal `gorm:"type:decimal(10,2)"` CreatedAt time.Time UpdatedAt time.Time }
type Payment ¶
type Payment struct { ID string `gorm:"primaryKey;not null;unique"` Order Order OrderID string `gorm:"index;not null"` Number string `gorm:"type:varchar(100);index"` Amount decimal.Decimal `gorm:"type:decimal(16,2)"` Method string `gorm:"type:varchar(100)"` Status string `gorm:"type:varchar(100)"` Token string `gorm:"type:varchar(100);index"` Payload string `gorm:"type:text"` PaymentType string `gorm:"type:varchar(100)"` VaNumber string `gorm:"type:varchar(100)"` BillCode string `gorm:"type:varchar(100)"` BillKey string `gorm:"type:varchar(100)"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt }
type Product ¶
type Product struct { ID string `gorm:"primaryKey;not null;unique"` ParentID string `gorm:"index"` User User UserID string `gorm:"index;not null"` Sku string `gorm:"type:varchar(100);index"` Name string `gorm:"type:varchar(255);not null"` Slug string `gorm:"type:varchar(255);not null"` Price decimal.Decimal `gorm:"type:decimal(16,2);"` Stock int Weight decimal.Decimal `gorm:"type:decimal(10,2);"` ShortDescription string `gorm:"type:text"` Description string `gorm:"type:text"` Status int `gorm:"default:0"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt ProductImages []ProductImage Categories []Category `gorm:"many2many:product_categories;"` CategoryID []string `json:"category_id" gorm:"-"` }
func (*Product) FindBySlug ¶
type ProductCategories ¶
type ProductImage ¶
type ProductImage struct { ID string `gorm:"primaryKey;not null;unique"` Product Product ProductID string `gorm:"index;not null"` Path string `gorm:"type:text"` ExtraLarge string `gorm:"type:text"` Large string `gorm:"type:text"` Medium string `gorm:"type:text"` Small string `gorm:"type:text"` CreatedAt time.Time UpdatedAt time.Time }
type User ¶
type User struct { ID string `gorm:"primaryKey;not null"` Addresses []Address FirstName string `gorm:"type:varchar(255);not null"` LastName string `gorm:"type:varchar(255);not null"` Email string `gorm:"type:varchar(255);unique;not null"` Password string `gorm:"type:varchar(255);not null" json:"-"` RememberToken string `gorm:"type:varchar(255);not null" json:"-"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
Click to show internal directories.
Click to hide internal directories.