imrahim Posted November 2, 2014 Share Posted November 2, 2014 I need the below code to be in an if else condition so i can excute it on certain parts of the website I am a noob i need the below code to execute properly if(is_wc_endpoint_url("order-received")) { echo "empty no text"; } else { echo "the below code"; } if(is_wc_endpoint_url("order-received")) { echo "empty no text"; } else { echo "the below code"; } echo doesn't work any without echo i will get some syntac errors please help <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> <div class="wc_address_validation_postcode_lookup" id="<?php echo esc_attr( 'wc_address_validation_postcode_lookup_' . $address_type ); ?>"> <p class="form-row form-row-first"> <input type="text" class="input-text" name="wc_address_validation_postcode_lookup_postcode" placeholder="<?php _e( 'Enter Postcode', WC_Address_Validation::TEXT_DOMAIN ); ?>" value="" /> </p> <?php if ( $requires_house_number ): ?> <p class="form-row form-row-last"> <input type="text" class="input-text" name="wc_address_validation_postcode_lookup_postcode_house_number" placeholder="<?php _e( 'Enter House Number', WC_Address_Validation::TEXT_DOMAIN ); ?>" value="" /> </p> <?php endif; ?> <p class="form-row <?php if ( $requires_house_number ): ?>form-row-wide<?php else: ?>form-row-last<?php endif;?>"> <a href="#" class="button"><?php _e( 'Find Address', WC_Address_Validation::TEXT_DOMAIN ); ?></a> </p> <div class="clear"></div> <p class="form-row message notes"> <select name="wc_address_validation_postcode_lookup_postcode_results" class="wc_address_validation_chosen select <?php echo esc_attr( $address_type ); ?>"></select> </p> <hr/> </div> <?php Quote Link to comment https://forums.phpfreaks.com/topic/292231-if-else-function/ Share on other sites More sharing options...
ginerjm Posted November 2, 2014 Share Posted November 2, 2014 Makes no sense. Quote Link to comment https://forums.phpfreaks.com/topic/292231-if-else-function/#findComment-1495546 Share on other sites More sharing options...
hansford Posted November 2, 2014 Share Posted November 2, 2014 First things first - you must first understand the fundamentals of programming - then you can pick up on any language even if you don't know it and figure things out. if(is_wc_endpoint_url("order-received")) { echo "empty no text"; } else { echo "the below code"; } That is an if/else statement. The argument in the "IF" clause is calling a function - wc_endpoint_url - that function is suppose to return true or false based on the argument it was passed which is "order-received". My only answer based on the information you gave is - check that function - is it returning anything at all, is it returning what it should be - true or false. Quote Link to comment https://forums.phpfreaks.com/topic/292231-if-else-function/#findComment-1495563 Share on other sites More sharing options...
ginerjm Posted November 2, 2014 Share Posted November 2, 2014 Please post your next set of code using the proper tags defined for this forum. Basically 'code' and '/code' wrapped in [] to start and end your code. That said you could also try to re-format your code so it is more readable. Right now your few lines are taking 2-3 screens to display and they really shouldn't. Quote Link to comment https://forums.phpfreaks.com/topic/292231-if-else-function/#findComment-1495567 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.