0

I am trying to "hide" individual line item values on my shopping cart. Is there a way to combine line items (possibly based on a term applied to each) such that they show as 1 item with the subtotal as the unit price?

As an example:

ungrouped:

  • item A - $100
  • item B - $50
  • item C - $25
  • item D - $200
  • item E - $50
  • item F - $25

grouped

  • item A, B, C - $175
  • item D, E, F - $275

where line items A, B, C would be tagged when added to cart as Group 1 and C, E, F would be tagged with Group 2.

I am not sure this is doable in the View directly; but possibly in one of the view alter hooks?

Update:

I am able to use hook_views_pre_render on the commerce_cart_form. From there I can access the line items, evaluate them and remove the line items I want to group in to main item. I just need to sort out what I need to modify to alter the displayed price of the main item. My guess is that I can't easily to do it here without saving the Order Item. I don't really want to modify the Order at all. I just want to display the cart differently.

Update 2:

Starting to think this is not possible without modifying the stored line item entity. Even preprocessing the Views table where I have access to each cell of the table; it seems as though $variables['rows'] does not use its values from the preprocess function.

Perhaps JS is the only (ugly) was to accomplish this. :(

1 Answer 1

0

Wouldn't it be more accurate to use attributes on the line items?

Or why do you have this "hidden" line items?

1
  • Line items are products. These are individual products which cost money; but are grouped together as shown in example. The intent is to not show the cost of the individual items, but the cost of the group of items. I do have this working now with JS - but was wondering if a php based way of doing this.
    – liquidcms
    Oct 10, 2022 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.