Class: Gemgento::API::SOAP::Checkout::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/gemgento/api/soap/checkout/customer.rb

Class Method Summary collapse

Class Method Details

.address(quote) ⇒ Gemgento::MagentoResponse

Set shipping and billing addreses for Quote in Magento.

Parameters:

Returns:



47
48
49
50
51
52
53
54
# File 'lib/gemgento/api/soap/checkout/customer.rb', line 47

def self.address(quote)
  message = {
      quote_id: quote.magento_id,
      customer: {item: compose_address_data([quote.shipping_address, quote.billing_address])},
      store_id: quote.store.magento_id
  }
  MagentoApi.create_call(:shopping_cart_customer_addresses, message)
end

.set(quote) ⇒ Gemgento::MagentoResponse

Set the cart customer.

Parameters:

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gemgento/api/soap/checkout/customer.rb', line 12

def self.set(quote)
  if quote.customer_is_guest
    customer = {
        mode: 'guest',
        email: quote.customer_email,
        firstname: (quote.billing_address.first_name || quote.shipping_address.first_name),
        lastname: (quote.billing_address.last_name || quote.shipping_address.last_name),
        'website_id' => '1'
    }
  else
    customer = {
        mode: 'customer',
        'customer_id' => quote.user.magento_id,
        email: quote.user.email,
        firstname: quote.user.first_name,
        lastname: quote.user.last_name,
        password: quote.user.password,
        confirmation: true,
        'group_id' => quote.user.user_group.magento_id,
        'website_id' => '1'
    }
  end

  message = {
      quote_id: quote.magento_id,
      customer: customer,
      store_id: quote.store.magento_id
  }
  MagentoApi.create_call(:shopping_cart_customer_set, message)
end