Documentation ¶
Index ¶
- Constants
- Variables
- type BaseCartReceiver
- func (cs *BaseCartReceiver) GetCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, cartDomain.ModifyBehaviour, error)
- func (cs *BaseCartReceiver) GetCartWithoutCache(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *BaseCartReceiver) Inject(guestCartService cartDomain.GuestCartService, ...)
- func (cs *BaseCartReceiver) ModifyBehaviour(ctx context.Context) (cartDomain.ModifyBehaviour, error)
- func (cs *BaseCartReceiver) RestoreCart(ctx context.Context, session *web.Session, cartToRestore cartDomain.Cart) (*cartDomain.Cart, error)
- func (cs *BaseCartReceiver) ShouldHaveCart(ctx context.Context, session *web.Session) bool
- func (cs *BaseCartReceiver) ShouldHaveGuestCart(session *web.Session) bool
- func (cs *BaseCartReceiver) ViewCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- func (cs *BaseCartReceiver) ViewGuestCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
- type CachedCartEntry
- type CartCache
- type CartCacheIdentifier
- type CartReceiverService
- func (cs *CartReceiverService) DecorateCart(ctx context.Context, cart *cartDomain.Cart) (*decorator.DecoratedCart, 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) ViewDecoratedCart(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, error)
- func (cs *CartReceiverService) ViewDecoratedCartWithoutCache(ctx context.Context, session *web.Session) (*decorator.DecoratedCart, 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(_ context.Context, marketplaceCode string, variantMarketplaceCode string, ...) cartDomain.AddRequest
- func (cs *CartService) CancelOrder(ctx context.Context, session *web.Session, ...) (*cartDomain.Cart, error)
- func (cs *CartService) CancelOrderWithoutRestore(ctx context.Context, session *web.Session, ...) error
- func (cs *CartService) Clean(ctx context.Context, session *web.Session) error
- func (cs *CartService) CompleteCurrentCart(ctx context.Context) (*cartDomain.Cart, 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, _ *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) RestoreCart(ctx context.Context, cart *cartDomain.Cart) (*cartDomain.Cart, error)
- func (cs *CartService) UpdateAdditionalData(ctx context.Context, session *web.Session, additionalData map[string]string) (*cartDomain.Cart, error)
- func (cs *CartService) UpdateBillingAddress(ctx context.Context, session *web.Session, billingAddress *cartDomain.Address) error
- func (cs *CartService) UpdateDeliveryAdditionalData(ctx context.Context, session *web.Session, deliveryCode string, ...) (*cartDomain.Cart, 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(logger flamingo.Logger, webIdentityService *auth.WebIdentityService, ...)
- func (cs *CartSessionCache) Invalidate(ctx context.Context, session *web.Session, id CartCacheIdentifier) error
- type EventReceiver
- type PostCartMergeEvent
- type PreCartMergeEvent
- type QtyAdjustmentResult
- type QtyAdjustmentResults
- type Receiver
- type RestrictionError
- type Service
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 cache is not found ErrNoCacheEntry = errors.New("cache entry not found") )
var (
ErrNoBundleConfigurationGiven = errors.New("no bundle configuration given for configurable product")
)
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 BaseCartReceiver ¶ added in v3.6.0
type BaseCartReceiver struct {
// contains filtered or unexported fields
}
BaseCartReceiver get undecorated carts only
func (*BaseCartReceiver) GetCart ¶ added in v3.6.0
func (cs *BaseCartReceiver) GetCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, cartDomain.ModifyBehaviour, error)
GetCart Get the correct Cart (either Guest or User)
func (*BaseCartReceiver) GetCartWithoutCache ¶ added in v3.6.0
func (cs *BaseCartReceiver) GetCartWithoutCache(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
GetCartWithoutCache - forces to get the cart without cache
func (*BaseCartReceiver) Inject ¶ added in v3.6.0
func (cs *BaseCartReceiver) Inject( guestCartService cartDomain.GuestCartService, customerCartService cartDomain.CustomerCartService, webIdentityService *auth.WebIdentityService, logger flamingo.Logger, eventRouter flamingo.EventRouter, optionals *struct { CartCache CartCache `inject:",optional"` }, )
Inject the dependencies
func (*BaseCartReceiver) ModifyBehaviour ¶ added in v3.6.0
func (cs *BaseCartReceiver) ModifyBehaviour(ctx context.Context) (cartDomain.ModifyBehaviour, error)
ModifyBehaviour returns the correct behaviour to modify the cart for the current user (guest/customer)
func (*BaseCartReceiver) RestoreCart ¶ added in v3.6.0
func (cs *BaseCartReceiver) RestoreCart(ctx context.Context, session *web.Session, cartToRestore cartDomain.Cart) (*cartDomain.Cart, error)
RestoreCart restores a previously used guest / customer cart deprecated: use CartService.RestoreCart(), ensure that your cart implements the CompleteBehaviour
func (*BaseCartReceiver) ShouldHaveCart ¶ added in v3.6.0
ShouldHaveCart - checks if there should be a cart. Indicated if a call to GetCart should return a real cart
func (*BaseCartReceiver) ShouldHaveGuestCart ¶ added in v3.6.0
func (cs *BaseCartReceiver) ShouldHaveGuestCart(session *web.Session) bool
ShouldHaveGuestCart - checks if there should be guest cart
func (*BaseCartReceiver) ViewCart ¶ added in v3.6.0
func (cs *BaseCartReceiver) ViewCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ViewCart return a Cart for view
func (*BaseCartReceiver) ViewGuestCart ¶ added in v3.6.0
func (cs *BaseCartReceiver) ViewGuestCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error)
ViewGuestCart try to get the guest Cart - even if the user is logged in
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 { *BaseCartReceiver // 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) 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, webIdentityService *auth.WebIdentityService, logger flamingo.Logger, eventRouter flamingo.EventRouter, optionals *struct { CartCache CartCache `inject:",optional"` }, )
Inject the dependencies
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
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(_ context.Context, marketplaceCode string, variantMarketplaceCode string, qty int, additionalData map[string]string) cartDomain.AddRequest
BuildAddRequest Helper to build Deprecated: build your own add request
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) CancelOrderWithoutRestore ¶ added in v3.1.0
func (cs *CartService) CancelOrderWithoutRestore(ctx context.Context, session *web.Session, orderInfos placeorder.PlacedOrderInfos) error
CancelOrderWithoutRestore cancels a previously placed order
func (*CartService) CompleteCurrentCart ¶ added in v3.1.0
func (cs *CartService) CompleteCurrentCart(ctx context.Context) (*cartDomain.Cart, error)
CompleteCurrentCart and remove from cache
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, _ *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, webIdentityService *auth.WebIdentityService, 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) RestoreCart ¶ added in v3.1.0
func (cs *CartService) RestoreCart(ctx context.Context, cart *cartDomain.Cart) (*cartDomain.Cart, error)
RestoreCart and cache
func (*CartService) UpdateAdditionalData ¶ added in v3.5.0
func (cs *CartService) UpdateAdditionalData(ctx context.Context, session *web.Session, additionalData map[string]string) (*cartDomain.Cart, error)
UpdateAdditionalData of cart
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) UpdateDeliveryAdditionalData ¶ added in v3.5.0
func (cs *CartService) UpdateDeliveryAdditionalData(ctx context.Context, session *web.Session, deliveryCode string, additionalData map[string]string) (*cartDomain.Cart, error)
UpdateDeliveryAdditionalData of 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( logger flamingo.Logger, webIdentityService *auth.WebIdentityService, 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, webIdentityService *auth.WebIdentityService, eventRouter flamingo.EventRouter, optionals *struct { CartCache CartCache `inject:",optional"` }, )
Inject dependencies
type PostCartMergeEvent ¶ added in v3.6.0
type PostCartMergeEvent struct {
MergedCart cartDomain.Cart
}
PostCartMergeEvent is dispatched after merging the guest cart and the customer cart
type PreCartMergeEvent ¶ added in v3.6.0
type PreCartMergeEvent struct { GuestCart cartDomain.Cart CustomerCart cartDomain.Cart }
PreCartMergeEvent is dispatched after getting the (current) guest cart and the customer cart before merging
type QtyAdjustmentResult ¶
type QtyAdjustmentResult struct { OriginalItem cartDomain.Item DeliveryCode string WasDeleted bool RestrictionResult *validation.RestrictionResult NewQty int HasRemovedCouponCodes bool }
QtyAdjustmentResult restriction result enriched with the respective item
type QtyAdjustmentResults ¶
type QtyAdjustmentResults []QtyAdjustmentResult
QtyAdjustmentResults slice of QtyAdjustmentResult
func (QtyAdjustmentResults) HasRemovedCouponCodes ¶ added in v3.0.1
func (qar QtyAdjustmentResults) HasRemovedCouponCodes() bool
HasRemovedCouponCodes returns if a QtyAdjustmentResults has any adjustment that removed a coupon code from the cart
type Receiver ¶ added in v3.6.0
type Receiver interface { ShouldHaveCart(ctx context.Context, session *web.Session) bool ShouldHaveGuestCart(session *web.Session) bool ViewCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error) ViewGuestCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, error) ModifyBehaviour(ctx context.Context) (cartDomain.ModifyBehaviour, error) GetCart(ctx context.Context, session *web.Session) (*cartDomain.Cart, cartDomain.ModifyBehaviour, error) GetCartWithoutCache(ctx context.Context, session *web.Session) (*cartDomain.Cart, error) }
Receiver that provides functionality regarding fetching the cart
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
type Service ¶ added in v3.5.0
type Service interface { GetCartReceiverService() *CartReceiverService ValidateCart(ctx context.Context, session *web.Session, decoratedCart *decorator.DecoratedCart) validation.Result ValidateCurrentCart(ctx context.Context, session *web.Session) (validation.Result, error) UpdatePaymentSelection(ctx context.Context, session *web.Session, paymentSelection cartDomain.PaymentSelection) error UpdateBillingAddress(ctx context.Context, session *web.Session, billingAddress *cartDomain.Address) error UpdateDeliveryInfo(ctx context.Context, session *web.Session, deliveryCode string, deliveryInfo cartDomain.DeliveryInfoUpdateCommand) error UpdatePurchaser(ctx context.Context, session *web.Session, purchaser *cartDomain.Person, additionalData *cartDomain.AdditionalData) error UpdateItemQty(ctx context.Context, session *web.Session, itemID string, deliveryCode string, qty int) error UpdateItemSourceID(ctx context.Context, session *web.Session, itemID string, sourceID string) error UpdateItems(ctx context.Context, session *web.Session, updateCommands []cartDomain.ItemUpdateCommand) error DeleteItem(ctx context.Context, session *web.Session, itemID string, deliveryCode string) error DeleteAllItems(ctx context.Context, session *web.Session) error CompleteCurrentCart(ctx context.Context) (*cartDomain.Cart, error) RestoreCart(ctx context.Context, cart *cartDomain.Cart) (*cartDomain.Cart, error) Clean(ctx context.Context, session *web.Session) error DeleteDelivery(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error) // Deprecated: build your own add request BuildAddRequest(ctx context.Context, marketplaceCode string, variantMarketplaceCode string, qty int, additionalData map[string]string) cartDomain.AddRequest AddProduct(ctx context.Context, session *web.Session, deliveryCode string, addRequest cartDomain.AddRequest) (productDomain.BasicProduct, error) CreateInitialDeliveryIfNotPresent(ctx context.Context, session *web.Session, deliveryCode string) (*cartDomain.Cart, error) GetInitialDelivery(deliveryCode string) (*cartDomain.DeliveryInfo, error) ApplyVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error) ApplyAny(ctx context.Context, session *web.Session, anyCode string) (*cartDomain.Cart, error) RemoveVoucher(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error) ApplyGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error) RemoveGiftCard(ctx context.Context, session *web.Session, couponCode string) (*cartDomain.Cart, error) DeleteCartInCache(ctx context.Context, session *web.Session, cart *cartDomain.Cart) ReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error) ForceReserveOrderIDAndSave(ctx context.Context, session *web.Session) (*cartDomain.Cart, error) PlaceOrderWithCart(ctx context.Context, session *web.Session, cart *cartDomain.Cart, payment *placeorder.Payment) (placeorder.PlacedOrderInfos, error) PlaceOrder(ctx context.Context, session *web.Session, payment *placeorder.Payment) (placeorder.PlacedOrderInfos, error) CancelOrder(ctx context.Context, session *web.Session, orderInfos placeorder.PlacedOrderInfos, cart cartDomain.Cart) (*cartDomain.Cart, error) CancelOrderWithoutRestore(ctx context.Context, session *web.Session, orderInfos placeorder.PlacedOrderInfos) error GetDefaultDeliveryCode() string AdjustItemsToRestrictedQty(ctx context.Context, session *web.Session) (QtyAdjustmentResults, error) UpdateAdditionalData(ctx context.Context, session *web.Session, additionalData map[string]string) (*cartDomain.Cart, error) UpdateDeliveryAdditionalData(ctx context.Context, session *web.Session, deliveryCode string, additionalData map[string]string) (*cartDomain.Cart, error) }
Service that provides functionality regarding the cart