Automattic\WooCommerce\Internal\Admin\EmailPreview
EmailPreview::provide_dummy_product_file
Provide a dummy product file so product->has_file() returns true in preview.
Метод класса: EmailPreview{}
Хуки из метода
Возвращает
WC_Product_Download|array|null.
Использование
$EmailPreview = new EmailPreview(); $EmailPreview->provide_dummy_product_file( $file );
- $file(WC_Product_Download|массив|null) (обязательный)
- Current file object, array, or null.
Код EmailPreview::provide_dummy_product_file() EmailPreview::provide dummy product file WC 11.3.0
public function provide_dummy_product_file( $file ) {
/**
* Filters whether the current request is an email preview.
*
* When true, provide a dummy product file so downloadable template parts
* can render during preview.
*
* @since 9.6.0
*
* @param bool $is_email_preview Whether preview mode is active.
*/
if ( apply_filters( 'woocommerce_is_email_preview', false ) ) {
$dummy_file = new WC_Product_Download();
$dummy_file->set_id( 'preview-dummy' );
$dummy_file->set_name( __( 'Sample Download File.pdf', 'woocommerce' ) );
$dummy_file->set_file( 'sample-download.pdf' );
return $dummy_file;
}
return $file;
}