Page 1 of 1

wholesale for some customers

Posted: Fri Aug 22, 2008 5:44 pm
by ryanstowasser
I have set up a wholesale user group and all wholesale usergroup members get a percentage discount.

I set this up my creating a volume discount and applying the percentage discount, set discount scope to global and selected my user group.

The discount works great on the basket page.

Now I need to display the discounted price on the product detail page, and on the category page if the logged in user is part of the wholesale user group.

I need to know if a customer is part of the wholesale user group and also the discounted price.

So far I have this:

Code: Select all

     if (!Token.Instance.User.IsAnonymous)
                        {
                            VolumeDiscountCollection VolumeDiscounts = VolumeDiscountDataSource.LoadForProduct(product.ProductId);
                            foreach (VolumeDiscount discount in VolumeDiscounts)
                            {
                                if(discount.IsValidForUser(Token.Instance.User))
                                {
                                    //discount.CalculateDiscount(1,1,product.Price,);
                                    _IsWholesale = true;
                                }
                            }
                        }
This is all written in the ProductHelper file. Has anyone else done this before?

Thanks for the help,

Ryan

Re: wholesale for some customers

Posted: Sun Aug 24, 2008 11:16 pm
by AbleMods
Volume discounts can already be assigned to specific groups.

Why are you modifying producthelper?

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 7:56 am
by Robbie@FireFold
He is trying to display the correct discount on the product page. This is something I require also.

I was told by AblePartners it was impossible, but I find that hard to believe. Considering every software I have worked with does this feature out of the box.

Wish I could help, but coding is not our thing.

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:01 am
by AbleMods
No way?? It'll take the discount but it won't show the discount on the product page???

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:12 am
by Robbie@FireFold
If its not public it will not show the discount.

I.e. Product costs $10.00. I give a special group 50% off.

Product page says - $10.00.
What we would like the product page to show: $5.00

The discount does take, but again only shown at check out.

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:31 am
by AbleMods
"Not Public" as in the product record visibility setting or "Not Public" as in the user is part of a user group and thus the discount only applies to group members?

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:33 am
by AbleMods
but wait...it's a volume discount. The system is only going to be able to take a discount on the product page if the basket total currently qualifies. That may be why Able chose to apply them during checkout - at that point the basket contents are committed.

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:38 am
by Robbie@FireFold
SolunarServices wrote:"Not Public" as in the product record visibility setting or "Not Public" as in the user is part of a user group and thus the discount only applies to group members?
Group wise.

Product would be public

Re: wholesale for some customers

Posted: Mon Aug 25, 2008 8:46 am
by Robbie@FireFold
This is similar: viewtopic.php?f=45&t=7948

Re: wholesale for some customers

Posted: Tue Sep 02, 2008 5:27 pm
by ryanstowasser
I have everything working except the CalulateDiscount function. Does anyone know how this function works?

Code: Select all

  if (!Token.Instance.User.IsAnonymous)
                        {
                            VolumeDiscountCollection VolumeDiscounts = VolumeDiscountDataSource.LoadForStore();
                            foreach (VolumeDiscount discount in VolumeDiscounts)
                            {
                                if(discount.IsValidForUser(Token.Instance.User))
                                {
                                    discountedPrice = discount.CalculateDiscount(1, 1, discountedPrice, discountedPrice);
                                }
                            }
                        }

Re: wholesale for some customers

Posted: Tue Sep 02, 2008 6:16 pm
by nickc
public LSDecimal CalculateDiscount(
int totalQuantity,
LSDecimal lineItemValue,
LSDecimal totalValue
)

totalQuantity (Int32)
Quantity of product (or line item) to be discounted.

lineItemValue (LSDecimal)
Extended Price of product (or line item) to be discounted.

totalValue (LSDecimal)
If grouping discount mode is enabled, this is the total Extended Price of all products from the same category; if line item discount mode is enabled, this should be the same value as lineItemValue.

Return Value
The calculated discount

Re: wholesale for some customers

Posted: Tue Sep 02, 2008 6:47 pm
by ryanstowasser
This code might help some other people out. The code displays a percentage discount on the Product Page.

The client we have does not give quantity discounts, but uses the options within Volume discounts to manage a wholesale percentage discount that is the same across a user group for all selected products or categories.

Code: Select all

 if (!Token.Instance.User.IsAnonymous)
                        {
                            VolumeDiscountCollection VolumeDiscounts = VolumeDiscountDataSource.LoadForStore();
                            foreach (VolumeDiscount discount in VolumeDiscounts)
                            {
                                if(discount.IsValidForUser(Token.Instance.User) && discount.Levels.Count > 0)
                                {
                                    //foreach (VolumeDiscountLevel level in discount.Levels)
                                    //{
                                    if (discount.Levels[0].IsPercent)
                                    {
                                        discountedPrice = discountedPrice * (1 - (discount.Levels[0].DiscountAmount / 100));
                                    }
                                    //}
                                }
                            }
                        }