0

How to i get color attribute for the returned json from this end point https://cleopatraweb.com/rest/V1/orders/9495?

This the response of the request. I could not find color attribute for products.

{
    "base_currency_code": "OMR",
    "base_discount_amount": 0,
    "base_grand_total": 59.74,
    "base_discount_tax_compensation_amount": 0,
    "base_shipping_amount": 2.2,
    "base_shipping_discount_amount": 0,
    "base_shipping_discount_tax_compensation_amnt": 0,
    "base_shipping_incl_tax": 2.2,
    "base_shipping_tax_amount": 0,
    "base_subtotal": 54.8,
    "base_subtotal_incl_tax": 57.54,
    "base_tax_amount": 2.74,
    "base_total_due": 59.74,
    "base_to_global_rate": 1,
    "base_to_order_rate": 1,
    "billing_address_id": 18867,
    "created_at": "2022-08-05 12:12:16",
    "customer_email": "[email protected]",
    "customer_group_id": 0,
    "customer_is_guest": 1,
    "customer_note_notify": 1,
    "discount_amount": 0,
    "email_sent": 1,
    "entity_id": 9495,
    "global_currency_code": "OMR",
    "grand_total": 59.74,
    "discount_tax_compensation_amount": 0,
    "increment_id": "000009041",
    "is_virtual": 0,
    "order_currency_code": "OMR",
    "protect_code": "3f57796da5d16196e93d615315b6cef8",
    "quote_id": 107596,
    "remote_ip": "127.0.0.1",
    "shipping_amount": 2.2,
    "shipping_description": "Shipping Cost - 2.2 OMR delivery charges for up to 3KG only, 500 baisa additional for every 1kg.",
    "shipping_discount_amount": 0,
    "shipping_discount_tax_compensation_amount": 0,
    "shipping_incl_tax": 2.2,
    "shipping_tax_amount": 0,
    "state": "new",
    "status": "pending",
    "store_currency_code": "OMR",
    "store_id": 1,
    "store_name": "Main Website\nMain Website Store\n",
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "subtotal": 54.8,
    "subtotal_incl_tax": 57.54,
    "tax_amount": 2.74,
    "total_due": 59.74,
    "total_item_count": 2,
    "total_qty_ordered": 2,
    "updated_at": "2022-08-05 12:12:17",
    "weight": 2,
    "items": [
        {
            "amount_refunded": 0,
            "base_amount_refunded": 0,
            "base_discount_amount": 0,
            "base_discount_invoiced": 0,
            "base_discount_tax_compensation_amount": 0,
            "base_original_price": 17.9,
            "base_price": 11.9,
            "base_price_incl_tax": 12.5,
            "base_row_invoiced": 0,
            "base_row_total": 11.9,
            "base_row_total_incl_tax": 12.5,
            "base_tax_amount": 0.6,
            "base_tax_invoiced": 0,
            "created_at": "2022-08-05 12:12:16",
            "discount_amount": 0,
            "discount_invoiced": 0,
            "discount_percent": 0,
            "free_shipping": 0,
            "discount_tax_compensation_amount": 0,
            "is_qty_decimal": 0,
            "is_virtual": 0,
            "item_id": 13050,
            "name": "JBL JR Pop Portable Bluetooth Speaker",
            "no_discount": 0,
            "order_id": 9495,
            "original_price": 17.9,
            "price": 11.9,
            "price_incl_tax": 12.5,
            "product_id": 3674,
            "product_type": "simple",
            "qty_canceled": 0,
            "qty_invoiced": 0,
            "qty_ordered": 1,
            "qty_refunded": 0,
            "qty_shipped": 0,
            "quote_item_id": 109407,
            "row_invoiced": 0,
            "row_total": 11.9,
            "row_total_incl_tax": 12.5,
            "row_weight": 1,
            "sku": "JBL JR Pop Portable Bluetooth Speaker",
            "store_id": 1,
            "tax_amount": 0.6,
            "tax_invoiced": 0,
            "tax_percent": 5,
            "updated_at": "2022-08-05 12:12:16",
            "weight": 1
        },
        {
            "amount_refunded": 0,
            "base_amount_refunded": 0,
            "base_discount_amount": 0,
            "base_discount_invoiced": 0,
            "base_discount_tax_compensation_amount": 0,
            "base_original_price": 45.9,
            "base_price": 42.9,
            "base_price_incl_tax": 45.04,
            "base_row_invoiced": 0,
            "base_row_total": 42.9,
            "base_row_total_incl_tax": 45.04,
            "base_tax_amount": 2.14,
            "base_tax_invoiced": 0,
            "created_at": "2022-08-05 12:12:16",
            "discount_amount": 0,
            "discount_invoiced": 0,
            "discount_percent": 0,
            "free_shipping": 0,
            "discount_tax_compensation_amount": 0,
            "is_qty_decimal": 0,
            "is_virtual": 0,
            "item_id": 13051,
            "name": "Amazfit A2013 T-Rex Pro Smart Watch",
            "no_discount": 0,
            "order_id": 9495,
            "original_price": 45.9,
            "price": 42.9,
            "price_incl_tax": 45.04,
            "product_id": 10355,
            "product_type": "simple",
            "qty_canceled": 0,
            "qty_invoiced": 0,
            "qty_ordered": 1,
            "qty_refunded": 0,
            "qty_shipped": 0,
            "quote_item_id": 109408,
            "row_invoiced": 0,
            "row_total": 42.9,
            "row_total_incl_tax": 45.04,
            "row_weight": 1,
            "sku": "Amazfit A2013 T-Rex Pro Smart Watch",
            "store_id": 1,
            "tax_amount": 2.14,
            "tax_invoiced": 0,
            "tax_percent": 5,
            "updated_at": "2022-08-05 12:12:16",
            "weight": 1
        }
    ],
    "billing_address": {
        "address_type": "billing",
        "city": "Salalah",
        "country_id": "OM",
        "email": "[email protected]",
        "entity_id": 18867,
        "firstname": "Vivian ",
        "lastname": "Lobo",
        "parent_id": 9495,
        "postcode": "900",
        "street": [
            "Al Wadi, Villa No. 1 , first floor, Salalah"
        ],
        "telephone": "96920766"
    },
    "payment": {
        "account_status": null,
        "additional_information": [
            "COD - Cash on Delivery"
        ],
        "amount_ordered": 59.74,
        "base_amount_ordered": 59.74,
        "base_shipping_amount": 2.2,
        "cc_exp_year": "0",
        "cc_last4": null,
        "cc_ss_start_month": "0",
        "cc_ss_start_year": "0",
        "entity_id": 9494,
        "method": "checkmo",
        "parent_id": 9495,
        "shipping_amount": 2.2
    },
    "status_histories": [],
    "extension_attributes": {
        "shipping_assignments": [
            {
                "shipping": {
                    "address": {
                        "address_type": "shipping",
                        "city": "Salalah",
                        "country_id": "OM",
                        "email": "[email protected]",
                        "entity_id": 18866,
                        "firstname": "Vivian ",
                        "lastname": "Lobo",
                        "parent_id": 9495,
                        "postcode": "900",
                        "street": [
                            "Al Wadi, Villa No. 1 , first floor, Salalah"
                        ],
                        "telephone": "96920766"
                    },
                    "method": "tablerate_bestway",
                    "total": {
                        "base_shipping_amount": 2.2,
                        "base_shipping_discount_amount": 0,
                        "base_shipping_discount_tax_compensation_amnt": 0,
                        "base_shipping_incl_tax": 2.2,
                        "base_shipping_tax_amount": 0,
                        "shipping_amount": 2.2,
                        "shipping_discount_amount": 0,
                        "shipping_discount_tax_compensation_amount": 0,
                        "shipping_incl_tax": 2.2,
                        "shipping_tax_amount": 0
                    }
                },
                "items": [
                    {
                        "amount_refunded": 0,
                        "base_amount_refunded": 0,
                        "base_discount_amount": 0,
                        "base_discount_invoiced": 0,
                        "base_discount_tax_compensation_amount": 0,
                        "base_original_price": 17.9,
                        "base_price": 11.9,
                        "base_price_incl_tax": 12.5,
                        "base_row_invoiced": 0,
                        "base_row_total": 11.9,
                        "base_row_total_incl_tax": 12.5,
                        "base_tax_amount": 0.6,
                        "base_tax_invoiced": 0,
                        "created_at": "2022-08-05 12:12:16",
                        "discount_amount": 0,
                        "discount_invoiced": 0,
                        "discount_percent": 0,
                        "free_shipping": 0,
                        "discount_tax_compensation_amount": 0,
                        "is_qty_decimal": 0,
                        "is_virtual": 0,
                        "item_id": 13050,
                        "name": "JBL JR Pop Portable Bluetooth Speaker",
                        "no_discount": 0,
                        "order_id": 9495,
                        "original_price": 17.9,
                        "price": 11.9,
                        "price_incl_tax": 12.5,
                        "product_id": 3674,
                        "product_type": "simple",
                        "qty_canceled": 0,
                        "qty_invoiced": 0,
                        "qty_ordered": 1,
                        "qty_refunded": 0,
                        "qty_shipped": 0,
                        "quote_item_id": 109407,
                        "row_invoiced": 0,
                        "row_total": 11.9,
                        "row_total_incl_tax": 12.5,
                        "row_weight": 1,
                        "sku": "JBL JR Pop Portable Bluetooth Speaker",
                        "store_id": 1,
                        "tax_amount": 0.6,
                        "tax_invoiced": 0,
                        "tax_percent": 5,
                        "updated_at": "2022-08-05 12:12:16",
                        "weight": 1
                    },
                    {
                        "amount_refunded": 0,
                        "base_amount_refunded": 0,
                        "base_discount_amount": 0,
                        "base_discount_invoiced": 0,
                        "base_discount_tax_compensation_amount": 0,
                        "base_original_price": 45.9,
                        "base_price": 42.9,
                        "base_price_incl_tax": 45.04,
                        "base_row_invoiced": 0,
                        "base_row_total": 42.9,
                        "base_row_total_incl_tax": 45.04,
                        "base_tax_amount": 2.14,
                        "base_tax_invoiced": 0,
                        "created_at": "2022-08-05 12:12:16",
                        "discount_amount": 0,
                        "discount_invoiced": 0,
                        "discount_percent": 0,
                        "free_shipping": 0,
                        "discount_tax_compensation_amount": 0,
                        "is_qty_decimal": 0,
                        "is_virtual": 0,
                        "item_id": 13051,
                        "name": "Amazfit A2013 T-Rex Pro Smart Watch",
                        "no_discount": 0,
                        "order_id": 9495,
                        "original_price": 45.9,
                        "price": 42.9,
                        "price_incl_tax": 45.04,
                        "product_id": 10355,
                        "product_type": "simple",
                        "qty_canceled": 0,
                        "qty_invoiced": 0,
                        "qty_ordered": 1,
                        "qty_refunded": 0,
                        "qty_shipped": 0,
                        "quote_item_id": 109408,
                        "row_invoiced": 0,
                        "row_total": 42.9,
                        "row_total_incl_tax": 45.04,
                        "row_weight": 1,
                        "sku": "Amazfit A2013 T-Rex Pro Smart Watch",
                        "store_id": 1,
                        "tax_amount": 2.14,
                        "tax_invoiced": 0,
                        "tax_percent": 5,
                        "updated_at": "2022-08-05 12:12:16",
                        "weight": 1
                    }
                ]
            }
        ],
        "payment_fee_amount": "0.0000",
        "base_payment_fee_amount": "0.0000",
        "payment_fee_tax_amount": "0.0000",
        "base_payment_fee_tax_amount": "0.0000"
    }
}

1 Answer 1

0

So this is how i worked around this case. Hope this helps someone, esp the sites still using 2.2.6.

  1. Send the orders request https://yoursite.com/rest/V1/orders/[ID] and get the list of products under "items".

  2. Each item will have an "item_id" which can be used to get its detail which are unique to the order id above. https://yoursite.com/rest/V1/orders/items/[ID]

  3. If the response has "product_option", then get its "option_id" and "option_value". There will be only one and use it to find the color in https://yoursite.com/rest/V1/products/[sku]

  4. If it doenst have "product_option", then you can simply get the color like how we did before.

All the best!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.