Skip to content

Fix prevent strtotime PHP deprecated#377

Merged
aratidgr8 merged 1 commit intotrunkfrom
fix/PRESS10-12
Nov 20, 2024
Merged

Fix prevent strtotime PHP deprecated#377
aratidgr8 merged 1 commit intotrunkfrom
fix/PRESS10-12

Conversation

@crodriguezbrito
Copy link
Copy Markdown
Contributor

Proposed changes

This PR addresses the deprecated error from the strtotime() function in PHP.

PHP Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated

The issue occurs when making an API call to the WooCommerce Store API (/wc/v3/products). This deprecated error is triggered if there are no products created on the site. The reason is that the API uses $product_query->get_last_modified(), which lacks error handling for cases where no products exist.

This PR will use the WooCommerce REST API endpoint (/wc/v3/products), which does not trigger the deprecated error.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Video

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@wpscholar
Copy link
Copy Markdown
Member

@aratidgr8 Do you mind testing this PR?

@aratidgr8
Copy link
Copy Markdown
Contributor

aratidgr8 commented Nov 20, 2024

@wpscholar Hey,

Myself & @amruthabs22 have tested below flows with new api call /wc/v3/products and it works fine without any errors / warnings

  1. No existing product
  2. Add product
  3. Manage products

Thanks!

CC: @crodriguezbrito

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.

3 participants