Page 1 of 1

Available Discounts

Posted: Thu Aug 14, 2008 2:20 pm
by William_firefold
Another minor(i hope) change.
Currently next to each product we have this:

Available Discounts
Store Wide
• Buy 2 to 9, save 1%
• Buy 10 to 24, save 2%
• Buy 25 to 49, save 3%
• Buy at least 50, save 4%

We want it to have a dollar value like this:

Image

Thanks in advance for any help.

Re: Available Discounts

Posted: Tue Aug 19, 2008 9:52 am
by Shopping Cart Admin
Moved to feature enhancements so it's not lost.

Re: Available Discounts

Posted: Mon Oct 27, 2008 1:38 pm
by SteveHiner
The image is gone so I have to make assumptions about what he's asking for. This is something I implemented myself but it makes updates and customization somewhat harder. I'd love to have it built in.

My current custom implementation builds a table that looks like this:

Code: Select all

1+       100+      500+     1000+     2500+
$2.79    $2.19     $1.39    $1.29     $1.25
This is also how my client thinks about the data. I wish they could enter the data in the product like this. Right now they'll have to change from thinking about it as the final price to thinking about a dollar discount based on quantity. If the quantity discounts could be entered as the final price instead of a discount it would be helpful to them.

Re: Available Discounts

Posted: Wed Nov 05, 2008 7:53 am
by William_firefold
Yes that is pretty much what I had in the image. Ours says Save $0.03 ea.,Save $0.06 ea....
I cant remember how we did it as I wasnt the one who did but here is the .cs for ours:

Code: Select all

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Common;
using CommerceBuilder.Products;
using CommerceBuilder.Marketing;
using CommerceBuilder.Utility;

public partial class ConLib_ProductDiscountsDialog : System.Web.UI.UserControl
{
    private string _Caption = "<strong>Quantity Discounts</strong>";

    [Personalizable(), WebBrowsable()]
    public string Caption
    {
        get { return _Caption; }
        set { _Caption = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        bool discountsFound = false;
        int _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
        Product _Product = ProductDataSource.Load(_ProductId);
        if (_Product != null)
        {
            VolumeDiscountCollection availableDiscounts = VolumeDiscountDataSource.GetAvailableDiscounts(_ProductId);
            if (availableDiscounts.Count > 0)
            {
                //SEE WHETHER THERE IS ONE DISCOUNT
                //AND IT ALWAYS HAS NO VALUE
                bool show = true;
                if (availableDiscounts.Count == 1)
                {
                    VolumeDiscount testDiscount = availableDiscounts[0];
                    if (testDiscount.Levels.Count == 1)
                    {
                        VolumeDiscountLevel testLevel = testDiscount.Levels[0];
                        show = ((testLevel.MinValue > 1) || (testLevel.DiscountAmount > 0));
                    }
                }
                if (show)
                {
                    phCaption.Text = this.Caption;
                    DiscountGrid.DataSource = availableDiscounts;
                    DiscountGrid.DataBind();
                    discountsFound = true;
                }
            }
        }
        //DO NOT DISPLAY THIS CONTROL IF NO DISCOUNTS AVAILABLE
        if (!discountsFound) this.Controls.Clear();
    }

    protected string GetLevels(object dataItem)
    {
        StringBuilder levelList = new StringBuilder();
        levelList.Append("<ul class=\"qtyDiscounts\">");
        VolumeDiscount discount = (VolumeDiscount)dataItem;
        string minFormat, maxFormat;
        if (discount.IsValueBased)
        {
            minFormat = "{0:ulc}";
            maxFormat = "{1:ulc}";
        }
        else
        {
            minFormat = "{0:F0}";
            maxFormat = "{1:F0}";
        }
        foreach (VolumeDiscountLevel level in discount.Levels)
        {
            levelList.Append("<li>Buy ");
            if (level.MinValue != 0)
            {
                if (level.MaxValue != 0)
                {
                    levelList.Append(string.Format(minFormat + " to " + maxFormat, level.MinValue, level.MaxValue));
                }
                else
                {
                    levelList.Append(string.Format("at least " + minFormat, level.MinValue));
                }
            }
            else if (level.MaxValue != 0)
            {
                levelList.Append(string.Format("up to " + minFormat, level.MaxValue));
            }
            else
            {
                levelList.Append("any");
            }
            levelList.Append(" - <span style=\"color:#f0ca00;font-weight:bold;\">Save ");
            if (level.IsPercent) levelList.Append(string.Format("{0:0.##}%", level.DiscountAmount));
            else levelList.Append(string.Format("{0:ulc} ea.", level.DiscountAmount));
            levelList.Append("</span></li>");
        }
        levelList.Append("</ul>");
        return levelList.ToString();
    }
}