Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1422167

    Hello,

    I would like to add the submenu shown on this page – https://wordpress-225877-3679670.cloudwaysapps.com/ to the individual woocommerce product pages. Is there a way to achieve this?

    #1422200

    Hey bbertuzzi7,

    Thank you for the inquiry.

    You can use a template hook to insert additional content in the product pages.

    Example:

    function ava_woocommerce_before_main_content() {
    	if ( is_product() ) { 
                 echo do_shortcode('[av_breadcrumbs]');
        	}
    }
    add_action( 'woocommerce_before_main_content', 'ava_woocommerce_before_main_content', 10 );
    

    To insert the same submenu, you can extract the element’s shortcode and then use it as the value for the do_shortcode function above. First, to extract the shortcode, you need to set the builder to debug mode.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#debug-mode

    Once debug mode is enabled, you’ll find the shortcode field below the Advanced Layout Builder. Simply copy the submenu shortcode and paste it as the value for the do_shortcode function above.

    Best regards,
    Ismael

    #1422235

    Thank you. I have enabled debug mode and I see the shortcode for the sub menu. My question is, where do I put that template hook? In the functions.php or in the single page template for a woocommerce product? I am also confused as to how much of the shortcode to put into the function. In debug mode, this is the shortcode that I see:

    [av_submenu which_menu='' menu='49' position='left' sticky='aviaTBsticky' color='alternate_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='' custom_class='' template_class='' av_uid='av-lnbxc8ss' sc_version='1.0']
    [av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-fdyw7' sc_version='1.0']
    [av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-70t2n' sc_version='1.0']
    [/av_submenu]

    Should I be grabbing all of that shortcode and adding it to the function?

    #1422324

    Hi,

    Thank you for the update.

    You have to copy the whole av_submenu shortcode including av_submenu_item and use it as the value of the do_shortcode function. The snippet should go to the functions.php file, preferably in the child theme.

    Best regards,
    Ismael

    #1422423

    This is the code that I inserted into the functions.php it caused a critical error on my site:

    /**
    * add submenu to product pages
    */
    function ava_woocommerce_before_main_content() {
    if ( is_product() ) {
    echo do_shortcode(‘[av_submenu which_menu='' menu='49' position='left' sticky='aviaTBsticky' color='alternate_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='' custom_class='' template_class='' av_uid='av-lnbxc8ss' sc_version='1.0']
    [av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-fdyw7' sc_version='1.0']
    [av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-70t2n' sc_version='1.0']‘);
    }
    }
    add_action( ‘woocommerce_before_main_content’, ‘ava_woocommerce_before_main_content’, 10 );

    Can you please let me know where the issue is? I’m just learning PHP and am not sure where the error is at. Thank you.

    #1422487

    Hi,
    Please note that your shortcode is using single quote marks:
    Enfold_Support_3684.jpeg
    so you need to use a double quote marks after echo do_shortcode( that wrap the inner shortcode:
    Enfold_Support_3686.jpeg
    and you can’t have any line breaks, try this code:

    function ava_woocommerce_before_main_content() {
    if ( is_product() ) {
    echo do_shortcode("[av_submenu which_menu='' menu='49' position='left' sticky='aviaTBsticky' color='alternate_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='' custom_class='' template_class='' av_uid='av-lnbxc8ss' sc_version='1.0'][av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-fdyw7' sc_version='1.0'][av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-70t2n' sc_version='1.0']");
    }
    }
    add_action( 'woocommerce_before_main_content', 'ava_woocommerce_before_main_content', 10 );

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.

    Best regards,
    Mike

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