Sha256: 690a8a22ff855d332366afa3dd5b072624c08abcc10cd5ba99d086eba842091d

Contents?: true

Size: 760 Bytes

Versions: 42

Compression:

Stored size: 760 Bytes

Contents

Spree::Sample.load_sample('option_values')
Spree::Sample.load_sample('products')

product = Spree::Product.find_by(name: 'Ruby on Rails Baseball Jersey')
size = Spree::OptionValue.find_by(name: 'Small')
color = Spree::OptionValue.find_by(name: 'Red')
eligible_values = "#{size.id},#{color.id}"

promotion = Spree::Promotion.where(
  name: 'free shipping',
  usage_limit: nil,
  path: nil,
  match_policy: 'any',
  description: ''
).first_or_create

Spree::PromotionRule.where(
  promotion_id: promotion.id,
  type: 'Spree::Promotion::Rules::OptionValue',
  preferences: { match_policy: 'any', eligible_values: { product.id.to_s => eligible_values } }
).first_or_create

Spree::Promotion::Actions::FreeShipping.where(promotion_id: promotion.id).first_or_create

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
spree_core-3.6.0 db/default/spree/promotions.rb
spree_core-3.6.0.rc1 db/default/spree/promotions.rb