Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Rename local delivery option in one-page checkout

Rename local delivery option in one-page checkout

jamalali81
Shopify Partner
25 0 4

We offer local delivery to our customers but want to rename the option that appears on one-page checkout. I have implemented this tutorial (I have only removed the zip code filter) and it does rename the standard delivery option but not the local delivery one.

 

Here is my code:

export function run(input) {
const message = "May be delayed due to weather conditions";

let toRename = input.cart.deliveryGroups
.flatMap(group => group.deliveryOptions)
.map(option => ({
rename: {
deliveryOptionHandle: option.handle,
title: option.title ? `${option.title} - ${message}` : message
}
}));

return {
operations: toRename
};
};

 

Here is a screenshot of the checkout page:

Screenshot 2024-01-02 at 22.45.15.png

 

Here is a screenshot of the function run details:

Screenshot 2024-01-02 at 22.44.58.png

Replies 2 (2)

Liam
Community Manager
3108 344 899

Hi Jamalali81,

 

I believe you'll need to modify your existing code to target the specific local delivery option, by applying a condition that checks if the current delivery option is indeed the local delivery option. You may need to target the local delivery option handle specifically - if you're not sure of the handle, you can temporarily log the handles to the console to find out:

 

input.cart.deliveryGroups
.flatMap(group => group.deliveryOptions)
.forEach(option => console.log(option.handle));

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

jamalali81
Shopify Partner
25 0 4

Hi @Liam, thanks for replying.

 

In the function run details screenshot, the Output section shows the option.handle in the rename operation. Is that not the correct way to do it? Do you have a link to the docs with more details as to how this works? Thank you!