• On the primary menu, i have a sub-menu replaced by a mini-cart function, which is being commented out by the html, but it only happens on the homepage. In all the other pages, it shows correctly.

    I’m using the replace option on the mega menu, and i’m replacing with this:
    <div class=”widget_shopping_cart_content”><?php woocommerce_mini_cart(); ?></div>

    Thank you in advance.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi lpaweb,

    I think the fact it loads on the inner pages is a red herring, I think the cart contents are being loaded using ajax (because you’ve wrapped it in a div with the correct class).

    You can’t use PHP directly in the replacement options (in general, it’s not possible to use PHP like that anywhere in WordPress). Instead, you should create a custom shortcode that executes the PHP, then add the shortcode to the menu instead.

    Alternatively, looking at this comment for the function, it seems like you could just add the WooCommerce Cart widget directly to the sub menu, and that in turn will call ‘woocommerce_mini_cart()’.

    Regards,
    Tom

    Thread Starter lpaweb

    (@lpaweb)

    Hi Tom,

    Thank you for your reply.
    The thing is, it works in all other pages the way it is now. It just doesn’t work on the Homepage.

    Regards.

    Plugin Author megamenu

    (@megamenu)

    Hi lpaweb,

    I understand that, I’m not sure why (we don’t control the contents of the widgets, we let the widgets control themselves) but can you try with the Widget instead just to see if it works?

    Regards,
    Tom

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Code being commented out’ is closed to new replies.