flamingo.me/flamingo-commerce/v3@v3.11.0/product/domain/productTypeSimple.go (about)

     1  package domain
     2  
     3  const (
     4  	// TypeSimple denotes simple products
     5  	TypeSimple = "simple"
     6  )
     7  
     8  type (
     9  	// SimpleProduct - A product without Variants that can be teasered and being sold
    10  	SimpleProduct struct {
    11  		Identifier string
    12  		BasicProductData
    13  		Saleable
    14  		Teaser TeaserData
    15  	}
    16  )
    17  
    18  // Verify Interfaces
    19  var _ BasicProduct = SimpleProduct{}
    20  
    21  // Type interface implementation for SimpleProduct
    22  func (p SimpleProduct) Type() string {
    23  	return TypeSimple
    24  }
    25  
    26  // IsSaleable is true
    27  func (p SimpleProduct) IsSaleable() bool {
    28  	return true
    29  }
    30  
    31  // BaseData interface implementation for SimpleProduct
    32  func (p SimpleProduct) BaseData() BasicProductData {
    33  	bp := p.BasicProductData
    34  	return bp
    35  }
    36  
    37  // TeaserData interface implementation for SimpleProduct
    38  func (p SimpleProduct) TeaserData() TeaserData {
    39  	return p.Teaser
    40  }
    41  
    42  // SaleableData getter for SimpleProduct
    43  func (p SimpleProduct) SaleableData() Saleable {
    44  	return p.Saleable
    45  }
    46  
    47  // GetIdentifier interface implementation for SimpleProduct
    48  func (p SimpleProduct) GetIdentifier() string {
    49  	return p.Identifier
    50  }
    51  
    52  // HasMedia  for SimpleProduct
    53  func (p SimpleProduct) HasMedia(group string, usage string) bool {
    54  	media := findMediaInProduct(BasicProduct(p), group, usage)
    55  	return media != nil
    56  }
    57  
    58  // GetMedia  for SimpleProduct
    59  func (p SimpleProduct) GetMedia(group string, usage string) Media {
    60  	return *findMediaInProduct(BasicProduct(p), group, usage)
    61  }