Purchase via shopping cart
This method is suitable for selling items of any type and in any quantity for real currency.
Note
When purchasing via the shopping cart, the opportunity to use promotional codes is provided.
- In the application UI, add the following elements:
- buttons for adding items to the cart
- form for viewing and editing the contents of the cart
- button to buy items in the cart
Note
In the application UI, it should not be available to add to the cart items that are sold only for virtual currency.
- Implement the logic of filling and editing the cart.
Note
Before calling the method for filling the cart, you won’t have information about promotions applied to the purchase. This means that the total cost and details of the added bonus items will be unknown.
- Implement the display of the cart contents.
- Call the
Purchase
SDK method of theCart
class. When calling it, pass a function that is called when the order transitions to thedone
status in theonSuccess
parameter.
- Update the inventory on the client side of the application using one of the following options:
- using SDK methods for displaying user inventory
- using the order content data that is passed to the
onSuccess
callback function of the purchase methods
SDK reference documentation
Learn more about SDK methods and its parameters.
Methods for filling and editing the cart
SDK method name | Description |
---|---|
FillCart | Fills the cart with the specified ID or the cart of the current user with items. If there is already an item with the same SKU in the cart, the existing item position will be replaced by the passed value. |
ClearCart | Removes all items from the cart with the specified ID or from the cart of the current user. |
UpdateItemInCart | Updates the quantity of a previously added item in the cart with the specified ID or in the current user cart. If there is no item with the specified SKU in the cart, it will be added. |
RemoveItemFromCart | Removes the item from the cart with the specified ID or from the cart of the current user. |
Methods for getting the contents of the cart
SDK method name | Description |
---|---|
GetCartItems | Returns a list of items from the cart with the specified ID or from the cart of the current user. For each item, complete data is returned. |
Methods for creating order
SDK method name | Description |
---|---|
Purchase | Launches purchase process for the cart with the specified ID or for the cart of the current user. This method encapsulates methods for creating an order, opening a payment UI, and tracking the order status. |
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Useful links
Last updated: January 22, 2024Found a typo or other text error? Select the text and press Ctrl+Enter.