Codeinwp / Codeinwp/woocommerce-product-addon

Improper subtotal values for cart items in the cart view

Open
#706 2 comments 0 reactions 1 assignee View on GitHub

@girishpanchal30 is already working on this.

Since Aug 12, 2026.

  • #727 by @girishpanchal30 — merged
bug
Dominant language
PHP
Stars
15
Forks
9
Avg merge
3d 17h
Merged PRs (30d)
16

Description

Description

Plugin version: 34.0.8

When adding multiple options configured through this module to a single product - improper subtotal values appear in the cart view.
I have a restaurant with catering website that allows the customer to add custom extras to the food. Here is an image showing the product page with available extras:

Image

As you can see the total is 17,00 zł
When I proceed to the cart view though - the subtotal is 12,00 zł

Image

It appears that only one extra field is being taken into calculation.

Step-by-step reproduction instructions
  1. Go to backoffice to create a field group inside the module settings.
  2. Configure at least 3 checkbox fields that add flat value to the price.
  3. Apply that config to any product.
  4. Proceed to front office - to the product chosen in the last step.
  5. Add at least 2 fields to the product.
  6. Observe the price on the product page.
  7. Add the product to the cart.
  8. Proceed to the cart view.
  9. Observe the subtotal of the previously added product.
Screenshots, screen recording, code snippet or Help Scout ticket

I have already found a solution to this problem in the following file:
\woocommerce-product-addon\src\WooCommerce\Cart\CartHandler.php
function item_subtotal (line ~778)

Replace this:

	foreach ( $option_prices as $option ) {
		$option       = Helpers::translation_options( $option );
		$option_price = isset( $option['price'] ) ? $option['price'] : 0;
		if ( 0 === $option_price || ( ! isset( $option['apply'] ) || 'onetime' !== $option['apply'] ) ) {
			continue;
		}
		$price = isset( $option['discount'] ) && $option['discount'] > 0 ? $option['discount'] : $option_price;
		if ( ! empty( $price ) ) {
			$price = apply_filters( 'ppom_option_price', $price );
			$price = floatval( wp_strip_all_tags( $price ) );
		}
	}

With this:

	foreach ( $option_prices as $option ) {
		$option       = Helpers::translation_options( $option );
		$option_price = isset( $option['price'] ) ? (float) $option['price'] : 0;

		if ( $option_price === 0 || ( ! isset( $option['apply'] ) || 'onetime' !== $option['apply'] ) ) {
			continue;
		}

		$current_price = ( isset( $option['discount'] ) && $option['discount'] > 0 )
			? (float) $option['discount']
			: $option_price;

		$current_price = apply_filters( 'ppom_option_price', $current_price );
		$current_price = (float) wp_strip_all_tags( $current_price );

		$price += $current_price;
	}

It fixes a problem with setting the value of the subtotal by instead accummulating it

Environment info

No response

Is the issue you are reporting a regression

No

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.