📘 公式リファレンス📦 リファレンス/オブジェクト初級
customer オブジェクト
ログイン中の顧客情報にアクセスするオブジェクト。名前、メール、注文履歴、累計支払額など顧客マスターデータを取得できる。
用途
顧客アカウントページで会員名や注文数を表示したり、チェックアウトやギフトカード発行時に顧客メールを参照したりするとき。
設置場所
顧客がログイン中の contexts(customers/account, customers/addresses, customers/order テンプレート、checkout.customer、order.customer、gift_card.customer など)で `{{ customer.first_name }}` `{{ customer.total_spent }}` `{{ customer.orders }}` のようにプロパティを参照する。
注意点
customer オブジェクトはログイン顧客のみ利用でき、未ログイン時は nil を返す。total_spent は顧客の現地通貨(プレゼンテーション通貨)の小数単位で返されるため、money フィルターで整形してから表示する。orders 配列は最大 20 件までで、paginate タグで件数制御が必要。
仕様
449 行 / json{
"access": {
"global": true,
"parents": [
{
"object": "checkout",
"property": "customer"
},
{
"object": "gift_card",
"property": "customer"
},
{
"object": "order",
"property": "customer"
}
],
"template": [
"customers/account",
"customers/addresses",
"customers/order"
]
},
"deprecated": false,
"deprecation_reason": "",
"description": "The `customer` object is directly accessible globally when a customer is logged in to their account. It's also defined in\nthe following contexts:\n\n- The [`customers/account` template](/themes/architecture/templates/customers-account)\n- The [`customers/addresses` template](/themes/architecture/templates/customers-addresses)\n- The [`customers/order` template](/themes/architecture/templates/customers-order)\n- When accessing [`checkout.customer`](/docs/api/liquid/objects/checkout#checkout-customer)\n- When accessing [`gift_card.customer`](/docs/api/liquid/objects/gift_card#gift_card-customer)\n- When accessing [`order.customer`](/docs/api/liquid/objects/order#order-customer)\n\nOutside of the above contexts, if the customer isn't logged into their account, the `customer` object returns `nil`.",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The first name of the customer.",
"name": "first_name"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The last name of the customer.",
"name": "last_name"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The total number of orders that the customer has placed.",
"name": "orders_count"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The value is output in the customer's local (presentment) currency.\n\nFor currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.\n\n> Tip:\n> Use [money filters](/docs/api/liquid/filters/money-filters) to output a formatted amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The total amount that the customer has spent on all orders in the currency's subunit.",
"name": "total_spent"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> Use the [paginate](/docs/api/liquid/tags/paginate) tag to choose how many orders to show at once, up to a limit of 20.",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "order"
}
],
"summary": "All of the orders placed by the customer.",
"name": "orders"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "order",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The last order placed by the customer, not including test orders.",
"name": "last_order"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The full name of the customer.",
"name": "name"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The email of the customer.",
"name": "email"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "This phone number is only populated if the customer checks out using a phone number during checkout, opts in to SMS\nnotifications, or if the merchant has manually entered it.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The phone number of the customer.",
"name": "phone"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "A customer can complete a checkout without making an account with the store. If the customer\ndoesn't have an account with the store, then `customer.has_account` is `false` at checkout.\n\nDuring the checkout process, if the customer has an account with the store and enters an email associated\nwith an account, then `customer.has_account` is `true`. The email is associated with the account regardless\nof whether the customer has logged into their account.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the email associated with the customer is tied to a\n[customer account](https://help.shopify.com/manual/customers/customer-accounts). Returns `false` if not.",
"name": "has_account"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the customer accepts marketing. Returns `false` if not.",
"name": "accepts_marketing"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The ID of the customer.",
"name": "id"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "string"
}
],
"summary": "The tags associated with the customer.",
"name": "tags"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "address",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The default address of the customer.",
"name": "default_address"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> Use the [paginate](/docs/api/liquid/tags/paginate) tag to choose how many addresses to show at once, up to a limit of 20.",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "address"
}
],
"summary": "All of the addresses associated with the customer.",
"name": "addresses"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The number of addresses associated with the customer.",
"name": "addresses_count"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the customer is exempt from taxes. Returns `false` if not.",
"name": "tax_exempt"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "customer_payment_method"
}
],
"summary": "The customer's saved payment methods.",
"name": "payment_methods"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about B2B in themes, refer to [Support B2B customers in your theme](/themes/pricing-payments/b2b).",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the customer is a B2B customer. Returns `false` if not.",
"name": "b2b?"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about B2B in themes, refer to [Support B2B customers in your theme](/themes/pricing-payments/b2b).\n\n> Tip:\n> Use the [paginate](/docs/api/liquid/tags/paginate) tag to choose how many company locations to show at once, up to a limit of 100.",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "company_location"
}
],
"summary": "The company locations that the customer has access to, or can interact with.",
"name": "company_available_locations"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The number of company locations associated with the customer.",
"name": "company_available_locations_count"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about B2B in themes, refer to [Support B2B customers in your theme](/themes/pricing-payments/b2b).",
"examples": [],
"return_type": [
{
"type": "company_location",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The currently selected company location.",
"name": "current_location"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about B2B in themes, refer to [Support B2B customers in your theme](/themes/pricing-payments/b2b).",
"examples": [],
"return_type": [
{
"type": "company",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The company that the customer is purchasing for.",
"name": "current_company"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "A customer may have an avatar associated with their account, which can be displayed in the storefront.\n\n> Tip:\n> Use with the [`avatar`](/docs/api/liquid/filters/avatar) filter to render the customer's avatar.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if an avatar is associated with a customer. Returns `false` if not.",
"name": "has_avatar?"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The account shown will be in the currency associated with the customer’s current context.\nFor example, if a customer is browsing the storefront in the US market, their USD store credit account will be\nreturned. If they do not have a USD store credit account `nil` will be returned.",
"examples": [],
"return_type": [
{
"type": "store_credit_account",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The store credit account associated with the customer.",
"name": "store_credit_account"
}
],
"summary": "A [customer](https://help.shopify.com/manual/customers) of the store.",
"name": "customer",
"examples": [
{
"name": "Check whether the `customer` object is defined",
"description": "When using the `customer` object outside of customer-specific templates or objects that specifically return a customer, you should check whether the `customer` object is defined.\n",
"syntax": "",
"path": "/",
"raw_liquid": "{% if customer %}\n Hello, {{ customer.first_name }}!\n{% endif %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"json_data": {
"path": "/",
"handle": "customer",
"data_from_file": ""
},
"return_type": []
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_header オブジェクト
Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト中級
metaobjects オブジェクト
ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
additional_checkout_buttons オブジェクト
PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
canonical_url オブジェクト
現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_index オブジェクト
ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_additional_checkout_buttons オブジェクト
PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。
📁 theme-liquid-docs·MIT·27 行