flamingo.me/flamingo-commerce/v3@v3.11.0/cart/domain/decorator/giftcard.go (about) 1 package decorator 2 3 import "flamingo.me/flamingo-commerce/v3/price/domain" 4 5 type ( 6 // DecoratedWithGiftCard interface for a decorated object to be able to handle giftcards 7 // the difference to cart.WithGiftCard is, that these functions do NOT provide the client 8 // with an error, errors are just logged 9 DecoratedWithGiftCard interface { 10 HasRemainingGiftCards() bool 11 HasAppliedGiftCards() bool 12 TotalGiftCardAmount() domain.Price 13 GrandTotalWithGiftCards() domain.Price 14 } 15 ) 16 17 var ( 18 // interface assertion 19 _ DecoratedWithGiftCard = &DecoratedCart{} 20 ) 21 22 // HasRemainingGiftCards check whether there are gift cards with remaining balance 23 func (dc DecoratedCart) HasRemainingGiftCards() bool { 24 return dc.Cart.HasRemainingGiftCards() 25 } 26 27 // HasAppliedGiftCards checks if a gift card is applied to the cart 28 func (dc DecoratedCart) HasAppliedGiftCards() bool { 29 return dc.Cart.HasAppliedGiftCards() 30 } 31 32 // TotalGiftCardAmount sum up all applied amounts of giftcads 33 // price is returned as a payable 34 func (dc DecoratedCart) TotalGiftCardAmount() domain.Price { 35 return dc.Cart.TotalGiftCardAmount 36 } 37 38 // GrandTotalWithGiftCards calculate the grand total of the cart minus gift cards 39 func (dc DecoratedCart) GrandTotalWithGiftCards() domain.Price { 40 return dc.Cart.GrandTotalWithGiftCards 41 }