Scraper Response

Once the scraper is called it will return an object with the following structure. Note that the basic return types such as <STRING> or <FLOAT> may depend on what is defined in the scraper data. The overall structure should stay the same though.

{
  state: {
    page: {
      type: '<STRING>',
      category: <CATEGORY>,
      product: {
        <PRODUCT>
      }
    },
    cart: {
      action: '<STRING>',
      currency: '<STRING>',
      products: [
        <PRODUCT>,
        <PRODUCT>,
        ...
      ]
    },
    order: {
      action: '<STRING>',
      currency: '<STRING>',
      id: '<STRING>',
      gross: <FLOAT>,
      discount: <FLOAT>,
      discountCode: '<STRING>',
      shipping: <FLOAT>,
      tax: <FLOAT>,
      orderEmail: '<STRING>',
      customerId: '<STRING>',
      customerEmail: '<STRING>',
      customerFirstName: '<STRING>',
      customerLastName: '<STRING>',
      products: [
        <PRODUCT>,
        <PRODUCT>,
        ...
      ]
    }
  },
  events: {
    product-quick-view: <EVENT>,
    cart-change: <EVENT>,
    page-change: <EVENT>
  },
  applyToCart: <BOOLEAN>
}

<CATEGORY>

Only a single category is returned.

{
  id: '<STRING>',
  name: '<STRING>'
}

<PRODUCT>

For product pages the quantity is set as 0.

{
  id: '<STRING>',
  sku: '<STRING>',
  name: '<STRING>',
  price: <FLOAT>,
  quantity: <INT>,
  image: '<STRING>',
  url: '<STRING>'
}

<EVENT>

Events will notify us of changes to our state when such things as a product quick view, "Ajax" cart change or when a page changes without a full reload (ie a single page app). This is simply set as a true or false to let us know which events we may need to listen to.

Every event will return a full scraper response. This means you can either update only the information you need to about that response, or update all data on each event.

Note that values for Product Quick Views and Quick Carts are set on the normal product and cart objects.

<BOOLEAN>

product-quick-view

This event will be fired when a user views a product as a popup while on another page. Generally this will only happen on category pages, but sometimes it may happen on other pages that lists products such as featured products on

cart-change

This event is fired whenever the cart details change and we are able to scrape this new information. This could be when a product is added to the cart and we get a "quick cart" view, if we are on a cart page and any information changes without reloading the page, such as adding a coupon or changing product quantity using "ajax". Note that the cart action may change between calls of this event.

page-change

For sites that do not reload the page when giving new information, such as a single page app, this event will be fired on page change. This event is normally tied to either an HTML Event fired on the page or a function called on the scraper object directly.

Apply To Cart

applyToCart is set to true if there is an Apply to Cart function set on the scraper. This is set as scraper.applyToCart

results matching ""

    No results matching ""