HomeWiki
HomeWiki
  1. Shopping Lists
  • Back to home
  • 1. Themes
  • Layout
    • New Layout
    • Legacy Layout
  • Components
    • Announcement
    • Banner Carousel
    • Banner With Products Carousel
    • Blog Category List
    • Blog List
    • Brand List
    • Brands Carousel
    • Breadcrumb
    • Call To Action
    • Cart
    • Categories List
    • Change Password
    • Checkout
    • Cookie Manager
    • Filter list
    • Footer
    • Forgot Password
    • Form
    • Hero Carousel
    • Icon Block
    • Invitation
    • Last Visited Products
    • Layout
    • Login
    • Map
    • Nav Bar
    • Offer
    • Product Attachments
    • Product Attributes
    • Product Documentation
    • Product Expected
    • Product Modal
    • Products Block
    • Products Carousel
    • Product Single
    • Profile
    • Quote
    • Register
    • Related Products
    • Search
    • Stores
    • Subscribe Newsletter
    • Text with Image
    • Top Bar
    • Video
  • Reusables
    • Getting Started
  • Assets
    • Getting Started
  • SDK
    • Products
      • _findProductsByCategory
      • _findProductsByIds
      • _findProductsByTitle
      • _findProductsByFilter
      • _findProductsByCriteria
      • _findProductsAndCalculate
      • _findProductsThenCalculate
      • _getProductAttributeSet
      • _setLastVisited
    • Categories
      • _findCategoryTreeById
      • _findCategoriesByIds
      • _findCategoryByAlias
      • _findCategoryTreeByAlias
      • _getCategoryContent
    • Collections
      • _getCollectionContent
      • _findCollectionsByIds
      • _findCollectionsByIdsThenCalculate
    • Brands
      • _getBrandContent
      • _findBrandsByIds
    • Cart
      • _addToCartMulti
      • _addToCart
      • _setCart
      • _clearCart
      • _setCartListener
      • _removeFromCart
      • _calculateCart
    • Checkout
      • _startCheckout
      • _updateCheckout
      • _completeCheckout
    • Shopping Lists
      • _getShoppingLists
      • _updateShoppingList
      • _createShoppingList
      • _deleteShoppingList
      • _getShoppingListByAlias
    • Navigation
      • _getFooterMenu
      • _getHeaderMenu
    • Users
      • _getUserById
    • Utils
      • _calculateCurrency
      • _getCurrencySymbol
      • _getCulture
      • _subscribeToNewsletter
      • _findUnitsByIds
  • Vs Code
    • Getting Started
  1. Shopping Lists

_createShoppingList

Example Usage of _createShoppingList Method#

The _createShoppingList method is used to create a new shopping list on the server. It sends the provided data to the server and processes the response using a callback function.

Purpose#

To create a new shopping list by sending data to the server and handle the created list data through a callback function.

Method Signature#

Parameters#

data (Object): An object containing the data for the new shopping list. This includes necessary details such as the name of the list and items to be included.
Example:
callback (Function): A function to be executed with the created shopping list data once the creation is successful.

Usage Steps#

1.
Define a Callback Function:
Create a function that will process the created shopping list data. This function will be called with the new list data as its argument.
2.
Prepare the Data Object:
Create an object representing the new shopping list, including necessary details such as the name and items.
3.
Invoke the Method:
Call _createShoppingList with the data object and the callback function.

Detailed Breakdown#

Data Creation: Sends a POST request to /api/ShoppingList with the provided data to create a new shopping list.
Callback Execution: Calls the provided callback function with the created shopping list data. This allows you to handle the newly created list as needed.

Example#

Here's how you might use the _createShoppingList method in your application:

Common Use Cases#

Creating New Lists: Useful for scenarios where users can create new shopping lists with initial items.
UI Updates: Helps in updating parts of the UI that display shopping list information to reflect the newly created list.
Data Integrity: Ensures that new shopping lists are stored on the server and accessible across different parts of the application.

Notes#

Data Validation: Ensure that the data object meets the server's requirements for creating a shopping list. Include validation to handle invalid data before making the request.
Error Handling: While this example does not include error handling, consider adding it to manage scenarios where the creation fails (e.g., network issues, server errors).
By following this documentation, you will be able to use the _createShoppingList method to effectively create new shopping lists in your application and handle related data.
Previous
_updateShoppingList
Next
_deleteShoppingList
Built with