Skip to content

Update product validation logic for checkout#3271

Closed
ajello-meta wants to merge 2 commits intomainfrom
checkout-cart-logging
Closed

Update product validation logic for checkout#3271
ajello-meta wants to merge 2 commits intomainfrom
checkout-cart-logging

Conversation

@ajello-meta
Copy link
Copy Markdown
Contributor

@ajello-meta ajello-meta commented May 29, 2025

Description

This PR updates product validation logic in Checkout.php. The WC()->cart->add_to_cart( $product_id, $quantity ) function does not throw an exception when the product ID (or quantity) is invalid. It also does not throw an exception when a product fails to be added to the cart. The updated logic (1) uses wc_get_product( $product_id ) to retrieve the product and validate it's existence and availability and (2) verifies that WC()->cart->add_to_cart( $product_id, $quantity ) returns true.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Syntax change (non-breaking change which fixes code modularity, linting or phpcs issues)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Test Plan

  1. Go to http://test-site-i.local/fb-checkout?products=<ID>:<#>. Fill in the "ID" and/or "#" with invalid inputs.
  2. Check Meta side logging to ensure that the error logs are visible.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 29, 2025

📦 Latest Plugin Build

Built at: 2025-05-29T20:00:39.115Z
Commit: dff80ca
Size: 1.1M

Download: Click here to download the plugin

To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ajello-meta merged this pull request in 062f0a8.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants