app/models/spree/shipment_decorator.rb
# A shipment is finalized when an order is finalized which happens when an
# order is complete. We want to extend the shipment finalization to pick
# a package type (this uses the same code as when a package picks a package
# type so it should result in the same answer) and store that package type
# with the shipment. If it was successful at picking a package type it should
# go ahead and generate the label. This will lock in the pricing.
#
# If it cannot pick a package type a label cannot be generated but an admin
# will still be able to pick a package type and print a label on the backend.
A shipment is finalized when an order is finalized which happens when an
order is complete. We want to extend the shipment finalization to pick
a package type (this uses the same code as when a package picks a package
type so it should result in the same answer) and store that package type
with the shipment. If it was successful at picking a package type it should
go ahead and generate the label. This will lock in the pricing.

If it cannot pick a package type a label cannot be generated but an admin
will still be able to pick a package type and print a label on the backend.
A shipment is finalized when an order is finalized which happens when an order is complete . We want to extend the shipment finalization to pick a package type ( this uses the same code as when a package picks a package type so it should result in the same answer ) and store that package type with the shipment . If it was successful at picking a package type it should go ahead and generate the label . This will lock in the pricing . If it cannot pick a package type a label cannot be generated but an admin will still be able to pick a package type and print a label on the backend .
def finalize_with_label!
    finalize_without_label!
    if calculator
      preferred = preferred_package_type calculator.preferred_provider, calculator.preferred_service_type
      self.package_type = preferred
      begin
        generate_label!
      rescue
        self.package_type = nil
      end
    end
  end
def finalize_with_label! finalize_without_label! if calculator preferred = preferred_package_type calculator . preferred_provider , calculator . preferred_service_type self . package_type = preferred begin generate_label! rescue self . package_type = nil end end end
A shipment is finalized when an order is finalized which happens when an
order is complete.
A shipment is finalized when an order is finalized which happens when an order is complete .
# Attempt to determine the package type automatically # Squash the error and remove the info about what package type was # selected so it is treated as if we couldn't figure out what package # the user needed. The backend user will need to select a package and # possibly fix the error.