App reviews, troubleshooting, and recommendations
I can successfully create a draft order using the DraftOrder API. However, when the order has an uploaded file attached, it fails to upload and attach the file to the property field of the draft order. Here is the PHP code that runs after the initial draftorder is created. It is attempting to update the draft order with the uploaded file. I have so far (error checking removed for simplicity):
$file_data = file_get_contents($_FILES['properties']['tmp_name']['customphoto']);
$result = shopify_call($access_token, "https://{$shopifyShop}/admin/api/{$shopifyApiVersion}/assets.json",
json_encode(['asset' => ['attachment' => base64_encode($file_data)]]), 'POST');
$file_info = json_decode($result);
$file_url = $file_info['asset']['public_url'];
// Step 3: Associate the file URL with the DraftOrder
$draft_order_update_data = [
'draft_order' => [
'note_attributes' => [
[
'name' => 'file_url',
'value' => $file_url,
],
],
],
];
$result = shopify_call($access_token, "https://{$shopifyShop}/admin/api/{$shopifyApiVersion}/draft_orders/{$draftOrderID}.json",
json_encode($draft_order_update_data), 'PUT');
$updateResponse = json_decode($result);
It currently returns a 404 Not Found error, when attempting to upload the file. What am I doing wrong?
We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024