Closed renatonascalves closed 1 year ago
I have custom templates too. Mine are in the wp-content/themes/theme_name/woocommerce/emails directory. To include them, I added this code:
`
$default_path = WC()->plugin_path() . '/templates/';
$files = scandir( $default_path . 'emails' );
$custom_path = get_theme_file_path() . '/woocommerce/';
$custom_files = scandir( $custom_path . 'emails' );
$exclude = array(
'.',
'..',
'email-header.php',
'email-footer.php',
'email-styles.php',
'email-order-items.php',
'email-addresses.php',
'email-customer-details.php',
'plain',
'woo-preview-emails.php',
'img'
);
$list = array_diff( array_merge( $files, $custom_files), $exclude);
sort($list);
` Just replace the $custom_path with the path to your plugin templates directory and add any files to exclude in the $exclude array.
Thank you! I can do that, but non-devs can't. It was good if the project developer could add this.
I have custom templates too. Mine are in the wp-content/themes/theme_name/woocommerce/emails directory. To include them, I added this code: ` $default_path = WC()->plugin_path() . '/templates/'; $files = scandir( $default_path . 'emails' );
$custom_path = get_theme_file_path() . '/woocommerce/'; $custom_files = scandir( $custom_path . 'emails' ); $exclude = array( '.', '..', 'email-header.php', 'email-footer.php', 'email-styles.php', 'email-order-items.php', 'email-addresses.php', 'email-customer-details.php', 'plain', 'woo-preview-emails.php', 'img' ); $list = array_diff( array_merge( $files, $custom_files), $exclude); sort($list);
` Just replace the $custom_path with the path to your plugin templates directory and add any files to exclude in the $exclude array.
Where did you add this code?
Templates added by plugins is not showing in the list because the plugin fetches only the core templates from WooCommerce.
Maybe that's the intention. Not sure!