For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
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:
Here is a screenshot of the function run details:
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
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!