Hi @tungnk ,
Based on the provided error response documentation and the current response you’re receiving, it seems the format has changed. The documented error response includes a status, message, and description in a JSON structure, like:
{
"status": 422,
"message": "Cart Error",
"description": null
}
However, your current response shows:
{status: 422, message: "Selling period has not started yet.", description: null} [Prototype]: Object
The current format appears to be a JavaScript object literal rather than a proper JSON string, which might be causing compatibility issues with your Dawn theme’s error handling code. The Dawn theme code seems to expect a JSON response (e.g., response.json()), but the current response might not be parsed correctly due to this change.
This could indicate a new update or change in Shopify’s API behavior rather than a bug. To confirm, I recommend checking the latest Shopify API documentation or changelog for updates related to cart error responses. If this is unintended, it might be a bug—consider reaching out to Shopify support with your observations.
For a quick fix in your Dawn theme, you could modify the onSubmitHandler to handle both JSON and object literal responses. Update the code to check the response type before processing:
fetch('/cart/add.js', {
method: 'POST',
body: JSON.stringify(formData),
headers: { 'Content-Type': 'application/json' }
})
.then((response) => response.json())
.then((data) => {
if (data.status && data.message) {
// Handle error
const errorMessage = data.message;
const soldOutMessage = document.querySelector('.sold-out-message');
if (soldOutMessage) {
soldOutMessage.textContent = errorMessage;
soldOutMessage.classList.remove('hidden');
}
} else {
// Success case
window.location = '/cart';
}
})
.catch((error) => console.error('Error:', error));
Thanks!