Documentation ¶
Index ¶
- Constants
- Variables
- type AuthManagerInterface
- type CachedCartEntry
- type CartCache
- type CartCacheIdentifier
- type CartReceiverService
- func (cs *CartReceiverService) DecorateCart(ctx context.Context, cart *cartDomain.Cart) (*decorator.DecoratedCart, error)
- func (cs *CartReceiverService) GetCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, cartDomain.ModifyBehaviour, error)
- func (cs *CartReceiverService) GetCartWithoutCache(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *CartReceiverService) GetDecoratedCart(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, cartDomain.ModifyBehaviour, error)
- func (cs *CartReceiverService) Inject(guestCartService cartDomain.GuestCartService, ...)
- func (cs *CartReceiverService) IsLoggedIn(ctx context.Context, session *web.Session) bool
- func (cs *CartReceiverService) RestoreCart(ctx context.Context, session *web.Session, cartToRestore cart.Cart) (*cartDomain.Cart, error)
- func (cs *CartReceiverService) ShouldHaveCart(ctx context.Context, session *web.Session) bool
- func (cs *CartReceiverService) ShouldHaveGuestCart(session *web.Session) bool
- func (cs *CartReceiverService) ViewCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *CartReceiverService) ViewDecoratedCart(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, error)
- func (cs *CartReceiverService) ViewDecoratedCartWithoutCache(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, error)
- func (cs *CartReceiverService) ViewGuestCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- type CartService
- func (cs *CartService) AddProduct(ctx context.Context, session *web.Session, deliveryCode string, ...) (productDomain.BasicProduct, error)
- func (cs *CartService) AdjustItemsToRestrictedQty(ctx context.Context, session *web.Session) (QtyAdjustmentResults, error)
- func (cs *CartService) ApplyAny(ctx context.Context, session *web.Session, anyCode string) (*cartDomain.Cart, error)
- func (cs *CartService) ApplyGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
- func (cs *CartService) ApplyVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
- func (cs *CartService) BuildAddRequest(ctx context.Context, marketplaceCode string, variantMarketplaceCode string, ...) cartDomain.AddRequest
- func (cs *CartService) CancelOrder(ctx context.Context, session *web.Session, ...) (*cartDomain.Cart, error)
- func (cs *CartService) Clean(ctx context.Context, session *web.Session) error
- func (cs *CartService) CreateInitialDeliveryIfNotPresent(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error)
- func (cs *CartService) DeleteAllItems(ctx context.Context, session *web.Session) error
- func (cs *CartService) DeleteCartInCache(ctx context.Context, session *web.Session, cart *cartDomain.Cart)
- func (cs *CartService) DeleteDelivery(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error)
- func (cs *CartService) DeleteItem(ctx context.Context, session *web.Session, itemID string, deliveryCode string) error
- func (cs *CartService) DeleteSavedSessionGuestCartID(session *web.Session) error
- func (cs *CartService) ForceReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *CartService) GetCartReceiverService() *CartReceiverService
- func (cs *CartService) GetDefaultDeliveryCode() string
- func (cs *CartService) GetInitialDelivery(deliveryCode string) (*cartDomain.DeliveryInfo, error)
- func (cs *CartService) Inject(cartReceiverService *CartReceiverService, ...)
- func (cs *CartService) PlaceOrder(ctx context.Context, session *web.Session, payment *placeorder.Payment) (placeorder.PlacedOrderInfos, error)
- func (cs *CartService) PlaceOrderWithCart(ctx context.Context, session *web.Session, cart *cartDomain.Cart, ...) (placeorder.PlacedOrderInfos, error)
- func (cs *CartService) RemoveGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
- func (cs *CartService) RemoveVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
- func (cs *CartService) ReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *CartService) UpdateBillingAddress(ctx context.Context, session *web.Session, billingAddress *cartDomain.Address) error
- func (cs *CartService) UpdateDeliveryInfo(ctx context.Context, session *web.Session, deliveryCode string, ...) error
- func (cs *CartService) UpdateItemQty(ctx context.Context, session *web.Session, itemID string, deliveryCode string, ...) error
- func (cs *CartService) UpdateItemSourceID(ctx context.Context, session *web.Session, itemID string, sourceID string) error
- func (cs *CartService) UpdateItems(ctx context.Context, session *web.Session, ...) error
- func (cs *CartService) UpdatePaymentSelection(ctx context.Context, session *web.Session, ...) error
- func (cs *CartService) UpdatePurchaser(ctx context.Context, session *web.Session, purchaser *cartDomain.Person, ...) error
- func (cs *CartService) ValidateCart(ctx context.Context, session *web.Session, ...) validation.Result
- func (cs *CartService) ValidateCurrentCart(ctx context.Context, session *web.Session) (validation.Result, error)
- type CartSessionCache
- func (cs *CartSessionCache) BuildIdentifier(ctx context.Context, session *web.Session) (CartCacheIdentifier, error)
- func (cs *CartSessionCache) CacheCart(ctx context.Context, session *web.Session, id CartCacheIdentifier, ...) error
- func (cs *CartSessionCache) Delete(ctx context.Context, session *web.Session, id CartCacheIdentifier) error
- func (cs *CartSessionCache) DeleteAll(ctx context.Context, session *web.Session) error
- func (cs *CartSessionCache) GetCart(ctx context.Context, session *web.Session, id CartCacheIdentifier) (*cart.Cart, error)
- func (cs *CartSessionCache) Inject(authManager *authApplication.AuthManager, ...)
- func (cs *CartSessionCache) Invalidate(ctx context.Context, session *web.Session, id CartCacheIdentifier) error
- type EventReceiver
- type QtyAdjustmentResult
- type QtyAdjustmentResults
- type RestrictionError
Constants ¶
const (
// CartSessionCacheCacheKeyPrefix is a string prefix for Cart Cache Keys
CartSessionCacheCacheKeyPrefix = "cart.sessioncache."
)
const (
// GuestCartSessionKey is a prefix
GuestCartSessionKey = "cart.guestid"
)
Variables ¶
var ( // ErrCacheIsInvalid sets generalized invalid Cache Error ErrCacheIsInvalid = errors.New("cache is invalid") // ErrNoCacheEntry - used if cahce is not found ErrNoCacheEntry = errors.New("cache entry not found") )
var ( //ErrTemporaryCartService - should be returned if it is likely that the backend service will return a cart on a next try ErrTemporaryCartService = errors.New("the cart could not be received currently - try again later") )
Functions ¶
This section is empty.
Types ¶
type AuthManagerInterface ¶
type AuthManagerInterface interface {
Auth(c context.Context, session *web.Session) (OAuthDomain.Auth, error)
}
AuthManagerInterface is the interface required to get Auth infos for CustomerCart handling
type CachedCartEntry ¶
CachedCartEntry defines a single Cart Cache Entry
type CartCache ¶
type CartCache interface { GetCart(context.Context, *web.Session, CartCacheIdentifier) (*cart.Cart, error) CacheCart(context.Context, *web.Session, CartCacheIdentifier, *cart.Cart) error Invalidate(context.Context, *web.Session, CartCacheIdentifier) error Delete(context.Context, *web.Session, CartCacheIdentifier) error DeleteAll(context.Context, *web.Session) error BuildIdentifier(context.Context, *web.Session) (CartCacheIdentifier, error) }
CartCache describes a cart caches methods
type CartCacheIdentifier ¶
CartCacheIdentifier identifies Cart Caches
func BuildIdentifierFromCart ¶
func BuildIdentifierFromCart(cart *cart.Cart) (*CartCacheIdentifier, error)
BuildIdentifierFromCart creates a Cache Identifier from Cart Data DEPRICATED
func (*CartCacheIdentifier) CacheKey ¶
func (ci *CartCacheIdentifier) CacheKey() string
CacheKey creates a Cache Key Identifier string
type CartReceiverService ¶
type CartReceiverService struct {
// contains filtered or unexported fields
}
CartReceiverService provides methods to get the correct cart
func (*CartReceiverService) DecorateCart ¶
func (cs *CartReceiverService) DecorateCart(ctx context.Context, cart *cartDomain.Cart) (*decorator.DecoratedCart, error)
DecorateCart Get the correct Cart
func (*CartReceiverService) GetCart ¶
func (cs *CartReceiverService) GetCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, cartDomain.ModifyBehaviour, error)
GetCart Get the correct Cart (either Guest or User)
func (*CartReceiverService) GetCartWithoutCache ¶
func (cs *CartReceiverService) GetCartWithoutCache(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
GetCartWithoutCache - forces to get the cart without cache
func (*CartReceiverService) GetDecoratedCart ¶
func (cs *CartReceiverService) GetDecoratedCart(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, cartDomain.ModifyBehaviour, error)
GetDecoratedCart Get the correct Cart
func (*CartReceiverService) Inject ¶
func (cs *CartReceiverService) Inject( guestCartService cartDomain.GuestCartService, customerCartService cartDomain.CustomerCartService, cartDecoratorFactory *decorator.DecoratedCartFactory, authManager AuthManagerInterface, userService authApplication.UserServiceInterface, logger flamingo.Logger, eventRouter flamingo.EventRouter, optionals *struct { CartCache CartCache `inject:",optional"` }, )
Inject the dependencies
func (*CartReceiverService) IsLoggedIn ¶
IsLoggedIn returns the logged in state
func (*CartReceiverService) RestoreCart ¶
func (cs *CartReceiverService) RestoreCart(ctx context.Context, session *web.Session, cartToRestore cart.Cart) (*cartDomain.Cart, error)
RestoreCart restores a previously used guest / customer cart
func (*CartReceiverService) ShouldHaveCart ¶
ShouldHaveCart - checks if there should be a cart. Indicated if a call to GetCart should return a real cart
func (*CartReceiverService) ShouldHaveGuestCart ¶
func (cs *CartReceiverService) ShouldHaveGuestCart(session *web.Session) bool
ShouldHaveGuestCart - checks if there should be guest cart
func (*CartReceiverService) ViewCart ¶
func (cs *CartReceiverService) ViewCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ViewCart return a Cart for view
func (*CartReceiverService) ViewDecoratedCart ¶
func (cs *CartReceiverService) ViewDecoratedCart(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, error)
ViewDecoratedCart return a Cart for view
func (*CartReceiverService) ViewDecoratedCartWithoutCache ¶
func (cs *CartReceiverService) ViewDecoratedCartWithoutCache(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, error)
ViewDecoratedCartWithoutCache return a Cart for view
func (*CartReceiverService) ViewGuestCart ¶
func (cs *CartReceiverService) ViewGuestCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ViewGuestCart - ry to get the uest Cart - even if the user is logged in
type CartService ¶
type CartService struct {
// contains filtered or unexported fields
}
CartService provides methods to modify the cart
func (*CartService) AddProduct ¶
func (cs *CartService) AddProduct(ctx context.Context, session *web.Session, deliveryCode string, addRequest cartDomain.AddRequest) (productDomain.BasicProduct, error)
AddProduct adds a product to the cart
func (*CartService) AdjustItemsToRestrictedQty ¶
func (cs *CartService) AdjustItemsToRestrictedQty(ctx context.Context, session *web.Session) (QtyAdjustmentResults, error)
AdjustItemsToRestrictedQty checks the quantity restrictions for each item of the cart and returns what quantities have been adjusted
func (*CartService) ApplyAny ¶
func (cs *CartService) ApplyAny(ctx context.Context, session *web.Session, anyCode string) (*cartDomain.Cart, error)
ApplyAny applies a voucher or giftcard to the cart
func (*CartService) ApplyGiftCard ¶
func (cs *CartService) ApplyGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
ApplyGiftCard adds a giftcard to the cart
func (*CartService) ApplyVoucher ¶
func (cs *CartService) ApplyVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
ApplyVoucher applies a voucher to the cart
func (*CartService) BuildAddRequest ¶
func (cs *CartService) BuildAddRequest(ctx context.Context, marketplaceCode string, variantMarketplaceCode string, qty int) cartDomain.AddRequest
BuildAddRequest Helper to build
func (*CartService) CancelOrder ¶
func (cs *CartService) CancelOrder(ctx context.Context, session *web.Session, orderInfos placeorder.PlacedOrderInfos, cart cartDomain.Cart) (*cartDomain.Cart, error)
CancelOrder cancels a previously placed order and restores the cart content
func (*CartService) CreateInitialDeliveryIfNotPresent ¶
func (cs *CartService) CreateInitialDeliveryIfNotPresent(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error)
CreateInitialDeliveryIfNotPresent creates the initial delivery
func (*CartService) DeleteAllItems ¶
DeleteAllItems in current cart
func (*CartService) DeleteCartInCache ¶
func (cs *CartService) DeleteCartInCache(ctx context.Context, session *web.Session, cart *cartDomain.Cart)
DeleteCartInCache removes the cart from cache
func (*CartService) DeleteDelivery ¶
func (cs *CartService) DeleteDelivery(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error)
DeleteDelivery in current cart
func (*CartService) DeleteItem ¶
func (cs *CartService) DeleteItem(ctx context.Context, session *web.Session, itemID string, deliveryCode string) error
DeleteItem in current cart
func (*CartService) DeleteSavedSessionGuestCartID ¶
func (cs *CartService) DeleteSavedSessionGuestCartID(session *web.Session) error
DeleteSavedSessionGuestCartID deletes a guest cart Key from the Session Values
func (*CartService) ForceReserveOrderIDAndSave ¶
func (cs *CartService) ForceReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ForceReserveOrderIDAndSave reserves order id by using the PlaceOrder behaviour, sets and saves it on the cart. Each call of this method reserves a new order ID, even if it is already set on the cart. You may want to use this before proceeding with payment to ensure having a useful reference in the payment processing
func (*CartService) GetCartReceiverService ¶
func (cs *CartService) GetCartReceiverService() *CartReceiverService
GetCartReceiverService returns the injected cart receiver service
func (*CartService) GetDefaultDeliveryCode ¶
func (cs *CartService) GetDefaultDeliveryCode() string
GetDefaultDeliveryCode returns the configured default deliverycode
func (*CartService) GetInitialDelivery ¶
func (cs *CartService) GetInitialDelivery(deliveryCode string) (*cartDomain.DeliveryInfo, error)
GetInitialDelivery - calls the registered deliveryInfoBuilder to get the initial values for a Delivery based on the given code
func (*CartService) Inject ¶
func (cs *CartService) Inject( cartReceiverService *CartReceiverService, productService productDomain.ProductService, eventPublisher events.EventPublisher, eventRouter flamingo.EventRouter, deliveryInfoBuilder cartDomain.DeliveryInfoBuilder, restrictionService *validation.RestrictionService, authManager AuthManagerInterface, logger flamingo.Logger, config *struct { DefaultDeliveryCode string `inject:"config:commerce.cart.defaultDeliveryCode,optional"` DeleteEmptyDelivery bool `inject:"config:commerce.cart.deleteEmptyDelivery,optional"` }, optionals *struct { CartValidator validation.Validator `inject:",optional"` ItemValidator validation.ItemValidator `inject:",optional"` CartCache CartCache `inject:",optional"` PlaceOrderService placeorder.Service `inject:",optional"` }, )
Inject dependencies
func (*CartService) PlaceOrder ¶
func (cs *CartService) PlaceOrder(ctx context.Context, session *web.Session, payment *placeorder.Payment) (placeorder.PlacedOrderInfos, error)
PlaceOrder converts the cart (possibly cached) with payments into orders by calling the Service
func (*CartService) PlaceOrderWithCart ¶
func (cs *CartService) PlaceOrderWithCart(ctx context.Context, session *web.Session, cart *cartDomain.Cart, payment *placeorder.Payment) (placeorder.PlacedOrderInfos, error)
PlaceOrderWithCart converts the given cart with payments into orders by calling the Service
func (*CartService) RemoveGiftCard ¶
func (cs *CartService) RemoveGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
RemoveGiftCard removes a giftcard from the cart
func (*CartService) RemoveVoucher ¶
func (cs *CartService) RemoveVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error)
RemoveVoucher removes a voucher from the cart
func (*CartService) ReserveOrderIDAndSave ¶
func (cs *CartService) ReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ReserveOrderIDAndSave reserves order id by using the PlaceOrder behaviour, sets and saves it on the cart. If the cart already holds a reserved order id no set/save is performed and the existing cart is returned. You may want to use this before proceeding with payment to ensure having a useful reference in the payment processing
func (*CartService) UpdateBillingAddress ¶
func (cs *CartService) UpdateBillingAddress(ctx context.Context, session *web.Session, billingAddress *cartDomain.Address) error
UpdateBillingAddress updates the billing address on the cart
func (*CartService) UpdateDeliveryInfo ¶
func (cs *CartService) UpdateDeliveryInfo(ctx context.Context, session *web.Session, deliveryCode string, deliveryInfo cartDomain.DeliveryInfoUpdateCommand) error
UpdateDeliveryInfo updates the delivery info on the cart
func (*CartService) UpdateItemQty ¶
func (cs *CartService) UpdateItemQty(ctx context.Context, session *web.Session, itemID string, deliveryCode string, qty int) error
UpdateItemQty updates a single cart item qty
func (*CartService) UpdateItemSourceID ¶
func (cs *CartService) UpdateItemSourceID(ctx context.Context, session *web.Session, itemID string, sourceID string) error
UpdateItemSourceID updates an item source id
func (*CartService) UpdateItems ¶
func (cs *CartService) UpdateItems(ctx context.Context, session *web.Session, updateCommands []cartDomain.ItemUpdateCommand) error
UpdateItems updates multiple items
func (*CartService) UpdatePaymentSelection ¶
func (cs *CartService) UpdatePaymentSelection(ctx context.Context, session *web.Session, paymentSelection cartDomain.PaymentSelection) error
UpdatePaymentSelection updates the paymentselection in the cart
func (*CartService) UpdatePurchaser ¶
func (cs *CartService) UpdatePurchaser(ctx context.Context, session *web.Session, purchaser *cartDomain.Person, additionalData *cartDomain.AdditionalData) error
UpdatePurchaser updates the purchaser on the cart
func (*CartService) ValidateCart ¶
func (cs *CartService) ValidateCart(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart) validation.Result
ValidateCart validates a carts content
func (*CartService) ValidateCurrentCart ¶
func (cs *CartService) ValidateCurrentCart(ctx context.Context, session *web.Session) (validation.Result, error)
ValidateCurrentCart validates the current active cart
type CartSessionCache ¶
type CartSessionCache struct {
// contains filtered or unexported fields
}
CartSessionCache defines a Cart Cache
func (*CartSessionCache) BuildIdentifier ¶
func (cs *CartSessionCache) BuildIdentifier(ctx context.Context, session *web.Session) (CartCacheIdentifier, error)
BuildIdentifier creates a CartCacheIdentifier based on the login state
func (*CartSessionCache) CacheCart ¶
func (cs *CartSessionCache) CacheCart(ctx context.Context, session *web.Session, id CartCacheIdentifier, cartForCache *cart.Cart) error
CacheCart adds a Cart to the Cache
func (*CartSessionCache) Delete ¶
func (cs *CartSessionCache) Delete(ctx context.Context, session *web.Session, id CartCacheIdentifier) error
Delete a Cache entry
func (*CartSessionCache) GetCart ¶
func (cs *CartSessionCache) GetCart(ctx context.Context, session *web.Session, id CartCacheIdentifier) (*cart.Cart, error)
GetCart fetches a Cart from the Cache
func (*CartSessionCache) Inject ¶
func (cs *CartSessionCache) Inject( authManager *authApplication.AuthManager, userService *authApplication.UserService, logger flamingo.Logger, config *struct { LifetimeSeconds float64 `inject:"config:commerce.cart.cacheLifetime"` // in seconds }, )
Inject the dependencies
func (*CartSessionCache) Invalidate ¶
func (cs *CartSessionCache) Invalidate(ctx context.Context, session *web.Session, id CartCacheIdentifier) error
Invalidate a Cache Entry
type EventReceiver ¶
type EventReceiver struct {
// contains filtered or unexported fields
}
EventReceiver - handles events from other packages
func (*EventReceiver) Inject ¶
func (e *EventReceiver) Inject( logger flamingo.Logger, cartService *CartService, cartReceiverService *CartReceiverService, optionals *struct { CartCache CartCache `inject:",optional"` }, )
Inject dependencies
type QtyAdjustmentResult ¶
type QtyAdjustmentResult struct { OriginalItem cartDomain.Item DeliveryCode string WasDeleted bool RestrictionResult *validation.RestrictionResult NewQty int }
QtyAdjustmentResult restriction result enriched with the respective item
type QtyAdjustmentResults ¶
type QtyAdjustmentResults []QtyAdjustmentResult
QtyAdjustmentResults slice of QtyAdjustmentResult
type RestrictionError ¶
type RestrictionError struct { CartItemID string RestrictionResult validation.RestrictionResult // contains filtered or unexported fields }
RestrictionError error enriched with result of restrictions
func (*RestrictionError) Error ¶
func (e *RestrictionError) Error() string
Error fetch error message