• I have looked for the documentation but cannot find it.

    We have a few custom fields and would like to display that data in the front-end overview table.

    we looked at the displaycustomfieldstofrontend function, but are unable to figure out how to pull that data into the table for the specific ticket.

    can you copy/paste the code i would use to enable this? thanks

    https://www.ads-software.com/plugins/wpsc-support-tickets/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author jquindlen

    (@jquindlen)

    You’ll want to copy the wpsctDisplayCustomFieldsToFrontend() function you mentioned and name it a new function that spits out the data you want, where you want it. Get rid of the table code inside the function, and use $specific_items[0] for the custom field name, and strip_tags(base64_decode($res[0][‘value’])) for the value.

    Thread Starter geohi

    (@geohi)

    Hmm.. ok. still having some issues. maybe you can help since youre the author ??

    Heres our new function:

    function wpsctDisplayCustomFieldsToFrontenda($primkey) {
        global $wpdb;
        // Custom fields
        $table_name33 = $wpdb->prefix . "wpstorecart_meta";
        $grabrecord = "SELECT * FROM <code>{$table_name33}</code> WHERE <code>type</code>='wpst-requiredinfo' ORDER BY <code>foreignkey</code> ASC;";
        $resultscf = $wpdb->get_results( $grabrecord , ARRAY_A );
        if(isset($resultscf)) {
                echo '<table style="width:100%;"><tbody>';
                foreach ($resultscf as $field) {
                    $specific_items = explode("||", $field['value']);
                    $res = $wpdb->get_results("SELECT * FROM <code>{$table_name33}</code> WHERE <code>type</code>='wpsct_custom_{$field['primkey']}' AND <code>foreignkey</code>='{$primkey}';", ARRAY_A);
                    if(@isset($res[0]['primkey'])) {
                        echo '<tr><td><p style="display:inline;color:red;font-weight:700;">'.$specific_items[0].':</p> '.strip_tags(base64_decode($res[0]['value'])).'</td></tr>';
                    }
                }
                echo '</tbody></table>';
        }
    }

    and are using strip_tags(base64_decode($res[0][‘value’])) where want the data to be shown.

    the database field is called “StatuteExpiry”

    any suggestions?

    Plugin Author jquindlen

    (@jquindlen)

    if you’re only looking to display the field “StatuteExpiry” then change this line:

    if(@isset($res[0]['primkey'])) {

    to this

    if(@isset($res[0]['primkey']) && $specific_items[0]=="StatuteExpiry") {

    the inside of that if statement should probably only echo the value like this:

    if(@isset($res[0]['primkey']) && $specific_items[0]=="StatuteExpiry") {
        echo strip_tags(base64_decode($res[0]['value']));
    }

    or something like that. I haven’t tested this, but I think it should point you in the right direction. Let me know how it goes if you have any other questions.

    EDIT: and get rid of the table code that is before and after the foreach loop.

    Thread Starter geohi

    (@geohi)

    you’re awesome… im going to give this a shot. one thing, however. the value of the custom field is actually Statute Expires||optional||input (text)

    how should i write that out?

    and im trying to see from the code how it will pull the data from that field knowing all the primkeys and foreignkeys are subsequent?

    Thread Starter geohi

    (@geohi)

    Ok… here’s the whole function

    function wpsctDisplayCustomFieldsToFrontenda($primkey) {
    
        global $wpdb;
    
        // Custom fields
    
        $table_name33 = $wpdb->prefix . "wpstorecart_meta";
    
        $grabrecord = "SELECT * FROM <code>{$table_name33}</code> WHERE <code>type</code>='wpst-requiredinfo' ORDER BY <code>foreignkey</code> ASC;";
    
        $resultscf = $wpdb->get_results( $grabrecord , ARRAY_A );
    
        if(isset($resultscf)) {
    
                foreach ($resultscf as $field) {
    
                    $specific_items = explode("||", $field['value']);
    
                    $res = $wpdb->get_results("SELECT * FROM <code>{$table_name33}</code> WHERE <code>type</code>='wpsct_custom_{$field['primkey']}' AND <code>foreignkey</code>='{$primkey}';", ARRAY_A);
    
                   if(@isset($res[0]['primkey']) && $specific_items[0]=="wpst-requiredinfo") {
        echo strip_tags(base64_decode($res[0]['value']));
    }
                }
    
        }     
    
    }

    and here’s how im trying to display it down below:

    base64_decode($res[0]['value'])

    but im still not getting anything to show. no errors though. which fieldname/value am i supposed to be using from the DB?

    Plugin Author jquindlen

    (@jquindlen)

    You’d be looking for “Statute Expires” in the code instead of “StatuteExpires” as I posted above. Like I said in the email you sent though, if you can help me out on this dinner date, I’ll get this code done for you tomorrow ?? I’ll still help you here regardless.

    Thread Starter geohi

    (@geohi)

    You’re awesome! So everything else looks correct other than “Statute Expires”?

    I didn’t get an email back from you… Sure you sent it to the right address? I’d be glad to help any way I can, boss!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Displaying custom fields help’ is closed to new replies.