Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify does not recognize variant written in line_items

Solved

Shopify does not recognize variant written in line_items

Pfoisy
Shopify Partner
2 0 0

Good afternoon everyone,

 

Using Shopify Admin REST API, I'm creating orders into my customer's Shopify store. Into said orders, I'm also pushing a list of line_items.

 

The goal is to allow the merchant to process its inbound orders as if they were created on the Shopify storefront

 

Here's an example of the payload I send : 

{
  "order": {
    "currency": "CAD",
    "email": "whatever@wherever.ca",
    "customer_locale": "fr_CA",
    "billing_address": {
      ...
    },
    "shipping_address": {
      ...
    },
    "subtotal_price": 32.99,
    "total_price": 49.42,
    "total_tax": 4.94,
    "total_shipping_price_set": {
      ...
    },
    "phone": "+15146657570",
    "total_weight": 1,
    "total_discounts": 0,
    "tags": "PanierBleu",
    "shipping_lines": [
      {
        ...
      }
    ],
    "line_items": [
      {
        "price": 32.99,
        "quantity": 1,
        "name": "Gundam 1/144 Astray Red Frame RG",
        "title": "Gundam 1/144 Astray Red Frame RG",
        "variant_id": 7349540913370
      }
    ],
    "tax_lines": [
      {
       ...
      }
    ],
    "discount_codes": [
      {
        ...
      }
    ]
  }
}

The problem I have is that Shopify does not seem to "recognize" the variant I'm providing as a line item. Here is what is returned 

{
  "order": {
    "id": 4858931609818,
    "admin_graphql_api_id": "gid://shopify/Order/4858931609818",
    "app_id": 6817847,
    "browser_ip": null,
    "buyer_accepts_marketing": false,
    "cancel_reason": null,
    "cancelled_at": null,
    "cart_token": null,
    "checkout_id": null,
    "checkout_token": null,
    "closed_at": null,
    "confirmed": true,
    "contact_email": "whatever@wherever.com",
    "created_at": "2022-08-10T11:55:30-04:00",
    "currency": "CAD",
    "current_subtotal_price": "32.99",
    "current_subtotal_price_set": {
      "shop_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      }
    },
    "current_total_discounts": "0.00",
    "current_total_discounts_set": {
      "shop_money": {
        "amount": "0.00",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "0.00",
        "currency_code": "CAD"
      }
    },
    "current_total_duties_set": null,
    "current_total_price": "49.42",
    "current_total_price_set": {
      "shop_money": {
        "amount": "49.42",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "49.42",
        "currency_code": "CAD"
      }
    },
    "current_total_tax": "4.94",
    "current_total_tax_set": {
      "shop_money": {
        "amount": "4.94",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "4.94",
        "currency_code": "CAD"
      }
    },
    "customer_locale": null,
    "device_id": null,
    "discount_codes": [],
    "email": "whatever@wherever.com",
    "estimated_taxes": false,
    "financial_status": "paid",
    "fulfillment_status": null,
    "gateway": "",
    "landing_site": null,
    "landing_site_ref": null,
    "location_id": null,
    "name": "#1290",
    "note": null,
    "note_attributes": [],
    "number": 290,
    "order_number": 1290,
    "order_status_url": "https://thatsuperspecialstore.myshopify.com/60861546714/orders/5bb111f5df9c9eb86df0d83e3423144f/authenticate?key=95953fe532122aa1f81c7db6f961ba41",
    "original_total_duties_set": null,
    "payment_gateway_names": [],
    "phone": "+15146657570",
    "presentment_currency": "CAD",
    "processed_at": "2022-08-10T11:55:30-04:00",
    "processing_method": "",
    "reference": null,
    "referring_site": null,
    "source_identifier": null,
    "source_name": "6817847",
    "source_url": null,
    "subtotal_price": "32.99",
    "subtotal_price_set": {
      "shop_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      }
    },
    "tags": "ThatSuperSpecialStore",
    "tax_lines": [
      {
        "price": "4.94",
        "rate": 0.14975,
        "title": "GST + QST",
        "price_set": {
          "shop_money": {
            "amount": "4.94",
            "currency_code": "CAD"
          },
          "presentment_money": {
            "amount": "4.94",
            "currency_code": "CAD"
          }
        },
        "channel_liable": null
      }
    ],
    "taxes_included": false,
    "test": false,
    "token": "5bb111f5df9c9eb86df0d83e3423144f",
    "total_discounts": "0.00",
    "total_discounts_set": {
      "shop_money": {
        "amount": "0.00",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "0.00",
        "currency_code": "CAD"
      }
    },
    "total_line_items_price": "32.99",
    "total_line_items_price_set": {
      "shop_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "32.99",
        "currency_code": "CAD"
      }
    },
    "total_outstanding": "49.42",
    "total_price": "49.42",
    "total_price_set": {
      "shop_money": {
        "amount": "49.42",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "49.42",
        "currency_code": "CAD"
      }
    },
    "total_price_usd": "38.35",
    "total_shipping_price_set": {
      "shop_money": {
        "amount": "11.49",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "11.49",
        "currency_code": "CAD"
      }
    },
    "total_tax": "4.94",
    "total_tax_set": {
      "shop_money": {
        "amount": "4.94",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "4.94",
        "currency_code": "CAD"
      }
    },
    "total_tip_received": "0.00",
    "total_weight": 1,
    "updated_at": "2022-08-10T11:55:30-04:00",
    "user_id": null,
    "billing_address": {
      ...
    },
    "customer": {
      ...
    },
    "discount_applications": [],
    "fulfillments": [],
    "line_items": [
      {
        "id": 12374006005978,
        "admin_graphql_api_id": "gid://shopify/LineItem/12374006005978",
        "fulfillable_quantity": 1,
        "fulfillment_service": "manual",
        "fulfillment_status": null,
        "gift_card": false,
        "grams": 0,
        "name": "Gundam 1/144 Astray Red Frame RG",
        "price": "32.99",
        "price_set": {
          "shop_money": {
            "amount": "32.99",
            "currency_code": "CAD"
          },
          "presentment_money": {
            "amount": "32.99",
            "currency_code": "CAD"
          }
        },
        "product_exists": false,
        "product_id": null,
        "properties": [],
        "quantity": 1,
        "requires_shipping": true,
        "sku": null,
        "taxable": true,
        "title": "Gundam 1/144 Astray Red Frame RG",
        "total_discount": "0.00",
        "total_discount_set": {
          "shop_money": {
            "amount": "0.00",
            "currency_code": "CAD"
          },
          "presentment_money": {
            "amount": "0.00",
            "currency_code": "CAD"
          }
        },
        "variant_id": null,
        "variant_inventory_management": null,
        "variant_title": null,
        "vendor": null,
        "tax_lines": [
          ...
        ],
        "duties": [],
        "discount_allocations": []
      }
    ],
    "payment_terms": null,
    "refunds": [],
    "shipping_address": {
      ...
    },
    "shipping_lines": [
      {
        ...
      }
    ]
  }
}

The fact that Shopify does not recognize the variant makes it so that the Order Listing and Detail pages UI is missing informations. See the small screenshot bellow

Screenshot 2022-08-10 132705.jpg

 

Two key elements : 

1- I know the variant exists in the Shopify store

2- There are instances where Shopify does recognize the variant and displays the proper information.

 

So.... what am I missing ?

Thanks in advance for your support

Philippe Foisy | Solution Architect - Valtech
Accepted Solution (1)

Jason
Shopify Partner
11207 226 2319

This is an accepted solution.

Are you sure that's a variant id and not a product id? Common mistake for people to make so best rule that out first.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

View solution in original post

Replies 2 (2)

Jason
Shopify Partner
11207 226 2319

This is an accepted solution.

Are you sure that's a variant id and not a product id? Common mistake for people to make so best rule that out first.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Pfoisy
Shopify Partner
2 0 0

Oh my lord, that was it... I'm ashamed 😛

 

So to be clear, I was sure I was pushing a variant_id when truly I was sending a product_id into the variant_id field. 

 

Thanks @Jason for forcing me to verify the data I was using. 

 

Cheers

Philippe Foisy | Solution Architect - Valtech