Hide prices for non-registered customers dont work on tier prices

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 anni tempo fa
I have version 1.90 and have done no modifications what so ever to the system.

When i choose the option, Hide prices for non-registered customers: all prices dissapear for the non-logged-in customer, with one exception. The tier prices still show.

Any idea why this is?
13 anni tempo fa
Hi,
Looking at the code, it seems that the 'hidepricesfornonregistereusers' setting has no effect on the display of the tier prices.

If you want to hide the whole tier prices control, just add the following code in modules/tierprices.ascx.cs, just inside the BindData() method:

if (this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered"))
            {
                this.Visible = false;
                return;
            }


I haven't tested this, so let me know if you have any problems!

Hope this helps,

Chris
13 anni tempo fa
Fast answer, i like it!

Implemented the code but nothing happned...

Recompilation needed, right?!?
13 anni tempo fa
whenever you make any kind of changes in .cs file - re-compilation is needed for changes to take affect.
13 anni tempo fa
Just as i thought. Many thanks!!
13 anni tempo fa
It's the bug. Thank for info. Following the next steps in order to fix it:
1. Open Modules/TierPrices.ascx.cs file
2. Replace
private void BindData()
        {
            var productVariant = this.ProductService.GetProductVariantById(this.ProductVariantId);
            
            if (productVariant != null)
            {
                var tierPrices = productVariant.TierPrices;
                if (tierPrices.Count > 0)
                {
                    lvTierPrices.DataSource = tierPrices;
                    lvTierPrices.DataBind();
                }
                else
                    this.Visible = false;
            }
            else
                this.Visible = false;
        }

with the following one:
private void BindData()
        {
            var productVariant = this.ProductService.GetProductVariantById(this.ProductVariantId);
            
            if (productVariant != null)
            {
                if (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                        (NopContext.Current.User != null &&
                        !NopContext.Current.User.IsGuest))
                {
                    var tierPrices = productVariant.TierPrices;
                    if (tierPrices.Count > 0)
                    {
                        lvTierPrices.DataSource = tierPrices;
                        lvTierPrices.DataBind();
                    }
                    else
                        this.Visible = false;
                }
                else
                    this.Visible = false;
            }
            else
                this.Visible = false;
        }

3. Recompile the solution
P.S. I didn't tested it, but presume it should work
13 anni tempo fa
Ok i will test this instead. Thanks.
13 anni tempo fa
Doh! Sorry, forgot to check if the user was logged in as well - that will teach me to copy and paste code without checking!

Andrei's solution should do the trick.

Chris
13 anni tempo fa
Ok, many thanks to you both (c:
13 anni tempo fa
It worked perfectly!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.