Getting Started with Shopify Functions
Last updated
21st April 2024
Read time
5 mins
Shopify Functions allow you to create custom commerce logic that transforms how your store operates. With Sway Functions Generator, you can build these custom functions without writing a single line of code. This guide will help you understand what Shopify Functions are and how to implement them for your specific business needs.
What Are Shopify Functions?
Shopify Functions allow merchants to customize core commerce logic in four key areas:
- Discounts - Create custom discount strategies beyond Shopify's native capabilities
- Shipping - Customize how shipping options appear and are filtered at checkout
- Payment - Control which payment methods are available and how they're displayed
- Cart Validation - Create rules that validate cart contents before checkout
These customizations run directly on Shopify's infrastructure, ensuring fast performance even during high-traffic events.
Getting Started: Your First Function
Let's walk through creating your first function in Sway Functions Generator:
- Install the App - If you haven't already, install Sway Functions Generator from the Shopify App Store
- Choose Function Type - Select which area of your store you want to customize
- Configure Logic - Set up the conditions and actions for your function
- Test & Deploy - Test your function in a safe environment before going live
Example: Simple Discount Function
Here's how different types of stores might implement a simple discount function:
For Apparel Brands (500+ products)
Function: Tiered Discount
Configuration:
- Spend $100, get 10% off
- Spend $200, get 15% off
- Spend $300, get 20% off
- Apply to all products except "New Arrivals" collection
For Health Supplement Stores (100-200 products)
Function: Bundle Discount
Configuration:
- Buy any 3 products from "Vitamins" collection
- Get 15% off the bundle
- Limit to registered customers only
For Home & Garden Retailers (1000+ products)
Function: Category-based Discount
Configuration:
- Buy any item from "Furniture" collection
- Get 25% off any item from "Decor" collection
- Minimum purchase: $250
For Food & Beverage Brands (50-100 products)
Function: Subscription Discount
Configuration:
- 20% off first order when subscribing
- 15% off all recurring orders
- Apply to all subscription-eligible products
Understanding Function Types
Sway Functions Generator offers multiple function types to address different business needs:
Discount Functions:
- Bundle Discount - Offer discounts when specific product combinations are purchased
- Conditional Discount - Apply discounts based on customer attributes, cart contents, etc.
- Tiered Discount - Provide increasing discounts based on purchase amount
- Buy X Get X Discounted - Classic BOGO-style discounts with flexible configurations
- Mixed Bundle Discount - Create bundles from different product types/collections
Shipping Functions:
- Change Name - Rename shipping options for clarity or branding purposes
- Conditionally Hide Rates - Show/hide shipping options based on cart contents, customer details, etc.
- Reorder Rates - Prioritize certain shipping options based on business rules
Payment Functions:
- Change Name - Customize payment method names for better clarity
- Conditionally Remove Gateways - Hide certain payment options based on order value, customer location, etc.
- Reorder Gateways - Prioritize preferred payment methods for different scenarios
Cart Validation Functions:
- Conditionally Validate Cart - Create rules that prevent checkout unless certain conditions are met
When to Use Different Functions
| Business Challenge | Recommended Function | Example Use Case | |-------------------|---------------------|-----------------| | Increase AOV | Tiered Discount | Encourage customers to spend more to reach next discount tier | | Cross-sell Products | Mixed Bundle Discount | Offer discounts when customers buy from multiple categories | | Promote New Collection | Conditional Discount | Discount new collection items when purchased with bestsellers | | Streamline Checkout | Reorder Payment Gateways | Position most popular payment methods first | | Manage Inventory | Cart Validation | Prevent purchase combinations that create fulfillment challenges | | Optimize Shipping | Conditionally Hide Rates | Hide express shipping for heavy or oversized items |
Next Steps
Now that you understand the basics, you're ready to create your first custom function. Start with a simple use case that addresses a specific business challenge, test thoroughly, and then expand to more complex scenarios.
For more detailed guides on specific function types, check out our other help articles:
- Bundle Discount Strategies for Food & Drink Brands
- Tiered Discounts for Apparel Brands
- Cart Validation Rules for Health Supplement Stores
Ask in our community
Question not answered? Ask us and other customers in the Sway customer community.
Go to community
Contact support
Message our support team privately to discuss anything specific to your organization
Contact support
Ask in our community
Question not answered? Ask us and other customers in the Sway customer community.
Go to community
Contact support
Message our support team privately to discuss anything specific to your organization
Contact support