Database, and WooCommerce Sign Up?

Currently i have WooCommerce and these are this is the code to add this information to the database I’m using wordpress and for some reason its submitting but not adding them to the database, something is wrong and its not working but not sure why? can anyone direct whats going wrong?

    $billing_first_name = $wpdb->escape(trim($_POST['billing_first_name']));
    $billing_last_name = $wpdb->escape(trim($_POST['billing_last_name']));
    $billing_company = $wpdb->escape(trim($_POST['billing_company']));
    $billing_address_1 = $wpdb->escape(trim($_POST['billing_address_1']));
    $billing_address_2 = $wpdb->escape(trim($_POST['billing_address_2']));
    $billing_city = $wpdb->escape(trim($_POST['billing_city']));
    $billing_postcode = $wpdb->escape(trim($_POST['billing_postcode']));
    $billing_state = $wpdb->escape(trim($_POST['billing_state']));
    $billing_country = $wpdb->escape(trim($_POST['billing_country']));
    $billing_phone = $wpdb->escape(trim($_POST['billing_phone']));
    $billing_email = $wpdb->escape(trim($_POST['billing_email']));
    $shipping_first_name = $wpdb->escape(trim($_POST['shipping_first_name']));
    $shipping_last_name = $wpdb->escape(trim($_POST['shipping_last_name']));
    $shipping_company = $wpdb->escape(trim($_POST['shipping_company']));
    $shipping_address_1 = $wpdb->escape(trim($_POST['shipping_address_1']));
    $shipping_address_2 = $wpdb->escape(trim($_POST['shipping_address_2']));
    $shipping_city = $wpdb->escape(trim($_POST['shipping_city']));
    $shipping_postcode = $wpdb->escape(trim($_POST['shipping_postcode']));
    $shipping_state = $wpdb->escape(trim($_POST['shipping_state']));
    $shipping_country = $wpdb->escape(trim($_POST['shipping_country']));

Related posts

Leave a Reply

1 comment

  1. It’s because you’re only assigning variables and not actually doing any SQL calls. I’m not sure exactly what table you’re trying to store this information in exactly, but it seems like your missing something like this:

    $wpdb->query($wpdb->prepare('insert into destination_table (col1, col2, etc...) values (%s, %s, etc...)', 'val1', 'val2', etc...));
    

    I haven’t worked with WooCommerce or seen how it stores it information, but actually inserting the data into the database seems to be what’s missing in your code. Hope this helps!