how to remove [+£xxx] from product attributes on CART page (ie OrderSummary.cshtml )

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
in 3.90 we have this line
AttributeInfo = _productAttributeFormatter.FormatAttributes(sci.Product, sci.AttributesXml, sci.Customer),

To be specific heres requrirement screenshot
6 years ago
The above solution is NOT applicable for 3.90, btw.
6 years ago
I think what you are looking for is the ProductAttributeFormatter:
https://github.com/nopSolutions/nopCommerce/blob/master/src/Libraries/Nop.Services/Catalog/ProductAttributeFormatter.cs#L174

This service creates a single string out of all attributes. The line #174 adds the [+ ] around the price.
Keep in mind that if you adjust the source code that you will need to create a new order (because the string is saved in the database).
5 years ago
vipul.dumaniya wrote:
Hello Guys,

I have checked on 3.8 version and i think older version should have same logic as well and below is the solutions to Hide the price adjustment values from OrderSummary.cshtml

you need to change one line of code in Nop.Web/Controllers/ShoppingCartController.cs

Find the method PrepareShoppingCartModel

Find the region
#region Cart items
and find and replace below line

AttributeInfo = _productAttributeFormatter.FormatAttributes(sci.Product, sci.AttributesXml),


with below line

AttributeInfo = _productAttributeFormatter.FormatAttributes(sci.Product, sci.AttributesXml,_workContext.CurrentCustomer,renderPrices:false),


there is one overloaded method _productAttributeFormatter.FormatAttributes() on which we can pass renderPrices=false so it will not add the price adjustment values.

so suppose if you wanted to apply same logic to other places like on order detail page on admin or on frond end you need to find appropriate controller action and model filling method and you need to pass renderPrices=false so it will not show price adjustment value.


WORKED LIKE A CHARM! in 3.9

Only change is the file to edit is Presentation/Nop.Web/Factories/ShoppingCartModelFactory.cs

Find the method PrepareShoppingCartModel
Lines:
409  - (edit for shopping cart)
1017 - (edit for mini shopping cart)

adding ",_workContext.CurrentCustomer,renderPrices:false" as you stated.


THANKS!
5 years ago
ChrisKaun wrote:
I think what you are looking for is the ProductAttributeFormatter:
https://github.com/nopSolutions/nopCommerce/blob/master/src/Libraries/Nop.Services/Catalog/ProductAttributeFormatter.cs#L174

This service creates a single string out of all attributes. The line #174 adds the [+ ] around the price.
Keep in mind that if you adjust the source code that you will need to create a new order (because the string is saved in the database).



I just tried this since it was a much cleaner edit with very little modification to code,
changing in LINE #90.. (actual line is #83 in ver 3.9 code)



public virtual string FormatAttributes(Product product, string attributesXml,

            Customer customer, string separator = "<br />", bool htmlEncode = true, bool renderPrices = true,

            bool renderProductAttributes = true, bool renderGiftCardAttributes = true,

            bool allowHyperlinks = true)


Changing:
bool renderPrices = true,

to
bool renderPrices = false,



This has the same result without having to use Overloads, Just change to FALSE and you are done.!
I would assume this has been added to future versions as a String Resource.

Thanks again!


BTW: the String is NOT saved in DataBase, no need to re-enter a new order.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.