I am wondering with what mechanisms it would be possible to add a warning message to anonymous users viewing their cart saying: "Please log in with any of the listed services in order to proceed to checkout".

If possible I'd like to avoid changing the module's code in order to avoid future update problems.

Thanks for any help, Best


The easiest way is overriding a default cart page template (cart page has been created with Views module, name - 'commerce_cart_form', display - 'default');

  1. Create a template for Style Output
  2. Copy the content of it
  3. Views module provides logged_in variable in template_preprocess_views_view(&$vars) function, so you can check with that variable and display a text;

example (views-view-table--commerce-cart-form--default.tpl.php):

<?php if (!$logged_in): ?>
<?php endif; ?>

<table <?php if ($classes) { print 'class="'. $classes . '" '; } ?><?php print $attributes; ?>>
  // Rest of code from Style Output
| improve this answer | |
  • Hi, thanks for your quick answer! I have found the view, and figure that I could add the message, right? Unfortunately I'm totally lost on the first step: Create template for Style Output. Since I dont know what it is I don't find where I could do that. – dmeu Sep 22 '14 at 16:29
  • @dmeu Open the 'Commerce cart form' in Views UI, expand Advanced section, open Theme:Information, copy the last template suggestion from Style Output section, paste it into your theme's folder (views-view-table--commerce-cart-form--default.tpl.php), click the StyleOutput link again, copy the code and put it into your created file, save the view, clear the cache, that's it. After that you can modify that template as I mentioned above. – xurshid29 Sep 22 '14 at 16:50
  • @dmeu Here is a video which shows how to theme a views.. – xurshid29 Sep 22 '14 at 16:55
  • Ok, thanks for the explanation, found it! Very useful. Meanwhile I have discovered the php views module which enables me to add your proposed code as a field in the footer. Thanks for your help! – dmeu Sep 22 '14 at 17:16

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.