Skip to main content

Overview

Shipping Customization Functions let you modify shipping rates, hide/show shipping options, rename delivery methods, and add custom shipping logic based on cart contents, location, or customer data.

Use Cases

Hide Shipping Methods

Remove options based on conditions
  • Hide express for remote areas
  • Remove free shipping below threshold
  • Restrict by product type

Adjust Rates

Modify shipping costs dynamically
  • Add handling fees
  • Apply discounts
  • Bulk order pricing
  • Weight-based adjustments

Rename Methods

Customize shipping option names
  • Add delivery estimates
  • Show carrier names
  • Include pricing details

Reorder Options

Change shipping method order
  • Promote fastest option
  • Prioritize cheapest
  • Customer preference

How It Works

1

Checkout Loads

Customer enters shipping address in checkout
2

Rates Calculated

Shopify calculates available shipping rates
3

Function Executes

Your function receives cart data and shipping rates
4

Rates Customized

Function returns modified rates and options
5

Checkout Updates

Customer sees customized shipping options

Example: Free Shipping Threshold

Generate a function that offers free shipping over $100:
1

Describe Your Function

2

Review Generated Code

Synapse creates:
  • Function logic (Rust or JavaScript)
  • Input query for cart and shipping data
  • Rate modification logic
  • Configuration
3

Deploy & Test

  • Automatic validation
  • Deployed to dev store
  • Test with different cart totals
4

Test in Checkout

  1. Add items to cart
  2. Go to checkout
  3. Enter shipping address
  4. See customized shipping options

Generated Function Structure

Function Code Examples

Common Patterns

Different shipping costs at different cart values:
Prompt Example:
Hide shipping options based on cart contents:
Prompt Example:
Adjust shipping rates by destination:
Prompt Example:
Show estimated delivery dates in shipping option names:
Prompt Example:

Operation Types

Shipping functions support these operations:
Modify shipping rate or name:
  • Change rate amount
  • Update display name
  • Modify description

Advanced Examples

Testing Shipping Functions

1

Test in Checkout

  1. Add items to cart
  2. Go to checkout
  3. Enter various shipping addresses
  4. Verify rates update correctly
2

Test Different Scenarios

  • Various cart values
  • Different product combinations
  • Multiple shipping addresses
  • International vs domestic
3

Check Function Logs

Monitor function executions
4

Performance Testing

  • Should execute in under 5ms
  • Test with many shipping options
  • Large cart edge cases

Best Practices

Always Show Options

Never hide all shipping methodsEnsure at least one method remains visible

Clear Messaging

Explain rate changesShow why fees added or discounts applied

Handle Errors

Graceful fallbacksReturn empty operations on errors, don’t crash

Performance

Keep functions fastMinimize loops, use Rust, cache calculations

Example Prompts

Troubleshooting

Cause: Function hiding all methodsSolution: Add safeguard to keep at least one visible
Cause: Price calculation errorSolution: Check Decimal parsing, handle errors with unwrap_or
Cause: Deployment issueSolution: Check deployment logs, verify function active

Next Steps

Discount Functions

Create custom discount logic

Payment Customization

Customize payment methods

Functions Overview

Learn about all function types

Debugging

Debug and optimize functions