Sha256: d6e0f15f50bff257e558c4a5f7c0411dc81dd052fdfd8d8c3053d4b90c68a34b

Contents?: true

Size: 1022 Bytes

Versions: 1

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true

india = Spree::Zone.find_by!(name: 'India')
tax_category = Spree::TaxCategory.find_by!(name: 'IGST')
shipping_category = Spree::ShippingCategory.find_or_create_by!(name: 'India')

Spree::ShippingMethod.create!([
  {
    name: 'Free Shipping (INR)',
    zones: [india],
    calculator: Spree::Calculator::Shipping::FlatRate.create!,
    tax_category: tax_category,
    shipping_categories: [shipping_category]
  },
  {
    name: 'Express Shipping (INR)',
    zones: [india],
    calculator: Spree::Calculator::Shipping::FlatRate.create!,
    tax_category: tax_category,
    shipping_categories: [shipping_category]
  }
])

{
  'Free Shipping (INR)' => [0, 'INR'],
  'Express Shipping (INR)' => [100, 'INR']
}.each do |shipping_method_name, (price, currency)|
  shipping_method = Spree::ShippingMethod.find_by!(name: shipping_method_name)
  shipping_method.calculator.preferences = {
    amount: price,
    currency: currency
  }
  shipping_method.calculator.save!
  shipping_method.save!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_india-0.0.1 db/samples/shipping_categories_and_methods.rb