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.
Hace 13 años
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?
Hace 13 años
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
Hace 13 años
Fast answer, i like it!

Implemented the code but nothing happned...

Recompilation needed, right?!?
Hace 13 años
whenever you make any kind of changes in .cs file - re-compilation is needed for changes to take affect.
Hace 13 años
Just as i thought. Many thanks!!
Hace 13 años
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
Hace 13 años
Ok i will test this instead. Thanks.
Hace 13 años
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
Hace 13 años
Ok, many thanks to you both (c:
Hace 13 años
It worked perfectly!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.