NO SPEAK ENGLISH ? NO PROBLEM, CLICK HERE
FULL API DOC HERE
Build ecommerce websites with the Epic commerce
toolkit
- Setup
- Initialization
- Access cart
- Access Wishlist
- Performing checkout
- HTML UI
- Additional customization
- User management
- Inventory object
- User management
- JS RESTful functions
- Eval customer metric
- Record user interest
- REST API
- One click checkout
- Credit card management
- Location management
- User data manipulation
- Social media SSO
- User login support.
- Wishlist Sharing.
- Social media SSO support.
- One Click checkout.
- User credit card management.
- User address management ( Locations ).
- Multiple currency support.
- Inventory JS requires
jQuery 1.9+
. - Epic Commerce account
bower install epic-commerce
npm install epic-commerce
Download this repository, unzip it and move it to your website root.
<script type="text/javascript" src="/your/path/inventory.min.js"></script>
Or host this one with Orkiv :
<script type="text/javascript" src="https://www.orkiv.com/i/inventory.js"></script>
Initialize the class with the following code. Replace accountid
with your actual account ID and frontendkey
with a valid JS Key generated for your account.
You can access all of this information under the settings section of your account within Epic commerce.
The variable 'itemid' is used throughout this document. It refers to any of your items' id.
The snippet below initializes the class
<script>
$inventory = new Inventory('accountid', 'frontendkey');
</script>
Cart object is an entry of an item within a user's cart.
Cart Object { id : "itemid",
quantity: 0,
variations:['variation'] }
This will retrieve the current user's cart objects.
This will add an item to the current user's cart. *Variations is an array of strings used to add specifications to your products on checkout
This will remove an item from the current user's cart.
This will remove all items from the current user's cart.
Wishlist object is an entry of an item within a user's Wishlist.
Wishlist Object { id : "itemid",
variations:['variation'] }
This will retrieve the current user's Wishlist objects.
This will add an item to the current user's Wishlist.
This will remove an item from the current user's Wishlist.
This will remove all items from the current user's Wishlist.
There two approaches to performing a checkout.
The first approach is using the function '$inventory.Buy('itemid',1,['variation'])'
This will open a checkout modal with the item currently specified.
The second approach is by performing a checkout of the items within the current user's cart.
This will open a checkout modal with the current items within the current user's cart.
$inventory once initialized can be accessed via html elements. This enables quick manipulation of the current user's data without any additional JS.
Within your item or service viewer in the Inventory dashboard, you will also see a button with name snippet generator
Item UI's allow for easy placement of item customization controls. This function will place the following ui in the desired location. The UI will handle item customizations and checkout options.
Place your item images with this function.
Adds the specified item to the current user's cart.
<button onclick="$inventoryStandard.Cart('itemid',1,['variations'])" data-id="itemid" data-link="cart" class="sync-orkivinv sync-dynamic" ><i class="fa fa-shopping-cart"></i> Add to cart</button>
Opens a checkout window for the specified item.
<button onclick="$inventoryStandard.Buy('itemid',1,['variations'])" data-id="itemid" class="sync-orkivinv" ><i class="fa fa-credit-card"></i> Buy</button>
Displays the checkout page without the user being able to update their cart.
<button onclick="$inventoryStandard.ShowCart()" class="sync-orkivinv" ><i class="fa fa-shopping-cart"></i> Checkout</button>
Opens the current user's cart.
<button onclick="$inventoryStandard.Checkout()" class="sync-orkivinv" ><i class="fa fa-shopping-cart"></i> Checkout</button>
Adds the specified item to the current user's Wishlist.
<button onclick="$inventoryStandard.Cart('itemid',['variations'])" data-id="itemid" data-link="cart" class="sync-orkivinv sync-dynamic" ><i class="fa fa-bars"></i> Wishlist</button>
Subscribes the current user to the specified serviceID
<button onclick="$inventoryStandard.BuyService('serviceID')" class="sync-orkivinv" ><i class="fa fa-circle"></i> Subscribe</button>
Combo boxes come with explicit user defined quantity.
Sets the cart entry of this item to the specified amount by the user.
<div class="inventory-form-group" data-type="cart" data-id="itemid">
<input min="0" type="number" data-isf="amt" placeholder="Amount" />
<button onclick="$inventoryStandard.ExplicitCart('itemid',['variation'])" class="sync-orkivinv" ><i class="fa fa-shopping-cart"></i></button>
</div>
Opens a checkout window with the specified user quantity
<div class="inventory-form-group" data-type="buy" data-id="itemid">
<input min="0" type="number" data-isf="amt" placeholder="Amount" />
<button onclick="$inventoryStandard.ExplicitCart('itemid',['variation'])" class="sync-orkivinv" ><i class="fa fa-shopping-cart"></i></button>
</div>
Inventory.prototype.Checkout()
To display an editable view of your user's cart.
Inventory.prototype.ShowWishlist()
To display an editable view of your user's wish list.
Additional initializations :
Parameters :
accountid
is your account id obtained from the settings section within your epic commerce portal
jstoken
is your front end key obtained from the settings section within your epic commerce portal
alerts
decides how Inventory handles visual alert notifications. Setting it to false will revert to using a custom alert. If none is set no action is called.
syncdynamic
decides if inventory should add dynamism to Drop in UI buttons. This dynamism ranges from automatically changing an add to cart button to a 'remove from cart' button; and refilling cart combo boxes to previous value.
<script>
$inventory = new Inventory('accountid', 'frontendkey',true,true);
</script>
This will set a custom alert. Please make sure alerts is set to false.
Generates a cart or wishlist id of the current itemid and variations supplied.
To display an editable view of your user's wish list.
To display an editable view of your user's cart.
Place full item customization form.
- Parameters
- itemid : Valid inventory item id.
- selector : jQuery
css
selector of element to add item information to.
Place item images.
- Parameters:
string itemid:
commerce item id.string selector:
jQuerycss
selector to add image grid to.array variations:
Array ofstring
with item variables.
** Important note: once your images are loaded, using the function again will filter images to appropriate variations.
Inventory JS supports out of the box basic user authentication. It works with the parameters defined within Inventory to help you convert visitors to returning customers.
- Information about user
- Any custom set key within Epic commerce's interfaces will be available within this object.
- panel attribute will specify which jQuery selector to append the login prompt to.
- userinfo is a string array of jQuery selectors to append logged in user information.
Delete current user session.
One click is a checkout mode in which your user does not have enter any information. They still must confirm the shipping address as well as shipping options.
Open client checkout. With this option your client does not have to enter billing information.
Open form to save credit card.
Get credit cards of the current user.
- Parameters
function callback:
Function called once data is retrieved.cards
is an array of cards
Set specified card id as default card to use with OneClick
.
- Parameters
string id:
ID of card to make default.function callback:
function to call once operation is complete.bool done:
Indication on success of operation.
Remove card.
- Parameters
string id:
ID of card to remove.function callback:
Function called once data is retrieved.bool done :
Indication on success of operation.
Open form to add a new shipping location for user.
Get locations of the current user.
- Parameters
function callback:
Function called once data is retrieved.locations
is an array of locations
Set specified location id as default location to use with OneClick
.
- Parameters
string id:
ID of location to make default.function callback:
function to call once operation is complete.bool done:
Indication on success of operation.
Remove location.
- Parameters
string id:
ID of address to remove.function callback:
Function called once data is retrieved.bool done :
Indication on success of operation.
Returns true if the person on the site is logged in.
Inventory.prototype.UpdatePassword(string current, string new, function callback(bool done, string error_reason) )
Update user password.
- Parameters
string current:
The current password of the user.string new:
New password to set.function callback
: Function called once data is retrieved.bool done:
Indication on success of operation.string error_reason:
Ifdone
is false, this string will specify why. You may also usefunction callback(bool done)
.
Inventory.prototype.UpdateAccount(object user_data, function callback(bool done, string error_reason))
Update user account properties. Refer to the user schema for system fields. You may also add custom properties.
- Parameters
object user:
user information to save.function callback:
Function called once data is retrieved.bool done:
Indication on success of operation.string error_reason:
Ifdone
is false, this string will specify why.
Inventory.prototype.Login(string username, string password, function callback(bool success, object user ) )
Create a new user session.
- Parameters
string username:
Email address of user to log in.string password:
Password of user.function callback:
Function called once data is retrieved.bool success:
Returns false if the username/password is incorrect.object user:
Refer to the user schema.
Create a new user.
- Parameters
object payload:
Refer to the user schema.function callback:
Function called once data is retrieved.bool success:
Returns false if the user could not join.object user:
Refer to the user schema.- ** On
success
being false, the user object will have a propertyreason
, stating why the registration failed.
Send a new password to the user via email.
- Parameters
string username:
Username to send reset password to.-
- `function callback: `Function called once data is retrieved. `bool success: `Returns false if the username is not a current user.
List user properties, set from Epic commerce
.
- Parameters
function callback:
Function called once data is retrieved.array fields:
Array of fields.
Get Facebook single sign on url. Allow your user to log in with Facebook.
- Parameters
function callback:
Function called once data is retrieved.string url:
URL to SSO portal.
Get Twitter single sign on url. Allow your user to log in with Twitter.
- Parameters
function callback:
Function called once data is retrieved.string url:
URL to SSO portal.
Get Google single sign on url. Allow your user to log in with Google.
- Parameters
function callback:
Function called once data is retrieved.string url:
URL to SSO portal.
The following functions can be used to retrieve inventory data from your account.
Get reviews for the specified item.
- Parameters :
- itemid : Valid inventory item to open
- onFinish: Function called once data is retrieved. Function variable data has 4 keys :
- usercount : integer of how many users have reviewed your product.
- rating : double of the specified item's average rating.
- comments : Array of user comments. Each object has 2 parameters :
- Comments : String of user feedback
- ratings : string number of stars user has given for product.
Fetch item categorization from your account.
- Parameters :
- onFinish : Function called once data is retrieved. Function variable data has 1 key :
- result : Array of categories. Please refer to the category schema
- onFinish : Function called once data is retrieved. Function variable data has 1 key :
Fetch item categorization from your account.
- Parameters :
- cat_id : Valid inventory category id.
- onFinish : Function called once data is retrieved. Function variable data has 1 key :
- result : Data of requested category. Please refer to the category schema
Add category or item to user interests.
- Parameters :
- item : String of item id to add to user interest. You may also use a category id instead of an item id as well. The system will automatically add an item's parent to the user's interests.
Determine if current user returns true on decision guide.
- Parameters :
- guide_id : String of decision guide id to use. Find your decision guides here
- onFinish : Function called once guide is evaluated. Function variable isTrue is
bool
of guide evaluation.
- Parameters :
- page : Current page to load
- query : Properties to compare items with, Nonetheless there are reserved properties to provide more functionality.
- onFinish : Function called once data is retrieved. Function variable has three keys :
- pages : Available pages, starting from 0
- result : Array of inventory item. Please refer to the General schema
This function will return items which match the specified query.
- Parameters :
- itemid : Valid inventory item to open
- onFinish : Function called once data is retrieved. Function variable keys :
- media : An array of URI strings
- result : Data of the requested item. Please refer to the General schema
Additional fields can be used. Please remember to use the field name as the property name.
string profileimagelink:
Public url to user's profile image.bool cart_notified:
true if user received an abandoned cart email.bool oneclick_ready:
true if user has a default location and card set.int loyaltypoints:
Loyalty points of current user.string masterToken:
Access token of user.
The following properties are required during registration.
string username:
Valid email.string password:
User password.
The following properties, when set, will trigger specific backend functionality.
string profilepicture:
Base64 of image to set as the user's profile picture.bool oneclick:
EnableOne Click
checkout option.
Card of user.
string id:
ID of card.bool default:
If this card is the user's default.string nickname:
Nickname of card.
Address of a user.
string id:
ID of location.bool default:
If this location is the user's default.string line_1:
Line 1 of address.string line_2:
Line 2 of address.string city:
City.string state:
State/Region.string zip:
Zip code.string country:
Country code.
A custom user property, set within Epic commerce
.
bool required:
If this field should be validated.string placeholder:
Placeholder of field.string name:
Name of field. Used as property name within a Userstring type:
Type of field. 6 types :text
|Number
|phone
|select
|checkbox
|radio
array choices:
Array ofstring
with field options. This property is true when the field type is set toselect
,radio
.
- string id : ID of inventory category.
- string name : Name of inventory category.
- The Following are not available with function
Inventory.prototype.Category
and Epic restful endpoints : - string tmp : URI to image of an item under such category.
- array children : Array of categories. Using the same schema.
- *With one key difference
tmp
is replaced bysampleimage
- *With one key difference
General schema is the minimum amount of data the platform will return. If you plan on using extra fields please refer to the custom set fields section below, for information on retrieving such data.
Here are some properties of an item object.
- string category : Category Id of item.
- string desc : Description of item
- string id : Inventory item ID
- int ordprice : Price in hundreds (ie : $1 = 100)
- string tags : Item tags, separated by
,
. - string link : Generated public URL to item.
- string quantity : Item quantity in stock.
- array variations : Array of item variations. Here is the property list of a variation :
- string id : ID of variation.
- string name : Name of variation.
- int priceChange : New price of item in hundreds.
- string type : add | replace
Use the same name as set for field directly with your inventory item. This property will be an object, from here on you can access your custom data within the data
property.
- search : Text string to match item name with.
- sortfield : Item property should the system use whilst sorting.
- sortorder : The order the API should follow. -1 for Descending and 1 for ascending.
- ext_cat_search : A valid inventory category ID. This value will be used to find any subset of this category.
- minp : Minimum price of an item allowed to be returned.
- maxp : Maximum price of an item allowed to be returned.
Here is a set of end points to help you retrieve data via api.
- [Base url] : https://www.orkiv.com/i/ext_epic.php
- [Authentication headers]
account
: Your account id. ie :{ "account" : YOUR_ACCOUNT_ID }
- [Response format] :
application/json
Get a category.
-
Parameters :
-
id : ID of category to open.
-
Result :
Get categories.
- Result :
- [Category ... ]
Get an item.
-
Parameters :
-
id : ID of item to open.
-
Result :
Reduce user's points. The format of this request is application/json
. Please make sure to submit your json as a post body.
-
Parameters :
-
string token :
Access token of user to target. -
int reduce:
Points to remove from current user balance. -
Result :
-
The request will return a
json
object with the following properties: -
bool success:
This wil return false if the user was not found, or the user doesn't have enough points.