Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Gonçalo Assunção 39 posts 68 karma points
    Jan 27, 2015 @ 17:23
    Gonçalo Assunção
    0

    TransactionLibrary.AddToBasket Not Working!

    Hello guys... again..

    So I did a order step by step without any issues in my testing server... When I try to implement it in the production server, the macro that creates and adds the product to the basket crashes with no aparent reason.

     

    Here's the code:


        var request = HttpContext.Current.Request;
       
        var obj_products = from items in Product.All().Where(x => x.ProductDefinition.Name == "productdefinitionName").OrderBy(z => z.Sku)
                           select items;
        Product[] arr_product = obj_products.ToArray();

        var obj_properties = from x in ProductDefinitionField.All().Where(y => y.ProductDefinition.Name == "Subscription")
                             select x;

        ProductDefinitionField[] arr_productProperty = obj_properties.ToArray();

        int num_productArrayLength = arr_product.Length;
        int num_productPropertyArrayLength = arr_productProperty.Length;
        int num_rowCount = 1;
        string str_productName = "";
        string str_prodDefinition = "";
        string str_MonthlyFeeValue = "";
        string str_productId = "";
        string product_Sku = "";
        string str_query = "";
        bool bool_HaveProperty;
        bool bool_hasBasket = true;



        if (request.QueryString["cartcmd"] != null && request.QueryString["cartcmd"].ToString() == "Add")
        {
            str_query = request.QueryString.ToString();
            var parsed = HttpUtility.ParseQueryString(str_query);

             product_Sku = parsed["productID"].ToString();
           
            else
            {
            if (SiteContext.Current.OrderContext.HasBasket)
            {
                bool_hasBasket = false;
            }
            else
            {
                bool_hasBasket = true;
            }
            PurchaseOrder obj_basket = TransactionLibrary.GetBasket(bool_hasBasket).PurchaseOrder;

            obj_basket.OrderLines.Clear();
            obj_basket.Save();

           
            TransactionLibrary.AddToBasket(1, product_Sku, null, true, true);

         
                if (!obj_basket.OrderLines.Any())
                {
                    <p>Cart is empty!</p>
                }

     
       
            //Redirects to the billing details page
            }
           
        }

     

    I only have 2 products without any variants, and they are identical to each other in both servers... pricing (>0,00DKK ), sku, definitions... everything...Same with the product and catalog definitions, and both stores are identical (except the host name...)

    When I press one of them, it redirects to the same page, and sends the product sku through query string, then I get the product sku via the query string, create the basket (if there isn't one created), and add that product to the basket and redirect to the billing details page...

    I have tried the other overload for the addtobasket method, and it still didn't work.

    I can't find the reason for it to work in the dev server but not in the production server...

  • Jesper Nielsen 141 posts 498 karma points
    Jan 28, 2015 @ 10:34
    Jesper Nielsen
    0

    Hello Goncalo,

    Please try and see if you can find any error message. Either in the logs, or perhaps javascript errors.

    One thing that can fail, is if there is already a basket for the user, but with a different currency as the one for the product you try to add.

    The basket is actually a PurchaseOrder (db table uCommerce_PurchaseOrder. If you can find the basket (OrderStatusId = 1), you can check the currency id for it.

    You can clear any exsiting basket by clearing the cookie called "basketid" in the browser.

    Kind regards,
    Jesper

  • Gonçalo Assunção 39 posts 68 karma points
    Jan 28, 2015 @ 12:00
    Gonçalo Assunção
    0

    Hello Jesper!

    I fixed the problem... The problem was that when I uploaded the macros to the production site, the billingcurrency was EUR, and then it was changed to DKK. So I was adding a DKK product to a EUR basket.. Deleted all the cookies, and it worked -.-

    Sorry for all the trouble... Like I said, still learning my way around this "world"

    Best Regards!

  • Jesper Nielsen 141 posts 498 karma points
    Jan 29, 2015 @ 10:14
    Jesper Nielsen
    0

    No problem!

    Glad you got the problem fixed! :-)

    Kind regards,
    Jesper

Please Sign in or register to post replies

Write your reply to:

Draft