shopcart

package
v0.0.0-...-0d658de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalBinary

func MarshalBinary(str []product.ProductResume) (data []byte)

func UnmarshalBinary

func UnmarshalBinary(bff []byte) (data any)

Types

type ShopCart

type ShopCart struct {
	Uuid               string                  `json:"uuid,omitempty" redis:"uuid,omitempty"`
	ProductsResume     []product.ProductResume `json:"products_resume,omitempty" redis:"products_resume,omitempty"`
	Products           []product.Product       `json:"products,omitempty" redis:"-"`
	ProductsUid        []string                `json:"-" redis:"products_uid,omitempty"`
	ProductsTotal      int                     `json:"products_total,omitempty" redis:"-"`
	Items              int                     `json:"items,omitempty" redis:"-"`
	Taxes              int                     `json:"taxes,omitempty" redis:"taxes,omitempty"`
	FreightsTotal      int                     `json:"freights_total,omitempty" redis:"-"`
	SubTotal           int                     `json:"sub_total,omitempty" redis:"-"`
	Total              int                     `json:"total,omitempty" redis:"-"`
	DiscountPercentage int                     `json:"discount_percentage,omitempty" redis:"discount_percentage,omitempty"`
	Status             Status                  `json:"status,omitempty" redis:"status,omitempty"`
	LastAcesses        string                  `json:"last_acesses,omitempty" redis:"last_acesses,omitempty"`
}

func New

func New(shopcartByte ...[]byte) (shopcart *ShopCart, err error)

func Repository

func Repository() *ShopCart

func (*ShopCart) Add

func (s *ShopCart) Add(product product.Product)

func (*ShopCart) ApplyProductsUid

func (s *ShopCart) ApplyProductsUid() []string

func (*ShopCart) CalcPercentage

func (s *ShopCart) CalcPercentage(price int, percentage int) int

func (*ShopCart) Delete

func (s *ShopCart) Delete(shopcart *ShopCart) (err error)

func (*ShopCart) ExpandProducts

func (s *ShopCart) ExpandProducts(productsResume []product.ProductResume) []product.Product

func (*ShopCart) ForEachProductsUid

func (s *ShopCart) ForEachProductsUid(fn func(uid string)) []string

func (*ShopCart) FreightResume

func (s *ShopCart) FreightResume() int

func (*ShopCart) GetByUuid

func (s *ShopCart) GetByUuid(uuid string) (shopcart *ShopCart, err error)

func (*ShopCart) GetList

func (s *ShopCart) GetList() (shopcarts []ShopCart, err error)

func (*ShopCart) GetUuid

func (s *ShopCart) GetUuid(uuid string) (shopcart *ShopCart, err error)

func (*ShopCart) Inject

func (s *ShopCart) Inject(shopcart *ShopCart) *ShopCart

func (*ShopCart) Lote

func (s *ShopCart) Lote(products []product.Product)

func (*ShopCart) ReduceProducts

func (s *ShopCart) ReduceProducts(products []product.Product) []product.ProductResume

func (*ShopCart) Remove

func (s *ShopCart) Remove(prod product.Product)

func (*ShopCart) RemoveLote

func (s *ShopCart) RemoveLote(products []product.Product)

func (*ShopCart) Restore

func (s *ShopCart) Restore(shopcart *ShopCart) (err error)

func (*ShopCart) Resume

func (s *ShopCart) Resume()

func (*ShopCart) Save

func (s *ShopCart) Save(shopcart *ShopCart) (err error)

func (*ShopCart) Update

func (s *ShopCart) Update(shopcart *ShopCart) (err error)

type Status

type Status string
const (
	Undefined Status = ""
	Enabled   Status = "enabled"
	Disabled  Status = "disabled"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL