app/models/spree/stock/estimator_decorator.rb
def find_or_create_shipping_method(rate, vendor_id)
        method_name = "#{ rate.carrier } #{ rate.service }"
        puts "here i am: #{vendor_id} #{method_name}"
        #TODO figure out if easypost shipping rates shoudl be generic (yes?) or per vendor
        if vendor_id.present?
          vendor = Spree::Vendor.find_by(id: vendor_id)
          vendor.present? ? vendor.shipping_methods.find_by(admin_name: method_name) : nil
        else
          Spree::ShippingMethod.find_or_create_by(admin_name: method_name) do |r|
            r.name = method_name
            r.display_on = 'back_end'
            r.code = rate.service
            r.calculator = Spree::Calculator::Shipping::FlatRate.create
            r.shipping_categories = [Spree::ShippingCategory.first]
          end
        end
      end
# Cartons require shipping methods to be present, This will lookup a
# Shipping method based on the admin(internal)_name. This is not user facing
# and should not be changed in the admin.
Cartons require shipping methods to be present, This will lookup a
Shipping method based on the admin(internal)_name. This is not user facing
and should not be changed in the admin.
Cartons require shipping methods to be present This will lookup a Shipping method based on the admin ( internal ) _name . This is not user facing and should not be changed in the admin .
def find_or_create_shipping_method(rate, vendor_id)
        method_name = "#{ rate.carrier } #{ rate.service }"
        puts "here i am: #{vendor_id} #{method_name}"
        if vendor_id.present?
          vendor = Spree::Vendor.find_by(id: vendor_id)
          vendor.present? ? vendor.shipping_methods.find_by(admin_name: method_name) : nil
        else
          Spree::ShippingMethod.find_or_create_by(admin_name: method_name) do |r|
            r.name = method_name
            r.display_on = 'back_end'
            r.code = rate.service
            r.calculator = Spree::Calculator::Shipping::FlatRate.create
            r.shipping_categories = [Spree::ShippingCategory.first]
          end
        end
      end
def find_or_create_shipping_method ( rate , vendor_id ) method_name = "#{ rate.carrier } #{ rate.service }" puts "here i am: #{vendor_id} #{method_name}" if vendor_id . present? vendor = Spree :: Vendor . find_by ( id : vendor_id ) vendor . present? ? vendor . shipping_methods . find_by ( admin_name : method_name ) : nil else Spree :: ShippingMethod . find_or_create_by ( admin_name : method_name ) do | r | r . name = method_name r . display_on = 'back_end' r . code = rate . service r . calculator = Spree :: Calculator :: Shipping :: FlatRate . create r . shipping_categories = [ Spree :: ShippingCategory . first ] end end end
Cartons require shipping methods to be present, This will lookup a
Shipping method based on the admin(internal)_name.
Cartons require shipping methods to be present This will lookup a Shipping method based on the admin ( internal ) _name .
#TODO figure out if easypost shipping rates shoudl be generic (yes?) or per vendor
rate
vendor_id