Support » Plugins and Hacks » [Resolved] Highlight Cart DIV when item added

[Resolved] Highlight Cart DIV when item added

  • Jon Dennis


    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 ?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Ewout


    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").

    Jon Dennis


    Brilliant. Thank you. That worked a charm!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Highlight Cart DIV when item added’ is closed to new replies.