Shopware Tricks

From etlam.eu Tech Wiki
Revision as of 14:31, 18 November 2024 by Malte (talk | contribs) (Created page with "'''DISCLAMER: these "tricks" are provided "as is", without warranty of any kind. These may break your shop, test them thoroughly before using them. You have been warned.''' Unless noted otherwise, everything applies to or has been tested on Shopware 6.6 === Move orders to a different account === This query moves all orders made by a (guest) user to a different user. Replace <TARGET CUSTOMER ID> with the customer number of the target account. Replace <GUEST CUSTOMER ID...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

DISCLAMER: these "tricks" are provided "as is", without warranty of any kind. These may break your shop, test them thoroughly before using them. You have been warned.

Unless noted otherwise, everything applies to or has been tested on Shopware 6.6

Move orders to a different account

This query moves all orders made by a (guest) user to a different user.

Replace <TARGET CUSTOMER ID> with the customer number of the target account. Replace <GUEST CUSTOMER ID> with the customer number of the guest account.

UPDATE `order_customer`
SET `customer_id` = (SELECT `id` FROM `customer` WHERE `customer_number` = '<TARGET CUSTOMER ID>' ORDER BY `id` DESC LIMIT 1), , `customer_number` = '<TARGET CUSTOMER ID>'
WHERE `order_customer`.`customer_id` = (SELECT `id` FROM `customer` WHERE `customer_number` = '<GUEST CUSTOMER ID>' ORDER BY `id` DESC LIMIT 1);

If you only want to move one order, this query does the trick. Replace <TARGET CUSTOMER ID> with the customer number of the target account. Replace <ORDER ID> with the order number.

UPDATE `order_customer`
SET `customer_id` = (SELECT `id` FROM `customer` WHERE `customer_number` = '<TARGET CUSTOMER ID>' ORDER BY `id` DESC LIMIT 1), `customer_number` = '<TARGET CUSTOMER ID>'
WHERE `order_customer`.`order_id` = (SELECT `id` FROM `order` WHERE `order_number` = '10016' ORDER BY `<ORDER ID>` DESC LIMIT 1);