Sha256: 53f17295ba562118b64055669c0f6c214e543e2dbf4109cf0773f308ee05ced4

Contents?: true

Size: 967 Bytes

Versions: 6

Compression:

Stored size: 967 Bytes

Contents

module Workarea
  class GiftCardSeeds
    def perform
      puts 'Adding gift cards...'
      add_gift_card_product
    end

    private

    def add_gift_card_product
      product = Workarea::Catalog::Product.new(
        id: 'GIFT_CARD',
        name: 'Gift Card',
        gift_card: true,
        digital: true,
        template: 'gift_card',
        customizations: 'gift_card',
        description: Faker::Lorem.paragraph,
        variants: [
          { sku: 'GIFT_CARD_10' },
          { sku: 'GIFT_CARD_25' },
          { sku: 'GIFT_CARD_50' }
        ]
      )

      product.save!

      Workarea::Pricing::Sku.find_or_create_by(
        id: 'GIFT_CARD_10',
        prices: [{ regular: 10 }]
      )

      Workarea::Pricing::Sku.find_or_create_by(
        id: 'GIFT_CARD_25',
        prices: [{ regular: 25 }]
      )

      Workarea::Pricing::Sku.find_or_create_by(
        id: 'GIFT_CARD_50',
        prices: [{ regular: 50 }]
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-gift_cards-3.4.11 app/seeds/workarea/gift_card_seeds.rb
workarea-gift_cards-3.4.10 app/seeds/workarea/gift_card_seeds.rb
workarea-gift_cards-3.4.9 app/seeds/workarea/gift_card_seeds.rb
workarea-gift_cards-3.4.8 app/seeds/workarea/gift_card_seeds.rb
workarea-gift_cards-3.4.7 app/seeds/workarea/gift_card_seeds.rb
workarea-gift_cards-3.4.6 app/seeds/workarea/gift_card_seeds.rb