Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • The problem here is this code in frontend.js that tells the form to display or not.

    if($('#product-'+pro_id).is('.outofstock') || $('#product-'+pro_id).is('.onbackorder')){
      $('.alert_container').css('display', 'block');
    }else{
      $('.alert_container').css('display', 'none');
    }

    The div doesn’t exist on a custom generated product page in Divi.

    So I created the following function to recreate that code.

    /**
     * Make product div
     *
     * Create a product div for WooCommerce Product Stock Alert
     * js functions to hook into.
     *
     * @return string
     */
    function my_product_div() {
    	global $product;
    
    	return '<div id="product-' . get_the_ID() . '" class="' . esc_attr( implode( ' ', wc_get_product_class( '', $product ) ) ) . '" style="display:none"></div>';
    }
    
    add_shortcode( 'my_wc_product_div', 'my_product_div' );

    Add that to your child functions.php and in Divi add a code module containing:

    [my_wc_product_div]
    [display_stock_alert_form]
    • This reply was modified 3 years, 5 months ago by louisatwork.
    • This reply was modified 3 years, 5 months ago by louisatwork.
    Thread Starter louisatwork

    (@louisatwork)

    Thats’s fine thanks for the answer.

    The likely reason this occurs when a site is migrated is because the path or domain has changed. Some data is stored in the database in php serialized format. The serialized data contains character counts. Most migration tools perform a simple find and replace in the database and this means the character count no longer matches the actual number of characters rendering the serialized data void.

    To fix this you could manually change the counts to be the right number of characters however there’s some room for human error there, you could code this with some PHP. However a quick solution is to extract the problem data and paste it into a fixer website, fix it then replace it in the database. I used this one (not affiliated to this – it’s a mess but worked), https://puvox.software/tools/serialization-fixer

    So the process is:

    SELECT * FROM wp_options where option_name = 'woocommerce_helper_data';

    Copy the result in the option_value field.

    Use a site or PHP to fix the serialization.

    Update the option_value where option_name = ‘woocommerce_helper_data’ in the wp_options table with the fixed data.

    • This reply was modified 3 years, 6 months ago by louisatwork.
    • This reply was modified 3 years, 6 months ago by louisatwork.
Viewing 3 replies - 1 through 3 (of 3 total)