Been testing the checkout UI and Functions on a dev store to add a “Ship on My UPS Account” option (very common in B2B) within the shipping block of the checkout. Trying to hide the other methods IF they select “Bill shipping to my UPS Account”, but this does not seem possible. Along with that we would need to update the shipping cost to $0.00 for this. Is there any other options or am I overlooking something where I make this happen? Or any other workarounds others have done?
Hey @JoeBTI this is doable, just not with the checkout UI extension alone. The UI piece can’t hide or reprice delivery options by itself.
Two pieces do it together:
- A delivery customization Function does the hiding. It reads a cart attribute and returns
hideoperations for every method except your UPS one. Delivery customizations can hide, rename, and reorder options, so this is exactly their job. - Your checkout UI extension sets that attribute when they pick “Bill to my UPS account” (
applyAttributeChange). The Function keys off it.
The one catch: delivery customizations can hide and rename, but they can’t change a rate’s price. So the $0 has to be a real rate. Create a $0 flat rate called something like “Ship on my UPS account,” then let the Function hide all the others when the attribute is set, leaving just that one at $0.00.
So the flow is: UI extension sets an attribute, the Function hides everything but the $0 rate. That combination is supported today.
@JoeBTI just to close the loop on the refund idea above, you dont actually need the post-order adjustment. a delivery customization Function hides the other methods live at checkout, hide/rename/reorder is exactly what those functions are for, so once the UPS-account attribute is set the checkout only shows your $0 rate. no refund step needed.
and it doesnt matter if these are CarrierService rates or plain Shopify Shipping ones, the Function runs on whatever delivery options come back, so it hides carrier-calculated rates the same way it hides native ones.
This is pretty much what I did and we do use they CarrierService.
- Created a flat rate shipping option at $0 and called it “Ship on my UPS account”, which is hidden by default.
- UI checkbox for the "Bill shipping to my UPS Account”, then all CarrierService rates are hidden and the $0 flat rate shipping option is shown.
- UPS account data is saved in a metafield as json, so our internal system can grab it with order info.
@JoeBTI nice, thats exactly the right setup. one thing worth knowing since youre stashing the UPS account as a json metafield: the delivery-customization Function can only read cart/checkout attributes, not order metafields (the order doesnt exist yet at checkout), so keep the hide trigger keyed off the attribute like you are and let the metafield just be the fulfillment hand-off. that split is what keeps it from breaking when Shopify recalculates rates. sounds like youve got it dialed in though.
