I'm not sure the posts above are actually answering your questions.
David Bo:
-
I would like to remove all orders older than 3 years from the order history. How do I do that?
-
How can I calculate the present price of a purchased product in some old order with the same attributes settings as it had when the order was purchased?
-
Is it possible to delete a product after it has been bought? If possible doesn't it make the products_id reference in table orders_products obsolete?
-
There is no built-in purge facility in Zen Cart at the present time. If you want to remove old records in large quantities, you'll need to do it manually by direct database access.
The tables related to order history are listed here:
http://www.zen-cart.com/wiki/index.php/Developers_-_Database_Schema#Order_History
-
This is not an easy task, and may actually not be possible after-the-fact, given the current database structure. Your best option for this would be to recreate the order afresh, selecting the specified attributes detailed in the old order's line-item information.
-
Sure, deleting a product from the database can be done quite easily. Granted, as you mentioned, you will be orphaning it from orders, meaning that existing orders won't be able to allow any lookups on the details of the original product.
There are caveats to removing any data from a relational database. Do so at your own risk.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.