Adding support for a currency to an Aurora-based store with REST API

With the currency added to HCL Commerce and the currency format and search facets defined in the environment database, you can now add the currency to the list of supported currencies for your asset stores and customer-facing store. By adding this support, your storefront users can now actually select and view prices in the new currency.

In this lesson, you complete the following high-level tasks to add support for the currency to a store:
  • Configure your environment stores (catalog asset store and customer-facing extended site stores) within Management Center to support the display of prices in the new currency.
  • Update store products to include specific prices for the products in the currency.

    Alternatively, you can choose to define how prices can be converted from the default store currency to the new currency. You can use REST API to define the currency conversion rate.

Procedure

  1. Compose the REST API request to add the currency to the a specific store.
    To compose the API call you need the following details for identifying the store and currency:
    • The store ID. This ID identifies the store where you are adding the support for the currency.
    • The code for identify the currency within yourHCL Commerce environment.

    If you want to add the currency to an extended sites store, you might need to complete multiple POST calls. If the currency is needed within multiple extended sites stores, you should add the currency to the catalog asset store and then add the currency to the extended site store itself. Add the currency to these stores in the following sequence.

    When you are adding currencies to either the catalog asset store or customer-facing extended site store you need to use the following Administrative REST API:
    The body of the call to add the currency to the catalog asset store and an extended site store can resemble the following body structure:
    
    {
        "items": [
           {
    	  \"storeId\":{{catalogAssetStoreId}},
             \"currency\":\"{{code}}\"
    	},
           {
    	  \"storeId\":{{esiteStoreId}},
             \"currency\":\"{{code}}\"
           },
        ]
    }
    
  2. Run your REST API calls add the currency to your store.
    To run your REST API calls, you can bundle your REST calls into a JSON collection with the API calls for adding the currency to HCL Commerce to run all the calls in sequence. The following collection shows how to bundle the API calls for adding a currency.
    To use this collection, you need to define the environment variables for the API. The API calls within the collection are structured with variables. The values that are used for the variables can be included within a separate JSON file. The following file includes sample values for defining the Indian Rupee (INR) currency for the default Aurora catalog asset store and extended site store. Replace the sample values that are set within the file with the values for the stores and the currency that you are adding to your environment. You can then use the collection and values files to run the API requests to add the currency.
  3. Verify that your currency is added to HCL Commerce and your store.
    1. Open the Management Center Store Management tool.
    2. From the Explorer view click Stores.
    3. From the list of available stores, right-click your catalog asset store and click Open.
    4. Within the properties view, review the list of supported currencies for the store.
      Your new currency should display within this list.
    5. Repeat the previous steps to verify that the language is available for your extended site store.

What to do next

  1. Update your store's product prices to include prices in the new currency. You can use the following offer price API to define offer prices in the new currency.
    https://{{ts-hostname}}:{{ts-port}}/rest/admin/v2/offer-prices
    You need to replace the following values within these API calls with the values for your environment:
    ts-hostname
    The name of the host where your transaction server is hosted.
    ts-port
    The port number for your transaction server host.
    When you issue the API request you can include multiple items within the body to set the offer prices for different products and product SKUs. For instance, the following sample body includes items for setting prices in a new currency for products that have the code GFR033_3301 and GFR033_3302 and product SKUs that have the code GFR033_330101 and GFR033_330201.
    
    {
        "items": [
            {
                "offerId": 4000000000000004123,
                "currency": "{{code}}",
                "price": 21
            },
            {
                "offerId": 4000000000000002702,
                "currency": "{{code}}",
                "price": 11
            },
            {
                "offerId": 4000000000000004701,
                "currency": "{{code}}",
                "price": 21.5
            },
            {
                "offerId": 4000000000000002703,
                "currency": "{{code}}",
                "price": 11.5
            },
            {
                "offerId": 4000000000000004125,
                "currency": "{{code}}",
                "price": 15.5
            },
            {
                "offerId": 4000000000000002704,
                "currency": "{{code}}",
                "price": 5.5
            },
            {
                "offerId": 4000000000000004704,
                "currency": "{{code}}",
                "price": 16.5
            },
            {
                "offerId": 4000000000000002705,
                "currency": "{{code}}",
                "price": 6.5
            }
        ]
    }
  2. Build your search indexes to view the offer prices for the products and product SKUs in your storefront. You can use the following API request to rebuild the index:
    https://{{ts-hostname}}:{{ts-port}}/wcs/resources/admin/index/dataImport/build?masterCatalogId=10001&fullBuild=true
    You can use the following API request to monitor the status of the index building process:
    https://{{ts-hostname}}:{{ts-port}}/wcs/resources/admin/index/dataImport/status?jobStatusId={{v9IndexingJobStatusId}}
    You need to replace the following values within these API calls with the values for your environment:
    ts-hostname
    The name of the host where your transaction server is hosted.
    ts-port
    The port number for your transaction server host.
    v9IndexingJobStatusId
    The ID for the search indexing job. This ID is returned in the response when you issue the API request to build the index.
Note: To delete a currency, use a REST API similar to the following REST API for the Store currencies.