Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #407634

    Hi there,

    Is there a way to add some php to the single-content.php in woo to display a custom menu?
    I build separate pages for my products and I don’t want single product to be linked to categories but to custom subpages :

    Food (page) –> Drinks (subpage), Meat (subpage).

    I duplicated the content-single-product.php and single-product.php and created content-single-product-food.php and single-product-food.php

    I’d like to call for a custom menu on content-single-product-food.php

    I can deal with styling myself but how to add the custom menu I created for FOOD.

    Thanks!

    #408151

    Hi Smaskit6!

    Thank you for using Enfold.

    You can use woocommerce hooks and filters to insert a new element such as a drop down menu inside a single product page. Maybe, you can use the Fullwidth Sub Menu shortcode and the do_shortcode function. Refer to this link for more info: http://docs.woothemes.com/document/hooks/

    Cheers!
    Ismael

    #408532

    Ismael,

    Thanks much! It shows up but messes up the styling and even some layout on woo single.

    I added this : <?php echo do_shortcode(‘[av_submenu menu="781" position="center" color="main_color" sticky="aviaTBsticky" custom_class=""]‘); ?>

    to my custom content-single-product-food.php

    <?php
    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly
    ?>
    <?php echo do_shortcode(‘[av_submenu menu="781" position="center" color="main_color" sticky="aviaTBsticky" custom_class=""]‘); ?>
    <?php
    /**
    * woocommerce_before_single_product hook
    *
    * @hooked wc_print_notices – 10
    */
    do_action( ‘woocommerce_before_single_product’ );

    if ( post_password_required() ) {
    echo get_the_password_form();
    return;
    }
    ?>

    Should I add something to CLEAR it so it does not affect the styling/layout (4 columns become 3) on single product?

    #409603

    Hey!

    If you don’t need a full width menu i’d suggest using wp_nav_menu instead (if you need an example on how to use check includes/helper-main-menu.php:130).

    Regards,
    Josue

    #410078

    Hi Ismael,

    I’m so lost..
    I feel like it should be easy but it’s not.

    The menu on single custom category items stopped showing up so I need to redo it.

    Questions :

    1. I read I should copy the woocommerce folder from plugins to theme and this is where I would overwrite the behavior.
    Is it where I should be doing it instead of woocommerce/plugins/templates ?

    2. Can you walk me through HOW TO DISPLY the menu (full width or not, don’t care..) on my custom single products?

    So, if I have a custom page : FOOD and I want to display that custom menu on single FOOD items how would I do it…?
    What php code on which template?

    I’m really confused. I know you don’t have to help out with woo but I’d so appreciate it!
    Thanks much!

    #410200

    So, I’m trying…

    I’ve decide to add this to : woocommerce/template/single-product.php
    <?php while ( have_posts() ) : the_post(); ?>
    <?php
    if (is_product(‘Food’)) {
    wc_get_template_part ( ‘content’, ‘single-product-food’ );
    }else{
    wc_get_template_part ( ‘content’, ‘single-product’ );

    } ?>
    <?php endwhile; // end of the loop. ?>

    and this to : woocommerce/template/content-single-product-food.php

    <?php
    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly
    ?>
    <div class=”singlefoodsmenu”>
    <?php wp_nav_menu( array(‘menu’ => ‘Cards’ )); ?>
    </div>

    ——
    The menu shows up on all categories… not just Food
    if (is_product(‘Food’)) {

    How do I state this on woocommerce/template/single-product.php
    so my content from contact-single-product-foods.php (or whatever category) shows up on single categories I choose instead on all…

    ps. This is just me testing with minimal php knowledge.
    If you have an idea (Josue, Ismael) how to do it properly, please let me know. Thanks much!

    #410258

    Hi,

    Can you post the link to your website please? admin access may be needed too.

    Regards,
    Josue

    #410264
    This reply has been marked as private.
    #410382

    Hi!

    I didn’t find any “food” category on the website you posted, can you point where exactly it is?

    Best regards,
    Josue

    #410545
    This reply has been marked as private.
    #410659

    Hey!

    Use this (put in functions.php):

    function add_menus_to_single_products() {
    	if( has_term('Cards', 'product_cat') ){
    
    		wp_nav_menu( array('menu' => 'Cards Menu' )); 
    
    	}elseif( has_term('Music', 'product_cat') ){
    
    		wp_nav_menu( array('menu' => 'Music Menu' )); 
    
    	}elseif( has_term('Books', 'product_cat') ){
    
    		wp_nav_menu( array('menu' => 'Books Menu' )); 
    		
    	}else{
    
    	}
    
    }
    add_action('woocommerce_before_single_product', 'add_menus_to_single_products');

    That’s a hook to the single product view that will render a specific menu if that product is in a certain category.

    Regards,
    Josue

    #410674

    You’re a genius, Josue! Thanks a million!!!! :))))
    Have a great day!

    #410728

    You are welcome, always glad to help :)

    Regards,
    Josue

    #410784
    This reply has been marked as private.
    #410785
    This reply has been marked as private.
    #410787
    This reply has been marked as private.
    #410811

    Hi,

    Can you please create me a temporary FTP account or enable file editing from the Dashboard?

    Regards,
    Josue

    #410812
    This reply has been marked as private.
    #410822

    Hey!

    The code is working as expected, you needed to clear the cache and change the code, you need to change each category and set their respective menus (and repeat as needed):

    function add_menus_to_single_products() {
    
    	if( has_term('cards', 'product_cat') ){
    		wp_nav_menu( array('menu' => 'Cards Menu', 'container_class' => 'single_product_menu' )); 
    
    	}elseif( has_term('music', 'product_cat') ){
    		wp_nav_menu( array('menu' => 'Pixia Main Menu', 'container_class' => 'single_product_menu'  )); 
    
    	}elseif( has_term('books', 'product_cat') ){
    		wp_nav_menu( array('menu' => 'Books Menu', 'container_class' => 'single_product_menu'  )); 
    		
    	}else{
    
    	}
    
    }
    add_action('woocommerce_before_single_product', 'add_menus_to_single_products');

    Here’s this product for example (which is under Music), you’ll see that the Pixia Main menu shows (as set in the code).

    Regards,
    Josue

    • This reply was modified 9 years, 9 months ago by Josue.
    #410828
    This reply has been marked as private.
    #410830

    Aaaa…thank you thank you Josue! So much.
    You’ve been incredibly helpful and the support is amazing!

    #410896

    You are welcome, glad to help :)

    Best regards,
    Josue

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