An OpenCart to Shopify migration cannot copy options across as variants. OpenCart keeps a price change and a stock count on each option value, with no record of a combination. Shopify sells variants, each with an absolute price and its own stock. So you multiply the values out, add the modifiers, and count the stock again.
Everything about OpenCart below was read from the 3.0.5.1 source and the demo data that ships with it. The Shopify side is Admin GraphQL API version 2026-10. We ran the code against that demo data loaded into SQLite, not against a live OpenCart, MySQL or a Shopify store.
Shopify’s migration guide has pages for WooCommerce, Wix, Squarespace and other platforms. OpenCart was not among them when we read it on 2 December 2026, so the choice is a migration app or the database and the Admin API.
What does OpenCart store for an option?
An option is spread over three tables. oc_option holds the option and its type. oc_product_option attaches an option to a product and says whether it is required. oc_product_option_value has one row per value on that product, with quantity, subtract, price and price_prefix.
No row joins two values. There is no record of Small in Red, and sku is a column on oc_product only, so in a stock install an option value has no SKU of its own.
The price is worked out in the cart. system/library/cart/cart.php loops over the chosen values, adding price when the prefix is + and subtracting it when the prefix is -. It then takes the product’s base price, swaps in a special for the customer’s group if one is active, and returns that plus the option total. The special does not scale the modifier: a +10 value costs 10 more at the sale price too.
select and radio options take one value. checkbox takes any number, and each ticked value adds its own modifier. text, textarea, file, date, time and datetime carry whatever the shopper entered, with no value rows and no price.
This query exports the value rows:
SELECT pov.product_id, od.name AS option_name, o.type, po.required,
ovd.name AS value_name, pov.quantity, pov.subtract,
pov.price, pov.price_prefix
FROM oc_product_option_value pov
JOIN oc_product_option po ON po.product_option_id = pov.product_option_id
JOIN oc_option o ON o.option_id = pov.option_id
JOIN oc_option_description od
ON od.option_id = pov.option_id AND od.language_id = 1
JOIN oc_option_value ov ON ov.option_value_id = pov.option_value_id
JOIN oc_option_value_description ovd
ON ovd.option_value_id = pov.option_value_id AND ovd.language_id = 1
ORDER BY pov.product_id, o.sort_order, ov.sort_order;
Change the oc_ prefix and language_id to match your store. The typed options never appear in the result, so list those from oc_product_option. Names are stored with HTML entities (the demo product is Apple Cinema 30"), so decode them before they reach Shopify.
How do OpenCart options become Shopify variants?
Each select or radio option becomes a Shopify option, and every combination of their values becomes a variant. The variant’s price is the special, or the base price when there is none, plus that combination’s modifiers. With a special in play, base plus modifiers goes in compareAtPrice.
// opencart-variants.mjs (Node 22 or later)
// product: { title, handle, price, special, quantity, subtract } for one oc_product row.
// rows: the export above, filtered to the same product_id.
const AXIS_TYPES = new Set(['select', 'radio']);
const units = (n) => Math.round(Number(n) * 10000); // OpenCart stores decimal(15,4)
const money = (u) => (u / 10000).toFixed(2);
// cart.php adds on '+', subtracts on '-' and ignores any other prefix.
const delta = (row) =>
row.price_prefix === '+' ? units(row.price) : row.price_prefix === '-' ? -units(row.price) : 0;
export function toProductSet(product, rows) {
const axes = [];
const notVariants = [];
for (const [name, values] of Map.groupBy(rows, (row) => row.option_name)) {
if (AXIS_TYPES.has(values[0].type)) axes.push({ name, values });
else notVariants.push({ name, type: values[0].type, priced: values.some((v) => delta(v) !== 0) });
}
if (axes.length === 0) throw new Error(`${product.handle}: no select or radio options`);
if (axes.length > 3) throw new Error(`${product.handle}: ${axes.length} select or radio options, Shopify allows 3`);
const combos = axes.reduce((acc, axis) => acc.flatMap((c) => axis.values.map((v) => [...c, v])), [[]]);
if (combos.length > 2048) throw new Error(`${product.handle}: ${combos.length} variants, limit is 2048`);
const ceilings = [];
const variants = combos.map((combo) => {
const extra = combo.reduce((sum, row) => sum + delta(row), 0);
const limits = combo.filter((row) => Number(row.subtract)).map((row) => Number(row.quantity));
if (Number(product.subtract)) limits.push(Number(product.quantity));
ceilings.push({
variant: combo.map((row) => row.value_name).join(' / '),
atMost: limits.length ? Math.min(...limits) : null,
});
const variant = {
optionValues: combo.map((row) => ({ optionName: row.option_name, name: row.value_name })),
price: money(units(product.special ?? product.price) + extra),
};
if (product.special != null) variant.compareAtPrice = money(units(product.price) + extra);
return variant;
});
const input = {
title: product.title,
handle: product.handle,
status: 'DRAFT',
productOptions: axes.map(({ name, values }, index) => ({
name,
position: index + 1,
values: values.map((v) => ({ name: v.value_name })),
})),
variants,
};
return { input, ceilings, notVariants };
}
The function returns input for productSet and two lists for you, ceilings and notVariants. For demo product 42 (base price 100, a special of 90, quantity 990) it built 12 variants, and a short runner printed the first four:
Small / Red 104.00 (was 114.00) at most 92
Small / Blue 103.00 (was 113.00) at most 96
Small / Green 101.00 (was 111.00) at most 96
Small / Yellow 102.00 (was 112.00) at most 96
Small in Red is 90 + 10 + 4. Shopify’s reference caps productOptions at three per product and, by default, a product at 2,048 variants. The function throws before either limit. Our post on the three-option limit covers where a fourth can go.
Send the input with a mutation like this:
mutation ImportProduct($input: ProductSetInput!) {
productSet(synchronous: true, input: $input) {
product {
id
handle
variantsCount {
count
}
}
userErrors {
code
field
message
}
}
}
variants is a list field, and productSet deletes existing entries that are missing from a list, so send every variant every time. DRAFT is the status the schema describes as unavailable to customers on sales channels, so use it until the stock is right.
Which options should not become variants?
The function sets these aside in notVariants.
A checkbox option is a set of independent yes-or-no choices. Four checkboxes allow up to 16 combinations by themselves, and as variants they could turn the demo product’s 12 into 192. If no value changes the price, collect the answer as a line item property. If one does (priced: true), a property cannot hold it: the Liquid reference describes a property as a name and value pair, with no price in it. That value has to become an option of its own or a separate add-on product.
Text, textarea, date and time options map to properties, and our line item properties guide has the theme side. We have not checked what a file option needs.
An optional select needs a decision too. In OpenCart a select that is not required can be left empty, and no modifier is added. Shopify describes a variant as a specific combination of option values, so give the option a value such as “None” with no modifier. The function does not do that for you; the export carries required so you can.
What stock can you carry across?
Only a ceiling for each variant, unless the product has a single option. When an order is placed, catalog/model/checkout/order.php takes the ordered quantity off oc_product.quantity and off each chosen value’s quantity, wherever subtract is 1. One Small in Red lowers the product, Small and Red by one each. Nothing records how many Small in Red are left.
The ceiling is the smallest tracked quantity among the variant’s values and the product. On the demo product the twelve ceilings add up to 1,802 against a product quantity of 990. Small has 96 units, and its four variants claim 380 between them.
With a single select or radio option and subtract set, each value is a variant and its quantity is that variant’s stock. Send it in inventoryQuantities with a locationId, the name available and the quantity.
With two or more, somebody has to count. Do not import the ceilings as stock. inventoryPolicy defaults to DENY, which stops sales only when Shopify’s number reaches zero, so a variant counted too high keeps selling after the shelf is empty.
What is different in OpenCart 4?
We read 4.1.0.4 as well. The option tables and the prefix rule in cart.php are unchanged. Specials are not. The product_special table is gone from the 4.1.0.4 schema, and product_discount has gained a special flag and a type. Type F is a fixed price with the option total added on top, as in 3.x. Type P takes a percentage off the base price plus the option total, and S subtracts an amount.
So on a 4.x store a percentage discount changes what each modifier is worth, and the function above gets those prices wrong. 4.x also has variant products, rows in oc_product with a master_id, which this post does not cover.
What happens to the old product URLs?
OpenCart product URLs come in two shapes. With SEO URLs off, a product is index.php?route=product/product&product_id=42. With them on, startup/seo_url.php builds a path from keywords in oc_seo_url, the category keywords and then the product’s. In the demo data, product 42 has the keyword test and its category has desktops, which gives /desktops/test. Reading the decoder, the product keyword resolves alone as well, so /test loads the same product. Expect more than one old path per product.
Keyword paths go into an ordinary redirect map to /products/<handle>. The index.php?route= form is harder. Shopify’s URL redirect help page, as we read it on 2 December 2026, warns that redirects from URLs with query strings may not behave as expected. Try a few on the new store before cutover, and have a rule ready at your CDN in case they fail. Our migration SEO checklist has a script that tests every row of the map.
What order would we run an OpenCart to Shopify migration in?
We would start with the options, before anyone quotes a date. Run the export and the function across the whole catalogue and keep three lists: products that threw on a fourth option, products with a priced checkbox, and products with two or more stock-tracked options. Each of those needs a decision or a stock count from the merchant, so they are the part of the job a script cannot finish.
Then import as drafts, count, set stock, and build the redirect map from oc_seo_url while the old site is still up.
We would skip all of this for a catalogue where no product has more than one option and no checkbox carries a price. The value rows map one to one there, and a plain product import is enough.
We move stores onto Shopify with their products, customers and URLs carried across and redirects in place. That work is part of our Shopify development services.