App reviews, troubleshooting, and recommendations
I want to make order from shopify extension. I used app proxy I got the data but now how can I place order or is it possible to call api directly on extension and make a order?
hi @vishal206 ,
You can use shopify admin api to create order on the store. You can hit the create order API directly from the extension or you can have a dedicated route in you're app to create the order. The extension then should hit you're app and you're app with admin access should create the order on the store. To create a order you can refer to the shopifys API documentation
Create order - Shopify REST api docs
Create a draft order using GraphQL admin api - Shopify
would you please show an example code? I have tried to use
fetch("/admin/api/2023-10/orders.json")
but It shows 404 or 500 error
hi @vishal206
I see that your trying to use the Admin REST API to create an order. Create order is a post route and it needs a request body. The shape of the body is documented at the link I gave you before. I'm giving you a demo fetch request from the example from that link
const order = {};
order.line_items = [
{
"title": "Big Brown Bear Boots",
"price": 74.99,
"grams": "1300",
"quantity": 3,
"tax_lines": [
{
"price": 13.5,
"rate": 0.06,
"title": "State tax"
}
]
}
];
order.transactions = [
{
"kind": "sale",
"status": "success",
"amount": 238.47
}
];
order.total_tax = 13.5;
order.currency = "EUR";
fetch("/admin/api/2023-10/orders.json", {
method: "POST",
body: JSON.stringify(order),
headers: {
"Content-type": "application/json"
}
})
one last thing should I call order API directly from extension or I use app proxy to get data from extension they I call order API using fetch inside app proxy route
hi @vishal206 ,
Maybe calling the API from you're app proxy is the better choice.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024