0

I am trying to get payment_transaction_id but it doesn't work. Same code works to get info from users, I didn't understand why couldn't get the data.

This is how table created(which is working and has data in it already).

require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta($sql);
    $table_name2 = $wpdb->prefix . 'iyzico_order_refunds';
    $sql = "CREATE TABLE $table_name2 (
        iyzico_order_refunds_id INT(11) NOT NULL AUTO_INCREMENT,
        order_id INT(11) NOT NULL,
        item_id INT(11) NOT NULL,
        payment_transaction_id INT(11) NOT NULL,
        paid_price VARCHAR(50),
        total_refunded VARCHAR(50),
        PRIMARY KEY  (iyzico_order_refunds_id)
    ) $charset_collate;";
    dbDelta($sql);

And I am trying to pull transaction ID with this:

$payment_transaction_id = $wpdb->get_var( "SELECT payment_transaction_id FROM $wpdb->iyzico_order_refunds WHERE order_id=769 AND item_id=760" );

What am I doing wrong?

1
  • I think you need to use {$wpdb->prefix}iyzico_order_refunds instead of $wpdb->iyzico_order_refunds. Commented Feb 14, 2017 at 22:11

1 Answer 1

2

Prepend the table prefix to iyzico_order_refunds instead of the $wpdb object:

$payment_transaction_id = $wpdb->get_var( 
    "SELECT payment_transaction_id FROM {$wpdb->prefix}iyzico_order_refunds} WHERE order_id=769 AND item_id=760"
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.