Developer forum

Forum » Ecommerce - Standard features » MINIMUM as Customer number in price matrix

MINIMUM as Customer number in price matrix

Thomas Jensen
Reply

Trying to determine if the is a hack or a feature or a bug, and how do I fix it?

In version 8.8.1.32 (cleansolution.net.dynamicweb-cms.com)

 

If price matrix has a line with "Customer number" = MINIMUM and you are loged in with a user that belong to User group "Rabatgruppe 30"
then
in product view the price will take the price from MINIMUM (30,-)  (@GetValue("Ecom:Product.Price"))
but in productlist it will take the price from "Rabatgruppe 30" (28,14) (@foreach (LoopItem i in GetLoop("Products")){ @i.GetValue("Ecom:Product.Price") })
and when putting it in to the cart it will take from "Rabatgruppe 30" (28,14) no matte if it is added from productlist or product view

 

There is no user where the customer number = "MINIMUM"
and there is no reference to "MINIMUM" in any template

 

It seams that this "feature" only works in Product view
 

 


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

HI,

I've tried to reproduce the issue on test environmet based on DW9.4.0 in line with your scenario (test product has two rules in proce martix - one has 'MINIMUM' and another one has user group) and was not able to reproduce it, I see the price related to rule has group logged user belong to is applied in the both places correctly - product view/product list (Ecom:Product.Price tag is used in the both templates, inside Product loop in the second case). The tested product has extendent variant has the same price as its product. The product price is passed to cart order line correctly in the both case as well.

BR, Oleg QA  

 
Thomas Jensen
Reply

I tried in a (test) DW Bikeshop ver 8.9.2.14
and also in another shop ver 8.8.1.17
and also in a third shop ver 8.6.1.25

and in all places has "MINIMUM" no effect



I have been told that it has worked before,
Maybe it was before an update from 8.6 to 8.8 (but not sure about this)

It should work by "MINIMUM" overwriting the price if it bigger than the group price

But if this feature is not a DW original feature, then the question are, where could this feature have been implemented, so I can make it work again ?

 
Nicolai Pedersen
Reply

Hi Thomas

Can you tell which product this is?

Thanks, Nicolai

 
Thomas Jensen
Reply
This post has been marked as an answer

Hi Nicolai

I found that it's a custom DLL file in \application\bin that has the function of this MINIMUM

it is in all products that has this "MINIMUM", that only workst in the "product view" it self, and not in the "product list" or in the "cart"

eg.  CleanSolution » Rengøringsmidler » Duftfrisker » Frosch Oase Granatæble Rumfrisker (Number 101312)

 

The DLL looks like this

        public override PriceRaw FindPrice(Product product, double quantity, string variantID, Currency currency, string unitID, Extranet user) {

           
            // Get the price from the DefaultPriceProvider
            DefaultPriceProvider defaultProvider = new DefaultPriceProvider();
            PriceRaw rawPrice = defaultProvider.FindPrice(product, quantity, variantID, currency, unitID, user);

            double minimumPrice = 0.0;

            if (user.LoggedIn) {
                foreach (var p in product.Prices) {
                    if (!string.IsNullOrWhiteSpace(user.CustomerNumber) && p.UserCustomerNumber == user.CustomerNumber) {
                        rawPrice.Price = p.Amount;
                        //return rawPrice;
                        //customerPrice = p.Amount;
                    }

                    if (p.UserCustomerNumber.ToUpper().Trim() == "MINIMUM") {
                        minimumPrice = p.Amount;
                    }
                }

                if (rawPrice.Price < minimumPrice) {
                    rawPrice.Price = minimumPrice;
                }

                return rawPrice;
                //return null;
            }


            return null;
        }
Votes for this answer: 1
 
Thomas Jensen
Reply

I Repeat

it is in all products that has this "MINIMUM", that only workst in the "product view" it self, and not in the "product list" or in the "cart" !?

 
Nicolai Pedersen
Reply

Not sure I understand...

Do you still have an issue pending, or did you solve your issue?

 
Thomas Jensen
Reply

Yes it's sille an issue

The MINIMUM prise only works on the Product detail page,
it dos not work in the product list og in the cart 

but now i know that it is a custom dll, but it sill only works in Product details

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Thomas,

Please review this screencast: https://www.screencast.com/t/3G3RuMXIh

It's a copy of your price provider. I have added an additional price to the product "Useless box" that will set the price to 1. In my video you'll see the provider being hit on productlist, product detail and cart. So this indicates to me that the price provider is hit in all three scenarios and works as intended. Is there something I have misunderstood, or does my example meet your scenario?

Let me have a comment.

BR
Morten

 
Thomas Jensen
Reply

Hi Morten

It looks from the screencast that you are testing this in DW94, the problem is in 8.8.1.32

upgrading from DW8 to DW9 is not allways strait out of the box, but it is a posibility to upgrade to 8.9

so can you test it in a DW8?

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply
This post has been marked as an answer

Hi Thomas,

You're quite right that in DW 8 the Prices collection is empty on product list and on the cart. Unfortunately this is also the case on most recent 8.9, on which I've tested. Also, I am quite confident that this will not be fixed on the 8 branch.

However, a work-around could be that you collect the prices manually from the database:

            if (user.LoggedIn)
            {
                System.Data.IDataReader reader = Dynamicweb.Database.CreateDataReader($"SELECT * FROM EcomPrices WHERE PriceProductId='{product.ID}'");
                while (reader.Read())
                {
                    if (!string.IsNullOrWhiteSpace(user.CustomerNumber) && reader["PriceUserCustomerNumber"].ToString() == user.CustomerNumber)
                        rawPrice.Price = (double)reader["PriceAmount"];

                    if (reader["PriceUserCustomerNumber"].ToString().ToUpper().Trim() == "MINIMUM")
                        minimumPrice = (double)reader["PriceAmount"];
                }

                if (rawPrice.Price < minimumPrice)
                    rawPrice.Price = minimumPrice;

                return rawPrice;
            }

Hope the above helps. Remember to dispose the reader properly, if you take use of the above.

BR
Morten

Votes for this answer: 1
 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply
This post has been marked as an answer

PS:

You may even want to leave out the loop:

 

            if (user.LoggedIn)
            {
                var result = Dynamicweb.Database.ExecuteScalar($"SELECT TOP 1 PriceAmount FROM EcomPrices WHERE PriceProductId='{product.ID}' AND UPPER(RTRIM(PriceUserCustomerNumber))='MINIMUM' ORDER BY PriceAmount ASC");
                if (result != null)
                    minimumPrice = (double)result;

                if (rawPrice.Price < minimumPrice)
                    rawPrice.Price = minimumPrice;

                return rawPrice;
            }
            return null;

BR
Morten

Votes for this answer: 1
 
Thomas Jensen
Reply

Hi

Yes, it worked, everything seems to work as expected now

Thanks

 

You must be logged in to post in the forum