I’m making a shipping service app to Shopify and my callback URL have this JSON post using json_decode to make an array. The value I want to sum is grams and putting into variable and then compare with the value of another variable using if ($weight <= $maxweight).
{
"rate": {
"items": [
{
"name": "My Product 3",
"sku": null,
"quantity": 1,
"grams": 1000,
"price": 2000,
"vendor": "TestVendor",
"requires_shipping": true,
"taxable": true,
"fulfillment_service": "manual"
},
{
"name": "My Product 1",
"sku": null,
"quantity": 1,
"grams": 500,
"price": 1000,
"vendor": "TestVendor",
"requires_shipping": true,
"taxable": true,
"fulfillment_service": "manual"
},
{
"name": "My Product 2",
"sku": null,
"quantity": 1,
"grams": 2000,
"price": 3000,
"vendor": "TestVendor",
"requires_shipping": true,
"taxable": true,
"fulfillment_service": "manual"
}
],
"currency": "CAD"
}
}