Support

Account

Home Forums General Issues Get Product ID When Value is TRUE or 1

Solved

Get Product ID When Value is TRUE or 1

  • I need to return the post or product id when the custom field is set to true on any specific Edit Product screen.

    foreach ( $cart->get_cart() as $key => $cart_item ) {
        $field      = get_post_meta( $cart_item['product_id'],'_free', true );
    }

    var_dump( $field ) returns 1 as the switch is set to true, great, but i need the I.D as well as i need to use it in the code.

  • You are using the product ID in the code to get the field value, you already have it in $cart_item['product_id']

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.