cart オブジェクト
ショッピングカート内の商品、合計金額、数量、メモなどの情報を取得するオブジェクト。カートテンプレートやミニカート表示で商品一覧や価格情報の参照に使う。
仕様
348 行 / json{
"access": {
"global": true,
"parents": [],
"template": [
"cart"
]
},
"deprecated": false,
"deprecation_reason": "",
"description": "",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if any of the products in the cart require shipping. Returns `false` if not.",
"name": "requires_shipping"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn more about capturing cart notes, refer to the [`cart` template](/themes/architecture/templates/cart#support-cart-notes-and-attributes).",
"examples": [
{
"name": "Capture cart notes",
"description": "To capture a cart note, include an HTML input such as a `<textarea>` with an attribute of `name=\"note\"` within the cart `<form>`.\n\n```liquid\n<label>Gift note:</label>\n<textarea name=\"note\"></textarea>\n```\n\n> Note:\n> There can only be one instance of `{{ cart.note }}` on the cart page. If there are multiple instances,\n> then the one that comes latest in the Document Object Model (DOM) will be submitted with the form.\n",
"syntax": "",
"path": "/cart",
"raw_liquid": "",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Additional information captured with the cart.",
"name": "note"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The number of items in the cart.",
"name": "item_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 price of all of the items in the cart in the currency's subunit, after discounts have been applied.",
"name": "total_price"
},
{
"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 price.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount that the customer will be charged at checkout in the currency's subunit.",
"name": "checkout_charge_amount"
},
{
"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 price of all of the items in the cart in the currency's subunit, before discounts have been applied.",
"name": "original_total_price"
},
{
"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 price of all of the items in the cart in the currency's subunit, after any line item discounts. This\ndoesn't include taxes (unless taxes are included in the prices), cart discounts, or shipping costs.",
"name": "items_subtotal_price"
},
{
"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 of all discounts (the amount saved) for the cart in the currency's subunit.",
"name": "total_discount"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "line_item"
}
],
"summary": "The line items in the cart.",
"name": "items"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if there are no items in the cart. Return's `false` if there are.",
"name": "empty?"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "If the store uses multi-currency, then this is the same as the customer's local\n(presentment) currency. Otherwise, it's the same as the store currency.\n\n> Tip:\n> You can output the store's available currencies using [`shop.enabled_currencies`](/docs/api/liquid/objects/shop#shop-enabled_currencies).",
"examples": [],
"return_type": [],
"summary": "The currency of the cart.",
"name": "currency"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> Use the [`weight_with_unit`](/docs/api/liquid/filters/weight_with_unit) filter to format the weight in\n> [the store's format](https://www.shopify.com/admin/settings/general), or override the default unit.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The total weight of all of the items in the cart in grams.",
"name": "total_weight"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [
{
"name": "Display discount applications",
"description": "",
"syntax": "",
"path": "/cart",
"raw_liquid": "{% for discount_application in cart.discount_applications %}\n Discount name: {{ discount_application.title }}\n Savings: -{{ discount_application.total_allocated_amount | money }}\n{% endfor %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "discount_application"
}
],
"summary": "The discount applications for the cart.",
"name": "discount_applications"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn more about capturing cart attributes, refer to the [`cart` template](/themes/architecture/templates/cart#support-cart-notes-and-attributes).",
"examples": [
{
"name": "Capture cart attributes",
"description": "To capture a cart attribute, include an HTML input with an attribute of `name=\"attributes[attribute-name]\"` within the cart `<form>`.\n\n```liquid\n<label>What do you want engraved on your cauldron?</label>\n<input type=\"text\" name=\"attributes[cauldron-engraving]\" value=\"{{ cart.attributes.cauldron-engraving }}\" />\n```\n\n> Tip:\n> You can add a double underscore `__` prefix to an attribute name to make it private. Private attributes behave like other cart attributes, except that they can't be read from Liquid or the Ajax API.\n> You can use them for data that doesn't affect the page rendering, which allows for more effective page caching.\n",
"syntax": "",
"path": "/cart",
"raw_liquid": "",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "untyped",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Additional attributes entered by the customer with the cart.",
"name": "attributes"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [
{
"name": "Display cart-level discount applications",
"description": "",
"syntax": "",
"path": "/cart",
"raw_liquid": "{% for discount_application in cart.cart_level_discount_applications %}\n Discount name: {{ discount_application.title }}\n Savings: -{{ discount_application.total_allocated_amount | money }}\n{% endfor %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "discount_application"
}
],
"summary": "The cart-specific discount applications for the cart.",
"name": "cart_level_discount_applications"
},
{
"deprecated": true,
"deprecation_reason": "Deprecated because not all discount types and details are available.\n\nThe `cart.discounts` property has been replaced by [`cart.discount_applications`](/docs/api/liquid/objects/cart#cart-discount_applications).",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "discount"
}
],
"summary": "The discounts applied to the cart.",
"name": "discounts"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "This can be set in a store’s [tax settings](https://www.shopify.com/admin/settings/taxes).\n\nIf the store includes or exclude tax [based on the customer’s country](https://help.shopify.com/manual/taxes/location#include-or-exclude-tax-based-on-your-customers-country),\nthen the value reflects the tax requirements of the customer’s country.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if taxes are included in the prices of products in the cart. Returns `false` if not.",
"name": "taxes_included"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if duties are included in the prices of products in the cart. Returns `false` if not.",
"name": "duties_included"
}
],
"summary": "A customer’s cart.",
"name": "cart",
"examples": [],
"json_data": {
"path": "/",
"handle": "cart",
"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> タグ内に埋め込む必須要素。
metaobjects オブジェクト
ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。
additional_checkout_buttons オブジェクト
PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。
canonical_url オブジェクト
現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。
content_for_index オブジェクト
ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。
content_for_additional_checkout_buttons オブジェクト
PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。