=== OpenCart Import for Sidcraft Commerce ===
Requires at least: 6.3
Requires PHP: 7.4
Requires Plugins: sidcraft-commerce-for-sidcraft-page-builder
Stable tag: 1.2.0
License: GPLv2 or later

Moves an OpenCart 2.x, 3.x or 4.x store into Sidcraft Commerce.

== Description ==

Needs Sidcraft Commerce 1.5.0 or later.

Store → Import from OpenCart reads the OpenCart database (it never writes to it) and copies:

* Currencies: OpenCart's enabled currencies become the store's extra currencies, with their rates (worked out against the store currency), symbols and decimals.
* Categories, with their hierarchy, descriptions and SEO keywords as slugs.
* Manufacturers as brands (with their logos).
* Products: name, description, SKU (or model), price, stock, enabled/disabled, categories, brand, attributes, weight and dimensions (converted to the store's units), "requires shipping", main image as the featured image and the other images as a gallery under the description.
* Specials and quantity discounts as price rules: the ordinary special becomes the sale price; dated specials, specials for customer groups and quantity discounts become rules that start, end and apply on their own. Specials and discounts that are over are left out.
* Product options (select, radio, checkbox, image, and text/textarea/date/time/file as text) as item options, with their extra prices, price reductions and the stock of choices that track it.
* Downloadable products' files, copied from OpenCart's download folder into the protected downloads folder. Paid orders keep their download links.
* Reward points: each product's points and each customer's balance.
* Customer groups: each group becomes a customer group (Store → Settings → Catalog) and customers get its role.
* Customers as WordPress users. They keep their passwords: OpenCart 4 bcrypt hashes are used as they are; older SHA1/MD5 hashes are accepted once at the next login and replaced with a WordPress hash. An email that already has an account here is linked, and that account's password is left alone.
* Affiliates (3.x/4.x customer affiliates, or 2.x affiliate accounts): tracking code, commission rate, website and payout details. Their orders' commissions come along as owed.
* Coupons: percentage or fixed, free shipping, products and categories, logged-in only, minimum spend, start and end dates, usage limit, uses per customer and times used.
* Orders with items, chosen options, subtotal, shipping, tax, coupon, gift voucher and other totals, addresses, payment and shipping methods and the full status history. Orders keep their OpenCart number when that id is free. No emails are sent and stock is not changed.
* Reviews with star ratings, approved or pending as in OpenCart.
* Languages: with WPML or Polylang set up for the same languages, OpenCart's other languages become translations of the categories, brands and products (names, descriptions and SEO keywords). Translations share the original's price, stock, options and orders.
* Several stores: choose one OpenCart store to import only its categories, products and orders. On a WordPress Multisite network, import each OpenCart store into its own site.

Prices are converted to the store currency at OpenCart's rate when the store currency isn't OpenCart's default (and OpenCart lists it). Orders are kept in the currency the customer paid in, with its exchange rate.

Old links (index.php?route=product/product&product_id=…, route=product/category&path=…, and SEO keyword URLs) redirect permanently to the new pages once this site takes over the old domain.

Running the import again updates what was imported before instead of duplicating it, so you can import, check, and import again just before switching over. Points balances and commission payouts recorded here are kept.

== Connecting ==

Use the values from OpenCart's config.php (DB_HOSTNAME, DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_PREFIX). If this server can't reach the OpenCart database, export it with phpMyAdmin and import the .sql file into a database here; the WordPress database works, since OpenCart's tables have their own prefix. Tick "The OpenCart tables are in the WordPress database" in that case and delete the oc_ tables when you're done.

Images are fetched from the old store's image/ folder: its web address (https://old-store.example.com/image/) or a copy of it on this server. Download files can't be fetched over the web (OpenCart protects them), so copy system/storage/download to this server and enter that folder.

== WP-CLI ==

    wp sidcraft-opencart connect --db-name=opencart --db-user=oc --db-password=secret --images=https://old-store.example.com/image/ --downloads=/path/to/storage/download
    wp sidcraft-opencart status
    wp sidcraft-opencart import [--steps=products,orders] [--store=1] [--no-translations] [--no-update] [--no-gallery] [--batch=50]

== Not imported ==

* Product "points" prices (buying a product with points), per-customer-group reward points, attribute filters, information pages, layouts, modules and each store's own settings (store name, theme, contact details).
* Translations of option and attribute names (translations show the original's; translate them on the product's translation screen).
* Which affiliate commissions were already paid out: OpenCart doesn't record payouts, so imported commissions are owed until you record a payout under Store → Affiliates.

An order paid in a currency OpenCart can't relate to the store currency keeps OpenCart's default currency, with a note of what was charged.

== Filters ==

* sccoc_order_status( $status, $opencart_status_id, $opencart_status_name ) — choose the Sidcraft Commerce status for an OpenCart status (custom statuses are matched by name; unknown ones become On hold).

== Changelog ==

= 1.2.0 =
* New: currencies and their rates; orders kept in the currency the customer paid in; prices converted when the store currency differs from OpenCart's default.
* New: OpenCart's other languages become WPML or Polylang translations of categories, brands and products.
* New: import one OpenCart store at a time (--store), e.g. each into its own Multisite site.
* Fixed: currency symbols stored double-encoded in OpenCart ("Â£") are repaired.
* Needs Sidcraft Commerce 1.5.0.

= 1.1.1 =
* New: coupons keep their "uses per customer" limit (needs Sidcraft Commerce 1.4.1). Imported orders count towards it.

= 1.1.0 =
* New: brands, quantity discounts, dated and customer-group specials, option stock and price reductions, attributes, weight and dimensions, downloads, reward points, customer groups, affiliates and commissions, and coupon rules (free shipping, products, categories, logged-in only, start date). Needs Sidcraft Commerce 1.4.0.

= 1.0.0 =
* First release.
