Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 7 of 7

Thread: Shipping Options Drop Down Box

  1. #1
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default Shipping Options Drop Down Box

    Can we change the shipping options on checkout1 to a drop down box?

    Just to make it easier for our customer to select an option.
    Would it be possible? If so how?

    Thanks in advance.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  2. #2
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    Yes, it is totally possible. If you have a source code, all it takes is a little tweaking on the AspDotNetStorefrontCore.ShoppingCart.GetShippingMe thodList method...

  3. #3
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    We have the source code, how hard would the modification be? If we could change the shipping options it would really enhance our shopping cart.

    Thanks!
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  4. #4
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    Personally, it's not so hard at all. You'll only need to change the HTML radio input type to a HTML select control and that's it...

  5. #5
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    I assume this the code I want to be changing.
    C#/VB.NET Code:
    tmpS.Append("<input type=\"radio\" value=\"" strValue "\" name=\"ShippingMethodID_" AddressID "\" id=\"FreeShippingMethodID_" AddressID "\" checked>");
                                        
    tmpS.Append(AppLogic.GetString("shoppingcart.cs.104"m_SkinIDm_ThisCustomer.LocaleSetting)); 
    However I can not think of a clear cut way to get this into a drop down list.
    Any ideas?
    I don't want to break the current system.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  6. #6
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    Well, not just that. Here's a sample code, but you should take care of the rest. This could be a good start though. First, you'll need to add this AppConfig:

    Parameter: ShippingMethodListControl
    Value: radio or select

    Then modify the AspDotNetStorefrontCore.ShoppingCart.GetShippingMe thodList (add the highlighted parts):
    Code:
                if (FreeShippingReason == Shipping.FreeShippingReasonEnum.AllDownloadItems || FreeShippingReason == Shipping.FreeShippingReasonEnum.AllOrdersHaveFreeShipping)
                {
                        switch(AppLogic.AppConfig("ShippingMethodListControl"))
                        {
                            case "radio":
                                tmpS.Append(string.Format("<input type=\"radio\" name=\"ShippingMethodID{0}\" id=\"ShippingMethodID{0}0\" value=\"0\" checked > " + String.Format(AppLogic.GetString("shoppingcart.cs.105", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), GetFreeShippingReason()) + "<br />", FieldSuffix));
                                break;
                            case "select":
                                tmpS.Append(string.Format("<select name=\"ShippingMethodID{0}\" id=\"ShippingMethodID{0}0\"> <option value=\"0\" selected /> " + String.Format(AppLogic.GetString("shoppingcart.cs.105", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), GetFreeShippingReason()) + "<br />", FieldSuffix)+ "</select>");
                                break;
                        }
                    AnyShippingMethodsFound = true;
                }
    For a sample, I'll use the Calculate Shipping By Weight for a start, under its case (pertaining to the SWITCH CASE):

    Code:
    using (rs)
                                {
                                    switch (AppLogic.AppConfig("ShippingMethodListControl"))
                                    {
                                        case "select":
                                            tmpS.Append("<select name=\"ShippingMethodList\">");
                                           while (rs.Read())
                                            {
                                                int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                                                AnyShippingMethodsFound = true;
                                                if (ShippingIsFree && Shipping.ShippingMethodIsInFreeList(ThisID))
                                                {
                                                    tmpS.Append("<option value=\"" + ThisID.ToString() + "\" " + CommonLogic.IIF((FirstItem().m_ShippingMethodID == ThisID), " selected ", "") + "/>");
                                                    tmpS.Append("&nbsp;");
                                                    tmpS.Append(DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting));
                                                    tmpS.Append("&nbsp;");
                                                    tmpS.Append(String.Format("({0})", AppLogic.GetString("shoppingcart.aspx.16", SkinID, ThisCustomer.LocaleSetting)));
                                                }
                                                else
                                                {
                                                    Decimal ThisShipCost = Shipping.GetShipByWeightCharge(ThisID, WeightTotal());
    
                                                    if (AppLogic.AppConfigBool("ApplyShippingHandlingExtraFeeToFreeShipping"))
                                                    {
                                                        if (ExtraFee != System.Decimal.Zero && m_ShipCalcID != Shipping.ShippingCalculationEnum.UseRealTimeRates)
                                                        {
                                                            ThisShipCost += ExtraFee;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (ExtraFee != System.Decimal.Zero && m_ShipCalcID != Shipping.ShippingCalculationEnum.UseRealTimeRates && ThisShipCost != System.Decimal.Zero)
                                                        {
                                                            ThisShipCost += ExtraFee;
                                                        }
                                                    }
    
                                                    if (m_VATOn)
                                                    {
                                                        ThisShipCost += Decimal.Round(ThisShipCost * ShippingTaxRate, 2, MidpointRounding.AwayFromZero);
                                                    }
    
                                                    if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                                    {
                                                        tmpS.Append("<option value=\"" + ThisID.ToString() + "\" " + CommonLogic.IIF((FirstItem().m_ShippingMethodID == ThisID), " selected ", "") + "/>");
                                                        tmpS.Append("&nbsp;");
                                                        tmpS.Append(DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting));
                                                        tmpS.Append("&nbsp;");
                                                        tmpS.Append(String.Format("({0})", m_ThisCustomer.CurrencyString(ThisShipCost)));
                                                    }
    
                                                    if (ThisShipCost == decimal.Zero && AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                                    {
                                                        zeroShipCostCountThatShouldBeFiltered++;
                                                    }
                                                }
                                                tmpS.Append("<br/>");
                                                i++;
                                            }
                                            tmpS.Append("</select>");
                                            break;
                                        case "radio":
                                            while (rs.Read())
                                            {
                                                int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                                                AnyShippingMethodsFound = true;
                                                if (ShippingIsFree && Shipping.ShippingMethodIsInFreeList(ThisID))
                                                {
                                                    tmpS.Append("<input type=\"radio\" name=\"ShippingMethodID" + FieldSuffix + "\" id=\"ShippingMethodID" + FieldSuffix + i.ToString() + "\" value=\"" + ThisID.ToString() + "\" " + CommonLogic.IIF((FirstItem().m_ShippingMethodID == ThisID), " checked ", "") + ">");
                                                    tmpS.Append("&nbsp;");
                                                    tmpS.Append(DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting));
                                                    tmpS.Append("&nbsp;");
                                                    tmpS.Append(String.Format("({0})", AppLogic.GetString("shoppingcart.aspx.16", SkinID, ThisCustomer.LocaleSetting)));
                                                }
                                                else
                                                {
                                                    Decimal ThisShipCost = Shipping.GetShipByWeightCharge(ThisID, WeightTotal());
    
                                                    if (AppLogic.AppConfigBool("ApplyShippingHandlingExtraFeeToFreeShipping"))
                                                    {
                                                        if (ExtraFee != System.Decimal.Zero && m_ShipCalcID != Shipping.ShippingCalculationEnum.UseRealTimeRates)
                                                        {
                                                            ThisShipCost += ExtraFee;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (ExtraFee != System.Decimal.Zero && m_ShipCalcID != Shipping.ShippingCalculationEnum.UseRealTimeRates && ThisShipCost != System.Decimal.Zero)
                                                        {
                                                            ThisShipCost += ExtraFee;
                                                        }
                                                    }
    
                                                    if (m_VATOn)
                                                    {
                                                        ThisShipCost += Decimal.Round(ThisShipCost * ShippingTaxRate, 2, MidpointRounding.AwayFromZero);
                                                    }
    
                                                    if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                                    {
                                                        tmpS.Append("<input type=\"radio\" name=\"ShippingMethodID" + FieldSuffix + "\" id=\"ShippingMethodID" + FieldSuffix + i.ToString() + "\" value=\"" + ThisID.ToString() + "\" " + CommonLogic.IIF((FirstItem().m_ShippingMethodID == ThisID), " checked ", "") + ">");
                                                        tmpS.Append("&nbsp;");
                                                        tmpS.Append(DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting));
                                                        tmpS.Append("&nbsp;");
                                                        tmpS.Append(String.Format("({0})", m_ThisCustomer.CurrencyString(ThisShipCost)));
                                                    }
    
                                                    if (ThisShipCost == decimal.Zero && AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                                    {
                                                        zeroShipCostCountThatShouldBeFiltered++;
                                                    }
                                                }
                                                tmpS.Append("<br/>");
                                                i++;
                                            }
                                            break;
                                    }
                                }

  7. #7
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    that code worked really well. (We use shipping by weight so it was ideal.)
    the only problem I am faced with now is on the checkout page you can not select any shipping method.

    the checkout page does not seem to pull any data from the drop down box. The results show up in the drop down box correctly however they can not be selected.

    (i.e. the default is standard shipping at say £9 however if you refresh the total or change payment method it still shows up as shipping £0)
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience