Home
Wiki
Home
Wiki
  1. Products
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • 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
  • Noir
    • 0. Introduction
    • 1. Structure
      • Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • Overview
      • Addresses
      • BillingRetail
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • Company
      • General
      • Login
      • LoginModal
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductListItem
      • ShoppingListsButton
      • ProductModal
      • ProfileInfo
      • PromptModal
      • Register
      • Shipping
      • ShoppingLists
      • ShoppingListsNavbar
      • Toast
      • Users
      • VariantContent
      • WishlistButton
      • Services
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • Overview
        • theme.js
      • Css / Scss
        • Overview
        • ThemeClasses
    • 5. SDK
      • Overview
      • LiquidGlobals
      • ServicesSDK
  1. Products

_findProductsAndCalculate

How to Use _findProductsAndCalculate Method#

The _findProductsAndCalculate method enables you to search for products and compute customer-specific prices based on the search criteria. This is particularly useful in scenarios where product pricing varies by customer or requires real-time calculation based on various factors.

Usage Steps:#

1.
Define Search Criteria:
Construct an object where each key-value pair represents a search filter or parameter. The keys are filter parameters, and the values are the criteria to filter the products.
2.
Define the Callback Function:
Create a callback function to handle the results returned from the search and calculation. This function will process the products and their calculated customer-specific prices.
3.
Call the Method:
Invoke the _findProductsAndCalculate method with the defined search criteria and callback function.
4.
Handle Results:
The callback function will receive the results, including products and their calculated prices, as its parameter.

Example:#

In this example:
The _findProductsAndCalculate method is called with searchCriteria to filter products by page, pageSize, categoryId, priceRange, and sort.
The handleResults function processes and displays the retrieved products and their calculated customer-specific prices.

Common Use Cases:#

1.
Customer-Specific Pricing:
Use this method to calculate and display prices based on customer-specific factors such as discounts, loyalty points, or regional pricing.
2.
Dynamic Price Calculation:
Ideal for applications where pricing needs to be computed in real-time based on search results and various conditions.
3.
Advanced Search and Pricing:
Combine search functionality with real-time price calculations to provide a comprehensive shopping experience, enhancing product discovery and pricing accuracy.

Notes:#

URL Construction:
The _buildProductSearchUrl function constructs the URL for the API request based on the provided search criteria. It appends the criteria to the endpoint /api/products/calculate to perform the search and calculation.
Handling Null Values:
Ensure that the searchCriteria object is properly constructed, as null or undefined values are filtered out from the URL parameters.
Fetching Data:
The _fetchData function (assumed to be defined elsewhere) handles the API request and processes the response. It should be designed to manage API requests and handle the results efficiently.
API Integration:
Verify that the endpoint /api/products/calculate is implemented on your server to accept search criteria and return calculated customer-specific prices. Ensure that it correctly processes the criteria and performs the necessary calculations.
By following these guidelines, you can effectively use the _findProductsAndCalculate method to deliver a powerful search and pricing feature that adapts to customer-specific conditions and requirements.
Modified at 2024-08-20 13:06:03
Previous
_findProductsByCriteria
Next
_findProductsThenCalculate
Built with