How to take value from span

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
nopCommerce display a decimal value in a html span, this is the code

   <span @if (String.IsNullOrWhiteSpace(Model.PriceWithDiscount))
                  { <text>  itemprop="price" class="price-value-@(Model.ProductId)" </text>  }>
                  
              
            </span>

This code display the product price after change the attribute of the product.
How can i take this value and use for my c# decimal calculation below?
7 years ago
You need to write some javascript code. If you want to know the exact the javascript code please share a link or share a picture.
7 years ago
7 years ago
It is not fully clear to me. After that I am trying to guess the issue and here is the code you may try.

      Regex rex = new Regex(@"\p{Sc}");

                string currencySymbol = rex.Match(Model.PriceWithDiscount).value;

                Regex rex1 = new Regex(@"\d.");

                decimal discountValue = Convert.ToDecimal(rex.Match(Model.PriceWithDiscount).value);

                Model.PriceWithDiscount = discountValue.ToString() + discountValue;

------------------------------------------------------------------------------------------------

suppose there is a code blog like

var priceWithDiscount= Model.PriceWithDiscount;

// the value of priceWithDiscount is 10 i.c the value come from model is 10. Now if you want to pass value 20 to controller you need to write

Model.PriceWithDiscount="$20";
7 years ago
Don;t look the code where i calculate the prices. It is clear for me.

Take a look to this code. And focus on it:

  @*render price*@
            <span @if (String.IsNullOrWhiteSpace(Model.PriceWithDiscount))
                  { <text>  itemprop="price" class="price-value-@(Model.ProductId)" </text>  }>
                  
            
            </span>

This part of code display the price of product (including attribute price) to the website product details page. It change the value depend of the selected attribute.

i want to take this value and use  in the later price calculations.
7 years ago
Sina.islam are u still here? Do you have any other sugestion?
7 years ago
yorke1988 wrote:
Don;t look the code where i calculate the prices. It is clear for me.

Take a look to this code. And focus on it:

  @*render price*@
            <span @if (String.IsNullOrWhiteSpace(Model.PriceWithDiscount))
                  { <text>  itemprop="price" class="price-value-@(Model.ProductId)" </text>  }>
                  
            
            </span>

This part of code display the price of product (including attribute price) to the website product details page. It change the value depend of the selected attribute.

i want to take this value and use  in the later price calculations.


I think You should check the following file too for your expected result.

_ProductAttributes.cshtml

Find the following code ==>

if (data.price) {
                                $(".@(priceVarClass)").text(data.price);
                            }


Try with like bellow ==>


var newdata=parseFloat(data.price)+100; // here 100 means your extra amount
$(".@(priceVarClass)").text(newdata);
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.