Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddToCartNotAllowed ¶
type AddToCartNotAllowed struct { Reason string RedirectHandlerName string RedirectParams map[string]string AdditionalData map[string]interface{} }
AddToCartNotAllowed error
func (*AddToCartNotAllowed) MessageCode ¶
func (e *AddToCartNotAllowed) MessageCode() string
MessageCode message code
type ItemValidationError ¶
ItemValidationError applies for a single item
type ItemValidator ¶
type ItemValidator interface {
Validate(ctx context.Context, session *web.Session, cart *decorator.DecoratedCart, deliveryCode string, request cart.AddRequest, product domain.BasicProduct) error
}
ItemValidator checks a cart item
type MaxQuantityRestrictor ¶
type MaxQuantityRestrictor interface { // Name returns the code of the restrictor Name() string // Restrict must return a `RestrictionResult` which contains information regarding if a restriction is // applied and whats the max allowed quantity. Might expect item id from context in implementation. Restrict(ctx context.Context, session *web.Session, product domain.BasicProduct, cart *cart.Cart, deliveryCode string) *RestrictionResult }
MaxQuantityRestrictor returns the maximum qty allowed for a given product and cart it is possible to register many (MultiBind) MaxQuantityRestrictor implementations
type PaymentSelectionValidator ¶ added in v3.3.0
type PaymentSelectionValidator interface {
Validate(ctx context.Context, cart *decorator.DecoratedCart, selection cart.PaymentSelection) error
}
PaymentSelectionValidator decides if the PaymentSelection is valid
type RestrictionResult ¶
type RestrictionResult struct { IsRestricted bool MaxAllowed int RemainingDifference int RestrictorName string }
RestrictionResult contains the result of a restriction
type RestrictionService ¶
type RestrictionService struct {
// contains filtered or unexported fields
}
RestrictionService checks product restriction
func (*RestrictionService) Inject ¶
func (rs *RestrictionService) Inject( qtyRestrictors []MaxQuantityRestrictor, ) *RestrictionService
Inject dependencies
func (*RestrictionService) RestrictQty ¶
func (rs *RestrictionService) RestrictQty(ctx context.Context, session *web.Session, product domain.BasicProduct, currentCart *cart.Cart, deliveryCode string) *RestrictionResult
RestrictQty checks if there is an qty restriction present and returns an according result containing the max allowed quantity and the quantity difference to the current cart. Restrictor might expect item id in context
type Result ¶
type Result struct { HasCommonError bool CommonErrorMessageKey string ItemResults []ItemValidationError }
Result groups the validation result
func (Result) GetErrorMessageKeyForItem ¶
GetErrorMessageKeyForItem returns the specific error message for that item
func (Result) HasErrorForItem ¶
HasErrorForItem checks if a specified item has an error