0

I need to display a message on the cart page if one or more specific SKUs are added to the cart.

For example, if a product with SKU # ABC123 is added to the cart, the Rule should be triggered and thus display a message... if a product with SKU # XYZ789 is added to the cart, the Rule would not be triggered and no message would be displayed.

It seems like this should be a fairly simple function, but for the life of me I cannot find a way to accomplish this. Can anyone please point me in the right direction?

Thanks!

  • The closest I can get so far is to use the "Customer starts checkout" event and the "Check an order's products" condition. This does allow the Rule's Actions to commence, but they do so on the Checkout page... not on the desired Cart page location. – hockey2112 Jan 22 '18 at 22:25
  • Do you only want this message to display once or every time the /cart page is hit for the current user? – erier Jan 23 '18 at 16:19
  • @erier Preferably display it every time for the current user, as long as one of the qualifying products is in the cart. – hockey2112 Jan 23 '18 at 20:25
0

This answer does not use Rules, but rather hard-coding inside of the cart template.

As the message should be displayed each time the user is on the /cart page, something like this might work. If page--cart.tpl.php doesn't exist, create it and add ...

$items = uc_cart_get_contents();
foreach($items as $item) {
    if($item->model == 'ABC123') {
        drupal_set_message('Item ABC123 is in the cart');
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.