Skip to content

Conversation

rithikb24
Copy link
Contributor

Summary:

Diff Summary: Add WooCommerce Product Validation Utility

Overview

This diff introduces a new utility function to validate WooCommerce products, enhancing the plugin's functionality and ensuring seamless integration with the WooCommerce platform.

Changes

The diff modifies the facebook-commerce.php file by adding a new private method is_woocommerce_product. This method takes a product ID as input and returns a boolean indicating whether the post is a valid WooCommerce product.

Key Highlights

  • The is_woocommerce_product function checks if a post is a WooCommerce product.
  • It verifies that the product ID is numeric and greater than 0.
  • The function uses get_post_type to determine the post type and checks if it is a WooCommerce product.

Code Snippet

private function is_woocommerce_product( $product_id ) {
    if ( ! is_numeric( $product_id ) || $product_id <= 0 ) {
        return false;
    }

    $post_type = get_post_type( $product_id );
    return in_array( $post_type, 

Impact

This update enhances the plugin's functionality by providing a robust method for validating WooCommerce products, ensuring accurate and reliable results. By incorporating this utility function, developers can streamline their workflows and improve the overall quality of their code.

Differential Revision: D81231382

@meta-cla meta-cla bot added the CLA Signed label Aug 29, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231382

@rithikb24 rithikb24 added the changelog: add A new feature, function, or functionality was added. label Aug 29, 2025
…mit them (facebook#3578)

Summary:


## Changes to Facebook for WooCommerce Plugin
### Summary

This diff introduces helper functions for tracking product meta change times and rate limiting updates. 

Specifically, it adds a new function `is_last_change_time_update_rate_limited` to the `facebook-commerce.php` file. This function checks if the last change time update is rate limited for a given product ID.

### Key Features

*   Checks for rate limiting based on a cached time for each product ID
*   Uses the WordPress cache to store the last change time for each product
*   Returns a boolean value indicating whether the update is rate limited or not

### Version History

*   Since 3.5.7

### Example Use Case

```php
$product_id = 123;
$is_rate_limited = $facebook-commerce->is_last_change_time_update_rate_limited($product_id);

if (!$is_rate_limited) {
    // Proceed with updating the product meta change time
} else {
    // Update is rate limited, skip or reschedule the update
}
```

Differential Revision: D81231381
Summary:


# Diff Summary: Add WooCommerce Product Validation Utility

## Overview

This diff introduces a new utility function to validate WooCommerce products, enhancing the plugin's functionality and ensuring seamless integration with the WooCommerce platform.

## Changes

The diff modifies the `facebook-commerce.php` file by adding a new private method `is_woocommerce_product`. This method takes a product ID as input and returns a boolean indicating whether the post is a valid WooCommerce product.

### Key Highlights

*   The `is_woocommerce_product` function checks if a post is a WooCommerce product.
*   It verifies that the product ID is numeric and greater than 0.
*   The function uses `get_post_type` to determine the post type and checks if it is a WooCommerce product.

Differential Revision: D81231382
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81231382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. CLA Signed fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants