get_products()

/**
 * Retrieve all the products regardless of status.
 *
 * @return array
 * @throws ReflectionException
 * @throws UnresolvableQueryHandlerException
 */
function get_products(): array;

get_all_products_with_filters()

/**
 * Retrieve all products or a product based on filters.
 *
 * @file core/Shared/Helpers/product.php
 * @param string|null $productSku Product sku.
 * @param int $limit Number of products to show.
 * @param int|null $offset The offset of the first row to be returned.
 * @param string $status Returned unescaped product based on status (all, draft, published, pending, archived)
 * @return array Array of published products or product by particular sku.
 * @throws CommandPropertyNotFoundException
 * @throws ReflectionException
 * @throws UnresolvableQueryHandlerException
 */
function get_all_products_with_filters(
    ?string $productSku = null,
    int $limit = 0,
    int $offset = null,
    string $status = 'all'
): array;

get_product_by()

/**
 * Retrieve product by a given field from the product table.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $field The field to retrieve the product with
 *                      (id = product_id, sku = product_sku, slug = product_slug).
 * @param string $value A value for $field (product_id, product_sku, product_slug).
 * @return false|object
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_by(string $field, string $value): false|object;

get_product_by_id()

/**
 * Retrieve product by the product id.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId
 * @return false|object
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_by_id(string $productId): object|false;

get_product_datetime()

/**
 * A function which retrieves product datetime.
 *
 * Purpose of this function is for the `get.product.datetime`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string|null $product
 * @return string Product datetime.
 * @throws ReflectionException
 * @throws Exception
 */
function get_product_datetime(?string $product = null): string;

get_product_modified()

/**
 * A function which retrieves product modified datetime.
 *
 * Purpose of this function is for the `get.product.modified`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string Product modified datetime or '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_modified(string $productId): string;

get_product_body()

/**
 * A function which retrieves a product body.
 *
 * Purpose of this function is for the `get.product.body`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string Product body or '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_body(string $productId): string;

get_product_sku()

/**
 * A function which retrieves a product product_type name.
 *
 * Purpose of this function is for the `get.product.sku`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string|false Product type name or '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_sku(string $productId): false|string;

get_product_title()

/**
 * A function which retrieves a product title.
 *
 * Purpose of this function is for the `get.product.title`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string Product title or '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_title(string $productId): string;

get_product_slug()

/**
 * A function which retrieves a product slug.
 *
 * Purpose of this function is for the `get.product.slug`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string Product slug or ''.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_slug(string $productId): string;

product_status_label()

/**
 * Adds label to product's status.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $status
 * @return string Product status label.
 */
function product_status_label(string $status): string;

get_product_attribute()

/**
 * Retrieve product attribute for a product.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product ID.
 * @param string $key The attribute key to retrieve.
 * @param mixed $default Optional. Whether to return a single value. Default false.
 * @return mixed Attribute value.
 * @throws ContainerExceptionInterface
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 */
function get_product_attribute(string $productId, string $key, mixed $default = null): mixed;

update_product_attribute()

/**
 * Update product attribute based on product ID.
 *
 * If the attribute for the product does not exist, it will be added.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product ID.
 * @param string $key Attribute key.
 * @param mixed $value Attribute value. Must be serializable if non-scalar.
 * @return AttributeBag
 * @throws ContainerExceptionInterface
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 */
function update_product_attribute(
    string $productId,
    string $key,
    mixed $value,
): AttributeBag;

add_product_attribute()

/**
 * Add attribute to a product.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product ID.
 * @param string $key Attribute name.
 * @param mixed $value Attribute value. Must be serializable if non-scalar.
 * @return AttributeBag
 * @throws ContainerExceptionInterface
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 */
function add_product_attribute(string $productId, string $key, mixed $value): AttributeBag;

delete_product_attribute()

/**
 * Remove attribute matching criteria from a product.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product ID.
 * @param string $key Attribute name.
 * @return AttributeBag
 * @throws ContainerExceptionInterface
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 */
function delete_product_attribute(string $productId, string $key): AttributeBag;

get_product_author_id()

/**
 * A function which retrieves a product author id.
 *
 * Purpose of this function is for the `get.product.author.id`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return false|string Product author id or false on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_author_id(string $productId): false|string;

get_product_author()

/**
 * A function which retrieves a product author.
 *
 * Purpose of this function is for the `get.product.author`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Optional Product id or product object.
 * @param bool $reverse If first name should appear first or not. Default is false.
 * @return string|false Product author or false on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_author(string $productId, bool $reverse = false): false|string;

get_product_status()

/**
 * A function which retrieves a product status.
 *
 * Purpose of this function is for the `get.product.status`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return string|false Product status or false on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_status(string $productId): false|string;

get_product_date()

/**
 * A function which retrieves product date.
 *
 * Uses `call_user_func_array()` function to return appropriate product date function.
 * Dynamic part is the variable $type, which calls the date function you need.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $type Type of date to return: created, published, modified. Default: published.
 * @param string $productId Product id.
 * @return string Product date.
 */
function get_product_date(string $type = 'published', string $productId = ''): string;

get_product_time()

/**
 * A function which retrieves product time.
 *
 * Uses `call_user_func_array()` function to return appropriate product time function.
 * Dynamic part is the variable $type, which calls the date function you need.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $type Type of date to return: created, published, modified. Default: published.
 * @param string $productId Product id.
 * @return string Product time.
 */
function get_product_time(string $type = 'published', string $productId = ''): string;

get_product_created_date()

/**
 * Retrieves product created date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was created.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product created date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_created_date(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_created_date()

/**
 * Retrieves product created date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was created.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'date_format' option. Default empty.
 * @return string Formatted product created date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_created_date(string $productId, string $format = ''): string;

get_product_created_time()

/**
 * A function which retrieves product created time.
 *
 * Purpose of this function is for the `get.product.created.time`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was created.
 *                        Accepts 'G', 'U', or php date format value specified
 *                        in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product created time string or Unix timestamp
 *                          if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_created_time(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_created_time()

/**
 * Retrieves product created time.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was written.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'time_format' option. Default empty.
 * @return string Formatted product created time string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_created_time(string $productId, string $format = ''): string;

get_product_published_date()

/**
 * A function which retrieves product published date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was published.
 *                        Accepts 'G', 'U', or php date format value specified
 *                        in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product published date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_published_date(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_published_date()

/**
 * Retrieves product published date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was published.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'date_format' option. Default empty.
 * @return string Formatted product published date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_published_date(string $productId, string $format = ''): string;

get_product_published_time()

/**
 * A function which retrieves product published time.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was published.
 *                        Accepts 'G', 'U', or php date format value specified
 *                        in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product published time string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_published_time(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_published_time()

/**
 * Retrieves product published time.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was published.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'time_format' option. Default empty.
 * @return string Formatted product published time string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_published_time(string $productId, string $format = ''): string;

get_product_modified_date()

/**
 * A function which retrieves product modified date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was modified.
 *                        Accepts 'G', 'U', or php date format value specified
 *                        in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product modified date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_modified_date(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_modified_date()

/**
 * Retrieves product published date.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the date the product was published.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'date_format' option. Default empty.
 * @return string Formatted product modified date string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_modified_date(string $productId, string $format = ''): string;

get_product_modified_time()

/**
 * A function which retrieves product modified time.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was modified.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'date_format' option. Default 'U'.
 * @param bool $gmt Whether to use GMT. Default false.
 * @param bool $translate Whether the returned string should be translated. Default false.
 * @return string Formatted product modified time string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_modified_time(
    string $productId,
    string $format = 'U',
    bool $gmt = false,
    bool $translate = false
): string;

the_product_modified_time()

/**
 * Retrieves product modified time.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @param string $format Format to use for retrieving the time the product was modified.
 *                       Accepts 'G', 'U', or php date format value specified
 *                       in 'time_format' option. Default empty.
 * @return string Formatted product modified time string or Unix timestamp
 *                if $format is 'U' or 'G'. '' on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_modified_time(string $productId, string $format = ''): string;

get_product_show_in_menu()

/**
 * A function which retrieves product show in menu.
 *
 * Purpose of this function is for the `get.product.show.in.menu`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return int Product show in menu integer or 0 on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_show_in_menu(string $productId): int;
/**
 * A function which retrieves product show in search.
 *
 * Purpose of this function is for the `get.product.show.in.search`
 * filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id.
 * @return int Product show in search integer or 0 on failure.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_show_in_search(string $productId): int;

cms_unique_product_slug()

/**
 * Creates a unique product slug.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $originalSlug Original slug of product.
 * @param string $originalTitle Original title of product.
 * @param string|null $productId Unique product id or null.
 * @return string Unique product slug.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function cms_unique_product_slug(
    string $originalSlug,
    string $originalTitle,
    ?string $productId = null,
): string;

cms_insert_product()

/**
 * Insert or update a product.
 *
 * All the `$productdata` array fields have filters associated with the values. The filters
 * have the prefix 'pre.' followed by the field name. An example using 'product_status' would have
 * the filter called, 'pre.product.status' that can be hooked into.
 *
 * @file core/Shared/Helpers/product.php
 * @param array|ServerRequestInterface|Product $productdata An array of data that is used for insert or update.
 *
 *      @type string $title The product's title.
 *      @type string $body The product's body.
 *      @type string $slug The product's slug.
 *      @type string $author The product's author.
 *      @type string $sku The product's parent.
 *      @type string $price The product's price.
 *      @type string $currency The product's currency.
 *      @type string $purchaseUrl The product's purchase url.
 *      @type string $showInMenu Whether to show product in menu.
 *      @type string $showInSearch Whether to show product in search.
 *      @type string $relativeUrl The product's relative url.
 *      @type string $featuredImage THe product's featured image.
 *      @type string $status THe product's status.
 *      @type string $published Timestamp describing the moment when the product
 *                              was published. Defaults to Y-m-d h:i A.
 * @return Error|string|null The newly created product's product_id or throws an error or returns null
 *                           if the product could not be created or updated.
 * @throws CommandCouldNotBeHandledException
 * @throws CommandPropertyNotFoundException
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws ReflectionException
 * @throws TypeException
 * @throws UnresolvableCommandHandlerException
 * @throws UnresolvableQueryHandlerException
 * @throws ContainerExceptionInterface
 * @throws NotFoundExceptionInterface
 */
function cms_insert_product(array|ServerRequestInterface|Product $productdata): Error|string|null;

cms_update_product()

/**
 * Update a product in the product document.
 *
 * See {@see cms_insert_product()} For what fields can be set in $productdata.
 *
 * @file core/Shared/Helpers/product.php
 * @param array|ServerRequestInterface|Product $productdata An array of product data or a product object.
 * @return string|Error The updated product's id or return Error if product could not be updated.
 * @throws CommandCouldNotBeHandledException
 * @throws CommandPropertyNotFoundException
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 * @throws UnresolvableCommandHandlerException
 * @throws UnresolvableQueryHandlerException
 */
function cms_update_product(array|ServerRequestInterface|Product $productdata): string|Error;

cms_delete_product()

/**
 * Deletes product from the product document.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId The id of the product to delete.
 * @return bool|Product Product on success or false on failure.
 * @throws CommandCouldNotBeHandledException
 * @throws CommandPropertyNotFoundException
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 * @throws TypeException
 * @throws UnresolvableCommandHandlerException
 */
function cms_delete_product(string $productId): Product|bool;

get_product_class()

/**
 * Retrieves an array of CSS class names.
 *
 * @file core/Shared/Helpers/product.php
 * @param string $productId Product id of current product.
 * @param string|array $class One or more CSS class names to add to element list.
 * @return array An array of CSS class names.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws InvalidArgumentException
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function get_product_class(string $productId, string|array $class = ''): array;

the_product_attribute()

/**
 * Retrieves and displays product attribute value.
 *
 * Uses `the.product.attribute` filter.
 *
 * @file core/Shared/Helpers/product.php
 * @param string|Product|ProductId $product Product object or id.
 * @param string $key Product attribute key.
 * @return string Product attribute value.
 * @throws ContainerExceptionInterface
 * @throws Exception
 * @throws NotFoundExceptionInterface
 * @throws ReflectionException
 */
function the_product_attribute(string|Product|ProductId $product, string $key): string;

currency_option()

/**
 * Currency dropdown options.
 * 
 * @param string|null $active Currency selected.
 * @return void
 */
function currency_option(?string $active = null): void;