Shopify treats numbers with 3 decimal places as int instead of float

Solved

Shopify treats numbers with 3 decimal places as int instead of float

saso
Tourist
6 0 0

There is a bug with the API call when creating an order, where Shopify treats numbers with 3 decimal places as int instead of float. Note, if the payload contains numbers with 2, 4, or more decimals, it gets correctly saved. The issue is triggered only with 3 decimals.

Endpoint: admin/api/2021-07/orders.json (API version does not matter)

Example POST request with a response:

Screenshot 2021-08-31 at 11.11.53.png

Example order:

Screenshot 2021-08-31 at 11.12.15.png

-----

Full body (example raw JSON)

 

{
    "order": {
        "line_items": [
            {
                "variant_id": "1234530",
                "quantity": "1",
                "price": "10.391",
                "vendor": "shopify-store",
                "title": "A donkey out of stock",
                "grams": 0,
                "sku": ""
            }
        ],
        "customer": {
            "first_name": "Jorge",
            "last_name": "Address",
            "email": "[email protected]"
        },
        "buyer_accepts_marketing": "1",
        "shipping_address": {
            "country": "United States",
            "province": "Oregon",
            "first_name": "Jorge",
            "last_name": "Address",
            "city": "Portland",
            "address1": "1315 NE Fremont St",
            "zip": "97212",
            "phone": "",
            "company": "",
            "address2": ""
        },
        "note": "",
        "note_attributes": [],
        "referring_site": "https:\/\/test.myshopify.com\/cart",
        "billing_address": {
            "country": "United States",
            "province": "Oregon",
            "first_name": "Jorge",
            "last_name": "Address",
            "city": "Portland",
            "address1": "1315 NE Fremont St",
            "zip": "97212",
            "phone": "",
            "company": "",
            "address2": ""
        },
        "email": "[email protected]",
        "transactions": [
            {
                "kind": "sale",
                "status": "success",
                "amount": "10.391"
            }
        ],
        "discount_codes": [],
        "financial_status": "paid",
        "shipping_lines": [
            {
                "code": "FirstPackage",
                "price": 0.00,
                "title": "First Class Package",
                "source": "usps",
                "tax_lines": [],
                "carrier_identifier": null,
                "requested_fulfillment_service_id": null
            }
        ],
        "send_receipt": true,
        "send_fulfillment_receipt": true,
        "inventory_behaviour": "decrement_ignoring_policy",
        "processing_method": "offsite",
        "gateway": "nmi_test",
        "total_weight": 0,
        "total_tax": 0,
        "tags": "test-bla, te_id_Q0AWsQoaYcsKetgpWM7v, 0-4396216362, TEST Checkout, test_FID_test-bla",
        "metafields": [
            {
                "key": "avs_result_code",
                "value": "Y",
                "value_type": "string",
                "namespace": "payment_details"
            },
            {
                "key": "credit_card_bin",
                "value": "453600",
                "value_type": "string",
                "namespace": "payment_details"
            },
            {
                "key": "cvv_result_code",
                "value": "M",
                "value_type": "string",
                "namespace": "payment_details"
            },
            {
                "key": "credit_card_number",
                "value": "•••• •••• •••• 4242",
                "value_type": "string",
                "namespace": "payment_details"
            },
            {
                "key": "credit_card_company",
                "value": "Visa",
                "value_type": "string",
                "namespace": "payment_details"
            }
        ]
    }
}

 

 

Response:

 

{
    "order": {
        "id": 4023770185837,
        "admin_graphql_api_id": "gid://shopify/Order/4023770185837",
        "app_id": 1356615,
        "browser_ip": null,
        "buyer_accepts_marketing": true,
        "cancel_reason": null,
        "cancelled_at": null,
        "cart_token": null,
        "checkout_id": null,
        "checkout_token": null,
        "closed_at": null,
        "confirmed": true,
        "contact_email": "[email protected]",
        "created_at": "2021-08-31T11:11:29+02:00",
        "currency": "USD",
        "current_subtotal_price": "10391.00",
        "current_subtotal_price_set": {
            "shop_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            }
        },
        "current_total_discounts": "0.00",
        "current_total_discounts_set": {
            "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
            }
        },
        "current_total_duties_set": null,
        "current_total_price": "10391.00",
        "current_total_price_set": {
            "shop_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            }
        },
        "current_total_tax": "0.00",
        "current_total_tax_set": {
            "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
            }
        },
        "customer_locale": null,
        "device_id": null,
        "discount_codes": [],
        "email": "[email protected]",
        "financial_status": "paid",
        "fulfillment_status": null,
        "gateway": "nmi_test",
        "landing_site": null,
        "landing_site_ref": null,
        "location_id": null,
        "name": "#483578",
        "note": "",
        "note_attributes": [],
        "number": 482578,
        "order_number": 483578,
        "order_status_url": "https://carthook-production-testing-1.myshopify.com/18821611584/orders/e0988a867248bf31d8564f7e8072d0f4/authenticate?key=c2ffd6892df2a036ba8b36098910592d",
        "original_total_duties_set": null,
        "payment_gateway_names": [
            "nmi_test"
        ],
        "phone": null,
        "presentment_currency": "USD",
        "processed_at": "2021-08-31T11:11:29+02:00",
        "processing_method": "",
        "reference": null,
        "referring_site": "https://test.myshopify.com/cart",
        "source_identifier": null,
        "source_name": "1356615",
        "source_url": null,
        "subtotal_price": "10391.00",
        "subtotal_price_set": {
            "shop_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            }
        },
        "tags": "0-4396216362, te_id_Q0AWsQoaYcsKetgpWM7v, TEST Checkout, test-bla, test_FID_test-bla",
        "tax_lines": [],
        "taxes_included": false,
        "test": false,
        "token": "e0988a867248bf31d8564f7e8072d0f4",
        "total_discounts": "0.00",
        "total_discounts_set": {
            "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
            }
        },
        "total_line_items_price": "10391.00",
        "total_line_items_price_set": {
            "shop_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            }
        },
        "total_outstanding": "10380.61",
        "total_price": "10391.00",
        "total_price_set": {
            "shop_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "10391.00",
                "currency_code": "USD"
            }
        },
        "total_price_usd": "10391.00",
        "total_shipping_price_set": {
            "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
            }
        },
        "total_tax": "0.00",
        "total_tax_set": {
            "shop_money": {
                "amount": "0.00",
                "currency_code": "USD"
            },
            "presentment_money": {
                "amount": "0.00",
                "currency_code": "USD"
            }
        },
        "total_tip_received": "0.00",
        "total_weight": 0,
        "updated_at": "2021-08-31T11:11:30+02:00",
        "user_id": null,
        "billing_address": {
            "first_name": "Jorge",
            "address1": "1315 NE Fremont St",
            "phone": "",
            "city": "Portland",
            "zip": "97212",
            "province": "Oregon",
            "country": "United States",
            "last_name": "Address",
            "address2": "",
            "company": "",
            "latitude": 45.5483639,
            "longitude": -122.6524147,
            "name": "Jorge Address",
            "country_code": "US",
            "province_code": "OR"
        },
        "customer": {
            "id": 3363283599469,
            "email": "[email protected]",
            "accepts_marketing": true,
            "created_at": "2020-06-17T13:07:52+02:00",
            "updated_at": "2021-08-31T11:11:30+02:00",
            "first_name": "Jorge",
            "last_name": "Address",
            "orders_count": 9,
            "state": "enabled",
            "total_spent": "10518.43",
            "last_order_id": 4023770185837,
            "note": null,
            "verified_email": true,
            "multipass_identifier": null,
            "tax_exempt": false,
            "phone": null,
            "tags": "Inactive Subscriber",
            "last_order_name": "#483578",
            "currency": "USD",
            "accepts_marketing_updated_at": "2020-06-17T13:07:53+02:00",
            "marketing_opt_in_level": "single_opt_in",
            "tax_exemptions": [],
            "admin_graphql_api_id": "gid://shopify/Customer/3363283599469",
            "default_address": {
                "id": 6495281414253,
                "customer_id": 3363283599469,
                "first_name": "Jorge",
                "last_name": "Address",
                "company": "",
                "address1": "1315 NE Fremont St",
                "address2": "",
                "city": "Portland",
                "province": "Oregon",
                "country": "United States",
                "zip": "97212",
                "phone": "",
                "name": "Jorge Address",
                "province_code": "OR",
                "country_code": "US",
                "country_name": "United States",
                "default": true
            }
        },
        "discount_applications": [],
        "fulfillments": [],
        "line_items": [
            {
                "id": 10287198535789,
                "admin_graphql_api_id": "gid://shopify/LineItem/10287198535789",
                "fulfillable_quantity": 1,
                "fulfillment_service": "manual",
                "fulfillment_status": null,
                "gift_card": false,
                "grams": 0,
                "name": "A donkey out of stock",
                "price": "10391.00",
                "price_set": {
                    "shop_money": {
                        "amount": "10391.00",
                        "currency_code": "USD"
                    },
                    "presentment_money": {
                        "amount": "10391.00",
                        "currency_code": "USD"
                    }
                },
                "product_exists": false,
                "product_id": null,
                "properties": [],
                "quantity": 1,
                "requires_shipping": true,
                "sku": "",
                "taxable": true,
                "title": "A donkey out of stock",
                "total_discount": "0.00",
                "total_discount_set": {
                    "shop_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    },
                    "presentment_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    }
                },
                "variant_id": null,
                "variant_inventory_management": null,
                "variant_title": null,
                "vendor": "shopify-store",
                "tax_lines": [],
                "duties": [],
                "discount_allocations": []
            }
        ],
        "refunds": [],
        "shipping_address": {
            "first_name": "Jorge",
            "address1": "1315 NE Fremont St",
            "phone": "",
            "city": "Portland",
            "zip": "97212",
            "province": "Oregon",
            "country": "United States",
            "last_name": "Address",
            "address2": "",
            "company": "",
            "latitude": 45.5483639,
            "longitude": -122.6524147,
            "name": "Jorge Address",
            "country_code": "US",
            "province_code": "OR"
        },
        "shipping_lines": [
            {
                "id": 3439817261165,
                "carrier_identifier": null,
                "code": "FirstPackage",
                "delivery_category": null,
                "discounted_price": "0.00",
                "discounted_price_set": {
                    "shop_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    },
                    "presentment_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    }
                },
                "phone": null,
                "price": "0.00",
                "price_set": {
                    "shop_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    },
                    "presentment_money": {
                        "amount": "0.00",
                        "currency_code": "USD"
                    }
                },
                "requested_fulfillment_service_id": null,
                "source": "usps",
                "title": "First Class Package",
                "tax_lines": [],
                "discount_allocations": []
            }
        ]
    }
}

 

 

 

 

Accepted Solution (1)

csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

Hi @saso 

Wanted to follow up with you to let you know that a fix has been put in place, and you shouldn't see this behaviour going forward.

 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

GrahamS
Shopify Staff (Retired)
193 37 55

Hello @saso ,

Thanks for bringing this to our attention. We ran a couple of tests using the payload you provided (you may have received a confirmation email accidentally on the first test - apologies for that!). We noted that this doesn't happen in GraphQL, nor several other REST endpoints. It seemingly just occurs with the order REST endpoint. We're confirming this one with the devs to see what might be happening here, and I'll let you know what comes back.

Best,

Graham

To learn more visit the Shopify Help Center or the Community Blog.

csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

Hi @saso 

Wanted to follow up with you to let you know that a fix has been put in place, and you shouldn't see this behaviour going forward.

 

To learn more visit the Shopify Help Center or the Community Blog.

devkind
Shopify Partner
1 0 1

Hi there,

It looks like that this bug is back. We've observed the same behaviour while importing the products.


Let us know when this is fixed.

Thanks

Looking to supercharge your Shopify store? Contact us today!