# Line item and Variation numbers for orders

**URL:** <https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078>\
**Category:** Questions\
**Tags:** orders-api\
**Created:** [October 18, 2020, 11:44pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078 "2020-10-18T23:44:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 18, 2020, 11:44pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/1 "2020-10-18T23:44:14Z")

</div>

I feel like I am having a rather blonde moment.

I am currently attempting to hook up a shopping cart with the orders api.  
My testing code is very simple

```
$lineItems = [];
$modifier = new OrderLineItemModifier();
$modifier->setCatalogObjectId('6LUBEB7TVB5UCAJFVDJRRLKH');

$lineItem = new OrderLineItem(9);
$lineItem->setCatalogObjectId('RVNF32KZWOTKBN6PJYPCQCUE');
$lineItem->setModifiers([$modifier]);
$lineItems[] = $lineItem;

$squareOrder = new Order(env('SQUARE_LOCATION_ID'));
$squareOrder->setLineItems($lineItems);

$body = new CreateOrderRequest();
$body->setOrder($squareOrder);
$body->setIdempotencyKey('refined_cms_order_number_'.$order->id);

$response = $this->client->getOrdersApi()->createOrder($body);
if ($response->isSuccess()) {
  echo '<h1 style="color:#0f0">Success</h1>';
  print_r($response->getResult());
} else {
  echo '<h1 style="color:#f00">Fail</h1>';
  print_r($response->getErrors());
}

```

I am getting the following error response

> Item variation with catalog object ID `RVNF32KZWOTKBN6PJYPCQCUE` not found.

I am getting the variation and item id using the catalogue api  
(the below output is from the ‘getVariations() method’

```
Square\Models\CatalogObject Object
(
[type:Square\Models\CatalogObject:private] => ITEM_VARIATION
[id:Square\Models\CatalogObject:private] => 6LUBEB7TVB5UCAJFVDJRRLKH
[updatedAt:Square\Models\CatalogObject:private] => 2020-10-15T21:05:09.923Z
[version:Square\Models\CatalogObject:private] => 1602795909923
[isDeleted:Square\Models\CatalogObject:private] => 
[customAttributeValues:Square\Models\CatalogObject:private] => 
[catalogV1Ids:Square\Models\CatalogObject:private] => 
[presentAtAllLocations:Square\Models\CatalogObject:private] => 
[presentAtLocationIds:Square\Models\CatalogObject:private] => Array
    (
        [0] => LSQMZFM7JA493
    )

[absentAtLocationIds:Square\Models\CatalogObject:private] => 
[imageId:Square\Models\CatalogObject:private] => 
[itemData:Square\Models\CatalogObject:private] => 
[categoryData:Square\Models\CatalogObject:private] => 
[itemVariationData:Square\Models\CatalogObject:private] => Square\Models\CatalogItemVariation Object
    (
        [itemId:Square\Models\CatalogItemVariation:private] => RVNF32KZWOTKBN6PJYPCQCUE
        [name:Square\Models\CatalogItemVariation:private] => Regular
        [sku:Square\Models\CatalogItemVariation:private] => 
        [upc:Square\Models\CatalogItemVariation:private] => 
        [ordinal:Square\Models\CatalogItemVariation:private] => 1
        [pricingType:Square\Models\CatalogItemVariation:private] => FIXED_PRICING
        [priceMoney:Square\Models\CatalogItemVariation:private] => Square\Models\Money Object
            (
                [amount:Square\Models\Money:private] => 150
                [currency:Square\Models\Money:private] => USD
            )

        [locationOverrides:Square\Models\CatalogItemVariation:private] => 
        [trackInventory:Square\Models\CatalogItemVariation:private] => 
        [inventoryAlertType:Square\Models\CatalogItemVariation:private] => 
        [inventoryAlertThreshold:Square\Models\CatalogItemVariation:private] => 
        [userData:Square\Models\CatalogItemVariation:private] => 
        [serviceDuration:Square\Models\CatalogItemVariation:private] => 
        [itemOptionValues:Square\Models\CatalogItemVariation:private] => 
        [measurementUnitId:Square\Models\CatalogItemVariation:private] => 
    )

[taxData:Square\Models\CatalogObject:private] => 
[discountData:Square\Models\CatalogObject:private] => 
[modifierListData:Square\Models\CatalogObject:private] => 
[modifierData:Square\Models\CatalogObject:private] => 
[timePeriodData:Square\Models\CatalogObject:private] => 
[productSetData:Square\Models\CatalogObject:private] => 
[pricingRuleData:Square\Models\CatalogObject:private] => 
[imageData:Square\Models\CatalogObject:private] => 
[measurementUnitData:Square\Models\CatalogObject:private] => 
[subscriptionPlanData:Square\Models\CatalogObject:private] => 
[itemOptionData:Square\Models\CatalogObject:private] => 
[itemOptionValueData:Square\Models\CatalogObject:private] => 
[customAttributeDefinitionData:Square\Models\CatalogObject:private] => 
[quickAmountsSettingsData:Square\Models\CatalogObject:private] => 

```

)

Am I not getting the ids correctly?

ta

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [October 19, 2020, 4:07pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/2 "2020-10-19T16:07:37Z")

</div>

`RVNF32KZWOTKBN6PJYPCQCUE` is the `itemId` field (meaning the parent id). What you want is above that, in the `id` field with the value `6LUBEB7TVB5UCAJFVDJRRLKH`, I believe.

---

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 19, 2020, 7:30pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/3 "2020-10-19T19:30:01Z")

</div>

so in the documentation for creating orders, it has this

> Replace `COFFEE_ITEM_ID` with your catalog item ID and `SMALL_MODIFIER_ID` with your catalog item variation ID.

```
$order_line_item_modifier = new \Square\Models\OrderLineItemModifier();
$order_line_item_modifier->setCatalogObjectId('SMALL_MODIFIER_ID');

$modifiers = [$order_line_item_modifier];
$order_line_item = new \Square\Models\OrderLineItem('1');
$order_line_item->setCatalogObjectId('COFFEE_ITEM_ID');
$order_line_item->setModifiers($modifiers);

```

So are you saying here that both of those ids should be the same?  
both for the variation id?

When i have both of the ids as `6LUBEB7TVB5UCAJFVDJRRLKH`, or if i swap the ids around i get the following error message

> Modifier option with catalog object ID `6LUBEB7TVB5UCAJFVDJRRLKH` not found.

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [October 19, 2020, 7:37pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/4 "2020-10-19T19:37:33Z")

</div>

Errr, now I’m not sure I’m following. What are you trying to do? In your first post, you shared the error: `Item variation with catalog object ID RVNF32KZWOTKBN6PJYPCQCUE not found.`, which is a real error (`RVNF32KZWOTKBN6PJYPCQCUE` is an item, not an item variation).

Now you’re showing `Modifier option with catalog object ID 6LUBEB7TVB5UCAJFVDJRRLKH not found.`, which is also a real error (`6LUBEB7TVB5UCAJFVDJRRLKH` is an item variation, not a modifier option).

The ids need to match whatever object they are. In your above example, it’s creating new objects (so using arbitrary strings as IDs), but it sounds like you already have the objects created since you have the actual IDs. You need to set the id of the `OrderLineItemModifier` to have an ID of type `MODIFIER`, and the `lineItem` needs to have an ID of type `ITEM_VARIATION` based on your original code.

---

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 19, 2020, 7:53pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/5 "2020-10-19T19:53:09Z")

</div>

I guess then I am not sure what ids I am meant to be using and where

From the api documentation, it looks as if i need to use the ITEM\_VARIATION id as well as the ITEM id.

My first lot of code pasted is the variation object, which from what i can tell has an id of `6LUBEB7TVB5UCAJFVDJRRLKH` and that ITEM\_VARIATION belongs to an ITEM with an id of `RVNF32KZWOTKBN6PJYPCQCUE`

but when plugging them into the code below

```
$variationId = '6LUBEB7TVB5UCAJFVDJRRLKH';
$itemId = 'RVNF32KZWOTKBN6PJYPCQCUE';
$order_line_item_modifier = new \Square\Models\OrderLineItemModifier();
$order_line_item_modifier->setCatalogObjectId($variationId);

$modifiers = [$order_line_item_modifier];
$order_line_item = new \Square\Models\OrderLineItem('1');
$order_line_item->setCatalogObjectId($itemId);
$order_line_item->setModifiers($modifiers);

```

I get

> Item variation with catalog object ID `RVNF32KZWOTKBN6PJYPCQCUE` not found.

but when i swap them around

```
$variationId = '6LUBEB7TVB5UCAJFVDJRRLKH';
$itemId = 'RVNF32KZWOTKBN6PJYPCQCUE';
$order_line_item_modifier = new \Square\Models\OrderLineItemModifier();
$order_line_item_modifier->setCatalogObjectId($itemId);

$modifiers = [$order_line_item_modifier];
$order_line_item = new \Square\Models\OrderLineItem('1');
$order_line_item->setCatalogObjectId($variationId);
$order_line_item->setModifiers($modifiers);

```

i get

> Modifier option with catalog object ID `6LUBEB7TVB5UCAJFVDJRRLKH` not found.

So really, i just want to know how i can successfully create an order using existing items and item variations as what i am doing is clearly not correct

---

<div class="post-metadata">

**Author:** ![Jordan](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@Jordan](https://developer.squareup.com/forums/u/Jordan)\
**Post date:** [October 19, 2020, 8:35pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/6 "2020-10-19T20:35:17Z")

</div>

In the Catalog data model, everything is a Catalog Object and each catalog object has a type, Item, Item Variation, Modifier, etc.

_Items_ are the parent to _item variations_, for example, the item might be “Fountain Soda” and its variations might be “Small”, “Medium”, “Large”.

All items have at least one variation.

**The line items of an order, the product that is bought and sold, is always a variation, you do not ever sell the top level item**

Line items may be modified by a modifier which are another type of catalog object. For example, you might have a “light ice” modifier.

In your request payload, you are applying the `item_id`, a property pointing to the parent of the item variation, as an order line item, which is not correct- you must use the item variation ID for the order line item catalog object ID. Similarly, you are applying an item variation ID as a modifier, which is not correct. If you want to modify the order line item with a modifier, you need the ID of a modifier catalog object, not an item variation.

---

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 19, 2020, 8:50pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/7 "2020-10-19T20:50:07Z")

</div>

Ok great, that makes sense.

So can this be done without the modifier line?

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [October 19, 2020, 9:07pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/8 "2020-10-19T21:07:11Z")

</div>

If you don’t need a modifier, then yes it can be done without it. If you’re just trying to create an order for a particular item, all you need is the variation. Everything else is extra (modifiers, taxes, discounts, etc).

---

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 19, 2020, 9:52pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/9 "2020-10-19T21:52:53Z")

</div>

Ok great, thanks, i shall give that ago

---

<div class="post-metadata">

**Author:** ![refineddigital](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/refineddigital/32/222_2.png) [@refineddigital](https://developer.squareup.com/forums/u/refineddigital)\
**Post date:** [October 19, 2020, 10:12pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/10 "2020-10-19T22:12:23Z")

</div>

Ok great.

So that worked, and I am now getting a success result, as well as an order id.  
I am not seeing them in my order sandbox order dashboard however

---

<div class="post-metadata">

**Author:** ![sjosey](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/sjosey/32/40_2.png) [@sjosey](https://developer.squareup.com/forums/u/sjosey)\
**Post date:** [October 19, 2020, 10:38pm UTC](https://developer.squareup.com/forums/t/line-item-and-variation-numbers-for-orders/1078/11 "2020-10-19T22:38:43Z")

</div>

Before an order shows up in the dashboard, it needs to be:

1. Paid for
2. Have a fulfillment within it.

For more info see here: [https://developer.squareup.com/docs/orders-api/order-ahead-usecase](https://developer.squareup.com/docs/orders-api/order-ahead-usecase)
