newfold-labs / wp-module-ecommerce

Next-generation eCommerce Experience for WordPress sites at Newfold Digital.
GNU General Public License v2.0
10 stars 4 forks source link

Fix prevent strtotime PHP deprecated #377

Closed crodriguezbrito closed 6 days ago

crodriguezbrito commented 1 week ago

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

Video

Checklist

Further comments

wpscholar commented 1 week ago

@aratidgr8 Do you mind testing this PR?

aratidgr8 commented 6 days ago

@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