Product options allow merchants to give customers one or more choices for a product before adding the product to the cart. This area of the API allows you to manage how that is done.
The following pre-requisites will be necessary to accomplish the goals of this article:
- General understanding of REST and API’s
If you haven’t already done so, you should probably have a development environment ready to development against, complete with Hotcakes installed and configured.
REST API Endpoints for Product Options
There are a handful of REST API endpoints that allow you to display or manage various aspects of product options. Those endpoints are detailed below.
|ProductOptionsAssignToProduct||Boolean||This method allows you to assign a product option to the specified product and optionally generate variants for the product using the available options. You should generally not generate variants in this method and call the ProductOptionsGenerateAllVariants method after all options have been added to the product instead.|
|ProductOptionsCreate||OptionDTO||This method allows you to create a new product option in the store.|
|ProductOptionsDelete||Boolean||Permanently deletes the specified product option from the store.|
|ProductOptionsFind||OptionDTO||Allows you to find a specific product option using its ID.|
|ProductOptionsFindAll||List of OptionDTO||This method allows you to find all instances of product options in the store.|
|ProductOptionsFindAllByProductId||List of OptionDTO||When called, this method allows you to find only the product options that match the specified product.|
|ProductOptionsGenerateAllVariants||Boolean||Generates all possible variants for the specified product. If no variants were created, then there were no possible variants to create.|
|ProductOptionsUnassignFromProduct||Boolean||This endpoint allows you to remove a product option assignment from a product.|
|ProductOptionsUpdate||OptionDTO||When called, this method allows you to save changes to a specific product option.|