impress-org / woocommerce-preview-emails

The easiest way to preview your WooCommerce emails as a reference while you customize them in your theme.
GNU General Public License v2.0
152 stars 32 forks source link

Show templates from plugins #16

Closed renatonascalves closed 1 year ago

renatonascalves commented 7 years ago

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!

angieellis commented 6 years 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.

renatonascalves commented 6 years ago

Thank you! I can do that, but non-devs can't. It was good if the project developer could add this.

KoolPal commented 5 years 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.

Where did you add this code?