在将电子邮件添加到WooCommerce电子邮件列表时出现错误。

huangapple go评论97阅读模式
英文:

Getting an error when adding an email to the WooCommerce email list

问题

问题出在以下路径:

/wp-content/themes/hello-elementor-child/inc/classes/class-wsn-email.php

具体是这一行代码引起的问题:

  1. require_once __DIR__ . '/inc/classes/class-wsn-email.php';

错误提示表明在打开这个文件时找不到指定的路径,因此导致了问题。

英文:

I want to add an email to the WooCommerce email list, But I get an error.

path : /wp-content/themes/hello-elementor-child/inc/classes/class-wsn-email.php

  1. function add_woocommerce_emails( $emails ) {
  2. require_once __DIR__ . '/inc/classes/class-wsn-email.php';
  3. $emails['wsn_email'] = new WSN_Email();
  4. return $emails;
  5. } add_filter( 'woocommerce_email_classes', 'add_woocommerce_emails' );

path : /wp-content/themes/hello-elementor-child/templates/email/wsn-email-template.php

path : /wp-content/themes/hello-elementor-child/templates/email/plain/wsn-email-template.php

  1. public function __construct() {
  2. $this->id = 'instock_notifier_users_mailout';
  3. $this->title = __( 'In-Stock Notifier', 'in-stock-notifier' );
  4. $this->description = __( 'When a product is Out-of-Stock and when it comes In-Stock again, this email is sent to all users registered in the waiting list for that product.', 'in-stock-notifier' );
  5. $this->heading = __( '{product_title} now back in stock at {blogname}', 'in-stock-notifier' );
  6. $this->subject = __( 'A product you are waiting for is back in stock', 'in-stock-notifier' );
  7. $this->template_base = require_once __DIR__ . '/templates/email/';
  8. $this->template_html = 'wsn-email-template.php';
  9. $this->template_plain = 'plain/wsn-email-template.php';
  10. $this->customer_email = true;
  11. add_action( 'send_wsn_email_mailout', array( $this, 'trigger' ), 10, 2 );
  12. parent::__construct();
  13. }

> Warning:
> require_once(C:\xampp\htdocs\ii\wp-content\themes\hello-elementor-child\inc\classes/templates/email/):
> failed to open stream: No such file or directory in
> C:\xampp\htdocs\ii\wp-content\themes\hello-elementor-child\inc\classes\class-wsn-email.php
> on line 51
>
> Fatal error: require_once(): Failed opening required
> 'C:\xampp\htdocs\ii\wp-content\themes\hello-elementor-child\inc\classes/templates/email/'
> (include_path='C:\xampp\php\PEAR') in
> C:\xampp\htdocs\ii\wp-content\themes\hello-elementor-child\inc\classes\class-wsn-email.php
> on line 51

where is the problem from?

答案1

得分: -2

要修复路径并使用子主题直接路径,您可以使用 get_stylesheet_directory() 函数来获取子主题目录的路径。以下是更新后的代码:

  1. function add_woocommerce_emails( $emails ) {
  2. require_once get_stylesheet_directory() . '/inc/classes/class-wsn-email.php';
  3. $emails['wsn_email'] = new WSN_Email();
  4. return $emails;
  5. }
  6. add_filter( 'woocommerce_email_classes', 'add_woocommerce_emails' );
英文:

To fix the path using the child theme direct path, you can use the get_stylesheet_directory() function to get the path to the child theme directory. Here's the updated code:

  1. function add_woocommerce_emails( $emails ) {
  2. require_once get_stylesheet_directory() . '/inc/classes/class-wsn-email.php';
  3. $emails['wsn_email'] = new WSN_Email();
  4. return $emails;
  5. }
  6. add_filter( 'woocommerce_email_classes', 'add_woocommerce_emails' );

huangapple
  • 本文由 发表于 2023年7月6日 18:39:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76627957.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定