Endif

hadoo

تازه وارد
سلام
کد زیر درسته؟

کد:
    if ( $_POST['billing_field_259'] == 'Arbeitnehmer' ) {
        $fields['employed_as'] = 'employee';
    } elseif ( $_POST['billing_field_259'] == 'Beamter' ) {
        $fields['employed_as'] = 'official';
    } elseif ( $_POST['billing_field_259'] == 'Selbstständiger' ) {
        $fields['employed_as'] = 'freelancer';
    } elseif ( $_POST['billing_field_259'] == 'Arbeiter' ) {
        $fields['employed_as'] = 'worker';
    } elseif ( $_POST['billing_field_259'] == 'Rentner' ) {
        $fields['employed_as'] = 'pensioner';
    } elseif ( $_POST['billing_field_259'] == 'Arbeitsloser' ) {
        $fields['employed_as'] = 'unemployed';
    } else ( $_POST['billing_field_259'] == 'Auszubildender' ) {
        $fields['employed_as'] = 'trainee';
        
    } endif;
 

Mohammad

مدیر انجمن
پرسنل مدیریت
اون Endif اخر لزومی نداره باشه...

 

hadoo

تازه وارد
کد:
<?php

function theme_enqueue_styles() {
    wp_enqueue_style( 'avada-parent-stylesheet', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

function hsf_lang_setup() {
	$lang = get_stylesheet_directory() . '/languages';
	load_child_theme_textdomain( 'storex', $lang );
}
add_action( 'after_setup_theme', 'hsf_lang_setup' );



require_once( 'class-Maxda-API.php' );

add_action('woocommerce_checkout_process', 'maxda_order', 10, 1);
function maxda_order() {
    /*
    $items = WC()->cart->get_items();
    foreach ($items as $item) {
        // Do something clever
    }
    */


    error_log( print_r( $items ,true) );
    error_log( print_r( $_POST ,true) );
    
    $fields = array();
    if ( $_POST['billing_field_701'] == 'Herr' ) {
        $fields['gender'] = 'male';
    } else {
        $fields['gender'] = 'female';
    }
    $fields['firstname'] = $_POST['billing_first_name'];
    
    $fields['lastname'] = $_POST['billing_last_name'];
    
    $fields['address'] = $_POST['billing_field_362'];
    
    $fields['zipcode'] = $_POST['billing_field_372'];

    $fields['city'] = $_POST['billing_field_628'];
    
    $fields['birthdate'] = $_POST['billing_field_828'] . '-' . $_POST['billing_field_776'] . '-' . $_POST['billing_field_76'];
    
    $fields['email'] = $_POST['billing_email'];
    
    $fields['phone'] = $_POST['billing_phone'];

    $fields['phone_alt'] = $_POST['billing_field_192'];
    
    if ( $_POST['billing_field_259'] == 'Arbeitnehmer' ) {
        $fields['employed_as'] = 'employee';
    } else if ( $_POST['billing_field_259'] == 'Beamter' ) {
        $fields['employed_as'] = 'official';
    } else if ( $_POST['billing_field_259'] == 'Selbstständiger' ) {
        $fields['employed_as'] = 'freelancer';
    } else if ( $_POST['billing_field_259'] == 'Arbeiter' ) {
        $fields['employed_as'] = 'worker';
    } else if ( $_POST['billing_field_259'] == 'Rentner' ) {
        $fields['employed_as'] = 'pensioner';
    } else if ( $_POST['billing_field_259'] == 'Arbeitsloser' ) {
        $fields['employed_as'] = 'unemployed';
    } else if ( $_POST['billing_field_259'] == 'Auszubildender' ) {
        $fields['employed_as'] = 'trainee';
    }endif;
        
    $fields['employer'] = $_POST['billing_field_431'];
    
    $fields['employed_since'] = $_POST['billing_field_766'] . '-' . $_POST['billing_field_143'];

    $fields['net_income'] = $_POST['billing_field_970'];
    
    $fields['additional_income'] = $_POST['billing_field_573'];
    
    $fields['rent'] = $_POST['billing_field_232'];

    if ( $_POST['billing_field_391'] == 'Ja' ) {
        $fields['realty'] = 'yes';
    } else {
        $fields['realty'] = 'no';
    }

    
    if ( $_POST['billing_field_992'] == 'deutsch' ) {
        $fields['nationality'] = 'entweder';
    } else {
        $fields['nationality'] = 'oder';
    }
    
    $fields['marital_status'] = $_POST['billing_field_316'];
    
    if ( $_POST['billing_field_316'] == 'ledig' ) {
        $fields['marital_status'] = 'single';
        
    } else if ( $_POST['billing_field_316'] == 'verheiratet' ) {
        $fields['marital_status'] = 'married';
        
    } else if ( $_POST['billing_field_316'] == 'verwitwet' ) {
        $fields['marital_status'] = 'widowed';
        
    } else if ( $_POST['billing_field_316'] == 'geschieden' ) {
        $fields['marital_status'] = 'divorced';
        
    } else if( $_POST['billing_field_316'] == 'getrennt lebend' ) {
        $fields['marital_status'] = 'separated';
    }end if;
    

    
    $fields['children'] = $_POST['billing_field_834'];
    
    
    

    
    // TODO all fields
    
    $response = MaxdaAPI::createRequestMaxda( $fields );
    if ( is_wp_error( $response ) ) {
        error_log( print_r( $response, true ) );
        throw new Exception( __( 'An error occurred, please try again later.', 'storex' ) );
    }

    $responseCode = wp_remote_retrieve_response_code( $response );
    if ( $responseCode != 201 ) {
        error_log( print_r( $response, true ) );
        throw new Exception( wp_remote_retrieve_response_message( $response ) );
    }

    $responseBody = json_decode(  wp_remote_retrieve_body( $response ) );
}
 

hadoo

تازه وارد
اين كد كامل function.php بندس ولي وقتي آپلودش ميكنم سايت از كار ميفته ميشه لطفا راهنمايي كنيد؟

با تشكر

 

Qalekhani

قلعه‌خانی
ساختار صحیح استفاده از if و else به این صورت هست:

<?php
if ($a > $b) {
echo "a is greater than b";
} else {
echo "a is NOT greater than b";
}
?>


لزومی به عبارت endif نداره. اطلاع بیشتر در 

 

hadoo

تازه وارد
ساختار صحیح استفاده از if و else به این صورت هست:

<?php
if ($a > $b) {
echo "a is greater than b";
} else {
echo "a is NOT greater than b";
}
?>


لزومی به عبارت endif نداره. اطلاع بیشتر در 
میشه لطفآ این کد رو تصحیح کنید برای من؟

اين كد كامل function.php منه ولي وقتي آپلودش ميكنم سايت از كار ميفته ميشه لطفا راهنمايي كنيد؟

 
بالا