Forums

Need help setting up a trigger check box (6 posts)

  1. scnix
    Member
    Posted 9 months ago #

    Hi guys and gals,

    I'm trying to add a checkbox within the WordPress Editor (Admin panel) that triggers a predetermined function that changes the current post.

    Basically, I have a product page (with lots and lots of products). When I edit the post for that specific product, there'll be a check box stating if the product is sold out or not. When checked, the site will display a "Sold Out" image at the top of entry div. When not, nothing will display there.

    I'm not exactly sure how to get about this. Do I need a plug in or sorts?

    Thanks! :)

  2. keesiemeijer
    moderator
    Posted 9 months ago #

    You can give the product a category "sold" or use custom fields or adding a metabox with the checkbox to the editor page.

    There are probably plugins that can do this also.

  3. scnix
    Member
    Posted 9 months ago #

    Hmm, ok I just installed a metabox plug in, do I just use the get_post_custom() to detect if the checkbox is checked?

    It doesn't show what values it returns. Or does checkboxes just return a "true/false" value?

  4. keesiemeijer
    moderator
    Posted 9 months ago #

    What plugin are you using?

  5. scnix
    Member
    Posted 9 months ago #

    This one : http://wordpress.org/extend/plugins/verve-meta-boxes/installation/

    Verve Meta Boxes

    I think I got it working. It pops up and alert when checked and doesn't when not. Now I just need to figure out how set it to differentiate each individual post.

    Here's the code I placed in the_loop

    <?php
       $detect_sold_out = get_post_custom_values('sold_out');
       if ($detect_sold_out == true) { ?>
           <script> alert('it works') </script>
    <?php } ?>

    :)

  6. keesiemeijer
    moderator
    Posted 9 months ago #

    Try looking what $detect_sold_out holds:

    $detect_sold_out = get_post_custom_values('sold_out');
    
    echo $detect_sold_out;
    
    // or
    
    echo '<pre>';
    print_r($detect_sold_out);
    echo '</pre>';

Reply

You must log in to post.

About this Topic