When editing an order as an administrator the address fields do not get populated when selecting a saved address. The onchange method of <select id="edit-addresses"> is set to: apply_address('delivery', this.value); whereas the checkout page uses uc_addresses_apply_address(). If apply_address('delivery' is changed to apply_address('delivery-delivery' then it works, this is the same with 'billing'. This is because the field ids for the address are of the format: edit-delivery-delivery-first-name. If apply_address('delivery' is changed to uc_addresses_apply_address('delivery' then that also works. What is the appropriate solution for this or is there a patch available that will fix this issue?
Comments
Comment #1
megachrizHm, I can't reproduce this error on my local system. On my local system the address selector already calls
uc_addresses_apply_address('delivery', this.value);on the "onchange" event.Maybe flush caches will solve the problem?
Else, there could be a conflict with an other module. Does the error also occur on a fresh Ubercart install with only the modules enabled that Ubercart Addresses need to function? Which Ubercart version do you have installed?
Comment #2
PlanetPHP commentedI am running Ubercart 6.x-2.9 on drupal 6.25 and have flushed the cache many times. I had been using version 6.x-1.0 of Ubercart Addresses before upgrading to 6.x-2.9. I just tried it on a fresh install of drupal/ubercart with minimum modules and this time
uc_addresses_apply_address()is being called, but the function is undefined asuc_addresses.jsis not included. The edit form is correct this time with the single delivery/billing instead of the format like:edit-delivery-delivery-first-name, so it seems it would work if the js was included.I have uninstalled the uc_addresses module and reinstalled again, flushed caches and still no change. The drupal version is 6.26.
Any ideas why this may be? I used fresh downloads of drupal/ubercart and modules for this test. I placed uc_addresses in sites/all/modules/ubercart/uc_addresses. So to clarify, the location for uc_addresses.js is sites/all/modules/ubercart/uc_addresses/uc_addresses.js. I am getting no 404s in the inspector. Just the error
Uncaught ReferenceError: uc_addresses_apply_address is not definedComment #3
megachrizI'm on Ubercart 6.x-2.9 too. I saw my test environment is still on Drupal 6.22, but I doubt this error is caused by minor changes in Drupal. I will check this out later.
So, you now have actually two issues. The first one is that the address selector tries to call
apply_address()instead ofuc_addresses_apply_address(). The second issue is that uc_addresses.js doesn't get included.1.
apply_address()instead ofuc_addresses_apply_address()This can be caused by an other module that alters the same form as Ubercart Addresses.
apply_address()is the original function supplied by Ubercart, but Ubercart Addresses usesuc_addresses_apply_address()in order to support extra address fields. (E.g. for Extra Fields Pane).Ubercart Addresses alters the form
uc_order_address_book_formto put inuc_addresses_apply_address(). Seeuc_addresses_form_uc_order_address_book_form_alter()in uc_addresses.module (± line 1009) anduc_addresses_select_address()(± line 1121). It's possible an other module undoes this change by altering the same form. You can search for the string "uc_order_address_book_form" in the modules you use and see if one of them is in a form alter function.An other possibility is that the customer had no addresses in his/her address book, although the functionality should also work with addresses coming from previous orders, but I haven't tested this much yet.
2. No uc_addresses.js
I've no idea yet how this is caused and why you don't encounter the same issue in your other installation. But it's clear to me some Ubercart Addresses code isn't called, as the module registers uc_addresses.js to load in the function
uc_addresses_order_pane_address()in uc_addresses.ubercart.inc (on ± line 238).As you also stated the edit form uses single delivery/billing id's (yeah, it should be double ones with Ubercart Addresses turned on), it looks like that somehow the original Ubercart order panes are used instead of Ubercart Addresses ones. Ubercart Addresses alters callback functions of the "ship_to" and "bill_to" order panes in
uc_addresses_order_pane_alter()(± line 610 in uc_addresses.module). The callbacks are defined in uc_addresses.ubercart.inc (from ± line 204).Before Ubercart 6.x-2.6, order panes couldn't be altered the way Ubercart Addresses does that, but since you are on Ubercart 6.x-2.9 this should work.
I'm curious how the two noted problems can happen. Hopefully, you want to dig a little deeper in the code to find the cause of the problem. Feel free to ask if you have any questions about specific Ubercart Addresses code.
Comment #4
PlanetPHP commentedWell MegaChriz, it appears you picked the right username, you are in fact mega! I searched for 'uc_order_address_book_form' and found some code that I had used to fix the older version. When I disabled the module that contained the code everything worked as it should. However the basic clean version I setup to test never had the address fix module enabled (issue 2) as it was a minimal setup and so I do not know why uc_addresses.js wasn't being included. I will try to see why uc_addresses.js wasn't being loaded in the basic installation but as everything is now working for me in the scenario I needed it to and need to get the project finished ASAP, I may not be able to figure it out for a while. Thanks for your help in locating the problem, very much appreciated :)
Comment #5
megachrizThanks for your compliments and I'm glad you were able to resolve your issue. :) Thank you also for providing clear information about your issue, without that it would have been harder for me to locate the problem.
I've updated my 6.x test environment to Drupal 6.26 now and I still can't reproduce your second issue (no uc_addresses.js included). Are you sure you had Ubercart 6.x-2.9 installed? I once had a situation where I thought I had updated a module (by moving the module's folder to sites/all/modules/contrib), but Drupal still loaded the older version. After some investigation why this happened, I discovered I previously had accidently moved the module's folder into the folder of an other module, causing Drupal to take that one and ignoring the second (newer) module instance.
Anyway, your original issue had been fixed now, so I'm marking this issue as fixed.
Comment #6.0
(not verified) commentedformatted, adding code tags