• 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! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    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.

    Thread Starter scnix

    (@scnix)

    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?

    Moderator keesiemeijer

    (@keesiemeijer)

    What plugin are you using?

    Thread Starter scnix

    (@scnix)

    This one : https://www.ads-software.com/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 } ?>

    ??

    Moderator keesiemeijer

    (@keesiemeijer)

    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>';

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need help setting up a trigger check box’ is closed to new replies.