Advertisement
datafix

WC error

Mar 13th, 2023 (edited)
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. // KOODI
  2.  
  3. <?php
  4.  
  5. add_filter( 'woocommerce_email_classes', 'change_email_class_based_on_shipping_method', 10, 1 );
  6. function change_email_class_based_on_shipping_method( $emails ) {
  7.     // Get the chosen shipping method
  8.     $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
  9.     $chosen_shipping_method = explode( ':', reset($chosen_shipping_methods) )[0];
  10.  
  11.     // Change the email class based on the chosen shipping method
  12.     if ( $chosen_shipping_method == 'shipping_method_0_shipit2' ) {
  13.         $emails['WC_Email_Customer_Processing_Order'] = include( 'wp-content/plugins/kadence-woocommerce-email-designer/templates/woo/emails/customer-processing-order.php' );
  14.     } elseif ( $chosen_shipping_method == 'shipping_method_0_local_pickup3' ) {
  15.         $emails['WC_Email_Customer_Processing_Order'] = include( 'wp-content/plugins/breakdance/plugin/themeless/themes/breakdance-zero/woocommerce/emails/customer-processing-order.php' );
  16.     }
  17.  
  18.     return $emails;
  19. }
  20.  
  21. // VIRHE
  22.  
  23. PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /tmp/51-woocommerce-conditional-email-template
  24. Stack trace:
  25. #0 /var/www/vhosts/***/wp-includes/class-wp-hook.php(308): change_email_class_based_on_shipping_method()
  26. #1 /var/www/vhosts/***/wp-includes/plugin.php(205): WP_Hook->apply_filters()
  27. #2 /var/www/vhosts/***/wp-content/plugins/woocommerce/includes/class-wc-emails.php(233): apply_filters()
  28. #3 /var/www/vhosts/***/wp-content/plugins/woocommerce/includes/class-wc-emails.php(190): WC_Emails->init
  29. #4 /var/www/vhosts/***/wp-content/plugins/woocommerce/includes/class-wc-emails.php(52): WC_Emails->__con
  30. #5 /var/www/vhosts/***/wp-content/plugins/woocommerce/includes/class-woocommerce.php(943): WC_Emails::in
  31. #6  in /tmp/51-woocommerce-conditional-email-template.php on line 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement