Automattic\WooCommerce\Blocks\AIContent
UpdateProducts::should_update_dummy_product()
Verify if the dummy product should have its content generated and managed by AI.
Method of the class: UpdateProducts{}
No Hooks.
Return
true|false
.
Usage
$UpdateProducts = new UpdateProducts(); $UpdateProducts->should_update_dummy_product( $dummy_product ): bool;
- $dummy_product(\WC_Product) (required)
- The dummy product.
UpdateProducts::should_update_dummy_product() UpdateProducts::should update dummy product code WC 9.8.1
public function should_update_dummy_product( $dummy_product ): bool { $current_product_hash = $this->get_hash_for_product( $dummy_product ); $ai_modified_product_hash = $this->get_hash_for_ai_modified_product( $dummy_product ); $date_created = $dummy_product->get_date_created(); $date_modified = $dummy_product->get_date_modified(); if ( ! $date_created instanceof \WC_DateTime || ! $date_modified instanceof \WC_DateTime ) { return false; } $formatted_date_created = $dummy_product->get_date_created()->date( 'Y-m-d H:i:s' ); $formatted_date_modified = $dummy_product->get_date_modified()->date( 'Y-m-d H:i:s' ); $timestamp_created = strtotime( $formatted_date_created ); $timestamp_modified = strtotime( $formatted_date_modified ); $timestamp_current = time(); $dummy_product_recently_modified = abs( $timestamp_current - $timestamp_modified ) < 10; $dummy_product_not_modified = abs( $timestamp_modified - $timestamp_created ) < 60; if ( $current_product_hash === $ai_modified_product_hash || $dummy_product_not_modified || $dummy_product_recently_modified ) { return true; } return false; }