cart

package
v1.4.5-alpha1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MPL-2.0 Imports: 8 Imported by: 10

Documentation

Overview

Package cart represents abstraction of business layer cart object

Index

Constants

View Source
const (
	ConstCartModelName         = "Cart"
	ConstSessionKeyCurrentCart = "cart_id"

	ConstErrorModule = "cart"
	ConstErrorLevel  = env.ConstErrorLevelModel
)

Package global constants

Variables

This section is empty.

Functions

This section is empty.

Types

type InterfaceCart

type InterfaceCart interface {
	AddItem(productID string, qty int, options map[string]interface{}) (InterfaceCartItem, error)
	RemoveItem(itemIdx int) error
	SetQty(itemIdx int, qty int) error

	GetItems() []InterfaceCartItem
	GetSubtotal() float64

	GetVisitorID() string
	SetVisitorID(string) error

	GetVisitor() visitor.InterfaceVisitor
	MakeCartForVisitor(visitorID string) error

	GetSessionID() string
	SetSessionID(sessionID string) error

	Activate() error
	Deactivate() error
	IsActive() bool

	GetLastUpdateTime() time.Time

	SetCartInfo(infoAttribute string, infoValue interface{}) error
	GetCartInfo() map[string]interface{}

	SetCustomInfo(info map[string]interface{})
	GetCustomInfo() map[string]interface{}

	ValidateCart() error

	models.InterfaceModel
	models.InterfaceStorable
}

InterfaceCart represents interface to access business layer implementation of cart object

func GetCartForVisitor

func GetCartForVisitor(visitorID string) (InterfaceCart, error)

GetCartForVisitor loads cart for visitor or creates new one

func GetCartModel

func GetCartModel() (InterfaceCart, error)

GetCartModel retrieves current InterfaceCart model implementation

func GetCartModelAndSetID

func GetCartModelAndSetID(cartID string) (InterfaceCart, error)

GetCartModelAndSetID retrieves current InterfaceCart model implementation and sets its ID to some value

func GetCurrentCart

func GetCurrentCart(context api.InterfaceApplicationContext, createNew bool) (InterfaceCart, error)

GetCurrentCart returns cart for current session or creates new one

func LoadCartByID

func LoadCartByID(cartID string) (InterfaceCart, error)

LoadCartByID loads cart data into current InterfaceCart model implementation

type InterfaceCartItem

type InterfaceCartItem interface {
	GetID() string
	SetID(newID string) error

	GetIdx() int
	SetIdx(newIdx int) error

	GetProductID() string
	GetProduct() product.InterfaceProduct

	GetQty() int
	SetQty(qty int) error

	GetOptions() map[string]interface{}
	SetOption(optionName string, optionValue interface{}) error

	ValidateProduct() error

	GetCart() InterfaceCart
}

InterfaceCartItem represents interface to access business layer implementation of cart item object

Jump to

Keyboard shortcuts

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