-
-
Notifications
You must be signed in to change notification settings - Fork 312
Customers
Joshua Harms edited this page Dec 20, 2023
·
1 revision
var service = new CustomerService(myShopifyUrl, shopAccessToken);
var customer = new Customer()
{
FirstName = "John",
LastName = "Doe",
Email = "john.doe@example.com",
Addresses = new List<Address>()
{
new Address()
{
Address1 = "123 4th Street",
City = "Minneapolis",
Province = "Minnesota",
ProvinceCode = "MN",
Zip = "55401",
Phone = "555-555-5555",
FirstName = "John",
LastName = "Doe",
Company = "Tomorrow Corporation",
Country = "United States",
CountryCode = "US",
Default = true,
}
},
VerifiedEmail = true,
Note = "Test note about the customer.",
State = "enabled"
};
customer = await service.CreateAsync(customer);
var service = new CustomerService(myShopifyUrl, shopAccessToken);
var customer = await service.GetAsync(customerId);
var service = new CustomerService(myShopifyUrl, shopAccessToken);
var customer = await service.GetAsync(customerId, "first_name,last_name,email");
//Returns a customer with only FirstName, LastName and Email fields. All other fields are null.
var service = new CustomerService(myShopifyUrl, shopAccessToken);
var customer = await service.UpdateAsync(customerId, new Customer()
{
Email = "test-update@example.com"
});
var service = new CustomerService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(customerId);
var service = new CustomerService(myShopifyUrl, shopAccessToken);
int customerCount = await service.CountAsync();
var service = new CustomerService(myShopifyUrl, shopAccessToken);
IEnumerable<Customer> customers = await Service.ListAsync();
var service = new CustomerService(myShopifyUrl, shopAccessToken);
IEnumerable<Order> orders = await service.ListOrdersForCustomerAsync(customerId);
Use a CustomerSearchListFilter
to perform searches for customers. There is a noticeable 3-30 second delay between creating a new customer and Shopify indexing it for a search.
var service = new CustomerService(myShopifyUrl, shopAccessToken);
var filter = new CustomerSearchListFilter
{
//Searches for a customer from the United States with a name like 'Jane'.
Query = "Jane country:United States"
};
IEnumerable<Customer> customers = await Service.SearchAsync(filter);