Sign In Register

How can we help you today?

Start a new topic
Answered

Accessing virtual good properties in cloud code?

Is it possible to access the properties of virtual goods (e.g. price, etc) from the cloud code?


Best Answer

Hi Stephane,


This is achievable in Cloud Code with SparkConfig, you can read more about it here. The following code will return the configuration for the Virtual Good I have created called "GOLD" (You could also use "getVirtualGoods()" to return all of the virtual goods if you wanted)


 

var virtualGood = Spark.getConfig().getVirtualGood("GOLD")

Spark.setScriptData("Config", virtualGood)

 

The response looks like this.

  

{
 "@class": ".LogEventResponse",
 "scriptData": {
  "Config": {
   "description": "It's GOLD !",
   "tags": [
    "GOLD"
   ],
   "shortCode": "GOLD",
   "currency1Cost": 10,
   "currency2Cost": 20,
   "name": "GOLD",
   "type": "VGOOD",
   "propertySet": null
  }
 }
}

   


Thanks,

Liam

1 Comment

Answer

Hi Stephane,


This is achievable in Cloud Code with SparkConfig, you can read more about it here. The following code will return the configuration for the Virtual Good I have created called "GOLD" (You could also use "getVirtualGoods()" to return all of the virtual goods if you wanted)


 

var virtualGood = Spark.getConfig().getVirtualGood("GOLD")

Spark.setScriptData("Config", virtualGood)

 

The response looks like this.

  

{
 "@class": ".LogEventResponse",
 "scriptData": {
  "Config": {
   "description": "It's GOLD !",
   "tags": [
    "GOLD"
   ],
   "shortCode": "GOLD",
   "currency1Cost": 10,
   "currency2Cost": 20,
   "name": "GOLD",
   "type": "VGOOD",
   "propertySet": null
  }
 }
}

   


Thanks,

Liam

Login to post a comment