Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Replace string (SEK) on every occurance

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44292
    Anonymous
    Inactive

    Hi!
    I have a WordPress ecommerce page with the plugin “wp-ecommerce”.
    The prices are output with wpsc_the_product_price_display();
    This outputs the price + the currency shorhand, which for Swedish Kronas is SEK. However, SEK isnt used in sweden, we us kr for kronas.
    So the client want me to change every SEK to Kr, and I’m thinking of doing a JS/jQuery solution with something like .find() .replace(), but since I’m really new to the ‘Js Jungle’, I need help with this.

    The price only occurs a mere 5 times per page. Every price is in a div with a class of price.

    How would i go about creating the jQuery code for this? Since there are multiple tags i guess .each() needs to be involved…

    Help greatly appreciated!

    #132674
    pixelgrid
    Participant

    $(‘.price’).each(function(){
    $(this).text( $(this).text().replace(/SEK/,’Kr’) );
    })

    However you should check if the wp-ecommerce plugin gives you a filter so you can alter the output most professionals plugins give all kind of hooks and filters so you can change the output

    #132701
    Anonymous
    Inactive

    Thanks alot!
    I will look into hooks and also in the source code to see if I can change the main PHP function, but this is a great solution meanwhile.
    Once again, thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.