Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hello
I am trying to generate checkout page using Checkout API, it works great with line items and other stuff.
It returns me a 400 error when I try to create checkout with line items and their custom properties (Custom Properties means the optional data that we pass with line items).
Is checkout API supported custom optional data with line items?
This my Request
$line_items = [
[
'variant_id' => 1232211231,
'quantity' => 1,
'properties' => [
[
'name' => 'asdasd',
'value' => 'asdsa'
],
[
'name' => 'asdasd',
'value' => 'asdsa'
]
]
]
]
$data = [
"checkout" => [
"email" => $request->input('job_email'),
"note" => $request->input('accounts_notes'),
'shipping_address' => [
"address1" => $request->input('ship_address'),
"address2" => '',
"city" => $request->input('ship_city'),
"company" => $request->input('ship_company'),
"country" => $request->input('ship_country'),
"last_name" => $request->input('ship_name'),
"province" => $request->input('ship_state'),
"zip" => $request->input('ship_zipcode'),
"phone" => $request->input('phone_number'),
],
'billing_address' => [
"address1" => $request->input('bill_address'),
"address2" => '',
"city" => $request->input('bill_city'),
"company" => $request->input('bill_company'),
"country" => $request->input('bill_country'),
"last_name" => $request->input('bill_name'),
"province" => $request->input('bill_state'),
"zip" => $request->input('bill_zipcode'),
"phone" => $request->input('phone_number'),
],
"line_items" => $line_items
]
];
$checkout = $this->shopifyProductsController->getShopify()->call([
'METHOD' => 'POST',
'URL' => '/admin/api/2019-10/checkouts.json',
'DATA' => $data
]);
properties field is an associative array, your line items should be assigned as follows:
$line_items = [ [ "variant_id" => 1232211231, "quantity" => 1, "properties" => [ "key1" => "value1", "key2" => "value2" ] ]