How to do calculation in _ProductTierPrices.cshtml

Posted: July 20, 2019 at 1:12 AM Quote #242703
Hello,

How to do a calculation to show the percentage discount in TierPrice instead of listing the actual prices?

i.e.
Price: $100,
Tier price 10pcs: $90
Tier price 20pcs: $80
Tier price 50pcs: $70

Calculate to
Tier price 10pcs: 10% OFF "by (($100-$90)/$100)"
Tier price 20pcs: 20% OFF
Tier price 50pcs: 30% OFF

Calculate in in _ProductTierPrices.cshtml file, no source code

Can anyone help?

Thank you
Z
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: July 24, 2019 at 6:19 AM Quote #242845
1.You need to add new field in TierPriceModel
public decimal PriceValue {get;set;}
2. I am not sure which nop version are you using? so you need to just set PriceValue = without formatting.
3. either do code at controller level or same page you use PriceValue so it should be achieve your requirement.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please up-vote the answer, if it helps you! :)

Need any professional assistance? Drop us your requirements on [email protected]

http://www.satyanamsoft.com/
nopCommerce Solution Partner
Posted: July 25, 2019 at 3:03 AM Quote #242901
n _ProductTierPrices.cshtml page we can't get the product original price. It should be requires to show percentage base calculation.

I think you need to modify ProductTemplate.Simple.cshtml page for using Product original price.
@await Html.PartialAsync("_ProductTierPrices", Model.TierPrices) replace with @await Html.PartialAsync("_ProductTierPrices", Model)

then make change in _ProductTierPrices.cshtml file according to use ProductDetailsModel model whole page lke Model.TirePrice in foreach loop etc..


Percentage Calculation should be

@foreach (var tierPrice in Model.TierPrices)
{
    var tirepriceStr = tierPrice.Price.Replace("$", "");
    var tirepriceValue = Convert.ToDecimal(tirepriceStr);
    var subtractedPrice = Convert.ToDecimal(Model.ProductPrice.PriceValue - tirepriceValue);
    var calulatedPercentage = (subtractedPrice / Model.ProductPrice.PriceValue) * 100;
    <td class="item-price">
        @*@tierPrice.Price*@
        @calulatedPercentage.ToString("0.##")% OFF
    </td>
}
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Please up-vote the answer, if it helps you! :)

Need any professional assistance? Drop us your requirements on [email protected]

http://www.satyanamsoft.com/
nopCommerce Solution Partner
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more