Display each cart item field as a separate line in the cart summary table

  • Posts: 8
  • Thank you received: 0
  • Hikashop Business
16 hours 15 minutes ago #370811

Hi HikaShop team,

We are customizing the checkout cart template (show_block_cart.php) to display each product option and cart item field as a separate line in the cart summary table, with individual unit price, quantity, and total columns.

While implementing this, we found that cart item fields (stored in $cart->cart_products[$i]->field_namekey) lack some metadata that would be essential for correct display:

1. No tax rate available for item fields
The field value stored in the cart item is the price excluding tax (e.g. 42.975), but there is no associated tax rate or tax category accessible from the template. We had to hardcode × 1.21 (21% VAT) because it happened to match the configured tax for that service. If a field uses a different tax rate (10%, 4%, etc.), the displayed price with tax will be wrong.

Suggested improvement: Include the tax rate or computed price_value_with_tax alongside the raw field value in the cart item data, similar to how prices[0]->price_value_with_tax is available for product options.

2. No indication of whether a field price scales with quantity
Some item fields represent a per-unit cost (should multiply by cart quantity), while others represent a flat one-time service fee (should not multiply). Currently there is no way to distinguish these cases from the template — we have to guess based on business logic.

Suggested improvement: Add a metadata flag to field definitions (e.g. field_multiply_by_quantity: true/false) so templates can handle both cases correctly without hardcoding assumptions.

3. prices[0]->unit_price in option elements equals prices[0]->price_value_with_tax
When displaying grouped options (group_options = 1), the unit_price nested object inside prices[0] of an option element contains the same value as price_value_with_tax (i.e. total price, not unit price). This makes it impossible to retrieve the true per-unit price for display without manually dividing by cart_product_quantity.

Suggested improvement: Ensure prices[0]->unit_price->price_value_with_tax consistently reflects the price for one unit, regardless of cart quantity.

These improvements would allow template developers to build accurate per-line breakdowns without relying on hardcoded business logic or reverse-engineering prices from totals.

Thank you for considering these improvements.


Pablo Arias

www.pabloarias.eu

Please Log in or Create an account to join the conversation.

  • Posts: 85264
  • Thank you received: 13917
  • MODERATOR
2 hours 42 minutes ago #370812

Hi,

I'm surprised by your message.
The custom item fields can't change the price of a product. So tax and quantity are irrelevant.
Could you explain where you're coming from with this ?
The only way this is possible is if you're using the price calculation plugin, but I don't see any purchase of it on your account, or some custom plugin on your end. If it's done by a custom plugin on your end, then the tax information and quantity should be an information provided by the plugin when modifying the price of the product via the events HikaShop provide, not something HikaShop itself does, since it doesn't know how the price is being modified by the plugin.

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum