Back to godoc.org

Package cart

v3.3.0
Latest Go to latest

The highest tagged major version is v3.

Published: Aug 12, 2020 | License: OSL-3.0 | Module: flamingo.me/flamingo-commerce/v3

Index

Constants

const (
	TotalsTypeDiscount      = "totals_type_discount"
	TotalsTypeVoucher       = "totals_type_voucher"
	TotalsTypeTax           = "totals_type_tax"
	TotalsTypeLoyaltypoints = "totals_loyaltypoints"
	TotalsTypeShipping      = "totals_type_shipping"
)

Key constants

const (
	//DeliveryWorkflowPickup - constant for common delivery workflows
	DeliveryWorkflowPickup = "pickup"
	//DeliveryWorkflowDelivery - workflow constant
	DeliveryWorkflowDelivery = "delivery"
	//DeliveryWorkflowUnspecified - workflow constant
	DeliveryWorkflowUnspecified = "unspecified"

	//DeliverylocationTypeUnspecified - constant
	DeliverylocationTypeUnspecified = "unspecified"
	//DeliverylocationTypeCollectionpoint - constant
	DeliverylocationTypeCollectionpoint = "collection-point"
	//DeliverylocationTypeStore - constant
	DeliverylocationTypeStore = "store"
	//DeliverylocationTypeAddress - constant
	DeliverylocationTypeAddress = "address"
	//DeliverylocationTypeFreightstation - constant
	DeliverylocationTypeFreightstation = "freight-station"
)

Variables

var (
	// ErrCartNotFound is used if a cart was not found
	ErrCartNotFound = errors.New("Cart not found")
	// ErrItemNotFound is used if a item on cart was not found
	ErrItemNotFound = errors.New("Item not found")
	// ErrDeliveryCodeNotFound is used if a delivery was not found
	ErrDeliveryCodeNotFound = errors.New("Delivery not found")
)
var (

	// ErrSplitNoGiftCards indicates that there are no gift cards given to PaymentSplitWithGiftCards
	ErrSplitNoGiftCards = errors.New("no gift cards applied")

	// ErrSplitEmptyGiftCards indicates that there are gift cards given but with 0 applied balance
	ErrSplitEmptyGiftCards = errors.New("applied gift cards are empty")

	// ErrSplitGiftCardsExceedTotal indicates that gift card sum exceeds total of prices items
	ErrSplitGiftCardsExceedTotal = errors.New("gift card amount exceeds total priced items value")

	// ErrSplitGiftCardsNoChargeTypeMapping indicates that there is no mapping from the gift card charge type to an actual payment method
	ErrSplitGiftCardsNoChargeTypeMapping = fmt.Errorf("payment method for charge type %q not defined", price.ChargeTypeGiftCard)

	// ErrPaymentSelectionNotSet is used for nil PaymentSelection on cart
	ErrPaymentSelectionNotSet = errors.New("paymentSelection not set")
)
var (
	// ErrAdditionalInfosNotFound is returned if the additional infos are not set
	ErrAdditionalInfosNotFound = errors.New("additional infos not found")
)

type AddRequest

type AddRequest struct {
	MarketplaceCode        string
	Qty                    int
	VariantMarketplaceCode string
	AdditionalData         map[string]string
}

AddRequest defines add to cart request

type AdditionalData

type AdditionalData struct {
	//CustomAttributes list of key values
	CustomAttributes map[string]string
	// ReservedOrderID is an ID already known by the Cart of the future order ID
	ReservedOrderID string
}

AdditionalData defines the supplementary cart data

type AdditionalDeliverInfo

type AdditionalDeliverInfo interface {
	Marshal() (json.RawMessage, error)
	Unmarshal(json.RawMessage) error
}

AdditionalDeliverInfo is an interface that allows to store "any" additional objects on the cart see DeliveryInfoUpdateCommand

type Address

type Address struct {
	Vat                    string
	Firstname              string
	Lastname               string
	MiddleName             string
	Title                  string
	Salutation             string
	Street                 string
	StreetNr               string
	AdditionalAddressLines []string
	Company                string
	City                   string
	PostCode               string
	State                  string
	RegionCode             string
	Country                string
	CountryCode            string
	Telephone              string
	Email                  string
}

Address defines a cart address

func (Address) FullName

func (a Address) FullName() string

FullName - return Firstname Lastname

func (*Address) IsEmpty

func (a *Address) IsEmpty() bool

IsEmpty checks all fields of the address if they are empty

type AppliedCouponCodes

type AppliedCouponCodes []CouponCode

AppliedCouponCodes slice of applied coupon codes

func (AppliedCouponCodes) ContainedIn

func (acc AppliedCouponCodes) ContainedIn(couponCodesToCompare AppliedCouponCodes) bool

ContainedIn - returns if the coupon codes are contained in couponCodesToCompare

type AppliedDiscount

type AppliedDiscount struct {
	CampaignCode  string       // unique code of the underlying campaign or rule e.g. "summer-campaign-2018"
	CouponCode    string       // code of discount e.g. provided by user "summer2018"
	Label         string       // readable name of discount "Super Summer Sale 2018"
	Applied       domain.Price // how much of the discount has been subtracted from cart price, IMPORTANT: always negative
	Type          string       // to distinguish between discounts
	IsItemRelated bool         // flag indicating if the discount is applied due to item in cart
	SortOrder     int          // indicates in which order discount have been applied, low value has been applied before high value
}

AppliedDiscount value object - generic reference for a discount

type AppliedDiscounts

type AppliedDiscounts []AppliedDiscount

AppliedDiscounts represents multiple discounts that are subtracted from total price of cart

func (AppliedDiscounts) ByCampaignCode

func (discounts AppliedDiscounts) ByCampaignCode(campaignCode string) AppliedDiscounts

ByCampaignCode filter AppliedDiscounts based on provided campaign code

func (AppliedDiscounts) ByType

func (discounts AppliedDiscounts) ByType(filterType string) AppliedDiscounts

ByType filter AppliedDiscounts based on type

func (AppliedDiscounts) Items

func (discounts AppliedDiscounts) Items() []AppliedDiscount

Items getter for graphql integration

func (AppliedDiscounts) Sum

func (discounts AppliedDiscounts) Sum() (domain.Price, error)

Sum returns the sum of the applied values of the AppliedDiscounts

type AppliedGiftCard

type AppliedGiftCard struct {
	Code             string
	Applied          domain.Price           // how much of the gift card has been subtracted from cart price
	Remaining        domain.Price           // how much of the gift card is still available
	CustomAttributes map[string]interface{} // additional custom attributes
}

AppliedGiftCard value object represents a gift card (partial payment) on the cart

func (AppliedGiftCard) HasRemaining

func (card AppliedGiftCard) HasRemaining() bool

HasRemaining checks whether gift card has a remaining balance

func (AppliedGiftCard) Total

func (card AppliedGiftCard) Total() (domain.Price, error)

Total returns the total value of the gift card by adding what is applied and remaining In case the values cannot be added the function returns the remaining amount of the giftcard and an error

type AppliedGiftCards

type AppliedGiftCards []AppliedGiftCard

AppliedGiftCards convenience wrapper for array of applied gift cards

func (*AppliedGiftCards) ByRemaining

func (cards *AppliedGiftCards) ByRemaining() AppliedGiftCards

ByRemaining fetches gift cards that still have a remaining value from applied gift cards

func (*AppliedGiftCards) GiftCardByCode

func (cards *AppliedGiftCards) GiftCardByCode(code string) (*AppliedGiftCard, bool)

GiftCardByCode returns a single gift card if the given code matches its code. First return parameter is the gift card if found and the second return parameter is a boolean depicting if a gift card was found

type Builder

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

Builder - the main builder for a cart

func (*Builder) AddAppliedCouponCode

func (b *Builder) AddAppliedCouponCode(code CouponCode) *Builder

AddAppliedCouponCode - optional - add the coupon that is applied for the cart

func (*Builder) AddDelivery

func (b *Builder) AddDelivery(d Delivery) *Builder

AddDelivery - add a delivery subobject - use the DeliveryBuilder todo Make sure that item id is unique over the whole cart (that is an invariant so we need to ensure that invalid cart objects cannot be build)

func (*Builder) AddTotalitem

func (b *Builder) AddTotalitem(totali Totalitem) *Builder

AddTotalitem - adds nontaxable extra totals on cartlevel

func (*Builder) Build

func (b *Builder) Build() (*Cart, error)

Build - main factory method

func (*Builder) SetAdditionalData

func (b *Builder) SetAdditionalData(d AdditionalData) *Builder

SetAdditionalData - to add additional data

func (*Builder) SetAppliedGiftCards

func (b *Builder) SetAppliedGiftCards(gc []AppliedGiftCard) *Builder

SetAppliedGiftCards - optional - sets the applied gift cards

func (*Builder) SetAuthenticatedUserID

func (b *Builder) SetAuthenticatedUserID(id string) *Builder

SetAuthenticatedUserID - to mark the art as authenticated users cart

func (*Builder) SetBelongsToAuthenticatedUser

func (b *Builder) SetBelongsToAuthenticatedUser(v bool) *Builder

SetBelongsToAuthenticatedUser - mark the art as authenticated users cart

func (*Builder) SetBillingAddress

func (b *Builder) SetBillingAddress(a Address) *Builder

SetBillingAddress - optional

func (*Builder) SetDefaultCurrency

func (b *Builder) SetDefaultCurrency(d string) *Builder

SetDefaultCurrency - sets the default currency

func (*Builder) SetIds

func (b *Builder) SetIds(id string, entityID string) *Builder

SetIds - sets the cart ids

func (*Builder) SetPaymentSelection

func (b *Builder) SetPaymentSelection(d PaymentSelection) *Builder

SetPaymentSelection - to add additional data

func (*Builder) SetPurchaser

func (b *Builder) SetPurchaser(p Person) *Builder

SetPurchaser - optional

func (*Builder) SetReservedOrderID

func (b *Builder) SetReservedOrderID(id string) *Builder

SetReservedOrderID - optional

type BuilderProvider

type BuilderProvider func() *Builder

BuilderProvider should be used to create the cart by using the Builder

type Cart

type Cart struct {
	//ID is the main identifier of the cart
	ID string
	//EntityID is a second identifier that may be used by some backends
	EntityID string

	//BillingAddress - the main billing address (relevant for all payments/invoices)
	BillingAddress *Address

	//Purchaser - additional infos for the legal contact person in this order
	Purchaser *Person

	//Deliveries - list of desired Deliveries (or Shipments) involved in this cart
	Deliveries []Delivery

	//AdditionalData   can be used for Custom attributes
	AdditionalData AdditionalData

	//PaymentSelection - the saved PaymentSelection (saves "how" the customer want to pay)
	PaymentSelection PaymentSelection

	//BelongsToAuthenticatedUser - false = Guest Cart true = cart from the authenticated user
	BelongsToAuthenticatedUser bool
	AuthenticatedUserID        string

	AppliedCouponCodes []CouponCode

	DefaultCurrency string

	//Additional non taxable totals
	Totalitems []Totalitem

	//List of applied gift cards
	AppliedGiftCards []AppliedGiftCard
}

Cart Value Object (immutable data - because the cartservice is responsible to return a cart).

func (Cart) AllShippingTitles

func (c Cart) AllShippingTitles() []string

AllShippingTitles - returns all ShippingItem titles

func (Cart) GetAllPaymentRequiredItems

func (c Cart) GetAllPaymentRequiredItems() PricedItems

GetAllPaymentRequiredItems - returns all the Items (Cartitem, ShippingItem, TotalItems) that need to be paid with the final gross price

func (Cart) GetByExternalReference

func (c Cart) GetByExternalReference(ref string) (*Item, error)

GetByExternalReference gets an item by its external reference

func (Cart) GetByItemID

func (c Cart) GetByItemID(itemID string) (*Item, error)

GetByItemID gets an item by its id

func (Cart) GetCartTeaser

func (c Cart) GetCartTeaser() *Teaser

GetCartTeaser returns the teaser

func (Cart) GetDeliveryByCode

func (c Cart) GetDeliveryByCode(deliveryCode string) (*Delivery, bool)

GetDeliveryByCode gets a delivery by code

func (Cart) GetDeliveryByCodeWithoutBool

func (c Cart) GetDeliveryByCodeWithoutBool(deliveryCode string) *Delivery

GetDeliveryByCodeWithoutBool TODO: This func needs to be removed as soon as there's a solution for handling of boolean returns when gql expects an err

func (Cart) GetDeliveryByItemID

func (c Cart) GetDeliveryByItemID(itemID string) (*Delivery, error)

GetDeliveryByItemID returns a delivery by a given itemID

func (Cart) GetDeliveryCodes

func (c Cart) GetDeliveryCodes() []string

GetDeliveryCodes returns a slice of all delivery codes in cart that have at least one cart item

func (Cart) GetMainShippingEMail

func (c Cart) GetMainShippingEMail() string

GetMainShippingEMail returns the main shipping address email, empty string if not available

func (Cart) GetPaymentReference

func (c Cart) GetPaymentReference() string

GetPaymentReference - Returns a string that can be used as reference to pass to payment gateway. You may want to use it. It returns either the reserved Order id or the cart id/entityid

func (Cart) GetTotalItemsByType

func (c Cart) GetTotalItemsByType(typeCode string) []Totalitem

GetTotalItemsByType gets a slice of all Totalitems by typeCode

func (Cart) GetTotalQty

func (c Cart) GetTotalQty(marketPlaceCode string, variantCode string) int

GetTotalQty for the product in the cart

func (Cart) GetVoucherSavings

func (c Cart) GetVoucherSavings() domain.Price

GetVoucherSavings returns the savings of all vouchers

func (Cart) GrandTotal

func (c Cart) GrandTotal() domain.Price

GrandTotal - Final sum (Valued price) that need to be paid: GrandTotal = SubTotal + TaxAmount - DiscountAmount + SOME of Totalitems = (Sum of Items RowTotalWithDiscountInclTax) + SOME of Totalitems

func (Cart) GrandTotalCharges

func (c Cart) GrandTotalCharges() domain.Charges

GrandTotalCharges - Final sum that need to be paid - splitted by the charges that need to be paid

func (Cart) HasAppliedCouponCode

func (c Cart) HasAppliedCouponCode() bool

HasAppliedCouponCode checks if a coupon code is applied to the cart

func (*Cart) HasAppliedDiscounts

func (c *Cart) HasAppliedDiscounts() (bool, error)

HasAppliedDiscounts check whether there are any discounts currently applied to the cart

func (Cart) HasAppliedGiftCards

func (c Cart) HasAppliedGiftCards() bool

HasAppliedGiftCards checks if a gift card is applied to the cart

func (Cart) HasDeliveryForCode

func (c Cart) HasDeliveryForCode(deliveryCode string) bool

HasDeliveryForCode checks if a delivery with the given code exists in the cart

func (Cart) HasRemainingGiftCards

func (c Cart) HasRemainingGiftCards() bool

HasRemainingGiftCards check whether there are gift cards with remaining balance

func (Cart) HasShippingCosts

func (c Cart) HasShippingCosts() bool

HasShippingCosts - returns true if cart HasShippingCosts

func (Cart) IsEmpty

func (c Cart) IsEmpty() bool

IsEmpty - returns true if cart is empty

func (Cart) IsPaymentSelected

func (c Cart) IsPaymentSelected() bool

IsPaymentSelected - returns true if a valid payment is selected

func (Cart) ItemCount

func (c Cart) ItemCount() int

ItemCount - returns amount of Cartitems

func (*Cart) MergeDiscounts

func (c *Cart) MergeDiscounts() (AppliedDiscounts, error)

MergeDiscounts sums up discounts of cart based on its deliveries All discounts with the same campaign code are aggregated and returned as one with a summed price

func (Cart) ProductCount

func (c Cart) ProductCount() int

ProductCount returns the amount of different products, but a product is counted twice if it is in different deliveries

func (Cart) ProductCountUnique

func (c Cart) ProductCountUnique() int

ProductCountUnique returns the amount of unique products across all deliveries

func (Cart) SubTotalGross

func (c Cart) SubTotalGross() domain.Price

SubTotalGross - returns sum price of deliveries SubTotalGross

func (Cart) SubTotalGrossWithDiscounts

func (c Cart) SubTotalGrossWithDiscounts() domain.Price

SubTotalGrossWithDiscounts - returns sum price of deliveries SubTotalGrossWithDiscounts

func (Cart) SubTotalNet

func (c Cart) SubTotalNet() domain.Price

SubTotalNet - returns sum price of deliveries SubTotalNet

func (Cart) SubTotalNetWithDiscounts

func (c Cart) SubTotalNetWithDiscounts() domain.Price

SubTotalNetWithDiscounts - returns sum price of deliveries SubTotalNetWithDiscounts

func (Cart) SumAppliedGiftCards

func (c Cart) SumAppliedGiftCards() (domain.Price, error)

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

func (Cart) SumGrandTotalWithGiftCards

func (c Cart) SumGrandTotalWithGiftCards() (domain.Price, error)

SumGrandTotalWithGiftCards calculate the grand total of the cart minus gift cards

func (Cart) SumItemRelatedDiscountAmount

func (c Cart) SumItemRelatedDiscountAmount() domain.Price

SumItemRelatedDiscountAmount - returns sum price of deliveries SumItemRelatedDiscountAmount

func (Cart) SumNonItemRelatedDiscountAmount

func (c Cart) SumNonItemRelatedDiscountAmount() domain.Price

SumNonItemRelatedDiscountAmount - returns sum price of deliveries SumNonItemRelatedDiscountAmount

func (Cart) SumShippingNet

func (c Cart) SumShippingNet() domain.Price

SumShippingNet - returns net sum price of deliveries ShippingItems

func (Cart) SumShippingNetWithDiscounts

func (c Cart) SumShippingNetWithDiscounts() domain.Price

SumShippingNetWithDiscounts - returns net sum price of deliveries ShippingItems with discounts

func (Cart) SumTaxes

func (c Cart) SumTaxes() Taxes

SumTaxes - returns sum of deliveries SumRowTaxes

func (Cart) SumTotalDiscountAmount

func (c Cart) SumTotalDiscountAmount() domain.Price

SumTotalDiscountAmount - returns sum price of deliveries SumTotalDiscountAmount

func (Cart) SumTotalTaxAmount

func (c Cart) SumTotalTaxAmount() domain.Price

SumTotalTaxAmount - returns sum price of deliveries Taxes as total amount

type CompleteBehaviour

type CompleteBehaviour interface {
	Complete(context.Context, *Cart) (*Cart, DeferEvents, error)
	// Restore should reopen the cart while maintaining the previously used cart id
	Restore(context.Context, *Cart) (*Cart, DeferEvents, error)
}

CompleteBehaviour can be implemented by a cart service. Complete is normally called before the cart is placed This can for example be used to invalidate gift cards

type CouponCode

type CouponCode struct {
	Code string
	// CustomAttributes can hold additional data for coupon code - keys and values are project specific
	CustomAttributes map[string]interface{}
}

CouponCode value object

type CustomerCartService

type CustomerCartService interface {
	// GetModifyBehaviour gets the behaviour for the customer cart service
	GetModifyBehaviour(context.Context, auth.Identity) (ModifyBehaviour, error)
	GetCart(ctx context.Context, identity auth.Identity, cartID string) (*Cart, error)
	// RestoreCart restores a previously used customer cart with all its content.
	// Depending on the used adapter this can lead to a new Cart.ID
	// Deprecated: Implement CompleteBehaviour instead
	RestoreCart(ctx context.Context, identity auth.Identity, cart Cart) (*Cart, error)
}

CustomerCartService interface - Secondary PORT

type DefaultDeliveryInfoBuilder

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

DefaultDeliveryInfoBuilder defines the default delivery info builder used

func (*DefaultDeliveryInfoBuilder) BuildByDeliveryCode

func (b *DefaultDeliveryInfoBuilder) BuildByDeliveryCode(deliverycode string) (*DeliveryInfo, error)

BuildByDeliveryCode builds a (initial) DeliveryInfo by deliveryCode Convention that is used in this factory is to split infos in the build deliveryinfo by "_" like this:

	* workflow_locationtype_locationdetail_method_anythingelse
 * not all parts are required
	* to "skip" parts in between use "-"

func (*DefaultDeliveryInfoBuilder) Inject

func (b *DefaultDeliveryInfoBuilder) Inject(
	logger flamingo.Logger,
	config *struct {
		DefaultUseBillingAddress bool `inject:"config:commerce.cart.defaultUseBillingAddress,optional"`
	},
)

Inject dependencies

type DefaultPaymentSelection

type DefaultPaymentSelection struct {
	// GatewayProp - the selected Gateway
	GatewayProp        string
	ChargedItemsProp   PaymentSplitByItem
	IdempotencyKeyUUID string
}

DefaultPaymentSelection value object - that implements the PaymentSelection interface

func (DefaultPaymentSelection) CartSplit

func (d DefaultPaymentSelection) CartSplit() PaymentSplit

CartSplit - the selected split per ChargeType and PaymentMethod

func (DefaultPaymentSelection) Gateway

func (d DefaultPaymentSelection) Gateway() string

Gateway - returns the selected Gateway code

func (DefaultPaymentSelection) GenerateNewIdempotencyKey

func (d DefaultPaymentSelection) GenerateNewIdempotencyKey() (PaymentSelection, error)

GenerateNewIdempotencyKey updates the Idempotency-Key to a new value

func (DefaultPaymentSelection) IdempotencyKey

func (d DefaultPaymentSelection) IdempotencyKey() string

IdempotencyKey returns the Idempotency-Key for this payment selection

func (DefaultPaymentSelection) ItemSplit

func (d DefaultPaymentSelection) ItemSplit() PaymentSplitByItem

ItemSplit - the selected split per ChargeType and PaymentMethod

func (DefaultPaymentSelection) MarshalJSON

func (d DefaultPaymentSelection) MarshalJSON() ([]byte, error)

MarshalJSON adds the Idempotency-Key to the payment selection json

func (DefaultPaymentSelection) MethodByType

func (d DefaultPaymentSelection) MethodByType(chargeType string) string

MethodByType returns the payment method by charge type

func (DefaultPaymentSelection) TotalValue

func (d DefaultPaymentSelection) TotalValue() price.Price

TotalValue - returns Valued price sum

type DeferEvents

type DeferEvents []flamingo.Event

DeferEvents represents events that should be dispatched after a cart modify call

type Delivery

type Delivery struct {
	//DeliveryInfo - The details for this delivery - normally completed during checkout
	DeliveryInfo DeliveryInfo
	//Cartitems - list of cartitems
	Cartitems []Item
	//ShippingItem	- The Shipping Costs that may be involved in this delivery
	ShippingItem ShippingItem
}

Delivery - represents the DeliveryInfo and the assigned Items

func (Delivery) GrandTotal

func (d Delivery) GrandTotal() priceDomain.Price

GrandTotal - returns SubTotalGross including shipping and discounts - for the Delivery

func (*Delivery) HasAppliedDiscounts

func (d *Delivery) HasAppliedDiscounts() (bool, error)

HasAppliedDiscounts check whether there are any discounts currently applied to the delivery

func (Delivery) HasItems

func (d Delivery) HasItems() bool

HasItems - returns true if there are items under the delivery

func (*Delivery) MergeDiscounts

func (d *Delivery) MergeDiscounts() (AppliedDiscounts, error)

MergeDiscounts sums up discounts of a delivery based on its single item discounts All discounts with the same campaign code are aggregated and returned as one with a summed price

func (Delivery) SubTotalGross

func (d Delivery) SubTotalGross() priceDomain.Price

SubTotalGross - returns SubTotalGross

func (Delivery) SubTotalGrossWithDiscounts

func (d Delivery) SubTotalGrossWithDiscounts() priceDomain.Price

SubTotalGrossWithDiscounts returns SubTotalGrossWithDiscounts

func (Delivery) SubTotalNet

func (d Delivery) SubTotalNet() priceDomain.Price

SubTotalNet - returns SubTotalNet

func (Delivery) SubTotalNetWithDiscounts

func (d Delivery) SubTotalNetWithDiscounts() priceDomain.Price

SubTotalNetWithDiscounts - returns SubTotalNet With Discounts

func (Delivery) SumItemRelatedDiscountAmount

func (d Delivery) SumItemRelatedDiscountAmount() priceDomain.Price

SumItemRelatedDiscountAmount - returns SumItemRelatedDiscountAmount

func (Delivery) SumNonItemRelatedDiscountAmount

func (d Delivery) SumNonItemRelatedDiscountAmount() priceDomain.Price

SumNonItemRelatedDiscountAmount returns SumNonItemRelatedDiscountAmount

func (Delivery) SumRowTaxes

func (d Delivery) SumRowTaxes() Taxes

SumRowTaxes - returns SumRowTaxes

func (Delivery) SumTotalDiscountAmount

func (d Delivery) SumTotalDiscountAmount() priceDomain.Price

SumTotalDiscountAmount - returns SumTotalDiscountAmount

func (Delivery) SumTotalTaxAmount

func (d Delivery) SumTotalTaxAmount() priceDomain.Price

SumTotalTaxAmount - returns SumTotalTaxAmount

type DeliveryBuilder

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

DeliveryBuilder - the Builder (factory) to build new deliveries by making sure the invariants are ok

func (*DeliveryBuilder) AddItem

func (f *DeliveryBuilder) AddItem(i Item) *DeliveryBuilder

AddItem adds an item to the delivery

func (*DeliveryBuilder) Build

func (f *DeliveryBuilder) Build() (*Delivery, error)

Build - main Factory method

func (*DeliveryBuilder) Copy

func (f *DeliveryBuilder) Copy(d *Delivery) *DeliveryBuilder

Copy - use to set the values for the new delivery from an existing delivery by copying it

func (*DeliveryBuilder) SetDeliveryCode

func (f *DeliveryBuilder) SetDeliveryCode(code string) *DeliveryBuilder

SetDeliveryCode - sets the deliverycode (dont need to be called if SetDeliveryInfo has a code set already)

func (*DeliveryBuilder) SetDeliveryInfo

func (f *DeliveryBuilder) SetDeliveryInfo(i DeliveryInfo) *DeliveryBuilder

SetDeliveryInfo - sets DeliveryInfo

func (*DeliveryBuilder) SetShippingItem

func (f *DeliveryBuilder) SetShippingItem(i ShippingItem) *DeliveryBuilder

SetShippingItem - sets the delivery ShippingItem

type DeliveryBuilderProvider

type DeliveryBuilderProvider func() *DeliveryBuilder

DeliveryBuilderProvider should be used to create a Delivery

type DeliveryInfo

type DeliveryInfo struct {
	// Code - is a project specific identifier for the Delivery - you need it for the AddToCart Request for example
	// The code can follow the convention in the Readme: Type_Method_LocationType_LocationCode
	Code string
	//Type - The Type of the Delivery - e.g. delivery or pickup - this might trigger different workflows
	Workflow string
	//Method - The shippingmethod something that is project specific and that can mean different delivery qualities with different deliverycosts
	Method string
	//Carrier - Optional the name of the Carrier that should be responsible for executing the delivery
	Carrier string
	//DeliveryLocation The target Location for the delivery
	DeliveryLocation DeliveryLocation
	//DesiredTime - Optional - the desired time of the delivery
	DesiredTime time.Time
	//AdditionalData  - Possibility for key value based information on the delivery - can be used flexible by each project
	AdditionalData map[string]string
	//AdditionalDeliveryInfos - similar to AdditionalData this can be used to store "any" other object on a delivery encoded as json.RawMessage
	AdditionalDeliveryInfos map[string]json.RawMessage `swaggerignore:"true"`
}

DeliveryInfo - represents the Delivery

func (DeliveryInfo) AdditionalDataKeys

func (di DeliveryInfo) AdditionalDataKeys() []string

AdditionalDataKeys lists all available keys

func (DeliveryInfo) AdditionalDeliveryInfoKeys

func (di DeliveryInfo) AdditionalDeliveryInfoKeys() []string

AdditionalDeliveryInfoKeys lists all available keys

func (DeliveryInfo) GetAdditionalData

func (di DeliveryInfo) GetAdditionalData(key string) string

GetAdditionalData returns additional data

func (DeliveryInfo) GetAdditionalDeliveryInfo

func (di DeliveryInfo) GetAdditionalDeliveryInfo(key string) json.RawMessage

GetAdditionalDeliveryInfo returns additional delivery info

func (*DeliveryInfo) LoadAdditionalInfo

func (di *DeliveryInfo) LoadAdditionalInfo(key string, info AdditionalDeliverInfo) error

LoadAdditionalInfo - returns the additional Data

type DeliveryInfoBuilder

type DeliveryInfoBuilder interface {
	BuildByDeliveryCode(deliveryCode string) (*DeliveryInfo, error)
}

DeliveryInfoBuilder - Factory

type DeliveryInfoUpdateCommand

type DeliveryInfoUpdateCommand struct {
	DeliveryInfo DeliveryInfo
	// contains filtered or unexported fields
}

DeliveryInfoUpdateCommand defines the update item command

func CreateDeliveryInfoUpdateCommand

func CreateDeliveryInfoUpdateCommand(info DeliveryInfo) DeliveryInfoUpdateCommand

CreateDeliveryInfoUpdateCommand - factory to get the update command based on the given deliveryInfos (which might come from cart)

func (*DeliveryInfoUpdateCommand) AddAdditional

func (d *DeliveryInfoUpdateCommand) AddAdditional(key string, val AdditionalDeliverInfo) (err error)

AddAdditional adds additional delivery info data

func (*DeliveryInfoUpdateCommand) Additional

func (d *DeliveryInfoUpdateCommand) Additional() map[string]json.RawMessage

Additional gets the additional data as war map from the delivery info update command

func (*DeliveryInfoUpdateCommand) SetAdditional

func (d *DeliveryInfoUpdateCommand) SetAdditional(val map[string]json.RawMessage)

SetAdditional adds additional delivery info data

type DeliveryLocation

type DeliveryLocation struct {
	//Type - the type of the delivery - use some of the constant defined in the package like DeliverylocationTypeAddress
	Type string
	//Address -  (only relevant for type address)
	Address *Address
	//UseBillingAddress - the address should be taken from billing (only relevant for type address)
	UseBillingAddress bool
	//Code - optional identifier of this location/destination - is used in special destination Types
	Code string
}

DeliveryLocation value object

type ExistingCustomerData

type ExistingCustomerData struct {
	//ID of the customer
	ID string
}

ExistingCustomerData value object

type GiftCardAndVoucherBehaviour

type GiftCardAndVoucherBehaviour interface {
	ApplyAny(ctx context.Context, cart *Cart, anyCode string) (*Cart, DeferEvents, error)
}

GiftCardAndVoucherBehaviour - additional interface that can be implemented to support generic code entry (which can either be voucher or giftcard)

type GiftCardBehaviour

type GiftCardBehaviour interface {
	ApplyGiftCard(ctx context.Context, cart *Cart, giftCardCode string) (*Cart, DeferEvents, error)
	RemoveGiftCard(ctx context.Context, cart *Cart, giftCardCode string) (*Cart, DeferEvents, error)
}

GiftCardBehaviour - additional interface that can be implemented to support GiftCard features

type GuestCartService

type GuestCartService interface {
	// GetModifyBehaviour gets the behaviour for the guest cart service
	GetModifyBehaviour(context.Context) (ModifyBehaviour, error)
	GetCart(ctx context.Context, cartID string) (*Cart, error)
	// GetNewCart - should return a new guest cart (including the id of the cart)
	GetNewCart(ctx context.Context) (*Cart, error)
	// RestoreCart restores a previously used guest cart with all its content.
	// Depending on the used adapter this can lead to a new Cart.ID
	// Deprecated: Implement CompleteBehaviour instead
	RestoreCart(ctx context.Context, cart Cart) (*Cart, error)
}

GuestCartService interface - Secondary PORT

type InvalidateCartEvent

type InvalidateCartEvent struct {
	Session *web.Session
}

InvalidateCartEvent value object

type Item

type Item struct {
	// ID of the item - needs to be unique over the whole cart
	ID string
	// ExternalReference can be used by cart service implementations to separate the representation in an external
	// cart service from the unique item ID
	ExternalReference string
	MarketplaceCode   string
	// VariantMarketPlaceCode is used for Configurable products
	VariantMarketPlaceCode string
	ProductName            string

	// Source Id of where the items should be initial picked - This is set by the SourcingLogic
	SourceID string

	Qty int

	AdditionalData map[string]string

	// SinglePriceGross brutto (gross) for single product
	SinglePriceGross priceDomain.Price

	// SinglePriceNet net price for single product
	SinglePriceNet priceDomain.Price

	// RowPriceGross
	RowPriceGross priceDomain.Price

	// RowPriceNet
	RowPriceNet priceDomain.Price

	// RowPriceGross
	RowTaxes Taxes

	// AppliedDiscounts contains the details about the discounts applied to this item - they can be "itemrelated" or not
	AppliedDiscounts AppliedDiscounts
}

Item for Cart

func (Item) AdditionalDataKeys

func (i Item) AdditionalDataKeys() []string

AdditionalDataKeys lists all available keys

func (Item) AdditionalDataValues

func (i Item) AdditionalDataValues() []string

AdditionalDataValues lists all values

func (Item) GetAdditionalData

func (i Item) GetAdditionalData(key string) string

GetAdditionalData returns a specified attribute

func (Item) HasAdditionalDataKey

func (i Item) HasAdditionalDataKey(key string) bool

HasAdditionalDataKey checks if an attribute is available

func (*Item) HasAppliedDiscounts

func (i *Item) HasAppliedDiscounts() (bool, error)

HasAppliedDiscounts check whether there are any discounts currently applied to the item

func (Item) ItemRelatedDiscountAmount

func (i Item) ItemRelatedDiscountAmount() priceDomain.Price

ItemRelatedDiscountAmount = Sum of AppliedDiscounts where IsItemRelated = True

func (*Item) MergeDiscounts

func (i *Item) MergeDiscounts() (AppliedDiscounts, error)

MergeDiscounts parses discounts of a single item All discounts with the same campaign code are aggregated and returned as one with a summed price

func (Item) NonItemRelatedDiscountAmount

func (i Item) NonItemRelatedDiscountAmount() priceDomain.Price

NonItemRelatedDiscountAmount = Sum of AppliedDiscounts where IsItemRelated = false

func (Item) RowPriceGrossWithDiscount

func (i Item) RowPriceGrossWithDiscount() priceDomain.Price

RowPriceGrossWithDiscount = RowPriceGross-TotalDiscountAmount()

func (Item) RowPriceGrossWithItemRelatedDiscount

func (i Item) RowPriceGrossWithItemRelatedDiscount() priceDomain.Price

RowPriceGrossWithItemRelatedDiscount = RowPriceGross-ItemRelatedDiscountAmount()

func (Item) RowPriceNetWithDiscount

func (i Item) RowPriceNetWithDiscount() priceDomain.Price

RowPriceNetWithDiscount = RowPriceNet-TotalDiscountAmount()

func (Item) RowPriceNetWithItemRelatedDiscount

func (i Item) RowPriceNetWithItemRelatedDiscount() priceDomain.Price

RowPriceNetWithItemRelatedDiscount =RowTotal-ItemRelatedDiscountAmount

func (Item) TotalDiscountAmount

func (i Item) TotalDiscountAmount() priceDomain.Price

TotalDiscountAmount gets the savings by item

func (Item) TotalTaxAmount

func (i Item) TotalTaxAmount() priceDomain.Price

TotalTaxAmount - returns total tax amount as price

type ItemBuilder

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

ItemBuilder can be used to construct an item with a fluent interface

func (*ItemBuilder) AddDiscount

func (f *ItemBuilder) AddDiscount(discount AppliedDiscount) *ItemBuilder

AddDiscount - adds a discount

func (*ItemBuilder) AddDiscounts

func (f *ItemBuilder) AddDiscounts(discounts ...AppliedDiscount) *ItemBuilder

AddDiscounts - adds a discount

func (*ItemBuilder) AddTaxInfo

func (f *ItemBuilder) AddTaxInfo(taxType string, taxRate *big.Float, taxAmount *priceDomain.Price) *ItemBuilder

AddTaxInfo - add a tax info - at least taxRate OR taxAmount need to be given. The taxAmount can be calculated

func (*ItemBuilder) Build

func (f *ItemBuilder) Build() (*Item, error)

Build returns build item or error if invariants do not match. Any call will also REST the ItemBuilder

func (*ItemBuilder) CalculatePricesAndTax

func (f *ItemBuilder) CalculatePricesAndTax() *ItemBuilder

CalculatePricesAndTax - reads the config flag and reculculates Total and Tax

func (*ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceGross

func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceGross() *ItemBuilder

CalculatePricesAndTaxAmountsFromSinglePriceGross - Vertical Tax Calculation - based from current SinglePriceNet, Qty and the RowTax Infos given Sets RowPriceNet, missing tax.Amount and RowPriceGross

func (*ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceNet

func (f *ItemBuilder) CalculatePricesAndTaxAmountsFromSinglePriceNet() *ItemBuilder

CalculatePricesAndTaxAmountsFromSinglePriceNet - Vertikal Tax Calculation - based from current SinglePriceNet, Qty and the RowTax Infos given Sets RowPriceNet, missing tax.Amount and RowPriceGross

func (*ItemBuilder) Inject

func (f *ItemBuilder) Inject(config *struct {
	UseGrosPrice bool `inject:"config:commerce.product.priceIsGross,optional"`
})

Inject - called by dingo

func (*ItemBuilder) SetAdditionalData

func (f *ItemBuilder) SetAdditionalData(d map[string]string) *ItemBuilder

SetAdditionalData - optional

func (*ItemBuilder) SetByProduct

func (f *ItemBuilder) SetByProduct(product domain.BasicProduct) *ItemBuilder

SetByProduct - gets a product and calculates also prices

func (*ItemBuilder) SetExternalReference

func (f *ItemBuilder) SetExternalReference(ref string) *ItemBuilder

SetExternalReference - sets the ExternalReference

func (*ItemBuilder) SetFromItem

func (f *ItemBuilder) SetFromItem(item Item) *ItemBuilder

SetFromItem - sets the data in builder from existing item - useful to get a updated item based from existing. Its not setting Taxes (use Calculate)

func (*ItemBuilder) SetID

func (f *ItemBuilder) SetID(id string) *ItemBuilder

SetID - sets the id

func (*ItemBuilder) SetProductData

func (f *ItemBuilder) SetProductData(marketplace string, vc string, name string) *ItemBuilder

SetProductData - set product data: MarketplaceCode,VariantMarketPlaceCode,ProductName

func (*ItemBuilder) SetQty

func (f *ItemBuilder) SetQty(q int) *ItemBuilder

SetQty - optional (default 1)

func (*ItemBuilder) SetSinglePriceGross

func (f *ItemBuilder) SetSinglePriceGross(grossPrice priceDomain.Price) *ItemBuilder

SetSinglePriceGross - set by gross price

func (*ItemBuilder) SetSinglePriceNet

func (f *ItemBuilder) SetSinglePriceNet(price priceDomain.Price) *ItemBuilder

SetSinglePriceNet - set by net

func (*ItemBuilder) SetSourceID

func (f *ItemBuilder) SetSourceID(id string) *ItemBuilder

SetSourceID - optional

func (*ItemBuilder) SetVariantMarketPlaceCode

func (f *ItemBuilder) SetVariantMarketPlaceCode(id string) *ItemBuilder

SetVariantMarketPlaceCode sets VariantMarketPlaceCode (only for configurable_with_variant relevant)

type ItemBuilderProvider

type ItemBuilderProvider func() *ItemBuilder

ItemBuilderProvider should be used to create an item

type ItemSplitter

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

ItemSplitter used to split an item

func (*ItemSplitter) Inject

func (s *ItemSplitter) Inject(itemBuilderProvider ItemBuilderProvider, config *struct {
	UseGrosPrice bool `inject:"config:commerce.product.priceIsGross,optional"`
})

Inject of ItemSplitter

func (*ItemSplitter) SplitInSingleQtyItems

func (s *ItemSplitter) SplitInSingleQtyItems(givenItem Item) ([]Item, error)

SplitInSingleQtyItems the given item into multiple items with Qty 1 and make sure the sum of the items prices matches by using SplitInPayables

type ItemUpdateCommand

type ItemUpdateCommand struct {
	// SourceID of where the items should be initially picked from - This is set by the SourcingLogic
	SourceID *string
	// Qty contains the item quantity
	Qty *int
	// AdditionalData contains item related data
	AdditionalData map[string]string
	// Mandatory field: ItemID is only for identifying the item.
	ItemID string
}

ItemUpdateCommand defines the update item command

type ModifyBehaviour

type ModifyBehaviour interface {
	DeleteItem(ctx context.Context, cart *Cart, itemID string, deliveryCode string) (*Cart, DeferEvents, error)
	UpdateItem(ctx context.Context, cart *Cart, itemUpdateCommand ItemUpdateCommand) (*Cart, DeferEvents, error)
	UpdateItems(ctx context.Context, cart *Cart, itemUpdateCommands []ItemUpdateCommand) (*Cart, DeferEvents, error)
	AddToCart(ctx context.Context, cart *Cart, deliveryCode string, addRequest AddRequest) (*Cart, DeferEvents, error)
	CleanCart(ctx context.Context, cart *Cart) (*Cart, DeferEvents, error)
	CleanDelivery(ctx context.Context, cart *Cart, deliveryCode string) (*Cart, DeferEvents, error)
	UpdatePurchaser(ctx context.Context, cart *Cart, purchaser *Person, additionalData *AdditionalData) (*Cart, DeferEvents, error)
	UpdateAdditionalData(ctx context.Context, cart *Cart, additionalData *AdditionalData) (*Cart, DeferEvents, error)
	UpdatePaymentSelection(ctx context.Context, cart *Cart, paymentSelection PaymentSelection) (*Cart, DeferEvents, error)
	UpdateDeliveryInfo(ctx context.Context, cart *Cart, deliveryCode string, deliveryInfo DeliveryInfoUpdateCommand) (*Cart, DeferEvents, error)
	UpdateBillingAddress(ctx context.Context, cart *Cart, billingAddress Address) (*Cart, DeferEvents, error)
	UpdateDeliveryInfoAdditionalData(ctx context.Context, cart *Cart, deliveryCode string, additionalData *AdditionalData) (*Cart, DeferEvents, error)
	ApplyVoucher(ctx context.Context, cart *Cart, couponCode string) (*Cart, DeferEvents, error)
	RemoveVoucher(ctx context.Context, cart *Cart, couponCode string) (*Cart, DeferEvents, error)
}

ModifyBehaviour is a interface that can be implemented by other packages to provide cart actions This port can not be registered directly but is provided by the registered "GuestCartService"

type PaymentSelection

type PaymentSelection interface {
	Gateway() string
	// ChargeSplits - the selected split per ChargeType and PaymentMethod
	CartSplit() PaymentSplit
	// ChargeSplits - the selected split per ChargeType and PaymentMethod
	ItemSplit() PaymentSplitByItem
	TotalValue() price.Price
	MethodByType(string) string
	IdempotencyKey() string
	GenerateNewIdempotencyKey() (PaymentSelection, error)
}

PaymentSelection value object - that represents the payment selection on the cart

func NewDefaultPaymentSelection

func NewDefaultPaymentSelection(gateway string, chargeTypeToPaymentMethod map[string]string, cart Cart) (PaymentSelection, error)

NewDefaultPaymentSelection returns a PaymentSelection that can be used to update the cart is able to include gift card charges if applied to cart

func NewPaymentSelection

func NewPaymentSelection(gateway string, chargedItems PaymentSplitByItem) PaymentSelection

NewPaymentSelection - with the passed PaymentSplitByItem

func RemoveZeroCharges

func RemoveZeroCharges(selection PaymentSelection, chargeTypeToPaymentMethod map[string]string) PaymentSelection

RemoveZeroCharges removes charges which have an value of zero from selection as they are necessary for our internal calculations but not for external clients, we assume zero charges are ignored moreover charges are transformed to pay ables

type PaymentSplit

type PaymentSplit map[SplitQualifier]price.Charge

PaymentSplit represents the Charges qualified by Charge Type, Charge Reference and Payment Method

func (PaymentSplit) ChargesByType

func (s PaymentSplit) ChargesByType() price.Charges

ChargesByType returns Charges (a list of Charges summed by Type)

func (PaymentSplit) MarshalJSON

func (s PaymentSplit) MarshalJSON() ([]byte, error)

MarshalJSON serialize to json

func (PaymentSplit) TotalValue

func (s PaymentSplit) TotalValue() price.Price

TotalValue returns the sum of the valued Price in the included Charges in this Split

func (*PaymentSplit) UnmarshalJSON

func (s *PaymentSplit) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialize from json

type PaymentSplitByItem

type PaymentSplitByItem struct {
	CartItems     map[string]PaymentSplit
	ShippingItems map[string]PaymentSplit
	TotalItems    map[string]PaymentSplit
}

PaymentSplitByItem - similar to value object that contains items of the different possible types, that have a price

func (PaymentSplitByItem) Sum

func (c PaymentSplitByItem) Sum() PaymentSplit

Sum - the resulting Split after sum all the included item split

type PaymentSplitByItemBuilder

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

PaymentSplitByItemBuilder - Builder to get valid PaymentSplitByItem instances

func (*PaymentSplitByItemBuilder) AddCartItem

func (pb *PaymentSplitByItemBuilder) AddCartItem(id string, method string, charge price.Charge) *PaymentSplitByItemBuilder

AddCartItem - adds a cartitems charge to the PaymentSplitByItem

func (*PaymentSplitByItemBuilder) AddShippingItem

func (pb *PaymentSplitByItemBuilder) AddShippingItem(deliveryCode string, method string, charge price.Charge) *PaymentSplitByItemBuilder

AddShippingItem - adds shipping charge

func (*PaymentSplitByItemBuilder) AddTotalItem

func (pb *PaymentSplitByItemBuilder) AddTotalItem(totalType string, method string, charge price.Charge) *PaymentSplitByItemBuilder

AddTotalItem - adds totalitem charge

func (*PaymentSplitByItemBuilder) Build

func (pb *PaymentSplitByItemBuilder) Build() PaymentSplitByItem

Build - returns the instance of PaymentSplitByItem

type PaymentSplitService

type PaymentSplitService struct{}

PaymentSplitService enables the creation of a PaymentSplitByItem following different payment methods

func (PaymentSplitService) SplitWithGiftCards

func (service PaymentSplitService) SplitWithGiftCards(chargeTypeToPaymentMethod map[string]string, items PricedItems, cards AppliedGiftCards) (*PaymentSplitByItem, error)

SplitWithGiftCards calculates a payment selection based on given method, priced items and applied gift cards

type Person

type Person struct {
	Address         *Address
	PersonalDetails PersonalDetails
	//ExistingCustomerData if the current purchaser is an existing customer - this contains infos about existing customer
	ExistingCustomerData *ExistingCustomerData
}

Person value object

type PersonalDetails

type PersonalDetails struct {
	DateOfBirth     string
	PassportCountry string
	PassportNumber  string
	Nationality     string
}

PersonalDetails value object

type PricedItems

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

PricedItems - value object that contains items of the different possible types, that have a price

func (PricedItems) CartItems

func (p PricedItems) CartItems() map[string]domain.Price

CartItems - returns the Price per cartItems - map key is cartitem ID

func (PricedItems) ShippingItems

func (p PricedItems) ShippingItems() map[string]domain.Price

ShippingItems - returns the Price per ShippingItems - map key is deliverycode

func (PricedItems) Sum

func (p PricedItems) Sum() domain.Price

Sum - returns Sum of all items in this struct

func (PricedItems) TotalItems

func (p PricedItems) TotalItems() map[string]domain.Price

TotalItems - returns the Price per Totalitem - map key is total type

type ShippingItem

type ShippingItem struct {
	Title            string
	PriceNet         priceDomain.Price
	TaxAmount        priceDomain.Price
	AppliedDiscounts AppliedDiscounts
}

ShippingItem value object

func (*ShippingItem) HasAppliedDiscounts

func (s *ShippingItem) HasAppliedDiscounts() (bool, error)

HasAppliedDiscounts checks whether there are any discounts currently applied to the shipping item

func (*ShippingItem) MergeDiscounts

func (s *ShippingItem) MergeDiscounts() (AppliedDiscounts, error)

MergeDiscounts parses discounts of a shipping item All discounts with the same campaign code are aggregated and returned as one with a summed price

func (ShippingItem) Tax

func (s ShippingItem) Tax() Tax

Tax - the Tax of the shipping

func (ShippingItem) TotalWithDiscountInclTax

func (s ShippingItem) TotalWithDiscountInclTax() priceDomain.Price

TotalWithDiscountInclTax - the price the customer need to pay for the shipping

type SplitQualifier

type SplitQualifier struct {
	ChargeType      string
	ChargeReference string
	Method          string
}

SplitQualifier qualifies by Charge Type, Charge Reference and Payment Method

type Tax

type Tax struct {
	Amount domain.Price
	Type   string
	Rate   *big.Float `swaggertype:"string"`
}

Tax - it the Tax represented by an Amount and Optional the Rate.

type Taxes

type Taxes []Tax

Taxes is a list of Tax

func (Taxes) AddTax

func (t Taxes) AddTax(tax Tax) Taxes

AddTax returns new Tax with this Tax added

func (Taxes) AddTaxWithMerge

func (t Taxes) AddTaxWithMerge(taxToAddOrMerge Tax) Taxes

AddTaxWithMerge returns new Taxes with this Tax added

func (Taxes) AddTaxesWithMerge

func (t Taxes) AddTaxesWithMerge(taxes Taxes) Taxes

AddTaxesWithMerge - returns new Taxes with the given Taxes all added or merged in

func (Taxes) TotalAmount

func (t Taxes) TotalAmount() domain.Price

TotalAmount - returns the sum of all taxes as price

type Teaser

type Teaser struct {
	ProductCount  int
	ItemCount     int
	DeliveryCodes []string
}

Teaser - represents some teaser infos for cart

type Totalitem

type Totalitem struct {
	Code  string
	Title string
	Price domain.Price
	Type  string
}

Totalitem for totals

type WithDiscount

type WithDiscount interface {
	HasAppliedDiscounts() (bool, error)
	MergeDiscounts() (AppliedDiscounts, error)
}

WithDiscount interface for a cart that is able to handle discounts

type WithGiftCard

type WithGiftCard interface {
	HasRemainingGiftCards() bool
	HasAppliedGiftCards() bool
	SumAppliedGiftCards() (domain.Price, error)
	SumGrandTotalWithGiftCards() (domain.Price, error)
}

WithGiftCard interface for a cart that is able to handle gift cards

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier