Omni GraphQI
This module extends an out-of-the-box Magento cart to support different operations like applying and removing loyalty points and gift cards, and it fetches these and other related fields in order and cart objects.
Queries
Get Discounts/Coupons based on Item ID
Retrieve loyalty points redeemed for given cart
Retrieve gift card redeemed for given cart
Retrieve discounts on a given cart
Retrieve return policy based on SKU
Get all the stores from LS Central
Get Discounts/Coupons based on Item ID
Use this query to retrieve information about the proactive discounts or coupon codes based on Item ID.
Required input is a valid Item ID. To fetch proactive discounts, a valid customer session is also required.
In the response, coupons and discount nodes are attached to a response object. It includes fields like coupons or discount details, expiry date, amount, and so on. These nodes will be null, if no relevant coupons or discounts are attached to an Item ID.
Request
{
query {
get_discounts(
item_id: "40020"
) {
output {
coupons {
coupon_description
coupon_details
coupon_expire_date
offer_id
}
discounts {
discount_description_title
discount_description_text
discount_min_qty
discount_products_data {
product_name
image_url
product_url
sku
price
}
}
}
}
}
Mix n Match Discount Response
{
"data": {
"get_discounts": {
"output": {
"coupons": [],
"discounts": [
{
"discount_description_title": "Linda Combo - 20%",
"discount_description_text": "Avail 20.00% Off if Buy with any of these items: ",
"discount_min_qty": null,
"discount_products_data": [
{
"product_name": "Jeans Linda line",
"image_url": "http://local.lsretail-mag.com/media/catalog/product/cache/73a9c9aa4d0822998971f47471bd047a/4/0/40000_1.jpg",
"product_url": "http://local.lsretail-mag.com/index.php/jeans-linda-line-40000.html",
"sku": "40000",
"price": "$90.00"
}
]
}
]
}
}
}
}
Request
{
query {
get_discounts(
item_id: "40180"
) {
output {
coupons {
coupon_description
coupon_details
coupon_expire_date
offer_id
}
discounts {
discount_description_title
discount_description_text
discount_min_qty
discount_products_data {
product_name
image_url
product_url
sku
price
}
}
}
}
}
Coupon Response
{
"data": {
"get_discounts": {
"output": {
"coupons": [
{
"coupon_description": "Leather Backpack - 20% off",
"coupon_details": "Receive 20% discount when you shop this fabulous bag. \nThis bag is genuine leather, designed by our team.\n",
"coupon_expire_date": "31st Dec, 2023 05:30 AM",
"offer_id": "COUP0119"
}
],
"discounts": []
}
}
}
}
Cart query
Use the Cart query to retrieve information about a particular cart. The query is responsible for things like tracking each item in the cart, including the quantity and base cost, determining estimated shipping costs, calculating subtotals, computing additional costs, applying coupons, and determining the payment method.
As part of eCommerce – Magento, it also returns loyalty points and gift card related objects.
Syntax
{cart(cart_id: String!) {Cart}}
Retrieve loyalty points redeemed for given cart
Use this query to retrieve information about the loyalty points applied to a given customer cart.
Required input is a valid cart ID that is attached to the currently logged-in customer.
In the response, loyalty_points_info is injected in the out-of-the-box Magento cart object. It includes fields like new points earned on completing a current transaction, loyalty points being used for current transaction, points rate, that is what is the worth of 1 point in base currency, and points discount that is discounted amount in base currency.
Request
{
cart(cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl") {
prices {
grand_total {
value
currency
}
}
loyalty_points_info {
points_earn
points_spent
points_discount
point_rate
}
}
}
Response
{
"data": {
"cart": {
"prices": {
"grand_total": {
"value": 84,
"currency": "USD"
}
},
"loyalty_points_info": {
"points_earn": "95",
"points_spent": "10",
"points_discount": "-1.00",
"point_rate": "0.10"
}
}
}
}
Retrieve gift card redeemed for given cart
Use this query to retrieve information about the gift card applied in a given cart. Required input is a valid cart ID.
In the response applied_gift_card is injected in the out-of-the-box Magento cart object. It includes fields like applied gift card code and applied amount. This object should return null if no gift card has been used.
Request
{
cart(cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl") {
applied_gift_card {
code
amount
}
}
}
Response
{
"data": {
"cart": {
"applied_gift_card": {
"code": "G000010",
"amount": 10
}
}
}
}
Retrieve discounts on a given cart
Use this query to retrieve information about the discounts applied in a given cart. Required input is a valid cart ID.
In the response, customer_cart_discounts is injected in the out-of-the-box Magento cart object. It includes fields corresponding to the applied coupon and relevant details. This object should return null, if no coupon has been used.
Request
{
cart(cart_id: "8viAjrAscfNcuVfacZEDtlP8rN2CZ8DF") {
prices {
grand_total {
value
currency
}
}
customer_cart_discounts {
coupons {
coupon_description
coupon_details
coupon_expire_date
offer_id
}
}
}
}
Response
{
"data": {
"cart": {
"prices": {
"grand_total": {
"value": 84,
"currency": "USD"
}
},
"customer_cart_discounts": {
"coupons": [
{
"coupon_description": "Leather Backpack - 20% off",
"coupon_details": "Receive 20% discount when you shop this fabulous bag. \nThis bag is genuine leather, designed by our team.\n",
"coupon_expire_date": "30th Dec, 2023 06:00 PM",
"offer_id": "COUP0119"
}
]
}
}
}
}
Retrieve return policy based on SKU
Use this query to retrieve information about the return policy associated with SKU. Required inputs are a parent SKU, child SKU, and store ID.
In the response, FILL IN OBJECT NAME is injected in the out-of-the-box Magento cart object. It includes fields corresponding to the return policy details. This object should return null, if no return policy is updated for the SKU.
Request
{
query getReturnPolicy(
$parent_sku: String
$child_sku: String
$store_id: String
) {
return_policy(
parent_sku: $parent_sku
child_sku: $child_sku
store_id: $store_id
) {
text
__typename
}
}
}
Response
FILL IN RESPONSE BODY
Get all stores
Get all the stores from LS Central
Request
{
get_all_stores {
stores {
available_hospitality_sales_types
city
click_and_collect_accepted
country
county
currency_accepted
latitude
longitude
phone
state
store_hours {
day_of_week
hour_types {
closing_time
opening_time
}
}
store_id
store_name
street
zip_code
}
}
}
Response
{
"data": {
"get_all_stores": {
"stores": [
{
"available_hospitality_sales_types": null,
"city": "Bedford",
"click_and_collect_accepted": true,
"country": "GB",
"county": null,
"currency_accepted": "GBP",
"latitude": "52.1349",
"longitude": "-0.0461",
"phone": "5555 999999",
"state": null,
"store_hours": [
{
"day_of_week": "Wednesday",
"hour_types": [
{
"closing_time": "20:00",
"opening_time": "06:00"
},
{
"closing_time": "18:00",
"opening_time": "10:00"
}
]
}
]}}
Get Gift Card Balance
Request
{
get_gift_card_balance(gift_card_no: "10000008", gift_card_pin: "3658") {
currency
error
value
}
}
Response
{
"data": {
"get_gift_card_balance": {
"currency": "GBP",
"error": null,
"value": "100.00"
}
}
}
Mutations
Apply available loyalty points to the cart
Remove already applied loyalty point from cart
Remove already applied gift card from cart
Apply available loyalty points to the cart
In order to pay part or whole of the grand total amount for a cart belonging a customer, you can use available loyalty points using this mutation. If loyalty points were already applied earlier, this mutation will update those points now.
Required input includes a valid customer cart ID and a valid loyalty points value not greater than both available points and grand total. Provide the customer’s token in the header section of the query.
In the response loyalty_points_info is injected in the out-of-the-box Magento cart object. It includes fields like new points earned on completing current transaction, loyalty points being used for current transaction, points rate, that is what is the worth of 1 point in base currency, points discount, that is discounted amount in base currency.
Request
mutation {
applyLsLoyaltyPoints(
input: {
cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl",
loyalty_points:10
}
) {
cart {
loyalty_points_info {
points_earn
points_spent
points_discount
point_rate
}
}
}
}
Response
{
"data": {
"applyLsLoyaltyPoints": {
"cart": {
"loyalty_points_info": {
"points_earn": "95",
"points_spent": "10",
"points_discount": "-1.00",
"point_rate": "0.10"
}
}
}
}
}
Remove already applied loyalty point from cart
If loyalty points have already been applied to the cart, they can be removed using this mutation.
Required input includes a valid customer cart ID. Provide the customer’s token in the header section of the query.
In the response loyalty_points_info is injected in the out-of-the-box Magento cart object. It includes fields like new points earned on completing current transaction, loyalty points being used for current transaction, points rate, that is what is the worth of 1 point in base currency, and points discount, that is discounted amount in base currency.
Request
mutation {
removeLsLoyaltyPoints(
input: {
cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl"
}
) {
cart {
loyalty_points_info {
points_earn
points_spent
points_discount
point_rate
}
}
}
}
Response
{
"data": {
"removeLsLoyaltyPoints": {
"cart": {
"loyalty_points_info": {
"points_earn": "95",
"points_spent": "0",
"points_discount": "0.00",
"point_rate": "0.10"
}
}
}
}
}
Apply a gift cart to the cart
In order to pay part or whole of the grand total amount for a cart belonging a customer, you can use a valid gift card using this mutation. If a gift card was already applied earlier, this mutation will update that now.
Required input includes a valid customer cart ID, a valid gift card code, and a valid amount not greater than both the available gift card balance and grand total.
In the response applied_gift_card is injected in the out-of-the-box Magento cart object. It includes fields like applied gift card code and applied amount.
Request
mutation {
applyLsGiftCard(
input: {
cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl",
code: "G000010",
amount: 10
}
) {
cart {
applied_gift_card {
code
amount
}
}
}
}
Response
{
"data": {
"applyLsGiftCard": {
"cart": {
"applied_gift_card": {
"code": "G000010",
"amount": 10
}
}
}
}
}
Remove already applied gift card from cart
If a gift card has already been applied to the cart, it can be removed using this mutation.
Required input includes a valid customer cart ID.
In the response applied_gift_card is injected in the out-of-the-box Magento cart object. It should be null, if the gift card has been successfully removed.
Request
mutation {
removeLsGiftCard(
input: {
cart_id: "Kj6KNDeEAdcxn8PQ2udsIzmDuLVUiyPl"
}
) {
cart {
applied_gift_card {
code
amount
}
}
}
}
Response
{
"data": {
"removeLsGiftCard": {
"cart": {
"applied_gift_card": null
}
}
}
}
PlaceOrder mutation
The placeOrder mutation converts the cart into an order and returns an order object which is an out-of-the-box behavior.
As part of eCommerce – Magento, the resulting object is customized to return also some useful information for customer reference, such as an document ID which comes from LS Central once the order is placed successfully.
Request
mutation {
placeOrder(input: {cart_id: "ElamcyASGZZCDVcHExeGLs4jj9Oni79t"}) {
order {
order_number,
document_id
}
}
}
Response
{
"data": {
"placeOrder": {
"order": {
"order_number": 000000006,
"document_id": C000007
}
}
}
}