Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
do you know how to display the amount of the basket next to the number of elements?
As this page http://demo.commerceguys.com/cart
/**
* Returns the title of the shopping cart menu item with an item count.
*/
function commerce_cart_menu_item_title() {
global $user;
// Default to a static title.
$title = t('Shopping cart');
// If the user actually has a cart order...
if ($order = commerce_cart_order_load($user->uid)) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$quantity = commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types());
// If there are more than 0 product line items on the order...
if ($quantity > 0) {
// Use the dynamic menu item title.
$title = format_plural($quantity, 'Shopping cart (1 item)', 'Shopping cart (@count items)');
}
}
return $title;
}
thank you in advance
Comments
Comment #2
zenimagine CreditAttribution: zenimagine commentedComment #3
rszrama CreditAttribution: rszrama at Centarro commentedPer the issue submission guidelines, we don't really handle support requests in this queue. Additionally, what you're asking about is the default behavior of the shopping cart block that ships with Drupal Commerce. I'm not sure why you aren't seeing that in your site, but if you have further issues enabling it, please post your question with more information at https://drupal.stackexchange.com.
Comment #4
zenimagine CreditAttribution: zenimagine commentedthank you I will see it