From c3da6f05dd7ac9b61b8f861d984c725a6199bc93 Mon Sep 17 00:00:00 2001 From: Linda Damus Date: Fri, 17 Jan 2025 13:10:41 -0500 Subject: [PATCH 1/5] Add template code for multi-class discounts --- .../javascript/discounts/default/.gitignore | 2 + .../default/locales/en.default.json.liquid | 4 + .../discounts/default/package.json.liquid | 30 + .../discounts/default/schema.graphql | 4518 +++++++++++++++++ .../default/shopify.extension.toml.liquid | 36 + .../discounts/default/src/index.liquid | 1 + .../discounts/default/src/run.graphql.liquid | 7 + .../discounts/default/src/run.liquid | 51 + .../discounts/default/src/run.test.liquid | 44 + .../discounts/default/vite.config.js | 1 + discounts/rust/discounts/default/.gitignore | 2 + .../rust/discounts/default/Cargo.toml.liquid | 16 + discounts/rust/discounts/default/README.md | 16 + .../default/locales/en.default.json.liquid | 4 + .../rust/discounts/default/schema.graphql | 4518 +++++++++++++++++ .../default/shopify.extension.toml.liquid | 37 + discounts/rust/discounts/default/src/main.rs | 7 + .../discounts/default/src/run.graphql.liquid | 7 + discounts/rust/discounts/default/src/run.rs | 61 + .../default/locales/en.default.json.liquid | 4 + .../wasm/discounts/default/run.graphql.liquid | 7 + .../wasm/discounts/default/schema.graphql | 4518 +++++++++++++++++ .../default/shopify.extension.toml.liquid | 37 + 23 files changed, 13928 insertions(+) create mode 100644 discounts/javascript/discounts/default/.gitignore create mode 100644 discounts/javascript/discounts/default/locales/en.default.json.liquid create mode 100644 discounts/javascript/discounts/default/package.json.liquid create mode 100644 discounts/javascript/discounts/default/schema.graphql create mode 100644 discounts/javascript/discounts/default/shopify.extension.toml.liquid create mode 100644 discounts/javascript/discounts/default/src/index.liquid create mode 100644 discounts/javascript/discounts/default/src/run.graphql.liquid create mode 100644 discounts/javascript/discounts/default/src/run.liquid create mode 100644 discounts/javascript/discounts/default/src/run.test.liquid create mode 100644 discounts/javascript/discounts/default/vite.config.js create mode 100644 discounts/rust/discounts/default/.gitignore create mode 100644 discounts/rust/discounts/default/Cargo.toml.liquid create mode 100644 discounts/rust/discounts/default/README.md create mode 100644 discounts/rust/discounts/default/locales/en.default.json.liquid create mode 100644 discounts/rust/discounts/default/schema.graphql create mode 100644 discounts/rust/discounts/default/shopify.extension.toml.liquid create mode 100644 discounts/rust/discounts/default/src/main.rs create mode 100644 discounts/rust/discounts/default/src/run.graphql.liquid create mode 100644 discounts/rust/discounts/default/src/run.rs create mode 100644 discounts/wasm/discounts/default/locales/en.default.json.liquid create mode 100644 discounts/wasm/discounts/default/run.graphql.liquid create mode 100644 discounts/wasm/discounts/default/schema.graphql create mode 100644 discounts/wasm/discounts/default/shopify.extension.toml.liquid diff --git a/discounts/javascript/discounts/default/.gitignore b/discounts/javascript/discounts/default/.gitignore new file mode 100644 index 00000000..01c7cfd6 --- /dev/null +++ b/discounts/javascript/discounts/default/.gitignore @@ -0,0 +1,2 @@ +dist +generated \ No newline at end of file diff --git a/discounts/javascript/discounts/default/locales/en.default.json.liquid b/discounts/javascript/discounts/default/locales/en.default.json.liquid new file mode 100644 index 00000000..333045ae --- /dev/null +++ b/discounts/javascript/discounts/default/locales/en.default.json.liquid @@ -0,0 +1,4 @@ +{ + "name": "{{name}}", + "description": "{{name}}" +} diff --git a/discounts/javascript/discounts/default/package.json.liquid b/discounts/javascript/discounts/default/package.json.liquid new file mode 100644 index 00000000..b4a20dad --- /dev/null +++ b/discounts/javascript/discounts/default/package.json.liquid @@ -0,0 +1,30 @@ +{ + "name": "{{handle}}", + "version": "0.0.1", + "license": "UNLICENSED", + "scripts": { + "shopify": "npm exec -- shopify", + "typegen": "npm exec -- shopify app function typegen", + "build": "npm exec -- shopify app function build", + "preview": "npm exec -- shopify app function run", + "test": "vitest" + }, + "codegen": { + "schema": "schema.graphql", + "documents": "src/*.graphql", + "generates": { + "./generated/api.ts": { + "plugins": [ + "typescript", + "typescript-operations" + ] + } + }, + "config": { + "omitOperationSuffix": true + } + }, + "devDependencies": { + "vitest": "^0.29.8" + } +} diff --git a/discounts/javascript/discounts/default/schema.graphql b/discounts/javascript/discounts/default/schema.graphql new file mode 100644 index 00000000..3ca4e22b --- /dev/null +++ b/discounts/javascript/discounts/default/schema.graphql @@ -0,0 +1,4518 @@ +schema { + query: Input + mutation: MutationRoot +} + +""" +Scale the Functions resource limits based on the field's length. +""" +directive @scaleLimits(rate: Float!) on FIELD_DEFINITION + +""" +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +Represents a generic custom attribute, such as whether an order is a customer's first. +""" +type Attribute { + """ + The key or name of the attribute. For example, `"customersFirstOrder"`. + """ + key: String! + + """ + The value of the attribute. For example, `"true"`. + """ + value: String +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type BuyerIdentity { + """ + The customer associated with the cart. + """ + customer: Customer + + """ + The email address of the buyer that's interacting with the cart. + """ + email: String + + """ + Whether the buyer authenticated with a customer account. + """ + isAuthenticated: Boolean! + + """ + The phone number of the buyer that's interacting with the cart. + """ + phone: String + + """ + The purchasing company associated with the cart. + """ + purchasingCompany: PurchasingCompany +} + +""" +A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +""" +type Cart { + """ + The attributes associated with the cart. Attributes are represented as key-value pairs. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + Information about the buyer that is interacting with the cart. + """ + buyerIdentity: BuyerIdentity + + """ + The costs that the buyer will pay at checkout. + """ + cost: CartCost! + + """ + A list of lines containing information about the items that can be delivered. + """ + deliverableLines: [DeliverableCartLine!]! + + """ + The delivery groups available for the cart based on the buyer's shipping address. + """ + deliveryGroups: [CartDeliveryGroup!]! + + """ + A list of lines containing information about the items the customer intends to purchase. + """ + lines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The localized fields available for the cart. + """ + localizedFields( + """ + The keys of the localized fields to retrieve. + """ + keys: [LocalizedFieldKey!]! = [] + ): [LocalizedField!]! +} + +""" +The cost that the buyer will pay at checkout. +""" +type CartCost { + """ + The amount, before taxes and discounts, for the customer to pay. + """ + subtotalAmount: MoneyV2! + + """ + The total amount for the customer to pay. + """ + totalAmount: MoneyV2! + + """ + The duty amount for the customer to pay at checkout. + """ + totalDutyAmount: MoneyV2 + + """ + The tax amount for the customer to pay at checkout. + """ + totalTaxAmount: MoneyV2 +} + +""" +Information about the options available for one or more line items to be delivered to a specific address. +""" +type CartDeliveryGroup { + """ + A list of cart lines for the delivery group. + """ + cartLines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The destination address for the delivery group. + """ + deliveryAddress: MailingAddress + + """ + The delivery options available for the delivery group. + """ + deliveryOptions: [CartDeliveryOption!]! + + """ + Unique identifier for the delivery group. + """ + id: ID! + + """ + Information about the delivery option the buyer has selected. + """ + selectedDeliveryOption: CartDeliveryOption +} + +""" +Information about a delivery option. +""" +type CartDeliveryOption { + """ + The code of the delivery option. + """ + code: String + + """ + The cost for the delivery option. + """ + cost: MoneyV2! + + """ + The method for the delivery option. + """ + deliveryMethodType: DeliveryMethod! + + """ + The description of the delivery option. + """ + description: String + + """ + The unique identifier of the delivery option. + """ + handle: Handle! + + """ + The title of the delivery option. + """ + title: String +} + +""" +Represents information about the merchandise in the cart. +""" +type CartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The cost of the merchandise line that the buyer will pay at checkout. + """ + cost: CartLineCost! + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! + + """ + The selling plan associated with the cart line and the effect that each + selling plan has on variants when they're purchased. + """ + sellingPlanAllocation: SellingPlanAllocation +} + +""" +The cost of the merchandise line that the buyer will pay at checkout. +""" +type CartLineCost { + """ + The amount of the merchandise line. + """ + amountPerQuantity: MoneyV2! + + """ + The compare at amount of the merchandise line. This value varies depending on + the buyer's identity, and is null when the value is hidden to buyers. + """ + compareAtAmountPerQuantity: MoneyV2 + + """ + The cost of the merchandise line before line-level discounts. + """ + subtotalAmount: MoneyV2! + + """ + The total cost of the merchandise line. + """ + totalAmount: MoneyV2! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. +""" +input CartLineTarget { + """ + The ID of the targeted cart line. + """ + id: ID! + + """ + The number of line items that are being discounted. + The default value is `null`, which represents the quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents whether the product is a member of the given collection. +""" +type CollectionMembership { + """ + The ID of the collection. + """ + collectionId: ID! + + """ + Whether the product is a member of the collection. + """ + isMember: Boolean! +} + +""" +Represents information about a company which is also a customer of the shop. +""" +type Company implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's main point of contact. +""" +type CompanyContact { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was created in Shopify. + """ + createdAt: DateTime! + + """ + The ID of the company. + """ + id: ID! + + """ + The company contact's locale (language). + """ + locale: String + + """ + The company contact's job title. + """ + title: String + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's location. +""" +type CompanyLocation implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + The preferred locale of the company location. + """ + locale: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company location. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was last modified. + """ + updatedAt: DateTime! +} + +""" +A country. +""" +type Country { + """ + The ISO code of the country. + """ + isoCode: CountryCode! +} + +""" +The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. +If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision +of another country. For example, the territories associated with Spain are represented by the country code `ES`, +and the territories associated with the United States of America are represented by the country code `US`. +""" +enum CountryCode { + """ + Ascension Island. + """ + AC + + """ + Andorra. + """ + AD + + """ + United Arab Emirates. + """ + AE + + """ + Afghanistan. + """ + AF + + """ + Antigua & Barbuda. + """ + AG + + """ + Anguilla. + """ + AI + + """ + Albania. + """ + AL + + """ + Armenia. + """ + AM + + """ + Netherlands Antilles. + """ + AN + + """ + Angola. + """ + AO + + """ + Argentina. + """ + AR + + """ + Austria. + """ + AT + + """ + Australia. + """ + AU + + """ + Aruba. + """ + AW + + """ + Åland Islands. + """ + AX + + """ + Azerbaijan. + """ + AZ + + """ + Bosnia & Herzegovina. + """ + BA + + """ + Barbados. + """ + BB + + """ + Bangladesh. + """ + BD + + """ + Belgium. + """ + BE + + """ + Burkina Faso. + """ + BF + + """ + Bulgaria. + """ + BG + + """ + Bahrain. + """ + BH + + """ + Burundi. + """ + BI + + """ + Benin. + """ + BJ + + """ + St. Barthélemy. + """ + BL + + """ + Bermuda. + """ + BM + + """ + Brunei. + """ + BN + + """ + Bolivia. + """ + BO + + """ + Caribbean Netherlands. + """ + BQ + + """ + Brazil. + """ + BR + + """ + Bahamas. + """ + BS + + """ + Bhutan. + """ + BT + + """ + Bouvet Island. + """ + BV + + """ + Botswana. + """ + BW + + """ + Belarus. + """ + BY + + """ + Belize. + """ + BZ + + """ + Canada. + """ + CA + + """ + Cocos (Keeling) Islands. + """ + CC + + """ + Congo - Kinshasa. + """ + CD + + """ + Central African Republic. + """ + CF + + """ + Congo - Brazzaville. + """ + CG + + """ + Switzerland. + """ + CH + + """ + Côte d’Ivoire. + """ + CI + + """ + Cook Islands. + """ + CK + + """ + Chile. + """ + CL + + """ + Cameroon. + """ + CM + + """ + China. + """ + CN + + """ + Colombia. + """ + CO + + """ + Costa Rica. + """ + CR + + """ + Cuba. + """ + CU + + """ + Cape Verde. + """ + CV + + """ + Curaçao. + """ + CW + + """ + Christmas Island. + """ + CX + + """ + Cyprus. + """ + CY + + """ + Czechia. + """ + CZ + + """ + Germany. + """ + DE + + """ + Djibouti. + """ + DJ + + """ + Denmark. + """ + DK + + """ + Dominica. + """ + DM + + """ + Dominican Republic. + """ + DO + + """ + Algeria. + """ + DZ + + """ + Ecuador. + """ + EC + + """ + Estonia. + """ + EE + + """ + Egypt. + """ + EG + + """ + Western Sahara. + """ + EH + + """ + Eritrea. + """ + ER + + """ + Spain. + """ + ES + + """ + Ethiopia. + """ + ET + + """ + Finland. + """ + FI + + """ + Fiji. + """ + FJ + + """ + Falkland Islands. + """ + FK + + """ + Faroe Islands. + """ + FO + + """ + France. + """ + FR + + """ + Gabon. + """ + GA + + """ + United Kingdom. + """ + GB + + """ + Grenada. + """ + GD + + """ + Georgia. + """ + GE + + """ + French Guiana. + """ + GF + + """ + Guernsey. + """ + GG + + """ + Ghana. + """ + GH + + """ + Gibraltar. + """ + GI + + """ + Greenland. + """ + GL + + """ + Gambia. + """ + GM + + """ + Guinea. + """ + GN + + """ + Guadeloupe. + """ + GP + + """ + Equatorial Guinea. + """ + GQ + + """ + Greece. + """ + GR + + """ + South Georgia & South Sandwich Islands. + """ + GS + + """ + Guatemala. + """ + GT + + """ + Guinea-Bissau. + """ + GW + + """ + Guyana. + """ + GY + + """ + Hong Kong SAR. + """ + HK + + """ + Heard & McDonald Islands. + """ + HM + + """ + Honduras. + """ + HN + + """ + Croatia. + """ + HR + + """ + Haiti. + """ + HT + + """ + Hungary. + """ + HU + + """ + Indonesia. + """ + ID + + """ + Ireland. + """ + IE + + """ + Israel. + """ + IL + + """ + Isle of Man. + """ + IM + + """ + India. + """ + IN + + """ + British Indian Ocean Territory. + """ + IO + + """ + Iraq. + """ + IQ + + """ + Iran. + """ + IR + + """ + Iceland. + """ + IS + + """ + Italy. + """ + IT + + """ + Jersey. + """ + JE + + """ + Jamaica. + """ + JM + + """ + Jordan. + """ + JO + + """ + Japan. + """ + JP + + """ + Kenya. + """ + KE + + """ + Kyrgyzstan. + """ + KG + + """ + Cambodia. + """ + KH + + """ + Kiribati. + """ + KI + + """ + Comoros. + """ + KM + + """ + St. Kitts & Nevis. + """ + KN + + """ + North Korea. + """ + KP + + """ + South Korea. + """ + KR + + """ + Kuwait. + """ + KW + + """ + Cayman Islands. + """ + KY + + """ + Kazakhstan. + """ + KZ + + """ + Laos. + """ + LA + + """ + Lebanon. + """ + LB + + """ + St. Lucia. + """ + LC + + """ + Liechtenstein. + """ + LI + + """ + Sri Lanka. + """ + LK + + """ + Liberia. + """ + LR + + """ + Lesotho. + """ + LS + + """ + Lithuania. + """ + LT + + """ + Luxembourg. + """ + LU + + """ + Latvia. + """ + LV + + """ + Libya. + """ + LY + + """ + Morocco. + """ + MA + + """ + Monaco. + """ + MC + + """ + Moldova. + """ + MD + + """ + Montenegro. + """ + ME + + """ + St. Martin. + """ + MF + + """ + Madagascar. + """ + MG + + """ + North Macedonia. + """ + MK + + """ + Mali. + """ + ML + + """ + Myanmar (Burma). + """ + MM + + """ + Mongolia. + """ + MN + + """ + Macao SAR. + """ + MO + + """ + Martinique. + """ + MQ + + """ + Mauritania. + """ + MR + + """ + Montserrat. + """ + MS + + """ + Malta. + """ + MT + + """ + Mauritius. + """ + MU + + """ + Maldives. + """ + MV + + """ + Malawi. + """ + MW + + """ + Mexico. + """ + MX + + """ + Malaysia. + """ + MY + + """ + Mozambique. + """ + MZ + + """ + Namibia. + """ + NA + + """ + New Caledonia. + """ + NC + + """ + Niger. + """ + NE + + """ + Norfolk Island. + """ + NF + + """ + Nigeria. + """ + NG + + """ + Nicaragua. + """ + NI + + """ + Netherlands. + """ + NL + + """ + Norway. + """ + NO + + """ + Nepal. + """ + NP + + """ + Nauru. + """ + NR + + """ + Niue. + """ + NU + + """ + New Zealand. + """ + NZ + + """ + Oman. + """ + OM + + """ + Panama. + """ + PA + + """ + Peru. + """ + PE + + """ + French Polynesia. + """ + PF + + """ + Papua New Guinea. + """ + PG + + """ + Philippines. + """ + PH + + """ + Pakistan. + """ + PK + + """ + Poland. + """ + PL + + """ + St. Pierre & Miquelon. + """ + PM + + """ + Pitcairn Islands. + """ + PN + + """ + Palestinian Territories. + """ + PS + + """ + Portugal. + """ + PT + + """ + Paraguay. + """ + PY + + """ + Qatar. + """ + QA + + """ + Réunion. + """ + RE + + """ + Romania. + """ + RO + + """ + Serbia. + """ + RS + + """ + Russia. + """ + RU + + """ + Rwanda. + """ + RW + + """ + Saudi Arabia. + """ + SA + + """ + Solomon Islands. + """ + SB + + """ + Seychelles. + """ + SC + + """ + Sudan. + """ + SD + + """ + Sweden. + """ + SE + + """ + Singapore. + """ + SG + + """ + St. Helena. + """ + SH + + """ + Slovenia. + """ + SI + + """ + Svalbard & Jan Mayen. + """ + SJ + + """ + Slovakia. + """ + SK + + """ + Sierra Leone. + """ + SL + + """ + San Marino. + """ + SM + + """ + Senegal. + """ + SN + + """ + Somalia. + """ + SO + + """ + Suriname. + """ + SR + + """ + South Sudan. + """ + SS + + """ + São Tomé & Príncipe. + """ + ST + + """ + El Salvador. + """ + SV + + """ + Sint Maarten. + """ + SX + + """ + Syria. + """ + SY + + """ + Eswatini. + """ + SZ + + """ + Tristan da Cunha. + """ + TA + + """ + Turks & Caicos Islands. + """ + TC + + """ + Chad. + """ + TD + + """ + French Southern Territories. + """ + TF + + """ + Togo. + """ + TG + + """ + Thailand. + """ + TH + + """ + Tajikistan. + """ + TJ + + """ + Tokelau. + """ + TK + + """ + Timor-Leste. + """ + TL + + """ + Turkmenistan. + """ + TM + + """ + Tunisia. + """ + TN + + """ + Tonga. + """ + TO + + """ + Türkiye. + """ + TR + + """ + Trinidad & Tobago. + """ + TT + + """ + Tuvalu. + """ + TV + + """ + Taiwan. + """ + TW + + """ + Tanzania. + """ + TZ + + """ + Ukraine. + """ + UA + + """ + Uganda. + """ + UG + + """ + U.S. Outlying Islands. + """ + UM + + """ + United States. + """ + US + + """ + Uruguay. + """ + UY + + """ + Uzbekistan. + """ + UZ + + """ + Vatican City. + """ + VA + + """ + St. Vincent & Grenadines. + """ + VC + + """ + Venezuela. + """ + VE + + """ + British Virgin Islands. + """ + VG + + """ + Vietnam. + """ + VN + + """ + Vanuatu. + """ + VU + + """ + Wallis & Futuna. + """ + WF + + """ + Samoa. + """ + WS + + """ + Kosovo. + """ + XK + + """ + Yemen. + """ + YE + + """ + Mayotte. + """ + YT + + """ + South Africa. + """ + ZA + + """ + Zambia. + """ + ZM + + """ + Zimbabwe. + """ + ZW + + """ + Unknown Region. + """ + ZZ +} + +""" +The three-letter currency codes that represent the world currencies used in +stores. These include standard ISO 4217 codes, legacy codes, +and non-standard codes. +""" +enum CurrencyCode { + """ + United Arab Emirates Dirham (AED). + """ + AED + + """ + Afghan Afghani (AFN). + """ + AFN + + """ + Albanian Lek (ALL). + """ + ALL + + """ + Armenian Dram (AMD). + """ + AMD + + """ + Netherlands Antillean Guilder. + """ + ANG + + """ + Angolan Kwanza (AOA). + """ + AOA + + """ + Argentine Pesos (ARS). + """ + ARS + + """ + Australian Dollars (AUD). + """ + AUD + + """ + Aruban Florin (AWG). + """ + AWG + + """ + Azerbaijani Manat (AZN). + """ + AZN + + """ + Bosnia and Herzegovina Convertible Mark (BAM). + """ + BAM + + """ + Barbadian Dollar (BBD). + """ + BBD + + """ + Bangladesh Taka (BDT). + """ + BDT + + """ + Bulgarian Lev (BGN). + """ + BGN + + """ + Bahraini Dinar (BHD). + """ + BHD + + """ + Burundian Franc (BIF). + """ + BIF + + """ + Bermudian Dollar (BMD). + """ + BMD + + """ + Brunei Dollar (BND). + """ + BND + + """ + Bolivian Boliviano (BOB). + """ + BOB + + """ + Brazilian Real (BRL). + """ + BRL + + """ + Bahamian Dollar (BSD). + """ + BSD + + """ + Bhutanese Ngultrum (BTN). + """ + BTN + + """ + Botswana Pula (BWP). + """ + BWP + + """ + Belarusian Ruble (BYN). + """ + BYN + + """ + Belarusian Ruble (BYR). + """ + BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") + + """ + Belize Dollar (BZD). + """ + BZD + + """ + Canadian Dollars (CAD). + """ + CAD + + """ + Congolese franc (CDF). + """ + CDF + + """ + Swiss Francs (CHF). + """ + CHF + + """ + Chilean Peso (CLP). + """ + CLP + + """ + Chinese Yuan Renminbi (CNY). + """ + CNY + + """ + Colombian Peso (COP). + """ + COP + + """ + Costa Rican Colones (CRC). + """ + CRC + + """ + Cape Verdean escudo (CVE). + """ + CVE + + """ + Czech Koruny (CZK). + """ + CZK + + """ + Djiboutian Franc (DJF). + """ + DJF + + """ + Danish Kroner (DKK). + """ + DKK + + """ + Dominican Peso (DOP). + """ + DOP + + """ + Algerian Dinar (DZD). + """ + DZD + + """ + Egyptian Pound (EGP). + """ + EGP + + """ + Eritrean Nakfa (ERN). + """ + ERN + + """ + Ethiopian Birr (ETB). + """ + ETB + + """ + Euro (EUR). + """ + EUR + + """ + Fijian Dollars (FJD). + """ + FJD + + """ + Falkland Islands Pounds (FKP). + """ + FKP + + """ + United Kingdom Pounds (GBP). + """ + GBP + + """ + Georgian Lari (GEL). + """ + GEL + + """ + Ghanaian Cedi (GHS). + """ + GHS + + """ + Gibraltar Pounds (GIP). + """ + GIP + + """ + Gambian Dalasi (GMD). + """ + GMD + + """ + Guinean Franc (GNF). + """ + GNF + + """ + Guatemalan Quetzal (GTQ). + """ + GTQ + + """ + Guyanese Dollar (GYD). + """ + GYD + + """ + Hong Kong Dollars (HKD). + """ + HKD + + """ + Honduran Lempira (HNL). + """ + HNL + + """ + Croatian Kuna (HRK). + """ + HRK + + """ + Haitian Gourde (HTG). + """ + HTG + + """ + Hungarian Forint (HUF). + """ + HUF + + """ + Indonesian Rupiah (IDR). + """ + IDR + + """ + Israeli New Shekel (NIS). + """ + ILS + + """ + Indian Rupees (INR). + """ + INR + + """ + Iraqi Dinar (IQD). + """ + IQD + + """ + Iranian Rial (IRR). + """ + IRR + + """ + Icelandic Kronur (ISK). + """ + ISK + + """ + Jersey Pound. + """ + JEP + + """ + Jamaican Dollars (JMD). + """ + JMD + + """ + Jordanian Dinar (JOD). + """ + JOD + + """ + Japanese Yen (JPY). + """ + JPY + + """ + Kenyan Shilling (KES). + """ + KES + + """ + Kyrgyzstani Som (KGS). + """ + KGS + + """ + Cambodian Riel. + """ + KHR + + """ + Kiribati Dollar (KID). + """ + KID + + """ + Comorian Franc (KMF). + """ + KMF + + """ + South Korean Won (KRW). + """ + KRW + + """ + Kuwaiti Dinar (KWD). + """ + KWD + + """ + Cayman Dollars (KYD). + """ + KYD + + """ + Kazakhstani Tenge (KZT). + """ + KZT + + """ + Laotian Kip (LAK). + """ + LAK + + """ + Lebanese Pounds (LBP). + """ + LBP + + """ + Sri Lankan Rupees (LKR). + """ + LKR + + """ + Liberian Dollar (LRD). + """ + LRD + + """ + Lesotho Loti (LSL). + """ + LSL + + """ + Lithuanian Litai (LTL). + """ + LTL + + """ + Latvian Lati (LVL). + """ + LVL + + """ + Libyan Dinar (LYD). + """ + LYD + + """ + Moroccan Dirham. + """ + MAD + + """ + Moldovan Leu (MDL). + """ + MDL + + """ + Malagasy Ariary (MGA). + """ + MGA + + """ + Macedonia Denar (MKD). + """ + MKD + + """ + Burmese Kyat (MMK). + """ + MMK + + """ + Mongolian Tugrik. + """ + MNT + + """ + Macanese Pataca (MOP). + """ + MOP + + """ + Mauritanian Ouguiya (MRU). + """ + MRU + + """ + Mauritian Rupee (MUR). + """ + MUR + + """ + Maldivian Rufiyaa (MVR). + """ + MVR + + """ + Malawian Kwacha (MWK). + """ + MWK + + """ + Mexican Pesos (MXN). + """ + MXN + + """ + Malaysian Ringgits (MYR). + """ + MYR + + """ + Mozambican Metical. + """ + MZN + + """ + Namibian Dollar. + """ + NAD + + """ + Nigerian Naira (NGN). + """ + NGN + + """ + Nicaraguan Córdoba (NIO). + """ + NIO + + """ + Norwegian Kroner (NOK). + """ + NOK + + """ + Nepalese Rupee (NPR). + """ + NPR + + """ + New Zealand Dollars (NZD). + """ + NZD + + """ + Omani Rial (OMR). + """ + OMR + + """ + Panamian Balboa (PAB). + """ + PAB + + """ + Peruvian Nuevo Sol (PEN). + """ + PEN + + """ + Papua New Guinean Kina (PGK). + """ + PGK + + """ + Philippine Peso (PHP). + """ + PHP + + """ + Pakistani Rupee (PKR). + """ + PKR + + """ + Polish Zlotych (PLN). + """ + PLN + + """ + Paraguayan Guarani (PYG). + """ + PYG + + """ + Qatari Rial (QAR). + """ + QAR + + """ + Romanian Lei (RON). + """ + RON + + """ + Serbian dinar (RSD). + """ + RSD + + """ + Russian Rubles (RUB). + """ + RUB + + """ + Rwandan Franc (RWF). + """ + RWF + + """ + Saudi Riyal (SAR). + """ + SAR + + """ + Solomon Islands Dollar (SBD). + """ + SBD + + """ + Seychellois Rupee (SCR). + """ + SCR + + """ + Sudanese Pound (SDG). + """ + SDG + + """ + Swedish Kronor (SEK). + """ + SEK + + """ + Singapore Dollars (SGD). + """ + SGD + + """ + Saint Helena Pounds (SHP). + """ + SHP + + """ + Sierra Leonean Leone (SLL). + """ + SLL + + """ + Somali Shilling (SOS). + """ + SOS + + """ + Surinamese Dollar (SRD). + """ + SRD + + """ + South Sudanese Pound (SSP). + """ + SSP + + """ + Sao Tome And Principe Dobra (STD). + """ + STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") + + """ + Sao Tome And Principe Dobra (STN). + """ + STN + + """ + Syrian Pound (SYP). + """ + SYP + + """ + Swazi Lilangeni (SZL). + """ + SZL + + """ + Thai baht (THB). + """ + THB + + """ + Tajikistani Somoni (TJS). + """ + TJS + + """ + Turkmenistani Manat (TMT). + """ + TMT + + """ + Tunisian Dinar (TND). + """ + TND + + """ + Tongan Pa'anga (TOP). + """ + TOP + + """ + Turkish Lira (TRY). + """ + TRY + + """ + Trinidad and Tobago Dollars (TTD). + """ + TTD + + """ + Taiwan Dollars (TWD). + """ + TWD + + """ + Tanzanian Shilling (TZS). + """ + TZS + + """ + Ukrainian Hryvnia (UAH). + """ + UAH + + """ + Ugandan Shilling (UGX). + """ + UGX + + """ + United States Dollars (USD). + """ + USD + + """ + Uruguayan Pesos (UYU). + """ + UYU + + """ + Uzbekistan som (UZS). + """ + UZS + + """ + Venezuelan Bolivares (VED). + """ + VED + + """ + Venezuelan Bolivares (VEF). + """ + VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") + + """ + Venezuelan Bolivares Soberanos (VES). + """ + VES + + """ + Vietnamese đồng (VND). + """ + VND + + """ + Vanuatu Vatu (VUV). + """ + VUV + + """ + Samoan Tala (WST). + """ + WST + + """ + Central African CFA Franc (XAF). + """ + XAF + + """ + East Caribbean Dollar (XCD). + """ + XCD + + """ + West African CFA franc (XOF). + """ + XOF + + """ + CFP Franc (XPF). + """ + XPF + + """ + Unrecognized currency. + """ + XXX + + """ + Yemeni Rial (YER). + """ + YER + + """ + South African Rand (ZAR). + """ + ZAR + + """ + Zambian Kwacha (ZMW). + """ + ZMW +} + +""" +A custom product. +""" +type CustomProduct { + """ + Whether the merchandise is a gift card. + """ + isGiftCard: Boolean! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +Represents a customer with the shop. +""" +type Customer implements HasMetafields { + """ + The total amount of money spent by the customer. Converted from the shop's + currency to the currency of the cart using a market rate. + """ + amountSpent: MoneyV2! + + """ + The customer’s name, email or phone number. + """ + displayName: String! + + """ + The customer’s email address. + """ + email: String + + """ + The customer's first name. + """ + firstName: String + + """ + Whether the customer has any of the given tags. + """ + hasAnyTag( + """ + The tags to search for. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the customer has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A unique identifier for the customer. + """ + id: ID! + + """ + The customer's last name. + """ + lastName: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The number of orders made by the customer. + """ + numberOfOrders: Int! +} + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. +For example, September 7, 2019 is represented as `"2019-07-16"`. +""" +scalar Date + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. +For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is +represented as `"2019-09-07T15:50:00Z`". +""" +scalar DateTime + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the date and time but not the timezone which is determined from context. + +For example, "2018-01-01T00:00:00". +""" +scalar DateTimeWithoutTimezone + +""" +A signed decimal number, which supports arbitrary precision and is serialized as a string. + +Example values: `"29.99"`, `"29.999"`. +""" +scalar Decimal + +""" +Represents information about the merchandise in the cart. +""" +type DeliverableCartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! +} + +""" +List of different delivery method types. +""" +enum DeliveryMethod { + """ + Local Delivery. + """ + LOCAL + + """ + None. + """ + NONE + + """ + Shipping to a Pickup Point. + """ + PICKUP_POINT + + """ + Local Pickup. + """ + PICK_UP + + """ + Retail. + """ + RETAIL + + """ + Shipping. + """ + SHIPPING +} + +""" +The discount to be applied. +""" +input Discount { + """ + The discount message. + """ + message: String + + """ + The targets of the discount. + + This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + """ + targets: [Target!]! + + """ + The value of the discount. + """ + value: Value! +} + +""" +The strategy that's applied to the list of discounts. +""" +enum DiscountApplicationStrategy { + """ + Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. + """ + ALL + + """ + Only apply the first discount with conditions that are satisfied. + """ + FIRST + + """ + Only apply the discount that offers the maximum reduction. + """ + MAXIMUM +} + +""" +A discount wrapper node. +""" +type DiscountNode implements HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A fixed amount value. +""" +input FixedAmount { + """ + The fixed amount value of the discount, in the currency of the cart. + + The amount must be greater than or equal to 0. + """ + amount: Decimal! + + """ + Whether to apply the value to each entitled item. + + The default value is `false`, which causes the value to be applied once across the entitled items. + When the value is `true`, the value will be applied to each of the entitled items. + """ + appliesToEachItem: Boolean +} + +""" +The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +""" +input FunctionResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +The run target result. +""" +input FunctionRunResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +A function-scoped handle to a refer a resource. +The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. +Example value: `"10079785100"` +""" +scalar Handle + +""" +Represents information about the metafields associated to the specified resource. +""" +interface HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +Represents whether the current object has the given tag. +""" +type HasTagResponse { + """ + Whether the current object has the tag. + """ + hasTag: Boolean! + + """ + The tag. + """ + tag: String! +} + +""" +Represents a unique identifier, often used to refetch an object. +The ID type appears in a JSON response as a String, but it is not intended to be human-readable. + +Example value: `"gid://shopify/Product/10079785100"` +""" +scalar ID + +""" +The input object for the function. +""" +type Input { + """ + The cart. + """ + cart: Cart! + + """ + The discount node executing the function. + """ + discountNode: DiscountNode! + + """ + The localization of the Function execution context. + """ + localization: Localization! + + """ + The conversion rate between the shop's currency and the currency of the cart. + """ + presentmentCurrencyRate: Decimal! + + """ + Information about the shop. + """ + shop: Shop! +} + +""" +A [JSON](https://www.json.org/json-en.html) object. + +Example value: +`{ + "product": { + "id": "gid://shopify/Product/1346443542550", + "title": "White T-shirt", + "options": [{ + "name": "Size", + "values": ["M", "L"] + }] + } +}` +""" +scalar JSON + +""" +A language. +""" +type Language { + """ + The ISO code. + """ + isoCode: LanguageCode! +} + +""" +Language codes supported by Shopify. +""" +enum LanguageCode { + """ + Afrikaans. + """ + AF + + """ + Akan. + """ + AK + + """ + Amharic. + """ + AM + + """ + Arabic. + """ + AR + + """ + Assamese. + """ + AS + + """ + Azerbaijani. + """ + AZ + + """ + Belarusian. + """ + BE + + """ + Bulgarian. + """ + BG + + """ + Bambara. + """ + BM + + """ + Bangla. + """ + BN + + """ + Tibetan. + """ + BO + + """ + Breton. + """ + BR + + """ + Bosnian. + """ + BS + + """ + Catalan. + """ + CA + + """ + Chechen. + """ + CE + + """ + Central Kurdish. + """ + CKB + + """ + Czech. + """ + CS + + """ + Church Slavic. + """ + CU + + """ + Welsh. + """ + CY + + """ + Danish. + """ + DA + + """ + German. + """ + DE + + """ + Dzongkha. + """ + DZ + + """ + Ewe. + """ + EE + + """ + Greek. + """ + EL + + """ + English. + """ + EN + + """ + Esperanto. + """ + EO + + """ + Spanish. + """ + ES + + """ + Estonian. + """ + ET + + """ + Basque. + """ + EU + + """ + Persian. + """ + FA + + """ + Fulah. + """ + FF + + """ + Finnish. + """ + FI + + """ + Filipino. + """ + FIL + + """ + Faroese. + """ + FO + + """ + French. + """ + FR + + """ + Western Frisian. + """ + FY + + """ + Irish. + """ + GA + + """ + Scottish Gaelic. + """ + GD + + """ + Galician. + """ + GL + + """ + Gujarati. + """ + GU + + """ + Manx. + """ + GV + + """ + Hausa. + """ + HA + + """ + Hebrew. + """ + HE + + """ + Hindi. + """ + HI + + """ + Croatian. + """ + HR + + """ + Hungarian. + """ + HU + + """ + Armenian. + """ + HY + + """ + Interlingua. + """ + IA + + """ + Indonesian. + """ + ID + + """ + Igbo. + """ + IG + + """ + Sichuan Yi. + """ + II + + """ + Icelandic. + """ + IS + + """ + Italian. + """ + IT + + """ + Japanese. + """ + JA + + """ + Javanese. + """ + JV + + """ + Georgian. + """ + KA + + """ + Kikuyu. + """ + KI + + """ + Kazakh. + """ + KK + + """ + Kalaallisut. + """ + KL + + """ + Khmer. + """ + KM + + """ + Kannada. + """ + KN + + """ + Korean. + """ + KO + + """ + Kashmiri. + """ + KS + + """ + Kurdish. + """ + KU + + """ + Cornish. + """ + KW + + """ + Kyrgyz. + """ + KY + + """ + Luxembourgish. + """ + LB + + """ + Ganda. + """ + LG + + """ + Lingala. + """ + LN + + """ + Lao. + """ + LO + + """ + Lithuanian. + """ + LT + + """ + Luba-Katanga. + """ + LU + + """ + Latvian. + """ + LV + + """ + Malagasy. + """ + MG + + """ + Māori. + """ + MI + + """ + Macedonian. + """ + MK + + """ + Malayalam. + """ + ML + + """ + Mongolian. + """ + MN + + """ + Marathi. + """ + MR + + """ + Malay. + """ + MS + + """ + Maltese. + """ + MT + + """ + Burmese. + """ + MY + + """ + Norwegian (Bokmål). + """ + NB + + """ + North Ndebele. + """ + ND + + """ + Nepali. + """ + NE + + """ + Dutch. + """ + NL + + """ + Norwegian Nynorsk. + """ + NN + + """ + Norwegian. + """ + NO + + """ + Oromo. + """ + OM + + """ + Odia. + """ + OR + + """ + Ossetic. + """ + OS + + """ + Punjabi. + """ + PA + + """ + Polish. + """ + PL + + """ + Pashto. + """ + PS + + """ + Portuguese. + """ + PT + + """ + Portuguese (Brazil). + """ + PT_BR + + """ + Portuguese (Portugal). + """ + PT_PT + + """ + Quechua. + """ + QU + + """ + Romansh. + """ + RM + + """ + Rundi. + """ + RN + + """ + Romanian. + """ + RO + + """ + Russian. + """ + RU + + """ + Kinyarwanda. + """ + RW + + """ + Sanskrit. + """ + SA + + """ + Sardinian. + """ + SC + + """ + Sindhi. + """ + SD + + """ + Northern Sami. + """ + SE + + """ + Sango. + """ + SG + + """ + Sinhala. + """ + SI + + """ + Slovak. + """ + SK + + """ + Slovenian. + """ + SL + + """ + Shona. + """ + SN + + """ + Somali. + """ + SO + + """ + Albanian. + """ + SQ + + """ + Serbian. + """ + SR + + """ + Sundanese. + """ + SU + + """ + Swedish. + """ + SV + + """ + Swahili. + """ + SW + + """ + Tamil. + """ + TA + + """ + Telugu. + """ + TE + + """ + Tajik. + """ + TG + + """ + Thai. + """ + TH + + """ + Tigrinya. + """ + TI + + """ + Turkmen. + """ + TK + + """ + Tongan. + """ + TO + + """ + Turkish. + """ + TR + + """ + Tatar. + """ + TT + + """ + Uyghur. + """ + UG + + """ + Ukrainian. + """ + UK + + """ + Urdu. + """ + UR + + """ + Uzbek. + """ + UZ + + """ + Vietnamese. + """ + VI + + """ + Volapük. + """ + VO + + """ + Wolof. + """ + WO + + """ + Xhosa. + """ + XH + + """ + Yiddish. + """ + YI + + """ + Yoruba. + """ + YO + + """ + Chinese. + """ + ZH + + """ + Chinese (Simplified). + """ + ZH_CN + + """ + Chinese (Traditional). + """ + ZH_TW + + """ + Zulu. + """ + ZU +} + +""" +Represents limited information about the current time relative to the parent object. +""" +type LocalTime { + """ + The current date relative to the parent object. + """ + date: Date! + + """ + Returns true if the current date and time is at or past the given date and time, and false otherwise. + """ + dateTimeAfter( + """ + The date and time to compare against, assumed to be in the timezone of the parent object. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is before the given date and time, and false otherwise. + """ + dateTimeBefore( + """ + The date and time to compare against, assumed to be in the timezone of the parent timezone. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is between the two given date and times, and false otherwise. + """ + dateTimeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endDateTime: DateTimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startDateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeAfter( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeBefore( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is between the two given times, and false otherwise. + """ + timeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endTime: TimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startTime: TimeWithoutTimezone! + ): Boolean! +} + +""" +Information about the localized experiences configured for the shop. +""" +type Localization { + """ + The country of the active localized experience. + """ + country: Country! + + """ + The language of the active localized experience. + """ + language: Language! + + """ + The market of the active localized experience. + """ + market: Market! +} + +""" +Represents the value captured by a localized field. Localized fields are +additional fields required by certain countries on international orders. For +example, some countries require additional fields for customs information or tax +identification numbers. +""" +type LocalizedField { + """ + The key of the localized field. + """ + key: LocalizedFieldKey! + + """ + The title of the localized field. + """ + title: String! + + """ + The value of the localized field. + """ + value: String +} + +""" +Unique key identifying localized fields. +""" +enum LocalizedFieldKey { + """ + Localized field key 'shipping_credential_br' for country BR. + """ + SHIPPING_CREDENTIAL_BR + + """ + Localized field key 'shipping_credential_cl' for country CL. + """ + SHIPPING_CREDENTIAL_CL + + """ + Localized field key 'shipping_credential_cn' for country CN. + """ + SHIPPING_CREDENTIAL_CN + + """ + Localized field key 'shipping_credential_co' for country CO. + """ + SHIPPING_CREDENTIAL_CO + + """ + Localized field key 'shipping_credential_cr' for country CR. + """ + SHIPPING_CREDENTIAL_CR + + """ + Localized field key 'shipping_credential_ec' for country EC. + """ + SHIPPING_CREDENTIAL_EC + + """ + Localized field key 'shipping_credential_es' for country ES. + """ + SHIPPING_CREDENTIAL_ES + + """ + Localized field key 'shipping_credential_gt' for country GT. + """ + SHIPPING_CREDENTIAL_GT + + """ + Localized field key 'shipping_credential_id' for country ID. + """ + SHIPPING_CREDENTIAL_ID + + """ + Localized field key 'shipping_credential_kr' for country KR. + """ + SHIPPING_CREDENTIAL_KR + + """ + Localized field key 'shipping_credential_mx' for country MX. + """ + SHIPPING_CREDENTIAL_MX + + """ + Localized field key 'shipping_credential_my' for country MY. + """ + SHIPPING_CREDENTIAL_MY + + """ + Localized field key 'shipping_credential_pe' for country PE. + """ + SHIPPING_CREDENTIAL_PE + + """ + Localized field key 'shipping_credential_pt' for country PT. + """ + SHIPPING_CREDENTIAL_PT + + """ + Localized field key 'shipping_credential_py' for country PY. + """ + SHIPPING_CREDENTIAL_PY + + """ + Localized field key 'shipping_credential_tr' for country TR. + """ + SHIPPING_CREDENTIAL_TR + + """ + Localized field key 'shipping_credential_tw' for country TW. + """ + SHIPPING_CREDENTIAL_TW + + """ + Localized field key 'shipping_credential_type_co' for country CO. + """ + SHIPPING_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_br' for country BR. + """ + TAX_CREDENTIAL_BR + + """ + Localized field key 'tax_credential_cl' for country CL. + """ + TAX_CREDENTIAL_CL + + """ + Localized field key 'tax_credential_co' for country CO. + """ + TAX_CREDENTIAL_CO + + """ + Localized field key 'tax_credential_cr' for country CR. + """ + TAX_CREDENTIAL_CR + + """ + Localized field key 'tax_credential_ec' for country EC. + """ + TAX_CREDENTIAL_EC + + """ + Localized field key 'tax_credential_es' for country ES. + """ + TAX_CREDENTIAL_ES + + """ + Localized field key 'tax_credential_gt' for country GT. + """ + TAX_CREDENTIAL_GT + + """ + Localized field key 'tax_credential_id' for country ID. + """ + TAX_CREDENTIAL_ID + + """ + Localized field key 'tax_credential_it' for country IT. + """ + TAX_CREDENTIAL_IT + + """ + Localized field key 'tax_credential_mx' for country MX. + """ + TAX_CREDENTIAL_MX + + """ + Localized field key 'tax_credential_my' for country MY. + """ + TAX_CREDENTIAL_MY + + """ + Localized field key 'tax_credential_pe' for country PE. + """ + TAX_CREDENTIAL_PE + + """ + Localized field key 'tax_credential_pt' for country PT. + """ + TAX_CREDENTIAL_PT + + """ + Localized field key 'tax_credential_py' for country PY. + """ + TAX_CREDENTIAL_PY + + """ + Localized field key 'tax_credential_tr' for country TR. + """ + TAX_CREDENTIAL_TR + + """ + Localized field key 'tax_credential_type_co' for country CO. + """ + TAX_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_type_mx' for country MX. + """ + TAX_CREDENTIAL_TYPE_MX + + """ + Localized field key 'tax_credential_use_mx' for country MX. + """ + TAX_CREDENTIAL_USE_MX + + """ + Localized field key 'tax_email_it' for country IT. + """ + TAX_EMAIL_IT +} + +""" +Represents a mailing address. +""" +type MailingAddress { + """ + The first line of the address. Typically the street address or PO Box number. + """ + address1: String + + """ + The second line of the address. Typically the number of the apartment, suite, or unit. + """ + address2: String + + """ + The name of the city, district, village, or town. + """ + city: String + + """ + The name of the customer's company or organization. + """ + company: String + + """ + The two-letter code for the country of the address. For example, US. + """ + countryCode: CountryCode + + """ + The first name of the customer. + """ + firstName: String + + """ + The last name of the customer. + """ + lastName: String + + """ + The approximate latitude of the address. + """ + latitude: Float + + """ + The approximate longitude of the address. + """ + longitude: Float + + """ + The market of the address. + """ + market: Market + + """ + The full name of the customer, based on firstName and lastName. + """ + name: String + + """ + A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. + """ + phone: String + + """ + The alphanumeric code for the region. For example, ON. + """ + provinceCode: String + + """ + The zip or postal code of the address. + """ + zip: String +} + +""" +A market is a group of one or more regions that you want to target for international sales. +By creating a market, you can configure a distinct, localized shopping experience for +customers from a specific area of the world. For example, you can +[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), +[configure international pricing](https://shopify.dev/api/examples/product-price-lists), +or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). +""" +type Market implements HasMetafields { + """ + A human-readable unique string for the market automatically generated from its title. + """ + handle: Handle! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + A geographic region which comprises a market. + """ + regions: [MarketRegion!]! +} + +""" +Represents a region. +""" +interface MarketRegion { + """ + The name of the region in the language of the current localization. + """ + name: String +} + +""" +A country which comprises a market. +""" +type MarketRegionCountry implements MarketRegion { + """ + The two-letter code for the country. + """ + code: CountryCode! + + """ + The country name in the language of the current localization. + """ + name: String! +} + +""" +The merchandise to be purchased at checkout. +""" +union Merchandise = CustomProduct | ProductVariant + +""" +[Metafields](https://shopify.dev/apps/metafields) +enable you to attach additional information to a +Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) +or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). +For more information about the Shopify resources that you can attach metafields to, refer to +[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +""" +type Metafield { + """ + The data stored in the metafield in JSON format. + """ + jsonValue: JSON! + + """ + The type of data that the metafield stores in the `value` field. + Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + """ + type: String! + + """ + The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + """ + value: String! +} + +""" +A monetary value with currency. +""" +type MoneyV2 { + """ + Decimal money amount. + """ + amount: Decimal! + + """ + Currency of the money. + """ + currencyCode: CurrencyCode! +} + +""" +The root mutation for the API. +""" +type MutationRoot { + """ + Handles the Function result. + """ + handleResult( + """ + The result of the Function. + """ + result: FunctionResult! + ): Void! @deprecated(reason: "Use the target-specific field instead.") + + """ + Handles the Function result for the purchase.product-discount.run target. + """ + run( + """ + The result of the Function. + """ + result: FunctionRunResult! + ): Void! +} + +""" +A percentage value. +""" +input Percentage { + """ + The percentage value. + + The value is validated against: >= 0 and <= 100. + """ + value: Decimal! +} + +""" +Represents a product. +""" +type Product implements HasMetafields { + """ + A unique human-friendly string of the product's title. + """ + handle: Handle! + + """ + Whether the product has any of the given tags. + """ + hasAnyTag( + """ + The tags to check. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the product has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Whether the product is in any of the given collections. + """ + inAnyCollection( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): Boolean! + + """ + Whether the product is in the given collections. + """ + inCollections( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): [CollectionMembership!]! + + """ + Whether the product is a gift card. + """ + isGiftCard: Boolean! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product type specified by the merchant. + """ + productType: String + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The name of the product's vendor. + """ + vendor: String +} + +""" +Represents a product variant. +""" +type ProductVariant implements HasMetafields { + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product that this variant belongs to. + """ + product: Product! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + """ + sku: String + + """ + The localized title of the product variant in the customer’s locale. + """ + title: String + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an +optional quantity limit. +""" +input ProductVariantTarget { + """ + The ID of the targeted product variant. + """ + id: ID! + + """ + The maximum number of line item units to be discounted. + The default value is `null`, which represents the total quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type PurchasingCompany { + """ + The company associated to the order or draft order. + """ + company: Company! + + """ + The company contact associated to the order or draft order. + """ + contact: CompanyContact + + """ + The company location associated to the order or draft order. + """ + location: CompanyLocation! +} + +""" +Represents how products and variants can be sold and purchased. +""" +type SellingPlan implements HasMetafields { + """ + The description of the selling plan. + """ + description: String + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. + """ + name: String! + + """ + Whether purchasing the selling plan will result in multiple deliveries. + """ + recurringDeliveries: Boolean! +} + +""" +Represents an association between a variant and a selling plan. Selling plan +allocations describe the options offered for each variant, and the price of the +variant when purchased with a selling plan. +""" +type SellingPlanAllocation { + """ + A list of price adjustments, with a maximum of two. When there are two, the + first price adjustment goes into effect at the time of purchase, while the + second one starts after a certain number of orders. A price adjustment + represents how a selling plan affects pricing when a variant is purchased with + a selling plan. Prices display in the customer's currency if the shop is + configured for it. + """ + priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! + + """ + A representation of how products and variants can be sold and purchased. For + example, an individual selling plan could be '6 weeks of prepaid granola, + delivered weekly'. + """ + sellingPlan: SellingPlan! +} + +""" +The resulting prices for variants when they're purchased with a specific selling plan. +""" +type SellingPlanAllocationPriceAdjustment { + """ + The effective price for a single delivery. For example, for a prepaid + subscription plan that includes 6 deliveries at the price of $48.00, the per + delivery price is $8.00. + """ + perDeliveryPrice: MoneyV2! + + """ + The price of the variant when it's purchased with a selling plan For example, + for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, + where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. + """ + price: MoneyV2! +} + +""" +Information about the shop. +""" +type Shop implements HasMetafields { + """ + Information about the current time relative to the shop's timezone setting. + """ + localTime: LocalTime! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A target of a discount, which determines which cart line(s) the discount will affect. + +A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + +Multiple targets with the same type and ID are the same as a single target of that type and ID with their +quantities added together, or `null` if any of those targets have a quantity of `null`. + +See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. +""" +input Target @oneOf { + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. + """ + cartLine: CartLineTarget + + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an + optional quantity limit. + """ + productVariant: ProductVariantTarget +} + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the time but not the date or timezone which is determined from context. +For example, "05:43:21". +""" +scalar TimeWithoutTimezone + +""" +The value of the discount. +""" +input Value @oneOf { + """ + A fixed amount value. + """ + fixedAmount: FixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +A void type that can be used to return a null value from a mutation. +""" +scalar Void + +""" +Units of measurement for weight. +""" +enum WeightUnit { + """ + Metric system unit of mass. + """ + GRAMS + + """ + 1 kilogram equals 1000 grams. + """ + KILOGRAMS + + """ + Imperial system unit of mass. + """ + OUNCES + + """ + 1 pound equals 16 ounces. + """ + POUNDS +} diff --git a/discounts/javascript/discounts/default/shopify.extension.toml.liquid b/discounts/javascript/discounts/default/shopify.extension.toml.liquid new file mode 100644 index 00000000..6f75e975 --- /dev/null +++ b/discounts/javascript/discounts/default/shopify.extension.toml.liquid @@ -0,0 +1,36 @@ +api_version = "unstable" + +[[extensions]] +name = "t:name" +handle = "{{handle}}" +type = "function" +{% if uid %}uid = "{{ uid }}"{% endif %} +description = "t:description" + + [[extensions.targeting]] + target = "purchase.discount.cart_run" + input_query = "src/run.graphql" + export = "cart_run" + + [[extensions.targeting]] + target = "purchase.discount.cart_fetch" + input_query = "src/run.graphql" + export = "cart_fetch" + + [[extensions.targeting]] + target = "purchase.discount.delivery_run" + input_query = "src/run.graphql" + export = "delivery_run" + + [[extensions.targeting]] + target = "purchase.discount.delivery_fetch" + input_query = "src/run.graphql" + export = "delivery_fetch" + + [extensions.build] + command = "" + path = "dist/function.wasm" + + [extensions.ui.paths] + create = "/" + details = "/" diff --git a/discounts/javascript/discounts/default/src/index.liquid b/discounts/javascript/discounts/default/src/index.liquid new file mode 100644 index 00000000..e12506eb --- /dev/null +++ b/discounts/javascript/discounts/default/src/index.liquid @@ -0,0 +1 @@ +export * from './run'; \ No newline at end of file diff --git a/discounts/javascript/discounts/default/src/run.graphql.liquid b/discounts/javascript/discounts/default/src/run.graphql.liquid new file mode 100644 index 00000000..6f91afaa --- /dev/null +++ b/discounts/javascript/discounts/default/src/run.graphql.liquid @@ -0,0 +1,7 @@ +query RunInput { + discountNode { + metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { + value + } + } +} diff --git a/discounts/javascript/discounts/default/src/run.liquid b/discounts/javascript/discounts/default/src/run.liquid new file mode 100644 index 00000000..a57c3669 --- /dev/null +++ b/discounts/javascript/discounts/default/src/run.liquid @@ -0,0 +1,51 @@ +{%- if flavor contains "vanilla-js" -%} +// @ts-check +import { DiscountApplicationStrategy } from "../generated/api"; + +/** + * @typedef {import("../generated/api").RunInput} RunInput + * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult + */ + +/** + * @type {FunctionRunResult} + */ +const EMPTY_DISCOUNT = { + discountApplicationStrategy: DiscountApplicationStrategy.First, + discounts: [], +}; + +/** + * @param {RunInput} input + * @returns {FunctionRunResult} + */ +export function run(input) { + const configuration = JSON.parse( + input?.discountNode?.metafield?.value ?? "{}" + ); + + return EMPTY_DISCOUNT; +}; +{%- elsif flavor contains "typescript" -%} +import type { + RunInput, + FunctionRunResult +} from "../generated/api"; +import { + DiscountApplicationStrategy, +} from "../generated/api"; + +const EMPTY_DISCOUNT: FunctionRunResult = { + discountApplicationStrategy: DiscountApplicationStrategy.First, + discounts: [], +}; + +type Configuration = {}; + +export function run(input: RunInput): FunctionRunResult { + const configuration: Configuration = JSON.parse( + input?.discountNode?.metafield?.value ?? "{}" + ); + return EMPTY_DISCOUNT; +}; +{%- endif -%} diff --git a/discounts/javascript/discounts/default/src/run.test.liquid b/discounts/javascript/discounts/default/src/run.test.liquid new file mode 100644 index 00000000..3e63b6e2 --- /dev/null +++ b/discounts/javascript/discounts/default/src/run.test.liquid @@ -0,0 +1,44 @@ +{%- if flavor contains "vanilla-js" -%} +import { describe, it, expect } from 'vitest'; +import { run } from './run'; + +/** + * @typedef {import("../generated/api").FunctionResult} FunctionResult + */ + +describe('product discounts function', () => { + it('returns no discounts without configuration', () => { + const result = run({ + discountNode: { + metafield: null + } + }); + const expected = /** @type {FunctionResult} */ ({ + discounts: [], + discountApplicationStrategy: "FIRST", + }); + + expect(result).toEqual(expected); + }); +}); +{%- elsif flavor contains "typescript" -%} +import { describe, it, expect } from 'vitest'; +import { run } from './run'; +import { FunctionResult, DiscountApplicationStrategy } from '../generated/api'; + +describe('product discounts function', () => { + it('returns no discounts without configuration', () => { + const result = run({ + discountNode: { + metafield: null + } + }); + const expected: FunctionResult = { + discounts: [], + discountApplicationStrategy: DiscountApplicationStrategy.First, + }; + + expect(result).toEqual(expected); + }); +}); +{%- endif -%} diff --git a/discounts/javascript/discounts/default/vite.config.js b/discounts/javascript/discounts/default/vite.config.js new file mode 100644 index 00000000..210c90d4 --- /dev/null +++ b/discounts/javascript/discounts/default/vite.config.js @@ -0,0 +1 @@ +// Prevents inheritance from parent Remix project diff --git a/discounts/rust/discounts/default/.gitignore b/discounts/rust/discounts/default/.gitignore new file mode 100644 index 00000000..96ef6c0b --- /dev/null +++ b/discounts/rust/discounts/default/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/discounts/rust/discounts/default/Cargo.toml.liquid b/discounts/rust/discounts/default/Cargo.toml.liquid new file mode 100644 index 00000000..ab5dd988 --- /dev/null +++ b/discounts/rust/discounts/default/Cargo.toml.liquid @@ -0,0 +1,16 @@ +[package] +name = "{{handle | replace: " ", "-" | downcase}}" +version = "1.0.0" +edition = "2021" +rust-version = "1.62" + +[dependencies] +serde = { version = "1.0.13", features = ["derive"] } +serde_json = "1.0" +shopify_function = "0.8.1" +graphql_client = "0.14.0" + +[profile.release] +lto = true +opt-level = 'z' +strip = true diff --git a/discounts/rust/discounts/default/README.md b/discounts/rust/discounts/default/README.md new file mode 100644 index 00000000..574afb9c --- /dev/null +++ b/discounts/rust/discounts/default/README.md @@ -0,0 +1,16 @@ +# Shopify Function development with Rust + +## Dependencies + +- [Install Rust](https://www.rust-lang.org/tools/install) + - On Windows, Rust requires the [Microsoft C++ Build Tools](https://docs.microsoft.com/en-us/windows/dev-environment/rust/setup). Be sure to select the _Desktop development with C++_ workload when installing them. + +## Building the function + +You can build this individual function using `cargo build`. + +```shell +cargo build --target=wasm32-wasip1 --release +``` + +The Shopify CLI `build` command will also execute this, based on the configuration in `shopify.extension.toml`. diff --git a/discounts/rust/discounts/default/locales/en.default.json.liquid b/discounts/rust/discounts/default/locales/en.default.json.liquid new file mode 100644 index 00000000..333045ae --- /dev/null +++ b/discounts/rust/discounts/default/locales/en.default.json.liquid @@ -0,0 +1,4 @@ +{ + "name": "{{name}}", + "description": "{{name}}" +} diff --git a/discounts/rust/discounts/default/schema.graphql b/discounts/rust/discounts/default/schema.graphql new file mode 100644 index 00000000..3ca4e22b --- /dev/null +++ b/discounts/rust/discounts/default/schema.graphql @@ -0,0 +1,4518 @@ +schema { + query: Input + mutation: MutationRoot +} + +""" +Scale the Functions resource limits based on the field's length. +""" +directive @scaleLimits(rate: Float!) on FIELD_DEFINITION + +""" +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +Represents a generic custom attribute, such as whether an order is a customer's first. +""" +type Attribute { + """ + The key or name of the attribute. For example, `"customersFirstOrder"`. + """ + key: String! + + """ + The value of the attribute. For example, `"true"`. + """ + value: String +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type BuyerIdentity { + """ + The customer associated with the cart. + """ + customer: Customer + + """ + The email address of the buyer that's interacting with the cart. + """ + email: String + + """ + Whether the buyer authenticated with a customer account. + """ + isAuthenticated: Boolean! + + """ + The phone number of the buyer that's interacting with the cart. + """ + phone: String + + """ + The purchasing company associated with the cart. + """ + purchasingCompany: PurchasingCompany +} + +""" +A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +""" +type Cart { + """ + The attributes associated with the cart. Attributes are represented as key-value pairs. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + Information about the buyer that is interacting with the cart. + """ + buyerIdentity: BuyerIdentity + + """ + The costs that the buyer will pay at checkout. + """ + cost: CartCost! + + """ + A list of lines containing information about the items that can be delivered. + """ + deliverableLines: [DeliverableCartLine!]! + + """ + The delivery groups available for the cart based on the buyer's shipping address. + """ + deliveryGroups: [CartDeliveryGroup!]! + + """ + A list of lines containing information about the items the customer intends to purchase. + """ + lines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The localized fields available for the cart. + """ + localizedFields( + """ + The keys of the localized fields to retrieve. + """ + keys: [LocalizedFieldKey!]! = [] + ): [LocalizedField!]! +} + +""" +The cost that the buyer will pay at checkout. +""" +type CartCost { + """ + The amount, before taxes and discounts, for the customer to pay. + """ + subtotalAmount: MoneyV2! + + """ + The total amount for the customer to pay. + """ + totalAmount: MoneyV2! + + """ + The duty amount for the customer to pay at checkout. + """ + totalDutyAmount: MoneyV2 + + """ + The tax amount for the customer to pay at checkout. + """ + totalTaxAmount: MoneyV2 +} + +""" +Information about the options available for one or more line items to be delivered to a specific address. +""" +type CartDeliveryGroup { + """ + A list of cart lines for the delivery group. + """ + cartLines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The destination address for the delivery group. + """ + deliveryAddress: MailingAddress + + """ + The delivery options available for the delivery group. + """ + deliveryOptions: [CartDeliveryOption!]! + + """ + Unique identifier for the delivery group. + """ + id: ID! + + """ + Information about the delivery option the buyer has selected. + """ + selectedDeliveryOption: CartDeliveryOption +} + +""" +Information about a delivery option. +""" +type CartDeliveryOption { + """ + The code of the delivery option. + """ + code: String + + """ + The cost for the delivery option. + """ + cost: MoneyV2! + + """ + The method for the delivery option. + """ + deliveryMethodType: DeliveryMethod! + + """ + The description of the delivery option. + """ + description: String + + """ + The unique identifier of the delivery option. + """ + handle: Handle! + + """ + The title of the delivery option. + """ + title: String +} + +""" +Represents information about the merchandise in the cart. +""" +type CartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The cost of the merchandise line that the buyer will pay at checkout. + """ + cost: CartLineCost! + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! + + """ + The selling plan associated with the cart line and the effect that each + selling plan has on variants when they're purchased. + """ + sellingPlanAllocation: SellingPlanAllocation +} + +""" +The cost of the merchandise line that the buyer will pay at checkout. +""" +type CartLineCost { + """ + The amount of the merchandise line. + """ + amountPerQuantity: MoneyV2! + + """ + The compare at amount of the merchandise line. This value varies depending on + the buyer's identity, and is null when the value is hidden to buyers. + """ + compareAtAmountPerQuantity: MoneyV2 + + """ + The cost of the merchandise line before line-level discounts. + """ + subtotalAmount: MoneyV2! + + """ + The total cost of the merchandise line. + """ + totalAmount: MoneyV2! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. +""" +input CartLineTarget { + """ + The ID of the targeted cart line. + """ + id: ID! + + """ + The number of line items that are being discounted. + The default value is `null`, which represents the quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents whether the product is a member of the given collection. +""" +type CollectionMembership { + """ + The ID of the collection. + """ + collectionId: ID! + + """ + Whether the product is a member of the collection. + """ + isMember: Boolean! +} + +""" +Represents information about a company which is also a customer of the shop. +""" +type Company implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's main point of contact. +""" +type CompanyContact { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was created in Shopify. + """ + createdAt: DateTime! + + """ + The ID of the company. + """ + id: ID! + + """ + The company contact's locale (language). + """ + locale: String + + """ + The company contact's job title. + """ + title: String + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's location. +""" +type CompanyLocation implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + The preferred locale of the company location. + """ + locale: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company location. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was last modified. + """ + updatedAt: DateTime! +} + +""" +A country. +""" +type Country { + """ + The ISO code of the country. + """ + isoCode: CountryCode! +} + +""" +The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. +If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision +of another country. For example, the territories associated with Spain are represented by the country code `ES`, +and the territories associated with the United States of America are represented by the country code `US`. +""" +enum CountryCode { + """ + Ascension Island. + """ + AC + + """ + Andorra. + """ + AD + + """ + United Arab Emirates. + """ + AE + + """ + Afghanistan. + """ + AF + + """ + Antigua & Barbuda. + """ + AG + + """ + Anguilla. + """ + AI + + """ + Albania. + """ + AL + + """ + Armenia. + """ + AM + + """ + Netherlands Antilles. + """ + AN + + """ + Angola. + """ + AO + + """ + Argentina. + """ + AR + + """ + Austria. + """ + AT + + """ + Australia. + """ + AU + + """ + Aruba. + """ + AW + + """ + Åland Islands. + """ + AX + + """ + Azerbaijan. + """ + AZ + + """ + Bosnia & Herzegovina. + """ + BA + + """ + Barbados. + """ + BB + + """ + Bangladesh. + """ + BD + + """ + Belgium. + """ + BE + + """ + Burkina Faso. + """ + BF + + """ + Bulgaria. + """ + BG + + """ + Bahrain. + """ + BH + + """ + Burundi. + """ + BI + + """ + Benin. + """ + BJ + + """ + St. Barthélemy. + """ + BL + + """ + Bermuda. + """ + BM + + """ + Brunei. + """ + BN + + """ + Bolivia. + """ + BO + + """ + Caribbean Netherlands. + """ + BQ + + """ + Brazil. + """ + BR + + """ + Bahamas. + """ + BS + + """ + Bhutan. + """ + BT + + """ + Bouvet Island. + """ + BV + + """ + Botswana. + """ + BW + + """ + Belarus. + """ + BY + + """ + Belize. + """ + BZ + + """ + Canada. + """ + CA + + """ + Cocos (Keeling) Islands. + """ + CC + + """ + Congo - Kinshasa. + """ + CD + + """ + Central African Republic. + """ + CF + + """ + Congo - Brazzaville. + """ + CG + + """ + Switzerland. + """ + CH + + """ + Côte d’Ivoire. + """ + CI + + """ + Cook Islands. + """ + CK + + """ + Chile. + """ + CL + + """ + Cameroon. + """ + CM + + """ + China. + """ + CN + + """ + Colombia. + """ + CO + + """ + Costa Rica. + """ + CR + + """ + Cuba. + """ + CU + + """ + Cape Verde. + """ + CV + + """ + Curaçao. + """ + CW + + """ + Christmas Island. + """ + CX + + """ + Cyprus. + """ + CY + + """ + Czechia. + """ + CZ + + """ + Germany. + """ + DE + + """ + Djibouti. + """ + DJ + + """ + Denmark. + """ + DK + + """ + Dominica. + """ + DM + + """ + Dominican Republic. + """ + DO + + """ + Algeria. + """ + DZ + + """ + Ecuador. + """ + EC + + """ + Estonia. + """ + EE + + """ + Egypt. + """ + EG + + """ + Western Sahara. + """ + EH + + """ + Eritrea. + """ + ER + + """ + Spain. + """ + ES + + """ + Ethiopia. + """ + ET + + """ + Finland. + """ + FI + + """ + Fiji. + """ + FJ + + """ + Falkland Islands. + """ + FK + + """ + Faroe Islands. + """ + FO + + """ + France. + """ + FR + + """ + Gabon. + """ + GA + + """ + United Kingdom. + """ + GB + + """ + Grenada. + """ + GD + + """ + Georgia. + """ + GE + + """ + French Guiana. + """ + GF + + """ + Guernsey. + """ + GG + + """ + Ghana. + """ + GH + + """ + Gibraltar. + """ + GI + + """ + Greenland. + """ + GL + + """ + Gambia. + """ + GM + + """ + Guinea. + """ + GN + + """ + Guadeloupe. + """ + GP + + """ + Equatorial Guinea. + """ + GQ + + """ + Greece. + """ + GR + + """ + South Georgia & South Sandwich Islands. + """ + GS + + """ + Guatemala. + """ + GT + + """ + Guinea-Bissau. + """ + GW + + """ + Guyana. + """ + GY + + """ + Hong Kong SAR. + """ + HK + + """ + Heard & McDonald Islands. + """ + HM + + """ + Honduras. + """ + HN + + """ + Croatia. + """ + HR + + """ + Haiti. + """ + HT + + """ + Hungary. + """ + HU + + """ + Indonesia. + """ + ID + + """ + Ireland. + """ + IE + + """ + Israel. + """ + IL + + """ + Isle of Man. + """ + IM + + """ + India. + """ + IN + + """ + British Indian Ocean Territory. + """ + IO + + """ + Iraq. + """ + IQ + + """ + Iran. + """ + IR + + """ + Iceland. + """ + IS + + """ + Italy. + """ + IT + + """ + Jersey. + """ + JE + + """ + Jamaica. + """ + JM + + """ + Jordan. + """ + JO + + """ + Japan. + """ + JP + + """ + Kenya. + """ + KE + + """ + Kyrgyzstan. + """ + KG + + """ + Cambodia. + """ + KH + + """ + Kiribati. + """ + KI + + """ + Comoros. + """ + KM + + """ + St. Kitts & Nevis. + """ + KN + + """ + North Korea. + """ + KP + + """ + South Korea. + """ + KR + + """ + Kuwait. + """ + KW + + """ + Cayman Islands. + """ + KY + + """ + Kazakhstan. + """ + KZ + + """ + Laos. + """ + LA + + """ + Lebanon. + """ + LB + + """ + St. Lucia. + """ + LC + + """ + Liechtenstein. + """ + LI + + """ + Sri Lanka. + """ + LK + + """ + Liberia. + """ + LR + + """ + Lesotho. + """ + LS + + """ + Lithuania. + """ + LT + + """ + Luxembourg. + """ + LU + + """ + Latvia. + """ + LV + + """ + Libya. + """ + LY + + """ + Morocco. + """ + MA + + """ + Monaco. + """ + MC + + """ + Moldova. + """ + MD + + """ + Montenegro. + """ + ME + + """ + St. Martin. + """ + MF + + """ + Madagascar. + """ + MG + + """ + North Macedonia. + """ + MK + + """ + Mali. + """ + ML + + """ + Myanmar (Burma). + """ + MM + + """ + Mongolia. + """ + MN + + """ + Macao SAR. + """ + MO + + """ + Martinique. + """ + MQ + + """ + Mauritania. + """ + MR + + """ + Montserrat. + """ + MS + + """ + Malta. + """ + MT + + """ + Mauritius. + """ + MU + + """ + Maldives. + """ + MV + + """ + Malawi. + """ + MW + + """ + Mexico. + """ + MX + + """ + Malaysia. + """ + MY + + """ + Mozambique. + """ + MZ + + """ + Namibia. + """ + NA + + """ + New Caledonia. + """ + NC + + """ + Niger. + """ + NE + + """ + Norfolk Island. + """ + NF + + """ + Nigeria. + """ + NG + + """ + Nicaragua. + """ + NI + + """ + Netherlands. + """ + NL + + """ + Norway. + """ + NO + + """ + Nepal. + """ + NP + + """ + Nauru. + """ + NR + + """ + Niue. + """ + NU + + """ + New Zealand. + """ + NZ + + """ + Oman. + """ + OM + + """ + Panama. + """ + PA + + """ + Peru. + """ + PE + + """ + French Polynesia. + """ + PF + + """ + Papua New Guinea. + """ + PG + + """ + Philippines. + """ + PH + + """ + Pakistan. + """ + PK + + """ + Poland. + """ + PL + + """ + St. Pierre & Miquelon. + """ + PM + + """ + Pitcairn Islands. + """ + PN + + """ + Palestinian Territories. + """ + PS + + """ + Portugal. + """ + PT + + """ + Paraguay. + """ + PY + + """ + Qatar. + """ + QA + + """ + Réunion. + """ + RE + + """ + Romania. + """ + RO + + """ + Serbia. + """ + RS + + """ + Russia. + """ + RU + + """ + Rwanda. + """ + RW + + """ + Saudi Arabia. + """ + SA + + """ + Solomon Islands. + """ + SB + + """ + Seychelles. + """ + SC + + """ + Sudan. + """ + SD + + """ + Sweden. + """ + SE + + """ + Singapore. + """ + SG + + """ + St. Helena. + """ + SH + + """ + Slovenia. + """ + SI + + """ + Svalbard & Jan Mayen. + """ + SJ + + """ + Slovakia. + """ + SK + + """ + Sierra Leone. + """ + SL + + """ + San Marino. + """ + SM + + """ + Senegal. + """ + SN + + """ + Somalia. + """ + SO + + """ + Suriname. + """ + SR + + """ + South Sudan. + """ + SS + + """ + São Tomé & Príncipe. + """ + ST + + """ + El Salvador. + """ + SV + + """ + Sint Maarten. + """ + SX + + """ + Syria. + """ + SY + + """ + Eswatini. + """ + SZ + + """ + Tristan da Cunha. + """ + TA + + """ + Turks & Caicos Islands. + """ + TC + + """ + Chad. + """ + TD + + """ + French Southern Territories. + """ + TF + + """ + Togo. + """ + TG + + """ + Thailand. + """ + TH + + """ + Tajikistan. + """ + TJ + + """ + Tokelau. + """ + TK + + """ + Timor-Leste. + """ + TL + + """ + Turkmenistan. + """ + TM + + """ + Tunisia. + """ + TN + + """ + Tonga. + """ + TO + + """ + Türkiye. + """ + TR + + """ + Trinidad & Tobago. + """ + TT + + """ + Tuvalu. + """ + TV + + """ + Taiwan. + """ + TW + + """ + Tanzania. + """ + TZ + + """ + Ukraine. + """ + UA + + """ + Uganda. + """ + UG + + """ + U.S. Outlying Islands. + """ + UM + + """ + United States. + """ + US + + """ + Uruguay. + """ + UY + + """ + Uzbekistan. + """ + UZ + + """ + Vatican City. + """ + VA + + """ + St. Vincent & Grenadines. + """ + VC + + """ + Venezuela. + """ + VE + + """ + British Virgin Islands. + """ + VG + + """ + Vietnam. + """ + VN + + """ + Vanuatu. + """ + VU + + """ + Wallis & Futuna. + """ + WF + + """ + Samoa. + """ + WS + + """ + Kosovo. + """ + XK + + """ + Yemen. + """ + YE + + """ + Mayotte. + """ + YT + + """ + South Africa. + """ + ZA + + """ + Zambia. + """ + ZM + + """ + Zimbabwe. + """ + ZW + + """ + Unknown Region. + """ + ZZ +} + +""" +The three-letter currency codes that represent the world currencies used in +stores. These include standard ISO 4217 codes, legacy codes, +and non-standard codes. +""" +enum CurrencyCode { + """ + United Arab Emirates Dirham (AED). + """ + AED + + """ + Afghan Afghani (AFN). + """ + AFN + + """ + Albanian Lek (ALL). + """ + ALL + + """ + Armenian Dram (AMD). + """ + AMD + + """ + Netherlands Antillean Guilder. + """ + ANG + + """ + Angolan Kwanza (AOA). + """ + AOA + + """ + Argentine Pesos (ARS). + """ + ARS + + """ + Australian Dollars (AUD). + """ + AUD + + """ + Aruban Florin (AWG). + """ + AWG + + """ + Azerbaijani Manat (AZN). + """ + AZN + + """ + Bosnia and Herzegovina Convertible Mark (BAM). + """ + BAM + + """ + Barbadian Dollar (BBD). + """ + BBD + + """ + Bangladesh Taka (BDT). + """ + BDT + + """ + Bulgarian Lev (BGN). + """ + BGN + + """ + Bahraini Dinar (BHD). + """ + BHD + + """ + Burundian Franc (BIF). + """ + BIF + + """ + Bermudian Dollar (BMD). + """ + BMD + + """ + Brunei Dollar (BND). + """ + BND + + """ + Bolivian Boliviano (BOB). + """ + BOB + + """ + Brazilian Real (BRL). + """ + BRL + + """ + Bahamian Dollar (BSD). + """ + BSD + + """ + Bhutanese Ngultrum (BTN). + """ + BTN + + """ + Botswana Pula (BWP). + """ + BWP + + """ + Belarusian Ruble (BYN). + """ + BYN + + """ + Belarusian Ruble (BYR). + """ + BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") + + """ + Belize Dollar (BZD). + """ + BZD + + """ + Canadian Dollars (CAD). + """ + CAD + + """ + Congolese franc (CDF). + """ + CDF + + """ + Swiss Francs (CHF). + """ + CHF + + """ + Chilean Peso (CLP). + """ + CLP + + """ + Chinese Yuan Renminbi (CNY). + """ + CNY + + """ + Colombian Peso (COP). + """ + COP + + """ + Costa Rican Colones (CRC). + """ + CRC + + """ + Cape Verdean escudo (CVE). + """ + CVE + + """ + Czech Koruny (CZK). + """ + CZK + + """ + Djiboutian Franc (DJF). + """ + DJF + + """ + Danish Kroner (DKK). + """ + DKK + + """ + Dominican Peso (DOP). + """ + DOP + + """ + Algerian Dinar (DZD). + """ + DZD + + """ + Egyptian Pound (EGP). + """ + EGP + + """ + Eritrean Nakfa (ERN). + """ + ERN + + """ + Ethiopian Birr (ETB). + """ + ETB + + """ + Euro (EUR). + """ + EUR + + """ + Fijian Dollars (FJD). + """ + FJD + + """ + Falkland Islands Pounds (FKP). + """ + FKP + + """ + United Kingdom Pounds (GBP). + """ + GBP + + """ + Georgian Lari (GEL). + """ + GEL + + """ + Ghanaian Cedi (GHS). + """ + GHS + + """ + Gibraltar Pounds (GIP). + """ + GIP + + """ + Gambian Dalasi (GMD). + """ + GMD + + """ + Guinean Franc (GNF). + """ + GNF + + """ + Guatemalan Quetzal (GTQ). + """ + GTQ + + """ + Guyanese Dollar (GYD). + """ + GYD + + """ + Hong Kong Dollars (HKD). + """ + HKD + + """ + Honduran Lempira (HNL). + """ + HNL + + """ + Croatian Kuna (HRK). + """ + HRK + + """ + Haitian Gourde (HTG). + """ + HTG + + """ + Hungarian Forint (HUF). + """ + HUF + + """ + Indonesian Rupiah (IDR). + """ + IDR + + """ + Israeli New Shekel (NIS). + """ + ILS + + """ + Indian Rupees (INR). + """ + INR + + """ + Iraqi Dinar (IQD). + """ + IQD + + """ + Iranian Rial (IRR). + """ + IRR + + """ + Icelandic Kronur (ISK). + """ + ISK + + """ + Jersey Pound. + """ + JEP + + """ + Jamaican Dollars (JMD). + """ + JMD + + """ + Jordanian Dinar (JOD). + """ + JOD + + """ + Japanese Yen (JPY). + """ + JPY + + """ + Kenyan Shilling (KES). + """ + KES + + """ + Kyrgyzstani Som (KGS). + """ + KGS + + """ + Cambodian Riel. + """ + KHR + + """ + Kiribati Dollar (KID). + """ + KID + + """ + Comorian Franc (KMF). + """ + KMF + + """ + South Korean Won (KRW). + """ + KRW + + """ + Kuwaiti Dinar (KWD). + """ + KWD + + """ + Cayman Dollars (KYD). + """ + KYD + + """ + Kazakhstani Tenge (KZT). + """ + KZT + + """ + Laotian Kip (LAK). + """ + LAK + + """ + Lebanese Pounds (LBP). + """ + LBP + + """ + Sri Lankan Rupees (LKR). + """ + LKR + + """ + Liberian Dollar (LRD). + """ + LRD + + """ + Lesotho Loti (LSL). + """ + LSL + + """ + Lithuanian Litai (LTL). + """ + LTL + + """ + Latvian Lati (LVL). + """ + LVL + + """ + Libyan Dinar (LYD). + """ + LYD + + """ + Moroccan Dirham. + """ + MAD + + """ + Moldovan Leu (MDL). + """ + MDL + + """ + Malagasy Ariary (MGA). + """ + MGA + + """ + Macedonia Denar (MKD). + """ + MKD + + """ + Burmese Kyat (MMK). + """ + MMK + + """ + Mongolian Tugrik. + """ + MNT + + """ + Macanese Pataca (MOP). + """ + MOP + + """ + Mauritanian Ouguiya (MRU). + """ + MRU + + """ + Mauritian Rupee (MUR). + """ + MUR + + """ + Maldivian Rufiyaa (MVR). + """ + MVR + + """ + Malawian Kwacha (MWK). + """ + MWK + + """ + Mexican Pesos (MXN). + """ + MXN + + """ + Malaysian Ringgits (MYR). + """ + MYR + + """ + Mozambican Metical. + """ + MZN + + """ + Namibian Dollar. + """ + NAD + + """ + Nigerian Naira (NGN). + """ + NGN + + """ + Nicaraguan Córdoba (NIO). + """ + NIO + + """ + Norwegian Kroner (NOK). + """ + NOK + + """ + Nepalese Rupee (NPR). + """ + NPR + + """ + New Zealand Dollars (NZD). + """ + NZD + + """ + Omani Rial (OMR). + """ + OMR + + """ + Panamian Balboa (PAB). + """ + PAB + + """ + Peruvian Nuevo Sol (PEN). + """ + PEN + + """ + Papua New Guinean Kina (PGK). + """ + PGK + + """ + Philippine Peso (PHP). + """ + PHP + + """ + Pakistani Rupee (PKR). + """ + PKR + + """ + Polish Zlotych (PLN). + """ + PLN + + """ + Paraguayan Guarani (PYG). + """ + PYG + + """ + Qatari Rial (QAR). + """ + QAR + + """ + Romanian Lei (RON). + """ + RON + + """ + Serbian dinar (RSD). + """ + RSD + + """ + Russian Rubles (RUB). + """ + RUB + + """ + Rwandan Franc (RWF). + """ + RWF + + """ + Saudi Riyal (SAR). + """ + SAR + + """ + Solomon Islands Dollar (SBD). + """ + SBD + + """ + Seychellois Rupee (SCR). + """ + SCR + + """ + Sudanese Pound (SDG). + """ + SDG + + """ + Swedish Kronor (SEK). + """ + SEK + + """ + Singapore Dollars (SGD). + """ + SGD + + """ + Saint Helena Pounds (SHP). + """ + SHP + + """ + Sierra Leonean Leone (SLL). + """ + SLL + + """ + Somali Shilling (SOS). + """ + SOS + + """ + Surinamese Dollar (SRD). + """ + SRD + + """ + South Sudanese Pound (SSP). + """ + SSP + + """ + Sao Tome And Principe Dobra (STD). + """ + STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") + + """ + Sao Tome And Principe Dobra (STN). + """ + STN + + """ + Syrian Pound (SYP). + """ + SYP + + """ + Swazi Lilangeni (SZL). + """ + SZL + + """ + Thai baht (THB). + """ + THB + + """ + Tajikistani Somoni (TJS). + """ + TJS + + """ + Turkmenistani Manat (TMT). + """ + TMT + + """ + Tunisian Dinar (TND). + """ + TND + + """ + Tongan Pa'anga (TOP). + """ + TOP + + """ + Turkish Lira (TRY). + """ + TRY + + """ + Trinidad and Tobago Dollars (TTD). + """ + TTD + + """ + Taiwan Dollars (TWD). + """ + TWD + + """ + Tanzanian Shilling (TZS). + """ + TZS + + """ + Ukrainian Hryvnia (UAH). + """ + UAH + + """ + Ugandan Shilling (UGX). + """ + UGX + + """ + United States Dollars (USD). + """ + USD + + """ + Uruguayan Pesos (UYU). + """ + UYU + + """ + Uzbekistan som (UZS). + """ + UZS + + """ + Venezuelan Bolivares (VED). + """ + VED + + """ + Venezuelan Bolivares (VEF). + """ + VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") + + """ + Venezuelan Bolivares Soberanos (VES). + """ + VES + + """ + Vietnamese đồng (VND). + """ + VND + + """ + Vanuatu Vatu (VUV). + """ + VUV + + """ + Samoan Tala (WST). + """ + WST + + """ + Central African CFA Franc (XAF). + """ + XAF + + """ + East Caribbean Dollar (XCD). + """ + XCD + + """ + West African CFA franc (XOF). + """ + XOF + + """ + CFP Franc (XPF). + """ + XPF + + """ + Unrecognized currency. + """ + XXX + + """ + Yemeni Rial (YER). + """ + YER + + """ + South African Rand (ZAR). + """ + ZAR + + """ + Zambian Kwacha (ZMW). + """ + ZMW +} + +""" +A custom product. +""" +type CustomProduct { + """ + Whether the merchandise is a gift card. + """ + isGiftCard: Boolean! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +Represents a customer with the shop. +""" +type Customer implements HasMetafields { + """ + The total amount of money spent by the customer. Converted from the shop's + currency to the currency of the cart using a market rate. + """ + amountSpent: MoneyV2! + + """ + The customer’s name, email or phone number. + """ + displayName: String! + + """ + The customer’s email address. + """ + email: String + + """ + The customer's first name. + """ + firstName: String + + """ + Whether the customer has any of the given tags. + """ + hasAnyTag( + """ + The tags to search for. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the customer has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A unique identifier for the customer. + """ + id: ID! + + """ + The customer's last name. + """ + lastName: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The number of orders made by the customer. + """ + numberOfOrders: Int! +} + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. +For example, September 7, 2019 is represented as `"2019-07-16"`. +""" +scalar Date + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. +For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is +represented as `"2019-09-07T15:50:00Z`". +""" +scalar DateTime + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the date and time but not the timezone which is determined from context. + +For example, "2018-01-01T00:00:00". +""" +scalar DateTimeWithoutTimezone + +""" +A signed decimal number, which supports arbitrary precision and is serialized as a string. + +Example values: `"29.99"`, `"29.999"`. +""" +scalar Decimal + +""" +Represents information about the merchandise in the cart. +""" +type DeliverableCartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! +} + +""" +List of different delivery method types. +""" +enum DeliveryMethod { + """ + Local Delivery. + """ + LOCAL + + """ + None. + """ + NONE + + """ + Shipping to a Pickup Point. + """ + PICKUP_POINT + + """ + Local Pickup. + """ + PICK_UP + + """ + Retail. + """ + RETAIL + + """ + Shipping. + """ + SHIPPING +} + +""" +The discount to be applied. +""" +input Discount { + """ + The discount message. + """ + message: String + + """ + The targets of the discount. + + This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + """ + targets: [Target!]! + + """ + The value of the discount. + """ + value: Value! +} + +""" +The strategy that's applied to the list of discounts. +""" +enum DiscountApplicationStrategy { + """ + Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. + """ + ALL + + """ + Only apply the first discount with conditions that are satisfied. + """ + FIRST + + """ + Only apply the discount that offers the maximum reduction. + """ + MAXIMUM +} + +""" +A discount wrapper node. +""" +type DiscountNode implements HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A fixed amount value. +""" +input FixedAmount { + """ + The fixed amount value of the discount, in the currency of the cart. + + The amount must be greater than or equal to 0. + """ + amount: Decimal! + + """ + Whether to apply the value to each entitled item. + + The default value is `false`, which causes the value to be applied once across the entitled items. + When the value is `true`, the value will be applied to each of the entitled items. + """ + appliesToEachItem: Boolean +} + +""" +The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +""" +input FunctionResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +The run target result. +""" +input FunctionRunResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +A function-scoped handle to a refer a resource. +The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. +Example value: `"10079785100"` +""" +scalar Handle + +""" +Represents information about the metafields associated to the specified resource. +""" +interface HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +Represents whether the current object has the given tag. +""" +type HasTagResponse { + """ + Whether the current object has the tag. + """ + hasTag: Boolean! + + """ + The tag. + """ + tag: String! +} + +""" +Represents a unique identifier, often used to refetch an object. +The ID type appears in a JSON response as a String, but it is not intended to be human-readable. + +Example value: `"gid://shopify/Product/10079785100"` +""" +scalar ID + +""" +The input object for the function. +""" +type Input { + """ + The cart. + """ + cart: Cart! + + """ + The discount node executing the function. + """ + discountNode: DiscountNode! + + """ + The localization of the Function execution context. + """ + localization: Localization! + + """ + The conversion rate between the shop's currency and the currency of the cart. + """ + presentmentCurrencyRate: Decimal! + + """ + Information about the shop. + """ + shop: Shop! +} + +""" +A [JSON](https://www.json.org/json-en.html) object. + +Example value: +`{ + "product": { + "id": "gid://shopify/Product/1346443542550", + "title": "White T-shirt", + "options": [{ + "name": "Size", + "values": ["M", "L"] + }] + } +}` +""" +scalar JSON + +""" +A language. +""" +type Language { + """ + The ISO code. + """ + isoCode: LanguageCode! +} + +""" +Language codes supported by Shopify. +""" +enum LanguageCode { + """ + Afrikaans. + """ + AF + + """ + Akan. + """ + AK + + """ + Amharic. + """ + AM + + """ + Arabic. + """ + AR + + """ + Assamese. + """ + AS + + """ + Azerbaijani. + """ + AZ + + """ + Belarusian. + """ + BE + + """ + Bulgarian. + """ + BG + + """ + Bambara. + """ + BM + + """ + Bangla. + """ + BN + + """ + Tibetan. + """ + BO + + """ + Breton. + """ + BR + + """ + Bosnian. + """ + BS + + """ + Catalan. + """ + CA + + """ + Chechen. + """ + CE + + """ + Central Kurdish. + """ + CKB + + """ + Czech. + """ + CS + + """ + Church Slavic. + """ + CU + + """ + Welsh. + """ + CY + + """ + Danish. + """ + DA + + """ + German. + """ + DE + + """ + Dzongkha. + """ + DZ + + """ + Ewe. + """ + EE + + """ + Greek. + """ + EL + + """ + English. + """ + EN + + """ + Esperanto. + """ + EO + + """ + Spanish. + """ + ES + + """ + Estonian. + """ + ET + + """ + Basque. + """ + EU + + """ + Persian. + """ + FA + + """ + Fulah. + """ + FF + + """ + Finnish. + """ + FI + + """ + Filipino. + """ + FIL + + """ + Faroese. + """ + FO + + """ + French. + """ + FR + + """ + Western Frisian. + """ + FY + + """ + Irish. + """ + GA + + """ + Scottish Gaelic. + """ + GD + + """ + Galician. + """ + GL + + """ + Gujarati. + """ + GU + + """ + Manx. + """ + GV + + """ + Hausa. + """ + HA + + """ + Hebrew. + """ + HE + + """ + Hindi. + """ + HI + + """ + Croatian. + """ + HR + + """ + Hungarian. + """ + HU + + """ + Armenian. + """ + HY + + """ + Interlingua. + """ + IA + + """ + Indonesian. + """ + ID + + """ + Igbo. + """ + IG + + """ + Sichuan Yi. + """ + II + + """ + Icelandic. + """ + IS + + """ + Italian. + """ + IT + + """ + Japanese. + """ + JA + + """ + Javanese. + """ + JV + + """ + Georgian. + """ + KA + + """ + Kikuyu. + """ + KI + + """ + Kazakh. + """ + KK + + """ + Kalaallisut. + """ + KL + + """ + Khmer. + """ + KM + + """ + Kannada. + """ + KN + + """ + Korean. + """ + KO + + """ + Kashmiri. + """ + KS + + """ + Kurdish. + """ + KU + + """ + Cornish. + """ + KW + + """ + Kyrgyz. + """ + KY + + """ + Luxembourgish. + """ + LB + + """ + Ganda. + """ + LG + + """ + Lingala. + """ + LN + + """ + Lao. + """ + LO + + """ + Lithuanian. + """ + LT + + """ + Luba-Katanga. + """ + LU + + """ + Latvian. + """ + LV + + """ + Malagasy. + """ + MG + + """ + Māori. + """ + MI + + """ + Macedonian. + """ + MK + + """ + Malayalam. + """ + ML + + """ + Mongolian. + """ + MN + + """ + Marathi. + """ + MR + + """ + Malay. + """ + MS + + """ + Maltese. + """ + MT + + """ + Burmese. + """ + MY + + """ + Norwegian (Bokmål). + """ + NB + + """ + North Ndebele. + """ + ND + + """ + Nepali. + """ + NE + + """ + Dutch. + """ + NL + + """ + Norwegian Nynorsk. + """ + NN + + """ + Norwegian. + """ + NO + + """ + Oromo. + """ + OM + + """ + Odia. + """ + OR + + """ + Ossetic. + """ + OS + + """ + Punjabi. + """ + PA + + """ + Polish. + """ + PL + + """ + Pashto. + """ + PS + + """ + Portuguese. + """ + PT + + """ + Portuguese (Brazil). + """ + PT_BR + + """ + Portuguese (Portugal). + """ + PT_PT + + """ + Quechua. + """ + QU + + """ + Romansh. + """ + RM + + """ + Rundi. + """ + RN + + """ + Romanian. + """ + RO + + """ + Russian. + """ + RU + + """ + Kinyarwanda. + """ + RW + + """ + Sanskrit. + """ + SA + + """ + Sardinian. + """ + SC + + """ + Sindhi. + """ + SD + + """ + Northern Sami. + """ + SE + + """ + Sango. + """ + SG + + """ + Sinhala. + """ + SI + + """ + Slovak. + """ + SK + + """ + Slovenian. + """ + SL + + """ + Shona. + """ + SN + + """ + Somali. + """ + SO + + """ + Albanian. + """ + SQ + + """ + Serbian. + """ + SR + + """ + Sundanese. + """ + SU + + """ + Swedish. + """ + SV + + """ + Swahili. + """ + SW + + """ + Tamil. + """ + TA + + """ + Telugu. + """ + TE + + """ + Tajik. + """ + TG + + """ + Thai. + """ + TH + + """ + Tigrinya. + """ + TI + + """ + Turkmen. + """ + TK + + """ + Tongan. + """ + TO + + """ + Turkish. + """ + TR + + """ + Tatar. + """ + TT + + """ + Uyghur. + """ + UG + + """ + Ukrainian. + """ + UK + + """ + Urdu. + """ + UR + + """ + Uzbek. + """ + UZ + + """ + Vietnamese. + """ + VI + + """ + Volapük. + """ + VO + + """ + Wolof. + """ + WO + + """ + Xhosa. + """ + XH + + """ + Yiddish. + """ + YI + + """ + Yoruba. + """ + YO + + """ + Chinese. + """ + ZH + + """ + Chinese (Simplified). + """ + ZH_CN + + """ + Chinese (Traditional). + """ + ZH_TW + + """ + Zulu. + """ + ZU +} + +""" +Represents limited information about the current time relative to the parent object. +""" +type LocalTime { + """ + The current date relative to the parent object. + """ + date: Date! + + """ + Returns true if the current date and time is at or past the given date and time, and false otherwise. + """ + dateTimeAfter( + """ + The date and time to compare against, assumed to be in the timezone of the parent object. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is before the given date and time, and false otherwise. + """ + dateTimeBefore( + """ + The date and time to compare against, assumed to be in the timezone of the parent timezone. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is between the two given date and times, and false otherwise. + """ + dateTimeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endDateTime: DateTimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startDateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeAfter( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeBefore( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is between the two given times, and false otherwise. + """ + timeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endTime: TimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startTime: TimeWithoutTimezone! + ): Boolean! +} + +""" +Information about the localized experiences configured for the shop. +""" +type Localization { + """ + The country of the active localized experience. + """ + country: Country! + + """ + The language of the active localized experience. + """ + language: Language! + + """ + The market of the active localized experience. + """ + market: Market! +} + +""" +Represents the value captured by a localized field. Localized fields are +additional fields required by certain countries on international orders. For +example, some countries require additional fields for customs information or tax +identification numbers. +""" +type LocalizedField { + """ + The key of the localized field. + """ + key: LocalizedFieldKey! + + """ + The title of the localized field. + """ + title: String! + + """ + The value of the localized field. + """ + value: String +} + +""" +Unique key identifying localized fields. +""" +enum LocalizedFieldKey { + """ + Localized field key 'shipping_credential_br' for country BR. + """ + SHIPPING_CREDENTIAL_BR + + """ + Localized field key 'shipping_credential_cl' for country CL. + """ + SHIPPING_CREDENTIAL_CL + + """ + Localized field key 'shipping_credential_cn' for country CN. + """ + SHIPPING_CREDENTIAL_CN + + """ + Localized field key 'shipping_credential_co' for country CO. + """ + SHIPPING_CREDENTIAL_CO + + """ + Localized field key 'shipping_credential_cr' for country CR. + """ + SHIPPING_CREDENTIAL_CR + + """ + Localized field key 'shipping_credential_ec' for country EC. + """ + SHIPPING_CREDENTIAL_EC + + """ + Localized field key 'shipping_credential_es' for country ES. + """ + SHIPPING_CREDENTIAL_ES + + """ + Localized field key 'shipping_credential_gt' for country GT. + """ + SHIPPING_CREDENTIAL_GT + + """ + Localized field key 'shipping_credential_id' for country ID. + """ + SHIPPING_CREDENTIAL_ID + + """ + Localized field key 'shipping_credential_kr' for country KR. + """ + SHIPPING_CREDENTIAL_KR + + """ + Localized field key 'shipping_credential_mx' for country MX. + """ + SHIPPING_CREDENTIAL_MX + + """ + Localized field key 'shipping_credential_my' for country MY. + """ + SHIPPING_CREDENTIAL_MY + + """ + Localized field key 'shipping_credential_pe' for country PE. + """ + SHIPPING_CREDENTIAL_PE + + """ + Localized field key 'shipping_credential_pt' for country PT. + """ + SHIPPING_CREDENTIAL_PT + + """ + Localized field key 'shipping_credential_py' for country PY. + """ + SHIPPING_CREDENTIAL_PY + + """ + Localized field key 'shipping_credential_tr' for country TR. + """ + SHIPPING_CREDENTIAL_TR + + """ + Localized field key 'shipping_credential_tw' for country TW. + """ + SHIPPING_CREDENTIAL_TW + + """ + Localized field key 'shipping_credential_type_co' for country CO. + """ + SHIPPING_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_br' for country BR. + """ + TAX_CREDENTIAL_BR + + """ + Localized field key 'tax_credential_cl' for country CL. + """ + TAX_CREDENTIAL_CL + + """ + Localized field key 'tax_credential_co' for country CO. + """ + TAX_CREDENTIAL_CO + + """ + Localized field key 'tax_credential_cr' for country CR. + """ + TAX_CREDENTIAL_CR + + """ + Localized field key 'tax_credential_ec' for country EC. + """ + TAX_CREDENTIAL_EC + + """ + Localized field key 'tax_credential_es' for country ES. + """ + TAX_CREDENTIAL_ES + + """ + Localized field key 'tax_credential_gt' for country GT. + """ + TAX_CREDENTIAL_GT + + """ + Localized field key 'tax_credential_id' for country ID. + """ + TAX_CREDENTIAL_ID + + """ + Localized field key 'tax_credential_it' for country IT. + """ + TAX_CREDENTIAL_IT + + """ + Localized field key 'tax_credential_mx' for country MX. + """ + TAX_CREDENTIAL_MX + + """ + Localized field key 'tax_credential_my' for country MY. + """ + TAX_CREDENTIAL_MY + + """ + Localized field key 'tax_credential_pe' for country PE. + """ + TAX_CREDENTIAL_PE + + """ + Localized field key 'tax_credential_pt' for country PT. + """ + TAX_CREDENTIAL_PT + + """ + Localized field key 'tax_credential_py' for country PY. + """ + TAX_CREDENTIAL_PY + + """ + Localized field key 'tax_credential_tr' for country TR. + """ + TAX_CREDENTIAL_TR + + """ + Localized field key 'tax_credential_type_co' for country CO. + """ + TAX_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_type_mx' for country MX. + """ + TAX_CREDENTIAL_TYPE_MX + + """ + Localized field key 'tax_credential_use_mx' for country MX. + """ + TAX_CREDENTIAL_USE_MX + + """ + Localized field key 'tax_email_it' for country IT. + """ + TAX_EMAIL_IT +} + +""" +Represents a mailing address. +""" +type MailingAddress { + """ + The first line of the address. Typically the street address or PO Box number. + """ + address1: String + + """ + The second line of the address. Typically the number of the apartment, suite, or unit. + """ + address2: String + + """ + The name of the city, district, village, or town. + """ + city: String + + """ + The name of the customer's company or organization. + """ + company: String + + """ + The two-letter code for the country of the address. For example, US. + """ + countryCode: CountryCode + + """ + The first name of the customer. + """ + firstName: String + + """ + The last name of the customer. + """ + lastName: String + + """ + The approximate latitude of the address. + """ + latitude: Float + + """ + The approximate longitude of the address. + """ + longitude: Float + + """ + The market of the address. + """ + market: Market + + """ + The full name of the customer, based on firstName and lastName. + """ + name: String + + """ + A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. + """ + phone: String + + """ + The alphanumeric code for the region. For example, ON. + """ + provinceCode: String + + """ + The zip or postal code of the address. + """ + zip: String +} + +""" +A market is a group of one or more regions that you want to target for international sales. +By creating a market, you can configure a distinct, localized shopping experience for +customers from a specific area of the world. For example, you can +[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), +[configure international pricing](https://shopify.dev/api/examples/product-price-lists), +or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). +""" +type Market implements HasMetafields { + """ + A human-readable unique string for the market automatically generated from its title. + """ + handle: Handle! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + A geographic region which comprises a market. + """ + regions: [MarketRegion!]! +} + +""" +Represents a region. +""" +interface MarketRegion { + """ + The name of the region in the language of the current localization. + """ + name: String +} + +""" +A country which comprises a market. +""" +type MarketRegionCountry implements MarketRegion { + """ + The two-letter code for the country. + """ + code: CountryCode! + + """ + The country name in the language of the current localization. + """ + name: String! +} + +""" +The merchandise to be purchased at checkout. +""" +union Merchandise = CustomProduct | ProductVariant + +""" +[Metafields](https://shopify.dev/apps/metafields) +enable you to attach additional information to a +Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) +or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). +For more information about the Shopify resources that you can attach metafields to, refer to +[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +""" +type Metafield { + """ + The data stored in the metafield in JSON format. + """ + jsonValue: JSON! + + """ + The type of data that the metafield stores in the `value` field. + Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + """ + type: String! + + """ + The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + """ + value: String! +} + +""" +A monetary value with currency. +""" +type MoneyV2 { + """ + Decimal money amount. + """ + amount: Decimal! + + """ + Currency of the money. + """ + currencyCode: CurrencyCode! +} + +""" +The root mutation for the API. +""" +type MutationRoot { + """ + Handles the Function result. + """ + handleResult( + """ + The result of the Function. + """ + result: FunctionResult! + ): Void! @deprecated(reason: "Use the target-specific field instead.") + + """ + Handles the Function result for the purchase.product-discount.run target. + """ + run( + """ + The result of the Function. + """ + result: FunctionRunResult! + ): Void! +} + +""" +A percentage value. +""" +input Percentage { + """ + The percentage value. + + The value is validated against: >= 0 and <= 100. + """ + value: Decimal! +} + +""" +Represents a product. +""" +type Product implements HasMetafields { + """ + A unique human-friendly string of the product's title. + """ + handle: Handle! + + """ + Whether the product has any of the given tags. + """ + hasAnyTag( + """ + The tags to check. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the product has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Whether the product is in any of the given collections. + """ + inAnyCollection( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): Boolean! + + """ + Whether the product is in the given collections. + """ + inCollections( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): [CollectionMembership!]! + + """ + Whether the product is a gift card. + """ + isGiftCard: Boolean! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product type specified by the merchant. + """ + productType: String + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The name of the product's vendor. + """ + vendor: String +} + +""" +Represents a product variant. +""" +type ProductVariant implements HasMetafields { + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product that this variant belongs to. + """ + product: Product! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + """ + sku: String + + """ + The localized title of the product variant in the customer’s locale. + """ + title: String + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an +optional quantity limit. +""" +input ProductVariantTarget { + """ + The ID of the targeted product variant. + """ + id: ID! + + """ + The maximum number of line item units to be discounted. + The default value is `null`, which represents the total quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type PurchasingCompany { + """ + The company associated to the order or draft order. + """ + company: Company! + + """ + The company contact associated to the order or draft order. + """ + contact: CompanyContact + + """ + The company location associated to the order or draft order. + """ + location: CompanyLocation! +} + +""" +Represents how products and variants can be sold and purchased. +""" +type SellingPlan implements HasMetafields { + """ + The description of the selling plan. + """ + description: String + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. + """ + name: String! + + """ + Whether purchasing the selling plan will result in multiple deliveries. + """ + recurringDeliveries: Boolean! +} + +""" +Represents an association between a variant and a selling plan. Selling plan +allocations describe the options offered for each variant, and the price of the +variant when purchased with a selling plan. +""" +type SellingPlanAllocation { + """ + A list of price adjustments, with a maximum of two. When there are two, the + first price adjustment goes into effect at the time of purchase, while the + second one starts after a certain number of orders. A price adjustment + represents how a selling plan affects pricing when a variant is purchased with + a selling plan. Prices display in the customer's currency if the shop is + configured for it. + """ + priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! + + """ + A representation of how products and variants can be sold and purchased. For + example, an individual selling plan could be '6 weeks of prepaid granola, + delivered weekly'. + """ + sellingPlan: SellingPlan! +} + +""" +The resulting prices for variants when they're purchased with a specific selling plan. +""" +type SellingPlanAllocationPriceAdjustment { + """ + The effective price for a single delivery. For example, for a prepaid + subscription plan that includes 6 deliveries at the price of $48.00, the per + delivery price is $8.00. + """ + perDeliveryPrice: MoneyV2! + + """ + The price of the variant when it's purchased with a selling plan For example, + for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, + where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. + """ + price: MoneyV2! +} + +""" +Information about the shop. +""" +type Shop implements HasMetafields { + """ + Information about the current time relative to the shop's timezone setting. + """ + localTime: LocalTime! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A target of a discount, which determines which cart line(s) the discount will affect. + +A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + +Multiple targets with the same type and ID are the same as a single target of that type and ID with their +quantities added together, or `null` if any of those targets have a quantity of `null`. + +See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. +""" +input Target @oneOf { + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. + """ + cartLine: CartLineTarget + + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an + optional quantity limit. + """ + productVariant: ProductVariantTarget +} + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the time but not the date or timezone which is determined from context. +For example, "05:43:21". +""" +scalar TimeWithoutTimezone + +""" +The value of the discount. +""" +input Value @oneOf { + """ + A fixed amount value. + """ + fixedAmount: FixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +A void type that can be used to return a null value from a mutation. +""" +scalar Void + +""" +Units of measurement for weight. +""" +enum WeightUnit { + """ + Metric system unit of mass. + """ + GRAMS + + """ + 1 kilogram equals 1000 grams. + """ + KILOGRAMS + + """ + Imperial system unit of mass. + """ + OUNCES + + """ + 1 pound equals 16 ounces. + """ + POUNDS +} diff --git a/discounts/rust/discounts/default/shopify.extension.toml.liquid b/discounts/rust/discounts/default/shopify.extension.toml.liquid new file mode 100644 index 00000000..0c0f546e --- /dev/null +++ b/discounts/rust/discounts/default/shopify.extension.toml.liquid @@ -0,0 +1,37 @@ +api_version = "2025-01" + +[[extensions]] +name = "t:name" +handle = "{{handle}}" +type = "function" +{% if uid %}uid = "{{ uid }}"{% endif %} +description = "t:description" + + [[extensions.targeting]] + target = "purchase.discount.cart_run" + input_query = "src/run.graphql" + export = "cart_run" + + [[extensions.targeting]] + target = "purchase.discount.cart_fetch" + input_query = "src/run.graphql" + export = "cart_fetch" + + [[extensions.targeting]] + target = "purchase.discount.delivery_run" + input_query = "src/run.graphql" + export = "delivery_run" + + [[extensions.targeting]] + target = "purchase.discount.delivery_fetch" + input_query = "src/run.graphql" + export = "delivery_fetch" + + [extensions.build] + command = "cargo build --target=wasm32-wasip1 --release" + path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" + watch = [ "src/**/*.rs" ] + + [extensions.ui.paths] + create = "/" + details = "/" diff --git a/discounts/rust/discounts/default/src/main.rs b/discounts/rust/discounts/default/src/main.rs new file mode 100644 index 00000000..9272b027 --- /dev/null +++ b/discounts/rust/discounts/default/src/main.rs @@ -0,0 +1,7 @@ +use std::process; +pub mod run; + +fn main() { + eprintln!("Please invoke a named export."); + process::exit(1); +} diff --git a/discounts/rust/discounts/default/src/run.graphql.liquid b/discounts/rust/discounts/default/src/run.graphql.liquid new file mode 100644 index 00000000..bc740d91 --- /dev/null +++ b/discounts/rust/discounts/default/src/run.graphql.liquid @@ -0,0 +1,7 @@ +query Input { + discountNode { + metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { + value + } + } +} diff --git a/discounts/rust/discounts/default/src/run.rs b/discounts/rust/discounts/default/src/run.rs new file mode 100644 index 00000000..69b8cfde --- /dev/null +++ b/discounts/rust/discounts/default/src/run.rs @@ -0,0 +1,61 @@ +use shopify_function::prelude::*; +use shopify_function::Result; + +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Default, PartialEq)] +#[serde(rename_all(deserialize = "camelCase"))] +struct Configuration {} + +impl Configuration { + fn from_str(value: &str) -> Self { + serde_json::from_str(value).expect("Unable to parse configuration value from metafield") + } +} + +#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] +fn run(input: input::ResponseData) -> Result { + let no_discount = output::FunctionRunResult { + discounts: vec![], + discount_application_strategy: output::DiscountApplicationStrategy::FIRST, + }; + + let _config = match input.discount_node.metafield { + Some(input::InputDiscountNodeMetafield { value }) => Configuration::from_str(&value), + None => return Ok(no_discount), + }; + + Ok(output::FunctionRunResult { + discounts: vec![], + discount_application_strategy: output::DiscountApplicationStrategy::FIRST, + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use shopify_function::{run_function_with_input, Result}; + + #[test] + fn test_result_contains_no_discounts() -> Result<()> { + use run::output::*; + + let result = run_function_with_input( + run, + r#" + { + "discountNode": { + "metafield": null + } + } + "#, + )?; + let expected = FunctionRunResult { + discounts: vec![], + discount_application_strategy: DiscountApplicationStrategy::FIRST, + }; + + assert_eq!(result, expected); + Ok(()) + } +} diff --git a/discounts/wasm/discounts/default/locales/en.default.json.liquid b/discounts/wasm/discounts/default/locales/en.default.json.liquid new file mode 100644 index 00000000..333045ae --- /dev/null +++ b/discounts/wasm/discounts/default/locales/en.default.json.liquid @@ -0,0 +1,4 @@ +{ + "name": "{{name}}", + "description": "{{name}}" +} diff --git a/discounts/wasm/discounts/default/run.graphql.liquid b/discounts/wasm/discounts/default/run.graphql.liquid new file mode 100644 index 00000000..bc740d91 --- /dev/null +++ b/discounts/wasm/discounts/default/run.graphql.liquid @@ -0,0 +1,7 @@ +query Input { + discountNode { + metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { + value + } + } +} diff --git a/discounts/wasm/discounts/default/schema.graphql b/discounts/wasm/discounts/default/schema.graphql new file mode 100644 index 00000000..3ca4e22b --- /dev/null +++ b/discounts/wasm/discounts/default/schema.graphql @@ -0,0 +1,4518 @@ +schema { + query: Input + mutation: MutationRoot +} + +""" +Scale the Functions resource limits based on the field's length. +""" +directive @scaleLimits(rate: Float!) on FIELD_DEFINITION + +""" +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +Represents a generic custom attribute, such as whether an order is a customer's first. +""" +type Attribute { + """ + The key or name of the attribute. For example, `"customersFirstOrder"`. + """ + key: String! + + """ + The value of the attribute. For example, `"true"`. + """ + value: String +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type BuyerIdentity { + """ + The customer associated with the cart. + """ + customer: Customer + + """ + The email address of the buyer that's interacting with the cart. + """ + email: String + + """ + Whether the buyer authenticated with a customer account. + """ + isAuthenticated: Boolean! + + """ + The phone number of the buyer that's interacting with the cart. + """ + phone: String + + """ + The purchasing company associated with the cart. + """ + purchasingCompany: PurchasingCompany +} + +""" +A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +""" +type Cart { + """ + The attributes associated with the cart. Attributes are represented as key-value pairs. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + Information about the buyer that is interacting with the cart. + """ + buyerIdentity: BuyerIdentity + + """ + The costs that the buyer will pay at checkout. + """ + cost: CartCost! + + """ + A list of lines containing information about the items that can be delivered. + """ + deliverableLines: [DeliverableCartLine!]! + + """ + The delivery groups available for the cart based on the buyer's shipping address. + """ + deliveryGroups: [CartDeliveryGroup!]! + + """ + A list of lines containing information about the items the customer intends to purchase. + """ + lines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The localized fields available for the cart. + """ + localizedFields( + """ + The keys of the localized fields to retrieve. + """ + keys: [LocalizedFieldKey!]! = [] + ): [LocalizedField!]! +} + +""" +The cost that the buyer will pay at checkout. +""" +type CartCost { + """ + The amount, before taxes and discounts, for the customer to pay. + """ + subtotalAmount: MoneyV2! + + """ + The total amount for the customer to pay. + """ + totalAmount: MoneyV2! + + """ + The duty amount for the customer to pay at checkout. + """ + totalDutyAmount: MoneyV2 + + """ + The tax amount for the customer to pay at checkout. + """ + totalTaxAmount: MoneyV2 +} + +""" +Information about the options available for one or more line items to be delivered to a specific address. +""" +type CartDeliveryGroup { + """ + A list of cart lines for the delivery group. + """ + cartLines: [CartLine!]! @scaleLimits(rate: 0.005) + + """ + The destination address for the delivery group. + """ + deliveryAddress: MailingAddress + + """ + The delivery options available for the delivery group. + """ + deliveryOptions: [CartDeliveryOption!]! + + """ + Unique identifier for the delivery group. + """ + id: ID! + + """ + Information about the delivery option the buyer has selected. + """ + selectedDeliveryOption: CartDeliveryOption +} + +""" +Information about a delivery option. +""" +type CartDeliveryOption { + """ + The code of the delivery option. + """ + code: String + + """ + The cost for the delivery option. + """ + cost: MoneyV2! + + """ + The method for the delivery option. + """ + deliveryMethodType: DeliveryMethod! + + """ + The description of the delivery option. + """ + description: String + + """ + The unique identifier of the delivery option. + """ + handle: Handle! + + """ + The title of the delivery option. + """ + title: String +} + +""" +Represents information about the merchandise in the cart. +""" +type CartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The cost of the merchandise line that the buyer will pay at checkout. + """ + cost: CartLineCost! + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! + + """ + The selling plan associated with the cart line and the effect that each + selling plan has on variants when they're purchased. + """ + sellingPlanAllocation: SellingPlanAllocation +} + +""" +The cost of the merchandise line that the buyer will pay at checkout. +""" +type CartLineCost { + """ + The amount of the merchandise line. + """ + amountPerQuantity: MoneyV2! + + """ + The compare at amount of the merchandise line. This value varies depending on + the buyer's identity, and is null when the value is hidden to buyers. + """ + compareAtAmountPerQuantity: MoneyV2 + + """ + The cost of the merchandise line before line-level discounts. + """ + subtotalAmount: MoneyV2! + + """ + The total cost of the merchandise line. + """ + totalAmount: MoneyV2! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. +""" +input CartLineTarget { + """ + The ID of the targeted cart line. + """ + id: ID! + + """ + The number of line items that are being discounted. + The default value is `null`, which represents the quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents whether the product is a member of the given collection. +""" +type CollectionMembership { + """ + The ID of the collection. + """ + collectionId: ID! + + """ + Whether the product is a member of the collection. + """ + isMember: Boolean! +} + +""" +Represents information about a company which is also a customer of the shop. +""" +type Company implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's main point of contact. +""" +type CompanyContact { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was created in Shopify. + """ + createdAt: DateTime! + + """ + The ID of the company. + """ + id: ID! + + """ + The company contact's locale (language). + """ + locale: String + + """ + The company contact's job title. + """ + title: String + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company contact was last modified. + """ + updatedAt: DateTime! +} + +""" +A company's location. +""" +type CompanyLocation implements HasMetafields { + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was created in Shopify. + """ + createdAt: DateTime! + + """ + A unique externally-supplied ID for the company. + """ + externalId: String + + """ + The ID of the company. + """ + id: ID! + + """ + The preferred locale of the company location. + """ + locale: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the company location. + """ + name: String! + + """ + The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) + at which the company location was last modified. + """ + updatedAt: DateTime! +} + +""" +A country. +""" +type Country { + """ + The ISO code of the country. + """ + isoCode: CountryCode! +} + +""" +The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. +If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision +of another country. For example, the territories associated with Spain are represented by the country code `ES`, +and the territories associated with the United States of America are represented by the country code `US`. +""" +enum CountryCode { + """ + Ascension Island. + """ + AC + + """ + Andorra. + """ + AD + + """ + United Arab Emirates. + """ + AE + + """ + Afghanistan. + """ + AF + + """ + Antigua & Barbuda. + """ + AG + + """ + Anguilla. + """ + AI + + """ + Albania. + """ + AL + + """ + Armenia. + """ + AM + + """ + Netherlands Antilles. + """ + AN + + """ + Angola. + """ + AO + + """ + Argentina. + """ + AR + + """ + Austria. + """ + AT + + """ + Australia. + """ + AU + + """ + Aruba. + """ + AW + + """ + Åland Islands. + """ + AX + + """ + Azerbaijan. + """ + AZ + + """ + Bosnia & Herzegovina. + """ + BA + + """ + Barbados. + """ + BB + + """ + Bangladesh. + """ + BD + + """ + Belgium. + """ + BE + + """ + Burkina Faso. + """ + BF + + """ + Bulgaria. + """ + BG + + """ + Bahrain. + """ + BH + + """ + Burundi. + """ + BI + + """ + Benin. + """ + BJ + + """ + St. Barthélemy. + """ + BL + + """ + Bermuda. + """ + BM + + """ + Brunei. + """ + BN + + """ + Bolivia. + """ + BO + + """ + Caribbean Netherlands. + """ + BQ + + """ + Brazil. + """ + BR + + """ + Bahamas. + """ + BS + + """ + Bhutan. + """ + BT + + """ + Bouvet Island. + """ + BV + + """ + Botswana. + """ + BW + + """ + Belarus. + """ + BY + + """ + Belize. + """ + BZ + + """ + Canada. + """ + CA + + """ + Cocos (Keeling) Islands. + """ + CC + + """ + Congo - Kinshasa. + """ + CD + + """ + Central African Republic. + """ + CF + + """ + Congo - Brazzaville. + """ + CG + + """ + Switzerland. + """ + CH + + """ + Côte d’Ivoire. + """ + CI + + """ + Cook Islands. + """ + CK + + """ + Chile. + """ + CL + + """ + Cameroon. + """ + CM + + """ + China. + """ + CN + + """ + Colombia. + """ + CO + + """ + Costa Rica. + """ + CR + + """ + Cuba. + """ + CU + + """ + Cape Verde. + """ + CV + + """ + Curaçao. + """ + CW + + """ + Christmas Island. + """ + CX + + """ + Cyprus. + """ + CY + + """ + Czechia. + """ + CZ + + """ + Germany. + """ + DE + + """ + Djibouti. + """ + DJ + + """ + Denmark. + """ + DK + + """ + Dominica. + """ + DM + + """ + Dominican Republic. + """ + DO + + """ + Algeria. + """ + DZ + + """ + Ecuador. + """ + EC + + """ + Estonia. + """ + EE + + """ + Egypt. + """ + EG + + """ + Western Sahara. + """ + EH + + """ + Eritrea. + """ + ER + + """ + Spain. + """ + ES + + """ + Ethiopia. + """ + ET + + """ + Finland. + """ + FI + + """ + Fiji. + """ + FJ + + """ + Falkland Islands. + """ + FK + + """ + Faroe Islands. + """ + FO + + """ + France. + """ + FR + + """ + Gabon. + """ + GA + + """ + United Kingdom. + """ + GB + + """ + Grenada. + """ + GD + + """ + Georgia. + """ + GE + + """ + French Guiana. + """ + GF + + """ + Guernsey. + """ + GG + + """ + Ghana. + """ + GH + + """ + Gibraltar. + """ + GI + + """ + Greenland. + """ + GL + + """ + Gambia. + """ + GM + + """ + Guinea. + """ + GN + + """ + Guadeloupe. + """ + GP + + """ + Equatorial Guinea. + """ + GQ + + """ + Greece. + """ + GR + + """ + South Georgia & South Sandwich Islands. + """ + GS + + """ + Guatemala. + """ + GT + + """ + Guinea-Bissau. + """ + GW + + """ + Guyana. + """ + GY + + """ + Hong Kong SAR. + """ + HK + + """ + Heard & McDonald Islands. + """ + HM + + """ + Honduras. + """ + HN + + """ + Croatia. + """ + HR + + """ + Haiti. + """ + HT + + """ + Hungary. + """ + HU + + """ + Indonesia. + """ + ID + + """ + Ireland. + """ + IE + + """ + Israel. + """ + IL + + """ + Isle of Man. + """ + IM + + """ + India. + """ + IN + + """ + British Indian Ocean Territory. + """ + IO + + """ + Iraq. + """ + IQ + + """ + Iran. + """ + IR + + """ + Iceland. + """ + IS + + """ + Italy. + """ + IT + + """ + Jersey. + """ + JE + + """ + Jamaica. + """ + JM + + """ + Jordan. + """ + JO + + """ + Japan. + """ + JP + + """ + Kenya. + """ + KE + + """ + Kyrgyzstan. + """ + KG + + """ + Cambodia. + """ + KH + + """ + Kiribati. + """ + KI + + """ + Comoros. + """ + KM + + """ + St. Kitts & Nevis. + """ + KN + + """ + North Korea. + """ + KP + + """ + South Korea. + """ + KR + + """ + Kuwait. + """ + KW + + """ + Cayman Islands. + """ + KY + + """ + Kazakhstan. + """ + KZ + + """ + Laos. + """ + LA + + """ + Lebanon. + """ + LB + + """ + St. Lucia. + """ + LC + + """ + Liechtenstein. + """ + LI + + """ + Sri Lanka. + """ + LK + + """ + Liberia. + """ + LR + + """ + Lesotho. + """ + LS + + """ + Lithuania. + """ + LT + + """ + Luxembourg. + """ + LU + + """ + Latvia. + """ + LV + + """ + Libya. + """ + LY + + """ + Morocco. + """ + MA + + """ + Monaco. + """ + MC + + """ + Moldova. + """ + MD + + """ + Montenegro. + """ + ME + + """ + St. Martin. + """ + MF + + """ + Madagascar. + """ + MG + + """ + North Macedonia. + """ + MK + + """ + Mali. + """ + ML + + """ + Myanmar (Burma). + """ + MM + + """ + Mongolia. + """ + MN + + """ + Macao SAR. + """ + MO + + """ + Martinique. + """ + MQ + + """ + Mauritania. + """ + MR + + """ + Montserrat. + """ + MS + + """ + Malta. + """ + MT + + """ + Mauritius. + """ + MU + + """ + Maldives. + """ + MV + + """ + Malawi. + """ + MW + + """ + Mexico. + """ + MX + + """ + Malaysia. + """ + MY + + """ + Mozambique. + """ + MZ + + """ + Namibia. + """ + NA + + """ + New Caledonia. + """ + NC + + """ + Niger. + """ + NE + + """ + Norfolk Island. + """ + NF + + """ + Nigeria. + """ + NG + + """ + Nicaragua. + """ + NI + + """ + Netherlands. + """ + NL + + """ + Norway. + """ + NO + + """ + Nepal. + """ + NP + + """ + Nauru. + """ + NR + + """ + Niue. + """ + NU + + """ + New Zealand. + """ + NZ + + """ + Oman. + """ + OM + + """ + Panama. + """ + PA + + """ + Peru. + """ + PE + + """ + French Polynesia. + """ + PF + + """ + Papua New Guinea. + """ + PG + + """ + Philippines. + """ + PH + + """ + Pakistan. + """ + PK + + """ + Poland. + """ + PL + + """ + St. Pierre & Miquelon. + """ + PM + + """ + Pitcairn Islands. + """ + PN + + """ + Palestinian Territories. + """ + PS + + """ + Portugal. + """ + PT + + """ + Paraguay. + """ + PY + + """ + Qatar. + """ + QA + + """ + Réunion. + """ + RE + + """ + Romania. + """ + RO + + """ + Serbia. + """ + RS + + """ + Russia. + """ + RU + + """ + Rwanda. + """ + RW + + """ + Saudi Arabia. + """ + SA + + """ + Solomon Islands. + """ + SB + + """ + Seychelles. + """ + SC + + """ + Sudan. + """ + SD + + """ + Sweden. + """ + SE + + """ + Singapore. + """ + SG + + """ + St. Helena. + """ + SH + + """ + Slovenia. + """ + SI + + """ + Svalbard & Jan Mayen. + """ + SJ + + """ + Slovakia. + """ + SK + + """ + Sierra Leone. + """ + SL + + """ + San Marino. + """ + SM + + """ + Senegal. + """ + SN + + """ + Somalia. + """ + SO + + """ + Suriname. + """ + SR + + """ + South Sudan. + """ + SS + + """ + São Tomé & Príncipe. + """ + ST + + """ + El Salvador. + """ + SV + + """ + Sint Maarten. + """ + SX + + """ + Syria. + """ + SY + + """ + Eswatini. + """ + SZ + + """ + Tristan da Cunha. + """ + TA + + """ + Turks & Caicos Islands. + """ + TC + + """ + Chad. + """ + TD + + """ + French Southern Territories. + """ + TF + + """ + Togo. + """ + TG + + """ + Thailand. + """ + TH + + """ + Tajikistan. + """ + TJ + + """ + Tokelau. + """ + TK + + """ + Timor-Leste. + """ + TL + + """ + Turkmenistan. + """ + TM + + """ + Tunisia. + """ + TN + + """ + Tonga. + """ + TO + + """ + Türkiye. + """ + TR + + """ + Trinidad & Tobago. + """ + TT + + """ + Tuvalu. + """ + TV + + """ + Taiwan. + """ + TW + + """ + Tanzania. + """ + TZ + + """ + Ukraine. + """ + UA + + """ + Uganda. + """ + UG + + """ + U.S. Outlying Islands. + """ + UM + + """ + United States. + """ + US + + """ + Uruguay. + """ + UY + + """ + Uzbekistan. + """ + UZ + + """ + Vatican City. + """ + VA + + """ + St. Vincent & Grenadines. + """ + VC + + """ + Venezuela. + """ + VE + + """ + British Virgin Islands. + """ + VG + + """ + Vietnam. + """ + VN + + """ + Vanuatu. + """ + VU + + """ + Wallis & Futuna. + """ + WF + + """ + Samoa. + """ + WS + + """ + Kosovo. + """ + XK + + """ + Yemen. + """ + YE + + """ + Mayotte. + """ + YT + + """ + South Africa. + """ + ZA + + """ + Zambia. + """ + ZM + + """ + Zimbabwe. + """ + ZW + + """ + Unknown Region. + """ + ZZ +} + +""" +The three-letter currency codes that represent the world currencies used in +stores. These include standard ISO 4217 codes, legacy codes, +and non-standard codes. +""" +enum CurrencyCode { + """ + United Arab Emirates Dirham (AED). + """ + AED + + """ + Afghan Afghani (AFN). + """ + AFN + + """ + Albanian Lek (ALL). + """ + ALL + + """ + Armenian Dram (AMD). + """ + AMD + + """ + Netherlands Antillean Guilder. + """ + ANG + + """ + Angolan Kwanza (AOA). + """ + AOA + + """ + Argentine Pesos (ARS). + """ + ARS + + """ + Australian Dollars (AUD). + """ + AUD + + """ + Aruban Florin (AWG). + """ + AWG + + """ + Azerbaijani Manat (AZN). + """ + AZN + + """ + Bosnia and Herzegovina Convertible Mark (BAM). + """ + BAM + + """ + Barbadian Dollar (BBD). + """ + BBD + + """ + Bangladesh Taka (BDT). + """ + BDT + + """ + Bulgarian Lev (BGN). + """ + BGN + + """ + Bahraini Dinar (BHD). + """ + BHD + + """ + Burundian Franc (BIF). + """ + BIF + + """ + Bermudian Dollar (BMD). + """ + BMD + + """ + Brunei Dollar (BND). + """ + BND + + """ + Bolivian Boliviano (BOB). + """ + BOB + + """ + Brazilian Real (BRL). + """ + BRL + + """ + Bahamian Dollar (BSD). + """ + BSD + + """ + Bhutanese Ngultrum (BTN). + """ + BTN + + """ + Botswana Pula (BWP). + """ + BWP + + """ + Belarusian Ruble (BYN). + """ + BYN + + """ + Belarusian Ruble (BYR). + """ + BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") + + """ + Belize Dollar (BZD). + """ + BZD + + """ + Canadian Dollars (CAD). + """ + CAD + + """ + Congolese franc (CDF). + """ + CDF + + """ + Swiss Francs (CHF). + """ + CHF + + """ + Chilean Peso (CLP). + """ + CLP + + """ + Chinese Yuan Renminbi (CNY). + """ + CNY + + """ + Colombian Peso (COP). + """ + COP + + """ + Costa Rican Colones (CRC). + """ + CRC + + """ + Cape Verdean escudo (CVE). + """ + CVE + + """ + Czech Koruny (CZK). + """ + CZK + + """ + Djiboutian Franc (DJF). + """ + DJF + + """ + Danish Kroner (DKK). + """ + DKK + + """ + Dominican Peso (DOP). + """ + DOP + + """ + Algerian Dinar (DZD). + """ + DZD + + """ + Egyptian Pound (EGP). + """ + EGP + + """ + Eritrean Nakfa (ERN). + """ + ERN + + """ + Ethiopian Birr (ETB). + """ + ETB + + """ + Euro (EUR). + """ + EUR + + """ + Fijian Dollars (FJD). + """ + FJD + + """ + Falkland Islands Pounds (FKP). + """ + FKP + + """ + United Kingdom Pounds (GBP). + """ + GBP + + """ + Georgian Lari (GEL). + """ + GEL + + """ + Ghanaian Cedi (GHS). + """ + GHS + + """ + Gibraltar Pounds (GIP). + """ + GIP + + """ + Gambian Dalasi (GMD). + """ + GMD + + """ + Guinean Franc (GNF). + """ + GNF + + """ + Guatemalan Quetzal (GTQ). + """ + GTQ + + """ + Guyanese Dollar (GYD). + """ + GYD + + """ + Hong Kong Dollars (HKD). + """ + HKD + + """ + Honduran Lempira (HNL). + """ + HNL + + """ + Croatian Kuna (HRK). + """ + HRK + + """ + Haitian Gourde (HTG). + """ + HTG + + """ + Hungarian Forint (HUF). + """ + HUF + + """ + Indonesian Rupiah (IDR). + """ + IDR + + """ + Israeli New Shekel (NIS). + """ + ILS + + """ + Indian Rupees (INR). + """ + INR + + """ + Iraqi Dinar (IQD). + """ + IQD + + """ + Iranian Rial (IRR). + """ + IRR + + """ + Icelandic Kronur (ISK). + """ + ISK + + """ + Jersey Pound. + """ + JEP + + """ + Jamaican Dollars (JMD). + """ + JMD + + """ + Jordanian Dinar (JOD). + """ + JOD + + """ + Japanese Yen (JPY). + """ + JPY + + """ + Kenyan Shilling (KES). + """ + KES + + """ + Kyrgyzstani Som (KGS). + """ + KGS + + """ + Cambodian Riel. + """ + KHR + + """ + Kiribati Dollar (KID). + """ + KID + + """ + Comorian Franc (KMF). + """ + KMF + + """ + South Korean Won (KRW). + """ + KRW + + """ + Kuwaiti Dinar (KWD). + """ + KWD + + """ + Cayman Dollars (KYD). + """ + KYD + + """ + Kazakhstani Tenge (KZT). + """ + KZT + + """ + Laotian Kip (LAK). + """ + LAK + + """ + Lebanese Pounds (LBP). + """ + LBP + + """ + Sri Lankan Rupees (LKR). + """ + LKR + + """ + Liberian Dollar (LRD). + """ + LRD + + """ + Lesotho Loti (LSL). + """ + LSL + + """ + Lithuanian Litai (LTL). + """ + LTL + + """ + Latvian Lati (LVL). + """ + LVL + + """ + Libyan Dinar (LYD). + """ + LYD + + """ + Moroccan Dirham. + """ + MAD + + """ + Moldovan Leu (MDL). + """ + MDL + + """ + Malagasy Ariary (MGA). + """ + MGA + + """ + Macedonia Denar (MKD). + """ + MKD + + """ + Burmese Kyat (MMK). + """ + MMK + + """ + Mongolian Tugrik. + """ + MNT + + """ + Macanese Pataca (MOP). + """ + MOP + + """ + Mauritanian Ouguiya (MRU). + """ + MRU + + """ + Mauritian Rupee (MUR). + """ + MUR + + """ + Maldivian Rufiyaa (MVR). + """ + MVR + + """ + Malawian Kwacha (MWK). + """ + MWK + + """ + Mexican Pesos (MXN). + """ + MXN + + """ + Malaysian Ringgits (MYR). + """ + MYR + + """ + Mozambican Metical. + """ + MZN + + """ + Namibian Dollar. + """ + NAD + + """ + Nigerian Naira (NGN). + """ + NGN + + """ + Nicaraguan Córdoba (NIO). + """ + NIO + + """ + Norwegian Kroner (NOK). + """ + NOK + + """ + Nepalese Rupee (NPR). + """ + NPR + + """ + New Zealand Dollars (NZD). + """ + NZD + + """ + Omani Rial (OMR). + """ + OMR + + """ + Panamian Balboa (PAB). + """ + PAB + + """ + Peruvian Nuevo Sol (PEN). + """ + PEN + + """ + Papua New Guinean Kina (PGK). + """ + PGK + + """ + Philippine Peso (PHP). + """ + PHP + + """ + Pakistani Rupee (PKR). + """ + PKR + + """ + Polish Zlotych (PLN). + """ + PLN + + """ + Paraguayan Guarani (PYG). + """ + PYG + + """ + Qatari Rial (QAR). + """ + QAR + + """ + Romanian Lei (RON). + """ + RON + + """ + Serbian dinar (RSD). + """ + RSD + + """ + Russian Rubles (RUB). + """ + RUB + + """ + Rwandan Franc (RWF). + """ + RWF + + """ + Saudi Riyal (SAR). + """ + SAR + + """ + Solomon Islands Dollar (SBD). + """ + SBD + + """ + Seychellois Rupee (SCR). + """ + SCR + + """ + Sudanese Pound (SDG). + """ + SDG + + """ + Swedish Kronor (SEK). + """ + SEK + + """ + Singapore Dollars (SGD). + """ + SGD + + """ + Saint Helena Pounds (SHP). + """ + SHP + + """ + Sierra Leonean Leone (SLL). + """ + SLL + + """ + Somali Shilling (SOS). + """ + SOS + + """ + Surinamese Dollar (SRD). + """ + SRD + + """ + South Sudanese Pound (SSP). + """ + SSP + + """ + Sao Tome And Principe Dobra (STD). + """ + STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") + + """ + Sao Tome And Principe Dobra (STN). + """ + STN + + """ + Syrian Pound (SYP). + """ + SYP + + """ + Swazi Lilangeni (SZL). + """ + SZL + + """ + Thai baht (THB). + """ + THB + + """ + Tajikistani Somoni (TJS). + """ + TJS + + """ + Turkmenistani Manat (TMT). + """ + TMT + + """ + Tunisian Dinar (TND). + """ + TND + + """ + Tongan Pa'anga (TOP). + """ + TOP + + """ + Turkish Lira (TRY). + """ + TRY + + """ + Trinidad and Tobago Dollars (TTD). + """ + TTD + + """ + Taiwan Dollars (TWD). + """ + TWD + + """ + Tanzanian Shilling (TZS). + """ + TZS + + """ + Ukrainian Hryvnia (UAH). + """ + UAH + + """ + Ugandan Shilling (UGX). + """ + UGX + + """ + United States Dollars (USD). + """ + USD + + """ + Uruguayan Pesos (UYU). + """ + UYU + + """ + Uzbekistan som (UZS). + """ + UZS + + """ + Venezuelan Bolivares (VED). + """ + VED + + """ + Venezuelan Bolivares (VEF). + """ + VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") + + """ + Venezuelan Bolivares Soberanos (VES). + """ + VES + + """ + Vietnamese đồng (VND). + """ + VND + + """ + Vanuatu Vatu (VUV). + """ + VUV + + """ + Samoan Tala (WST). + """ + WST + + """ + Central African CFA Franc (XAF). + """ + XAF + + """ + East Caribbean Dollar (XCD). + """ + XCD + + """ + West African CFA franc (XOF). + """ + XOF + + """ + CFP Franc (XPF). + """ + XPF + + """ + Unrecognized currency. + """ + XXX + + """ + Yemeni Rial (YER). + """ + YER + + """ + South African Rand (ZAR). + """ + ZAR + + """ + Zambian Kwacha (ZMW). + """ + ZMW +} + +""" +A custom product. +""" +type CustomProduct { + """ + Whether the merchandise is a gift card. + """ + isGiftCard: Boolean! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +Represents a customer with the shop. +""" +type Customer implements HasMetafields { + """ + The total amount of money spent by the customer. Converted from the shop's + currency to the currency of the cart using a market rate. + """ + amountSpent: MoneyV2! + + """ + The customer’s name, email or phone number. + """ + displayName: String! + + """ + The customer’s email address. + """ + email: String + + """ + The customer's first name. + """ + firstName: String + + """ + Whether the customer has any of the given tags. + """ + hasAnyTag( + """ + The tags to search for. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the customer has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A unique identifier for the customer. + """ + id: ID! + + """ + The customer's last name. + """ + lastName: String + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The number of orders made by the customer. + """ + numberOfOrders: Int! +} + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. +For example, September 7, 2019 is represented as `"2019-07-16"`. +""" +scalar Date + +""" +Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. +For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is +represented as `"2019-09-07T15:50:00Z`". +""" +scalar DateTime + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the date and time but not the timezone which is determined from context. + +For example, "2018-01-01T00:00:00". +""" +scalar DateTimeWithoutTimezone + +""" +A signed decimal number, which supports arbitrary precision and is serialized as a string. + +Example values: `"29.99"`, `"29.999"`. +""" +scalar Decimal + +""" +Represents information about the merchandise in the cart. +""" +type DeliverableCartLine { + """ + Retrieve a cart line attribute by key. + + Cart line attributes are also known as line item properties in Liquid. + """ + attribute( + """ + The key of the attribute to retrieve. + """ + key: String + ): Attribute + + """ + The ID of the cart line. + """ + id: ID! + + """ + The merchandise that the buyer intends to purchase. + """ + merchandise: Merchandise! + + """ + The quantity of the merchandise that the customer intends to purchase. + """ + quantity: Int! +} + +""" +List of different delivery method types. +""" +enum DeliveryMethod { + """ + Local Delivery. + """ + LOCAL + + """ + None. + """ + NONE + + """ + Shipping to a Pickup Point. + """ + PICKUP_POINT + + """ + Local Pickup. + """ + PICK_UP + + """ + Retail. + """ + RETAIL + + """ + Shipping. + """ + SHIPPING +} + +""" +The discount to be applied. +""" +input Discount { + """ + The discount message. + """ + message: String + + """ + The targets of the discount. + + This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + """ + targets: [Target!]! + + """ + The value of the discount. + """ + value: Value! +} + +""" +The strategy that's applied to the list of discounts. +""" +enum DiscountApplicationStrategy { + """ + Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. + """ + ALL + + """ + Only apply the first discount with conditions that are satisfied. + """ + FIRST + + """ + Only apply the discount that offers the maximum reduction. + """ + MAXIMUM +} + +""" +A discount wrapper node. +""" +type DiscountNode implements HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A fixed amount value. +""" +input FixedAmount { + """ + The fixed amount value of the discount, in the currency of the cart. + + The amount must be greater than or equal to 0. + """ + amount: Decimal! + + """ + Whether to apply the value to each entitled item. + + The default value is `false`, which causes the value to be applied once across the entitled items. + When the value is `true`, the value will be applied to each of the entitled items. + """ + appliesToEachItem: Boolean +} + +""" +The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +""" +input FunctionResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +The run target result. +""" +input FunctionRunResult { + """ + The strategy to apply the list of discounts. + """ + discountApplicationStrategy: DiscountApplicationStrategy! + + """ + The list of discounts to be applied. + """ + discounts: [Discount!]! +} + +""" +A function-scoped handle to a refer a resource. +The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. +Example value: `"10079785100"` +""" +scalar Handle + +""" +Represents information about the metafields associated to the specified resource. +""" +interface HasMetafields { + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +Represents whether the current object has the given tag. +""" +type HasTagResponse { + """ + Whether the current object has the tag. + """ + hasTag: Boolean! + + """ + The tag. + """ + tag: String! +} + +""" +Represents a unique identifier, often used to refetch an object. +The ID type appears in a JSON response as a String, but it is not intended to be human-readable. + +Example value: `"gid://shopify/Product/10079785100"` +""" +scalar ID + +""" +The input object for the function. +""" +type Input { + """ + The cart. + """ + cart: Cart! + + """ + The discount node executing the function. + """ + discountNode: DiscountNode! + + """ + The localization of the Function execution context. + """ + localization: Localization! + + """ + The conversion rate between the shop's currency and the currency of the cart. + """ + presentmentCurrencyRate: Decimal! + + """ + Information about the shop. + """ + shop: Shop! +} + +""" +A [JSON](https://www.json.org/json-en.html) object. + +Example value: +`{ + "product": { + "id": "gid://shopify/Product/1346443542550", + "title": "White T-shirt", + "options": [{ + "name": "Size", + "values": ["M", "L"] + }] + } +}` +""" +scalar JSON + +""" +A language. +""" +type Language { + """ + The ISO code. + """ + isoCode: LanguageCode! +} + +""" +Language codes supported by Shopify. +""" +enum LanguageCode { + """ + Afrikaans. + """ + AF + + """ + Akan. + """ + AK + + """ + Amharic. + """ + AM + + """ + Arabic. + """ + AR + + """ + Assamese. + """ + AS + + """ + Azerbaijani. + """ + AZ + + """ + Belarusian. + """ + BE + + """ + Bulgarian. + """ + BG + + """ + Bambara. + """ + BM + + """ + Bangla. + """ + BN + + """ + Tibetan. + """ + BO + + """ + Breton. + """ + BR + + """ + Bosnian. + """ + BS + + """ + Catalan. + """ + CA + + """ + Chechen. + """ + CE + + """ + Central Kurdish. + """ + CKB + + """ + Czech. + """ + CS + + """ + Church Slavic. + """ + CU + + """ + Welsh. + """ + CY + + """ + Danish. + """ + DA + + """ + German. + """ + DE + + """ + Dzongkha. + """ + DZ + + """ + Ewe. + """ + EE + + """ + Greek. + """ + EL + + """ + English. + """ + EN + + """ + Esperanto. + """ + EO + + """ + Spanish. + """ + ES + + """ + Estonian. + """ + ET + + """ + Basque. + """ + EU + + """ + Persian. + """ + FA + + """ + Fulah. + """ + FF + + """ + Finnish. + """ + FI + + """ + Filipino. + """ + FIL + + """ + Faroese. + """ + FO + + """ + French. + """ + FR + + """ + Western Frisian. + """ + FY + + """ + Irish. + """ + GA + + """ + Scottish Gaelic. + """ + GD + + """ + Galician. + """ + GL + + """ + Gujarati. + """ + GU + + """ + Manx. + """ + GV + + """ + Hausa. + """ + HA + + """ + Hebrew. + """ + HE + + """ + Hindi. + """ + HI + + """ + Croatian. + """ + HR + + """ + Hungarian. + """ + HU + + """ + Armenian. + """ + HY + + """ + Interlingua. + """ + IA + + """ + Indonesian. + """ + ID + + """ + Igbo. + """ + IG + + """ + Sichuan Yi. + """ + II + + """ + Icelandic. + """ + IS + + """ + Italian. + """ + IT + + """ + Japanese. + """ + JA + + """ + Javanese. + """ + JV + + """ + Georgian. + """ + KA + + """ + Kikuyu. + """ + KI + + """ + Kazakh. + """ + KK + + """ + Kalaallisut. + """ + KL + + """ + Khmer. + """ + KM + + """ + Kannada. + """ + KN + + """ + Korean. + """ + KO + + """ + Kashmiri. + """ + KS + + """ + Kurdish. + """ + KU + + """ + Cornish. + """ + KW + + """ + Kyrgyz. + """ + KY + + """ + Luxembourgish. + """ + LB + + """ + Ganda. + """ + LG + + """ + Lingala. + """ + LN + + """ + Lao. + """ + LO + + """ + Lithuanian. + """ + LT + + """ + Luba-Katanga. + """ + LU + + """ + Latvian. + """ + LV + + """ + Malagasy. + """ + MG + + """ + Māori. + """ + MI + + """ + Macedonian. + """ + MK + + """ + Malayalam. + """ + ML + + """ + Mongolian. + """ + MN + + """ + Marathi. + """ + MR + + """ + Malay. + """ + MS + + """ + Maltese. + """ + MT + + """ + Burmese. + """ + MY + + """ + Norwegian (Bokmål). + """ + NB + + """ + North Ndebele. + """ + ND + + """ + Nepali. + """ + NE + + """ + Dutch. + """ + NL + + """ + Norwegian Nynorsk. + """ + NN + + """ + Norwegian. + """ + NO + + """ + Oromo. + """ + OM + + """ + Odia. + """ + OR + + """ + Ossetic. + """ + OS + + """ + Punjabi. + """ + PA + + """ + Polish. + """ + PL + + """ + Pashto. + """ + PS + + """ + Portuguese. + """ + PT + + """ + Portuguese (Brazil). + """ + PT_BR + + """ + Portuguese (Portugal). + """ + PT_PT + + """ + Quechua. + """ + QU + + """ + Romansh. + """ + RM + + """ + Rundi. + """ + RN + + """ + Romanian. + """ + RO + + """ + Russian. + """ + RU + + """ + Kinyarwanda. + """ + RW + + """ + Sanskrit. + """ + SA + + """ + Sardinian. + """ + SC + + """ + Sindhi. + """ + SD + + """ + Northern Sami. + """ + SE + + """ + Sango. + """ + SG + + """ + Sinhala. + """ + SI + + """ + Slovak. + """ + SK + + """ + Slovenian. + """ + SL + + """ + Shona. + """ + SN + + """ + Somali. + """ + SO + + """ + Albanian. + """ + SQ + + """ + Serbian. + """ + SR + + """ + Sundanese. + """ + SU + + """ + Swedish. + """ + SV + + """ + Swahili. + """ + SW + + """ + Tamil. + """ + TA + + """ + Telugu. + """ + TE + + """ + Tajik. + """ + TG + + """ + Thai. + """ + TH + + """ + Tigrinya. + """ + TI + + """ + Turkmen. + """ + TK + + """ + Tongan. + """ + TO + + """ + Turkish. + """ + TR + + """ + Tatar. + """ + TT + + """ + Uyghur. + """ + UG + + """ + Ukrainian. + """ + UK + + """ + Urdu. + """ + UR + + """ + Uzbek. + """ + UZ + + """ + Vietnamese. + """ + VI + + """ + Volapük. + """ + VO + + """ + Wolof. + """ + WO + + """ + Xhosa. + """ + XH + + """ + Yiddish. + """ + YI + + """ + Yoruba. + """ + YO + + """ + Chinese. + """ + ZH + + """ + Chinese (Simplified). + """ + ZH_CN + + """ + Chinese (Traditional). + """ + ZH_TW + + """ + Zulu. + """ + ZU +} + +""" +Represents limited information about the current time relative to the parent object. +""" +type LocalTime { + """ + The current date relative to the parent object. + """ + date: Date! + + """ + Returns true if the current date and time is at or past the given date and time, and false otherwise. + """ + dateTimeAfter( + """ + The date and time to compare against, assumed to be in the timezone of the parent object. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is before the given date and time, and false otherwise. + """ + dateTimeBefore( + """ + The date and time to compare against, assumed to be in the timezone of the parent timezone. + """ + dateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current date and time is between the two given date and times, and false otherwise. + """ + dateTimeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endDateTime: DateTimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startDateTime: DateTimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeAfter( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is at or past the given time, and false otherwise. + """ + timeBefore( + """ + The time to compare against, assumed to be in the timezone of the parent timezone. + """ + time: TimeWithoutTimezone! + ): Boolean! + + """ + Returns true if the current time is between the two given times, and false otherwise. + """ + timeBetween( + """ + The upper bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + endTime: TimeWithoutTimezone! + + """ + The lower bound time to compare against, assumed to be in the timezone of the parent timezone. + """ + startTime: TimeWithoutTimezone! + ): Boolean! +} + +""" +Information about the localized experiences configured for the shop. +""" +type Localization { + """ + The country of the active localized experience. + """ + country: Country! + + """ + The language of the active localized experience. + """ + language: Language! + + """ + The market of the active localized experience. + """ + market: Market! +} + +""" +Represents the value captured by a localized field. Localized fields are +additional fields required by certain countries on international orders. For +example, some countries require additional fields for customs information or tax +identification numbers. +""" +type LocalizedField { + """ + The key of the localized field. + """ + key: LocalizedFieldKey! + + """ + The title of the localized field. + """ + title: String! + + """ + The value of the localized field. + """ + value: String +} + +""" +Unique key identifying localized fields. +""" +enum LocalizedFieldKey { + """ + Localized field key 'shipping_credential_br' for country BR. + """ + SHIPPING_CREDENTIAL_BR + + """ + Localized field key 'shipping_credential_cl' for country CL. + """ + SHIPPING_CREDENTIAL_CL + + """ + Localized field key 'shipping_credential_cn' for country CN. + """ + SHIPPING_CREDENTIAL_CN + + """ + Localized field key 'shipping_credential_co' for country CO. + """ + SHIPPING_CREDENTIAL_CO + + """ + Localized field key 'shipping_credential_cr' for country CR. + """ + SHIPPING_CREDENTIAL_CR + + """ + Localized field key 'shipping_credential_ec' for country EC. + """ + SHIPPING_CREDENTIAL_EC + + """ + Localized field key 'shipping_credential_es' for country ES. + """ + SHIPPING_CREDENTIAL_ES + + """ + Localized field key 'shipping_credential_gt' for country GT. + """ + SHIPPING_CREDENTIAL_GT + + """ + Localized field key 'shipping_credential_id' for country ID. + """ + SHIPPING_CREDENTIAL_ID + + """ + Localized field key 'shipping_credential_kr' for country KR. + """ + SHIPPING_CREDENTIAL_KR + + """ + Localized field key 'shipping_credential_mx' for country MX. + """ + SHIPPING_CREDENTIAL_MX + + """ + Localized field key 'shipping_credential_my' for country MY. + """ + SHIPPING_CREDENTIAL_MY + + """ + Localized field key 'shipping_credential_pe' for country PE. + """ + SHIPPING_CREDENTIAL_PE + + """ + Localized field key 'shipping_credential_pt' for country PT. + """ + SHIPPING_CREDENTIAL_PT + + """ + Localized field key 'shipping_credential_py' for country PY. + """ + SHIPPING_CREDENTIAL_PY + + """ + Localized field key 'shipping_credential_tr' for country TR. + """ + SHIPPING_CREDENTIAL_TR + + """ + Localized field key 'shipping_credential_tw' for country TW. + """ + SHIPPING_CREDENTIAL_TW + + """ + Localized field key 'shipping_credential_type_co' for country CO. + """ + SHIPPING_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_br' for country BR. + """ + TAX_CREDENTIAL_BR + + """ + Localized field key 'tax_credential_cl' for country CL. + """ + TAX_CREDENTIAL_CL + + """ + Localized field key 'tax_credential_co' for country CO. + """ + TAX_CREDENTIAL_CO + + """ + Localized field key 'tax_credential_cr' for country CR. + """ + TAX_CREDENTIAL_CR + + """ + Localized field key 'tax_credential_ec' for country EC. + """ + TAX_CREDENTIAL_EC + + """ + Localized field key 'tax_credential_es' for country ES. + """ + TAX_CREDENTIAL_ES + + """ + Localized field key 'tax_credential_gt' for country GT. + """ + TAX_CREDENTIAL_GT + + """ + Localized field key 'tax_credential_id' for country ID. + """ + TAX_CREDENTIAL_ID + + """ + Localized field key 'tax_credential_it' for country IT. + """ + TAX_CREDENTIAL_IT + + """ + Localized field key 'tax_credential_mx' for country MX. + """ + TAX_CREDENTIAL_MX + + """ + Localized field key 'tax_credential_my' for country MY. + """ + TAX_CREDENTIAL_MY + + """ + Localized field key 'tax_credential_pe' for country PE. + """ + TAX_CREDENTIAL_PE + + """ + Localized field key 'tax_credential_pt' for country PT. + """ + TAX_CREDENTIAL_PT + + """ + Localized field key 'tax_credential_py' for country PY. + """ + TAX_CREDENTIAL_PY + + """ + Localized field key 'tax_credential_tr' for country TR. + """ + TAX_CREDENTIAL_TR + + """ + Localized field key 'tax_credential_type_co' for country CO. + """ + TAX_CREDENTIAL_TYPE_CO + + """ + Localized field key 'tax_credential_type_mx' for country MX. + """ + TAX_CREDENTIAL_TYPE_MX + + """ + Localized field key 'tax_credential_use_mx' for country MX. + """ + TAX_CREDENTIAL_USE_MX + + """ + Localized field key 'tax_email_it' for country IT. + """ + TAX_EMAIL_IT +} + +""" +Represents a mailing address. +""" +type MailingAddress { + """ + The first line of the address. Typically the street address or PO Box number. + """ + address1: String + + """ + The second line of the address. Typically the number of the apartment, suite, or unit. + """ + address2: String + + """ + The name of the city, district, village, or town. + """ + city: String + + """ + The name of the customer's company or organization. + """ + company: String + + """ + The two-letter code for the country of the address. For example, US. + """ + countryCode: CountryCode + + """ + The first name of the customer. + """ + firstName: String + + """ + The last name of the customer. + """ + lastName: String + + """ + The approximate latitude of the address. + """ + latitude: Float + + """ + The approximate longitude of the address. + """ + longitude: Float + + """ + The market of the address. + """ + market: Market + + """ + The full name of the customer, based on firstName and lastName. + """ + name: String + + """ + A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. + """ + phone: String + + """ + The alphanumeric code for the region. For example, ON. + """ + provinceCode: String + + """ + The zip or postal code of the address. + """ + zip: String +} + +""" +A market is a group of one or more regions that you want to target for international sales. +By creating a market, you can configure a distinct, localized shopping experience for +customers from a specific area of the world. For example, you can +[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), +[configure international pricing](https://shopify.dev/api/examples/product-price-lists), +or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). +""" +type Market implements HasMetafields { + """ + A human-readable unique string for the market automatically generated from its title. + """ + handle: Handle! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + A geographic region which comprises a market. + """ + regions: [MarketRegion!]! +} + +""" +Represents a region. +""" +interface MarketRegion { + """ + The name of the region in the language of the current localization. + """ + name: String +} + +""" +A country which comprises a market. +""" +type MarketRegionCountry implements MarketRegion { + """ + The two-letter code for the country. + """ + code: CountryCode! + + """ + The country name in the language of the current localization. + """ + name: String! +} + +""" +The merchandise to be purchased at checkout. +""" +union Merchandise = CustomProduct | ProductVariant + +""" +[Metafields](https://shopify.dev/apps/metafields) +enable you to attach additional information to a +Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) +or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). +For more information about the Shopify resources that you can attach metafields to, refer to +[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +""" +type Metafield { + """ + The data stored in the metafield in JSON format. + """ + jsonValue: JSON! + + """ + The type of data that the metafield stores in the `value` field. + Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + """ + type: String! + + """ + The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + """ + value: String! +} + +""" +A monetary value with currency. +""" +type MoneyV2 { + """ + Decimal money amount. + """ + amount: Decimal! + + """ + Currency of the money. + """ + currencyCode: CurrencyCode! +} + +""" +The root mutation for the API. +""" +type MutationRoot { + """ + Handles the Function result. + """ + handleResult( + """ + The result of the Function. + """ + result: FunctionResult! + ): Void! @deprecated(reason: "Use the target-specific field instead.") + + """ + Handles the Function result for the purchase.product-discount.run target. + """ + run( + """ + The result of the Function. + """ + result: FunctionRunResult! + ): Void! +} + +""" +A percentage value. +""" +input Percentage { + """ + The percentage value. + + The value is validated against: >= 0 and <= 100. + """ + value: Decimal! +} + +""" +Represents a product. +""" +type Product implements HasMetafields { + """ + A unique human-friendly string of the product's title. + """ + handle: Handle! + + """ + Whether the product has any of the given tags. + """ + hasAnyTag( + """ + The tags to check. + """ + tags: [String!]! = [] + ): Boolean! + + """ + Whether the product has the given tags. + """ + hasTags( + """ + The tags to check. + """ + tags: [String!]! = [] + ): [HasTagResponse!]! + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Whether the product is in any of the given collections. + """ + inAnyCollection( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): Boolean! + + """ + Whether the product is in the given collections. + """ + inCollections( + """ + The IDs of the collections to check. + """ + ids: [ID!]! = [] + ): [CollectionMembership!]! + + """ + Whether the product is a gift card. + """ + isGiftCard: Boolean! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product type specified by the merchant. + """ + productType: String + + """ + The localized title of the product in the customer’s locale. + """ + title: String! + + """ + The name of the product's vendor. + """ + vendor: String +} + +""" +Represents a product variant. +""" +type ProductVariant implements HasMetafields { + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The product that this variant belongs to. + """ + product: Product! + + """ + Whether the merchandise requires shipping. + """ + requiresShipping: Boolean! + + """ + An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + """ + sku: String + + """ + The localized title of the product variant in the customer’s locale. + """ + title: String + + """ + The weight of the product variant in the unit system specified with `weight_unit`. + """ + weight: Float + + """ + Unit of measurement for weight. + """ + weightUnit: WeightUnit! +} + +""" +A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an +optional quantity limit. +""" +input ProductVariantTarget { + """ + The ID of the targeted product variant. + """ + id: ID! + + """ + The maximum number of line item units to be discounted. + The default value is `null`, which represents the total quantity of the matching line items. + + The value is validated against: > 0. + """ + quantity: Int +} + +""" +Represents information about the buyer that is interacting with the cart. +""" +type PurchasingCompany { + """ + The company associated to the order or draft order. + """ + company: Company! + + """ + The company contact associated to the order or draft order. + """ + contact: CompanyContact + + """ + The company location associated to the order or draft order. + """ + location: CompanyLocation! +} + +""" +Represents how products and variants can be sold and purchased. +""" +type SellingPlan implements HasMetafields { + """ + The description of the selling plan. + """ + description: String + + """ + A globally-unique identifier. + """ + id: ID! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield + + """ + The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. + """ + name: String! + + """ + Whether purchasing the selling plan will result in multiple deliveries. + """ + recurringDeliveries: Boolean! +} + +""" +Represents an association between a variant and a selling plan. Selling plan +allocations describe the options offered for each variant, and the price of the +variant when purchased with a selling plan. +""" +type SellingPlanAllocation { + """ + A list of price adjustments, with a maximum of two. When there are two, the + first price adjustment goes into effect at the time of purchase, while the + second one starts after a certain number of orders. A price adjustment + represents how a selling plan affects pricing when a variant is purchased with + a selling plan. Prices display in the customer's currency if the shop is + configured for it. + """ + priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! + + """ + A representation of how products and variants can be sold and purchased. For + example, an individual selling plan could be '6 weeks of prepaid granola, + delivered weekly'. + """ + sellingPlan: SellingPlan! +} + +""" +The resulting prices for variants when they're purchased with a specific selling plan. +""" +type SellingPlanAllocationPriceAdjustment { + """ + The effective price for a single delivery. For example, for a prepaid + subscription plan that includes 6 deliveries at the price of $48.00, the per + delivery price is $8.00. + """ + perDeliveryPrice: MoneyV2! + + """ + The price of the variant when it's purchased with a selling plan For example, + for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, + where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. + """ + price: MoneyV2! +} + +""" +Information about the shop. +""" +type Shop implements HasMetafields { + """ + Information about the current time relative to the shop's timezone setting. + """ + localTime: LocalTime! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield +} + +""" +A target of a discount, which determines which cart line(s) the discount will affect. + +A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + +Multiple targets with the same type and ID are the same as a single target of that type and ID with their +quantities added together, or `null` if any of those targets have a quantity of `null`. + +See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. +""" +input Target @oneOf { + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. + """ + cartLine: CartLineTarget + + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an + optional quantity limit. + """ + productVariant: ProductVariantTarget +} + +""" +A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that +includes the time but not the date or timezone which is determined from context. +For example, "05:43:21". +""" +scalar TimeWithoutTimezone + +""" +The value of the discount. +""" +input Value @oneOf { + """ + A fixed amount value. + """ + fixedAmount: FixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +A void type that can be used to return a null value from a mutation. +""" +scalar Void + +""" +Units of measurement for weight. +""" +enum WeightUnit { + """ + Metric system unit of mass. + """ + GRAMS + + """ + 1 kilogram equals 1000 grams. + """ + KILOGRAMS + + """ + Imperial system unit of mass. + """ + OUNCES + + """ + 1 pound equals 16 ounces. + """ + POUNDS +} diff --git a/discounts/wasm/discounts/default/shopify.extension.toml.liquid b/discounts/wasm/discounts/default/shopify.extension.toml.liquid new file mode 100644 index 00000000..90f30061 --- /dev/null +++ b/discounts/wasm/discounts/default/shopify.extension.toml.liquid @@ -0,0 +1,37 @@ +api_version = "2025-01" + +[[extensions]] +name = "t:name" +handle = "{{handle}}" +type = "function" +{% if uid %}uid = "{{ uid }}"{% endif %} +description = "t:description" + + [[extensions.targeting]] + target = "purchase.discount.cart_run" + input_query = "src/run.graphql" + export = "cart_run" + + [[extensions.targeting]] + target = "purchase.discount.cart_fetch" + input_query = "src/run.graphql" + export = "cart_fetch" + + [[extensions.targeting]] + target = "purchase.discount.delivery_run" + input_query = "src/run.graphql" + export = "delivery_run" + + [[extensions.targeting]] + target = "purchase.discount.delivery_fetch" + input_query = "src/run.graphql" + export = "delivery_fetch" + + [extensions.build] + command = "echo 'build the wasm'" + path = "" + watch = [] + + [extensions.ui.paths] + create = "/" + details = "/" From 1e550478f7583bf431b2932525ae856119995bb6 Mon Sep 17 00:00:00 2001 From: Jonathan Hamel Date: Thu, 23 Jan 2025 10:32:09 -0500 Subject: [PATCH 2/5] implement all targets and read from the fetch function --- .../rust/discounts/default/schema.graphql | 1098 ++++++++++++++--- .../default/shopify.extension.toml.liquid | 10 +- .../default/src/fetch.graphql.liquid | 7 + .../discounts/default/src/run.graphql.liquid | 6 +- discounts/rust/discounts/default/src/run.rs | 254 +++- 5 files changed, 1170 insertions(+), 205 deletions(-) create mode 100644 discounts/rust/discounts/default/src/fetch.graphql.liquid diff --git a/discounts/rust/discounts/default/schema.graphql b/discounts/rust/discounts/default/schema.graphql index 3ca4e22b..dcef3af3 100644 --- a/discounts/rust/discounts/default/schema.graphql +++ b/discounts/rust/discounts/default/schema.graphql @@ -1,8 +1,20 @@ +# This file is auto-generated from the current state of the GraphQL API. Instead of editing this file, +# please edit the ruby definition files and run `bin/rails graphql:schema:dump` to regenerate the schema. +# +# If you're just looking to browse, you may find it friendlier to use the graphiql browser which is +# available in services-internal at https://app.shopify.com/services/internal/shops/14168/graphql. +# Check out the "Docs" tab in the top right. + schema { query: Input mutation: MutationRoot } +""" +Only allow the field to be queried when targeting one of the specified targets. +""" +directive @restrictTarget(only: [String!]!) on FIELD_DEFINITION + """ Scale the Functions resource limits based on the field's length. """ @@ -13,6 +25,16 @@ Requires that exactly one field must be supplied and that field must not be `nul """ directive @oneOf on INPUT_OBJECT +""" +A discount code that is associated with a discount candidate. +""" +input AssociatedDiscountCode { + """ + The discount code. + """ + code: String! +} + """ Represents a generic custom attribute, such as whether an order is a customer's first. """ @@ -56,12 +78,19 @@ type BuyerIdentity { The purchasing company associated with the cart. """ purchasingCompany: PurchasingCompany + + """ + Represents the [Shop User](https://help.shopify.com/en/manual/online-sales-channels/shop/sign-in-features) + corresponding to the customer within the shop, if the buyer is a Shop User. Can be used to request [Shop User + metafields](https://shopify.dev/docs/api/shop-user-custom-data). + """ + shopUser: ShopUser } """ A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. """ -type Cart { +type Cart implements HasMetafields { """ The attributes associated with the cart. Attributes are represented as key-value pairs. """ @@ -106,6 +135,21 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + Returns a metafield by namespace and key that belongs to the resource. + """ + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield } """ @@ -285,6 +329,27 @@ input CartLineTarget { quantity: Int } +""" +The operations that can be performed to apply discounts to the cart. +""" +input CartOperation @oneOf { + """ + A group of order discounts that share a selection strategy. + """ + addOrderDiscounts: OrderDiscounts + + """ + A group of product discounts that share a selection strategy. + """ + addProductDiscounts: ProductDiscounts + + """ + A list of valid discount codes that correspond to external discounts. This can + only be used by Functions with network access. + """ + addValidDiscountCodes: ValidDiscountCodes +} + """ Represents whether the product is a member of the given collection. """ @@ -422,6 +487,11 @@ type CompanyLocation implements HasMetafields { """ name: String! + """ + The number of orders placed at this company location. + """ + orderCount: Int! + """ The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company location was last modified. @@ -429,6 +499,26 @@ type CompanyLocation implements HasMetafields { updatedAt: DateTime! } +""" +The condition to apply the discount candidate. +""" +input Condition @oneOf { + """ + The condition for checking the minimum subtotal amount of the order. + """ + orderMinimumSubtotal: OrderMinimumSubtotal + + """ + The condition for checking the minimum quantity of a product. + """ + productMinimumQuantity: ProductMinimumQuantity + + """ + The condition for checking the minimum subtotal amount of the product. + """ + productMinimumSubtotal: ProductMinimumSubtotal +} + """ A country. """ @@ -1581,6 +1671,11 @@ enum CountryCode { """ UM + """ + Unknown country code. + """ + UNKNOWN__ + """ United States. """ @@ -1801,7 +1896,10 @@ enum CurrencyCode { """ Belarusian Ruble (BYR). """ - BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") + BYR + @deprecated( + reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead." + ) """ Belize Dollar (BZD). @@ -2326,7 +2424,10 @@ enum CurrencyCode { """ Sao Tome And Principe Dobra (STD). """ - STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") + STD + @deprecated( + reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead." + ) """ Sao Tome And Principe Dobra (STN). @@ -2421,7 +2522,10 @@ enum CurrencyCode { """ Venezuelan Bolivares (VEF). """ - VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") + VEF + @deprecated( + reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead." + ) """ Venezuelan Bolivares Soberanos (VES). @@ -2650,6 +2754,97 @@ type DeliverableCartLine { quantity: Int! } +""" +The delivery discount candidate to be applied. +""" +input DeliveryDiscountCandidate { + """ + The discount code associated with this discount candidate, for code-based discounts. + """ + associatedDiscountCode: AssociatedDiscountCode + + """ + The discount message. + """ + message: String + + """ + The targets of the delivery discount candidate. + """ + targets: [DeliveryDiscountCandidateTarget!]! + + """ + The value of the delivery discount candidate. + """ + value: DeliveryDiscountCandidateValue! +} + +""" +The target of the delivery discount candidate. +""" +input DeliveryDiscountCandidateTarget @oneOf { + """ + The target delivery group. + """ + deliveryGroup: DeliveryGroupTarget + + """ + The target delivery option. + """ + deliveryOption: DeliveryOptionTarget +} + +""" +The delivery discount candidate value. +""" +input DeliveryDiscountCandidateValue @oneOf { + """ + A fixed amount value. + """ + fixedAmount: FixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +The strategy that's applied to the list of delivery discount candidates. +""" +enum DeliveryDiscountSelectionStrategy { + """ + Apply all delivery discount candidates with conditions that are satisfied. This does not override + discount combination or stacking rules. + """ + ALL +} + +""" +A group of delivery discounts that share a selection strategy. +""" +input DeliveryDiscounts { + """ + The list of delivery discount candidates to be applied. + """ + candidates: [DeliveryDiscountCandidate!]! + + """ + The strategy that's applied to the list of discounts. + """ + selectionStrategy: DeliveryDiscountSelectionStrategy! +} + +""" +The target delivery group. +""" +input DeliveryGroupTarget { + """ + The ID of the target delivery group. + """ + id: ID! +} + """ List of different delivery method types. """ @@ -2686,51 +2881,67 @@ enum DeliveryMethod { } """ -The discount to be applied. +The operations that can be performed to apply discounts to the delivery lines. """ -input Discount { +input DeliveryOperation @oneOf { """ - The discount message. + A group of delivery discounts that share a selection strategy. """ - message: String + addDeliveryDiscounts: DeliveryDiscounts """ - The targets of the discount. - - This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + A list of valid discount codes that correspond to external discounts. This can + only be used by Functions with network access. """ - targets: [Target!]! + addValidDiscountCodes: ValidDiscountCodes +} +""" +The target delivery option. +""" +input DeliveryOptionTarget { """ - The value of the discount. + The handle of the target delivery option. """ - value: Value! + handle: Handle! } """ -The strategy that's applied to the list of discounts. +The [discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) +that's used to control how discounts can be combined. """ -enum DiscountApplicationStrategy { +enum DiscountClass { """ - Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. + The discount is combined with an + [order discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) + class. """ - ALL + ORDER """ - Only apply the first discount with conditions that are satisfied. + The discount is combined with a + [product discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) + class. """ - FIRST + PRODUCT """ - Only apply the discount that offers the maximum reduction. + The discount is combined with a + [shipping discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) + class. """ - MAXIMUM + SHIPPING } """ A discount wrapper node. """ type DiscountNode implements HasMetafields { + """ + The discount classes supported by the discount node. + """ + discountClasses: [DiscountClass!]! + """ Returns a metafield by namespace and key that belongs to the resource. """ @@ -2757,44 +2968,104 @@ input FixedAmount { The amount must be greater than or equal to 0. """ amount: Decimal! +} +""" +The cart.fetch target result. Refer to [network access] +(https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. +""" +input FunctionCartFetchResult { """ - Whether to apply the value to each entitled item. + The http request. + """ + request: HttpRequest +} - The default value is `false`, which causes the value to be applied once across the entitled items. - When the value is `true`, the value will be applied to each of the entitled items. +""" +The cart.run target result. +""" +input FunctionCartRunResult { + """ + The list of operations to apply discounts to the cart. + """ + operations: [CartOperation!]! +} + +""" +The delivery.fetch target result. Refer to +[network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. +""" +input FunctionDeliveryFetchResult { + """ + The http request. """ - appliesToEachItem: Boolean + request: HttpRequest } """ -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +The delivery.run target result. """ -input FunctionResult { +input FunctionDeliveryRunResult { + """ + The list of operations to apply discounts to the delivery lines. + """ + operations: [DeliveryOperation!]! +} + +""" +Represents a gate configuration. +""" +type GateConfiguration implements HasMetafields { + """ + An optional string identifier. + """ + appId: String + + """ + A non-unique string used to group gate configurations. + """ + handle: Handle + """ - The strategy to apply the list of discounts. + The ID of the gate configuration. """ - discountApplicationStrategy: DiscountApplicationStrategy! + id: ID! """ - The list of discounts to be applied. + Returns a metafield by namespace and key that belongs to the resource. """ - discounts: [Discount!]! + metafield( + """ + The key for the metafield. + """ + key: String! + + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield } """ -The run target result. +Represents a connection from a subject to a gate configuration. """ -input FunctionRunResult { +type GateSubject { """ - The strategy to apply the list of discounts. + The bound gate configuration. """ - discountApplicationStrategy: DiscountApplicationStrategy! + configuration( + """ + The appId of the gate configurations to search for. + """ + appId: String + @deprecated(reason: "Use GateSubject.handle to filter gates instead.") + ): GateConfiguration! """ - The list of discounts to be applied. + The ID of the gate subject. """ - discounts: [Discount!]! + id: ID! } """ @@ -2804,6 +3075,21 @@ Example value: `"10079785100"` """ scalar Handle +""" +Gate subjects associated to the specified resource. +""" +interface HasGates { + """ + Returns active gate subjects bound to the resource. + """ + gates( + """ + The handle of the gate configurations to search for. + """ + handle: Handle + ): [GateSubject!]! +} + """ Represents information about the metafields associated to the specified resource. """ @@ -2840,111 +3126,269 @@ type HasTagResponse { } """ -Represents a unique identifier, often used to refetch an object. -The ID type appears in a JSON response as a String, but it is not intended to be human-readable. - -Example value: `"gid://shopify/Product/10079785100"` +The attributes associated with an HTTP request. """ -scalar ID +input HttpRequest { + """ + The HTTP request body as a plain string. + Use this field when the body isn't in JSON format. + """ + body: String -""" -The input object for the function. -""" -type Input { """ - The cart. + The HTTP headers. """ - cart: Cart! + headers: [HttpRequestHeader!]! """ - The discount node executing the function. + The HTTP request body as a JSON object. + Use this field when the body's in JSON format, to reduce function instruction consumption + and to ensure the body's formatted in logs. + Don't use this field together with the `body` field. If both are provided, then the `body` field + will take precedence. + If this field is specified and no `Content-Type` header is included, then the header will + automatically be set to `application/json`. """ - discountNode: DiscountNode! + jsonBody: JSON """ - The localization of the Function execution context. + The HTTP method. """ - localization: Localization! + method: HttpRequestMethod! """ - The conversion rate between the shop's currency and the currency of the cart. + Policy attached to the HTTP request. """ - presentmentCurrencyRate: Decimal! + policy: HttpRequestPolicy! """ - Information about the shop. + The HTTP url (eg.: https://example.com). The scheme needs to be HTTPS. """ - shop: Shop! + url: URL! } """ -A [JSON](https://www.json.org/json-en.html) object. - -Example value: -`{ - "product": { - "id": "gid://shopify/Product/1346443542550", - "title": "White T-shirt", - "options": [{ - "name": "Size", - "values": ["M", "L"] - }] - } -}` +The attributes associated with an HTTP request header. """ -scalar JSON +input HttpRequestHeader { + """ + Header name. + """ + name: String! -""" -A language. -""" -type Language { """ - The ISO code. + Header value. """ - isoCode: LanguageCode! + value: String! } """ -Language codes supported by Shopify. +The HTTP request available methods. """ -enum LanguageCode { +enum HttpRequestMethod { """ - Afrikaans. + Http GET. """ - AF + GET """ - Akan. + Http POST. """ - AK + POST +} +""" +The attributes associated with an HTTP request policy. +""" +input HttpRequestPolicy { """ - Amharic. + Read timeout in milliseconds. """ - AM + readTimeoutMs: Int! +} +""" +The attributes associated with an HTTP response. +""" +type HttpResponse { """ - Arabic. + The HTTP response body as a plain string. + Use this field when the body is not in JSON format. """ - AR + body: String """ - Assamese. + An HTTP header. """ - AS + header( + """ + A case-insensitive header name. + """ + name: String! + ): HttpResponseHeader """ - Azerbaijani. + The HTTP headers. """ - AZ + headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") """ - Belarusian. + The HTTP response body parsed as JSON. + If the body is valid JSON, it will be parsed and returned as a JSON object. + If parsing fails, then raw body is returned as a string. + Use this field when you expect the response to be JSON, or when you're dealing + with mixed response types, meaning both JSON and non-JSON. + Using this field reduces function instruction consumption and ensures that the data is formatted in logs. + To prevent increasing the function target input size unnecessarily, avoid querying + both `body` and `jsonBody` simultaneously. """ - BE + jsonBody: JSON """ - Bulgarian. + The HTTP status code. + """ + status: Int! +} + +""" +The attributes associated with an HTTP response header. +""" +type HttpResponseHeader { + """ + Header name. + """ + name: String! + + """ + Header value. + """ + value: String! +} + +""" +Represents a unique identifier, often used to refetch an object. +The ID type appears in a JSON response as a String, but it is not intended to be human-readable. + +Example value: `"gid://shopify/Product/10079785100"` +""" +scalar ID + +""" +The input object for the Function. +""" +type Input { + """ + The cart. + """ + cart: Cart! + + """ + The discount node executing the Function. + """ + discountNode: DiscountNode! + + """ + Discount codes entered by the buyer as an array of strings, excluding gift cards. + Codes are not validated in any way other than gift card filtering. + """ + enteredDiscountCodes: [String!]! + @restrictTarget( + only: ["purchase.discount.cart_fetch", "purchase.discount.delivery_fetch"] + ) + + """ + The result of the fetch target. Refer to [network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) + for Shopify Functions. + """ + fetchResult: HttpResponse + @restrictTarget( + only: ["purchase.discount.cart_run", "purchase.discount.delivery_run"] + ) + + """ + The localization of the Function execution context. + """ + localization: Localization! + + """ + The conversion rate between the shop's currency and the currency of the cart. + """ + presentmentCurrencyRate: Decimal! + + """ + Information about the shop. + """ + shop: Shop! +} + +""" +A [JSON](https://www.json.org/json-en.html) object. + +Example value: +`{ + "product": { + "id": "gid://shopify/Product/1346443542550", + "title": "White T-shirt", + "options": [{ + "name": "Size", + "values": ["M", "L"] + }] + } +}` +""" +scalar JSON + +""" +A language. +""" +type Language { + """ + The ISO code. + """ + isoCode: LanguageCode! +} + +""" +Language codes supported by Shopify. +""" +enum LanguageCode { + """ + Afrikaans. + """ + AF + + """ + Akan. + """ + AK + + """ + Amharic. + """ + AM + + """ + Arabic. + """ + AR + + """ + Assamese. + """ + AS + + """ + Azerbaijani. + """ + AZ + + """ + Belarusian. + """ + BE + + """ + Bulgarian. """ BG @@ -3742,187 +4186,187 @@ Unique key identifying localized fields. """ enum LocalizedFieldKey { """ - Localized field key 'shipping_credential_br' for country BR. + Localized field key 'shipping_credential_br' for country Brazil. """ SHIPPING_CREDENTIAL_BR """ - Localized field key 'shipping_credential_cl' for country CL. + Localized field key 'shipping_credential_cl' for country Chile. """ SHIPPING_CREDENTIAL_CL """ - Localized field key 'shipping_credential_cn' for country CN. + Localized field key 'shipping_credential_cn' for country China. """ SHIPPING_CREDENTIAL_CN """ - Localized field key 'shipping_credential_co' for country CO. + Localized field key 'shipping_credential_co' for country Colombia. """ SHIPPING_CREDENTIAL_CO """ - Localized field key 'shipping_credential_cr' for country CR. + Localized field key 'shipping_credential_cr' for country Costa Rica. """ SHIPPING_CREDENTIAL_CR """ - Localized field key 'shipping_credential_ec' for country EC. + Localized field key 'shipping_credential_ec' for country Ecuador. """ SHIPPING_CREDENTIAL_EC """ - Localized field key 'shipping_credential_es' for country ES. + Localized field key 'shipping_credential_es' for country Spain. """ SHIPPING_CREDENTIAL_ES """ - Localized field key 'shipping_credential_gt' for country GT. + Localized field key 'shipping_credential_gt' for country Guatemala. """ SHIPPING_CREDENTIAL_GT """ - Localized field key 'shipping_credential_id' for country ID. + Localized field key 'shipping_credential_id' for country Indonesia. """ SHIPPING_CREDENTIAL_ID """ - Localized field key 'shipping_credential_kr' for country KR. + Localized field key 'shipping_credential_kr' for country South Korea. """ SHIPPING_CREDENTIAL_KR """ - Localized field key 'shipping_credential_mx' for country MX. + Localized field key 'shipping_credential_mx' for country Mexico. """ SHIPPING_CREDENTIAL_MX """ - Localized field key 'shipping_credential_my' for country MY. + Localized field key 'shipping_credential_my' for country Malaysia. """ SHIPPING_CREDENTIAL_MY """ - Localized field key 'shipping_credential_pe' for country PE. + Localized field key 'shipping_credential_pe' for country Peru. """ SHIPPING_CREDENTIAL_PE """ - Localized field key 'shipping_credential_pt' for country PT. + Localized field key 'shipping_credential_pt' for country Portugal. """ SHIPPING_CREDENTIAL_PT """ - Localized field key 'shipping_credential_py' for country PY. + Localized field key 'shipping_credential_py' for country Paraguay. """ SHIPPING_CREDENTIAL_PY """ - Localized field key 'shipping_credential_tr' for country TR. + Localized field key 'shipping_credential_tr' for country Turkey. """ SHIPPING_CREDENTIAL_TR """ - Localized field key 'shipping_credential_tw' for country TW. + Localized field key 'shipping_credential_tw' for country Taiwan. """ SHIPPING_CREDENTIAL_TW """ - Localized field key 'shipping_credential_type_co' for country CO. + Localized field key 'shipping_credential_type_co' for country Colombia. """ SHIPPING_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_br' for country BR. + Localized field key 'tax_credential_br' for country Brazil. """ TAX_CREDENTIAL_BR """ - Localized field key 'tax_credential_cl' for country CL. + Localized field key 'tax_credential_cl' for country Chile. """ TAX_CREDENTIAL_CL """ - Localized field key 'tax_credential_co' for country CO. + Localized field key 'tax_credential_co' for country Colombia. """ TAX_CREDENTIAL_CO """ - Localized field key 'tax_credential_cr' for country CR. + Localized field key 'tax_credential_cr' for country Costa Rica. """ TAX_CREDENTIAL_CR """ - Localized field key 'tax_credential_ec' for country EC. + Localized field key 'tax_credential_ec' for country Ecuador. """ TAX_CREDENTIAL_EC """ - Localized field key 'tax_credential_es' for country ES. + Localized field key 'tax_credential_es' for country Spain. """ TAX_CREDENTIAL_ES """ - Localized field key 'tax_credential_gt' for country GT. + Localized field key 'tax_credential_gt' for country Guatemala. """ TAX_CREDENTIAL_GT """ - Localized field key 'tax_credential_id' for country ID. + Localized field key 'tax_credential_id' for country Indonesia. """ TAX_CREDENTIAL_ID """ - Localized field key 'tax_credential_it' for country IT. + Localized field key 'tax_credential_it' for country Italy. """ TAX_CREDENTIAL_IT """ - Localized field key 'tax_credential_mx' for country MX. + Localized field key 'tax_credential_mx' for country Mexico. """ TAX_CREDENTIAL_MX """ - Localized field key 'tax_credential_my' for country MY. + Localized field key 'tax_credential_my' for country Malaysia. """ TAX_CREDENTIAL_MY """ - Localized field key 'tax_credential_pe' for country PE. + Localized field key 'tax_credential_pe' for country Peru. """ TAX_CREDENTIAL_PE """ - Localized field key 'tax_credential_pt' for country PT. + Localized field key 'tax_credential_pt' for country Portugal. """ TAX_CREDENTIAL_PT """ - Localized field key 'tax_credential_py' for country PY. + Localized field key 'tax_credential_py' for country Paraguay. """ TAX_CREDENTIAL_PY """ - Localized field key 'tax_credential_tr' for country TR. + Localized field key 'tax_credential_tr' for country Turkey. """ TAX_CREDENTIAL_TR """ - Localized field key 'tax_credential_type_co' for country CO. + Localized field key 'tax_credential_type_co' for country Colombia. """ TAX_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_type_mx' for country MX. + Localized field key 'tax_credential_type_mx' for country Mexico. """ TAX_CREDENTIAL_TYPE_MX """ - Localized field key 'tax_credential_use_mx' for country MX. + Localized field key 'tax_credential_use_mx' for country Mexico. """ TAX_CREDENTIAL_USE_MX """ - Localized field key 'tax_email_it' for country IT. + Localized field key 'tax_email_it' for country Italy. """ TAX_EMAIL_IT } @@ -4021,6 +4465,11 @@ type Market implements HasMetafields { """ id: ID! + """ + The manager of the market, if the accessing app is the market’s manager. Otherwise, this will be null. + """ + manager: MarketManager + """ Returns a metafield by namespace and key that belongs to the resource. """ @@ -4042,6 +4491,17 @@ type Market implements HasMetafields { regions: [MarketRegion!]! } +""" +The entity that manages a particular market. +""" +type MarketManager { + """ + The identity of the manager. This can either be `merchant` if the market is + manually managed by the merchant or an ID of the app responsible for managing the market. + """ + identifier: String! +} + """ Represents a region. """ @@ -4118,26 +4578,169 @@ The root mutation for the API. """ type MutationRoot { """ - Handles the Function result. + Handles the Function result for the purchase.discount.cart_fetch target. + """ + cartFetch( + """ + The result of the Function. + """ + result: FunctionCartFetchResult! + ): Void! + + """ + Handles the Function result for the purchase.discount.cart_run target. + """ + cartRun( + """ + The result of the Function. + """ + result: FunctionCartRunResult! + ): Void! + + """ + Handles the Function result for the purchase.discount.delivery_fetch target. """ - handleResult( + deliveryFetch( """ The result of the Function. """ - result: FunctionResult! - ): Void! @deprecated(reason: "Use the target-specific field instead.") + result: FunctionDeliveryFetchResult! + ): Void! """ - Handles the Function result for the purchase.product-discount.run target. + Handles the Function result for the purchase.discount.delivery_run target. """ - run( + deliveryRun( """ The result of the Function. """ - result: FunctionRunResult! + result: FunctionDeliveryRunResult! ): Void! } +""" +The order discount candidate to be applied. +""" +input OrderDiscountCandidate { + """ + The discount code associated with this discount candidate, for code-based discounts. + """ + associatedDiscountCode: AssociatedDiscountCode + + """ + The conditions that must be satisfied to apply the order discount candidate. + """ + conditions: [Condition!] + + """ + The discount message. + """ + message: String + + """ + The targets of the order discount candidate. + + The value is validated against: targets should contain only one type of `OrderDiscountCandidateTarget`. + Only a list that contains either a single `OrderSubtotalTarget` or one or more + `ProductVariantTarget`s is valid. + """ + targets: [OrderDiscountCandidateTarget!]! + + """ + The value of the order discount candidate. + """ + value: OrderDiscountCandidateValue! +} + +""" +A target of a order discount candidate. + +An `OrderDiscountCandidate` can either have a single `OrderSubtotalTarget`, or one or more `ProductVariantTarget`s. +""" +input OrderDiscountCandidateTarget @oneOf { + """ + If used, the discount targets the entire order subtotal after product discounts are applied. + """ + orderSubtotal: OrderSubtotalTarget + + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an + optional quantity limit. + """ + productVariant: ProductVariantTarget +} + +""" +The order discount candidate value. +""" +input OrderDiscountCandidateValue @oneOf { + """ + A fixed amount value. + """ + fixedAmount: FixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +The strategy that's applied to the list of order discount candidates. +""" +enum OrderDiscountSelectionStrategy { + """ + Only apply the first order discount candidate with conditions that are satisfied. + """ + FIRST + + """ + Only apply the order discount candidate that offers the maximum reduction. + """ + MAXIMUM +} + +""" +A group of order discounts that share a selection strategy. +""" +input OrderDiscounts { + """ + The list of order discount candidates to be applied. + """ + candidates: [OrderDiscountCandidate!]! + + """ + The strategy that's applied to the list of discounts. + """ + selectionStrategy: OrderDiscountSelectionStrategy! +} + +""" +The condition for checking the minimum subtotal amount of the order. +""" +input OrderMinimumSubtotal { + """ + Variant IDs with a merchandise line price that's excluded to calculate the minimum subtotal amount of the order. + """ + excludedVariantIds: [ID!]! + + """ + The minimum subtotal amount of the order. + """ + minimumAmount: Decimal! +} + +""" +If used, the discount targets the entire order subtotal after product discounts are applied. +""" +input OrderSubtotalTarget { + """ + The list of excluded product variant IDs. Cart lines for these product variants are excluded from the order + subtotal calculation when calculating the maximum value of the discount. + """ + excludedVariantIds: [ID!]! +} + """ A percentage value. """ @@ -4153,7 +4756,17 @@ input Percentage { """ Represents a product. """ -type Product implements HasMetafields { +type Product implements HasGates & HasMetafields { + """ + Returns active gate subjects bound to the resource. + """ + gates( + """ + The handle of the gate configurations to search for. + """ + handle: Handle + ): [GateSubject!]! + """ A unique human-friendly string of the product's title. """ @@ -4240,6 +4853,156 @@ type Product implements HasMetafields { vendor: String } +""" +The product discount candidate to be applied. +""" +input ProductDiscountCandidate { + """ + The discount code associated with this discount candidate, for code-based discounts. + """ + associatedDiscountCode: AssociatedDiscountCode + + """ + The discount message. + """ + message: String + + """ + The targets of the product discount candidate. + This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + """ + targets: [ProductDiscountCandidateTarget!]! + + """ + The value of the product discount candidate. + """ + value: ProductDiscountCandidateValue! +} + +""" +A product discount candidate fixed amount value. +""" +input ProductDiscountCandidateFixedAmount { + """ + The fixed amount value of the product discount candidate, in the currency of the cart. + + The amount must be greater than or equal to 0. + """ + amount: Decimal! + + """ + Whether to apply the value to each entitled item. + + The default value is `false`, which causes the value to be applied once across the entitled items. + When the value is `true`, the value will be applied to each of the entitled items. + """ + appliesToEachItem: Boolean = false +} + +""" +A target of a product discount candidate, which determines which cart line(s) the discount will affect. + +A `ProductDiscountCandidate` can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. + +Multiple targets with the same type and ID are the same as a single target of that type and ID with their +quantities added together, or `null` if any of those targets have a quantity of `null`. + +See the [Discounts API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. +""" +input ProductDiscountCandidateTarget @oneOf { + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. + """ + cartLine: CartLineTarget + + """ + A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an + optional quantity limit. + """ + productVariant: ProductVariantTarget +} + +""" +The value of the product discount candidate. +""" +input ProductDiscountCandidateValue @oneOf { + """ + A product discount candidate fixed amount value. + """ + fixedAmount: ProductDiscountCandidateFixedAmount + + """ + A percentage value. + """ + percentage: Percentage +} + +""" +The strategy that's applied to the list of product discount candidates. +""" +enum ProductDiscountSelectionStrategy { + """ + Apply all product discount candidates with conditions that are satisfied. This + does not override discount combination or stacking rules. + """ + ALL + + """ + Only apply the first product discount candidate with conditions that are satisfied. + """ + FIRST + + """ + Only apply the product discount candidate that offers the maximum reduction. + """ + MAXIMUM +} + +""" +A group of product discounts that share a selection strategy. +""" +input ProductDiscounts { + """ + The list of product discount candidates to be applied. + """ + candidates: [ProductDiscountCandidate!]! + + """ + The strategy that's applied to the list of product discount candidates. + """ + selectionStrategy: ProductDiscountSelectionStrategy! +} + +""" +The condition for checking the minimum quantity of a product. +""" +input ProductMinimumQuantity { + """ + Variant IDs with a merchandise line price that's included to calculate the minimum quantity of the product. + """ + ids: [ID!]! + + """ + The minimum quantity of a product. + """ + minimumQuantity: Int! +} + +""" +The condition for checking the minimum subtotal amount of the product. +""" +input ProductMinimumSubtotal { + """ + Variant IDs with a merchandise line price that's included to calculate the minimum subtotal amount of a product. + """ + ids: [ID!]! + + """ + The minimum subtotal amount of the product. + """ + minimumAmount: Decimal! +} + """ Represents a product variant. """ @@ -4443,26 +5206,23 @@ type Shop implements HasMetafields { } """ -A target of a discount, which determines which cart line(s) the discount will affect. - -A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. - -Multiple targets with the same type and ID are the same as a single target of that type and ID with their -quantities added together, or `null` if any of those targets have a quantity of `null`. - -See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. +Represents information about the buyer that is interacting with the cart. """ -input Target @oneOf { +type ShopUser implements HasMetafields { """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. + Returns a metafield by namespace and key that belongs to the resource. """ - cartLine: CartLineTarget + metafield( + """ + The key for the metafield. + """ + key: String! - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an - optional quantity limit. - """ - productVariant: ProductVariantTarget + """ + The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + """ + namespace: String + ): Metafield } """ @@ -4473,18 +5233,34 @@ For example, "05:43:21". scalar TimeWithoutTimezone """ -The value of the discount. +Represents an [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) and +[RFC 3987](https://datatracker.ietf.org/doc/html/rfc3987)-compliant URI string. + +For example, `"https://example.myshopify.com"` is a valid URL. It includes a scheme (`https`) and a host +(`example.myshopify.com`). +""" +scalar URL + """ -input Value @oneOf { +A discount code that corresponds to a valid external discount. +This can only be used by Functions with network access. +""" +input ValidDiscountCode { """ - A fixed amount value. + The discount code. """ - fixedAmount: FixedAmount + code: String! +} +""" +A list of valid discount codes that correspond to external discounts. This can +only be used by Functions with network access. +""" +input ValidDiscountCodes { """ - A percentage value. + The list of valid discount codes. """ - percentage: Percentage + codes: [ValidDiscountCode!]! } """ diff --git a/discounts/rust/discounts/default/shopify.extension.toml.liquid b/discounts/rust/discounts/default/shopify.extension.toml.liquid index 0c0f546e..26721382 100644 --- a/discounts/rust/discounts/default/shopify.extension.toml.liquid +++ b/discounts/rust/discounts/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "unstable" [[extensions]] name = "t:name" @@ -19,12 +19,12 @@ description = "t:description" [[extensions.targeting]] target = "purchase.discount.delivery_run" - input_query = "src/run.graphql" + input_query = "src/fetch.graphql" export = "delivery_run" [[extensions.targeting]] target = "purchase.discount.delivery_fetch" - input_query = "src/run.graphql" + input_query = "src/fetch.graphql" export = "delivery_fetch" [extensions.build] @@ -33,5 +33,5 @@ description = "t:description" watch = [ "src/**/*.rs" ] [extensions.ui.paths] - create = "/" - details = "/" + create = "/app/discounts/:functionId/new" + details = "/app/discounts/:functionId/:id" diff --git a/discounts/rust/discounts/default/src/fetch.graphql.liquid b/discounts/rust/discounts/default/src/fetch.graphql.liquid new file mode 100644 index 00000000..bc740d91 --- /dev/null +++ b/discounts/rust/discounts/default/src/fetch.graphql.liquid @@ -0,0 +1,7 @@ +query Input { + discountNode { + metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { + value + } + } +} diff --git a/discounts/rust/discounts/default/src/run.graphql.liquid b/discounts/rust/discounts/default/src/run.graphql.liquid index bc740d91..2387c479 100644 --- a/discounts/rust/discounts/default/src/run.graphql.liquid +++ b/discounts/rust/discounts/default/src/run.graphql.liquid @@ -1,7 +1,5 @@ query Input { - discountNode { - metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { - value - } + fetchResult { + body } } diff --git a/discounts/rust/discounts/default/src/run.rs b/discounts/rust/discounts/default/src/run.rs index 69b8cfde..3209c01f 100644 --- a/discounts/rust/discounts/default/src/run.rs +++ b/discounts/rust/discounts/default/src/run.rs @@ -1,61 +1,245 @@ +use serde::de::DeserializeOwned; + use shopify_function::prelude::*; use shopify_function::Result; -use serde::{Deserialize, Serialize}; +use cart_fetch::output::{ + FunctionCartFetchResult, HttpRequest as CartHttpRequest, + HttpRequestMethod as CartHttpRequestMethod, HttpRequestPolicy as CartHttpRequestPolicy, +}; +use cart_run::output::FunctionCartRunResult; +use delivery_fetch::output::{ + FunctionDeliveryFetchResult, HttpRequest as DeliveryHttpRequest, + HttpRequestMethod as DeliveryHttpRequestMethod, HttpRequestPolicy as DeliveryHttpRequestPolicy, +}; +use delivery_run::output::FunctionDeliveryRunResult; -#[derive(Serialize, Deserialize, Default, PartialEq)] -#[serde(rename_all(deserialize = "camelCase"))] -struct Configuration {} +type CartResponseData = cart_run::input::ResponseData; +type DeliveryResponseData = delivery_run::input::ResponseData; +type CartFetchResponseData = cart_fetch::input::ResponseData; -impl Configuration { - fn from_str(value: &str) -> Self { - serde_json::from_str(value).expect("Unable to parse configuration value from metafield") - } +#[shopify_function_target( + target = "cart_run", + query_path = "src/run.graphql", + schema_path = "schema.graphql" +)] +fn cart_run(input: CartResponseData) -> Result { + let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); + let body = fetch_result.body.as_ref().expect("Missing body"); + let result = metafield_to_config::(&body); + + Ok(result) } -#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] -fn run(input: input::ResponseData) -> Result { - let no_discount = output::FunctionRunResult { - discounts: vec![], - discount_application_strategy: output::DiscountApplicationStrategy::FIRST, - }; +#[shopify_function_target( + target = "delivery_run", + query_path = "src/run.graphql", + schema_path = "schema.graphql" +)] +fn delivery_run(input: DeliveryResponseData) -> Result { + let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); + let body = fetch_result.body.as_ref().expect("Missing body"); + let result = metafield_to_config::(&body); - let _config = match input.discount_node.metafield { - Some(input::InputDiscountNodeMetafield { value }) => Configuration::from_str(&value), - None => return Ok(no_discount), - }; + Ok(result) +} + +#[shopify_function_target( + target = "cart_fetch", + query_path = "src/fetch.graphql", + schema_path = "schema.graphql" +)] +fn cart_fetch(input: CartFetchResponseData) -> Result { + let metafield = input + .discount_node + .metafield + .expect("Missing required metafield configuration"); + + Ok(FunctionCartFetchResult { + request: Some(CartHttpRequest { + body: Some(metafield.value.clone()), + headers: vec![], + json_body: serde_json::from_str(&metafield.value)?, + method: CartHttpRequestMethod::POST, + policy: CartHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), + }) +} + +#[shopify_function_target( + target = "delivery_fetch", + query_path = "src/fetch.graphql", + schema_path = "schema.graphql" +)] +fn delivery_fetch(input: CartFetchResponseData) -> Result { + let metafield = input + .discount_node + .metafield + .expect("Missing required metafield configuration"); - Ok(output::FunctionRunResult { - discounts: vec![], - discount_application_strategy: output::DiscountApplicationStrategy::FIRST, + Ok(FunctionDeliveryFetchResult { + request: Some(DeliveryHttpRequest { + body: Some(metafield.value.clone()), + headers: vec![], + json_body: serde_json::from_str(&metafield.value)?, + method: DeliveryHttpRequestMethod::POST, + policy: DeliveryHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), }) } +fn metafield_to_config(value: &str) -> T { + serde_json::from_str(value).expect("Unable to parse configuration value from metafield") +} + #[cfg(test)] mod tests { use super::*; + use cart_run::output::{ + CartOperation, OrderDiscountSelectionStrategy, OrderDiscounts, + ProductDiscountSelectionStrategy, ProductDiscounts, + }; + use delivery_run::output::{ + DeliveryDiscountSelectionStrategy, DeliveryDiscounts, DeliveryOperation, + FunctionDeliveryRunResult, + }; + use serde_json::json; use shopify_function::{run_function_with_input, Result}; #[test] - fn test_result_contains_no_discounts() -> Result<()> { - use run::output::*; + fn test_cart_run() -> Result<()> { + let query_input_json = r#" + { + "fetchResult": { + "body": "{\"operations\":[{\"addOrderDiscounts\":{\"selectionStrategy\":\"FIRST\",\"candidates\":[]}},{\"addProductDiscounts\":{\"selectionStrategy\":\"FIRST\",\"candidates\":[]}}]}" + } + } + "#; + + let expected = FunctionCartRunResult { + operations: vec![ + CartOperation::AddOrderDiscounts(OrderDiscounts { + selection_strategy: OrderDiscountSelectionStrategy::FIRST, + candidates: vec![], + }), + CartOperation::AddProductDiscounts(ProductDiscounts { + selection_strategy: ProductDiscountSelectionStrategy::FIRST, + candidates: vec![], + }), + ], + }; + + assert_eq!( + run_function_with_input(cart_run, query_input_json)?, + expected + ); + Ok(()) + } + + #[test] + fn test_delivery_run() -> Result<()> { + let query_input_json = r#" + { + "fetchResult": { + "body": "{\"operations\":[{\"addDeliveryDiscounts\":{\"selectionStrategy\":\"ALL\",\"candidates\":[]}}]}" + } + } + "#; + + let expected = FunctionDeliveryRunResult { + operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { + selection_strategy: DeliveryDiscountSelectionStrategy::ALL, + candidates: vec![], + })], + }; + + assert_eq!( + run_function_with_input(delivery_run, query_input_json)?, + expected + ); + Ok(()) + } - let result = run_function_with_input( - run, - r#" + #[test] + fn test_cart_fetch() -> Result<()> { + let body = json!({ + "operations": [ { - "discountNode": { - "metafield": null - } + "addOrderDiscounts": {"selectionStrategy": "FIRST", "candidates": []}, + "addProductDiscounts": {"selectionStrategy": "FIRST", "candidates": []} } - "#, - )?; - let expected = FunctionRunResult { - discounts: vec![], - discount_application_strategy: DiscountApplicationStrategy::FIRST, + ] + }); + + let fetch_result = FunctionCartFetchResult { + request: Some(CartHttpRequest { + body: Some(body.to_string()), + headers: vec![], + json_body: Some(body.clone()), + method: CartHttpRequestMethod::POST, + policy: CartHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), }; - assert_eq!(result, expected); + let metafield = json!({ + "discountNode": { + "metafield": { + "value": body.to_string(), + } + } + }); + + assert_eq!( + run_function_with_input(cart_fetch, &metafield.to_string())?, + fetch_result + ); + Ok(()) + } + + #[test] + fn test_delivery_fetch() -> Result<()> { + let body = json!({ + "operations": [ + { + "addDeliveryDiscounts": {"selectionStrategy": "ALL", "candidates": []}, + } + ] + }); + + let fetch_result = FunctionDeliveryFetchResult { + request: Some(DeliveryHttpRequest { + body: Some(body.to_string()), + headers: vec![], + json_body: Some(body.clone()), + method: DeliveryHttpRequestMethod::POST, + policy: DeliveryHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), + }; + + let metafield = json!({ + "discountNode": { + "metafield": { + "value": body.to_string(), + } + } + }); + + assert_eq!( + run_function_with_input(delivery_fetch, &metafield.to_string())?, + fetch_result + ); Ok(()) } } From 199c691aa41f31e6b9ec9a49c7bef0a3ca8c1509 Mon Sep 17 00:00:00 2001 From: Jonathan Hamel Date: Thu, 23 Jan 2025 13:39:31 -0500 Subject: [PATCH 3/5] remove other targets for now --- .../javascript/discounts/default/.gitignore | 2 - .../default/locales/en.default.json.liquid | 4 - .../discounts/default/package.json.liquid | 30 - .../discounts/default/schema.graphql | 4518 ----------------- .../default/shopify.extension.toml.liquid | 36 - .../discounts/default/src/index.liquid | 1 - .../discounts/default/src/run.graphql.liquid | 7 - .../discounts/default/src/run.liquid | 51 - .../discounts/default/src/run.test.liquid | 44 - .../discounts/default/vite.config.js | 1 - discounts/rust/discounts/default/src/run.rs | 168 +- .../default/locales/en.default.json.liquid | 4 - .../wasm/discounts/default/run.graphql.liquid | 7 - .../wasm/discounts/default/schema.graphql | 4518 ----------------- .../default/shopify.extension.toml.liquid | 37 - 15 files changed, 103 insertions(+), 9325 deletions(-) delete mode 100644 discounts/javascript/discounts/default/.gitignore delete mode 100644 discounts/javascript/discounts/default/locales/en.default.json.liquid delete mode 100644 discounts/javascript/discounts/default/package.json.liquid delete mode 100644 discounts/javascript/discounts/default/schema.graphql delete mode 100644 discounts/javascript/discounts/default/shopify.extension.toml.liquid delete mode 100644 discounts/javascript/discounts/default/src/index.liquid delete mode 100644 discounts/javascript/discounts/default/src/run.graphql.liquid delete mode 100644 discounts/javascript/discounts/default/src/run.liquid delete mode 100644 discounts/javascript/discounts/default/src/run.test.liquid delete mode 100644 discounts/javascript/discounts/default/vite.config.js delete mode 100644 discounts/wasm/discounts/default/locales/en.default.json.liquid delete mode 100644 discounts/wasm/discounts/default/run.graphql.liquid delete mode 100644 discounts/wasm/discounts/default/schema.graphql delete mode 100644 discounts/wasm/discounts/default/shopify.extension.toml.liquid diff --git a/discounts/javascript/discounts/default/.gitignore b/discounts/javascript/discounts/default/.gitignore deleted file mode 100644 index 01c7cfd6..00000000 --- a/discounts/javascript/discounts/default/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -generated \ No newline at end of file diff --git a/discounts/javascript/discounts/default/locales/en.default.json.liquid b/discounts/javascript/discounts/default/locales/en.default.json.liquid deleted file mode 100644 index 333045ae..00000000 --- a/discounts/javascript/discounts/default/locales/en.default.json.liquid +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "{{name}}", - "description": "{{name}}" -} diff --git a/discounts/javascript/discounts/default/package.json.liquid b/discounts/javascript/discounts/default/package.json.liquid deleted file mode 100644 index b4a20dad..00000000 --- a/discounts/javascript/discounts/default/package.json.liquid +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "{{handle}}", - "version": "0.0.1", - "license": "UNLICENSED", - "scripts": { - "shopify": "npm exec -- shopify", - "typegen": "npm exec -- shopify app function typegen", - "build": "npm exec -- shopify app function build", - "preview": "npm exec -- shopify app function run", - "test": "vitest" - }, - "codegen": { - "schema": "schema.graphql", - "documents": "src/*.graphql", - "generates": { - "./generated/api.ts": { - "plugins": [ - "typescript", - "typescript-operations" - ] - } - }, - "config": { - "omitOperationSuffix": true - } - }, - "devDependencies": { - "vitest": "^0.29.8" - } -} diff --git a/discounts/javascript/discounts/default/schema.graphql b/discounts/javascript/discounts/default/schema.graphql deleted file mode 100644 index 3ca4e22b..00000000 --- a/discounts/javascript/discounts/default/schema.graphql +++ /dev/null @@ -1,4518 +0,0 @@ -schema { - query: Input - mutation: MutationRoot -} - -""" -Scale the Functions resource limits based on the field's length. -""" -directive @scaleLimits(rate: Float!) on FIELD_DEFINITION - -""" -Requires that exactly one field must be supplied and that field must not be `null`. -""" -directive @oneOf on INPUT_OBJECT - -""" -Represents a generic custom attribute, such as whether an order is a customer's first. -""" -type Attribute { - """ - The key or name of the attribute. For example, `"customersFirstOrder"`. - """ - key: String! - - """ - The value of the attribute. For example, `"true"`. - """ - value: String -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type BuyerIdentity { - """ - The customer associated with the cart. - """ - customer: Customer - - """ - The email address of the buyer that's interacting with the cart. - """ - email: String - - """ - Whether the buyer authenticated with a customer account. - """ - isAuthenticated: Boolean! - - """ - The phone number of the buyer that's interacting with the cart. - """ - phone: String - - """ - The purchasing company associated with the cart. - """ - purchasingCompany: PurchasingCompany -} - -""" -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. -""" -type Cart { - """ - The attributes associated with the cart. Attributes are represented as key-value pairs. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - Information about the buyer that is interacting with the cart. - """ - buyerIdentity: BuyerIdentity - - """ - The costs that the buyer will pay at checkout. - """ - cost: CartCost! - - """ - A list of lines containing information about the items that can be delivered. - """ - deliverableLines: [DeliverableCartLine!]! - - """ - The delivery groups available for the cart based on the buyer's shipping address. - """ - deliveryGroups: [CartDeliveryGroup!]! - - """ - A list of lines containing information about the items the customer intends to purchase. - """ - lines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The localized fields available for the cart. - """ - localizedFields( - """ - The keys of the localized fields to retrieve. - """ - keys: [LocalizedFieldKey!]! = [] - ): [LocalizedField!]! -} - -""" -The cost that the buyer will pay at checkout. -""" -type CartCost { - """ - The amount, before taxes and discounts, for the customer to pay. - """ - subtotalAmount: MoneyV2! - - """ - The total amount for the customer to pay. - """ - totalAmount: MoneyV2! - - """ - The duty amount for the customer to pay at checkout. - """ - totalDutyAmount: MoneyV2 - - """ - The tax amount for the customer to pay at checkout. - """ - totalTaxAmount: MoneyV2 -} - -""" -Information about the options available for one or more line items to be delivered to a specific address. -""" -type CartDeliveryGroup { - """ - A list of cart lines for the delivery group. - """ - cartLines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The destination address for the delivery group. - """ - deliveryAddress: MailingAddress - - """ - The delivery options available for the delivery group. - """ - deliveryOptions: [CartDeliveryOption!]! - - """ - Unique identifier for the delivery group. - """ - id: ID! - - """ - Information about the delivery option the buyer has selected. - """ - selectedDeliveryOption: CartDeliveryOption -} - -""" -Information about a delivery option. -""" -type CartDeliveryOption { - """ - The code of the delivery option. - """ - code: String - - """ - The cost for the delivery option. - """ - cost: MoneyV2! - - """ - The method for the delivery option. - """ - deliveryMethodType: DeliveryMethod! - - """ - The description of the delivery option. - """ - description: String - - """ - The unique identifier of the delivery option. - """ - handle: Handle! - - """ - The title of the delivery option. - """ - title: String -} - -""" -Represents information about the merchandise in the cart. -""" -type CartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The cost of the merchandise line that the buyer will pay at checkout. - """ - cost: CartLineCost! - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! - - """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. - """ - sellingPlanAllocation: SellingPlanAllocation -} - -""" -The cost of the merchandise line that the buyer will pay at checkout. -""" -type CartLineCost { - """ - The amount of the merchandise line. - """ - amountPerQuantity: MoneyV2! - - """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. - """ - compareAtAmountPerQuantity: MoneyV2 - - """ - The cost of the merchandise line before line-level discounts. - """ - subtotalAmount: MoneyV2! - - """ - The total cost of the merchandise line. - """ - totalAmount: MoneyV2! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. -""" -input CartLineTarget { - """ - The ID of the targeted cart line. - """ - id: ID! - - """ - The number of line items that are being discounted. - The default value is `null`, which represents the quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -Represents whether the product is a member of the given collection. -""" -type CollectionMembership { - """ - The ID of the collection. - """ - collectionId: ID! - - """ - Whether the product is a member of the collection. - """ - isMember: Boolean! -} - -""" -Represents information about a company which is also a customer of the shop. -""" -type Company implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's main point of contact. -""" -type CompanyContact { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was created in Shopify. - """ - createdAt: DateTime! - - """ - The ID of the company. - """ - id: ID! - - """ - The company contact's locale (language). - """ - locale: String - - """ - The company contact's job title. - """ - title: String - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's location. -""" -type CompanyLocation implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - The preferred locale of the company location. - """ - locale: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company location. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was last modified. - """ - updatedAt: DateTime! -} - -""" -A country. -""" -type Country { - """ - The ISO code of the country. - """ - isoCode: CountryCode! -} - -""" -The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. -If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision -of another country. For example, the territories associated with Spain are represented by the country code `ES`, -and the territories associated with the United States of America are represented by the country code `US`. -""" -enum CountryCode { - """ - Ascension Island. - """ - AC - - """ - Andorra. - """ - AD - - """ - United Arab Emirates. - """ - AE - - """ - Afghanistan. - """ - AF - - """ - Antigua & Barbuda. - """ - AG - - """ - Anguilla. - """ - AI - - """ - Albania. - """ - AL - - """ - Armenia. - """ - AM - - """ - Netherlands Antilles. - """ - AN - - """ - Angola. - """ - AO - - """ - Argentina. - """ - AR - - """ - Austria. - """ - AT - - """ - Australia. - """ - AU - - """ - Aruba. - """ - AW - - """ - Åland Islands. - """ - AX - - """ - Azerbaijan. - """ - AZ - - """ - Bosnia & Herzegovina. - """ - BA - - """ - Barbados. - """ - BB - - """ - Bangladesh. - """ - BD - - """ - Belgium. - """ - BE - - """ - Burkina Faso. - """ - BF - - """ - Bulgaria. - """ - BG - - """ - Bahrain. - """ - BH - - """ - Burundi. - """ - BI - - """ - Benin. - """ - BJ - - """ - St. Barthélemy. - """ - BL - - """ - Bermuda. - """ - BM - - """ - Brunei. - """ - BN - - """ - Bolivia. - """ - BO - - """ - Caribbean Netherlands. - """ - BQ - - """ - Brazil. - """ - BR - - """ - Bahamas. - """ - BS - - """ - Bhutan. - """ - BT - - """ - Bouvet Island. - """ - BV - - """ - Botswana. - """ - BW - - """ - Belarus. - """ - BY - - """ - Belize. - """ - BZ - - """ - Canada. - """ - CA - - """ - Cocos (Keeling) Islands. - """ - CC - - """ - Congo - Kinshasa. - """ - CD - - """ - Central African Republic. - """ - CF - - """ - Congo - Brazzaville. - """ - CG - - """ - Switzerland. - """ - CH - - """ - Côte d’Ivoire. - """ - CI - - """ - Cook Islands. - """ - CK - - """ - Chile. - """ - CL - - """ - Cameroon. - """ - CM - - """ - China. - """ - CN - - """ - Colombia. - """ - CO - - """ - Costa Rica. - """ - CR - - """ - Cuba. - """ - CU - - """ - Cape Verde. - """ - CV - - """ - Curaçao. - """ - CW - - """ - Christmas Island. - """ - CX - - """ - Cyprus. - """ - CY - - """ - Czechia. - """ - CZ - - """ - Germany. - """ - DE - - """ - Djibouti. - """ - DJ - - """ - Denmark. - """ - DK - - """ - Dominica. - """ - DM - - """ - Dominican Republic. - """ - DO - - """ - Algeria. - """ - DZ - - """ - Ecuador. - """ - EC - - """ - Estonia. - """ - EE - - """ - Egypt. - """ - EG - - """ - Western Sahara. - """ - EH - - """ - Eritrea. - """ - ER - - """ - Spain. - """ - ES - - """ - Ethiopia. - """ - ET - - """ - Finland. - """ - FI - - """ - Fiji. - """ - FJ - - """ - Falkland Islands. - """ - FK - - """ - Faroe Islands. - """ - FO - - """ - France. - """ - FR - - """ - Gabon. - """ - GA - - """ - United Kingdom. - """ - GB - - """ - Grenada. - """ - GD - - """ - Georgia. - """ - GE - - """ - French Guiana. - """ - GF - - """ - Guernsey. - """ - GG - - """ - Ghana. - """ - GH - - """ - Gibraltar. - """ - GI - - """ - Greenland. - """ - GL - - """ - Gambia. - """ - GM - - """ - Guinea. - """ - GN - - """ - Guadeloupe. - """ - GP - - """ - Equatorial Guinea. - """ - GQ - - """ - Greece. - """ - GR - - """ - South Georgia & South Sandwich Islands. - """ - GS - - """ - Guatemala. - """ - GT - - """ - Guinea-Bissau. - """ - GW - - """ - Guyana. - """ - GY - - """ - Hong Kong SAR. - """ - HK - - """ - Heard & McDonald Islands. - """ - HM - - """ - Honduras. - """ - HN - - """ - Croatia. - """ - HR - - """ - Haiti. - """ - HT - - """ - Hungary. - """ - HU - - """ - Indonesia. - """ - ID - - """ - Ireland. - """ - IE - - """ - Israel. - """ - IL - - """ - Isle of Man. - """ - IM - - """ - India. - """ - IN - - """ - British Indian Ocean Territory. - """ - IO - - """ - Iraq. - """ - IQ - - """ - Iran. - """ - IR - - """ - Iceland. - """ - IS - - """ - Italy. - """ - IT - - """ - Jersey. - """ - JE - - """ - Jamaica. - """ - JM - - """ - Jordan. - """ - JO - - """ - Japan. - """ - JP - - """ - Kenya. - """ - KE - - """ - Kyrgyzstan. - """ - KG - - """ - Cambodia. - """ - KH - - """ - Kiribati. - """ - KI - - """ - Comoros. - """ - KM - - """ - St. Kitts & Nevis. - """ - KN - - """ - North Korea. - """ - KP - - """ - South Korea. - """ - KR - - """ - Kuwait. - """ - KW - - """ - Cayman Islands. - """ - KY - - """ - Kazakhstan. - """ - KZ - - """ - Laos. - """ - LA - - """ - Lebanon. - """ - LB - - """ - St. Lucia. - """ - LC - - """ - Liechtenstein. - """ - LI - - """ - Sri Lanka. - """ - LK - - """ - Liberia. - """ - LR - - """ - Lesotho. - """ - LS - - """ - Lithuania. - """ - LT - - """ - Luxembourg. - """ - LU - - """ - Latvia. - """ - LV - - """ - Libya. - """ - LY - - """ - Morocco. - """ - MA - - """ - Monaco. - """ - MC - - """ - Moldova. - """ - MD - - """ - Montenegro. - """ - ME - - """ - St. Martin. - """ - MF - - """ - Madagascar. - """ - MG - - """ - North Macedonia. - """ - MK - - """ - Mali. - """ - ML - - """ - Myanmar (Burma). - """ - MM - - """ - Mongolia. - """ - MN - - """ - Macao SAR. - """ - MO - - """ - Martinique. - """ - MQ - - """ - Mauritania. - """ - MR - - """ - Montserrat. - """ - MS - - """ - Malta. - """ - MT - - """ - Mauritius. - """ - MU - - """ - Maldives. - """ - MV - - """ - Malawi. - """ - MW - - """ - Mexico. - """ - MX - - """ - Malaysia. - """ - MY - - """ - Mozambique. - """ - MZ - - """ - Namibia. - """ - NA - - """ - New Caledonia. - """ - NC - - """ - Niger. - """ - NE - - """ - Norfolk Island. - """ - NF - - """ - Nigeria. - """ - NG - - """ - Nicaragua. - """ - NI - - """ - Netherlands. - """ - NL - - """ - Norway. - """ - NO - - """ - Nepal. - """ - NP - - """ - Nauru. - """ - NR - - """ - Niue. - """ - NU - - """ - New Zealand. - """ - NZ - - """ - Oman. - """ - OM - - """ - Panama. - """ - PA - - """ - Peru. - """ - PE - - """ - French Polynesia. - """ - PF - - """ - Papua New Guinea. - """ - PG - - """ - Philippines. - """ - PH - - """ - Pakistan. - """ - PK - - """ - Poland. - """ - PL - - """ - St. Pierre & Miquelon. - """ - PM - - """ - Pitcairn Islands. - """ - PN - - """ - Palestinian Territories. - """ - PS - - """ - Portugal. - """ - PT - - """ - Paraguay. - """ - PY - - """ - Qatar. - """ - QA - - """ - Réunion. - """ - RE - - """ - Romania. - """ - RO - - """ - Serbia. - """ - RS - - """ - Russia. - """ - RU - - """ - Rwanda. - """ - RW - - """ - Saudi Arabia. - """ - SA - - """ - Solomon Islands. - """ - SB - - """ - Seychelles. - """ - SC - - """ - Sudan. - """ - SD - - """ - Sweden. - """ - SE - - """ - Singapore. - """ - SG - - """ - St. Helena. - """ - SH - - """ - Slovenia. - """ - SI - - """ - Svalbard & Jan Mayen. - """ - SJ - - """ - Slovakia. - """ - SK - - """ - Sierra Leone. - """ - SL - - """ - San Marino. - """ - SM - - """ - Senegal. - """ - SN - - """ - Somalia. - """ - SO - - """ - Suriname. - """ - SR - - """ - South Sudan. - """ - SS - - """ - São Tomé & Príncipe. - """ - ST - - """ - El Salvador. - """ - SV - - """ - Sint Maarten. - """ - SX - - """ - Syria. - """ - SY - - """ - Eswatini. - """ - SZ - - """ - Tristan da Cunha. - """ - TA - - """ - Turks & Caicos Islands. - """ - TC - - """ - Chad. - """ - TD - - """ - French Southern Territories. - """ - TF - - """ - Togo. - """ - TG - - """ - Thailand. - """ - TH - - """ - Tajikistan. - """ - TJ - - """ - Tokelau. - """ - TK - - """ - Timor-Leste. - """ - TL - - """ - Turkmenistan. - """ - TM - - """ - Tunisia. - """ - TN - - """ - Tonga. - """ - TO - - """ - Türkiye. - """ - TR - - """ - Trinidad & Tobago. - """ - TT - - """ - Tuvalu. - """ - TV - - """ - Taiwan. - """ - TW - - """ - Tanzania. - """ - TZ - - """ - Ukraine. - """ - UA - - """ - Uganda. - """ - UG - - """ - U.S. Outlying Islands. - """ - UM - - """ - United States. - """ - US - - """ - Uruguay. - """ - UY - - """ - Uzbekistan. - """ - UZ - - """ - Vatican City. - """ - VA - - """ - St. Vincent & Grenadines. - """ - VC - - """ - Venezuela. - """ - VE - - """ - British Virgin Islands. - """ - VG - - """ - Vietnam. - """ - VN - - """ - Vanuatu. - """ - VU - - """ - Wallis & Futuna. - """ - WF - - """ - Samoa. - """ - WS - - """ - Kosovo. - """ - XK - - """ - Yemen. - """ - YE - - """ - Mayotte. - """ - YT - - """ - South Africa. - """ - ZA - - """ - Zambia. - """ - ZM - - """ - Zimbabwe. - """ - ZW - - """ - Unknown Region. - """ - ZZ -} - -""" -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. -""" -enum CurrencyCode { - """ - United Arab Emirates Dirham (AED). - """ - AED - - """ - Afghan Afghani (AFN). - """ - AFN - - """ - Albanian Lek (ALL). - """ - ALL - - """ - Armenian Dram (AMD). - """ - AMD - - """ - Netherlands Antillean Guilder. - """ - ANG - - """ - Angolan Kwanza (AOA). - """ - AOA - - """ - Argentine Pesos (ARS). - """ - ARS - - """ - Australian Dollars (AUD). - """ - AUD - - """ - Aruban Florin (AWG). - """ - AWG - - """ - Azerbaijani Manat (AZN). - """ - AZN - - """ - Bosnia and Herzegovina Convertible Mark (BAM). - """ - BAM - - """ - Barbadian Dollar (BBD). - """ - BBD - - """ - Bangladesh Taka (BDT). - """ - BDT - - """ - Bulgarian Lev (BGN). - """ - BGN - - """ - Bahraini Dinar (BHD). - """ - BHD - - """ - Burundian Franc (BIF). - """ - BIF - - """ - Bermudian Dollar (BMD). - """ - BMD - - """ - Brunei Dollar (BND). - """ - BND - - """ - Bolivian Boliviano (BOB). - """ - BOB - - """ - Brazilian Real (BRL). - """ - BRL - - """ - Bahamian Dollar (BSD). - """ - BSD - - """ - Bhutanese Ngultrum (BTN). - """ - BTN - - """ - Botswana Pula (BWP). - """ - BWP - - """ - Belarusian Ruble (BYN). - """ - BYN - - """ - Belarusian Ruble (BYR). - """ - BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") - - """ - Belize Dollar (BZD). - """ - BZD - - """ - Canadian Dollars (CAD). - """ - CAD - - """ - Congolese franc (CDF). - """ - CDF - - """ - Swiss Francs (CHF). - """ - CHF - - """ - Chilean Peso (CLP). - """ - CLP - - """ - Chinese Yuan Renminbi (CNY). - """ - CNY - - """ - Colombian Peso (COP). - """ - COP - - """ - Costa Rican Colones (CRC). - """ - CRC - - """ - Cape Verdean escudo (CVE). - """ - CVE - - """ - Czech Koruny (CZK). - """ - CZK - - """ - Djiboutian Franc (DJF). - """ - DJF - - """ - Danish Kroner (DKK). - """ - DKK - - """ - Dominican Peso (DOP). - """ - DOP - - """ - Algerian Dinar (DZD). - """ - DZD - - """ - Egyptian Pound (EGP). - """ - EGP - - """ - Eritrean Nakfa (ERN). - """ - ERN - - """ - Ethiopian Birr (ETB). - """ - ETB - - """ - Euro (EUR). - """ - EUR - - """ - Fijian Dollars (FJD). - """ - FJD - - """ - Falkland Islands Pounds (FKP). - """ - FKP - - """ - United Kingdom Pounds (GBP). - """ - GBP - - """ - Georgian Lari (GEL). - """ - GEL - - """ - Ghanaian Cedi (GHS). - """ - GHS - - """ - Gibraltar Pounds (GIP). - """ - GIP - - """ - Gambian Dalasi (GMD). - """ - GMD - - """ - Guinean Franc (GNF). - """ - GNF - - """ - Guatemalan Quetzal (GTQ). - """ - GTQ - - """ - Guyanese Dollar (GYD). - """ - GYD - - """ - Hong Kong Dollars (HKD). - """ - HKD - - """ - Honduran Lempira (HNL). - """ - HNL - - """ - Croatian Kuna (HRK). - """ - HRK - - """ - Haitian Gourde (HTG). - """ - HTG - - """ - Hungarian Forint (HUF). - """ - HUF - - """ - Indonesian Rupiah (IDR). - """ - IDR - - """ - Israeli New Shekel (NIS). - """ - ILS - - """ - Indian Rupees (INR). - """ - INR - - """ - Iraqi Dinar (IQD). - """ - IQD - - """ - Iranian Rial (IRR). - """ - IRR - - """ - Icelandic Kronur (ISK). - """ - ISK - - """ - Jersey Pound. - """ - JEP - - """ - Jamaican Dollars (JMD). - """ - JMD - - """ - Jordanian Dinar (JOD). - """ - JOD - - """ - Japanese Yen (JPY). - """ - JPY - - """ - Kenyan Shilling (KES). - """ - KES - - """ - Kyrgyzstani Som (KGS). - """ - KGS - - """ - Cambodian Riel. - """ - KHR - - """ - Kiribati Dollar (KID). - """ - KID - - """ - Comorian Franc (KMF). - """ - KMF - - """ - South Korean Won (KRW). - """ - KRW - - """ - Kuwaiti Dinar (KWD). - """ - KWD - - """ - Cayman Dollars (KYD). - """ - KYD - - """ - Kazakhstani Tenge (KZT). - """ - KZT - - """ - Laotian Kip (LAK). - """ - LAK - - """ - Lebanese Pounds (LBP). - """ - LBP - - """ - Sri Lankan Rupees (LKR). - """ - LKR - - """ - Liberian Dollar (LRD). - """ - LRD - - """ - Lesotho Loti (LSL). - """ - LSL - - """ - Lithuanian Litai (LTL). - """ - LTL - - """ - Latvian Lati (LVL). - """ - LVL - - """ - Libyan Dinar (LYD). - """ - LYD - - """ - Moroccan Dirham. - """ - MAD - - """ - Moldovan Leu (MDL). - """ - MDL - - """ - Malagasy Ariary (MGA). - """ - MGA - - """ - Macedonia Denar (MKD). - """ - MKD - - """ - Burmese Kyat (MMK). - """ - MMK - - """ - Mongolian Tugrik. - """ - MNT - - """ - Macanese Pataca (MOP). - """ - MOP - - """ - Mauritanian Ouguiya (MRU). - """ - MRU - - """ - Mauritian Rupee (MUR). - """ - MUR - - """ - Maldivian Rufiyaa (MVR). - """ - MVR - - """ - Malawian Kwacha (MWK). - """ - MWK - - """ - Mexican Pesos (MXN). - """ - MXN - - """ - Malaysian Ringgits (MYR). - """ - MYR - - """ - Mozambican Metical. - """ - MZN - - """ - Namibian Dollar. - """ - NAD - - """ - Nigerian Naira (NGN). - """ - NGN - - """ - Nicaraguan Córdoba (NIO). - """ - NIO - - """ - Norwegian Kroner (NOK). - """ - NOK - - """ - Nepalese Rupee (NPR). - """ - NPR - - """ - New Zealand Dollars (NZD). - """ - NZD - - """ - Omani Rial (OMR). - """ - OMR - - """ - Panamian Balboa (PAB). - """ - PAB - - """ - Peruvian Nuevo Sol (PEN). - """ - PEN - - """ - Papua New Guinean Kina (PGK). - """ - PGK - - """ - Philippine Peso (PHP). - """ - PHP - - """ - Pakistani Rupee (PKR). - """ - PKR - - """ - Polish Zlotych (PLN). - """ - PLN - - """ - Paraguayan Guarani (PYG). - """ - PYG - - """ - Qatari Rial (QAR). - """ - QAR - - """ - Romanian Lei (RON). - """ - RON - - """ - Serbian dinar (RSD). - """ - RSD - - """ - Russian Rubles (RUB). - """ - RUB - - """ - Rwandan Franc (RWF). - """ - RWF - - """ - Saudi Riyal (SAR). - """ - SAR - - """ - Solomon Islands Dollar (SBD). - """ - SBD - - """ - Seychellois Rupee (SCR). - """ - SCR - - """ - Sudanese Pound (SDG). - """ - SDG - - """ - Swedish Kronor (SEK). - """ - SEK - - """ - Singapore Dollars (SGD). - """ - SGD - - """ - Saint Helena Pounds (SHP). - """ - SHP - - """ - Sierra Leonean Leone (SLL). - """ - SLL - - """ - Somali Shilling (SOS). - """ - SOS - - """ - Surinamese Dollar (SRD). - """ - SRD - - """ - South Sudanese Pound (SSP). - """ - SSP - - """ - Sao Tome And Principe Dobra (STD). - """ - STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") - - """ - Sao Tome And Principe Dobra (STN). - """ - STN - - """ - Syrian Pound (SYP). - """ - SYP - - """ - Swazi Lilangeni (SZL). - """ - SZL - - """ - Thai baht (THB). - """ - THB - - """ - Tajikistani Somoni (TJS). - """ - TJS - - """ - Turkmenistani Manat (TMT). - """ - TMT - - """ - Tunisian Dinar (TND). - """ - TND - - """ - Tongan Pa'anga (TOP). - """ - TOP - - """ - Turkish Lira (TRY). - """ - TRY - - """ - Trinidad and Tobago Dollars (TTD). - """ - TTD - - """ - Taiwan Dollars (TWD). - """ - TWD - - """ - Tanzanian Shilling (TZS). - """ - TZS - - """ - Ukrainian Hryvnia (UAH). - """ - UAH - - """ - Ugandan Shilling (UGX). - """ - UGX - - """ - United States Dollars (USD). - """ - USD - - """ - Uruguayan Pesos (UYU). - """ - UYU - - """ - Uzbekistan som (UZS). - """ - UZS - - """ - Venezuelan Bolivares (VED). - """ - VED - - """ - Venezuelan Bolivares (VEF). - """ - VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") - - """ - Venezuelan Bolivares Soberanos (VES). - """ - VES - - """ - Vietnamese đồng (VND). - """ - VND - - """ - Vanuatu Vatu (VUV). - """ - VUV - - """ - Samoan Tala (WST). - """ - WST - - """ - Central African CFA Franc (XAF). - """ - XAF - - """ - East Caribbean Dollar (XCD). - """ - XCD - - """ - West African CFA franc (XOF). - """ - XOF - - """ - CFP Franc (XPF). - """ - XPF - - """ - Unrecognized currency. - """ - XXX - - """ - Yemeni Rial (YER). - """ - YER - - """ - South African Rand (ZAR). - """ - ZAR - - """ - Zambian Kwacha (ZMW). - """ - ZMW -} - -""" -A custom product. -""" -type CustomProduct { - """ - Whether the merchandise is a gift card. - """ - isGiftCard: Boolean! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents a customer with the shop. -""" -type Customer implements HasMetafields { - """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. - """ - amountSpent: MoneyV2! - - """ - The customer’s name, email or phone number. - """ - displayName: String! - - """ - The customer’s email address. - """ - email: String - - """ - The customer's first name. - """ - firstName: String - - """ - Whether the customer has any of the given tags. - """ - hasAnyTag( - """ - The tags to search for. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the customer has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A unique identifier for the customer. - """ - id: ID! - - """ - The customer's last name. - """ - lastName: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The number of orders made by the customer. - """ - numberOfOrders: Int! -} - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. -For example, September 7, 2019 is represented as `"2019-07-16"`. -""" -scalar Date - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. -For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is -represented as `"2019-09-07T15:50:00Z`". -""" -scalar DateTime - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the date and time but not the timezone which is determined from context. - -For example, "2018-01-01T00:00:00". -""" -scalar DateTimeWithoutTimezone - -""" -A signed decimal number, which supports arbitrary precision and is serialized as a string. - -Example values: `"29.99"`, `"29.999"`. -""" -scalar Decimal - -""" -Represents information about the merchandise in the cart. -""" -type DeliverableCartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! -} - -""" -List of different delivery method types. -""" -enum DeliveryMethod { - """ - Local Delivery. - """ - LOCAL - - """ - None. - """ - NONE - - """ - Shipping to a Pickup Point. - """ - PICKUP_POINT - - """ - Local Pickup. - """ - PICK_UP - - """ - Retail. - """ - RETAIL - - """ - Shipping. - """ - SHIPPING -} - -""" -The discount to be applied. -""" -input Discount { - """ - The discount message. - """ - message: String - - """ - The targets of the discount. - - This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. - """ - targets: [Target!]! - - """ - The value of the discount. - """ - value: Value! -} - -""" -The strategy that's applied to the list of discounts. -""" -enum DiscountApplicationStrategy { - """ - Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. - """ - ALL - - """ - Only apply the first discount with conditions that are satisfied. - """ - FIRST - - """ - Only apply the discount that offers the maximum reduction. - """ - MAXIMUM -} - -""" -A discount wrapper node. -""" -type DiscountNode implements HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A fixed amount value. -""" -input FixedAmount { - """ - The fixed amount value of the discount, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! - - """ - Whether to apply the value to each entitled item. - - The default value is `false`, which causes the value to be applied once across the entitled items. - When the value is `true`, the value will be applied to each of the entitled items. - """ - appliesToEachItem: Boolean -} - -""" -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. -""" -input FunctionResult { - """ - The strategy to apply the list of discounts. - """ - discountApplicationStrategy: DiscountApplicationStrategy! - - """ - The list of discounts to be applied. - """ - discounts: [Discount!]! -} - -""" -The run target result. -""" -input FunctionRunResult { - """ - The strategy to apply the list of discounts. - """ - discountApplicationStrategy: DiscountApplicationStrategy! - - """ - The list of discounts to be applied. - """ - discounts: [Discount!]! -} - -""" -A function-scoped handle to a refer a resource. -The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. -Example value: `"10079785100"` -""" -scalar Handle - -""" -Represents information about the metafields associated to the specified resource. -""" -interface HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents whether the current object has the given tag. -""" -type HasTagResponse { - """ - Whether the current object has the tag. - """ - hasTag: Boolean! - - """ - The tag. - """ - tag: String! -} - -""" -Represents a unique identifier, often used to refetch an object. -The ID type appears in a JSON response as a String, but it is not intended to be human-readable. - -Example value: `"gid://shopify/Product/10079785100"` -""" -scalar ID - -""" -The input object for the function. -""" -type Input { - """ - The cart. - """ - cart: Cart! - - """ - The discount node executing the function. - """ - discountNode: DiscountNode! - - """ - The localization of the Function execution context. - """ - localization: Localization! - - """ - The conversion rate between the shop's currency and the currency of the cart. - """ - presentmentCurrencyRate: Decimal! - - """ - Information about the shop. - """ - shop: Shop! -} - -""" -A [JSON](https://www.json.org/json-en.html) object. - -Example value: -`{ - "product": { - "id": "gid://shopify/Product/1346443542550", - "title": "White T-shirt", - "options": [{ - "name": "Size", - "values": ["M", "L"] - }] - } -}` -""" -scalar JSON - -""" -A language. -""" -type Language { - """ - The ISO code. - """ - isoCode: LanguageCode! -} - -""" -Language codes supported by Shopify. -""" -enum LanguageCode { - """ - Afrikaans. - """ - AF - - """ - Akan. - """ - AK - - """ - Amharic. - """ - AM - - """ - Arabic. - """ - AR - - """ - Assamese. - """ - AS - - """ - Azerbaijani. - """ - AZ - - """ - Belarusian. - """ - BE - - """ - Bulgarian. - """ - BG - - """ - Bambara. - """ - BM - - """ - Bangla. - """ - BN - - """ - Tibetan. - """ - BO - - """ - Breton. - """ - BR - - """ - Bosnian. - """ - BS - - """ - Catalan. - """ - CA - - """ - Chechen. - """ - CE - - """ - Central Kurdish. - """ - CKB - - """ - Czech. - """ - CS - - """ - Church Slavic. - """ - CU - - """ - Welsh. - """ - CY - - """ - Danish. - """ - DA - - """ - German. - """ - DE - - """ - Dzongkha. - """ - DZ - - """ - Ewe. - """ - EE - - """ - Greek. - """ - EL - - """ - English. - """ - EN - - """ - Esperanto. - """ - EO - - """ - Spanish. - """ - ES - - """ - Estonian. - """ - ET - - """ - Basque. - """ - EU - - """ - Persian. - """ - FA - - """ - Fulah. - """ - FF - - """ - Finnish. - """ - FI - - """ - Filipino. - """ - FIL - - """ - Faroese. - """ - FO - - """ - French. - """ - FR - - """ - Western Frisian. - """ - FY - - """ - Irish. - """ - GA - - """ - Scottish Gaelic. - """ - GD - - """ - Galician. - """ - GL - - """ - Gujarati. - """ - GU - - """ - Manx. - """ - GV - - """ - Hausa. - """ - HA - - """ - Hebrew. - """ - HE - - """ - Hindi. - """ - HI - - """ - Croatian. - """ - HR - - """ - Hungarian. - """ - HU - - """ - Armenian. - """ - HY - - """ - Interlingua. - """ - IA - - """ - Indonesian. - """ - ID - - """ - Igbo. - """ - IG - - """ - Sichuan Yi. - """ - II - - """ - Icelandic. - """ - IS - - """ - Italian. - """ - IT - - """ - Japanese. - """ - JA - - """ - Javanese. - """ - JV - - """ - Georgian. - """ - KA - - """ - Kikuyu. - """ - KI - - """ - Kazakh. - """ - KK - - """ - Kalaallisut. - """ - KL - - """ - Khmer. - """ - KM - - """ - Kannada. - """ - KN - - """ - Korean. - """ - KO - - """ - Kashmiri. - """ - KS - - """ - Kurdish. - """ - KU - - """ - Cornish. - """ - KW - - """ - Kyrgyz. - """ - KY - - """ - Luxembourgish. - """ - LB - - """ - Ganda. - """ - LG - - """ - Lingala. - """ - LN - - """ - Lao. - """ - LO - - """ - Lithuanian. - """ - LT - - """ - Luba-Katanga. - """ - LU - - """ - Latvian. - """ - LV - - """ - Malagasy. - """ - MG - - """ - Māori. - """ - MI - - """ - Macedonian. - """ - MK - - """ - Malayalam. - """ - ML - - """ - Mongolian. - """ - MN - - """ - Marathi. - """ - MR - - """ - Malay. - """ - MS - - """ - Maltese. - """ - MT - - """ - Burmese. - """ - MY - - """ - Norwegian (Bokmål). - """ - NB - - """ - North Ndebele. - """ - ND - - """ - Nepali. - """ - NE - - """ - Dutch. - """ - NL - - """ - Norwegian Nynorsk. - """ - NN - - """ - Norwegian. - """ - NO - - """ - Oromo. - """ - OM - - """ - Odia. - """ - OR - - """ - Ossetic. - """ - OS - - """ - Punjabi. - """ - PA - - """ - Polish. - """ - PL - - """ - Pashto. - """ - PS - - """ - Portuguese. - """ - PT - - """ - Portuguese (Brazil). - """ - PT_BR - - """ - Portuguese (Portugal). - """ - PT_PT - - """ - Quechua. - """ - QU - - """ - Romansh. - """ - RM - - """ - Rundi. - """ - RN - - """ - Romanian. - """ - RO - - """ - Russian. - """ - RU - - """ - Kinyarwanda. - """ - RW - - """ - Sanskrit. - """ - SA - - """ - Sardinian. - """ - SC - - """ - Sindhi. - """ - SD - - """ - Northern Sami. - """ - SE - - """ - Sango. - """ - SG - - """ - Sinhala. - """ - SI - - """ - Slovak. - """ - SK - - """ - Slovenian. - """ - SL - - """ - Shona. - """ - SN - - """ - Somali. - """ - SO - - """ - Albanian. - """ - SQ - - """ - Serbian. - """ - SR - - """ - Sundanese. - """ - SU - - """ - Swedish. - """ - SV - - """ - Swahili. - """ - SW - - """ - Tamil. - """ - TA - - """ - Telugu. - """ - TE - - """ - Tajik. - """ - TG - - """ - Thai. - """ - TH - - """ - Tigrinya. - """ - TI - - """ - Turkmen. - """ - TK - - """ - Tongan. - """ - TO - - """ - Turkish. - """ - TR - - """ - Tatar. - """ - TT - - """ - Uyghur. - """ - UG - - """ - Ukrainian. - """ - UK - - """ - Urdu. - """ - UR - - """ - Uzbek. - """ - UZ - - """ - Vietnamese. - """ - VI - - """ - Volapük. - """ - VO - - """ - Wolof. - """ - WO - - """ - Xhosa. - """ - XH - - """ - Yiddish. - """ - YI - - """ - Yoruba. - """ - YO - - """ - Chinese. - """ - ZH - - """ - Chinese (Simplified). - """ - ZH_CN - - """ - Chinese (Traditional). - """ - ZH_TW - - """ - Zulu. - """ - ZU -} - -""" -Represents limited information about the current time relative to the parent object. -""" -type LocalTime { - """ - The current date relative to the parent object. - """ - date: Date! - - """ - Returns true if the current date and time is at or past the given date and time, and false otherwise. - """ - dateTimeAfter( - """ - The date and time to compare against, assumed to be in the timezone of the parent object. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is before the given date and time, and false otherwise. - """ - dateTimeBefore( - """ - The date and time to compare against, assumed to be in the timezone of the parent timezone. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is between the two given date and times, and false otherwise. - """ - dateTimeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endDateTime: DateTimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startDateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeAfter( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeBefore( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is between the two given times, and false otherwise. - """ - timeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endTime: TimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startTime: TimeWithoutTimezone! - ): Boolean! -} - -""" -Information about the localized experiences configured for the shop. -""" -type Localization { - """ - The country of the active localized experience. - """ - country: Country! - - """ - The language of the active localized experience. - """ - language: Language! - - """ - The market of the active localized experience. - """ - market: Market! -} - -""" -Represents the value captured by a localized field. Localized fields are -additional fields required by certain countries on international orders. For -example, some countries require additional fields for customs information or tax -identification numbers. -""" -type LocalizedField { - """ - The key of the localized field. - """ - key: LocalizedFieldKey! - - """ - The title of the localized field. - """ - title: String! - - """ - The value of the localized field. - """ - value: String -} - -""" -Unique key identifying localized fields. -""" -enum LocalizedFieldKey { - """ - Localized field key 'shipping_credential_br' for country BR. - """ - SHIPPING_CREDENTIAL_BR - - """ - Localized field key 'shipping_credential_cl' for country CL. - """ - SHIPPING_CREDENTIAL_CL - - """ - Localized field key 'shipping_credential_cn' for country CN. - """ - SHIPPING_CREDENTIAL_CN - - """ - Localized field key 'shipping_credential_co' for country CO. - """ - SHIPPING_CREDENTIAL_CO - - """ - Localized field key 'shipping_credential_cr' for country CR. - """ - SHIPPING_CREDENTIAL_CR - - """ - Localized field key 'shipping_credential_ec' for country EC. - """ - SHIPPING_CREDENTIAL_EC - - """ - Localized field key 'shipping_credential_es' for country ES. - """ - SHIPPING_CREDENTIAL_ES - - """ - Localized field key 'shipping_credential_gt' for country GT. - """ - SHIPPING_CREDENTIAL_GT - - """ - Localized field key 'shipping_credential_id' for country ID. - """ - SHIPPING_CREDENTIAL_ID - - """ - Localized field key 'shipping_credential_kr' for country KR. - """ - SHIPPING_CREDENTIAL_KR - - """ - Localized field key 'shipping_credential_mx' for country MX. - """ - SHIPPING_CREDENTIAL_MX - - """ - Localized field key 'shipping_credential_my' for country MY. - """ - SHIPPING_CREDENTIAL_MY - - """ - Localized field key 'shipping_credential_pe' for country PE. - """ - SHIPPING_CREDENTIAL_PE - - """ - Localized field key 'shipping_credential_pt' for country PT. - """ - SHIPPING_CREDENTIAL_PT - - """ - Localized field key 'shipping_credential_py' for country PY. - """ - SHIPPING_CREDENTIAL_PY - - """ - Localized field key 'shipping_credential_tr' for country TR. - """ - SHIPPING_CREDENTIAL_TR - - """ - Localized field key 'shipping_credential_tw' for country TW. - """ - SHIPPING_CREDENTIAL_TW - - """ - Localized field key 'shipping_credential_type_co' for country CO. - """ - SHIPPING_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_br' for country BR. - """ - TAX_CREDENTIAL_BR - - """ - Localized field key 'tax_credential_cl' for country CL. - """ - TAX_CREDENTIAL_CL - - """ - Localized field key 'tax_credential_co' for country CO. - """ - TAX_CREDENTIAL_CO - - """ - Localized field key 'tax_credential_cr' for country CR. - """ - TAX_CREDENTIAL_CR - - """ - Localized field key 'tax_credential_ec' for country EC. - """ - TAX_CREDENTIAL_EC - - """ - Localized field key 'tax_credential_es' for country ES. - """ - TAX_CREDENTIAL_ES - - """ - Localized field key 'tax_credential_gt' for country GT. - """ - TAX_CREDENTIAL_GT - - """ - Localized field key 'tax_credential_id' for country ID. - """ - TAX_CREDENTIAL_ID - - """ - Localized field key 'tax_credential_it' for country IT. - """ - TAX_CREDENTIAL_IT - - """ - Localized field key 'tax_credential_mx' for country MX. - """ - TAX_CREDENTIAL_MX - - """ - Localized field key 'tax_credential_my' for country MY. - """ - TAX_CREDENTIAL_MY - - """ - Localized field key 'tax_credential_pe' for country PE. - """ - TAX_CREDENTIAL_PE - - """ - Localized field key 'tax_credential_pt' for country PT. - """ - TAX_CREDENTIAL_PT - - """ - Localized field key 'tax_credential_py' for country PY. - """ - TAX_CREDENTIAL_PY - - """ - Localized field key 'tax_credential_tr' for country TR. - """ - TAX_CREDENTIAL_TR - - """ - Localized field key 'tax_credential_type_co' for country CO. - """ - TAX_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_type_mx' for country MX. - """ - TAX_CREDENTIAL_TYPE_MX - - """ - Localized field key 'tax_credential_use_mx' for country MX. - """ - TAX_CREDENTIAL_USE_MX - - """ - Localized field key 'tax_email_it' for country IT. - """ - TAX_EMAIL_IT -} - -""" -Represents a mailing address. -""" -type MailingAddress { - """ - The first line of the address. Typically the street address or PO Box number. - """ - address1: String - - """ - The second line of the address. Typically the number of the apartment, suite, or unit. - """ - address2: String - - """ - The name of the city, district, village, or town. - """ - city: String - - """ - The name of the customer's company or organization. - """ - company: String - - """ - The two-letter code for the country of the address. For example, US. - """ - countryCode: CountryCode - - """ - The first name of the customer. - """ - firstName: String - - """ - The last name of the customer. - """ - lastName: String - - """ - The approximate latitude of the address. - """ - latitude: Float - - """ - The approximate longitude of the address. - """ - longitude: Float - - """ - The market of the address. - """ - market: Market - - """ - The full name of the customer, based on firstName and lastName. - """ - name: String - - """ - A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. - """ - phone: String - - """ - The alphanumeric code for the region. For example, ON. - """ - provinceCode: String - - """ - The zip or postal code of the address. - """ - zip: String -} - -""" -A market is a group of one or more regions that you want to target for international sales. -By creating a market, you can configure a distinct, localized shopping experience for -customers from a specific area of the world. For example, you can -[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), -[configure international pricing](https://shopify.dev/api/examples/product-price-lists), -or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). -""" -type Market implements HasMetafields { - """ - A human-readable unique string for the market automatically generated from its title. - """ - handle: Handle! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - A geographic region which comprises a market. - """ - regions: [MarketRegion!]! -} - -""" -Represents a region. -""" -interface MarketRegion { - """ - The name of the region in the language of the current localization. - """ - name: String -} - -""" -A country which comprises a market. -""" -type MarketRegionCountry implements MarketRegion { - """ - The two-letter code for the country. - """ - code: CountryCode! - - """ - The country name in the language of the current localization. - """ - name: String! -} - -""" -The merchandise to be purchased at checkout. -""" -union Merchandise = CustomProduct | ProductVariant - -""" -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). -""" -type Metafield { - """ - The data stored in the metafield in JSON format. - """ - jsonValue: JSON! - - """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). - """ - type: String! - - """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. - """ - value: String! -} - -""" -A monetary value with currency. -""" -type MoneyV2 { - """ - Decimal money amount. - """ - amount: Decimal! - - """ - Currency of the money. - """ - currencyCode: CurrencyCode! -} - -""" -The root mutation for the API. -""" -type MutationRoot { - """ - Handles the Function result. - """ - handleResult( - """ - The result of the Function. - """ - result: FunctionResult! - ): Void! @deprecated(reason: "Use the target-specific field instead.") - - """ - Handles the Function result for the purchase.product-discount.run target. - """ - run( - """ - The result of the Function. - """ - result: FunctionRunResult! - ): Void! -} - -""" -A percentage value. -""" -input Percentage { - """ - The percentage value. - - The value is validated against: >= 0 and <= 100. - """ - value: Decimal! -} - -""" -Represents a product. -""" -type Product implements HasMetafields { - """ - A unique human-friendly string of the product's title. - """ - handle: Handle! - - """ - Whether the product has any of the given tags. - """ - hasAnyTag( - """ - The tags to check. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the product has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Whether the product is in any of the given collections. - """ - inAnyCollection( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): Boolean! - - """ - Whether the product is in the given collections. - """ - inCollections( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): [CollectionMembership!]! - - """ - Whether the product is a gift card. - """ - isGiftCard: Boolean! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product type specified by the merchant. - """ - productType: String - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The name of the product's vendor. - """ - vendor: String -} - -""" -Represents a product variant. -""" -type ProductVariant implements HasMetafields { - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product that this variant belongs to. - """ - product: Product! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. - """ - sku: String - - """ - The localized title of the product variant in the customer’s locale. - """ - title: String - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an -optional quantity limit. -""" -input ProductVariantTarget { - """ - The ID of the targeted product variant. - """ - id: ID! - - """ - The maximum number of line item units to be discounted. - The default value is `null`, which represents the total quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type PurchasingCompany { - """ - The company associated to the order or draft order. - """ - company: Company! - - """ - The company contact associated to the order or draft order. - """ - contact: CompanyContact - - """ - The company location associated to the order or draft order. - """ - location: CompanyLocation! -} - -""" -Represents how products and variants can be sold and purchased. -""" -type SellingPlan implements HasMetafields { - """ - The description of the selling plan. - """ - description: String - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. - """ - name: String! - - """ - Whether purchasing the selling plan will result in multiple deliveries. - """ - recurringDeliveries: Boolean! -} - -""" -Represents an association between a variant and a selling plan. Selling plan -allocations describe the options offered for each variant, and the price of the -variant when purchased with a selling plan. -""" -type SellingPlanAllocation { - """ - A list of price adjustments, with a maximum of two. When there are two, the - first price adjustment goes into effect at the time of purchase, while the - second one starts after a certain number of orders. A price adjustment - represents how a selling plan affects pricing when a variant is purchased with - a selling plan. Prices display in the customer's currency if the shop is - configured for it. - """ - priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! - - """ - A representation of how products and variants can be sold and purchased. For - example, an individual selling plan could be '6 weeks of prepaid granola, - delivered weekly'. - """ - sellingPlan: SellingPlan! -} - -""" -The resulting prices for variants when they're purchased with a specific selling plan. -""" -type SellingPlanAllocationPriceAdjustment { - """ - The effective price for a single delivery. For example, for a prepaid - subscription plan that includes 6 deliveries at the price of $48.00, the per - delivery price is $8.00. - """ - perDeliveryPrice: MoneyV2! - - """ - The price of the variant when it's purchased with a selling plan For example, - for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, - where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. - """ - price: MoneyV2! -} - -""" -Information about the shop. -""" -type Shop implements HasMetafields { - """ - Information about the current time relative to the shop's timezone setting. - """ - localTime: LocalTime! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A target of a discount, which determines which cart line(s) the discount will affect. - -A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. - -Multiple targets with the same type and ID are the same as a single target of that type and ID with their -quantities added together, or `null` if any of those targets have a quantity of `null`. - -See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. -""" -input Target @oneOf { - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. - """ - cartLine: CartLineTarget - - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an - optional quantity limit. - """ - productVariant: ProductVariantTarget -} - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the time but not the date or timezone which is determined from context. -For example, "05:43:21". -""" -scalar TimeWithoutTimezone - -""" -The value of the discount. -""" -input Value @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -A void type that can be used to return a null value from a mutation. -""" -scalar Void - -""" -Units of measurement for weight. -""" -enum WeightUnit { - """ - Metric system unit of mass. - """ - GRAMS - - """ - 1 kilogram equals 1000 grams. - """ - KILOGRAMS - - """ - Imperial system unit of mass. - """ - OUNCES - - """ - 1 pound equals 16 ounces. - """ - POUNDS -} diff --git a/discounts/javascript/discounts/default/shopify.extension.toml.liquid b/discounts/javascript/discounts/default/shopify.extension.toml.liquid deleted file mode 100644 index 6f75e975..00000000 --- a/discounts/javascript/discounts/default/shopify.extension.toml.liquid +++ /dev/null @@ -1,36 +0,0 @@ -api_version = "unstable" - -[[extensions]] -name = "t:name" -handle = "{{handle}}" -type = "function" -{% if uid %}uid = "{{ uid }}"{% endif %} -description = "t:description" - - [[extensions.targeting]] - target = "purchase.discount.cart_run" - input_query = "src/run.graphql" - export = "cart_run" - - [[extensions.targeting]] - target = "purchase.discount.cart_fetch" - input_query = "src/run.graphql" - export = "cart_fetch" - - [[extensions.targeting]] - target = "purchase.discount.delivery_run" - input_query = "src/run.graphql" - export = "delivery_run" - - [[extensions.targeting]] - target = "purchase.discount.delivery_fetch" - input_query = "src/run.graphql" - export = "delivery_fetch" - - [extensions.build] - command = "" - path = "dist/function.wasm" - - [extensions.ui.paths] - create = "/" - details = "/" diff --git a/discounts/javascript/discounts/default/src/index.liquid b/discounts/javascript/discounts/default/src/index.liquid deleted file mode 100644 index e12506eb..00000000 --- a/discounts/javascript/discounts/default/src/index.liquid +++ /dev/null @@ -1 +0,0 @@ -export * from './run'; \ No newline at end of file diff --git a/discounts/javascript/discounts/default/src/run.graphql.liquid b/discounts/javascript/discounts/default/src/run.graphql.liquid deleted file mode 100644 index 6f91afaa..00000000 --- a/discounts/javascript/discounts/default/src/run.graphql.liquid +++ /dev/null @@ -1,7 +0,0 @@ -query RunInput { - discountNode { - metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { - value - } - } -} diff --git a/discounts/javascript/discounts/default/src/run.liquid b/discounts/javascript/discounts/default/src/run.liquid deleted file mode 100644 index a57c3669..00000000 --- a/discounts/javascript/discounts/default/src/run.liquid +++ /dev/null @@ -1,51 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check -import { DiscountApplicationStrategy } from "../generated/api"; - -/** - * @typedef {import("../generated/api").RunInput} RunInput - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult - */ - -/** - * @type {FunctionRunResult} - */ -const EMPTY_DISCOUNT = { - discountApplicationStrategy: DiscountApplicationStrategy.First, - discounts: [], -}; - -/** - * @param {RunInput} input - * @returns {FunctionRunResult} - */ -export function run(input) { - const configuration = JSON.parse( - input?.discountNode?.metafield?.value ?? "{}" - ); - - return EMPTY_DISCOUNT; -}; -{%- elsif flavor contains "typescript" -%} -import type { - RunInput, - FunctionRunResult -} from "../generated/api"; -import { - DiscountApplicationStrategy, -} from "../generated/api"; - -const EMPTY_DISCOUNT: FunctionRunResult = { - discountApplicationStrategy: DiscountApplicationStrategy.First, - discounts: [], -}; - -type Configuration = {}; - -export function run(input: RunInput): FunctionRunResult { - const configuration: Configuration = JSON.parse( - input?.discountNode?.metafield?.value ?? "{}" - ); - return EMPTY_DISCOUNT; -}; -{%- endif -%} diff --git a/discounts/javascript/discounts/default/src/run.test.liquid b/discounts/javascript/discounts/default/src/run.test.liquid deleted file mode 100644 index 3e63b6e2..00000000 --- a/discounts/javascript/discounts/default/src/run.test.liquid +++ /dev/null @@ -1,44 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -import { describe, it, expect } from 'vitest'; -import { run } from './run'; - -/** - * @typedef {import("../generated/api").FunctionResult} FunctionResult - */ - -describe('product discounts function', () => { - it('returns no discounts without configuration', () => { - const result = run({ - discountNode: { - metafield: null - } - }); - const expected = /** @type {FunctionResult} */ ({ - discounts: [], - discountApplicationStrategy: "FIRST", - }); - - expect(result).toEqual(expected); - }); -}); -{%- elsif flavor contains "typescript" -%} -import { describe, it, expect } from 'vitest'; -import { run } from './run'; -import { FunctionResult, DiscountApplicationStrategy } from '../generated/api'; - -describe('product discounts function', () => { - it('returns no discounts without configuration', () => { - const result = run({ - discountNode: { - metafield: null - } - }); - const expected: FunctionResult = { - discounts: [], - discountApplicationStrategy: DiscountApplicationStrategy.First, - }; - - expect(result).toEqual(expected); - }); -}); -{%- endif -%} diff --git a/discounts/javascript/discounts/default/vite.config.js b/discounts/javascript/discounts/default/vite.config.js deleted file mode 100644 index 210c90d4..00000000 --- a/discounts/javascript/discounts/default/vite.config.js +++ /dev/null @@ -1 +0,0 @@ -// Prevents inheritance from parent Remix project diff --git a/discounts/rust/discounts/default/src/run.rs b/discounts/rust/discounts/default/src/run.rs index 3209c01f..f53acfd9 100644 --- a/discounts/rust/discounts/default/src/run.rs +++ b/discounts/rust/discounts/default/src/run.rs @@ -1,23 +1,23 @@ -use serde::de::DeserializeOwned; +use serde::{de::DeserializeOwned, Deserialize}; use shopify_function::prelude::*; use shopify_function::Result; -use cart_fetch::output::{ - FunctionCartFetchResult, HttpRequest as CartHttpRequest, - HttpRequestMethod as CartHttpRequestMethod, HttpRequestPolicy as CartHttpRequestPolicy, -}; +use cart_fetch::output::FunctionCartFetchResult; use cart_run::output::FunctionCartRunResult; -use delivery_fetch::output::{ - FunctionDeliveryFetchResult, HttpRequest as DeliveryHttpRequest, - HttpRequestMethod as DeliveryHttpRequestMethod, HttpRequestPolicy as DeliveryHttpRequestPolicy, -}; +use delivery_fetch::output::FunctionDeliveryFetchResult; use delivery_run::output::FunctionDeliveryRunResult; type CartResponseData = cart_run::input::ResponseData; type DeliveryResponseData = delivery_run::input::ResponseData; type CartFetchResponseData = cart_fetch::input::ResponseData; +#[derive(Deserialize)] +struct Wrapper { + cart: Option, + delivery: Option, +} + #[shopify_function_target( target = "cart_run", query_path = "src/run.graphql", @@ -26,7 +26,9 @@ type CartFetchResponseData = cart_fetch::input::ResponseData; fn cart_run(input: CartResponseData) -> Result { let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); let body = fetch_result.body.as_ref().expect("Missing body"); - let result = metafield_to_config::(&body); + let result = string_to_config::(&body) + .cart + .unwrap_or_else(|| FunctionCartRunResult { operations: vec![] }); Ok(result) } @@ -39,7 +41,9 @@ fn cart_run(input: CartResponseData) -> Result { fn delivery_run(input: DeliveryResponseData) -> Result { let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); let body = fetch_result.body.as_ref().expect("Missing body"); - let result = metafield_to_config::(&body); + let result = string_to_config::(&body) + .delivery + .unwrap_or_else(|| FunctionDeliveryRunResult { operations: vec![] }); Ok(result) } @@ -55,18 +59,9 @@ fn cart_fetch(input: CartFetchResponseData) -> Result { .metafield .expect("Missing required metafield configuration"); - Ok(FunctionCartFetchResult { - request: Some(CartHttpRequest { - body: Some(metafield.value.clone()), - headers: vec![], - json_body: serde_json::from_str(&metafield.value)?, - method: CartHttpRequestMethod::POST, - policy: CartHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "https://example.com".to_string(), - }), - }) + Ok(string_to_config::( + &metafield.value, + )) } #[shopify_function_target( @@ -80,31 +75,30 @@ fn delivery_fetch(input: CartFetchResponseData) -> Result( + &metafield.value, + )) } -fn metafield_to_config(value: &str) -> T { +fn string_to_config(value: &str) -> T { serde_json::from_str(value).expect("Unable to parse configuration value from metafield") } #[cfg(test)] mod tests { use super::*; + use cart_fetch::output::{ + HttpRequest as CartHttpRequest, HttpRequestMethod as CartHttpRequestMethod, + HttpRequestPolicy as CartHttpRequestPolicy, + }; use cart_run::output::{ CartOperation, OrderDiscountSelectionStrategy, OrderDiscounts, ProductDiscountSelectionStrategy, ProductDiscounts, }; + use delivery_fetch::output::{ + HttpRequest as DeliveryHttpRequest, HttpRequestMethod as DeliveryHttpRequestMethod, + HttpRequestPolicy as DeliveryHttpRequestPolicy, + }; use delivery_run::output::{ DeliveryDiscountSelectionStrategy, DeliveryDiscounts, DeliveryOperation, FunctionDeliveryRunResult, @@ -114,13 +108,23 @@ mod tests { #[test] fn test_cart_run() -> Result<()> { - let query_input_json = r#" - { + let query_input_json = json!({ "fetchResult": { - "body": "{\"operations\":[{\"addOrderDiscounts\":{\"selectionStrategy\":\"FIRST\",\"candidates\":[]}},{\"addProductDiscounts\":{\"selectionStrategy\":\"FIRST\",\"candidates\":[]}}]}" + "body": json!( + { + "cart": { + "operations": [ + { + "addOrderDiscounts": {"selectionStrategy":"FIRST","candidates":[]}, + }, { + "addProductDiscounts": {"selectionStrategy":"FIRST","candidates":[]} + } + ] + } + } + ).to_string() } - } - "#; + }); let expected = FunctionCartRunResult { operations: vec![ @@ -136,7 +140,7 @@ mod tests { }; assert_eq!( - run_function_with_input(cart_run, query_input_json)?, + run_function_with_input(cart_run, &query_input_json.to_string())?, expected ); Ok(()) @@ -144,13 +148,21 @@ mod tests { #[test] fn test_delivery_run() -> Result<()> { - let query_input_json = r#" - { + let query_input_json = json!({ "fetchResult": { - "body": "{\"operations\":[{\"addDeliveryDiscounts\":{\"selectionStrategy\":\"ALL\",\"candidates\":[]}}]}" + "body": json!( + { + "delivery": { + "operations": [ + { + "addDeliveryDiscounts": {"selectionStrategy":"ALL","candidates":[]}, + } + ] + } + } + ).to_string() } - } - "#; + }); let expected = FunctionDeliveryRunResult { operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { @@ -160,7 +172,7 @@ mod tests { }; assert_eq!( - run_function_with_input(delivery_run, query_input_json)?, + run_function_with_input(delivery_run, &query_input_json.to_string())?, expected ); Ok(()) @@ -169,15 +181,17 @@ mod tests { #[test] fn test_cart_fetch() -> Result<()> { let body = json!({ - "operations": [ - { - "addOrderDiscounts": {"selectionStrategy": "FIRST", "candidates": []}, - "addProductDiscounts": {"selectionStrategy": "FIRST", "candidates": []} - } - ] + "cart": { + "operations": [ + { + "addOrderDiscounts": {"selectionStrategy": "FIRST", "candidates": []}, + "addProductDiscounts": {"selectionStrategy": "FIRST", "candidates": []} + } + ] + } }); - let fetch_result = FunctionCartFetchResult { + let expected_fetch_result = FunctionCartFetchResult { request: Some(CartHttpRequest { body: Some(body.to_string()), headers: vec![], @@ -193,14 +207,25 @@ mod tests { let metafield = json!({ "discountNode": { "metafield": { - "value": body.to_string(), + "value": json!({ + "request": { + "body": Some(body.to_string()), + "headers": [], + "jsonBody": Some(body.clone()), + "method": "POST", + "policy": { + "readTimeoutMs": 2000, + }, + "url": "https://example.com", + } + }).to_string(), } } }); assert_eq!( run_function_with_input(cart_fetch, &metafield.to_string())?, - fetch_result + expected_fetch_result ); Ok(()) } @@ -208,14 +233,16 @@ mod tests { #[test] fn test_delivery_fetch() -> Result<()> { let body = json!({ - "operations": [ - { - "addDeliveryDiscounts": {"selectionStrategy": "ALL", "candidates": []}, - } - ] + "delivery": { + "operations": [ + { + "addDeliveryDiscounts": {"selectionStrategy": "ALL", "candidates": []}, + } + ] + } }); - let fetch_result = FunctionDeliveryFetchResult { + let expected_fetch_result = FunctionDeliveryFetchResult { request: Some(DeliveryHttpRequest { body: Some(body.to_string()), headers: vec![], @@ -231,14 +258,25 @@ mod tests { let metafield = json!({ "discountNode": { "metafield": { - "value": body.to_string(), + "value": json!({ + "request": { + "body": Some(body.to_string()), + "headers": [], + "jsonBody": Some(body.clone()), + "method": "POST", + "policy": { + "readTimeoutMs": 2000, + }, + "url": "https://example.com", + } + }).to_string(), } } }); assert_eq!( run_function_with_input(delivery_fetch, &metafield.to_string())?, - fetch_result + expected_fetch_result ); Ok(()) } diff --git a/discounts/wasm/discounts/default/locales/en.default.json.liquid b/discounts/wasm/discounts/default/locales/en.default.json.liquid deleted file mode 100644 index 333045ae..00000000 --- a/discounts/wasm/discounts/default/locales/en.default.json.liquid +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "{{name}}", - "description": "{{name}}" -} diff --git a/discounts/wasm/discounts/default/run.graphql.liquid b/discounts/wasm/discounts/default/run.graphql.liquid deleted file mode 100644 index bc740d91..00000000 --- a/discounts/wasm/discounts/default/run.graphql.liquid +++ /dev/null @@ -1,7 +0,0 @@ -query Input { - discountNode { - metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { - value - } - } -} diff --git a/discounts/wasm/discounts/default/schema.graphql b/discounts/wasm/discounts/default/schema.graphql deleted file mode 100644 index 3ca4e22b..00000000 --- a/discounts/wasm/discounts/default/schema.graphql +++ /dev/null @@ -1,4518 +0,0 @@ -schema { - query: Input - mutation: MutationRoot -} - -""" -Scale the Functions resource limits based on the field's length. -""" -directive @scaleLimits(rate: Float!) on FIELD_DEFINITION - -""" -Requires that exactly one field must be supplied and that field must not be `null`. -""" -directive @oneOf on INPUT_OBJECT - -""" -Represents a generic custom attribute, such as whether an order is a customer's first. -""" -type Attribute { - """ - The key or name of the attribute. For example, `"customersFirstOrder"`. - """ - key: String! - - """ - The value of the attribute. For example, `"true"`. - """ - value: String -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type BuyerIdentity { - """ - The customer associated with the cart. - """ - customer: Customer - - """ - The email address of the buyer that's interacting with the cart. - """ - email: String - - """ - Whether the buyer authenticated with a customer account. - """ - isAuthenticated: Boolean! - - """ - The phone number of the buyer that's interacting with the cart. - """ - phone: String - - """ - The purchasing company associated with the cart. - """ - purchasingCompany: PurchasingCompany -} - -""" -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. -""" -type Cart { - """ - The attributes associated with the cart. Attributes are represented as key-value pairs. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - Information about the buyer that is interacting with the cart. - """ - buyerIdentity: BuyerIdentity - - """ - The costs that the buyer will pay at checkout. - """ - cost: CartCost! - - """ - A list of lines containing information about the items that can be delivered. - """ - deliverableLines: [DeliverableCartLine!]! - - """ - The delivery groups available for the cart based on the buyer's shipping address. - """ - deliveryGroups: [CartDeliveryGroup!]! - - """ - A list of lines containing information about the items the customer intends to purchase. - """ - lines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The localized fields available for the cart. - """ - localizedFields( - """ - The keys of the localized fields to retrieve. - """ - keys: [LocalizedFieldKey!]! = [] - ): [LocalizedField!]! -} - -""" -The cost that the buyer will pay at checkout. -""" -type CartCost { - """ - The amount, before taxes and discounts, for the customer to pay. - """ - subtotalAmount: MoneyV2! - - """ - The total amount for the customer to pay. - """ - totalAmount: MoneyV2! - - """ - The duty amount for the customer to pay at checkout. - """ - totalDutyAmount: MoneyV2 - - """ - The tax amount for the customer to pay at checkout. - """ - totalTaxAmount: MoneyV2 -} - -""" -Information about the options available for one or more line items to be delivered to a specific address. -""" -type CartDeliveryGroup { - """ - A list of cart lines for the delivery group. - """ - cartLines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The destination address for the delivery group. - """ - deliveryAddress: MailingAddress - - """ - The delivery options available for the delivery group. - """ - deliveryOptions: [CartDeliveryOption!]! - - """ - Unique identifier for the delivery group. - """ - id: ID! - - """ - Information about the delivery option the buyer has selected. - """ - selectedDeliveryOption: CartDeliveryOption -} - -""" -Information about a delivery option. -""" -type CartDeliveryOption { - """ - The code of the delivery option. - """ - code: String - - """ - The cost for the delivery option. - """ - cost: MoneyV2! - - """ - The method for the delivery option. - """ - deliveryMethodType: DeliveryMethod! - - """ - The description of the delivery option. - """ - description: String - - """ - The unique identifier of the delivery option. - """ - handle: Handle! - - """ - The title of the delivery option. - """ - title: String -} - -""" -Represents information about the merchandise in the cart. -""" -type CartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The cost of the merchandise line that the buyer will pay at checkout. - """ - cost: CartLineCost! - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! - - """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. - """ - sellingPlanAllocation: SellingPlanAllocation -} - -""" -The cost of the merchandise line that the buyer will pay at checkout. -""" -type CartLineCost { - """ - The amount of the merchandise line. - """ - amountPerQuantity: MoneyV2! - - """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. - """ - compareAtAmountPerQuantity: MoneyV2 - - """ - The cost of the merchandise line before line-level discounts. - """ - subtotalAmount: MoneyV2! - - """ - The total cost of the merchandise line. - """ - totalAmount: MoneyV2! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. -""" -input CartLineTarget { - """ - The ID of the targeted cart line. - """ - id: ID! - - """ - The number of line items that are being discounted. - The default value is `null`, which represents the quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -Represents whether the product is a member of the given collection. -""" -type CollectionMembership { - """ - The ID of the collection. - """ - collectionId: ID! - - """ - Whether the product is a member of the collection. - """ - isMember: Boolean! -} - -""" -Represents information about a company which is also a customer of the shop. -""" -type Company implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's main point of contact. -""" -type CompanyContact { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was created in Shopify. - """ - createdAt: DateTime! - - """ - The ID of the company. - """ - id: ID! - - """ - The company contact's locale (language). - """ - locale: String - - """ - The company contact's job title. - """ - title: String - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's location. -""" -type CompanyLocation implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - The preferred locale of the company location. - """ - locale: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company location. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was last modified. - """ - updatedAt: DateTime! -} - -""" -A country. -""" -type Country { - """ - The ISO code of the country. - """ - isoCode: CountryCode! -} - -""" -The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. -If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision -of another country. For example, the territories associated with Spain are represented by the country code `ES`, -and the territories associated with the United States of America are represented by the country code `US`. -""" -enum CountryCode { - """ - Ascension Island. - """ - AC - - """ - Andorra. - """ - AD - - """ - United Arab Emirates. - """ - AE - - """ - Afghanistan. - """ - AF - - """ - Antigua & Barbuda. - """ - AG - - """ - Anguilla. - """ - AI - - """ - Albania. - """ - AL - - """ - Armenia. - """ - AM - - """ - Netherlands Antilles. - """ - AN - - """ - Angola. - """ - AO - - """ - Argentina. - """ - AR - - """ - Austria. - """ - AT - - """ - Australia. - """ - AU - - """ - Aruba. - """ - AW - - """ - Åland Islands. - """ - AX - - """ - Azerbaijan. - """ - AZ - - """ - Bosnia & Herzegovina. - """ - BA - - """ - Barbados. - """ - BB - - """ - Bangladesh. - """ - BD - - """ - Belgium. - """ - BE - - """ - Burkina Faso. - """ - BF - - """ - Bulgaria. - """ - BG - - """ - Bahrain. - """ - BH - - """ - Burundi. - """ - BI - - """ - Benin. - """ - BJ - - """ - St. Barthélemy. - """ - BL - - """ - Bermuda. - """ - BM - - """ - Brunei. - """ - BN - - """ - Bolivia. - """ - BO - - """ - Caribbean Netherlands. - """ - BQ - - """ - Brazil. - """ - BR - - """ - Bahamas. - """ - BS - - """ - Bhutan. - """ - BT - - """ - Bouvet Island. - """ - BV - - """ - Botswana. - """ - BW - - """ - Belarus. - """ - BY - - """ - Belize. - """ - BZ - - """ - Canada. - """ - CA - - """ - Cocos (Keeling) Islands. - """ - CC - - """ - Congo - Kinshasa. - """ - CD - - """ - Central African Republic. - """ - CF - - """ - Congo - Brazzaville. - """ - CG - - """ - Switzerland. - """ - CH - - """ - Côte d’Ivoire. - """ - CI - - """ - Cook Islands. - """ - CK - - """ - Chile. - """ - CL - - """ - Cameroon. - """ - CM - - """ - China. - """ - CN - - """ - Colombia. - """ - CO - - """ - Costa Rica. - """ - CR - - """ - Cuba. - """ - CU - - """ - Cape Verde. - """ - CV - - """ - Curaçao. - """ - CW - - """ - Christmas Island. - """ - CX - - """ - Cyprus. - """ - CY - - """ - Czechia. - """ - CZ - - """ - Germany. - """ - DE - - """ - Djibouti. - """ - DJ - - """ - Denmark. - """ - DK - - """ - Dominica. - """ - DM - - """ - Dominican Republic. - """ - DO - - """ - Algeria. - """ - DZ - - """ - Ecuador. - """ - EC - - """ - Estonia. - """ - EE - - """ - Egypt. - """ - EG - - """ - Western Sahara. - """ - EH - - """ - Eritrea. - """ - ER - - """ - Spain. - """ - ES - - """ - Ethiopia. - """ - ET - - """ - Finland. - """ - FI - - """ - Fiji. - """ - FJ - - """ - Falkland Islands. - """ - FK - - """ - Faroe Islands. - """ - FO - - """ - France. - """ - FR - - """ - Gabon. - """ - GA - - """ - United Kingdom. - """ - GB - - """ - Grenada. - """ - GD - - """ - Georgia. - """ - GE - - """ - French Guiana. - """ - GF - - """ - Guernsey. - """ - GG - - """ - Ghana. - """ - GH - - """ - Gibraltar. - """ - GI - - """ - Greenland. - """ - GL - - """ - Gambia. - """ - GM - - """ - Guinea. - """ - GN - - """ - Guadeloupe. - """ - GP - - """ - Equatorial Guinea. - """ - GQ - - """ - Greece. - """ - GR - - """ - South Georgia & South Sandwich Islands. - """ - GS - - """ - Guatemala. - """ - GT - - """ - Guinea-Bissau. - """ - GW - - """ - Guyana. - """ - GY - - """ - Hong Kong SAR. - """ - HK - - """ - Heard & McDonald Islands. - """ - HM - - """ - Honduras. - """ - HN - - """ - Croatia. - """ - HR - - """ - Haiti. - """ - HT - - """ - Hungary. - """ - HU - - """ - Indonesia. - """ - ID - - """ - Ireland. - """ - IE - - """ - Israel. - """ - IL - - """ - Isle of Man. - """ - IM - - """ - India. - """ - IN - - """ - British Indian Ocean Territory. - """ - IO - - """ - Iraq. - """ - IQ - - """ - Iran. - """ - IR - - """ - Iceland. - """ - IS - - """ - Italy. - """ - IT - - """ - Jersey. - """ - JE - - """ - Jamaica. - """ - JM - - """ - Jordan. - """ - JO - - """ - Japan. - """ - JP - - """ - Kenya. - """ - KE - - """ - Kyrgyzstan. - """ - KG - - """ - Cambodia. - """ - KH - - """ - Kiribati. - """ - KI - - """ - Comoros. - """ - KM - - """ - St. Kitts & Nevis. - """ - KN - - """ - North Korea. - """ - KP - - """ - South Korea. - """ - KR - - """ - Kuwait. - """ - KW - - """ - Cayman Islands. - """ - KY - - """ - Kazakhstan. - """ - KZ - - """ - Laos. - """ - LA - - """ - Lebanon. - """ - LB - - """ - St. Lucia. - """ - LC - - """ - Liechtenstein. - """ - LI - - """ - Sri Lanka. - """ - LK - - """ - Liberia. - """ - LR - - """ - Lesotho. - """ - LS - - """ - Lithuania. - """ - LT - - """ - Luxembourg. - """ - LU - - """ - Latvia. - """ - LV - - """ - Libya. - """ - LY - - """ - Morocco. - """ - MA - - """ - Monaco. - """ - MC - - """ - Moldova. - """ - MD - - """ - Montenegro. - """ - ME - - """ - St. Martin. - """ - MF - - """ - Madagascar. - """ - MG - - """ - North Macedonia. - """ - MK - - """ - Mali. - """ - ML - - """ - Myanmar (Burma). - """ - MM - - """ - Mongolia. - """ - MN - - """ - Macao SAR. - """ - MO - - """ - Martinique. - """ - MQ - - """ - Mauritania. - """ - MR - - """ - Montserrat. - """ - MS - - """ - Malta. - """ - MT - - """ - Mauritius. - """ - MU - - """ - Maldives. - """ - MV - - """ - Malawi. - """ - MW - - """ - Mexico. - """ - MX - - """ - Malaysia. - """ - MY - - """ - Mozambique. - """ - MZ - - """ - Namibia. - """ - NA - - """ - New Caledonia. - """ - NC - - """ - Niger. - """ - NE - - """ - Norfolk Island. - """ - NF - - """ - Nigeria. - """ - NG - - """ - Nicaragua. - """ - NI - - """ - Netherlands. - """ - NL - - """ - Norway. - """ - NO - - """ - Nepal. - """ - NP - - """ - Nauru. - """ - NR - - """ - Niue. - """ - NU - - """ - New Zealand. - """ - NZ - - """ - Oman. - """ - OM - - """ - Panama. - """ - PA - - """ - Peru. - """ - PE - - """ - French Polynesia. - """ - PF - - """ - Papua New Guinea. - """ - PG - - """ - Philippines. - """ - PH - - """ - Pakistan. - """ - PK - - """ - Poland. - """ - PL - - """ - St. Pierre & Miquelon. - """ - PM - - """ - Pitcairn Islands. - """ - PN - - """ - Palestinian Territories. - """ - PS - - """ - Portugal. - """ - PT - - """ - Paraguay. - """ - PY - - """ - Qatar. - """ - QA - - """ - Réunion. - """ - RE - - """ - Romania. - """ - RO - - """ - Serbia. - """ - RS - - """ - Russia. - """ - RU - - """ - Rwanda. - """ - RW - - """ - Saudi Arabia. - """ - SA - - """ - Solomon Islands. - """ - SB - - """ - Seychelles. - """ - SC - - """ - Sudan. - """ - SD - - """ - Sweden. - """ - SE - - """ - Singapore. - """ - SG - - """ - St. Helena. - """ - SH - - """ - Slovenia. - """ - SI - - """ - Svalbard & Jan Mayen. - """ - SJ - - """ - Slovakia. - """ - SK - - """ - Sierra Leone. - """ - SL - - """ - San Marino. - """ - SM - - """ - Senegal. - """ - SN - - """ - Somalia. - """ - SO - - """ - Suriname. - """ - SR - - """ - South Sudan. - """ - SS - - """ - São Tomé & Príncipe. - """ - ST - - """ - El Salvador. - """ - SV - - """ - Sint Maarten. - """ - SX - - """ - Syria. - """ - SY - - """ - Eswatini. - """ - SZ - - """ - Tristan da Cunha. - """ - TA - - """ - Turks & Caicos Islands. - """ - TC - - """ - Chad. - """ - TD - - """ - French Southern Territories. - """ - TF - - """ - Togo. - """ - TG - - """ - Thailand. - """ - TH - - """ - Tajikistan. - """ - TJ - - """ - Tokelau. - """ - TK - - """ - Timor-Leste. - """ - TL - - """ - Turkmenistan. - """ - TM - - """ - Tunisia. - """ - TN - - """ - Tonga. - """ - TO - - """ - Türkiye. - """ - TR - - """ - Trinidad & Tobago. - """ - TT - - """ - Tuvalu. - """ - TV - - """ - Taiwan. - """ - TW - - """ - Tanzania. - """ - TZ - - """ - Ukraine. - """ - UA - - """ - Uganda. - """ - UG - - """ - U.S. Outlying Islands. - """ - UM - - """ - United States. - """ - US - - """ - Uruguay. - """ - UY - - """ - Uzbekistan. - """ - UZ - - """ - Vatican City. - """ - VA - - """ - St. Vincent & Grenadines. - """ - VC - - """ - Venezuela. - """ - VE - - """ - British Virgin Islands. - """ - VG - - """ - Vietnam. - """ - VN - - """ - Vanuatu. - """ - VU - - """ - Wallis & Futuna. - """ - WF - - """ - Samoa. - """ - WS - - """ - Kosovo. - """ - XK - - """ - Yemen. - """ - YE - - """ - Mayotte. - """ - YT - - """ - South Africa. - """ - ZA - - """ - Zambia. - """ - ZM - - """ - Zimbabwe. - """ - ZW - - """ - Unknown Region. - """ - ZZ -} - -""" -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. -""" -enum CurrencyCode { - """ - United Arab Emirates Dirham (AED). - """ - AED - - """ - Afghan Afghani (AFN). - """ - AFN - - """ - Albanian Lek (ALL). - """ - ALL - - """ - Armenian Dram (AMD). - """ - AMD - - """ - Netherlands Antillean Guilder. - """ - ANG - - """ - Angolan Kwanza (AOA). - """ - AOA - - """ - Argentine Pesos (ARS). - """ - ARS - - """ - Australian Dollars (AUD). - """ - AUD - - """ - Aruban Florin (AWG). - """ - AWG - - """ - Azerbaijani Manat (AZN). - """ - AZN - - """ - Bosnia and Herzegovina Convertible Mark (BAM). - """ - BAM - - """ - Barbadian Dollar (BBD). - """ - BBD - - """ - Bangladesh Taka (BDT). - """ - BDT - - """ - Bulgarian Lev (BGN). - """ - BGN - - """ - Bahraini Dinar (BHD). - """ - BHD - - """ - Burundian Franc (BIF). - """ - BIF - - """ - Bermudian Dollar (BMD). - """ - BMD - - """ - Brunei Dollar (BND). - """ - BND - - """ - Bolivian Boliviano (BOB). - """ - BOB - - """ - Brazilian Real (BRL). - """ - BRL - - """ - Bahamian Dollar (BSD). - """ - BSD - - """ - Bhutanese Ngultrum (BTN). - """ - BTN - - """ - Botswana Pula (BWP). - """ - BWP - - """ - Belarusian Ruble (BYN). - """ - BYN - - """ - Belarusian Ruble (BYR). - """ - BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") - - """ - Belize Dollar (BZD). - """ - BZD - - """ - Canadian Dollars (CAD). - """ - CAD - - """ - Congolese franc (CDF). - """ - CDF - - """ - Swiss Francs (CHF). - """ - CHF - - """ - Chilean Peso (CLP). - """ - CLP - - """ - Chinese Yuan Renminbi (CNY). - """ - CNY - - """ - Colombian Peso (COP). - """ - COP - - """ - Costa Rican Colones (CRC). - """ - CRC - - """ - Cape Verdean escudo (CVE). - """ - CVE - - """ - Czech Koruny (CZK). - """ - CZK - - """ - Djiboutian Franc (DJF). - """ - DJF - - """ - Danish Kroner (DKK). - """ - DKK - - """ - Dominican Peso (DOP). - """ - DOP - - """ - Algerian Dinar (DZD). - """ - DZD - - """ - Egyptian Pound (EGP). - """ - EGP - - """ - Eritrean Nakfa (ERN). - """ - ERN - - """ - Ethiopian Birr (ETB). - """ - ETB - - """ - Euro (EUR). - """ - EUR - - """ - Fijian Dollars (FJD). - """ - FJD - - """ - Falkland Islands Pounds (FKP). - """ - FKP - - """ - United Kingdom Pounds (GBP). - """ - GBP - - """ - Georgian Lari (GEL). - """ - GEL - - """ - Ghanaian Cedi (GHS). - """ - GHS - - """ - Gibraltar Pounds (GIP). - """ - GIP - - """ - Gambian Dalasi (GMD). - """ - GMD - - """ - Guinean Franc (GNF). - """ - GNF - - """ - Guatemalan Quetzal (GTQ). - """ - GTQ - - """ - Guyanese Dollar (GYD). - """ - GYD - - """ - Hong Kong Dollars (HKD). - """ - HKD - - """ - Honduran Lempira (HNL). - """ - HNL - - """ - Croatian Kuna (HRK). - """ - HRK - - """ - Haitian Gourde (HTG). - """ - HTG - - """ - Hungarian Forint (HUF). - """ - HUF - - """ - Indonesian Rupiah (IDR). - """ - IDR - - """ - Israeli New Shekel (NIS). - """ - ILS - - """ - Indian Rupees (INR). - """ - INR - - """ - Iraqi Dinar (IQD). - """ - IQD - - """ - Iranian Rial (IRR). - """ - IRR - - """ - Icelandic Kronur (ISK). - """ - ISK - - """ - Jersey Pound. - """ - JEP - - """ - Jamaican Dollars (JMD). - """ - JMD - - """ - Jordanian Dinar (JOD). - """ - JOD - - """ - Japanese Yen (JPY). - """ - JPY - - """ - Kenyan Shilling (KES). - """ - KES - - """ - Kyrgyzstani Som (KGS). - """ - KGS - - """ - Cambodian Riel. - """ - KHR - - """ - Kiribati Dollar (KID). - """ - KID - - """ - Comorian Franc (KMF). - """ - KMF - - """ - South Korean Won (KRW). - """ - KRW - - """ - Kuwaiti Dinar (KWD). - """ - KWD - - """ - Cayman Dollars (KYD). - """ - KYD - - """ - Kazakhstani Tenge (KZT). - """ - KZT - - """ - Laotian Kip (LAK). - """ - LAK - - """ - Lebanese Pounds (LBP). - """ - LBP - - """ - Sri Lankan Rupees (LKR). - """ - LKR - - """ - Liberian Dollar (LRD). - """ - LRD - - """ - Lesotho Loti (LSL). - """ - LSL - - """ - Lithuanian Litai (LTL). - """ - LTL - - """ - Latvian Lati (LVL). - """ - LVL - - """ - Libyan Dinar (LYD). - """ - LYD - - """ - Moroccan Dirham. - """ - MAD - - """ - Moldovan Leu (MDL). - """ - MDL - - """ - Malagasy Ariary (MGA). - """ - MGA - - """ - Macedonia Denar (MKD). - """ - MKD - - """ - Burmese Kyat (MMK). - """ - MMK - - """ - Mongolian Tugrik. - """ - MNT - - """ - Macanese Pataca (MOP). - """ - MOP - - """ - Mauritanian Ouguiya (MRU). - """ - MRU - - """ - Mauritian Rupee (MUR). - """ - MUR - - """ - Maldivian Rufiyaa (MVR). - """ - MVR - - """ - Malawian Kwacha (MWK). - """ - MWK - - """ - Mexican Pesos (MXN). - """ - MXN - - """ - Malaysian Ringgits (MYR). - """ - MYR - - """ - Mozambican Metical. - """ - MZN - - """ - Namibian Dollar. - """ - NAD - - """ - Nigerian Naira (NGN). - """ - NGN - - """ - Nicaraguan Córdoba (NIO). - """ - NIO - - """ - Norwegian Kroner (NOK). - """ - NOK - - """ - Nepalese Rupee (NPR). - """ - NPR - - """ - New Zealand Dollars (NZD). - """ - NZD - - """ - Omani Rial (OMR). - """ - OMR - - """ - Panamian Balboa (PAB). - """ - PAB - - """ - Peruvian Nuevo Sol (PEN). - """ - PEN - - """ - Papua New Guinean Kina (PGK). - """ - PGK - - """ - Philippine Peso (PHP). - """ - PHP - - """ - Pakistani Rupee (PKR). - """ - PKR - - """ - Polish Zlotych (PLN). - """ - PLN - - """ - Paraguayan Guarani (PYG). - """ - PYG - - """ - Qatari Rial (QAR). - """ - QAR - - """ - Romanian Lei (RON). - """ - RON - - """ - Serbian dinar (RSD). - """ - RSD - - """ - Russian Rubles (RUB). - """ - RUB - - """ - Rwandan Franc (RWF). - """ - RWF - - """ - Saudi Riyal (SAR). - """ - SAR - - """ - Solomon Islands Dollar (SBD). - """ - SBD - - """ - Seychellois Rupee (SCR). - """ - SCR - - """ - Sudanese Pound (SDG). - """ - SDG - - """ - Swedish Kronor (SEK). - """ - SEK - - """ - Singapore Dollars (SGD). - """ - SGD - - """ - Saint Helena Pounds (SHP). - """ - SHP - - """ - Sierra Leonean Leone (SLL). - """ - SLL - - """ - Somali Shilling (SOS). - """ - SOS - - """ - Surinamese Dollar (SRD). - """ - SRD - - """ - South Sudanese Pound (SSP). - """ - SSP - - """ - Sao Tome And Principe Dobra (STD). - """ - STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") - - """ - Sao Tome And Principe Dobra (STN). - """ - STN - - """ - Syrian Pound (SYP). - """ - SYP - - """ - Swazi Lilangeni (SZL). - """ - SZL - - """ - Thai baht (THB). - """ - THB - - """ - Tajikistani Somoni (TJS). - """ - TJS - - """ - Turkmenistani Manat (TMT). - """ - TMT - - """ - Tunisian Dinar (TND). - """ - TND - - """ - Tongan Pa'anga (TOP). - """ - TOP - - """ - Turkish Lira (TRY). - """ - TRY - - """ - Trinidad and Tobago Dollars (TTD). - """ - TTD - - """ - Taiwan Dollars (TWD). - """ - TWD - - """ - Tanzanian Shilling (TZS). - """ - TZS - - """ - Ukrainian Hryvnia (UAH). - """ - UAH - - """ - Ugandan Shilling (UGX). - """ - UGX - - """ - United States Dollars (USD). - """ - USD - - """ - Uruguayan Pesos (UYU). - """ - UYU - - """ - Uzbekistan som (UZS). - """ - UZS - - """ - Venezuelan Bolivares (VED). - """ - VED - - """ - Venezuelan Bolivares (VEF). - """ - VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") - - """ - Venezuelan Bolivares Soberanos (VES). - """ - VES - - """ - Vietnamese đồng (VND). - """ - VND - - """ - Vanuatu Vatu (VUV). - """ - VUV - - """ - Samoan Tala (WST). - """ - WST - - """ - Central African CFA Franc (XAF). - """ - XAF - - """ - East Caribbean Dollar (XCD). - """ - XCD - - """ - West African CFA franc (XOF). - """ - XOF - - """ - CFP Franc (XPF). - """ - XPF - - """ - Unrecognized currency. - """ - XXX - - """ - Yemeni Rial (YER). - """ - YER - - """ - South African Rand (ZAR). - """ - ZAR - - """ - Zambian Kwacha (ZMW). - """ - ZMW -} - -""" -A custom product. -""" -type CustomProduct { - """ - Whether the merchandise is a gift card. - """ - isGiftCard: Boolean! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents a customer with the shop. -""" -type Customer implements HasMetafields { - """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. - """ - amountSpent: MoneyV2! - - """ - The customer’s name, email or phone number. - """ - displayName: String! - - """ - The customer’s email address. - """ - email: String - - """ - The customer's first name. - """ - firstName: String - - """ - Whether the customer has any of the given tags. - """ - hasAnyTag( - """ - The tags to search for. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the customer has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A unique identifier for the customer. - """ - id: ID! - - """ - The customer's last name. - """ - lastName: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The number of orders made by the customer. - """ - numberOfOrders: Int! -} - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. -For example, September 7, 2019 is represented as `"2019-07-16"`. -""" -scalar Date - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. -For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is -represented as `"2019-09-07T15:50:00Z`". -""" -scalar DateTime - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the date and time but not the timezone which is determined from context. - -For example, "2018-01-01T00:00:00". -""" -scalar DateTimeWithoutTimezone - -""" -A signed decimal number, which supports arbitrary precision and is serialized as a string. - -Example values: `"29.99"`, `"29.999"`. -""" -scalar Decimal - -""" -Represents information about the merchandise in the cart. -""" -type DeliverableCartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! -} - -""" -List of different delivery method types. -""" -enum DeliveryMethod { - """ - Local Delivery. - """ - LOCAL - - """ - None. - """ - NONE - - """ - Shipping to a Pickup Point. - """ - PICKUP_POINT - - """ - Local Pickup. - """ - PICK_UP - - """ - Retail. - """ - RETAIL - - """ - Shipping. - """ - SHIPPING -} - -""" -The discount to be applied. -""" -input Discount { - """ - The discount message. - """ - message: String - - """ - The targets of the discount. - - This argument accepts a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. - """ - targets: [Target!]! - - """ - The value of the discount. - """ - value: Value! -} - -""" -The strategy that's applied to the list of discounts. -""" -enum DiscountApplicationStrategy { - """ - Apply all discounts with conditions that are satisfied. This does not override discount combination or stacking rules. - """ - ALL - - """ - Only apply the first discount with conditions that are satisfied. - """ - FIRST - - """ - Only apply the discount that offers the maximum reduction. - """ - MAXIMUM -} - -""" -A discount wrapper node. -""" -type DiscountNode implements HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A fixed amount value. -""" -input FixedAmount { - """ - The fixed amount value of the discount, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! - - """ - Whether to apply the value to each entitled item. - - The default value is `false`, which causes the value to be applied once across the entitled items. - When the value is `true`, the value will be applied to each of the entitled items. - """ - appliesToEachItem: Boolean -} - -""" -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. -""" -input FunctionResult { - """ - The strategy to apply the list of discounts. - """ - discountApplicationStrategy: DiscountApplicationStrategy! - - """ - The list of discounts to be applied. - """ - discounts: [Discount!]! -} - -""" -The run target result. -""" -input FunctionRunResult { - """ - The strategy to apply the list of discounts. - """ - discountApplicationStrategy: DiscountApplicationStrategy! - - """ - The list of discounts to be applied. - """ - discounts: [Discount!]! -} - -""" -A function-scoped handle to a refer a resource. -The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. -Example value: `"10079785100"` -""" -scalar Handle - -""" -Represents information about the metafields associated to the specified resource. -""" -interface HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents whether the current object has the given tag. -""" -type HasTagResponse { - """ - Whether the current object has the tag. - """ - hasTag: Boolean! - - """ - The tag. - """ - tag: String! -} - -""" -Represents a unique identifier, often used to refetch an object. -The ID type appears in a JSON response as a String, but it is not intended to be human-readable. - -Example value: `"gid://shopify/Product/10079785100"` -""" -scalar ID - -""" -The input object for the function. -""" -type Input { - """ - The cart. - """ - cart: Cart! - - """ - The discount node executing the function. - """ - discountNode: DiscountNode! - - """ - The localization of the Function execution context. - """ - localization: Localization! - - """ - The conversion rate between the shop's currency and the currency of the cart. - """ - presentmentCurrencyRate: Decimal! - - """ - Information about the shop. - """ - shop: Shop! -} - -""" -A [JSON](https://www.json.org/json-en.html) object. - -Example value: -`{ - "product": { - "id": "gid://shopify/Product/1346443542550", - "title": "White T-shirt", - "options": [{ - "name": "Size", - "values": ["M", "L"] - }] - } -}` -""" -scalar JSON - -""" -A language. -""" -type Language { - """ - The ISO code. - """ - isoCode: LanguageCode! -} - -""" -Language codes supported by Shopify. -""" -enum LanguageCode { - """ - Afrikaans. - """ - AF - - """ - Akan. - """ - AK - - """ - Amharic. - """ - AM - - """ - Arabic. - """ - AR - - """ - Assamese. - """ - AS - - """ - Azerbaijani. - """ - AZ - - """ - Belarusian. - """ - BE - - """ - Bulgarian. - """ - BG - - """ - Bambara. - """ - BM - - """ - Bangla. - """ - BN - - """ - Tibetan. - """ - BO - - """ - Breton. - """ - BR - - """ - Bosnian. - """ - BS - - """ - Catalan. - """ - CA - - """ - Chechen. - """ - CE - - """ - Central Kurdish. - """ - CKB - - """ - Czech. - """ - CS - - """ - Church Slavic. - """ - CU - - """ - Welsh. - """ - CY - - """ - Danish. - """ - DA - - """ - German. - """ - DE - - """ - Dzongkha. - """ - DZ - - """ - Ewe. - """ - EE - - """ - Greek. - """ - EL - - """ - English. - """ - EN - - """ - Esperanto. - """ - EO - - """ - Spanish. - """ - ES - - """ - Estonian. - """ - ET - - """ - Basque. - """ - EU - - """ - Persian. - """ - FA - - """ - Fulah. - """ - FF - - """ - Finnish. - """ - FI - - """ - Filipino. - """ - FIL - - """ - Faroese. - """ - FO - - """ - French. - """ - FR - - """ - Western Frisian. - """ - FY - - """ - Irish. - """ - GA - - """ - Scottish Gaelic. - """ - GD - - """ - Galician. - """ - GL - - """ - Gujarati. - """ - GU - - """ - Manx. - """ - GV - - """ - Hausa. - """ - HA - - """ - Hebrew. - """ - HE - - """ - Hindi. - """ - HI - - """ - Croatian. - """ - HR - - """ - Hungarian. - """ - HU - - """ - Armenian. - """ - HY - - """ - Interlingua. - """ - IA - - """ - Indonesian. - """ - ID - - """ - Igbo. - """ - IG - - """ - Sichuan Yi. - """ - II - - """ - Icelandic. - """ - IS - - """ - Italian. - """ - IT - - """ - Japanese. - """ - JA - - """ - Javanese. - """ - JV - - """ - Georgian. - """ - KA - - """ - Kikuyu. - """ - KI - - """ - Kazakh. - """ - KK - - """ - Kalaallisut. - """ - KL - - """ - Khmer. - """ - KM - - """ - Kannada. - """ - KN - - """ - Korean. - """ - KO - - """ - Kashmiri. - """ - KS - - """ - Kurdish. - """ - KU - - """ - Cornish. - """ - KW - - """ - Kyrgyz. - """ - KY - - """ - Luxembourgish. - """ - LB - - """ - Ganda. - """ - LG - - """ - Lingala. - """ - LN - - """ - Lao. - """ - LO - - """ - Lithuanian. - """ - LT - - """ - Luba-Katanga. - """ - LU - - """ - Latvian. - """ - LV - - """ - Malagasy. - """ - MG - - """ - Māori. - """ - MI - - """ - Macedonian. - """ - MK - - """ - Malayalam. - """ - ML - - """ - Mongolian. - """ - MN - - """ - Marathi. - """ - MR - - """ - Malay. - """ - MS - - """ - Maltese. - """ - MT - - """ - Burmese. - """ - MY - - """ - Norwegian (Bokmål). - """ - NB - - """ - North Ndebele. - """ - ND - - """ - Nepali. - """ - NE - - """ - Dutch. - """ - NL - - """ - Norwegian Nynorsk. - """ - NN - - """ - Norwegian. - """ - NO - - """ - Oromo. - """ - OM - - """ - Odia. - """ - OR - - """ - Ossetic. - """ - OS - - """ - Punjabi. - """ - PA - - """ - Polish. - """ - PL - - """ - Pashto. - """ - PS - - """ - Portuguese. - """ - PT - - """ - Portuguese (Brazil). - """ - PT_BR - - """ - Portuguese (Portugal). - """ - PT_PT - - """ - Quechua. - """ - QU - - """ - Romansh. - """ - RM - - """ - Rundi. - """ - RN - - """ - Romanian. - """ - RO - - """ - Russian. - """ - RU - - """ - Kinyarwanda. - """ - RW - - """ - Sanskrit. - """ - SA - - """ - Sardinian. - """ - SC - - """ - Sindhi. - """ - SD - - """ - Northern Sami. - """ - SE - - """ - Sango. - """ - SG - - """ - Sinhala. - """ - SI - - """ - Slovak. - """ - SK - - """ - Slovenian. - """ - SL - - """ - Shona. - """ - SN - - """ - Somali. - """ - SO - - """ - Albanian. - """ - SQ - - """ - Serbian. - """ - SR - - """ - Sundanese. - """ - SU - - """ - Swedish. - """ - SV - - """ - Swahili. - """ - SW - - """ - Tamil. - """ - TA - - """ - Telugu. - """ - TE - - """ - Tajik. - """ - TG - - """ - Thai. - """ - TH - - """ - Tigrinya. - """ - TI - - """ - Turkmen. - """ - TK - - """ - Tongan. - """ - TO - - """ - Turkish. - """ - TR - - """ - Tatar. - """ - TT - - """ - Uyghur. - """ - UG - - """ - Ukrainian. - """ - UK - - """ - Urdu. - """ - UR - - """ - Uzbek. - """ - UZ - - """ - Vietnamese. - """ - VI - - """ - Volapük. - """ - VO - - """ - Wolof. - """ - WO - - """ - Xhosa. - """ - XH - - """ - Yiddish. - """ - YI - - """ - Yoruba. - """ - YO - - """ - Chinese. - """ - ZH - - """ - Chinese (Simplified). - """ - ZH_CN - - """ - Chinese (Traditional). - """ - ZH_TW - - """ - Zulu. - """ - ZU -} - -""" -Represents limited information about the current time relative to the parent object. -""" -type LocalTime { - """ - The current date relative to the parent object. - """ - date: Date! - - """ - Returns true if the current date and time is at or past the given date and time, and false otherwise. - """ - dateTimeAfter( - """ - The date and time to compare against, assumed to be in the timezone of the parent object. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is before the given date and time, and false otherwise. - """ - dateTimeBefore( - """ - The date and time to compare against, assumed to be in the timezone of the parent timezone. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is between the two given date and times, and false otherwise. - """ - dateTimeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endDateTime: DateTimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startDateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeAfter( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeBefore( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is between the two given times, and false otherwise. - """ - timeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endTime: TimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startTime: TimeWithoutTimezone! - ): Boolean! -} - -""" -Information about the localized experiences configured for the shop. -""" -type Localization { - """ - The country of the active localized experience. - """ - country: Country! - - """ - The language of the active localized experience. - """ - language: Language! - - """ - The market of the active localized experience. - """ - market: Market! -} - -""" -Represents the value captured by a localized field. Localized fields are -additional fields required by certain countries on international orders. For -example, some countries require additional fields for customs information or tax -identification numbers. -""" -type LocalizedField { - """ - The key of the localized field. - """ - key: LocalizedFieldKey! - - """ - The title of the localized field. - """ - title: String! - - """ - The value of the localized field. - """ - value: String -} - -""" -Unique key identifying localized fields. -""" -enum LocalizedFieldKey { - """ - Localized field key 'shipping_credential_br' for country BR. - """ - SHIPPING_CREDENTIAL_BR - - """ - Localized field key 'shipping_credential_cl' for country CL. - """ - SHIPPING_CREDENTIAL_CL - - """ - Localized field key 'shipping_credential_cn' for country CN. - """ - SHIPPING_CREDENTIAL_CN - - """ - Localized field key 'shipping_credential_co' for country CO. - """ - SHIPPING_CREDENTIAL_CO - - """ - Localized field key 'shipping_credential_cr' for country CR. - """ - SHIPPING_CREDENTIAL_CR - - """ - Localized field key 'shipping_credential_ec' for country EC. - """ - SHIPPING_CREDENTIAL_EC - - """ - Localized field key 'shipping_credential_es' for country ES. - """ - SHIPPING_CREDENTIAL_ES - - """ - Localized field key 'shipping_credential_gt' for country GT. - """ - SHIPPING_CREDENTIAL_GT - - """ - Localized field key 'shipping_credential_id' for country ID. - """ - SHIPPING_CREDENTIAL_ID - - """ - Localized field key 'shipping_credential_kr' for country KR. - """ - SHIPPING_CREDENTIAL_KR - - """ - Localized field key 'shipping_credential_mx' for country MX. - """ - SHIPPING_CREDENTIAL_MX - - """ - Localized field key 'shipping_credential_my' for country MY. - """ - SHIPPING_CREDENTIAL_MY - - """ - Localized field key 'shipping_credential_pe' for country PE. - """ - SHIPPING_CREDENTIAL_PE - - """ - Localized field key 'shipping_credential_pt' for country PT. - """ - SHIPPING_CREDENTIAL_PT - - """ - Localized field key 'shipping_credential_py' for country PY. - """ - SHIPPING_CREDENTIAL_PY - - """ - Localized field key 'shipping_credential_tr' for country TR. - """ - SHIPPING_CREDENTIAL_TR - - """ - Localized field key 'shipping_credential_tw' for country TW. - """ - SHIPPING_CREDENTIAL_TW - - """ - Localized field key 'shipping_credential_type_co' for country CO. - """ - SHIPPING_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_br' for country BR. - """ - TAX_CREDENTIAL_BR - - """ - Localized field key 'tax_credential_cl' for country CL. - """ - TAX_CREDENTIAL_CL - - """ - Localized field key 'tax_credential_co' for country CO. - """ - TAX_CREDENTIAL_CO - - """ - Localized field key 'tax_credential_cr' for country CR. - """ - TAX_CREDENTIAL_CR - - """ - Localized field key 'tax_credential_ec' for country EC. - """ - TAX_CREDENTIAL_EC - - """ - Localized field key 'tax_credential_es' for country ES. - """ - TAX_CREDENTIAL_ES - - """ - Localized field key 'tax_credential_gt' for country GT. - """ - TAX_CREDENTIAL_GT - - """ - Localized field key 'tax_credential_id' for country ID. - """ - TAX_CREDENTIAL_ID - - """ - Localized field key 'tax_credential_it' for country IT. - """ - TAX_CREDENTIAL_IT - - """ - Localized field key 'tax_credential_mx' for country MX. - """ - TAX_CREDENTIAL_MX - - """ - Localized field key 'tax_credential_my' for country MY. - """ - TAX_CREDENTIAL_MY - - """ - Localized field key 'tax_credential_pe' for country PE. - """ - TAX_CREDENTIAL_PE - - """ - Localized field key 'tax_credential_pt' for country PT. - """ - TAX_CREDENTIAL_PT - - """ - Localized field key 'tax_credential_py' for country PY. - """ - TAX_CREDENTIAL_PY - - """ - Localized field key 'tax_credential_tr' for country TR. - """ - TAX_CREDENTIAL_TR - - """ - Localized field key 'tax_credential_type_co' for country CO. - """ - TAX_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_type_mx' for country MX. - """ - TAX_CREDENTIAL_TYPE_MX - - """ - Localized field key 'tax_credential_use_mx' for country MX. - """ - TAX_CREDENTIAL_USE_MX - - """ - Localized field key 'tax_email_it' for country IT. - """ - TAX_EMAIL_IT -} - -""" -Represents a mailing address. -""" -type MailingAddress { - """ - The first line of the address. Typically the street address or PO Box number. - """ - address1: String - - """ - The second line of the address. Typically the number of the apartment, suite, or unit. - """ - address2: String - - """ - The name of the city, district, village, or town. - """ - city: String - - """ - The name of the customer's company or organization. - """ - company: String - - """ - The two-letter code for the country of the address. For example, US. - """ - countryCode: CountryCode - - """ - The first name of the customer. - """ - firstName: String - - """ - The last name of the customer. - """ - lastName: String - - """ - The approximate latitude of the address. - """ - latitude: Float - - """ - The approximate longitude of the address. - """ - longitude: Float - - """ - The market of the address. - """ - market: Market - - """ - The full name of the customer, based on firstName and lastName. - """ - name: String - - """ - A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. - """ - phone: String - - """ - The alphanumeric code for the region. For example, ON. - """ - provinceCode: String - - """ - The zip or postal code of the address. - """ - zip: String -} - -""" -A market is a group of one or more regions that you want to target for international sales. -By creating a market, you can configure a distinct, localized shopping experience for -customers from a specific area of the world. For example, you can -[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), -[configure international pricing](https://shopify.dev/api/examples/product-price-lists), -or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). -""" -type Market implements HasMetafields { - """ - A human-readable unique string for the market automatically generated from its title. - """ - handle: Handle! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - A geographic region which comprises a market. - """ - regions: [MarketRegion!]! -} - -""" -Represents a region. -""" -interface MarketRegion { - """ - The name of the region in the language of the current localization. - """ - name: String -} - -""" -A country which comprises a market. -""" -type MarketRegionCountry implements MarketRegion { - """ - The two-letter code for the country. - """ - code: CountryCode! - - """ - The country name in the language of the current localization. - """ - name: String! -} - -""" -The merchandise to be purchased at checkout. -""" -union Merchandise = CustomProduct | ProductVariant - -""" -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). -""" -type Metafield { - """ - The data stored in the metafield in JSON format. - """ - jsonValue: JSON! - - """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). - """ - type: String! - - """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. - """ - value: String! -} - -""" -A monetary value with currency. -""" -type MoneyV2 { - """ - Decimal money amount. - """ - amount: Decimal! - - """ - Currency of the money. - """ - currencyCode: CurrencyCode! -} - -""" -The root mutation for the API. -""" -type MutationRoot { - """ - Handles the Function result. - """ - handleResult( - """ - The result of the Function. - """ - result: FunctionResult! - ): Void! @deprecated(reason: "Use the target-specific field instead.") - - """ - Handles the Function result for the purchase.product-discount.run target. - """ - run( - """ - The result of the Function. - """ - result: FunctionRunResult! - ): Void! -} - -""" -A percentage value. -""" -input Percentage { - """ - The percentage value. - - The value is validated against: >= 0 and <= 100. - """ - value: Decimal! -} - -""" -Represents a product. -""" -type Product implements HasMetafields { - """ - A unique human-friendly string of the product's title. - """ - handle: Handle! - - """ - Whether the product has any of the given tags. - """ - hasAnyTag( - """ - The tags to check. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the product has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Whether the product is in any of the given collections. - """ - inAnyCollection( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): Boolean! - - """ - Whether the product is in the given collections. - """ - inCollections( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): [CollectionMembership!]! - - """ - Whether the product is a gift card. - """ - isGiftCard: Boolean! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product type specified by the merchant. - """ - productType: String - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The name of the product's vendor. - """ - vendor: String -} - -""" -Represents a product variant. -""" -type ProductVariant implements HasMetafields { - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product that this variant belongs to. - """ - product: Product! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. - """ - sku: String - - """ - The localized title of the product variant in the customer’s locale. - """ - title: String - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an -optional quantity limit. -""" -input ProductVariantTarget { - """ - The ID of the targeted product variant. - """ - id: ID! - - """ - The maximum number of line item units to be discounted. - The default value is `null`, which represents the total quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type PurchasingCompany { - """ - The company associated to the order or draft order. - """ - company: Company! - - """ - The company contact associated to the order or draft order. - """ - contact: CompanyContact - - """ - The company location associated to the order or draft order. - """ - location: CompanyLocation! -} - -""" -Represents how products and variants can be sold and purchased. -""" -type SellingPlan implements HasMetafields { - """ - The description of the selling plan. - """ - description: String - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. - """ - name: String! - - """ - Whether purchasing the selling plan will result in multiple deliveries. - """ - recurringDeliveries: Boolean! -} - -""" -Represents an association between a variant and a selling plan. Selling plan -allocations describe the options offered for each variant, and the price of the -variant when purchased with a selling plan. -""" -type SellingPlanAllocation { - """ - A list of price adjustments, with a maximum of two. When there are two, the - first price adjustment goes into effect at the time of purchase, while the - second one starts after a certain number of orders. A price adjustment - represents how a selling plan affects pricing when a variant is purchased with - a selling plan. Prices display in the customer's currency if the shop is - configured for it. - """ - priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! - - """ - A representation of how products and variants can be sold and purchased. For - example, an individual selling plan could be '6 weeks of prepaid granola, - delivered weekly'. - """ - sellingPlan: SellingPlan! -} - -""" -The resulting prices for variants when they're purchased with a specific selling plan. -""" -type SellingPlanAllocationPriceAdjustment { - """ - The effective price for a single delivery. For example, for a prepaid - subscription plan that includes 6 deliveries at the price of $48.00, the per - delivery price is $8.00. - """ - perDeliveryPrice: MoneyV2! - - """ - The price of the variant when it's purchased with a selling plan For example, - for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, - where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. - """ - price: MoneyV2! -} - -""" -Information about the shop. -""" -type Shop implements HasMetafields { - """ - Information about the current time relative to the shop's timezone setting. - """ - localTime: LocalTime! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A target of a discount, which determines which cart line(s) the discount will affect. - -A discount can have a collection of either `ProductVariantTarget`s or `CartLineTarget`s, but not both. - -Multiple targets with the same type and ID are the same as a single target of that type and ID with their -quantities added together, or `null` if any of those targets have a quantity of `null`. - -See the [Product Discount API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. -""" -input Target @oneOf { - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. - """ - cartLine: CartLineTarget - - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that can apply to any cart lines for a specific product variant, up to an - optional quantity limit. - """ - productVariant: ProductVariantTarget -} - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the time but not the date or timezone which is determined from context. -For example, "05:43:21". -""" -scalar TimeWithoutTimezone - -""" -The value of the discount. -""" -input Value @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -A void type that can be used to return a null value from a mutation. -""" -scalar Void - -""" -Units of measurement for weight. -""" -enum WeightUnit { - """ - Metric system unit of mass. - """ - GRAMS - - """ - 1 kilogram equals 1000 grams. - """ - KILOGRAMS - - """ - Imperial system unit of mass. - """ - OUNCES - - """ - 1 pound equals 16 ounces. - """ - POUNDS -} diff --git a/discounts/wasm/discounts/default/shopify.extension.toml.liquid b/discounts/wasm/discounts/default/shopify.extension.toml.liquid deleted file mode 100644 index 90f30061..00000000 --- a/discounts/wasm/discounts/default/shopify.extension.toml.liquid +++ /dev/null @@ -1,37 +0,0 @@ -api_version = "2025-01" - -[[extensions]] -name = "t:name" -handle = "{{handle}}" -type = "function" -{% if uid %}uid = "{{ uid }}"{% endif %} -description = "t:description" - - [[extensions.targeting]] - target = "purchase.discount.cart_run" - input_query = "src/run.graphql" - export = "cart_run" - - [[extensions.targeting]] - target = "purchase.discount.cart_fetch" - input_query = "src/run.graphql" - export = "cart_fetch" - - [[extensions.targeting]] - target = "purchase.discount.delivery_run" - input_query = "src/run.graphql" - export = "delivery_run" - - [[extensions.targeting]] - target = "purchase.discount.delivery_fetch" - input_query = "src/run.graphql" - export = "delivery_fetch" - - [extensions.build] - command = "echo 'build the wasm'" - path = "" - watch = [] - - [extensions.ui.paths] - create = "/" - details = "/" From d24616010877a1774d243ba237e75e3916cebc2f Mon Sep 17 00:00:00 2001 From: Jonathan Hamel Date: Fri, 24 Jan 2025 09:08:16 -0500 Subject: [PATCH 4/5] discount using metafield and rest from actual cart --- .../default/src/fetch.graphql.liquid | 8 +- .../discounts/default/src/run.graphql.liquid | 19 + discounts/rust/discounts/default/src/run.rs | 418 ++++++++++++------ 3 files changed, 301 insertions(+), 144 deletions(-) diff --git a/discounts/rust/discounts/default/src/fetch.graphql.liquid b/discounts/rust/discounts/default/src/fetch.graphql.liquid index bc740d91..be0dd36d 100644 --- a/discounts/rust/discounts/default/src/fetch.graphql.liquid +++ b/discounts/rust/discounts/default/src/fetch.graphql.liquid @@ -1,7 +1,7 @@ query Input { - discountNode { - metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { - value - } + cart { + buyerIdentity { + email + } } } diff --git a/discounts/rust/discounts/default/src/run.graphql.liquid b/discounts/rust/discounts/default/src/run.graphql.liquid index 2387c479..397fa5c5 100644 --- a/discounts/rust/discounts/default/src/run.graphql.liquid +++ b/discounts/rust/discounts/default/src/run.graphql.liquid @@ -1,5 +1,24 @@ query Input { fetchResult { body + status + } + cart { + deliveryGroups { + id + } + lines { + id + cost { + subtotalAmount { + amount + } + } + } + } + discountNode { + metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { + value + } } } diff --git a/discounts/rust/discounts/default/src/run.rs b/discounts/rust/discounts/default/src/run.rs index f53acfd9..e5d70d22 100644 --- a/discounts/rust/discounts/default/src/run.rs +++ b/discounts/rust/discounts/default/src/run.rs @@ -1,21 +1,61 @@ use serde::{de::DeserializeOwned, Deserialize}; +use serde_json::json; use shopify_function::prelude::*; use shopify_function::Result; -use cart_fetch::output::FunctionCartFetchResult; -use cart_run::output::FunctionCartRunResult; +use cart_fetch::output::{ + FunctionCartFetchResult, HttpRequest as CartHttpRequest, + HttpRequestMethod as CartHttpRequestMethod, HttpRequestPolicy as CartHttpRequestPolicy, +}; +use cart_run::output::{ + CartLineTarget, CartOperation, FunctionCartRunResult, OrderDiscountCandidate, + OrderDiscountCandidateTarget, OrderDiscountCandidateValue, OrderDiscountSelectionStrategy, + OrderDiscounts, OrderSubtotalTarget, Percentage as CartPercentage, ProductDiscountCandidate, + ProductDiscountCandidateTarget, ProductDiscountCandidateValue, + ProductDiscountSelectionStrategy, ProductDiscounts, +}; use delivery_fetch::output::FunctionDeliveryFetchResult; -use delivery_run::output::FunctionDeliveryRunResult; +use delivery_fetch::output::{ + HttpRequest as DeliveryHttpRequest, HttpRequestMethod as DeliveryHttpRequestMethod, + HttpRequestPolicy as DeliveryHttpRequestPolicy, +}; +use delivery_run::output::{ + DeliveryDiscountCandidate, DeliveryDiscountCandidateTarget, DeliveryDiscountCandidateValue, + DeliveryDiscountSelectionStrategy, DeliveryDiscounts, DeliveryGroupTarget, DeliveryOperation, + FunctionDeliveryRunResult, Percentage as DeliveryPercentage, +}; type CartResponseData = cart_run::input::ResponseData; type DeliveryResponseData = delivery_run::input::ResponseData; type CartFetchResponseData = cart_fetch::input::ResponseData; +type DeliveryFetchResponseData = delivery_fetch::input::ResponseData; + +impl CartResponseData { + fn metafield(&self) -> Metafield { + self.discount_node + .metafield + .as_ref() + .map(|metafield| string_to_config::(&metafield.value)) + .expect("Missing required metafield configuration") + } +} + +impl DeliveryResponseData { + fn metafield(&self) -> Metafield { + self.discount_node + .metafield + .as_ref() + .map(|metafield| string_to_config::(&metafield.value)) + .expect("Missing required metafield configuration") + } +} #[derive(Deserialize)] -struct Wrapper { - cart: Option, - delivery: Option, +struct Metafield { + cart_percent: Option, + product_percent: Option, + delivery_percent: Option, } #[shopify_function_target( @@ -24,13 +64,35 @@ struct Wrapper { schema_path = "schema.graphql" )] fn cart_run(input: CartResponseData) -> Result { + let default = FunctionCartRunResult { operations: vec![] }; + let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); - let body = fetch_result.body.as_ref().expect("Missing body"); - let result = string_to_config::(&body) - .cart - .unwrap_or_else(|| FunctionCartRunResult { operations: vec![] }); + if fetch_result.status != 200 { + return Ok(default); + } + + let metafield = input.metafield(); + let mut operations: Vec = vec![]; + + if metafield.cart_percent.is_some() { + operations.push(create_order_discount(&metafield)); + } - Ok(result) + if metafield.product_percent.is_some() { + let highest_priced_line = input + .cart + .lines + .iter() + .max_by(|a, b| { + let a_amount = a.cost.subtotal_amount.amount; + let b_amount = b.cost.subtotal_amount.amount; + a_amount.partial_cmp(&b_amount).unwrap() + }) + .unwrap(); + operations.push(create_product_discount(&highest_priced_line.id, &metafield)); + } + + Ok(FunctionCartRunResult { operations }) } #[shopify_function_target( @@ -39,13 +101,31 @@ fn cart_run(input: CartResponseData) -> Result { schema_path = "schema.graphql" )] fn delivery_run(input: DeliveryResponseData) -> Result { + let default = FunctionDeliveryRunResult { operations: vec![] }; + let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); - let body = fetch_result.body.as_ref().expect("Missing body"); - let result = string_to_config::(&body) - .delivery - .unwrap_or_else(|| FunctionDeliveryRunResult { operations: vec![] }); + if fetch_result.status != 200 { + return Ok(default); + } + + let metafield = input.metafield(); + if metafield.delivery_percent.is_none() { + return Ok(default); + } - Ok(result) + let candidates = input + .cart + .delivery_groups + .iter() + .map(|group| create_delivery_discount_candidate(&group.id, &metafield)) + .collect::>(); + + Ok(FunctionDeliveryRunResult { + operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { + selection_strategy: DeliveryDiscountSelectionStrategy::ALL, + candidates, + })], + }) } #[shopify_function_target( @@ -54,14 +134,24 @@ fn delivery_run(input: DeliveryResponseData) -> Result Result { - let metafield = input - .discount_node - .metafield - .expect("Missing required metafield configuration"); - - Ok(string_to_config::( - &metafield.value, - )) + let body = json!({ + "buyerIdentity": { + "email": input.cart.buyer_identity.as_ref().unwrap().email + } + }); + + Ok(FunctionCartFetchResult { + request: Some(CartHttpRequest { + body: Some(body.to_string()), + headers: vec![], + json_body: Some(body.clone()), + method: CartHttpRequestMethod::POST, + policy: CartHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), + }) } #[shopify_function_target( @@ -69,15 +159,79 @@ fn cart_fetch(input: CartFetchResponseData) -> Result { query_path = "src/fetch.graphql", schema_path = "schema.graphql" )] -fn delivery_fetch(input: CartFetchResponseData) -> Result { - let metafield = input - .discount_node - .metafield - .expect("Missing required metafield configuration"); - - Ok(string_to_config::( - &metafield.value, - )) +fn delivery_fetch(input: DeliveryFetchResponseData) -> Result { + let body = json!({ + "buyerIdentity": { + "email": input.cart.buyer_identity.as_ref().unwrap().email + } + }); + + Ok(FunctionDeliveryFetchResult { + request: Some(DeliveryHttpRequest { + body: Some(body.to_string()), + headers: vec![], + json_body: Some(body.clone()), + method: DeliveryHttpRequestMethod::POST, + policy: DeliveryHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "https://example.com".to_string(), + }), + }) +} + +fn create_order_discount(metafield: &Metafield) -> CartOperation { + CartOperation::AddOrderDiscounts(OrderDiscounts { + selection_strategy: OrderDiscountSelectionStrategy::FIRST, + candidates: vec![OrderDiscountCandidate { + targets: vec![OrderDiscountCandidateTarget::OrderSubtotal( + OrderSubtotalTarget { + excluded_variant_ids: vec![], + }, + )], + associated_discount_code: None, + message: None, + value: OrderDiscountCandidateValue::Percentage(CartPercentage { + value: metafield.cart_percent.unwrap(), + }), + conditions: None, + }], + }) +} + +fn create_product_discount(cart_line_id: &str, metafield: &Metafield) -> CartOperation { + CartOperation::AddProductDiscounts(ProductDiscounts { + selection_strategy: ProductDiscountSelectionStrategy::FIRST, + candidates: vec![ProductDiscountCandidate { + targets: vec![ProductDiscountCandidateTarget::CartLine(CartLineTarget { + id: cart_line_id.to_string(), + quantity: Some(1), + })], + associated_discount_code: None, + message: None, + value: ProductDiscountCandidateValue::Percentage(CartPercentage { + value: metafield.product_percent.unwrap(), + }), + }], + }) +} + +fn create_delivery_discount_candidate( + delivery_group_id: &str, + metafield: &Metafield, +) -> DeliveryDiscountCandidate { + DeliveryDiscountCandidate { + targets: vec![DeliveryDiscountCandidateTarget::DeliveryGroup( + DeliveryGroupTarget { + id: delivery_group_id.to_string(), + }, + )], + value: DeliveryDiscountCandidateValue::Percentage(DeliveryPercentage { + value: metafield.delivery_percent.unwrap(), + }), + message: None, + associated_discount_code: None, + } } fn string_to_config(value: &str) -> T { @@ -87,60 +241,102 @@ fn string_to_config(value: &str) -> T { #[cfg(test)] mod tests { use super::*; - use cart_fetch::output::{ - HttpRequest as CartHttpRequest, HttpRequestMethod as CartHttpRequestMethod, - HttpRequestPolicy as CartHttpRequestPolicy, - }; use cart_run::output::{ CartOperation, OrderDiscountSelectionStrategy, OrderDiscounts, ProductDiscountSelectionStrategy, ProductDiscounts, }; - use delivery_fetch::output::{ - HttpRequest as DeliveryHttpRequest, HttpRequestMethod as DeliveryHttpRequestMethod, - HttpRequestPolicy as DeliveryHttpRequestPolicy, - }; use delivery_run::output::{ DeliveryDiscountSelectionStrategy, DeliveryDiscounts, DeliveryOperation, FunctionDeliveryRunResult, }; use serde_json::json; + use shopify_function::prelude::Decimal; use shopify_function::{run_function_with_input, Result}; - #[test] - fn test_cart_run() -> Result<()> { - let query_input_json = json!({ - "fetchResult": { - "body": json!( + fn get_run_input() -> String { + json!({ + "cart": { + "lines": [ { - "cart": { - "operations": [ - { - "addOrderDiscounts": {"selectionStrategy":"FIRST","candidates":[]}, - }, { - "addProductDiscounts": {"selectionStrategy":"FIRST","candidates":[]} - } - ] + "id": "gid://shopify/CartLine/123", + "cost": { + "subtotalAmount": { + "amount": "100.00" + } } } - ).to_string() + ], + "deliveryGroups": [ + { + "id": "gid://shopify/DeliveryGroup/123" + } + ] + }, + "discountNode": { + "metafield": { + "value": json!({ + "cart_percent": "10", + "product_percent": "20", + "delivery_percent": "30", + }).to_string(), + } + }, + "fetchResult": { + "status": 200, + } + }) + .to_string() + } + + fn get_fetch_input_json() -> serde_json::Value { + json!({ + "cart": { + "buyerIdentity": { + "email": "test@example.com" + } } - }); + }) + } + #[test] + fn test_cart_run() -> Result<()> { let expected = FunctionCartRunResult { operations: vec![ CartOperation::AddOrderDiscounts(OrderDiscounts { selection_strategy: OrderDiscountSelectionStrategy::FIRST, - candidates: vec![], + candidates: vec![OrderDiscountCandidate { + targets: vec![OrderDiscountCandidateTarget::OrderSubtotal( + OrderSubtotalTarget { + excluded_variant_ids: vec![], + }, + )], + associated_discount_code: None, + message: None, + value: OrderDiscountCandidateValue::Percentage(CartPercentage { + value: Decimal(10.0), + }), + conditions: None, + }], }), CartOperation::AddProductDiscounts(ProductDiscounts { selection_strategy: ProductDiscountSelectionStrategy::FIRST, - candidates: vec![], + candidates: vec![ProductDiscountCandidate { + targets: vec![ProductDiscountCandidateTarget::CartLine(CartLineTarget { + id: "gid://shopify/CartLine/123".to_string(), + quantity: Some(1), + })], + associated_discount_code: None, + message: None, + value: ProductDiscountCandidateValue::Percentage(CartPercentage { + value: Decimal(20.0), + }), + }], }), ], }; assert_eq!( - run_function_with_input(cart_run, &query_input_json.to_string())?, + run_function_with_input(cart_run, &get_run_input())?, expected ); Ok(()) @@ -148,31 +344,26 @@ mod tests { #[test] fn test_delivery_run() -> Result<()> { - let query_input_json = json!({ - "fetchResult": { - "body": json!( - { - "delivery": { - "operations": [ - { - "addDeliveryDiscounts": {"selectionStrategy":"ALL","candidates":[]}, - } - ] - } - } - ).to_string() - } - }); - let expected = FunctionDeliveryRunResult { operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { selection_strategy: DeliveryDiscountSelectionStrategy::ALL, - candidates: vec![], + candidates: vec![DeliveryDiscountCandidate { + targets: vec![DeliveryDiscountCandidateTarget::DeliveryGroup( + DeliveryGroupTarget { + id: "gid://shopify/DeliveryGroup/123".to_string(), + }, + )], + value: DeliveryDiscountCandidateValue::Percentage(DeliveryPercentage { + value: Decimal(30.0), + }), + message: None, + associated_discount_code: None, + }], })], }; assert_eq!( - run_function_with_input(delivery_run, &query_input_json.to_string())?, + run_function_with_input(delivery_run, &get_run_input())?, expected ); Ok(()) @@ -180,22 +371,14 @@ mod tests { #[test] fn test_cart_fetch() -> Result<()> { - let body = json!({ - "cart": { - "operations": [ - { - "addOrderDiscounts": {"selectionStrategy": "FIRST", "candidates": []}, - "addProductDiscounts": {"selectionStrategy": "FIRST", "candidates": []} - } - ] - } - }); + let fetch_input = get_fetch_input_json(); + let buyer_identity = &fetch_input["cart"]; let expected_fetch_result = FunctionCartFetchResult { request: Some(CartHttpRequest { - body: Some(body.to_string()), + body: Some(buyer_identity.to_string()), headers: vec![], - json_body: Some(body.clone()), + json_body: Some(buyer_identity.clone()), method: CartHttpRequestMethod::POST, policy: CartHttpRequestPolicy { read_timeout_ms: 2000, @@ -204,27 +387,8 @@ mod tests { }), }; - let metafield = json!({ - "discountNode": { - "metafield": { - "value": json!({ - "request": { - "body": Some(body.to_string()), - "headers": [], - "jsonBody": Some(body.clone()), - "method": "POST", - "policy": { - "readTimeoutMs": 2000, - }, - "url": "https://example.com", - } - }).to_string(), - } - } - }); - assert_eq!( - run_function_with_input(cart_fetch, &metafield.to_string())?, + run_function_with_input(cart_fetch, &fetch_input.to_string())?, expected_fetch_result ); Ok(()) @@ -232,21 +396,14 @@ mod tests { #[test] fn test_delivery_fetch() -> Result<()> { - let body = json!({ - "delivery": { - "operations": [ - { - "addDeliveryDiscounts": {"selectionStrategy": "ALL", "candidates": []}, - } - ] - } - }); + let fetch_input = get_fetch_input_json(); + let buyer_identity = &fetch_input["cart"]; let expected_fetch_result = FunctionDeliveryFetchResult { request: Some(DeliveryHttpRequest { - body: Some(body.to_string()), + body: Some(buyer_identity.to_string()), headers: vec![], - json_body: Some(body.clone()), + json_body: Some(buyer_identity.clone()), method: DeliveryHttpRequestMethod::POST, policy: DeliveryHttpRequestPolicy { read_timeout_ms: 2000, @@ -255,27 +412,8 @@ mod tests { }), }; - let metafield = json!({ - "discountNode": { - "metafield": { - "value": json!({ - "request": { - "body": Some(body.to_string()), - "headers": [], - "jsonBody": Some(body.clone()), - "method": "POST", - "policy": { - "readTimeoutMs": 2000, - }, - "url": "https://example.com", - } - }).to_string(), - } - } - }); - assert_eq!( - run_function_with_input(delivery_fetch, &metafield.to_string())?, + run_function_with_input(delivery_fetch, &fetch_input.to_string())?, expected_fetch_result ); Ok(()) From a2588370596233415f4a77f5dcb73691b5fa36e5 Mon Sep 17 00:00:00 2001 From: Jonathan Hamel Date: Mon, 27 Jan 2025 16:34:35 -0500 Subject: [PATCH 5/5] use enteredDiscountCode --- .../rust/discounts/default/Cargo.toml.liquid | 2 +- .../default/src/fetch.graphql.liquid | 6 +- discounts/rust/discounts/default/src/fetch.rs | 139 ++++++++ discounts/rust/discounts/default/src/main.rs | 1 + discounts/rust/discounts/default/src/run.rs | 305 ++++++++---------- 5 files changed, 272 insertions(+), 181 deletions(-) create mode 100644 discounts/rust/discounts/default/src/fetch.rs diff --git a/discounts/rust/discounts/default/Cargo.toml.liquid b/discounts/rust/discounts/default/Cargo.toml.liquid index ab5dd988..6d47ae18 100644 --- a/discounts/rust/discounts/default/Cargo.toml.liquid +++ b/discounts/rust/discounts/default/Cargo.toml.liquid @@ -2,7 +2,7 @@ name = "{{handle | replace: " ", "-" | downcase}}" version = "1.0.0" edition = "2021" -rust-version = "1.62" +rust-version = "1.84" [dependencies] serde = { version = "1.0.13", features = ["derive"] } diff --git a/discounts/rust/discounts/default/src/fetch.graphql.liquid b/discounts/rust/discounts/default/src/fetch.graphql.liquid index be0dd36d..890973d8 100644 --- a/discounts/rust/discounts/default/src/fetch.graphql.liquid +++ b/discounts/rust/discounts/default/src/fetch.graphql.liquid @@ -1,7 +1,3 @@ query Input { - cart { - buyerIdentity { - email - } - } + enteredDiscountCodes } diff --git a/discounts/rust/discounts/default/src/fetch.rs b/discounts/rust/discounts/default/src/fetch.rs new file mode 100644 index 00000000..7f0abdb3 --- /dev/null +++ b/discounts/rust/discounts/default/src/fetch.rs @@ -0,0 +1,139 @@ +use serde_json::json; +use shopify_function::prelude::*; +use shopify_function::Result; + +use cart_fetch::output::{ + FunctionCartFetchResult, HttpRequest as CartHttpRequest, + HttpRequestMethod as CartHttpRequestMethod, HttpRequestPolicy as CartHttpRequestPolicy, +}; + +use delivery_fetch::output::FunctionDeliveryFetchResult; +use delivery_fetch::output::{ + HttpRequest as DeliveryHttpRequest, HttpRequestMethod as DeliveryHttpRequestMethod, + HttpRequestPolicy as DeliveryHttpRequestPolicy, +}; + +type CartFetchResponseData = cart_fetch::input::ResponseData; +type DeliveryFetchResponseData = delivery_fetch::input::ResponseData; +type CartHttpRequestHeader = cart_fetch::output::HttpRequestHeader; +type DeliveryHttpRequestHeader = delivery_fetch::output::HttpRequestHeader; + +#[shopify_function_target( + target = "cart_fetch", + query_path = "src/fetch.graphql", + schema_path = "schema.graphql" +)] +fn cart_fetch(input: CartFetchResponseData) -> Result { + let body = json!({ + "enteredDiscountCodes": input.entered_discount_codes + }); + + Ok(FunctionCartFetchResult { + request: Some(CartHttpRequest { + body: Some(body.to_string()), + headers: vec![CartHttpRequestHeader { + name: "Accept".to_string(), + value: "application/json; charset=utf-8".to_string(), + }], + json_body: Some(body.clone()), + method: CartHttpRequestMethod::POST, + policy: CartHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "http://localhost:3000".to_string(), + }), + }) +} + +#[shopify_function_target( + target = "delivery_fetch", + query_path = "src/fetch.graphql", + schema_path = "schema.graphql" +)] +fn delivery_fetch(input: DeliveryFetchResponseData) -> Result { + let body = json!({ + "enteredDiscountCodes": input.entered_discount_codes + }); + + Ok(FunctionDeliveryFetchResult { + request: Some(DeliveryHttpRequest { + body: Some(body.to_string()), + headers: vec![DeliveryHttpRequestHeader { + name: "Accept".to_string(), + value: "application/json; charset=utf-8".to_string(), + }], + json_body: Some(body.clone()), + method: DeliveryHttpRequestMethod::POST, + policy: DeliveryHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "http://localhost:3000".to_string(), + }), + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use shopify_function::{run_function_with_input, Result}; + + fn get_fetch_input_json() -> serde_json::Value { + json!({ + "enteredDiscountCodes": ["WELCOME10"] + }) + } + + #[test] + fn test_cart_fetch() -> Result<()> { + let fetch_input = get_fetch_input_json(); + + let expected_fetch_result = FunctionCartFetchResult { + request: Some(CartHttpRequest { + body: Some(fetch_input.to_string()), + headers: vec![CartHttpRequestHeader { + name: "Accept".to_string(), + value: "application/json; charset=utf-8".to_string(), + }], + json_body: Some(fetch_input.clone()), + method: CartHttpRequestMethod::POST, + policy: CartHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "http://localhost:3000".to_string(), + }), + }; + + assert_eq!( + run_function_with_input(cart_fetch, &fetch_input.to_string())?, + expected_fetch_result + ); + Ok(()) + } + + #[test] + fn test_delivery_fetch() -> Result<()> { + let fetch_input = get_fetch_input_json(); + + let expected_fetch_result = FunctionDeliveryFetchResult { + request: Some(DeliveryHttpRequest { + body: Some(fetch_input.to_string()), + headers: vec![DeliveryHttpRequestHeader { + name: "Accept".to_string(), + value: "application/json; charset=utf-8".to_string(), + }], + json_body: Some(fetch_input.clone()), + method: DeliveryHttpRequestMethod::POST, + policy: DeliveryHttpRequestPolicy { + read_timeout_ms: 2000, + }, + url: "http://localhost:3000".to_string(), + }), + }; + + assert_eq!( + run_function_with_input(delivery_fetch, &fetch_input.to_string())?, + expected_fetch_result + ); + Ok(()) + } +} diff --git a/discounts/rust/discounts/default/src/main.rs b/discounts/rust/discounts/default/src/main.rs index 9272b027..2aeeaddf 100644 --- a/discounts/rust/discounts/default/src/main.rs +++ b/discounts/rust/discounts/default/src/main.rs @@ -1,4 +1,5 @@ use std::process; +pub mod fetch; pub mod run; fn main() { diff --git a/discounts/rust/discounts/default/src/run.rs b/discounts/rust/discounts/default/src/run.rs index e5d70d22..bc5044f2 100644 --- a/discounts/rust/discounts/default/src/run.rs +++ b/discounts/rust/discounts/default/src/run.rs @@ -1,42 +1,47 @@ -use serde::{de::DeserializeOwned, Deserialize}; +use serde::Deserialize; -use serde_json::json; use shopify_function::prelude::*; use shopify_function::Result; -use cart_fetch::output::{ - FunctionCartFetchResult, HttpRequest as CartHttpRequest, - HttpRequestMethod as CartHttpRequestMethod, HttpRequestPolicy as CartHttpRequestPolicy, -}; use cart_run::output::{ - CartLineTarget, CartOperation, FunctionCartRunResult, OrderDiscountCandidate, - OrderDiscountCandidateTarget, OrderDiscountCandidateValue, OrderDiscountSelectionStrategy, - OrderDiscounts, OrderSubtotalTarget, Percentage as CartPercentage, ProductDiscountCandidate, + AssociatedDiscountCode as CartAssociatedDiscountCode, CartLineTarget, CartOperation, + FunctionCartRunResult, OrderDiscountCandidate, OrderDiscountCandidateTarget, + OrderDiscountCandidateValue, OrderDiscountSelectionStrategy, OrderDiscounts, + OrderSubtotalTarget, Percentage as CartPercentage, ProductDiscountCandidate, ProductDiscountCandidateTarget, ProductDiscountCandidateValue, - ProductDiscountSelectionStrategy, ProductDiscounts, -}; -use delivery_fetch::output::FunctionDeliveryFetchResult; -use delivery_fetch::output::{ - HttpRequest as DeliveryHttpRequest, HttpRequestMethod as DeliveryHttpRequestMethod, - HttpRequestPolicy as DeliveryHttpRequestPolicy, + ProductDiscountSelectionStrategy, ProductDiscounts, ValidDiscountCode as CartValidDiscountCode, + ValidDiscountCodes as CartValidDiscountCodes, }; + use delivery_run::output::{ - DeliveryDiscountCandidate, DeliveryDiscountCandidateTarget, DeliveryDiscountCandidateValue, + AssociatedDiscountCode as DeliveryAssociatedDiscountCode, DeliveryDiscountCandidate, + DeliveryDiscountCandidateTarget, DeliveryDiscountCandidateValue, DeliveryDiscountSelectionStrategy, DeliveryDiscounts, DeliveryGroupTarget, DeliveryOperation, FunctionDeliveryRunResult, Percentage as DeliveryPercentage, + ValidDiscountCode as DeliveryValidDiscountCode, + ValidDiscountCodes as DeliveryValidDiscountCodes, }; type CartResponseData = cart_run::input::ResponseData; type DeliveryResponseData = delivery_run::input::ResponseData; -type CartFetchResponseData = cart_fetch::input::ResponseData; -type DeliveryFetchResponseData = delivery_fetch::input::ResponseData; impl CartResponseData { fn metafield(&self) -> Metafield { self.discount_node .metafield .as_ref() - .map(|metafield| string_to_config::(&metafield.value)) + .map(|metafield| serde_json::from_str(&metafield.value)) + .unwrap() + .expect("Missing required metafield configuration") + } + fn valid_discount_codes(&self) -> Vec { + self.fetch_result + .as_ref() + .unwrap() + .body + .as_ref() + .map(|available_codes| serde_json::from_str(available_codes)) + .unwrap() .expect("Missing required metafield configuration") } } @@ -46,7 +51,19 @@ impl DeliveryResponseData { self.discount_node .metafield .as_ref() - .map(|metafield| string_to_config::(&metafield.value)) + .map(|metafield| serde_json::from_str(&metafield.value)) + .unwrap() + .expect("Missing required metafield configuration") + } + + fn valid_discount_codes(&self) -> Vec { + self.fetch_result + .as_ref() + .unwrap() + .body + .as_ref() + .map(|available_codes| serde_json::from_str(available_codes)) + .unwrap() .expect("Missing required metafield configuration") } } @@ -65,17 +82,27 @@ struct Metafield { )] fn cart_run(input: CartResponseData) -> Result { let default = FunctionCartRunResult { operations: vec![] }; + let codes = input.valid_discount_codes(); + let available_discount_code = codes.first(); - let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); - if fetch_result.status != 200 { + if available_discount_code.is_none() { return Ok(default); } let metafield = input.metafield(); let mut operations: Vec = vec![]; + let available_discount_code = available_discount_code.unwrap(); + + operations.push(CartOperation::AddValidDiscountCodes( + CartValidDiscountCodes { + codes: vec![CartValidDiscountCode { + code: available_discount_code.to_string(), + }], + }, + )); if metafield.cart_percent.is_some() { - operations.push(create_order_discount(&metafield)); + operations.push(create_order_discount(&metafield, available_discount_code)); } if metafield.product_percent.is_some() { @@ -89,7 +116,11 @@ fn cart_run(input: CartResponseData) -> Result { a_amount.partial_cmp(&b_amount).unwrap() }) .unwrap(); - operations.push(create_product_discount(&highest_priced_line.id, &metafield)); + operations.push(create_product_discount( + &highest_priced_line.id, + &metafield, + available_discount_code, + )); } Ok(FunctionCartRunResult { operations }) @@ -102,85 +133,43 @@ fn cart_run(input: CartResponseData) -> Result { )] fn delivery_run(input: DeliveryResponseData) -> Result { let default = FunctionDeliveryRunResult { operations: vec![] }; + let codes = input.valid_discount_codes(); + let available_discount_code = codes.first(); + let metafield = input.metafield(); - let fetch_result = input.fetch_result.as_ref().expect("Missing fetch result"); - if fetch_result.status != 200 { + if available_discount_code.is_none() || metafield.delivery_percent.is_none() { return Ok(default); } - let metafield = input.metafield(); - if metafield.delivery_percent.is_none() { - return Ok(default); - } + let mut operations: Vec = vec![]; + let available_discount_code = available_discount_code.unwrap(); + + operations.push(DeliveryOperation::AddValidDiscountCodes( + DeliveryValidDiscountCodes { + codes: vec![DeliveryValidDiscountCode { + code: available_discount_code.to_string(), + }], + }, + )); let candidates = input .cart .delivery_groups .iter() - .map(|group| create_delivery_discount_candidate(&group.id, &metafield)) + .map(|group| { + create_delivery_discount_candidate(&group.id, &metafield, available_discount_code) + }) .collect::>(); - Ok(FunctionDeliveryRunResult { - operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { - selection_strategy: DeliveryDiscountSelectionStrategy::ALL, - candidates, - })], - }) -} - -#[shopify_function_target( - target = "cart_fetch", - query_path = "src/fetch.graphql", - schema_path = "schema.graphql" -)] -fn cart_fetch(input: CartFetchResponseData) -> Result { - let body = json!({ - "buyerIdentity": { - "email": input.cart.buyer_identity.as_ref().unwrap().email - } - }); - - Ok(FunctionCartFetchResult { - request: Some(CartHttpRequest { - body: Some(body.to_string()), - headers: vec![], - json_body: Some(body.clone()), - method: CartHttpRequestMethod::POST, - policy: CartHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "https://example.com".to_string(), - }), - }) -} - -#[shopify_function_target( - target = "delivery_fetch", - query_path = "src/fetch.graphql", - schema_path = "schema.graphql" -)] -fn delivery_fetch(input: DeliveryFetchResponseData) -> Result { - let body = json!({ - "buyerIdentity": { - "email": input.cart.buyer_identity.as_ref().unwrap().email - } - }); + operations.push(DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { + selection_strategy: DeliveryDiscountSelectionStrategy::ALL, + candidates, + })); - Ok(FunctionDeliveryFetchResult { - request: Some(DeliveryHttpRequest { - body: Some(body.to_string()), - headers: vec![], - json_body: Some(body.clone()), - method: DeliveryHttpRequestMethod::POST, - policy: DeliveryHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "https://example.com".to_string(), - }), - }) + Ok(FunctionDeliveryRunResult { operations }) } -fn create_order_discount(metafield: &Metafield) -> CartOperation { +fn create_order_discount(metafield: &Metafield, available_discount_code: &str) -> CartOperation { CartOperation::AddOrderDiscounts(OrderDiscounts { selection_strategy: OrderDiscountSelectionStrategy::FIRST, candidates: vec![OrderDiscountCandidate { @@ -189,7 +178,9 @@ fn create_order_discount(metafield: &Metafield) -> CartOperation { excluded_variant_ids: vec![], }, )], - associated_discount_code: None, + associated_discount_code: Some(CartAssociatedDiscountCode { + code: available_discount_code.to_string(), + }), message: None, value: OrderDiscountCandidateValue::Percentage(CartPercentage { value: metafield.cart_percent.unwrap(), @@ -199,7 +190,11 @@ fn create_order_discount(metafield: &Metafield) -> CartOperation { }) } -fn create_product_discount(cart_line_id: &str, metafield: &Metafield) -> CartOperation { +fn create_product_discount( + cart_line_id: &str, + metafield: &Metafield, + available_discount_code: &str, +) -> CartOperation { CartOperation::AddProductDiscounts(ProductDiscounts { selection_strategy: ProductDiscountSelectionStrategy::FIRST, candidates: vec![ProductDiscountCandidate { @@ -207,7 +202,9 @@ fn create_product_discount(cart_line_id: &str, metafield: &Metafield) -> CartOpe id: cart_line_id.to_string(), quantity: Some(1), })], - associated_discount_code: None, + associated_discount_code: Some(CartAssociatedDiscountCode { + code: available_discount_code.to_string(), + }), message: None, value: ProductDiscountCandidateValue::Percentage(CartPercentage { value: metafield.product_percent.unwrap(), @@ -219,6 +216,7 @@ fn create_product_discount(cart_line_id: &str, metafield: &Metafield) -> CartOpe fn create_delivery_discount_candidate( delivery_group_id: &str, metafield: &Metafield, + available_discount_code: &str, ) -> DeliveryDiscountCandidate { DeliveryDiscountCandidate { targets: vec![DeliveryDiscountCandidateTarget::DeliveryGroup( @@ -230,14 +228,12 @@ fn create_delivery_discount_candidate( value: metafield.delivery_percent.unwrap(), }), message: None, - associated_discount_code: None, + associated_discount_code: Some(DeliveryAssociatedDiscountCode { + code: available_discount_code.to_string(), + }), } } -fn string_to_config(value: &str) -> T { - serde_json::from_str(value).expect("Unable to parse configuration value from metafield") -} - #[cfg(test)] mod tests { use super::*; @@ -282,26 +278,22 @@ mod tests { } }, "fetchResult": { - "status": 200, + "body": "[\"WELCOME10\"]", + "status": 200 } }) .to_string() } - fn get_fetch_input_json() -> serde_json::Value { - json!({ - "cart": { - "buyerIdentity": { - "email": "test@example.com" - } - } - }) - } - #[test] fn test_cart_run() -> Result<()> { let expected = FunctionCartRunResult { operations: vec![ + CartOperation::AddValidDiscountCodes(CartValidDiscountCodes { + codes: vec![CartValidDiscountCode { + code: "WELCOME10".to_string(), + }], + }), CartOperation::AddOrderDiscounts(OrderDiscounts { selection_strategy: OrderDiscountSelectionStrategy::FIRST, candidates: vec![OrderDiscountCandidate { @@ -310,7 +302,9 @@ mod tests { excluded_variant_ids: vec![], }, )], - associated_discount_code: None, + associated_discount_code: Some(CartAssociatedDiscountCode { + code: "WELCOME10".to_string(), + }), message: None, value: OrderDiscountCandidateValue::Percentage(CartPercentage { value: Decimal(10.0), @@ -325,7 +319,9 @@ mod tests { id: "gid://shopify/CartLine/123".to_string(), quantity: Some(1), })], - associated_discount_code: None, + associated_discount_code: Some(CartAssociatedDiscountCode { + code: "WELCOME10".to_string(), + }), message: None, value: ProductDiscountCandidateValue::Percentage(CartPercentage { value: Decimal(20.0), @@ -345,21 +341,30 @@ mod tests { #[test] fn test_delivery_run() -> Result<()> { let expected = FunctionDeliveryRunResult { - operations: vec![DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { - selection_strategy: DeliveryDiscountSelectionStrategy::ALL, - candidates: vec![DeliveryDiscountCandidate { - targets: vec![DeliveryDiscountCandidateTarget::DeliveryGroup( - DeliveryGroupTarget { - id: "gid://shopify/DeliveryGroup/123".to_string(), - }, - )], - value: DeliveryDiscountCandidateValue::Percentage(DeliveryPercentage { - value: Decimal(30.0), - }), - message: None, - associated_discount_code: None, - }], - })], + operations: vec![ + DeliveryOperation::AddValidDiscountCodes(DeliveryValidDiscountCodes { + codes: vec![DeliveryValidDiscountCode { + code: "WELCOME10".to_string(), + }], + }), + DeliveryOperation::AddDeliveryDiscounts(DeliveryDiscounts { + selection_strategy: DeliveryDiscountSelectionStrategy::ALL, + candidates: vec![DeliveryDiscountCandidate { + targets: vec![DeliveryDiscountCandidateTarget::DeliveryGroup( + DeliveryGroupTarget { + id: "gid://shopify/DeliveryGroup/123".to_string(), + }, + )], + value: DeliveryDiscountCandidateValue::Percentage(DeliveryPercentage { + value: Decimal(30.0), + }), + message: None, + associated_discount_code: Some(DeliveryAssociatedDiscountCode { + code: "WELCOME10".to_string(), + }), + }], + }), + ], }; assert_eq!( @@ -368,54 +373,4 @@ mod tests { ); Ok(()) } - - #[test] - fn test_cart_fetch() -> Result<()> { - let fetch_input = get_fetch_input_json(); - let buyer_identity = &fetch_input["cart"]; - - let expected_fetch_result = FunctionCartFetchResult { - request: Some(CartHttpRequest { - body: Some(buyer_identity.to_string()), - headers: vec![], - json_body: Some(buyer_identity.clone()), - method: CartHttpRequestMethod::POST, - policy: CartHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "https://example.com".to_string(), - }), - }; - - assert_eq!( - run_function_with_input(cart_fetch, &fetch_input.to_string())?, - expected_fetch_result - ); - Ok(()) - } - - #[test] - fn test_delivery_fetch() -> Result<()> { - let fetch_input = get_fetch_input_json(); - let buyer_identity = &fetch_input["cart"]; - - let expected_fetch_result = FunctionDeliveryFetchResult { - request: Some(DeliveryHttpRequest { - body: Some(buyer_identity.to_string()), - headers: vec![], - json_body: Some(buyer_identity.clone()), - method: DeliveryHttpRequestMethod::POST, - policy: DeliveryHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "https://example.com".to_string(), - }), - }; - - assert_eq!( - run_function_with_input(delivery_fetch, &fetch_input.to_string())?, - expected_fetch_result - ); - Ok(()) - } }