Grow your CSS skills. Land your dream job.

Replace string (SEK) on every occurance

  • # April 22, 2013 at 3:43 am

    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!

    # April 22, 2013 at 3:54 am

    $(‘.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

    # April 22, 2013 at 8:59 am

    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)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".