Custom Variables

What are they?

Custom Variables are essentially custom options you can ask your customers when they are purchasing their item. But it gets even cooler than this. For example, if you want to ask your user which weapon they want in-game upon purchase, you could create a custom text question for them to input along with a variable name such as {weapon}, and you could re-access their answer throughout your notifier, commands, and API.

To create a custom variable, simply go and edit this module within your admin panel and go to the "Variables" tab. Here you can create your first custom variable. Creating custom variables includes the following options.

  • Global or per item option: Do you want this option to be asked for every item your customer adds to their shop? Or just once?
  • Variable: The actual variable you want to use for this option. This input would be something like {VARIABLE} , or as we stated before {weapon}. This is up to you.
  • Option Description: This is the description and the actual question that will be displayed when the user is purchasing their item
  • Option Type: Do you want this to be a text only input? Multiple choice? Alphanumerical? Alphabetical? Numeric?
  • Depending on your choice for the option type, you may be asked to input further information regarding the question



Variables Tutorial

In this tutorial example, we will be explaining how to use a multiple choice Variable within your shop, and how this can benefit you. Specifically, we will ask the user to input an amount of money that they can earn by purchasing an item within your shop.

  1. First, go to your admin panel > modules tab > edit your shopping module > Variables tab
  2. Click the big blue button "Add Variable Option"
  3. Add the following information
Global or per item option? - Global. We want this option to be asked on every item they add to their cart.
Variable - {money}
Option description or name? - "How much money do you want!?"
Option type - Numeric.
Min value - 1
Max value - 500
Required? - This option will not be required.
4. Save the variable. And go to your shop manager tab.
5. Edit 1 item, scroll down, and check off our new custom variable so it can be used on this item.
6. While still editing the item, add a new command that states on purchase of this item, the command "say {name} would like this much money: {money}" will be sent to [x] server.
7. Make another command that states on purchase of this item, the command "ecogive {name} {money}" will be sent to [x] server.
8. Save "update" item on the bottom of the page.
9. Go to your Notifier tab. within the Private Messages text that will be sent to both you and the user, add the line "User would like this much money in-game: {money}.".
10. Now that we have our custom variable set up with our commands and notification when the user purchases our items, let grab this information from the shopping API.
11. Use the alternative URL method to grab our custom variable from the purchases in our shop.
Example: Find ALL purchases on shopping module ID: "12545213" with this custom field
Use something like this - http://yourSite.com/api/m-shopping-purchases/m/12545213/custom_field/money
Switch out "yourSite.com" with your domain, and switch "12545213" with your shopping module ID.

As you can see, you have now integrated your custom variable with your commands, notifications, and API. And this is just the beginning. With a creative mind, so much more can be done!

Was this article helpful?
0 out of 0 found this helpful