Customer GraphQl

This module extends out-of-the box customer GraphQl queries to fetch all related attributes and information for customers that are linked to LS eCommerce – Magento.

Queries

Customer query

Retrieve basic LS Central account information

Retrieve basic LS Central account current scheme information

Retrieve a summary of the customer’s sales entries

Retrieve detailed information of a sales entry

Customer query

The out-of-the-box customer query returns information about the logged-in customer, store credit history, and the customer’s wish list. As part of LS eCommerce – Magento, the query also returns all customer account details from LS Central and all related customer sales entries.

To return or modify information about a customer, Magento recommends that you use customer tokens in the header of your GraphQL calls. However, you can also use session authentication.

Syntax

Copy
{customer: {Customer}}

Retrieve basic LS Central account information

Retrieves basic LS Central account information, such as card IDs, contact IDs, user names. Provide the customer’s token in the header section of the query.

Request

Copy

 customer { 
  lsAccount { 
   card_id 
   contact_id 
   username 
  } 
 } 
}

Response

Copy

  "data": { 
    "customer": { 
      "lsAccount": { 
        "card_id": "10036", 
        "contact_id": "MSO000017", 
        "username": "mc_21696" 
      } 
    } 
  } 

Retrieve basic LS Central account current scheme information

Retrieves customer account, current scheme, club name, loyalty level, and available point balance. Provide the customer’s token in the header section of the query.

Request

Copy

 customer { 
  lsAccount { 
   scheme { 
    club_name 
    loyalty_level 
    point_balance 
   } 
  } 
 } 
}

Response

Copy

  "data": { 
    "customer": { 
      "lsAccount": { 
        "scheme": { 
          "club_name": "Cronus Loyalty Club", 
          "loyalty_level": "Cronus Bronze", 
          "point_balance": "14.00" 
        } 
      } 
    } 
  } 
}

Retrieve a summary of the customer’s sales entries

The following example returns a summary of the logged-in customer’s previous sales entries. Provide the customer’s token in the header section of the query.

Request

Copy

 customer { 
  lsSalesEntries { 
   id 
   click_and_collect_order 
   document_reg_time 
   external_id 
   id_type 
   line_item_count 
   points_rewarded 
   points_used 
   posted 
   ship_to_name 
   ship_to_email 
   status 
   store_id 
   store_name 
   total_amount 
   total_net_amount 
   total_discount 
  } 
 } 
}

Response

Copy

  "data": { 
    "customer": { 
      "lsSalesEntries": [ 
         { 
          "id": "101123", 
          "click_and_collect_order": "false", 
          "document_reg_time": "2021-08-30T20:52:27.55", 
          "external_id": "UYS-1000000011", 
          "id_type": "Receipt", 
          "line_item_count": "4.00", 
          "points_rewarded": "65.00", 
          "points_used": "0.00", 
          "posted": "true", 
          "ship_to_name": "Umar Yousaf", 
          "ship_to_email": "umaryo_retail@lsretail.com", 
          "status": "Complete", 
          "store_id": "S0013", 
          "store_name": "Cronus Web Store", 
          "total_amount": "79.80", 
          "total_net_amount": "63.84", 
          "total_discount": "7.20" 
         }, 
         { 
          "id": "CO000173", 
          "click_and_collect_order": "false", 
          "document_reg_time": "2021-08-30T12:41:15.793", 
          "external_id": "UYS-1000000010", 
          "id_type": "Order", 
          "line_item_count": "4.00", 
          "points_rewarded": "0.00", 
          "points_used": "0.00", 
          "posted": "false", 
          "ship_to_name": "Umar Yousaf", 
          "ship_to_email": "umaryo_retail@lsretail.com", 
          "status": "Created", 
          "store_id": "S0013", 
          "store_name": "Cronus Web Store", 
          "total_amount": "79.80", 
          "total_net_amount": "63.84", 
          "total_discount": "7.20" 
         } 
      ] 
    } 
  } 
}

Retrieve detailed information of a sales entry

The following example returns detailed information for a given sales entry, including line items, ship-to and contact addresses, payment methods, and so on.

This request requires a filter object with the ID and type of the sales entry. Possible values for type could be Order, Receipt, HospOrder.

Request

Copy

 customer { 
  lsSalesEntries(filter: { id: "CO000150", type: "Order" }, pageSize: 1) { 
   id 
   click_and_collect_order 
   document_reg_time 
   external_id 
   id_type 
   line_item_count 
   points_rewarded 
   points_used 
   posted 
   ship_to_name 
   ship_to_email 
   status 
   store_id 
   store_name 
   total_amount 
   total_net_amount 
   total_discount 
   contact_address { 
    address1 
    address2 
    cell_phone_number 
    city
    country 
    house_no 
    post_code 
    state_province_region 
    type 
   } 
   ship_to_address { 
    address1 
    address2 
    cell_phone_number 
    city 
    country 
    house_no 
    post_code 
    state_province_region 
    type 
   } 
   payments { 
    amount 
    card_no 
    currency_code 
    currency_factor 
    line_number 
    tender_type 
   } 
   items { 
    amount 
    click_and_collect_line 
    discount_amount 
    discount_percent 
    item_description 
    item_id 
    item_image_id 
    line_number 
    line_type 
    net_amount 
    net_price 
    parent_line 
    price 
    quantity 
    store_id
    tax_amount 
    uom_id 
    variant_description 
    variant_id 
   } 
  } 
 } 
}

Response

Copy

  "data": { 
    "customer": { 
      "lsSalesEntries": [ 
        { 
          "id": "CO000150", 
          "click_and_collect_order": "false", 
          "document_reg_time": "2021-08-18T11:08:50.573", 
          "external_id": "UYS-000000023", 
          "id_type": "Order", 
          "line_item_count": "4.00", 
          "points_rewarded": "0.00", 
          "points_used": "0.00", 
          "posted": "false", 
          "ship_to_name": "Umar Yousaf", 
          "ship_to_email": "umaryo_retail@lsretail.com", 
          "status": "Created", 
          "store_id": "S0013", 
          "store_name": "Cronus Web Store", 
          "total_amount": "129.75", 
          "total_net_amount": "103.80", 
          "total_discount": "20.25", 
          "contact_address": { 
            "address1": "B2-8-02 Meritus Towers", 
            "address2": "", 
            "cell_phone_number": "", 
            "city": "Petaling Jaya", 
            "country": "MY", 
            "house_no": "",
            "post_code": "40150", 
            "state_province_region": "", 
            "type": "Residential" 
          }, 
          "ship_to_address": { 
            "address1": "B2-8-02 Meritus Towers", 
            "address2": "", 
            "cell_phone_number": "", 
            "city": "Petaling Jaya", 
            "country": "MY", 
            "house_no": "", 
            "post_code": "40150", 
            "state_province_region": "", 
            "type": "Residential" 
          }, 
          "payments": [ 
            { 
              "amount": "129.75", 
              "card_no": "1111",
              "currency_code": "EUR", 
              "currency_factor": "1.42", 
              "line_number": "10000", 
              "tender_type": "1" 
            } 
          ], 
          "items": [ 
            { 
              "amount": "114.75", 
              "click_and_collect_line": "false", 
              "discount_amount": "20.25", 
              "discount_percent": "0.00", 
              "item_description": "Jeans Shirt Linda line", 
              "item_id": "40015", 
              "item_image_id": "40015-WHITE", 
              "line_number": "10000", 
              "line_type": "Item", 
              "net_amount": "91.80", 
              "net_price": "37.35", 
              "parent_line": "0", 
              "price": "45.00", 
              "quantity": "3.00", 
              "store_id": "S0013", 
              "tax_amount": "22.95", 
              "uom_id": "PCS", 
              "variant_description": "CREAM/36", 
              "variant_id": "000" 
            }, 
            { 
              "amount": "15.00", 
              "click_and_collect_line": "false", 
              "discount_amount": "0.00", 
              "discount_percent": "0.00", 
              "item_description": "Shipment Charge", 
              "item_id": "66010", 
              "item_image_id": "SHIPMENT", 
              "line_number": "40000", 
              "line_type": "Item", 
              "net_amount": "12.00", 
              "net_price": "12.00", 
              "parent_line": "0", 
              "price": "15.00", 
              "quantity": "1.00", 
              "store_id": "S0013", 
              "tax_amount": "3.00", 
              "uom_id": "PCS", 
              "variant_description": "", 
              "variant_id": "" 
            } 
          ] 
        } 
      ] 
    } 
  }