Jump to content

IF Else function


imrahim

Recommended Posts

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

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.