Title: Error Help
Last modified: June 24, 2023

---

# Error Help

 *  [sunnydhain1](https://wordpress.org/support/users/sunnydhain1/)
 * (@sunnydhain1)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/error-help-7/)
 * Hi
 * I have noticed that the following php error is showing with this attachment:
 * Function wp_enqueue_style was called incorrectly. Scripts and styles should not
   be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts,
   or login_enqueue_scripts hooks. This notice was triggered by the wcoa-front-app
   handle. Please see Debugging in WordPress for more information. (This message
   was added in version 3.3.0.)
 * The only way it works is if I remove the plugin but I need this plugin. Is there
   any other way
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-help-7%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Dominik](https://wordpress.org/support/users/sldesignpl/)
 * (@sldesignpl)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/error-help-7/#post-16846139)
 * Hello,
 * I am testing the ‘Order Attachments for WooCommerce’ plugin on the latest version
   of WordPress, which is 6.2.2, and the issue you described does not occur for 
   me.
 * I will try to look into it and debug the problem on my end. Maybe I will be able
   to identify and fix something. In the meantime, please follow these steps:
 * Keep the ‘Order Attachments for WooCommerce’ plugin enabled.
   Disable other plugins
   one by one until my plugin starts functioning correctly. This way, we might be
   able to find the culprit. Unless the issue lies within the theme? You should 
   also check that.Thank you!
 *  Thread Starter [sunnydhain1](https://wordpress.org/support/users/sunnydhain1/)
 * (@sunnydhain1)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/error-help-7/#post-16851572)
 * Hi,
 * I have updated the themes and all other plugins and the error is still showing?
   Did you manage to find anything?
 *  [pirulee](https://wordpress.org/support/users/pirulee/)
 * (@pirulee)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/error-help-7/#post-17033784)
 * The error persists and it is because you are calling `wp_enqueue_style` in the
   class `__construct` of `WCOA_My_Account`. This is wrong, it needs to be called
   during specific hooks before rendering.
 * There are two solutions for this issue:
 * **Use wp_enqueue_scripts hook**
 *     ```wp-block-code
       public function __construct()
       {
           add_action( 'wp_enqueue_scripts', [$this, 'enqueue'] );
       }
   
       public function enqueue()
       {
           wp_enqueue_style( 'wcoa-front-app', WCOA_PLUGIN_URL . '/assets/frontend/css/style.css', false, 1.0, 'all' );
       }
       ```
   
 * **Use it before rendering your template**
 *     ```wp-block-code
       public function initialize_template()
       {
           wp_enqueue_style( 'wcoa-front-app', WCOA_PLUGIN_URL . '/assets/frontend/css/style.css', false, 1.0, 'all' );
           do_action( 'wcoa_account_attachments_enqueue' );
           require_once WCOA_PLUGIN_DIR . 'templates/frontend/frontend-my-account-attachments.php';
       }
       ```
   
 * In my personal opinion, I would go with the second option, this way you don’t
   have to load the css on every single page which is not optimal, the other workaround
   would be to use the `wp_enqueue_scripts` hook but only enqueue the style when
   the attachment page is being rendered.
 *  [Andrew Sleigh](https://wordpress.org/support/users/ajsleigh/)
 * (@ajsleigh)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/error-help-7/#post-17079535)
 * Came here to report the same php errors. The above suggestion by [@pirulee](https://wordpress.org/support/users/pirulee/)
   is the way to go, looks like you have already done this in class-wcoa-admin.php
   so should be an easy fix.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Error Help’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/order-attachments-for-woocommerce.
   svg)
 * [Order Attachments for WooCommerce](https://wordpress.org/plugins/order-attachments-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/order-attachments-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/order-attachments-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/order-attachments-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/order-attachments-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/order-attachments-for-woocommerce/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [Andrew Sleigh](https://wordpress.org/support/users/ajsleigh/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/error-help-7/#post-17079535)
 * Status: not resolved