Class: Workarea::Checkout::Steps::Shipping

Inherits:
Base
  • Object
show all
Defined in:
app/models/workarea/checkout/steps/shipping.rb

Defined Under Namespace

Classes: NoAvailableShippingOption

Instance Attribute Summary

Attributes inherited from Base

#checkout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Workarea::Checkout::Steps::Base

Instance Method Details

#complete?Boolean

Whether this checkout step is finished. Requires order to be valid, since a default shipping service will always be set.

Returns:

  • (Boolean)


45
46
47
# File 'app/models/workarea/checkout/steps/shipping.rb', line 45

def complete?
  order.valid? && (!order.requires_shipping? || shipping.valid?)
end

#shipping_optionsCheckout::ShippingOptions

The checkout shipipng options that are available for this order.



11
12
13
# File 'app/models/workarea/checkout/steps/shipping.rb', line 11

def shipping_options
  @shipping_options ||= ShippingOptions.new(order, shipping)
end

#update(params = {}) ⇒ Boolean

Update the shipping step of checkout. This includes:

  • shipping service

A default shipping service will probably be set before getting to this point of the checkout.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

Returns:

  • (Boolean)

    whether the update succeeded

Raises:



28
29
30
31
32
33
34
35
36
37
# File 'app/models/workarea/checkout/steps/shipping.rb', line 28

def update(params = {})
  unless order.requires_shipping?
    clean_shipping
    return true
  end

  update_shipping_service(params)
  add_shipping_instructions(params)
  persist_update
end