Page 1 of 1

Bug in AC705 Edit Addresses page

Posted: Wed May 18, 2011 6:38 am
by AbleMods
When using the Edit Addresses button from the Order Details page in AbleCommerce 7.0.5, there is bug when multiple shipments are involved. If you click Save to store any changes made, all the shipment addresses will get set to the whatever address is shown on the first shipment. This blows away the address details of shipments beyond Shipment #1.

The fix is simple. Edit the /Admin/Orders/EditAddresses.aspx.cs file. Locate the following code:

Code: Select all

    protected void SaveButton_Click(object sender, EventArgs e)
    {
        _Order.BillToFirstName = BillToFirstName.Text;
        _Order.BillToLastName = BillToLastName.Text ;
        _Order.BillToCompany = BillToCompany.Text ;
        _Order.BillToAddress1 = BillToAddress1.Text;
        _Order.BillToAddress2  =BillToAddress2.Text;
        _Order.BillToCity = BillToCity.Text;
        _Order.BillToProvince = BillToProvince.Text;
        _Order.BillToPostalCode = BillToPostalCode.Text;
        _Order.BillToCountryCode = BillToCountryCode.Items[BillToCountryCode.SelectedIndex].Value;
        _Order.BillToPhone = BillToPhone.Text;
        int index = 0;
        foreach (OrderShipment shipment in _Order.Shipments)
        {
            RepeaterItem item = ShipmentRepeater.Items[index];
            shipment.ShipToFirstName = GetControlValue(item, "ShipToFirstName");
            shipment.ShipToLastName = GetControlValue(item, "ShipToLastName");
            shipment.ShipToCompany = GetControlValue(item, "ShipToCompany");
            shipment.ShipToAddress1 = GetControlValue(item, "ShipToAddress1");
            shipment.ShipToAddress2 = GetControlValue(item, "ShipToAddress2");
            shipment.ShipToCity = GetControlValue(item, "ShipToCity");
            shipment.ShipToProvince = GetControlValue(item, "ShipToProvince");
            shipment.ShipToPostalCode = GetControlValue(item, "ShipToPostalCode");
            shipment.ShipToCountryCode = GetControlValue(item, "ShipToCountryCode");
            shipment.ShipToPhone = GetControlValue(item, "ShipToPhone");
        }
        _Order.Save();
        SavedMessage.Text = string.Format(SavedMessage.Text, DateTime.UtcNow.ToLocalTime());
        SavedMessage.Visible = true;
        EditAddressAjax.Update();
    }
And replace it with this code:

Code: Select all

    protected void SaveButton_Click(object sender, EventArgs e)
    {
        _Order.BillToFirstName = BillToFirstName.Text;
        _Order.BillToLastName = BillToLastName.Text ;
        _Order.BillToCompany = BillToCompany.Text ;
        _Order.BillToAddress1 = BillToAddress1.Text;
        _Order.BillToAddress2  =BillToAddress2.Text;
        _Order.BillToCity = BillToCity.Text;
        _Order.BillToProvince = BillToProvince.Text;
        _Order.BillToPostalCode = BillToPostalCode.Text;
        _Order.BillToCountryCode = BillToCountryCode.Items[BillToCountryCode.SelectedIndex].Value;
        _Order.BillToPhone = BillToPhone.Text;
        int index = 0;
        foreach (OrderShipment shipment in _Order.Shipments)
        {
            RepeaterItem item = ShipmentRepeater.Items[index];
            shipment.ShipToFirstName = GetControlValue(item, "ShipToFirstName");
            shipment.ShipToLastName = GetControlValue(item, "ShipToLastName");
            shipment.ShipToCompany = GetControlValue(item, "ShipToCompany");
            shipment.ShipToAddress1 = GetControlValue(item, "ShipToAddress1");
            shipment.ShipToAddress2 = GetControlValue(item, "ShipToAddress2");
            shipment.ShipToCity = GetControlValue(item, "ShipToCity");
            shipment.ShipToProvince = GetControlValue(item, "ShipToProvince");
            shipment.ShipToPostalCode = GetControlValue(item, "ShipToPostalCode");
            shipment.ShipToCountryCode = GetControlValue(item, "ShipToCountryCode");
            shipment.ShipToPhone = GetControlValue(item, "ShipToPhone");
            // BEGIN MOD: AbleMods.com
            // 5/18/2011
            // bug-fix in AC705
            index++;
            // END MOD: AbleMods.com
        }
        _Order.Save();
        SavedMessage.Text = string.Format(SavedMessage.Text, DateTime.UtcNow.ToLocalTime());
        SavedMessage.Visible = true;
        EditAddressAjax.Update();
    }
I checked AC707 and the bug appears fixed in 7.0.7.

Re: Bug in AC705 Edit Addresses page

Posted: Wed May 18, 2011 8:44 am
by mazhar
Yes Joe this was reported to us a while ago and was fixed in 7.0.7. Thanks for providing this patch for old builds.