Title: PHP Notice:  wp_enqueue_script was called incorrectly.
Last modified: August 21, 2016

---

# PHP Notice: wp_enqueue_script was called incorrectly.

 *  Resolved [defmans7](https://wordpress.org/support/users/defmans7/)
 * (@defmans7)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/php-notice-wp_enqueue_script-was-called-incorrectly/)
 * I was getting this error message and found a solution by editing the woocommerce.
   php file unfortunately.
    From line 1173
 *     ```
       // Queue frontend scripts conditionally
       		if ( $ajax_cart_en )
       			wp_enqueue_script( 'wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array( 'jquery' ), $this->version, true );
   
       		if ( is_cart() )
       			wp_enqueue_script( 'wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array( 'jquery' ), $this->version, true );
   
       		if ( is_checkout() ) {
       			if ( $chosen_en ) {
       				wp_enqueue_script( 'wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array( 'chosen' ), $this->version, true );
       				wp_enqueue_style( 'woocommerce_chosen_styles', $this->plugin_url() . '/assets/css/chosen.css' );
       			}
   
       			wp_enqueue_script( 'wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array( 'jquery', 'woocommerce' ), $this->version, true );
       		}
   
       		if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {
       			wp_enqueue_script( 'prettyPhoto', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true );
       			wp_enqueue_script( 'prettyPhoto-init', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $this->version, true );
       			wp_enqueue_style( 'woocommerce_prettyPhoto_css', $this->plugin_url() . '/assets/css/prettyPhoto.css' );
       		}
   
       		if ( is_product() )
       			wp_enqueue_script( 'wc-single-product' );
       ```
   
 * Changed it to this to get the ajax shipping calculation to work:
 *     ```
       // Queue frontend scripts conditionally
       		if ( $ajax_cart_en ){
       			wp_enqueue_script( 'wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array( 'jquery' ), $this->version, true );
               }
       		if ( is_cart() ){
       			wp_enqueue_script( 'wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array( 'jquery' ), $this->version, true );
               }
       		if ( is_checkout() ) {
       			if ( $chosen_en ) {
       				wp_enqueue_script( 'wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array( 'chosen' ), $this->version, true );
       				wp_enqueue_style( 'woocommerce_chosen_styles', $this->plugin_url() . '/assets/css/chosen.css' );
       			}
   
       			wp_enqueue_script( 'wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array( 'jquery', 'woocommerce' ), $this->version, true );
       		}
   
       		if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {
       			wp_enqueue_script( 'prettyPhoto', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true );
       			wp_enqueue_script( 'prettyPhoto-init', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $this->version, true );
       			wp_enqueue_style( 'woocommerce_prettyPhoto_css', $this->plugin_url() . '/assets/css/prettyPhoto.css' );
       		}
   
       		if ( is_product() ){
       			wp_enqueue_script( 'wc-single-product' );
               }
       ```
   
 * Is there a better way to do this? It’s bad practice obviously to do this…
 * [http://wordpress.org/plugins/woocommerce/](http://wordpress.org/plugins/woocommerce/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [defmans7](https://wordpress.org/support/users/defmans7/)
 * (@defmans7)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/php-notice-wp_enqueue_script-was-called-incorrectly/#post-4399898)
 * I… actually. It was something else entirely that was the problem. My apologies.

Viewing 1 replies (of 1 total)

The topic ‘PHP Notice: wp_enqueue_script was called incorrectly.’ is closed to new
replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [defmans7](https://wordpress.org/support/users/defmans7/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/php-notice-wp_enqueue_script-was-called-incorrectly/#post-4399898)
 * Status: resolved