Can you help me fix this code?

Discussion in 'General Scripting Chat' started by thetvnun, Oct 28, 2011.

  1. thetvnun

    thetvnun Power Member

    Joined:
    Sep 8, 2010
    Messages:
    656
    Likes Received:
    255
    Guys, I am supposed to follow the instructions below. Honestly I suck at anything like this; even though the instructions are clear - I don't know what to do.

    These are the instructions:

    On line 142 of wpsc-single_product.php, we see this:

    <p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Price', 'wpsc'); ?>: <span id='product_price_<?php echo wpsc_the_product_id(); ?>' class="currentprice pricedisplay"><?php echo wpsc_the_product_price(); ?></span></p>


    That?s the part that actually outputs the price label for a single-item display. Wrap it with this:


    if(!strpos(wpsc_the_product_price(), "0.00")): ?> ... (line 142 stuff) ... <?php endif; ?>


    That's it you're all done.
     
  2. theMHR

    theMHR Junior Member

    Joined:
    Apr 27, 2011
    Messages:
    124
    Likes Received:
    19
    what actually you want to do, just to go with line 142 stuff if your condition is right?
     
  3. thetvnun

    thetvnun Power Member

    Joined:
    Sep 8, 2010
    Messages:
    656
    Likes Received:
    255
    hey thanks, i need it to remove all prices that are "0.00" so that the price will vanish. that's what this solution is supposed to do anyway.
     
  4. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,868
    Likes Received:
    1,336
    If this is just a clear-cut follow instruction scenario with nothing to do on your part, this is how it should be:
    Code:
    <?php if (!strpos(wpsc_the_product_price(), "0.00")) { ?><p class="pricedisplay <?php echo wpsc_the_product_id(); ?>"><?php _e('Price', 'wpsc'); ?>: <span id='product_price_<?php echo wpsc_the_product_id(); ?>' class="currentprice pricedisplay"><?php echo wpsc_the_product_price(); ?></span></p><?php } ?>
    Though I did change the if block to bracketed form because it's more widely-used, user-friendly, space-saving, etc.
     
    • Thanks Thanks x 1
    Last edited: Oct 28, 2011
  5. thetvnun

    thetvnun Power Member

    Joined:
    Sep 8, 2010
    Messages:
    656
    Likes Received:
    255
    hey man, i really appreciate it! i'm going to give it a shot and look at it so that maybe ill understand next time; i appreciate your effort!