Automattic\WooCommerce\Blocks\AIContent
UpdateProducts::should_update_dummy_product
Verify if the dummy product should have its content generated and managed by AI.
Метод класса: UpdateProducts{}
Хуков нет.
Возвращает
true|false.
Использование
$UpdateProducts = new UpdateProducts(); $UpdateProducts->should_update_dummy_product( $dummy_product ): bool;
- $dummy_product(WC_Product) (обязательный)
- The dummy product.
Код UpdateProducts::should_update_dummy_product() UpdateProducts::should update dummy product WC 10.7.0
public function should_update_dummy_product( $dummy_product ): bool {
$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 ( $dummy_product_not_modified || $dummy_product_recently_modified ) {
return true;
}
return false;
}