I need to rewrite default view - commerce_cart_form, because of my design of /cart page. So, I've created file views-view--commerce-cart-form.tpl.php and try to repeat something like on original /cart page were. I can print all needed information about line items in cart, but I don't know how to create "Update" button, to change quantity which I typed in textfield with quantity of line item. That's why I want to get help with this.

I use Drupal Commerce 7.x-1.9

Many thanks in advance!

  • view - commerce_cart_form is a view. Why don't you edit the view? You can change the output in many ways with Views GUI... – Kojo Sep 11 '14 at 20:24
  • I need to add some divs on that page. So, it is easier to write my own view template file. – ihateubercart Sep 11 '14 at 20:33
  • If I get you right, I need to write in views-view--commerce-cart-form.tpl.php file something like this: echo "<div class='title_page_view'>In cart</div>"; $name = "commerce_cart_form"; echo views_embed_view($name, $display_id = 'default'); Am I right? – ihateubercart Sep 11 '14 at 21:03
  • Not a good idea in fact. I posted an answer instead. – Kojo Sep 12 '14 at 9:09

Assuming that you want to display the full view result and add some extra content to your cart, put the following lines in a file named views-view--commerce-cart-form.tpl.php :

if($view->current_display == 'default'){//OR your display
  print $rows;
  print '<div>MY CUSTOM CONTENT</div>';

Check views-view.tpl.php doc to see available variables.

Otherwise, have a look at Commerce Cart View Override :

This module provides the ability to override the default cart page view for Drupal Commerce.

  • Thanx a lot!!! That is exactly what I wanted!! – ihateubercart Sep 12 '14 at 16:11

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.