• Resolved sinergiostijn

    (@sinergiostijn)


    Hello

    First of all, the plugin is looking great!

    I’m having a small issue though, is there a way to add a notice in the cart popup?

    In my shop the customer is only able to add products to the cart from one category at a time. This means that they should get a notification when they are trying to add a ‘wrong’ product.

    In my functions.php I added the following code which adds a WP notice, however it’s not showing up in the cart and the cart popup ‘acts’ as if the product was added successfully even though it wasn’t: https://pastebin.com/iHRArG4N

    So basically my question is if I can hook into something to add a Cartpops notice at the top of my cart saying ‘You can only add products of the same category’.

    Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor cartpops

    (@cartpops)

    Hey!

    We do have a few hooks here and there. I suggest checking out the plugin folder, and templates to find some hooks that might suit you.

    There’s an add_action hook that’s right above the checkout button that might help?

    cartpops_drawer_before_checkout_button or cartpops_drawer_after_checkout_button

    Thread Starter sinergiostijn

    (@sinergiostijn)

    Hi

    Thanks you for the quick response!

    At the moment I hooked into the cartpops_drawer_header_after hook, however now the notice shows at all times (I would rather show it only when necessary).

    I saw in the plugin templates that there is a folder ‘info’ which contains a file ‘error.php’. This file seems to loop over notices. Is there a way for me to add a custom notice to this loop?

    Plugin Contributor cartpops

    (@cartpops)

    Hey @sinergiostijn ,

    Sorry the late reply!

    The info.php and error.php template files are deperecated. we have since build a different notification system for add to cart, and other events. We don’t have a way to add your own notifications just yet. But there’s a filter that you can try:

    This fires right before the notification is sent back to the frontend.

    apply_filters( ‘cartpops_drawer_notice_html’, $notification );

    $notification is not an array, but just 1 notification.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add notice to cart’ is closed to new replies.