If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Addon Admin Tools / [support thread] - "edit orders -> detail record copy"

[support thread] - "edit orders -> detail record copy"

Started by carlwhat on 19 Oct 2020, 9:19 PM · Views: 5,938

Results 1 to 20 of 24
19 Oct 2020, 9:19 PM
#1
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #1 by carlwhat

plugin for a plugin!

if you have additional fields added to your orders_products table, and have been frustrated by those fields not being there when adjusting quantities via the Edit Orders plugin, be frustrated no longer!

this is the support thread for a new observer to properly copy all added fields when using edit orders.

this plugin can be downloaded here:

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

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

25 Oct 2020, 4:31 PM
#2
elemi avatar

elemi

Zen Follower

Join Date:
Mar 2006
Location:
Auckland, New Zealand
Posts:
242
Plugin Contributions:
0

Post #2 by elemi

Is this based on the assumption that the "Edit orders" plugin is installed (and working) for 1.5.7?

Sorry, not quite clear in your description :-)

Elemi

The Art of Bespoke Aromatherapy
https://www.AmorAromatherapy.co.nz

25 Oct 2020, 6:32 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #3 by swguy

Only users of the Edit Orders plugin who also have added fields to the orders_products table need this plugin.
If that's not you, you don't need it.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

25 Oct 2020, 10:00 PM
#4
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #4 by carlwhat

Elemi:

Is this based on the assumption that the "Edit orders" plugin is installed (and working) for 1.5.7?

Sorry, not quite clear in your description :-)

what swguy said.

there are any number of us who have modified the orders products table by adding additional fields. if u use edit orders to let’s say adjust the customer quantity from 3 to 4, edit orders will delete the original record and create a new record. this has caused me tremendous frustration with clients over the years and a lot of work. apparently other people have noticed and complained about it.

with the addition of notifiers to the edit orders plugin, i created a little observer that now preserves those additional fields from the deleted record, and copies them to the new record.

unfortunately the notifier does not provide the exact fields it uses for the new record, so if those fields change, this observer will need to change. it’s a minor point but worth noting.

in the interim i think this is a little slick solution to address what has been a very frustrating problem.

thanks to @lat9 for the maintenance of the edit orders plugin and for the addition of the observer events.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

4 Dec 2020, 3:33 PM
#6
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #6 by carlwhat

lat9:

The updated EO notification will be available in EO v4.5.5 (recently submitted) and later: https://www.zen-cart.com/downloads.php?do=file&id=1513

:thumbsup:

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

19 Feb 2021, 11:46 PM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #7 by swguy

Would you please clarify the installation instructions? It says,

Unfortunately, the observers used in edit orders, do NOT give the exact fields updated. So those fields needed to be hard coded in this file. When edit orders changes this file may need to change.

Does this mean I need to add any new fields I have added in the orders_products table to the $updatedFields list?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

20 Feb 2021, 3:18 AM
#8
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #8 by carlwhat

swguy:

Would you please clarify the installation instructions? It says,

Unfortunately, the observers used in edit orders, do NOT give the exact fields updated. So those fields needed to be hard coded in this file. When edit orders changes this file may need to change.

Does this mean I need to add any new fields I have added in the orders_products table to the $updatedFields list?

@swguy, if you are running v4.5.5 of edit orders, there is no need to add any new fields...

as long as your notifier in YOUR_ADMIN/includes/functions/extra_functions/edit_orders_functions.php looks like:

$zco_notifier->notify('EDIT_ORDERS_ADD_PRODUCT', array('order_id' => (int)$order_id, 'orders_products_id' => $order_products_id, 'product' => $product, 'sql_data_array' => $op_sql_data_array));

you are good to go with no need to maintain the $updatedFields array.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

20 Feb 2021, 5:47 AM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #9 by swguy

OK - I didn't realize 4.5.5 was the cutoff - I thought all that was needed was the EDIT_ORDERS_ADD_PRODUCT notifier. I will update EO; thanks for confirming.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

20 Feb 2021, 5:24 PM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #10 by swguy

Does this only work in 1.5.7? In 1.5.6, the class constructor doesn't seem to fire, and the compatibility information for the first version says 1.5.6.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

20 Feb 2021, 5:38 PM
#11
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #11 by swguy

Yeah that was it. The auto stuff for admin side was introduced in 1.5.7.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

20 Feb 2021, 5:56 PM
#12
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #12 by carlwhat

swguy:

Does this only work in 1.5.7? In 1.5.6, the class constructor doesn't seem to fire, and the compatibility information for the first version says 1.5.6.

Yeah that was it. The auto stuff for admin side was introduced in 1.5.7.

@swguy, you have going to have wash your own bottles on this one... (are you not the chief cook and bottle washer?)

ok... good to know...

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

20 Feb 2021, 9:01 PM
#13
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #13 by swguy

It's all good. I have updated the plugin page to note that this is a 1.5.7 mod (not 1.5.6).

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

20 Feb 2021, 11:48 PM
#14
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #14 by carlwhat

swguy:

It's all good. I have updated the plugin page to note that this is a 1.5.7 mod (not 1.5.6).

:thumbsup: thanks.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

21 Feb 2021, 1:11 PM
#15
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #15 by swguy

I updated the documentation on autoloading as well just to clarify this point.

Thanks again for doing this; it was an inspired solution.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

22 Feb 2021, 12:50 AM
#16
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #16 by carlwhat

swguy:

I updated the documentation on autoloading as well just to clarify this point.

Thanks again for doing this; it was an inspired solution.

:smile: too kind. thank you. glad it helps others and not just me.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

10 Aug 2021, 8:57 PM
#17
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #17 by swguy

Small fix needed: includes/classes/observers/auto.editOrdersDetailObserver.php line 75, change

           zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array, $db_action, $db_where);

to

if (!empty($sql_data_array)) {
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array, $db_action, $db_where);
}

This happens if there are no changes to the Orders Products table but you are running this mod.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

10 Aug 2021, 9:28 PM
#18
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #18 by carlwhat

swguy:

Small fix needed: includes/classes/observers/auto.editOrdersDetailObserver.php line 75, change

           zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array, $db_action, $db_where);

to

if (!empty($sql_data_array)) {
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array, $db_action, $db_where);
}

This happens if there are no changes to the Orders Products table but you are running this mod.

hi scott,
when would this possibly happen? have you seen it happen in the wild?

part of the reason i developed this mod, was that even if you did not change anything on the products for an order, EO would still delete the record and recreate it. which frankly, i have never liked that behavior.

does a newer version of EO no longer do that?

i have no problem making this change, but the question for me is whether it is needed.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

10 Aug 2021, 10:18 PM
#19
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #19 by swguy

You can reproduce it easily on a cart that has no changes to the orders_products table just by running edit orders.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

10 Aug 2021, 10:18 PM
#20
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #20 by swguy

Yes, I saw it in the wild - happened because I thought a client had changes to the table but they didn't.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.