Bug in AC705 Edit Addresses page

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Bug in AC705 Edit Addresses page

Post by AbleMods » Wed May 18, 2011 6:38 am

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.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Bug in AC705 Edit Addresses page

Post by mazhar » Wed May 18, 2011 8:44 am

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.

Post Reply