Omni GraphQl
This module extends out-of-the-box Magento cart to support different operations like applying and removing loyalty points and gift cards, and it fetches these related fields and others in order and cart objects.
Queries
Retrieve loyalty points redeemed for given cart
Retrieve gift card redeemed for given cart
Cart query
Use 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 LS 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
}
}
}
}
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 LS 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
}
}
}
}