Tags/topics: 
2
Answers
Vote up!
0
Vote down!

how do I get line item quantity to link to cart in shopping cart view in user bar second?

Hi-

Thanks for Drupal Commerce.

I started with Commerce Kickstart profile and have moved to a fresh non-CK profile install of Commerce.

I have been able to copy over almost all of the theming I want from Commerce Kickstart to my Omega Kickstart theme on the fresh install.

What I can't figure out is how to get the line item quantity to be a link to cart.
And my Checkout link links to Checkout, but in the CK demo it links to cart as well.

If you go this demo:

http://demo.commerceguys.com/ck/

and add a product to cart. Take a look a the Shopping Cart view at the top of the screen. The line item count AND Checkout button both link to /ck/cart. When I edit the View nothing seems to add a link to Cart from the item count.

Any help?

Thanks,

Michael

Asked by: luckydad
on December 3, 2012

2 Answers

Vote up!
2
Vote down!

I was wondering the same thing, so I dug around in the Kickstart code and found the relevant stuff in the Product UI module. To implement this, I did the following:

1) Copied the commerce-line-item-summary.tpl.php file from the commerce_kickstart_product_ui/theme folder to a theme folder in my custom module ("MYMODULE")

2) Adding the following functions to my custome module:

/**
* Implements hook_theme_registry_alter().
*/
function MYMODULE_theme_registry_alter(&$theme_registry) {
  // Remove cart block total label & add cart link on item.
  $theme_registry['commerce_line_item_summary']['path'] = drupal_get_path('module', 'MYMODULE') . '/theme';
  $theme_registry['commerce_line_item_summary']['template'] = 'commerce-line-item-summary';
}

/**
* Implements hook_preprocess_HOOK().
* Link cart block items to cart.
*/
function MYMODULE_preprocess_commerce_line_item_summary(&$variable) {
  $variable['cart_items'] = l($variable['quantity'], 'cart', array('attributes' => array('class' => array('line-item-quantity'))));
}

You would need to replace "MYMODULE" with the actual name of your custom module. Plus, you need a custom module to put this code in. :) This works perfectly for me, though, and replicates that cart block functionality of Kickstart.

Answer by: foxylearning
Posted: Dec 7, 2012

Comments

Thanks Foxylearning. Those instructions were clear and worked perfectly for me in my D7 / Kickstart build

- paultrotter50 on November 12, 2013
Vote up!
0
Vote down!

Digging up an old post here... Has anyone figured out how to do this without creating a custom module? It seems like there must be a way that's built in. But right now clicking on the blue text "# items" doesn't link me to anything, and clicking on "checkout" links me to my cart in Omega Kickstart. I would like clicking on "# items" to link to cart, and clicking on "checkout" to actually link to checkout.

Answer by: fortozs
Posted: Sep 11, 2013