Hello,
I need some help.
I want shopping-cart-teaser to show in menu not total quantity of all units of products but quantity of products themselves.
For example, I have 3 products (red, blue, white) and put into a cart: 2 units of red, 3 units of blue and 1 unit of white. Now the result in teaser block is 6 units, but in my project the correct result should be 3 products.
How can I get the amount of products in the cart-teaser block, not the amount of units?
PS As a temporary solution I replace $quantity in dc_ajax_add_cart.module to this one:
global $user;
$order = commerce_cart_order_load($user->uid);
$counter = 0;
if(!empty($order->commerce_line_items)){
foreach($order->commerce_line_items['und'] as $item){
$counter++;
}
}
......
$quantity = $counter;
But I'm not sure this is the right decision.
with respect,
savage
Comments
Comment #2
savage1974 commentedComment #3
savage1974 commentedComment #4
savage1974 commentedComment #5
subhojit777You are somewhat going in the right direction. You have loaded the
$orderfor current user. You need to iterate through the commerce line items, and gather them by their product ids, in a separate array. Then just return thecount()of the array. That should do it. The current code will just return the total number of products again.I am closing this issue as this requirement is project specific.