Skip to content

Fixed legacy price rows using saved settings - #812

Open
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/pro/833
Open

girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/pro/833

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Fixed legacy pricing vulnerabilities by rebuilding all priced cart rows from saved field settings and submitted field values instead of trusting client-submitted prices. Extended server-side repricing to cover Options, Text, Quantities, Select Quantity, Variation Quantity Matrix, Quantities Pack, Bulk Quantity, Fixed Price, and Measure fields, while respecting product-attached field groups and skipping conditionally hidden fields. Preserved posted rows only for field types not handled by the legacy pricing logic, such as Matrix, Matrix Discount, Event Calendar, and WooCommerce Variation Quantities. Updated line pricing, fixed fees, subtotals, and legacy quantity displays to use the same rebuilt rows.

Check before Pull Request is ready:

Closes https://github.com/Codeinwp/ppom-pro/issues/833

@pirate-bot

pirate-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Tip

You can preview the changes in the Playground

Plugin build for 7b9ea85 is ready 🛎️!

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

Paid file uploads and priced Image selections are no longer charged in legacy mode, and another product's request can change existing line charges.

Validation details
  • Files reviewed: 5/5 changed files. Unchecked questions: consumer helpers that read the rebuilt rows, currency conversion (issues #755 and #775), field group resolution (#705), zero-price flags (#752), and add-to-cart guards of the new builders.
  • PHPUnit at HEAD (PHP 8.3, WP 7.1.4, WC 11.3.0): Test_Cart_Handler passed 78 tests [R6]. Test_Wcml_Cart_Option_Conversion passed 18 tests [R7].
  • Base-tree runs: all ten added tests fail on pr-base code.
  • Scratch test: a 3.00 file cost is charged on pr-base [R10] and dropped at HEAD [R9].
Untested areas
  • Fancy Cropper cartPrice in modern mode (src/Pricing/Engine.php:576-584) trusts the posted price. Its add-on source was not available, so reachability is unverified.
  • Pro paths were not checked: fixed price packages, Pro currency conversion, and switcher or image select markup.
  • Older history leads were not checked one by one.
  • The Playwright suite did not run. Payloads were rebuilt from templates.

🤖 Automated review · run code-review-agent_6afc1b119a4979.02207759.


🤖 Review agent — review posted ✅ on 8fde6748 · changes requested · 7 findings · 50 min

Run code-review-agent_6afc1b119a4979.02207759 · trail

Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

Cropper viewport, Audio, Color and Date charges are still lost in legacy mode, and order meta still trusts the request's hidden list.

  • src/Support/Helpers.php:349 — security ✓ Verified in the sandbox Order meta still trusts the request's hidden list, so a priced field can be fulfilled for free. Pricing now reads only the line's conditionally_hidden through is_field_hidden_in_payload(). generate_cart_meta() still calls is_field_hidden_by_condition(), which prefers $_POST['ppom']['conditionally_hidden']. A shopper lists a priced field as hidden at add to cart, then posts an empty list at checkout. The field is not charged, but it is saved in the order meta. A Cropper image link shows too (Helpers.php:2043-2056). Call is_field_hidden_in_payload( (string) $key, $ppom_cart_items ) here. Add a test that sets a stored hidden list and an empty $_POST list, and asserts that make_meta_data() leaves the field out.
Validation details
  • Files reviewed: 7/7 changed files. Unchecked questions: ppom_cart_fixed_fee consumers, the merged Quantities line (#782), the narrowed-input guards of the new builders, add-to-cart guards, other consumer hooks, and older history leads.
  • PHPUnit at HEAD (PHP 8.3.36): vendor/bin/phpunit --do-not-cache-result --filter 'Test_Cart_Handler::' printed OK (89 tests, 218 assertions).
  • Base-tree runs: 10 of the 12 new tests fail on pr-base code with assertion failures. The modern-mode subtotal case and the reverse hidden-list case pass there too.
  • A scratch PHPUnit class priced Cropper, Audio, Color and hidden-list lines at HEAD and on pr-base code. The inline comments give their prices.
Untested areas
  • Pro-only field types and Pro Fixed Price were not checked. Their source is not available.
  • Date with jquery_dp was checked in source only.
  • The Order Again compatibility test errors on both trees in the sandbox ("headers already sent").
  • The unchecked questions above were not settled.
  • The Playwright suite did not run.

🤖 Automated review · run code-review-agent_6afc31124ece78.55897567.


🤖 Review agent — review posted ✅ on c53853ac · changes requested · 5 findings · 32 min

Run code-review-agent_6afc31124ece78.55897567 · trail

Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved
Comment thread src/WooCommerce/Cart/CartHandler.php Resolved

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

The four earlier pricing threads and the order meta fix are confirmed, but priced Color and Date fields are now charged without a page price under legacy rendering.

Validation details
  • Files reviewed: 4/4 files changed since the prior review. Unchecked questions: CURCY double conversion, conditional fields on multi-product pages, narrowed-input guards, the merged Quantities line (#782).
  • PHPUnit at HEAD (PHP 8.3.36): cd /workspace/checks/RN2 && timeout 200 sandbox-wp-tests.sh --help 2>&1 | tail -5; set -o pipefail; timeout 280 bash -c … printed OK (94 tests, 229 assertions) (run R1)
  • The six new tests pass at HEAD: cd /workspace/checks/RN2 && set -o pipefail; F=$(cat filter.txt); timeout 200 bash -c "cd /repo && vendor/bin/phpunit --… printed OK (6 tests (run R3)
  • The order meta test fails on the prior commit's code, at test-cart-and-options.php:79.
Untested areas
  • Default price mode: a checkout request can mark Bulk Quantity hidden. The engine then drops its tier, while order meta keeps it. The add-on source is not in the checkout.
  • The unchecked questions above were not settled.
  • Translated Cropper options, Pro-only field types and Pro Order Again were not checked.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • classes/form.class.php:197-205 — unverified: Switcher, imageselect, emojis, fancycropper and Pro quantity/package parity remain unsettled: their frontend controls, submitted shapes and pricing implementations are unavailable.…

🤖 Automated review · run code-review-agent_6afc3b5d5257d4.29699356.


🤖 Review agent — review posted ✅ on 7b9ea855 · changes requested · 1 finding · 47 min

Run code-review-agent_6afc3b5d5257d4.29699356 · trail

Comment on lines +1061 to +1062
case 'color':
case 'date':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness With legacy pricing and legacy input rendering both on, a priced Color or jQuery Date field is now charged, but the product page never showed that price. That renderer keeps the saved color/date type and data-type (RegularInputRenderer.php:69-81). The price script prices a field only for data-type="text" (js/price/ppom-price.js:989-1006), so no row is posted. The cart now adds the saved price for any non-empty value. Build these rows only when the page renders the field as a text input, or price them on the page too. Add Color and Date cases with ppom_enable_legacy_inputs_rendering set to yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applied. The legacy renderer does not keep the saved type: it reads type through nmform_attribute_value, where Callbacks::color_to_text_type() (src/Hooks/Callbacks.php:663-670) turns color into text. A jQuery Date becomes text via ppom_field_setting → Callbacks::input_args() (Callbacks.php:600-603). With ppom_enable_legacy_inputs_rendering = yes, both render data-type="text" and the price script prices them; only a native Date renders data-type="date", and the cart already leaves that one unpriced (CartHandler::legacy_text_rows()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants