decorator

package
v3.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 7 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CartFromDecoratedCartFactoryContext added in v3.9.0

func CartFromDecoratedCartFactoryContext(ctx context.Context) *cartDomain.Cart

func DeliveryCodeFromDecoratedCartFactoryContext added in v3.10.0

func DeliveryCodeFromDecoratedCartFactoryContext(ctx context.Context) string

Types

type DecoratedCart

type DecoratedCart struct {
	Cart                cartDomain.Cart
	DecoratedDeliveries []DecoratedDelivery
	Ctx                 context.Context `json:"-"`
	Logger              flamingo.Logger `json:"-"`
}

DecoratedCart Decorates Access To a Cart

func (DecoratedCart) GetAllDecoratedItems

func (dc DecoratedCart) GetAllDecoratedItems() []DecoratedCartItem

GetAllDecoratedItems getter

func (DecoratedCart) GetDecoratedDeliveryByCode

func (dc DecoratedCart) GetDecoratedDeliveryByCode(deliveryCode string) (*DecoratedDelivery, bool)

GetDecoratedDeliveryByCode getter

func (DecoratedCart) GetDecoratedDeliveryByCodeWithoutBool

func (dc DecoratedCart) GetDecoratedDeliveryByCodeWithoutBool(deliveryCode string) *DecoratedDelivery

GetDecoratedDeliveryByCodeWithoutBool - used inside a template, therefor we need the method with a single return param

func (DecoratedCart) GetGroupedBy

func (dc DecoratedCart) GetGroupedBy(group string, sortGroup bool, params ...string) []*GroupedDecoratedCartItem

GetGroupedBy legacy function deprecated: only here to support the old structure of accesing DecoratedItems in the Decorated Cart Use instead:

or iterate over DecoratedCart.DecoratedDelivery

func (DecoratedCart) GrandTotalWithGiftCards added in v3.6.0

func (dc DecoratedCart) GrandTotalWithGiftCards() domain.Price

GrandTotalWithGiftCards calculate the grand total of the cart minus gift cards

func (DecoratedCart) HasAppliedDiscounts

func (dc DecoratedCart) HasAppliedDiscounts() bool

HasAppliedDiscounts checks whether decorated cart has discounts

func (DecoratedCart) HasAppliedGiftCards

func (dc DecoratedCart) HasAppliedGiftCards() bool

HasAppliedGiftCards checks if a gift card is applied to the cart

func (DecoratedCart) HasRemainingGiftCards

func (dc DecoratedCart) HasRemainingGiftCards() bool

HasRemainingGiftCards check whether there are gift cards with remaining balance

func (DecoratedCart) MergeDiscounts

func (dc DecoratedCart) MergeDiscounts() cart.AppliedDiscounts

MergeDiscounts sum up discounts applied to cart

func (DecoratedCart) TotalGiftCardAmount added in v3.6.0

func (dc DecoratedCart) TotalGiftCardAmount() domain.Price

TotalGiftCardAmount sum up all applied amounts of giftcads price is returned as a payable

type DecoratedCartFactory

type DecoratedCartFactory struct {
	// contains filtered or unexported fields
}

DecoratedCartFactory - Factory to be injected: If you need to create a new Decorator then get the factory injected and use the factory

func (*DecoratedCartFactory) Create

Create Factory method to get Decorated Cart

func (*DecoratedCartFactory) CreateDecorateCartItems

func (df *DecoratedCartFactory) CreateDecorateCartItems(ctx context.Context, items []cartDomain.Item) []DecoratedCartItem

CreateDecorateCartItems Factory method to get Decorated Cart

func (*DecoratedCartFactory) Inject

func (df *DecoratedCartFactory) Inject(
	productService domain.ProductService,
	logger flamingo.Logger,
)

Inject dependencies

type DecoratedCartItem

type DecoratedCartItem struct {
	Item    cartDomain.Item
	Product domain.BasicProduct
	// contains filtered or unexported fields
}

DecoratedCartItem Decorates a CartItem with its Product

func (DecoratedCartItem) GetChargesToPay

func (dci DecoratedCartItem) GetChargesToPay(wishedToPaySum *domain.WishedToPay) priceDomain.Charges

GetChargesToPay getter

func (DecoratedCartItem) GetDisplayMarketplaceCode

func (dci DecoratedCartItem) GetDisplayMarketplaceCode() string

GetDisplayMarketplaceCode getter

func (DecoratedCartItem) GetDisplayTitle

func (dci DecoratedCartItem) GetDisplayTitle() string

GetDisplayTitle getter

func (DecoratedCartItem) GetVariant

func (dci DecoratedCartItem) GetVariant() (*domain.Variant, error)

GetVariant getter

func (DecoratedCartItem) GetVariantsVariationAttributeCodes

func (dci DecoratedCartItem) GetVariantsVariationAttributeCodes() []string

GetVariantsVariationAttributeCodes getter

func (DecoratedCartItem) GetVariantsVariationAttributes

func (dci DecoratedCartItem) GetVariantsVariationAttributes() domain.Attributes

GetVariantsVariationAttributes getter

func (*DecoratedCartItem) HasAppliedDiscounts

func (dci *DecoratedCartItem) HasAppliedDiscounts() bool

HasAppliedDiscounts checks whether decorated item has discounts

func (DecoratedCartItem) IsConfigurable

func (dci DecoratedCartItem) IsConfigurable() bool

IsConfigurable - checks if current CartItem is a Configurable Product

func (DecoratedCartItem) MergeDiscounts

func (dci DecoratedCartItem) MergeDiscounts() cart.AppliedDiscounts

MergeDiscounts sum up discounts applied to item

type DecoratedDelivery

type DecoratedDelivery struct {
	Delivery       cartDomain.Delivery
	DecoratedItems []DecoratedCartItem
	// contains filtered or unexported fields
}

DecoratedDelivery Decorates a CartItem with its Product

func (DecoratedDelivery) GetDecoratedCartItemByID

func (dc DecoratedDelivery) GetDecoratedCartItemByID(ID string) *DecoratedCartItem

GetDecoratedCartItemByID getter

func (DecoratedDelivery) GetGroupedBy

func (dc DecoratedDelivery) GetGroupedBy(group string, sortGroup bool, params ...string) []*GroupedDecoratedCartItem

GetGroupedBy getter

func (DecoratedDelivery) HasAppliedDiscounts

func (dc DecoratedDelivery) HasAppliedDiscounts() bool

HasAppliedDiscounts checks whether decorated delivery has discounts

func (DecoratedDelivery) MergeDiscounts

func (dc DecoratedDelivery) MergeDiscounts() cart.AppliedDiscounts

MergeDiscounts sum up discounts applied to delivery

type DecoratedWithDiscount

type DecoratedWithDiscount interface {
	HasAppliedDiscounts() bool
	MergeDiscounts() cart.AppliedDiscounts
}

DecoratedWithDiscount interface for a decorated object to be able to handle discounts the difference to cart.WithDiscount is, that these functions do NOT provide the client with an error, errors are just logged

type DecoratedWithGiftCard

type DecoratedWithGiftCard interface {
	HasRemainingGiftCards() bool
	HasAppliedGiftCards() bool
	TotalGiftCardAmount() domain.Price
	GrandTotalWithGiftCards() domain.Price
}

DecoratedWithGiftCard interface for a decorated object to be able to handle giftcards the difference to cart.WithGiftCard is, that these functions do NOT provide the client with an error, errors are just logged

type GroupedDecoratedCartItem

type GroupedDecoratedCartItem struct {
	DecoratedItems []DecoratedCartItem
	Group          string
}

GroupedDecoratedCartItem - value object used for grouping (generated on the fly)

Jump to

Keyboard shortcuts

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