we are to trying like this to enable assetes but getting 404 ?
$shopifyDomain = “your-domain”;
$accessToken = “your-access-tocken”;
$themeId = “your-themid”;
$assetKey = “config/settings_data.json”;
$blockIdToEnable = “your block id”; // Block ID to modify
// 1. GET current settings_data.json
$getUrl = “https://$shopifyDomain/admin/api/2024-04/themes/$themeId/assets.json?asset[key]=$assetKey”;
$ch = curl_init($getUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
“X-Shopify-Access-Token: $accessToken”,
“Content-Type: application/json”
]
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check if GET request was successful
if ($httpCode !== 200) {
die(“Error fetching current settings: HTTP $httpCode\n” . curl_error($ch));
}
// Decode response to get settings data
$assetData = json_decode($response, true);
if (!isset($assetData[‘asset’][‘value’])) {
die(“Error: settings_data.json not found or no value returned.”);
}
// Decode settings_data.json content
$settings = json_decode($assetData[‘asset’][‘value’], true);
// 2. Verify if the block ID exists before modifying
if (isset($settings[‘current’][‘blocks’][$blockIdToEnable])) {
$settings[‘current’][‘blocks’][$blockIdToEnable][‘disabled’] = false; // Enable block (set to false)
} else {
die(“Block ID $blockIdToEnable not found in theme settings.”);
}
// 3. Prepare PUT request data
// PUT request URL
$putUrl = “https://$shopifyDomain/admin/api/2024-04/themes/$themeId/assets.json”;
// Prepare the PUT payload
$putData = [
‘asset’ => [
‘key’ => $assetKey,
‘value’ => json_encode($settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
]
];
// Initialize cURL for PUT request
$ch = curl_init($putUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => “PUT”,
CURLOPT_POSTFIELDS => json_encode($putData),
CURLOPT_HTTPHEADER => [
“X-Shopify-Access-Token: $accessToken”,
“Content-Type: application/json”
]
]);
// Execute PUT request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode === 200) {
echo “Successfully updated app embed settings.\n”;
} else {
echo “Error updating settings: HTTP $httpCode\n”;
print_r(json_decode($response, true));
}
curl_close($ch)