Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1084230

    So we are trying various plugins for having a product variations table on single product page in Woocommerce.
    The plugins are supposed to display these tables below the quick description/price and above the product description/more info.

    However in Enfold these tables gets added BELOW product description/more info.
    I have tried switching themes and everything works as it should but not in Enfold.
    This is an example of a plugin we want to use:

    Ni WooCommerce Product Variations Table

    Provided URL to our site with the plugin mentioned above installed.

    I think some quick custom PHP is needed in order to hook this in the default location, above the product description/more info.

    #1085659

    Hey,

    Please try adding following code to bottom of functions.php file in Appearance > Editor

    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 );
    add_action(    'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );

    Best regards,
    Yigit

    #1085723

    Thanks for your reply. The code worked ok for our pages with a product variations table.
    However, now we have a problem with all other Woocommerce product pages that are not using a product variations table.

    More info in private content

    #1087340

    Hi,

    Thanks for the update.

    You have to check if the current product is of variable type, so this code adjustment should work.

    add_action('after_setup_theme', 'ava_move_product_elements');
    
    function ava_move_product_elements() {
        global $product;
    
        if ( $product->is_type( 'variable' ) ) {
             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 );
             add_action(    'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
        }
    
        return false;
    }
    

    Best regards,
    Ismael

    #1087546

    I tried adding the code at the bottom of functions.php (First I removed the 2 lines of code from Yigit, mentioned earlier in this thread)
    But I get the following error message (and wordpress refuse to save the file):

    Uncaught Error: Call to a member function is_type() on null in wp-content/themes/enfold/functions.php:745
    Stack trace:
    #0 [internal function]: ava_move_product_elements(”)
    #1 wp-includes/class-wp-hook.php(286): call_user_func_array(‘ava_move_produc…’, Array)
    #2 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #3 wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #4 wp-settings.php(434): do_action(‘after_setup_the…’)
    #5 wp-config.php(184): require_once(‘/nas/content/st…’)
    #6 wp-load.php(37): require_once(‘/nas/content/st…’)
    #7 wp-admin/admin.php(31): require_once(‘/nas/content/st…’)
    #8 wp-admin/theme-editor.php(10): require_once(‘/nas/content/st…’)
    #9 {main}
    thrown

    • This reply was modified 5 years, 8 months ago by belinger.
    #1088115

    Hi,

    Thanks for the update.

    Try to replace this line:

     global $product;
    

    .. with:

    $product = wc_get_product( get_the_ID() );
    

    Or post the login details in the private field so that we can test it. Make sure that the Appearance > Editor panel is accessible.

    Best regards,
    Ismael

    #1089249

    Thanks for the reply, but I got the same error.
    Log in details in private content

    #1089796

    Hi,

    We adjusted the code but then we can get the same error as posted above. Please post the FTP details in the private field so that we can remove the filter. Sorry for the inconvenience.

    Best regards,
    Ismael

    #1090128

    Provided login details in private content

    #1090808

    Hi,

    Thanks for the update.

    We used a different hook and added the “wc_get_product” function to fetch the product. The code is in the functions.php file.

    add_action('wp', 'ava_move_product_elements');
    function ava_move_product_elements() {
    	$product = wc_get_product( get_the_ID() );
    
        if ( $product->is_type( 'variable' ) ) {
             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 );
             add_action(    'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
        }
    
        return false;
    }
    
    

    You may need to remove the previous custom function that we added in the plugin from your database.

    Best regards,
    Ismael

    #1092062

    Thanks again for trying to help, but did you even have a look at our website?
    Its inaccessible displaying a long error msg all over the site.
    Provided details in private content

    • This reply was modified 5 years, 8 months ago by belinger.
    #1092526

    Hi,

    We don’t see that error in the product pages. Please remove the browser’s cache, then try again. (see private field)

    Best regards,
    Ismael

    #1094537
    This reply has been marked as private.
    #1095157

    Hi,

    Thanks for the update.

    In the filter, look for this line:

    $product = wc_get_product( get_the_ID() );
    

    Above that, add this code.

    if( ! is_singular('product') ) return;
    

    That should exclude all pages except from product items.

    Best regards,
    Ismael

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.