Address

A set of methods to create, update, and list user shipping and billing addresses.

create

Create a new address for the current user. emits the PelcroAddressCreated DOM events when the response is returned successfully.

Example

window.Pelcro.address.create({
      type: "shipping",
      first_name: "john",
      last_name: "doe",
      title: "mr",
      company: "abc",
      department: "operations",
      line1: "4 kingston street",
      line2: "apt 15",
      city: "San Francisco",
      state: "CA",
      country: "US",
      postal_code: "12345",
      is_default: true
}, (error, response) => {
  	if (error) {
    	return console.log("error", error.message);
    }
 
    const user = response.data;
    console.log(user);
})

Parameters

Parameter

Type

type

String "shipping" | "billing"

title

String

first_name

String

last_name

String

phone

String

company

String

department

String

line 1

String

line 2

string

city

string

state

string

country

string

is_default

boolean

update

update an existing address for the current user. Emits the PelcroAddressUpdated DOM events when the response is returned successfully.

Example

window.Pelcro.address.update({
      address_id: 123,
      type: "shipping",
      first_name: "john",
      last_name: "doe",
      title: "mr",
      company: "abc",
      department: "operations",
      line1: "4 kingston street",
      line2: "apt 15",
      city: "San Francisco",
      state: "CA",
      country: "US",
      postal_code: "12345",
      is_default: true
}, (error, response) => {
  	if (error) {
    	return console.log("error", error.message);
    }
 
    const user = response.data;
    console.log(user);
})

Parameters

Parameter

Type

address_id

number

type

String "shipping" | "billing"

title

String

first_name

String

last_name

String

phone

String

company

String

department

String

line 1

String

line 2

string

city

string

state

string

country

string

is_default

boolean

list

Get the list of the current user's addresses

const userAddresses = window.Pelcro.address.list();
console.log(userAddresses);