-1

i'm testing the Short Code show Notice on front-end when user interact with the form . The logic simply as : user type in 2 test box ("Insert active code here :" & "Insert Order ID: ") on form and press "Active complete order" button . The program will find data in SQL if true or false will show notice at bellow the form. Could You have check my code , it's not working . what's my wrong. thank a lot your helps.enter image description here

function active_code(){
    global $inform;
    echo '<form method="post">';
    echo '<label for="active_code">Insert active code here : </label>';
    echo '<input type="text" id="active_code" name="active_code" /> ';
    echo  '<label for="id-order">Insert Order ID: </label>';
    echo '<input type="text" id="id_order" name="id_order"/> ';
    echo '<input type="submit" id="activecodesubmit" name="activecodesubmit" value="Active Complete Order" />';
    echo '</form>';
    return;
    echo $inform;

}
//Check Query match with active code and order id in postmeta
function check_query(){
    global $inform;
    global $wpdb;
    if ( !$_POST['activecodesubmit']){
        return;
    }
    else {
    $activecode = $_POST['active_code'];
    $idorder = $_POST['id_order'];
    //checking after press checking order
    $countid = $wpdb->get_var("SELECT Count(*) from {$wp->prefix}woocommerce_order_items where order_id=$idorder");
    $countactive = $wpdb->get_var("SELECT count(*) from {$wp->prefix}postmeta where meta_value = $activecode");
        if ($countid >0 && $contactive > 0) {
            return $inform = "Order Actived" ;          
        }
        else {
            return $inform = "wrong order id or active code" ;
        }
        
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.