Picture a Plus store that has been running the same four Ruby scripts since 2019. One gives trade customers a flat percentage off two collections. One hides cash on delivery once the cart goes over a certain value. One renames the shipping rates so "Standard" reads "2 to 4 working days". The fourth removes express shipping for a list of postcodes that nobody has reviewed in years.
Then the Script Editor app goes away, and nobody left on the team wrote the Ruby.
That is the normal version of this project. The code is small. The business rules inside it are written down nowhere else. The person who asked for rule number four left two finance managers ago. So before anyone opens a terminal, the real first task is reading those scripts line by line and turning them into sentences a non-developer can confirm or reject.
What actually changes
Scripts were a text box in the admin. You pasted Ruby, hit save, and checkout behaved differently. Functions are not that. A Function is WebAssembly, written in Rust or JavaScript, packaged inside a Shopify app and deployed with the Shopify CLI. Even if the app is private to one store and will never be listed anywhere, you still need a Partner organisation, an app, and someone who owns the deploy.
That shift catches finance and operations teams by surprise more than the code does. The question "who can change the discount rule on Friday afternoon" now has a different answer. Our advice is to design for that from the start: push every number, threshold, country list and collection ID out of the code and into configuration, so the rule can be edited in the admin without a developer and a deploy.
In practice that means metafields on the discount or the app, or a settings screen in the app itself. A function that hardcodes "15" and "SE, NO, DK" is a function you will be paid to edit four times a year. We would rather build the boring configuration layer once.
Two other constraints matter. Functions have no network access, so you cannot call your ERP or a pricing API while the shopper is at checkout. Anything the rule depends on has to already be on the cart, the customer, the product or a metafield. And Shopify caps how long a function may run and how large its input may be, which is why the run.graphql input query should request only the fields you genuinely use.
Mapping each old script to the right Function
Scripts came in three flavours. Functions come in more, and the mapping is not one to one.
- Line item scripts that changed prices become product discount or order discount functions. The function calculates the discount, but it only runs if a discount exists in the admin to attach it to. So part of the migration is creating automatic discounts or discount codes under Discounts that point at your app's function.
- Shipping scripts that discounted a rate become shipping discount functions.
- Shipping scripts that hid, renamed or reordered rates become a delivery customization, set up under Settings → Shipping and delivery. Different API, different mental model: you are filtering and relabelling the rates Shopify already returned, not pricing them.
- Payment scripts become a payment customization under Settings → Payments, which is where you hide cash on delivery over a threshold or push a method to the bottom of the list.
- Clever scripts that blocked checkout have no discount equivalent at all. Those go to a cart and checkout validation function, which returns errors instead of prices.
Delivery and payment customizations are Plus features, and discount functions are available more widely, so check your plan before promising the operations team their payment rule survives.
The thing that bites hardest in step 1 is discount stacking. Old scripts could pile discounts on top of each other however the Ruby felt like it. Functions respect Shopify's discount classes and the Combinations settings on each discount, which means a store that used to apply a trade discount and a campaign code together may suddenly apply only one. We always rebuild the five or six worst-case carts by hand and compare the old totals against the new ones before cutover. Spreadsheet, two columns, no cleverness.
We also prefer one function per rule over one function that does everything. It is slightly more work to deploy and much easier to turn a single rule off at 9am when sales disagree with it.
Testing when there is nothing to run in parallel
You cannot run Scripts and Functions side by side on the same live checkout and compare. So the testing has to happen somewhere else.
What usually works: a development store with a copy of the relevant products, a few customers carrying the same tags and metafields as production, and the Bogus payment gateway. Run shopify app dev against it, place real test orders through checkout, not just draft orders, because draft orders do not exercise delivery and payment customizations the way a shopper does. The CLI can also execute a function against a saved input JSON file, which is how you cover the edge cases that are painful to reproduce by hand: empty cart, one item over the threshold, mixed currencies, a customer with no tags.
Keep those input files in the repository. They become your regression tests the next time someone changes the trade percentage.
On the day of the switch, watch the first batch of orders individually. Check the discount allocation on each line, the shipping method name that actually got saved, and the payment method used. Problems here are rarely dramatic. They look like a rounding difference of a few cents, or an express rate that is still visible in one region because a country code was written in the wrong case.
Where your back office comes into it
If Shopify orders flow into Odoo, this migration changes the shape of the data arriving at your accounting. Scripts often rewrote the unit price directly. Functions apply discount allocations on top of the original price. Both can end up looking fine in the Shopify admin and quite different in Sales → Orders in Odoo, where you may see a discount percentage on the line, a separate negative discount line, or a total that no longer matches the invoice your customer received.
So we test the integration, not just the checkout. Place three orders with different discount shapes, let them sync, then open the resulting sales order and the customer invoice and confirm the net amounts and tax base line up. Discounts move the taxable amount, and the treatment of discounts for tax purposes differs by country and changes over time, so get your accountant or your local tax authority to confirm the treatment rather than trusting what the connector happens to do.
That whole area, custom Shopify apps with checkout rules in Functions plus the sync into Odoo, is what we do on /services/shopify-development/. The wider list of what we build sits on /services/, and ready-made modules are on /odoo-apps/.
Questions we get asked
Can we keep the rules in the admin instead of in code?
Partly. Simple percentage and threshold discounts can often be rebuilt with native automatic discounts and no function at all, and we always check that first. Anything conditional on customer tags, B2B company location, product metafields or combinations of carts needs a function.
How long does a migration like this take?
The code is usually days, not weeks. The time goes into agreeing what the rules should be now, because teams rarely want an exact copy of a script written seven years ago, and into testing the order flow end to end.
Do we need a Shopify app published in the App Store?
No. A custom app installed on your store only is normal for this. You do need a Partner organisation and a way to deploy it.
Talk to us
If you are sitting on old Scripts and are not sure what they even do any more, send us what you have and we will read them and tell you what maps to what. You can request a quote or just contact us with a question. We work remotely with teams in any country and handle the Shopify side and the Odoo side together.
