This document assumes that you have some development experience/skills using JavaScript in the browser.

The following code will work on any storefront page when quoteninja is installed on your store. The Quote Ninja Javascript API is not available in certain areas: Checkout, Account Pages, Order Confirmation Page.

Add product(s)

If you want to add products to the current quote, you have a couple of options.

  1. QN.add_product(event?: Event | null, autoAdd: boolean, container: string) Takes the product option form container and we will parse the options and qty element and add the product to the quote if the options are valid.
  2. QN.add_products_to_quote(products: {id: number, qty: number, options?: {product_option_id: number, selected_value?: number, selected_valuetext?: string}[]}, mergeWithCurrentQuote?: boolean) Pass in an array of object(s), that contain product id, quantity, and product options (optional) that we will then use to add the product(s)

Option #1 is useful for adding individual "Add to Quote" buttons, for example on category pages with simple products, or if you have a custom page that lists multiple products each with their own option table & qty selector.

Option #2 is useful for building fully custom product pages with complex options that may not be shown to the user, or are not standardized product forms. This allows you to fully customize how the product is added to the quote. You don't even have to show the customer anything related to the product on the page.

If you run into issues with complex options, please reach out to us so we can get those fixed. The only option type that is currently not supported via add_products_to_quote is file upload.

Did this answer your question?