• I have a code here: https://pastebin.com/KnYtcFr9

    This is what I want to do in “pseudo-code” (I think just a line should be changed):

    if ( ! empty( trim( $discount_post ) ) && ! not checked the check box:"6_checkbox")) {

    In other words I need also that a checkbox with the meta name “6_checkbox” is not checked in order to apply that discount

    when I check that check box, and olnly for the period n6, the post discount is not applied and the agency discount instead will be applied, if existing

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi sacconi,

    First I would add the variable:
    $checkbox_status = get_post_meta($post->ID, '6_checkbox', true);
    For this line of code:
    if ( ! empty( trim( $discount_post ) ) && ! not checked the check box:"6_checkbox")) {
    I would edit it to make it look like this:
    if ( ! empty( trim( $discount_post ) ) && empty($checkbox_status) ) {

    here is the full code:
    https://pastebin.com/gsquyas2
    Let me know if you have any questions.

    Thread Starter sacconi

    (@sacconi)

    The checkbox will be in the author admin page so more like the following?

    get_the_author_meta( '6_checkbox', $post->post_author )

    Thread Starter sacconi

    (@sacconi)

    unluckily it’s not working.

    the code doesnt understand when checked and when unchecked..but I’m working on my checkbox code

    • This reply was modified 1 year, 5 months ago by sacconi.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding a conditional if a check box is checked’ is closed to new replies.