Automattic\WooCommerce\Internal\Admin\EmailPreview
EmailPreview::provide_dummy_product_file
Provide a dummy product file so product->has_file() returns true in preview.
Method of the class: EmailPreview{}
Hooks from the method
Returns
Array|null.
Usage
$EmailPreview = new EmailPreview(); $EmailPreview->provide_dummy_product_file( $file );
- $file(array|null) (required)
- Current file array or null.
EmailPreview::provide_dummy_product_file() EmailPreview::provide dummy product file code WC 10.5.0
public function provide_dummy_product_file( $file ) {
/**
* Filters whether the current request is an email preview.
*
* When true, provide a dummy product file array 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 ) ) {
return array(
'name' => __( 'Sample Download File.pdf', 'woocommerce' ),
'file' => 'sample-download.pdf',
);
}
return $file;
}