diff --git a/components/core/Navbar/Navbar.tsx b/components/core/Navbar/Navbar.tsx index 740054cf0..34838b01c 100644 --- a/components/core/Navbar/Navbar.tsx +++ b/components/core/Navbar/Navbar.tsx @@ -1,4 +1,3 @@ -import cn from 'classnames' import { FC } from 'react' import s from './Navbar.module.css' import { Logo, Container } from '@components/ui' diff --git a/components/core/Searchbar/Searchbar.tsx b/components/core/Searchbar/Searchbar.tsx index c29bbe581..865e00a49 100644 --- a/components/core/Searchbar/Searchbar.tsx +++ b/components/core/Searchbar/Searchbar.tsx @@ -1,14 +1,19 @@ +import { FC, useEffect } from 'react' import cn from 'classnames' -import { FC } from 'react' import s from './Searchbar.module.css' import { useRouter } from 'next/router' + interface Props { className?: string - children?: any } const Searchbar: FC = ({ className }) => { const router = useRouter() + + useEffect(() => { + router.prefetch('/search') + }, []) + return (
{ + // Use a dummy base as we only care about the relative path + const url = new URL('/v3/catalog/products', 'http://a') + + if (search) url.searchParams.set('keyword', search) + + const { data } = await config.storeApiFetch(url.pathname + url.search) + + res.status(200).json({ data }) +} + +export default getProducts diff --git a/lib/bigcommerce/api/catalog/products.ts b/lib/bigcommerce/api/catalog/products.ts new file mode 100644 index 000000000..0633846c6 --- /dev/null +++ b/lib/bigcommerce/api/catalog/products.ts @@ -0,0 +1,47 @@ +import type { definitions } from '../definitions/catalog' +import isAllowedMethod from '../utils/is-allowed-method' +import createApiHandler, { + BigcommerceApiHandler, + BigcommerceHandler, +} from '../utils/create-api-handler' +import { BigcommerceApiError } from '../utils/errors' +import getProducts from './handlers/get-products' + +export type Product = definitions['product_Full'] + +export type ProductsHandlers = { + getProducts: BigcommerceHandler +} + +const METHODS = ['GET'] + +// TODO: a complete implementation should have schema validation for `req.body` +const cartApi: BigcommerceApiHandler = async ( + req, + res, + config, + handlers +) => { + if (!isAllowedMethod(req, res, METHODS)) return + + try { + // Return current cart info + if (req.method === 'GET') { + const body = req.query + return await handlers['getProducts']({ req, res, config, body }) + } + } catch (error) { + console.error(error) + + const message = + error instanceof BigcommerceApiError + ? 'An unexpected error ocurred with the Bigcommerce API' + : 'An unexpected error ocurred' + + res.status(500).json({ data: null, errors: [{ message }] }) + } +} + +export const handlers = { getProducts } + +export default createApiHandler(cartApi, handlers) diff --git a/lib/bigcommerce/api/definitions/catalog.ts b/lib/bigcommerce/api/definitions/catalog.ts new file mode 100644 index 000000000..08a760bf7 --- /dev/null +++ b/lib/bigcommerce/api/definitions/catalog.ts @@ -0,0 +1,3001 @@ +/** + * This file was auto-generated by swagger-to-ts. + * Do not make direct changes to the file. + */ + +export interface definitions { + /** + * Common Modifier properties. + */ + productModifier_Base: { + /** + * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. + */ + type: + | 'date' + | 'checkbox' + | 'file' + | 'text' + | 'multi_line_text' + | 'numbers_only_text' + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + /** + * Whether or not this modifer is required or not at checkout. Required in a /POST. + */ + required: boolean + /** + * The order the modifiers display on the product detail page. + */ + sort_order?: number + config?: definitions['config_Full'] + /** + * The name of the option shown on the storefront. + */ + display_name?: string + } + /** + * Product Modifier + */ + productModifier_Full: definitions['productModifier_Base'] & { + /** + * The unique numeric ID of the modifier; increments sequentially. + */ + id?: number + /** + * The unique numeric ID of the product to which the option belongs. + */ + product_id?: number + /** + * The unique option name. Auto-generated from the display name, a timestamp, and the product ID. + */ + name?: string + option_values?: definitions['productModifierOptionValue_Full'][] + } + /** + * The model for a POST to create a modifier on a product. + */ + productModifier_Post: { + /** + * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. + */ + type: + | 'date' + | 'checkbox' + | 'file' + | 'text' + | 'multi_line_text' + | 'numbers_only_text' + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + /** + * Whether or not this modifer is required or not at checkout. Required in a /POST. + */ + required: boolean + /** + * The order the modifiers display on the product detail page. + */ + sort_order?: number + /** + * The values for option config can vary based on the Modifier created. + */ + config?: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + option_values?: (({ + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + adjusters?: { + /** + * Adjuster for Complex Rules. + */ + price?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * Adjuster for Complex Rules. + */ + weight?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. + */ + image_url?: string + purchasing_disabled?: { + /** + * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. + */ + status?: boolean + /** + * The message displayed on the storefront when the purchasing disabled status is `true`. + */ + message?: string + } + } + }) & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + })[] + } & { + /** + * The name of the option shown on the storefront. + */ + display_name: string + } + /** + * The model for a PUT to update a modifier on a product. + */ + productModifier_Put: { + /** + * BigCommerce API, which determines how it will display on the storefront. Acceptable values: `date`, `checkbox`, `file`, `text`, `multi_line_text`, `numbers_only_text`, `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. Required in a /POST. + */ + type: + | 'date' + | 'checkbox' + | 'file' + | 'text' + | 'multi_line_text' + | 'numbers_only_text' + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + /** + * Whether or not this modifer is required or not at checkout. Required in a /POST. + */ + required: boolean + /** + * The order the modifiers display on the product detail page. + */ + sort_order?: number + /** + * The values for option config can vary based on the Modifier created. + */ + config?: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + option_values?: (({ + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + adjusters?: { + /** + * Adjuster for Complex Rules. + */ + price?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * Adjuster for Complex Rules. + */ + weight?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. + */ + image_url?: string + purchasing_disabled?: { + /** + * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. + */ + status?: boolean + /** + * The message displayed on the storefront when the purchasing disabled status is `true`. + */ + message?: string + } + } + }) & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + })[] + } + /** + * Common Product Modifer `option_value` properties. + */ + productModifierOptionValue_Base: { + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. If no data is available, returns `null`. + */ + value_data?: { [key: string]: any } + adjusters?: definitions['adjusters_Full'] + } + /** + * Product Modifer `option_value`. + */ + productModifierOptionValue_Full: definitions['productModifierOptionValue_Base'] & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + option_id?: number + } + /** + * The model for a POST to create a modifier value on a product. + */ + productModifierOptionValue_Post: { + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + adjusters?: { + /** + * Adjuster for Complex Rules. + */ + price?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * Adjuster for Complex Rules. + */ + weight?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. + */ + image_url?: string + purchasing_disabled?: { + /** + * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. + */ + status?: boolean + /** + * The message displayed on the storefront when the purchasing disabled status is `true`. + */ + message?: string + } + } + } + /** + * The model for a PUT to update a modifier value on a product. + */ + productModifierOptionValue_Put: ({ + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + adjusters?: { + /** + * Adjuster for Complex Rules. + */ + price?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * Adjuster for Complex Rules. + */ + weight?: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. + */ + image_url?: string + purchasing_disabled?: { + /** + * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. + */ + status?: boolean + /** + * The message displayed on the storefront when the purchasing disabled status is `true`. + */ + message?: string + } + } + }) & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + } + resp_productionOption: { + data?: definitions['productOption_Full'] + /** + * Empty meta object; may be used later. + */ + meta?: { ''?: string } + } + /** + * Common Option properties. + */ + productOption_Base: { + /** + * The unique numerical ID of the option, increments sequentially. + */ + id?: number + /** + * The unique numerical ID of the product to which the option belongs. + */ + product_id?: number + /** + * The name of the option shown on the storefront. + */ + display_name?: string + /** + * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. + */ + type?: + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + config?: definitions['productOptionConfig_Full'] + /** + * Order in which the option is displayed on the storefront. + */ + sort_order?: number + option_values?: definitions['productOptionOptionValue_Full'] + } + productOption_Full: definitions['productOption_Base'] & { + /** + * The unique option name, auto-generated from the display name, a timestamp, and the product ID. + */ + name?: string + } + /** + * The model for a POST to create options on a product. + */ + productOption_Post: { + /** + * The unique numerical ID of the option, increments sequentially. + */ + id?: number + /** + * The unique numerical ID of the product to which the option belongs. + */ + product_id?: number + /** + * The name of the option shown on the storefront. + */ + display_name?: string + /** + * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. + */ + type?: + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + /** + * The values for option config can vary based on the Modifier created. + */ + config?: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + /** + * Order in which the option is displayed on the storefront. + */ + sort_order?: number + option_values?: ({ + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + })[] + /** + * Publicly available image url + */ + image_url?: string + } + /** + * The model for a PUT to update options on a product. + */ + productOption_Put: { + /** + * The unique numerical ID of the option, increments sequentially. + */ + id?: number + /** + * The unique numerical ID of the product to which the option belongs. + */ + product_id?: number + /** + * The name of the option shown on the storefront. + */ + display_name?: string + /** + * The type of option, which determines how it will display on the storefront. Acceptable values: `radio_buttons`, `rectangles`, `dropdown`, `product_list`, `product_list_with_images`, `swatch`. For reference, the former v2 API values are: RB = radio_buttons, RT = rectangles, S = dropdown, P = product_list, PI = product_list_with_images, CS = swatch. + */ + type?: + | 'radio_buttons' + | 'rectangles' + | 'dropdown' + | 'product_list' + | 'product_list_with_images' + | 'swatch' + /** + * The values for option config can vary based on the Modifier created. + */ + config?: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + /** + * Order in which the option is displayed on the storefront. + */ + sort_order?: number + option_values?: ({ + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + })[] + /** + * Publicly available image url + */ + image_url?: string + } + /** + * Returns the categories tree, a nested lineage of the categories with parent->child relationship. The Category objects returned are simplified versions of the category objects returned in the rest of this API. + */ + categoriesTree_Resp: { + data?: definitions['categoriesTreeNode_Full'][] + meta?: definitions['metaEmpty_Full'] + } + /** + * Used to reflect parent <> child category relationships. Used by Category Tree. + */ + categoriesTreeNode_Full: { + /** + * The unique numeric ID of the category; increments sequentially. + */ + id?: number + /** + * The unique numeric ID of the category's parent. This field controls where the category sits in the tree of categories that organize the catalog. + */ + parent_id?: number + /** + * The name displayed for the category. Name is unique with respect to the category's siblings. + */ + name?: string + /** + * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the category will be displayed. If `false`, the category will be hidden from view. + */ + is_visible?: boolean + /** + * The custom URL for the category on the storefront. + */ + url?: string + /** + * The list of children of the category. + */ + children?: definitions['categoriesTreeNode_Full'][] + } + /** + * Common Category object properties. + */ + category_Full: { + /** + * Unique ID of the *Category*. Increments sequentially. + * Read-Only. + */ + id?: number + /** + * The unique numeric ID of the category's parent. This field controls where the category sits in the tree of categories that organize the catalog. + * Required in a POST if creating a child category. + */ + parent_id: number + /** + * The name displayed for the category. Name is unique with respect to the category's siblings. + * Required in a POST. + */ + name: string + /** + * The product description, which can include HTML formatting. + */ + description?: string + /** + * Number of views the category has on the storefront. + */ + views?: number + /** + * Priority this category will be given when included in the menu and category pages. The lower the number, the closer to the top of the results the category will be. + */ + sort_order?: number + /** + * Custom title for the category page. If not defined, the category name will be used as the meta title. + */ + page_title?: string + /** + * A comma-separated list of keywords that can be used to locate the category when searching the store. + */ + search_keywords?: string + /** + * Custom meta keywords for the category page. If not defined, the store's default keywords will be used. Must post as an array like: ["awesome","sauce"]. + */ + meta_keywords?: string[] + /** + * Custom meta description for the category page. If not defined, the store's default meta description will be used. + */ + meta_description?: string + /** + * A valid layout file. (Please refer to [this article](https://support.bigcommerce.com/articles/Public/Creating-Custom-Template-Files/) on creating category files.) This field is writable only for stores with a Blueprint theme applied. + */ + layout_file?: string + /** + * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the category will be displayed. If `false`, the category will be hidden from view. + */ + is_visible?: boolean + /** + * Determines how the products are sorted on category page load. + */ + default_product_sort?: + | 'use_store_settings' + | 'featured' + | 'newest' + | 'best_selling' + | 'alpha_asc' + | 'alpha_desc' + | 'avg_customer_review' + | 'price_asc' + | 'price_desc' + /** + * Image URL used for this category on the storefront. Images can be uploaded via form file post to `/categories/{categoryId}/image`, or by providing a publicly accessible URL in this field. + */ + image_url?: string + custom_url?: definitions['customUrl_Full'] + } + /** + * Common Brand properties. + */ + brand_Full: { + /** + * Unique ID of the *Brand*. Read-Only. + */ + id?: number + /** + * The name of the brand. Must be unique. + * Required in POST. + */ + name: string + /** + * The title shown in the browser while viewing the brand. + */ + page_title?: string + /** + * Comma-separated list of meta keywords to include in the HTML. + */ + meta_keywords?: string[] + /** + * A meta description to include. + */ + meta_description?: string + /** + * A comma-separated list of keywords that can be used to locate this brand. + */ + search_keywords?: string + /** + * Image URL used for this category on the storefront. Images can be uploaded via form file post to `/brands/{brandId}/image`, or by providing a publicly accessible URL in this field. + */ + image_url?: string + custom_url?: definitions['customUrl_Full'] + } + /** + * Common Variant properties. + */ + productVariant_Base: { + /** + * The cost price of the variant. Not affected by Price List prices. + */ + cost_price?: number + /** + * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. + */ + price?: number + /** + * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. + */ + sale_price?: number + /** + * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. + */ + retail_price?: number + /** + * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. + */ + weight?: number + /** + * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. + */ + width?: number + /** + * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. + */ + height?: number + /** + * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. + */ + depth?: number + /** + * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. + */ + is_free_shipping?: boolean + /** + * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * If `true`, this variant will not be purchasable on the storefront. + */ + purchasing_disabled?: boolean + /** + * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. + */ + purchasing_disabled_message?: string + /** + * The UPC code used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. + */ + inventory_level?: number + /** + * When the variant hits this inventory level, it is considered low stock. + */ + inventory_warning_level?: number + /** + * Identifies where in a warehouse the variant is located. + */ + bin_picking_number?: string + } + productVariant_Full: definitions['productVariant_Base'] & { + id?: number + product_id?: number + sku?: string + /** + * Read-only reference to v2 API's SKU ID. Null if it is a base variant. + */ + sku_id?: number + /** + * Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant. + */ + option_values?: definitions['productVariantOptionValue_Full'][] + /** + * The price of the variant as seen on the storefront. This price takes into account `sale_price` and any price adjustment rules that are applicable to this variant. + */ + calculated_price?: number + ''?: string + } + /** + * The model for a POST to create variants on a product. + */ + productVariant_Post: { + /** + * The cost price of the variant. Not affected by Price List prices. + */ + cost_price?: number + /** + * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. + */ + price?: number + /** + * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. + */ + sale_price?: number + /** + * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. + */ + retail_price?: number + /** + * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. + */ + weight?: number + /** + * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. + */ + width?: number + /** + * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. + */ + height?: number + /** + * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. + */ + depth?: number + /** + * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. + */ + is_free_shipping?: boolean + /** + * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * If `true`, this variant will not be purchasable on the storefront. + */ + purchasing_disabled?: boolean + /** + * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. + */ + purchasing_disabled_message?: string + /** + * The UPC code used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. + */ + inventory_level?: number + /** + * When the variant hits this inventory level, it is considered low stock. + */ + inventory_warning_level?: number + /** + * Identifies where in a warehouse the variant is located. + */ + bin_picking_number?: string + } & { + product_id?: number + sku?: string + /** + * Array of option and option values IDs that make up this variant. Will be empty if the variant is the product's base variant. + */ + option_values?: definitions['productVariantOptionValue_Full'][] + } + variantCollection_Put: definitions['productVariant_Full'][] + /** + * The model for a PUT to update variants on a product. + */ + variant_Put: { + /** + * The cost price of the variant. Not affected by Price List prices. + */ + cost_price?: number + /** + * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. + */ + price?: number + /** + * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. + */ + sale_price?: number + /** + * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. + */ + retail_price?: number + /** + * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. + */ + weight?: number + /** + * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. + */ + width?: number + /** + * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. + */ + height?: number + /** + * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. + */ + depth?: number + /** + * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. + */ + is_free_shipping?: boolean + /** + * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * If `true`, this variant will not be purchasable on the storefront. + */ + purchasing_disabled?: boolean + /** + * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. + */ + purchasing_disabled_message?: string + /** + * The UPC code used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. + */ + inventory_level?: number + /** + * When the variant hits this inventory level, it is considered low stock. + */ + inventory_warning_level?: number + /** + * Identifies where in a warehouse the variant is located. + */ + bin_picking_number?: string + } & { id?: number } + /** + * The model for a POST to create variants on a product. + */ + productVariant_Post_Product: definitions['productVariant_Base'] & { + sku?: string + option_values?: { + /** + * The name of the option. + */ + option_display_name?: string + /** + * The label of the option value. + */ + label?: string + }[] + } + /** + * The model for a PUT to update variants on a product. + */ + productVariant_Put_Product: { + /** + * The cost price of the variant. Not affected by Price List prices. + */ + cost_price?: number + /** + * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. + */ + price?: number + /** + * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. + */ + sale_price?: number + /** + * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. + */ + retail_price?: number + /** + * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. + */ + weight?: number + /** + * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. + */ + width?: number + /** + * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. + */ + height?: number + /** + * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. + */ + depth?: number + /** + * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. + */ + is_free_shipping?: boolean + /** + * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * If `true`, this variant will not be purchasable on the storefront. + */ + purchasing_disabled?: boolean + /** + * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. + */ + purchasing_disabled_message?: string + /** + * The UPC code used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. + */ + inventory_level?: number + /** + * When the variant hits this inventory level, it is considered low stock. + */ + inventory_warning_level?: number + /** + * Identifies where in a warehouse the variant is located. + */ + bin_picking_number?: string + product_id?: number + sku?: string + } + productVariantOptionValue_Full: { + /** + * The name of the option. + */ + option_display_name?: string + /** + * The label of the option value. + */ + label?: string + } & definitions['productVariantOptionValue_Base'] + /** + * The model for a POST to create option values on a product. + */ + productOptionValue_Post_Product: { + /** + * The name of the option. + */ + option_display_name?: string + /** + * The label of the option value. + */ + label?: string + } + /** + * Common Product Variant Option properties. + */ + productVariantOptionValue_Base: { + /** + * `option_value` ID. + */ + id?: number + /** + * `option` ID. + */ + option_id?: number + } + /** + * The model for a POST to create option values on a variant. + */ + productVariantOptionValue_Post: { id?: number; option_id?: number } + resp_productOptionValue: { + data?: definitions['productOptionOptionValue_Full'] + /** + * Empty meta object; may be used later. + */ + meta?: { ''?: string } + } + /** + * Common Product Option `option_value` properties. + */ + productOptionOptionValue_Base: { + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. If no data is available, returns `null`. + */ + value_data?: { [key: string]: any } + } + /** + * Product Option `option_value`. + */ + productOptionOptionValue_Full: definitions['productOptionOptionValue_Base'] & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + } + /** + * The model for a POST to create option values on a product. + */ + productOptionValue_Post: { + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } + /** + * The model for a PUT to update option values on a product. + */ + productOptionValue_Put: { + /** + * The flag for preselecting a value as the default on the storefront. This field is not supported for swatch options/modifiers. + */ + is_default?: boolean + /** + * The text display identifying the value on the storefront. Required in a /POST. + */ + label: string + /** + * The order in which the value will be displayed on the product page. Required in a /POST. + */ + sort_order: number + /** + * Extra data describing the value, based on the type of option or modifier with which the value is associated. The `swatch` type option can accept an array of `colors`, with up to three hexidecimal color keys; or an `image_url`, which is a full image URL path including protocol. The `product list` type option requires a `product_id`. The `checkbox` type option requires a boolean flag, called `checked_value`, to determine which value is considered to be the checked state. + */ + value_data?: { [key: string]: any } + } & { + /** + * The unique numeric ID of the value; increments sequentially. + */ + id?: number + } + /** + * Common ProductImage properties. + */ + productImage_Base: { + /** + * The local path to the original image file uploaded to BigCommerce. + */ + image_file?: string + /** + * Flag for identifying whether the image is used as the product's thumbnail. + */ + is_thumbnail?: boolean + /** + * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. + */ + sort_order?: number + /** + * The description for the image. + */ + description?: string + /** + * Must be a fully qualified URL path, including protocol. Limit of 8MB per file. + */ + image_url?: string + } + /** + * The model for a POST to create an image on a product. + */ + productImage_Post: { + /** + * The unique numeric ID of the image; increments sequentially. + */ + id?: number + /** + * The unique numeric identifier for the product with which the image is associated. + */ + product_id?: number + /** + * The local path to the original image file uploaded to BigCommerce. + */ + image_file?: string + /** + * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. + */ + url_zoom?: string + /** + * The standard URL for this image. By default, this is used for product-page images. + */ + url_standard?: string + /** + * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. + */ + url_thumbnail?: string + /** + * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. + */ + url_tiny?: string + /** + * The date on which the product image was modified. + */ + date_modified?: string + /** + * Flag for identifying whether the image is used as the product's thumbnail. + */ + is_thumbnail?: boolean + /** + * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. + */ + sort_order?: number + /** + * The description for the image. + */ + description?: string + } & { + /** + * Must be a fully qualified URL path, including protocol. Limit of 8MB per file. + */ + image_url?: string + /** + * Must be sent as a multipart/form-data field in the request body. + */ + image_file?: string + } + /** + * The model for a PUT to update applicable Product Image fields. + */ + productImage_Put: { + /** + * The unique numeric ID of the image; increments sequentially. + */ + id?: number + /** + * The unique numeric identifier for the product with which the image is associated. + */ + product_id?: number + /** + * The local path to the original image file uploaded to BigCommerce. + */ + image_file?: string + /** + * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. + */ + url_zoom?: string + /** + * The standard URL for this image. By default, this is used for product-page images. + */ + url_standard?: string + /** + * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. + */ + url_thumbnail?: string + /** + * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. + */ + url_tiny?: string + /** + * The date on which the product image was modified. + */ + date_modified?: string + /** + * Flag for identifying whether the image is used as the product's thumbnail. + */ + is_thumbnail?: boolean + /** + * The order in which the image will be displayed on the product page. Higher integers give the image a lower priority. When updating, if the image is given a lower priority, all images with a `sort_order` the same as or greater than the image's new `sort_order` value will have their `sort_order`s reordered. + */ + sort_order?: number + /** + * The description for the image. + */ + description?: string + } + /** + * The model for a POST to create a video on a product. + */ + productVideo_Base: { + /** + * The title for the video. If left blank, this will be filled in according to data on a host site. + */ + title?: string + /** + * The description for the video. If left blank, this will be filled in according to data on a host site. + */ + description?: string + /** + * The order in which the video will be displayed on the product page. Higher integers give the video a lower priority. When updating, if the video is given a lower priority, all videos with a `sort_order` the same as or greater than the video's new `sort_order` value will have their `sort_order`s reordered. + */ + sort_order?: number + /** + * The video type (a short name of a host site). + */ + type?: 'youtube' + /** + * The ID of the video on a host site. + */ + video_id?: string + } + /** + * A product video model. + */ + productVideo_Full: definitions['productVideo_Base'] & { + /** + * The unique numeric ID of the product video; increments sequentially. + */ + id?: number + /** + * The unique numeric identifier for the product with which the image is associated. + */ + product_id?: number + /** + * Length of the video. This will be filled in according to data on a host site. + */ + length?: string + } + /** + * The model for a POST to create a video on a product. + */ + productVideo_Post: definitions['productVideo_Base'] + /** + * The model for a PUT to update a video on a product. + */ + productVideo_Put: definitions['productVideo_Base'] & { + /** + * The unique numeric ID of the product video; increments sequentially. + */ + id?: number + } + productReview_Base: { + /** + * The title for the product review. + * Required in /POST. + */ + title: string + /** + * The text for the product review. + */ + text?: string + /** + * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. + */ + status?: string + /** + * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. + */ + rating?: number + /** + * The email of the reviewer. Must be a valid email, or an empty string. + */ + email?: string + /** + * The name of the reviewer. + */ + name?: string + /** + * Date the product was reviewed. Required in /POST. + */ + date_reviewed: string + } + /** + * A product review model. + */ + productReview_Full: definitions['productReview_Base'] & { + /** + * The unique numeric ID of the product review; increments sequentially. + */ + id?: number + /** + * The unique numeric identifier for the product with which the review is associated. + */ + product_id?: number + /** + * Date the product review was created. + */ + date_created?: string + /** + * Date the product review was modified. + */ + date_modified?: string + } + /** + * The model for a POST to create a product review. + */ + productReview_Post: { + /** + * The title for the product review. + * Required in /POST. + */ + title: string + /** + * The text for the product review. + */ + text?: string + /** + * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. + */ + status?: string + /** + * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. + */ + rating?: number + /** + * The email of the reviewer. Must be a valid email, or an empty string. + */ + email?: string + /** + * The name of the reviewer. + */ + name?: string + /** + * Date the product was reviewed. Required in /POST. + */ + date_reviewed: string + } + /** + * The model for a PUT to update a product review. + */ + productReview_Put: { + /** + * The title for the product review. + * Required in /POST. + */ + title: string + /** + * The text for the product review. + */ + text?: string + /** + * The status of the product review. Must be one of `approved`, `disapproved` or `pending`. + */ + status?: string + /** + * The rating of the product review. Must be one of 0, 1, 2, 3, 4, 5. + */ + rating?: number + /** + * The email of the reviewer. Must be a valid email, or an empty string. + */ + email?: string + /** + * The name of the reviewer. + */ + name?: string + /** + * Date the product was reviewed. Required in /POST. + */ + date_reviewed: string + } + /** + * Image Response returns for: + * * Create Variant Image + * * Create Modifier Image + * * Create Category Image + * * Create Brand Image + */ + resp_productImage: { + data?: definitions['productImage_Full'] + /** + * Empty meta object; may be used later. + */ + meta?: { [key: string]: any } + } + /** + * An object containing a publicly accessible image URL, or a form post that contains an image file. + */ + resourceImage_Full: { + /** + * A public URL for a GIF, JPEG, or PNG image. Limit of 8MB per file. + */ + image_url?: string + } + product_Post: definitions['product_Base'] + /** + * The model for a PUT to update a product. + */ + product_Put: { + /** + * The unique numerical ID of the product; increments sequentially. + */ + id?: number + } & definitions['product_Base'] & { + variants?: definitions['productVariant_Put_Product'] + } + /** + * Catalog Summary object describes a lightweight summary of the catalog. + */ + catalogSummary_Full: { + /** + * A count of all inventory items in the catalog. + */ + inventory_count?: number + /** + * Total value of store's inventory. + */ + inventory_value?: number + /** + * ID of the category containing the most products. + */ + primary_category_id?: number + /** + * Name of the category containing the most products. + */ + primary_category_name?: string + /** + * Total number of variants + */ + variant_count?: number + /** + * Highest priced variant + */ + highest_variant_price?: number + /** + * Average price of all variants + */ + average_variant_price?: number + /** + * Lowest priced variant in the store + */ + lowest_variant_price?: string + oldest_variant_date?: string + newest_variant_date?: string + } + /** + * Metafield for products, categories, variants, and brands. The max number of metafields allowed on each product, category, variant, or brand is fifty. For more information, see [Platform Limits](https://support.bigcommerce.com/s/article/Platform-Limits) in the Help Center. + */ + metafield_Base: { + /** + * Unique ID of the *Metafield*. Read-Only. + */ + id?: number + /** + * Determines the visibility and writeability of the field by other API consumers. + * + * |Value|Description + * |-|-| + * |`app_only`|Private to the app that owns the field| + * |`read`|Visible to other API consumers| + * |`write`|Open for reading and writing by other API consumers| + * |`read_and_sf_access`|Visible to other API consumers, including on storefront| + * |`write_and_sf_access`|Open for reading and writing by other API consumers, including on storefront| + */ + permission_set: + | 'app_only' + | 'read' + | 'write' + | 'read_and_sf_access' + | 'write_and_sf_access' + /** + * Namespace for the metafield, for organizational purposes. This is set set by the developer. Required for POST. + */ + namespace: string + /** + * The name of the field, for example: `location_id`, `color`. Required for POST. + */ + key: string + /** + * The value of the field, for example: `1`, `blue`. Required for POST. + */ + value: string + /** + * Description for the metafields. + */ + description?: string + /** + * The type of resource with which the metafield is associated. + */ + resource_type?: 'category' | 'brand' | 'product' | 'variant' + /** + * The ID for the resource with which the metafield is associated. + */ + resource_id?: number + /** + * Date and time of the metafield's creation. Read-Only. + */ + date_created?: string + /** + * Date and time when the metafield was last updated. Read-Only. + */ + date_modified?: string + } + /** + * Common ComplexRule properties. + */ + complexRule_Base: { + /** + * The unique numeric ID of the rule; increments sequentially. + * Read-Only + */ + id?: number + /** + * The unique numeric ID of the product with which the rule is associated; increments sequentially. + */ + product_id?: number + /** + * The priority to give this rule when making adjustments to the product properties. + */ + sort_order?: number + /** + * Flag for determining whether the rule is to be used when adjusting a product's price, weight, image, or availabilty. + */ + enabled?: boolean + /** + * Flag for determining whether other rules should not be applied after this rule has been applied. + */ + stop?: boolean + /** + * Flag for determining whether the rule should disable purchasing of a product when the conditions are applied. + */ + purchasing_disabled?: boolean + /** + * Message displayed on the storefront when a rule disables the purchasing of a product. + */ + purchasing_disabled_message?: string + /** + * Flag for determining whether the rule should hide purchasing of a product when the conditions are applied. + */ + purchasing_hidden?: boolean + /** + * The URL for an image displayed on the storefront when the conditions are applied. Limit of 8MB per file. + */ + image_url?: string + price_adjuster?: definitions['adjuster_Full'] + weight_adjuster?: definitions['adjuster_Full'] + conditions?: definitions['complexRuleConditionBase'][] + } + /** + * Gets custom fields associated with a product. These allow you to specify additional information that will appear on the product's page, such as a book's ISBN or a DVD's release date. + */ + productCustomField_Base: { + /** + * The unique numeric ID of the custom field; increments sequentially. + * Read-Only + */ + id?: number + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + name: string + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + value: string + } + /** + * The model for a POST to create a custom field on a product. + */ + productCustomField_Post: { + /** + * The unique numeric ID of the custom field; increments sequentially. + * Read-Only + */ + id?: number + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + name: string + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + value: string + } + /** + * The model for a PUT to update a custom field on a product. + */ + productCustomField_Put: { + /** + * The unique numeric ID of the custom field; increments sequentially. + * Read-Only + */ + id?: number + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + name: string + /** + * The name of the field, shown on the storefront, orders, etc. Required for /POST + */ + value: string + } + /** + * Complex rules may return with conditions that apply to one or more variants, or with a single modifier value (if the rules were created using the v2 API or the control panel). Complex rules created or updated in the v3 API must have conditions that either reference multiple `modifier_value_id`'s, or else reference a `modifier_value_id` and a `variant_id`. + */ + complexRuleConditionBase: { + /** + * The unique numeric ID of the rule condition; increments sequentially. Read-Only + */ + id?: number + /** + * The unique numeric ID of the rule with which the condition is associated. + * Read-Only + */ + rule_id?: number + /** + * The unique numeric ID of the modifier with which the rule condition is associated. + * Required in /POST. + */ + modifier_id: number + /** + * The unique numeric ID of the modifier value with which the rule condition is associated. + * Required in /POST. + */ + modifier_value_id: number + /** + * The unique numeric ID of the variant with which the rule condition is associated. + * Required in /POST. + */ + variant_id: number + /** + * (READ-ONLY:) The unique numeric ID of the SKU (v2 API), or Combination, with which the rule condition is associated. This is to maintain cross-compatibility between v2 and v3. + */ + combination_id?: number + } + /** + * The custom URL for the category on the storefront. + */ + customUrl_Full: { + /** + * Category URL on the storefront. + */ + url?: string + /** + * Returns `true` if the URL has been changed from its default state (the auto-assigned URL that BigCommerce provides). + */ + is_customized?: boolean + } + /** + * Common Bulk Pricing Rule properties + */ + bulkPricingRule_Full: { + /** + * Unique ID of the *Bulk Pricing Rule*. Read-Only. + */ + id?: number + /** + * The minimum inclusive quantity of a product to satisfy this rule. Must be greater than or equal to zero. + * Required in /POST. + */ + quantity_min: number + /** + * The maximum inclusive quantity of a product to satisfy this rule. Must be greater than the `quantity_min` value – unless this field has a value of 0 (zero), in which case there will be no maximum bound for this rule. + * Required in /POST. + */ + quantity_max: number + /** + * The type of adjustment that is made. Values: `price` - the adjustment amount per product; `percent` - the adjustment as a percentage of the original price; `fixed` - the adjusted absolute price of the product. + * Required in /POST. + */ + type: 'price' | 'percent' | 'fixed' + /** + * The discount can be a fixed dollar amount or a percentage. For a fixed dollar amount enter it as an integer and the response will return as an integer. For percentage enter the amount as the percentage divided by 100 using string format. For example 10% percent would be “.10”. The response will return as an integer. + * Required in /POST. + */ + amount: number + } + /** + * The values for option config can vary based on the Modifier created. + */ + productOptionConfig_Full: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + /** + * Adjuster for Complex Rules. + */ + adjuster_Full: { + /** + * The type of adjuster for either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster?: 'relative' | 'percentage' + /** + * The numeric amount by which the adjuster will change either the price or the weight of the variant, when the modifier value is selected on the storefront. + */ + adjuster_value?: number + } + /** + * Errors during batch usage for the BigCommerce API. + */ + resp_variantBatchError: { + batch_errors?: (definitions['error_Base'] & { + errors?: { additionalProperties?: string } + })[] + } + /** + * Data about the response, including pagination and collection totals. + */ + metaCollection_Full: { pagination?: definitions['pagination_Full'] } + /** + * Data about the response, including pagination and collection totals. + */ + pagination_Full: { + /** + * Total number of items in the result set. + */ + total?: number + /** + * Total number of items in the collection response. + */ + count?: number + /** + * The amount of items returned in the collection per page, controlled by the limit parameter. + */ + per_page?: number + /** + * The page you are currently on within the collection. + */ + current_page?: number + /** + * The total number of pages in the collection. + */ + total_pages?: number + /** + * Pagination links for the previous and next parts of the whole collection. + */ + links?: { + /** + * Link to the previous page returned in the response. + */ + previous?: string + /** + * Link to the current page returned in the response. + */ + current?: string + /** + * Link to the next page returned in the response. + */ + next?: string + } + } + /** + * Empty meta object; may be used later. + */ + metaEmpty_Full: { [key: string]: any } + errorResponse_Full: definitions['error_Base'] & { + errors?: definitions['detailedErrors'] + } + /** + * Error payload for the BigCommerce API. + */ + error_Base: { + /** + * The HTTP status code. + */ + status?: number + /** + * The error title describing the particular error. + */ + title?: string + type?: string + instance?: string + } + /** + * Error payload for the BigCommerce API. + */ + errorNotFound: { + /** + * 404 HTTP status code. + */ + status?: number + /** + * The error title describing the particular error. + */ + title?: string + type?: string + instance?: string + } + /** + * A gift-certificate model. + */ + giftCertificate_Full: { + /** + * The gift-certificate code. + */ + code?: string + /** + * The balance on a gift certificate when it was purchased. + */ + original_balance?: number + /** + * The balance on a gift certificate at the time of this purchase. + */ + starting_balance?: number + /** + * The remaining balance on a gift certificate. + */ + remaining_balance?: number + /** + * The status of a gift certificate: `active` - gift certificate is active; `pending` - gift certificate purchase is pending; `disabled` - gift certificate is disabled; `expired` - gift certificate is expired. + */ + status?: 'active' | 'pending' | 'disabled' | 'expired' + } + /** + * No-content response for the BigCommerce API. + */ + errorNoContent: { + /** + * 204 HTTP status code. + */ + status?: number + /** + * The error title describing the situation. + */ + title?: string + type?: string + instance?: string + } + detailedErrors: { additionalProperties?: string } + product_Full: definitions['product_Base'] & { + /** + * The date on which the product was created. + */ + date_created?: string + /** + * The date on which the product was modified. + */ + date_modified?: string + /** + * ID of the product. Read Only. + */ + id?: number + /** + * The unique identifier of the base variant associated with a simple product. This value is `null` for complex products. + */ + base_variant_id?: number + /** + * The price of the product as seen on the storefront. It will be equal to the `sale_price`, if set, and the `price` if there is not a `sale_price`. + */ + calculated_price?: number + options?: definitions['productOption_Base'][] + modifiers?: definitions['productModifier_Full'][] + /** + * Minimum Advertised Price. + */ + map_price?: number + /** + * Indicates that the product is in an Option Set (legacy V2 concept). + */ + option_set_id?: number + /** + * Legacy template setting which controls if the option set shows up to the side of or below the product image and description. + */ + option_set_display?: string + } & { variants?: definitions['productVariant_Full'] } + /** + * Common ProductImage properties. + */ + productImage_Full: definitions['productImage_Base'] & { + /** + * The unique numeric ID of the image; increments sequentially. + */ + id?: number + /** + * The unique numeric identifier for the product with which the image is associated. + */ + product_id?: number + /** + * The zoom URL for this image. By default, this is used as the zoom image on product pages when zoom images are enabled. + */ + url_zoom?: string + /** + * The standard URL for this image. By default, this is used for product-page images. + */ + url_standard?: string + /** + * The thumbnail URL for this image. By default, this is the image size used on the category page and in side panels. + */ + url_thumbnail?: string + /** + * The tiny URL for this image. By default, this is the image size used for thumbnails beneath the product image on a product page. + */ + url_tiny?: string + /** + * The date on which the product image was modified. + */ + date_modified?: string + } + metafield_Post: definitions['metafield_Base'] + /** + * The model for batch updating products. + */ + product_Put_Collection: ({ + /** + * The unique numerical ID of the product; increments sequentially. Required on batch product `PUT` requests. + */ + id: number + } & definitions['product_Base'])[] + /** + * The values for option config can vary based on the Modifier created. + */ + config_Full: { + /** + * (date, text, multi_line_text, numbers_only_text) The default value. Shown on a date option as an ISO-8601–formatted string, or on a text option as a string. + */ + default_value?: string + /** + * (checkbox) Flag for setting the checkbox to be checked by default. + */ + checked_by_default?: boolean + /** + * (checkbox) Label displayed for the checkbox option. + */ + checkbox_label?: string + /** + * (date) Flag to limit the dates allowed to be entered on a date option. + */ + date_limited?: boolean + /** + * (date) The type of limit that is allowed to be entered on a date option. + */ + date_limit_mode?: 'earliest' | 'range' | 'latest' + /** + * (date) The earliest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_earliest_value?: string + /** + * (date) The latest date allowed to be entered on the date option, as an ISO-8601 formatted string. + */ + date_latest_value?: string + /** + * (file) The kind of restriction on the file types that can be uploaded with a file upload option. Values: `specific` - restricts uploads to particular file types; `all` - allows all file types. + */ + file_types_mode?: 'specific' | 'all' + /** + * (file) The type of files allowed to be uploaded if the `file_type_option` is set to `specific`. Values: + * `images` - Allows upload of image MIME types (`bmp`, `gif`, `jpg`, `jpeg`, `jpe`, `jif`, `jfif`, `jfi`, `png`, `wbmp`, `xbm`, `tiff`). `documents` - Allows upload of document MIME types (`txt`, `pdf`, `rtf`, `doc`, `docx`, `xls`, `xlsx`, `accdb`, `mdb`, `one`, `pps`, `ppsx`, `ppt`, `pptx`, `pub`, `odt`, `ods`, `odp`, `odg`, `odf`). + * `other` - Allows file types defined in the `file_types_other` array. + */ + file_types_supported?: string[] + /** + * (file) A list of other file types allowed with the file upload option. + */ + file_types_other?: string[] + /** + * (file) The maximum size for a file that can be used with the file upload option. This will still be limited by the server. + */ + file_max_size?: number + /** + * (text, multi_line_text) Flag to validate the length of a text or multi-line text input. + */ + text_characters_limited?: boolean + /** + * (text, multi_line_text) The minimum length allowed for a text or multi-line text option. + */ + text_min_length?: number + /** + * (text, multi_line_text) The maximum length allowed for a text or multi line text option. + */ + text_max_length?: number + /** + * (multi_line_text) Flag to validate the maximum number of lines allowed on a multi-line text input. + */ + text_lines_limited?: boolean + /** + * (multi_line_text) The maximum number of lines allowed on a multi-line text input. + */ + text_max_lines?: number + /** + * (numbers_only_text) Flag to limit the value of a number option. + */ + number_limited?: boolean + /** + * (numbers_only_text) The type of limit on values entered for a number option. + */ + number_limit_mode?: 'lowest' | 'highest' | 'range' + /** + * (numbers_only_text) The lowest allowed value for a number option if `number_limited` is true. + */ + number_lowest_value?: number + /** + * (numbers_only_text) The highest allowed value for a number option if `number_limited` is true. + */ + number_highest_value?: number + /** + * (numbers_only_text) Flag to limit the input on a number option to whole numbers only. + */ + number_integers_only?: boolean + /** + * (product_list, product_list_with_images) Flag for automatically adjusting inventory on a product included in the list. + */ + product_list_adjusts_inventory?: boolean + /** + * (product_list, product_list_with_images) Flag to add the optional product's price to the main product's price. + */ + product_list_adjusts_pricing?: boolean + /** + * (product_list, product_list_with_images) How to factor the optional product's weight and package dimensions into the shipping quote. Values: `none` - don't adjust; `weight` - use shipping weight only; `package` - use weight and dimensions. + */ + product_list_shipping_calc?: 'none' | 'weight' | 'package' + } + adjusters_Full: { + price?: definitions['adjuster_Full'] + weight?: definitions['adjuster_Full'] + /** + * The URL for an image displayed on the storefront when the modifier value is selected.Limit of 8MB per file. + */ + image_url?: string + purchasing_disabled?: { + /** + * Flag for whether the modifier value disables purchasing when selected on the storefront. This can be used for temporarily disabling a particular modifier value. + */ + status?: boolean + /** + * The message displayed on the storefront when the purchasing disabled status is `true`. + */ + message?: string + } + } + /** + * Variant properties used on: + * * `/catalog/products/variants` + * * `/catalog/variants` + */ + variant_Base: { + /** + * The cost price of the variant. Not affected by Price List prices. + */ + cost_price?: number + /** + * This variant's base price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is `null`, the product's default price (set in the Product resource's `price` field) will be used as the base price. + */ + price?: number + /** + * This variant's sale price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's sale price (set in the Product resource's `price` field) will be used as the sale price. + */ + sale_price?: number + /** + * This variant's retail price on the storefront. If a Price List ID is used, the Price List value will be used. If a Price List ID is not used, and this value is null, the product's retail price (set in the Product resource's `price` field) will be used as the retail price. + */ + retail_price?: number + /** + * This variant's base weight on the storefront. If this value is null, the product's default weight (set in the Product resource's weight field) will be used as the base weight. + */ + weight?: number + /** + * Width of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default width (set in the Product resource's `width` field) will be used as the base width. + */ + width?: number + /** + * Height of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default height (set in the Product resource's `height` field) will be used as the base height. + */ + height?: number + /** + * Depth of the variant, which can be used when calculating shipping costs. If this value is `null`, the product's default depth (set in the Product resource's `depth` field) will be used as the base depth. + */ + depth?: number + /** + * Flag used to indicate whether the variant has free shipping. If `true`, the shipping cost for the variant will be zero. + */ + is_free_shipping?: boolean + /** + * A fixed shipping cost for the variant. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * If `true`, this variant will not be purchasable on the storefront. + */ + purchasing_disabled?: boolean + /** + * If `purchasing_disabled` is `true`, this message should show on the storefront when the variant is selected. + */ + purchasing_disabled_message?: string + /** + * The UPC code used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * Inventory level for the variant, which is used when the product's inventory_tracking is set to `variant`. + */ + inventory_level?: number + /** + * When the variant hits this inventory level, it is considered low stock. + */ + inventory_warning_level?: number + /** + * Identifies where in a warehouse the variant is located. + */ + bin_picking_number?: string + } + /** + * Shared `Product` properties used in: + * * `POST` + * * `PUT` + * * `GET` + */ + product_Base: { + /** + * The product name. + */ + name: string + /** + * The product type. One of: `physical` - a physical stock unit, `digital` - a digital download. + */ + type: 'physical' | 'digital' + /** + * User defined product code/stock keeping unit (SKU). + */ + sku?: string + /** + * The product description, which can include HTML formatting. + */ + description?: string + /** + * Weight of the product, which can be used when calculating shipping costs. This is based on the unit set on the store + */ + weight: number + /** + * Width of the product, which can be used when calculating shipping costs. + */ + width?: number + /** + * Depth of the product, which can be used when calculating shipping costs. + */ + depth?: number + /** + * Height of the product, which can be used when calculating shipping costs. + */ + height?: number + /** + * The price of the product. The price should include or exclude tax, based on the store settings. + */ + price: number + /** + * The cost price of the product. Stored for reference only; it is not used or displayed anywhere on the store. + */ + cost_price?: number + /** + * The retail cost of the product. If entered, the retail cost price will be shown on the product page. + */ + retail_price?: number + /** + * If entered, the sale price will be used instead of value in the price field when calculating the product's cost. + */ + sale_price?: number + /** + * The ID of the tax class applied to the product. (NOTE: Value ignored if automatic tax is enabled.) + */ + tax_class_id?: number + /** + * Accepts AvaTax System Tax Codes, which identify products and services that fall into special sales-tax categories. By using these codes, merchants who subscribe to BigCommerce's Avalara Premium integration can calculate sales taxes more accurately. Stores without Avalara Premium will ignore the code when calculating sales tax. Do not pass more than one code. The codes are case-sensitive. For details, please see Avalara's documentation. + */ + product_tax_code?: string + /** + * An array of IDs for the categories to which this product belongs. When updating a product, if an array of categories is supplied, all product categories will be overwritten. Does not accept more than 1,000 ID values. + */ + categories?: number[] + /** + * A product can be added to an existing brand during a product /PUT or /POST. + */ + brand_id?: number + /** + * Current inventory level of the product. Simple inventory tracking must be enabled (See the `inventory_tracking` field) for this to take any effect. + */ + inventory_level?: number + /** + * Inventory warning level for the product. When the product's inventory level drops below the warning level, the store owner will be informed. Simple inventory tracking must be enabled (see the `inventory_tracking` field) for this to take any effect. + */ + inventory_warning_level?: number + /** + * The type of inventory tracking for the product. Values are: `none` - inventory levels will not be tracked; `product` - inventory levels will be tracked using the `inventory_level` and `inventory_warning_level` fields; `variant` - inventory levels will be tracked based on variants, which maintain their own warning levels and inventory levels. + */ + inventory_tracking?: 'none' | 'product' | 'variant' + /** + * A fixed shipping cost for the product. If defined, this value will be used during checkout instead of normal shipping-cost calculation. + */ + fixed_cost_shipping_price?: number + /** + * Flag used to indicate whether the product has free shipping. If `true`, the shipping cost for the product will be zero. + */ + is_free_shipping?: boolean + /** + * Flag to determine whether the product should be displayed to customers browsing the store. If `true`, the product will be displayed. If `false`, the product will be hidden from view. + */ + is_visible?: boolean + /** + * Flag to determine whether the product should be included in the `featured products` panel when viewing the store. + */ + is_featured?: boolean + /** + * An array of IDs for the related products. + */ + related_products?: number[] + /** + * Warranty information displayed on the product page. Can include HTML formatting. + */ + warranty?: string + /** + * The BIN picking number for the product. + */ + bin_picking_number?: string + /** + * The layout template file used to render this product category. This field is writable only for stores with a Blueprint theme applied. + */ + layout_file?: string + /** + * The product UPC code, which is used in feeds for shopping comparison sites and external channel integrations. + */ + upc?: string + /** + * A comma-separated list of keywords that can be used to locate the product when searching the store. + */ + search_keywords?: string + /** + * Availability of the product. Availability options are: `available` - the product can be purchased on the storefront; `disabled` - the product is listed in the storefront, but cannot be purchased; `preorder` - the product is listed for pre-orders. + */ + availability?: 'available' | 'disabled' | 'preorder' + /** + * Availability text displayed on the checkout page, under the product title. Tells the customer how long it will normally take to ship this product, such as: 'Usually ships in 24 hours.' + */ + availability_description?: string + /** + * Type of gift-wrapping options. Values: `any` - allow any gift-wrapping options in the store; `none` - disallow gift-wrapping on the product; `list` – provide a list of IDs in the `gift_wrapping_options_list` field. + */ + gift_wrapping_options_type?: 'any' | 'none' | 'list' + /** + * A list of gift-wrapping option IDs. + */ + gift_wrapping_options_list?: number[] + /** + * Priority to give this product when included in product lists on category pages and in search results. Lower integers will place the product closer to the top of the results. + */ + sort_order?: number + /** + * The product condition. Will be shown on the product page if the `is_condition_shown` field's value is `true`. Possible values: `New`, `Used`, `Refurbished`. + */ + condition?: 'New' | 'Used' | 'Refurbished' + /** + * Flag used to determine whether the product condition is shown to the customer on the product page. + */ + is_condition_shown?: boolean + /** + * The minimum quantity an order must contain, to be eligible to purchase this product. + */ + order_quantity_minimum?: number + /** + * The maximum quantity an order can contain when purchasing the product. + */ + order_quantity_maximum?: number + /** + * Custom title for the product page. If not defined, the product name will be used as the meta title. + */ + page_title?: string + /** + * Custom meta keywords for the product page. If not defined, the store's default keywords will be used. + */ + meta_keywords?: string[] + /** + * Custom meta description for the product page. If not defined, the store's default meta description will be used. + */ + meta_description?: string + /** + * The number of times the product has been viewed. + */ + view_count?: number + /** + * Pre-order release date. See the `availability` field for details on setting a product's availability to accept pre-orders. + */ + preorder_release_date?: string + /** + * Custom expected-date message to display on the product page. If undefined, the message defaults to the storewide setting. Can contain the `%%DATE%%` placeholder, which will be substituted for the release date. + */ + preorder_message?: string + /** + * If set to true then on the preorder release date the preorder status will automatically be removed. + * If set to false, then on the release date the preorder status **will not** be removed. It will need to be changed manually either in the + * control panel or using the API. Using the API set `availability` to `available`. + */ + is_preorder_only?: boolean + /** + * False by default, indicating that this product's price should be shown on the product page. If set to `true`, the price is hidden. (NOTE: To successfully set `is_price_hidden` to `true`, the `availability` value must be `disabled`.) + */ + is_price_hidden?: boolean + /** + * By default, an empty string. If `is_price_hidden` is `true`, the value of `price_hidden_label` is displayed instead of the price. (NOTE: To successfully set a non-empty string value with `is_price_hidden` set to `true`, the `availability` value must be `disabled`.) + */ + price_hidden_label?: string + custom_url?: definitions['customUrl_Full'] + /** + * Type of product, defaults to `product`. + */ + open_graph_type?: + | 'product' + | 'album' + | 'book' + | 'drink' + | 'food' + | 'game' + | 'movie' + | 'song' + | 'tv_show' + /** + * Title of the product, if not specified the product name will be used instead. + */ + open_graph_title?: string + /** + * Description to use for the product, if not specified then the meta_description will be used instead. + */ + open_graph_description?: string + /** + * Flag to determine if product description or open graph description is used. + */ + open_graph_use_meta_description?: boolean + /** + * Flag to determine if product name or open graph name is used. + */ + open_graph_use_product_name?: boolean + /** + * Flag to determine if product image or open graph image is used. + */ + open_graph_use_image?: boolean + /** + * The brand can be created during a product PUT or POST request. If the brand already exists then the product will be added. If not the brand will be created and the product added. If using `brand_name` it performs a fuzzy match and adds the brand. eg. "Common Good" and "Common good" are the same. Brand name does not return as part of a product response. Only the `brand_id`. + */ + 'brand_name or brand_id'?: string + /** + * Global Trade Item Number + */ + gtin?: string + /** + * Manufacturer Part Number + */ + mpn?: string + /** + * The total rating for the product. + */ + reviews_rating_sum?: number + /** + * The number of times the product has been rated. + */ + reviews_count?: number + /** + * The total quantity of this product sold. + */ + total_sold?: number + custom_fields?: definitions['productCustomField_Put'][] + bulk_pricing_rules?: definitions['bulkPricingRule_Full'][] + images?: definitions['productImage_Full'][] + primary_image?: definitions['productImage_Full'] + videos?: definitions['productVideo_Full'][] + } + /** + * Properties for updating metafields. + */ + metafield_Put: { + /** + * Unique ID of the *Metafield*. Read-Only. + */ + id?: number + } & definitions['metafield_Base'] + metafield_Full: definitions['metafield_Put'] & { + /** + * Date and time of the metafield's creation. Read-Only. + */ + date_created?: string + /** + * Date and time when the metafield was last updated. Read-Only. + */ + date_modified?: string + } + /** + * The model for a PUT to update variants on a product. + */ + productVariant_Put: definitions['productVariant_Base'] & { + product_id?: number + sku?: string + } +} diff --git a/lib/bigcommerce/cart/use-cart.tsx b/lib/bigcommerce/cart/use-cart.tsx index 525d1f82c..255791a5d 100644 --- a/lib/bigcommerce/cart/use-cart.tsx +++ b/lib/bigcommerce/cart/use-cart.tsx @@ -1,3 +1,4 @@ +import { ConfigInterface } from 'swr' import { HookFetcher, HookDeps } from '@lib/commerce/utils/types' import useCommerceCart from '@lib/commerce/cart/use-cart' import type { Cart } from '../api/cart' @@ -8,24 +9,22 @@ const defaultOpts = { export type { Cart } -export const fetcher: HookFetcher = ( - options, - _, - fetch -) => { +export const fetcher: HookFetcher = (options, _, fetch) => { return fetch({ url: options?.url, query: options?.query, }) } -export function extendHook(customFetcher: typeof fetcher) { +export function extendHook( + customFetcher: typeof fetcher, + swrOptions?: ConfigInterface +) { const useCart = () => { - const cart = useCommerceCart( - [defaultOpts.url, undefined], - customFetcher, - { revalidateOnFocus: false } - ) + const cart = useCommerceCart(defaultOpts, [], customFetcher, { + revalidateOnFocus: false, + ...swrOptions, + }) // Uses a getter to only calculate the prop when required // cart.data is also a getter and it's better to not trigger it early diff --git a/lib/bigcommerce/products/use-search.tsx b/lib/bigcommerce/products/use-search.tsx new file mode 100644 index 000000000..b6953bd62 --- /dev/null +++ b/lib/bigcommerce/products/use-search.tsx @@ -0,0 +1,52 @@ +import useSWR, { ConfigInterface } from 'swr' +import { HookDeps, HookFetcher } from '@lib/commerce/utils/types' +import useCommerceSearch from '@lib/commerce/products/use-search' +import type { Product } from '../api/catalog/products' +import { useCommerce } from '..' + +const defaultOpts = { + url: '/api/bigcommerce/catalog/products', + method: 'GET', +} + +export type SearchProductsInput = { + search?: string +} + +export const fetcher: HookFetcher = ( + options, + { search }, + fetch +) => { + // Use a dummy base as we only care about the relative path + const url = new URL(options?.url ?? defaultOpts.url, 'http://a') + + if (search) url.searchParams.set('search', search) + + return fetch({ + url: url.pathname + url.search, + method: options?.method ?? defaultOpts.method, + }) +} + +export function extendHook( + customFetcher: typeof fetcher, + swrOptions?: ConfigInterface +) { + const useSearch = (input: SearchProductsInput = {}) => { + const response = useCommerceSearch( + defaultOpts, + [['search', input.search]], + customFetcher, + { revalidateOnFocus: false, ...swrOptions } + ) + + return response + } + + useSearch.extend = extendHook + + return useSearch +} + +export default extendHook(fetcher) diff --git a/lib/commerce/cart/use-cart.tsx b/lib/commerce/cart/use-cart.tsx index 0f2485667..dde1ee513 100644 --- a/lib/commerce/cart/use-cart.tsx +++ b/lib/commerce/cart/use-cart.tsx @@ -1,6 +1,6 @@ import useSWR, { responseInterface, ConfigInterface } from 'swr' import Cookies from 'js-cookie' -import { HookDeps, HookFetcher } from '../utils/types' +import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types' import { useCommerce } from '..' export type CartResponse = responseInterface & { @@ -8,16 +8,28 @@ export type CartResponse = responseInterface & { } export default function useCart( - deps: [string | undefined, string | undefined, ...HookDeps[]], - fetcherFn: HookFetcher, + options: HookFetcherOptions, + input: HookInput, + fetcherFn: HookFetcher, swrOptions?: ConfigInterface ) { const { fetcherRef, cartCookie } = useCommerce() - const fetcher = (url?: string, query?: string, ...args: HookDeps[]) => + const fetcher = (url?: string, query?: string, ...args: any[]) => Cookies.get(cartCookie) - ? fetcherFn({ url, query }, args, fetcherRef.current) + ? fetcherFn( + { url, query }, + args.reduce((obj, val, i) => { + obj[input[i][1]!] = val + return obj + }, {}), + fetcherRef.current + ) : null - const response = useSWR(deps, fetcher, swrOptions) + const response = useSWR( + [options.url, options.query, ...input.map((e) => e[1])], + fetcher, + swrOptions + ) return Object.assign(response, { isEmpty: true }) as CartResponse } diff --git a/lib/commerce/products/use-search.tsx b/lib/commerce/products/use-search.tsx new file mode 100644 index 000000000..73548b381 --- /dev/null +++ b/lib/commerce/products/use-search.tsx @@ -0,0 +1,28 @@ +import useSWR, { ConfigInterface } from 'swr' +import type { HookInput, HookFetcher, HookFetcherOptions } from '../utils/types' +import { useCommerce } from '..' + +export default function useSearch( + options: HookFetcherOptions, + input: HookInput, + fetcherFn: HookFetcher, + swrOptions?: ConfigInterface +) { + const { fetcherRef } = useCommerce() + const fetcher = (url?: string, query?: string, ...args: any[]) => + fetcherFn( + { url, query }, + args.reduce((obj, val, i) => { + obj[input[i][1]!] = val + return obj + }, {}), + fetcherRef.current + ) + const response = useSWR( + [options.url, options.query, ...input.map((e) => e[1])], + fetcher, + swrOptions + ) + + return response +} diff --git a/lib/commerce/utils/types.ts b/lib/commerce/utils/types.ts index 6cad2c7e2..0af754fc0 100644 --- a/lib/commerce/utils/types.ts +++ b/lib/commerce/utils/types.ts @@ -21,4 +21,6 @@ export type HookFetcherOptions = { method?: string } +export type HookInput = [string, string | number | undefined][] + export type HookDeps = string | number | undefined[] diff --git a/pages/api/bigcommerce/catalog/products.ts b/pages/api/bigcommerce/catalog/products.ts new file mode 100644 index 000000000..41ec81526 --- /dev/null +++ b/pages/api/bigcommerce/catalog/products.ts @@ -0,0 +1,3 @@ +import catalogProductsApi from '@lib/bigcommerce/api/catalog/products' + +export default catalogProductsApi() diff --git a/pages/index.tsx b/pages/index.tsx index 70e6b6257..b447c1e07 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -4,8 +4,6 @@ import { Layout } from '@components/core' import { Grid, Marquee, Hero } from '@components/ui' import { ProductCard } from '@components/product' import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' -import { useEffect } from 'react' -import { useRouter } from 'next/router' export async function getStaticProps({ preview }: GetStaticPropsContext) { const { products } = await getAllProducts() @@ -21,12 +19,6 @@ export default function Home({ categories, brands, }: InferGetStaticPropsType) { - const router = useRouter() - - useEffect(() => { - router.prefetch('/search') - }, []) - return (
diff --git a/pages/search.tsx b/pages/search.tsx index bc560d6f8..ce864da46 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -1,9 +1,10 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' -import { Layout } from '@components/core' -import { Grid, Marquee, Hero } from '@components/ui' -import { ProductCard } from '@components/product' import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' +import useSearch from '@lib/bigcommerce/products/use-search' +import { Layout } from '@components/core' +import { Grid } from '@components/ui' +import { ProductCard } from '@components/product' import { useRouter } from 'next/router' export async function getStaticProps({ preview }: GetStaticPropsContext) { @@ -21,6 +22,10 @@ export default function Home({ brands, }: InferGetStaticPropsType) { const router = useRouter() + const search = useSearch({ search: router.query.search as string }) + + console.log('SEARCH', search) + return (