Hi,

I added som field to my billing pane and now everytime on checkout I get notices like this for every extra field:
Notice: Undefined index: delivery_ucxf_dic v uc_addresses_checkout_pane_address() (line 218 in uc_addresses.ubercart.inc).

Could you please look into this?

Thanks.

Comments

megachriz’s picture

I tried to reproduce the error. At first, nothing seem to be wrong and I nearly decided to ask you more about your setup. But then, after playing with the settings, and knowing from issue #1843562: Support checkbox "My billing information is the same as my delivery information." checked by default you probably have the "Use the same address" checkout setting enabled, I got the error too when I disabled an extra field that would only appear in the delivery pane.

I followed these steps:

  1. On the checkout settings, I enabled "Use the same address for billing and delivery by default." (admin/store/settings/checkout).
  2. I created a text field to appear only in the delivery pane.
  3. I created a few other extra fields too (appearing in both panes).
  4. I disabled the delivery only field on the "Address Fields" page (admin/store/settings/countries/fields).
  5. I added a product to the cart and went to checkout (cart/checkout). The billing pane was already collapsed.
  6. I choose an existing address for the delivery pane.
  7. I clicked on the "Review order" button at the bottom of the page.
  8. The "Review order" page get loaded (cart/checkout/review) and the "Undefined index" error was displayed, stating the extra field that I had disabled.

In my case I only got the error once, and only for the disabled extra field. You say you got the error for every extra field. Are the steps you took in your setup similar to mine?

Neo13’s picture

Yes my setup is similar but I use extra fields just in billing pane and this pane is hidden by default with setting "Use the same address for billing and delivery by default." All fields are enabled.

megachriz’s picture

Project: Extra Fields Checkout Pane » Ubercart Addresses
Assigned: Unassigned » megachriz

I have found the bug. There are actually two bugs. And they are both in Ubercart Addresses. It has nothing to do with if the field is enabled or disabled.

When "My billing information is the same" is checked, Ubercart Addresses copies over values from the delivery pane to the billing pane. It's doing this by looping through all billing fields.

Bug 1: When determining the name of the delivery field, it just replaces "billing" with "delivery", so if your field is called ucxf_billing_only - which will become billing_ucxf_billing_only at checkout - it tries to copy values over from a field called delivery_ucxf_delivery_only. This should have been delivery_ucxf_billing_only, it should not replace the second "billing" word with "delivery".

Bug 2: It doesn't check if the field exists in the delivery pane and this results into the notice you get. Ubercart Addresses doesn't have a feature/setting to put fields in one pane only, but Extra Fields Pane has.

I'm working on a fix and move this over to the Ubercart Addresses issue queue.

megachriz’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new1.08 KB

I think this fixes the bug, but to prevent from the bug to reappear, it could use an automated test.

Neo13’s picture

Status: Needs review » Reviewed & tested by the community

I tested provided patch and it seems to solve the problem. I did not notice any side effects. Thank you!

megachriz’s picture

Status: Reviewed & tested by the community » Needs work

I see I made a mistake in this line:
+ $source_fieldname = 'delivery_' . $fieldname;'delivery' is hard-coded there, but if the billing pane comes first, then this won't work. Setting the status to "needs work" for me.

Anyway, thanks for testing so far.

megachriz’s picture

Status: Needs work » Fixed

Phoe! I had to change a lot of code in order to write a test for this bug fix.

I finally made three commits:

  1. First, a commit for the fix.
  2. Second, the move of the UcAddressesTextFieldHandler from the example module to the main module. This was done in order to prepare the module code for the upcoming test. See commit.
  3. And third, the automated test and some other small changes in the module code. See commit.
Neo13’s picture

Great work MegaChriz!

Automatically closed -- issue fixed for 2 weeks with no activity.