Support » Plugin: WooCommerce Gift Coupon » Database table missing

  • After installing the plugin I get an error message on the woocommerce orders page that the gift coupon database table doesn’t exist?

    WordPress databasfel: [Table ‘klickerforlaget.s5s8zrr_woocommerce_gift_coupon’ doesn’t exist]
    SELECT * FROM s5s8zrr_woocommerce_gift_coupon WHERE id_order=63412

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter agrolsy

    (@agrolsy)

    when I try to create it manually using the sql from the plugin I get the following error message

    CREATE TABLE IF NOT EXISTS wp_woocommerce_gift_coupon(
    id_user BIGINT(20) UNSIGNED NOT NULL,
    id_coupon BIGINT(20) UNSIGNED NOT NULL,
    id_order BIGINT(20) UNSIGNED NOT NULL,
    KEY woocomerce_key_user_generate_coupons (id_user),
    KEY woocomerce_key_coupon_generate_coupons (id_coupon),
    KEY woocomerce_key_order_generate_coupons (id_order),
    FOREIGN KEY (id_user) REFERENCES wp_users(ID) ON DELETE CASCADE,
    FOREIGN KEY (id_coupon) REFERENCES wp_posts(ID) ON DELETE CASCADE,
    FOREIGN KEY (id_order) REFERENCES wp_woocommerce_order_items(order_id) ON DELETE CASCADE
    )CHARACTER SET utf8 COLLATE utf8_general_ci

    #1005 – Can’t create table wp_woocommerce_gift_coupon (errno: 150 “Foreign key constraint is incorrectly formed”)

    Hi agrolsy, I stumbled over this too.

    problem is there are two bugs in the sql querry:

    When you open the woocommerce-gift-coupon.php you have to change it like that:

    $sql = ‘CREATE TABLE IF NOT EXISTS ‘ . $table . ‘(
    id_user BIGINT(20) UNSIGNED NOT NULL,
    id_coupon BIGINT(20) UNSIGNED NOT NULL,
    id_order BIGINT(20) UNSIGNED NOT NULL,
    KEY woocomerce_key_user_generate_coupons (id_user),
    KEY woocomerce_key_coupon_generate_coupons (id_coupon),
    KEY woocomerce_key_order_generate_coupons (id_order),
    FOREIGN KEY (id_user) REFERENCES ‘ . $wpdb->base_prefix . ‘users(ID) ON DELETE CASCADE,
    FOREIGN KEY (id_coupon) REFERENCES ‘ . $wpdb->prefix . ‘posts(ID) ON DELETE CASCADE,
    FOREIGN KEY (id_order) REFERENCES ‘ . $wpdb->prefix . ‘woocommerce_order_items(order_id) ON DELETE CASCADE
    )CHARACTER SET utf8 COLLATE utf8_general_ci’;

    1. I changed the way $table is set as otherwise you just create a table named “$table”
    2. I changed the database prefix for the user table $wpdb->base_prefix . ‘users(ID). This is because for multisites there is not extra user table. All use the base-sites user table. Thus the prefix has to link to the base table.

    Btw: I guess your manual creation did fail bc your wordpress db prefix seems “s5s8zrr” but you tried it with: “wp”

    cheers!

    I got the exact same problem since migration from one server to another one.

    Erreur de la base de données WordPress : [Table ‘AAAAA_AAAAA.ap_woocommerce_gift_coupon’ doesn’t exist]
    SELECT * FROM ap_woocommerce_gift_coupon WHERE id_order=3568

    The strange thing is that, I can still reach the old hosting, and no bug : but the two database look exactly the same : in the old one, the no ap_woocommerce_gift_coupon table, but it works.

    I tried to put the code of rollinsforge int he php file, but white page appears. May be I didn’t undestand what to do with this code. Anyway, it’s working in the other hosting. Why not in the new ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Database table missing’ is closed to new replies.