WP Menu Cart
[resolved] Highlight Cart DIV when item added (3 posts)

  1. Jon Dennis
    Posted 2 years ago #

    does anyone know if it is possible to add a simple bit of jquery to this plugin, so that the div containing the menu cart, gets 'highlighted' when an item is added to the cart ?

    $(this).parent().effect("highlight", {},  5000);

    If so, where would i put this code etc ?


  2. Ewout
    Plugin Author

    Posted 2 years ago #

    Hi Jondennis,
    You can put this code in any JS file that is loaded with your theme or the WP Menu Cart plugin, but the safest / most upgrade proof (!) way is probably to output the code into the footer.

    Your example doesn't work because it's not using the correct selectors. $('input').change could be any button or text input. You'll want to use only the add to cart button class. For WooCommerce, that's .add_to_cart_button, but it depends on your eCommerce system which one you need.
    Then $(this).parent() would be the parent element of the input element. Could be anything. But you want the menu item to highlight, so you'll have to reference that element. It has a class wpmenucartli that you can use: $(".wpmenucartli").

    Putting everything together:

    add_action('wp_footer', 'wpmenucart_highlight_item');
    function wpmenucart_highlight_item(){
    <script type="text/javascript">
    jQuery(document).ready(function($) {
      $(".add_to_cart_button, .edd-add-to-cart, .wpsc_buy_button, .eshopbutton, div.cartopt p label.update input#update").click(function(){
        $(".wpmenucartli").effect("highlight", {},  5000);

    Now I don't have jQuery UI installed but it should work (I tested with another function after $(".wpmenucartli").

  3. Jon Dennis
    Posted 2 years ago #

    Brilliant. Thank you. That worked a charm!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Menu Cart
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.