Automattic\WooCommerce\Internal\StockNotifications

Factory::create_dummy_notification │ public static │ WC 1.0

Create a dummy notification for preview/testing purposes.

Метод класса: Factory{}

Хуков нет.

Возвращает

Notification.

Использование

$result = Factory::create_dummy_notification(): Notification;

Код Factory::create_dummy_notification() WC 11.2.2

public static function create_dummy_notification(): Notification {
	$notification = new Notification();

	// Create a dummy product.
	$product = new \WC_Product();
	$product->set_name( __( 'Dummy Product', 'woocommerce' ) );
	$product->set_price( 25 );
	$product->set_image_id( get_option( 'woocommerce_placeholder_image', 0 ) );

	// Set required notification data.
	$notification->set_product_id( $product->get_id() );
	$notification->set_user_email( 'preview@example.com' );

	// Store the dummy product in the notification object for preview.
	$notification->product = $product;

	return $notification;
}