• ssurojit

    (@ssurojit)


    We are facing issue with the updated Version 4.12.0. The site was working fine with the Version 2.22.0. Something wrong with the mysql table “wp_yith_wapo_blocks” in the given error.

    I have added the link
    https://shopcbdstg.wpenginepowered.com/product/9to5-nce-sofi-750/ where the error occurs.

    Below are the details of the site configurations:

    PHP Version: 8.2?
    MySQL Version: 8.0.36-28
    MySQL Client Version: mysqlnd 7.4.33.6
    WordPress Version: 6.5.5
    Woocommerce Version: 8.8.3
    YIITH Plugin version: 4.12.0

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

Viewing 1 replies (of 1 total)
  • Plugin Support Facundo Arano

    (@aranofacundo)

    Hi there,

    I hope you’re doing well. I checked the page you mentioned and could see the issue you mentioned, and it’s possible there was an issue when migrating from the previous version to the new one.

    In this case, I suggest you add the following PHP code in the functions.php file of your current theme:

    if ( ! function_exists( 'yith_wapo_check_db_400' ) ) {
    function yith_wapo_check_db_400() {

    // Add ?yith_addons=1 to the URL inside the admin panel will execute all the code.
    if ( isset( $_GET['yith_addons'] ) ) {

    global $wpdb;
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

    $blocks_table = $wpdb->prefix . 'yith_wapo_blocks';
    $assoc_table = $wpdb->prefix . 'yith_wapo_blocks_assoc';

    $charset_collate = $wpdb->get_charset_collate();

    // 1. BLOCKS TABLE - START
    $sql_blocks = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks (
    id INT(3) NOT NULL AUTO_INCREMENT,
    user_id BIGINT(20),
    vendor_id BIGINT(20),
    settings LONGTEXT,
    priority DECIMAL(9,5),
    visibility INT(1),
    creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    last_update TIMESTAMP,
    name varchar(255) NOT NULL,
    product_association varchar(255),
    exclude_products tinyint(1) NOT NULL,
    user_association varchar(255),
    exclude_users tinyint(1) NOT NULL,
    PRIMARY KEY (id)
    ) $charset_collate;";

    if ( function_exists( 'maybe_create_table' ) ) {
    maybe_create_table( $blocks_table, $sql_blocks );
    }

    // CREATE COLUMNS FOR BLOCKS TABLE.
    $blocks_columns = array(
    'name' => 'ALTER TABLE ' . $blocks_table . ' ADD name varchar(255) NOT NULL;',
    'product_association' => 'ALTER TABLE ' . $blocks_table . ' ADD product_association varchar(255);',
    'exclude_products' => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_products tinyint(1) NOT NULL;',
    'user_association' => 'ALTER TABLE ' . $blocks_table . ' ADD user_association varchar(255);',
    'exclude_users' => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_users tinyint(1) NOT NULL;',
    );

    foreach ( $blocks_columns as $block_column => $block_statement ){
    if ( function_exists( 'maybe_add_column' ) ) {
    maybe_add_column($blocks_table, $block_column, $block_statement);
    }
    }

    // BLOCKS TABLE - END

    // 2. BLOCKS ASSOC TABLE - START

    $sql_associations = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks_assoc (
    rule_id bigint(20) NOT NULL,
    object varchar(255) NOT NULL,
    type varchar(50) NOT NULL,
    KEY type (type),
    KEY object (object)
    ) $charset_collate;";

    if ( function_exists( 'maybe_create_table' ) ) {
    maybe_create_table($assoc_table, $sql_associations);
    }

    // CREATE COLUMNS FOR ASSOCIATION TABLE.
    $assoc_columns = array(
    'rule_id' => 'ALTER TABLE ' . $assoc_table . ' ADD rule_id varchar(255) NOT NULL;',
    'object' => 'ALTER TABLE ' . $assoc_table . ' ADD object varchar(255) NOT NULL;',
    'type' => 'ALTER TABLE ' . $assoc_table . ' ADD type varchar(50) NOT NULL;',
    );

    foreach ( $assoc_columns as $assoc_column => $assoc_statement ){
    if ( function_exists( 'maybe_add_column' ) ) {
    maybe_add_column($assoc_table, $assoc_column, $assoc_statement);
    }
    }

    // BLOCKS ASSOC TABLE - END

    // 3. UPDATE OPTION - START
    update_option( 'yith_wapo_db_update_scheduled_for', '2.0.0' );
    update_option( 'yith_wapo_db_version_option', '2.0.0' );
    //UPDATE OPTION - END

    }
    }
    add_action( 'admin_init', 'yith_wapo_check_db_400' );
    }

    Then go to the following link (replace yoursite.com with the URL of the site):

    https://yoursite.com/wp-admin/admin.php?page=yith_wapo_panel&yith_addon=1

    This should create the database tables that are missing and solve the issue. Once you’re sure it’s working, you can remove the code.

    We’ll remain at your disposal.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.