How can I add multiple shipping methods in my app's checkout page?

How can I add multiple shipping methods in my app's checkout page?

werhoty
Shopify Partner
1 0 0

Hi evryone, I develop new app, and trying to add two shipping method on checkout page(standard and fast), but when I tring to push two methods for /admin/api/2024-04/carrier_services.json I got an error: body: {source: '{"errors":{"base":["Standard is already configured"]}}} . Add my code below:

export const action = async ({ request }) => {
try {
const { admin, session } = await authenticate.admin(request);

const carrier_service_courier = new admin.rest.resources.CarrierService({ session: session });
carrier_service_courier.name = "Standard";
carrier_service_courier.callback_url = "https://mystore/carrier";
carrier_service_courier.active = true;
await carrier_service_courier.save();

const carrier_service = new admin.rest.resources.CarrierService({ session: session });
carrier_service.name = "Fast";
carrier_service.callback_url = "https://mystore/carrierFast";
carrier_service.active = true;
await carrier_service.save();



return json({status: 'success'});
} catch (error) {
console.error('Error adding carrier services:', error);
return json({ error: 'Failed to add carrier services' }, 500);
}
};

 

Replies 0 (0)