lat9 / edit_orders

Edit Orders: Updates for continued operation on Zen Cart v1.5.8 and later
GNU General Public License v2.0
5 stars 9 forks source link

Restructure to reduce removal/inserts of orders_products records #59

Open lat9 opened 6 years ago

lat9 commented 6 years ago

The current EO processing removes and reinserts all orders_products and orders_products_attributes records on an order update. This can cause grief to stores that include modifications to those tables by other order-related plugins.

In the next major version, restructure to reuse existing records, where possible, while keeping existing functionality for plugins that are using the EDIT_ORDERS_ADD_PRODUCT and/or EDIT_ORDERS_REMOVE_PRODUCT notifications.

lat9 commented 5 years ago

As identified in this Zen Cart support-thread posting, the removal/reinsertion processing has the unwanted side-effect of enabling products that were disabled on entry.

scottcwilson commented 4 years ago

Is there anything I can do to help move this issue forward? It's a major pain point for customers who use Dropshipping (which adds fields to orders_products that are lost during editing).

scottcwilson commented 4 years ago

If no changes have been made to the list of products in an order, it would be great if OPC could skip the step of deleting and re-adding the rows in the orders_products table. The reason is, some mods (such as dropshipping) add data to those records which is not easily recreated.

lat9 commented 4 years ago

I know. The thing is that this is going to require a major structural change to EO and I'll need time to (a) formulate the approach, keeping backward compatibility and (b) code, code, code.

scottcwilson commented 4 years ago

:( rats - I thought I had come up with a shortcut.

proseLA commented 3 years ago

@lat9

i have come up with a "simple" solution that is available here:

https://www.zen-cart.com/downloads.php?do=file&id=2292

i think it would be better if the EDIT_ORDERS_ADD_PRODUCT notifier had the actual field names being updated as opposed to/in addition to the $product object. in that way, the observer would not need to get updated if there was some sort of change to the fields in this plugin.

lat9 commented 5 days ago

Noting that EO v5.0.0 will be released as an "encapsulated" plugin for zc200 and later (fully supported by zc210). For zc20x installations, the following base ZC PRs will be required for proper operation:

/ajax.php

This file, updated in releases following Zen Cart 2.0.0 via this PR enables an encapsulated plugin to provide additional AJAX handlers. An additional PR corrects a potential PHP error. If your site runs on Zen Cart 2.0.0, you can safely replace the file with its updated version.

/includes/classes/PluginSupport/ScriptedInstaller.php

This file, updated in the release following Zen Cart 2.0.1 via this PR correctly supplies an encapsulated plugin its currently-installed version on any upgrade. While not required for the initial version of EO's encapsulated version, it'll be required for any future upgrade. You can safely replace the file with its changed version.

Enable order-total/shipping/payment modules to be encapsulated PR 6682

All seven files 'touched' by this PR can be safely replaced with the changes in this PR:

  1. admin/modules.php
  2. includes/classes/ResourceLoaders/ArraysLanguageLoader.php
  3. includes/classes/ResourceLoaders/LanguageLoader.php
  4. includes/classes/ResourceLoaders/ModuleFinder.php (added via this PR)
  5. includes/classes/order_total.php
  6. includes/classes/payment.php
  7. includes/classes/shipping.php