Foreign key insert conflicted error 7.0.3

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

Foreign key insert conflicted error 7.0.3

Post by AbleMods » Tue Aug 04, 2009 11:32 am

Sigh I can't find anything today. I swear I saw a fix somewhere for this error, maybe I'm wrong. I've got customers getting this during checkout. Anyone else getting this in 7.0.3 - it's a standard unmodified install.
The INSERT statement conflicted with the FOREIGN KEY constraint "ac_Baskets_ac_BasketItems_FK1". The conflict occurred in database "AbleMods", table "dbo.ac_Baskets", column 'BasketId'
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
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Foreign key insert conflicted error 7.0.3

Post by jmestep » Tue Aug 04, 2009 12:43 pm

Yes, that's a known bug. I was able to patch a couple of sites.
viewtopic.php?f=42&t=11348&hilit=FOREIGN+KEY
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Foreign key insert conflicted error 7.0.3

Post by AbleMods » Tue Aug 04, 2009 1:56 pm

Well apparently you missed mine :P

Thanks a bunch Judy, your memory serves you far better than mine these days. I've made the change, we'll see if that fixes it for me.
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

Ming-Chu
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Mon Feb 28, 2011 9:34 pm

Re: Foreign key insert conflicted error 7.0.3

Post by Ming-Chu » Tue Sep 13, 2011 11:10 pm

Hi all,

My AC version is VERSION: 7.0.7.14481 but my customers have still got this error during checkout.

I check ConLib/OnePageCheckout.ascx.cs, I find the code basket.Package(false, true) as below:

Code: Select all

    private void InitializeBasket()
    {
        Basket basket = Token.Instance.User.Basket;
        basket.Package(false, true);
        foreach (BasketShipment shipment in basket.Shipments)
        {
            shipment.ShipMethodId = 0;
            shipment.Save();
        }
        basket.Recalculate();
        _CurrentBasketHash = basket.GetContentHash(OrderItemType.Product);
    }
And I check ConLib/Basket.ascx.cs, I also find basket.Package(false, false) in Page_PreRender() and GetBasketItems().

Code: Select all

    private BasketItemCollection GetBasketItems()
    {
        User user = Token.Instance.User;
        Basket basket = user.Basket;
        basket.Package(false, false);
        _DisplayedBasketItems = new BasketItemCollection();
       // ignore...
    }

Code: Select all

    protected void Page_PreRender(object sender, EventArgs e)
    {
        //GET ANY MESSAGES FROM SESSION
        List<string> sessionMessages = Session["BasketMessage"] as List<string>;
        //GET THE BASKET AND RECALCULATE
        Basket basket = Token.Instance.User.Basket;
        basket.Package(false, false);
        basket.Recalculate();
        // ignore...
    }
I have compared ConLib/Basket.ascx.cs in Service Release for AC 7.0.3 and my AC 7.0.7.
The different is that AC7.0.3 uses basket.Package() but AC7.0.7 uses basket.Package(false, false).

My error log is as below.
errorlog.JPG
I am not sure what is the solution and how to fix it?

Could anybody help me?

Thank you!!

Post Reply