Roots Discourse

Woocommerce my-account pages not loading common.js

Hi,

Got a bit of an issue on my woocommerce build. Using bedrock/Sage and latest versions of woo and wordpress. My common.js file is not being loaded on the my-account pages, so thats things like orders, downloads, addresses, account details - these are all front-end pages so things like my font-awesome icons and my custom basket functionality aren’t working on these pages.

These are the relevant bits in main.js:

// import local dependencies
import Router from './util/Router';
import common from './routes/common';
import home from './routes/home';
import aboutUs from './routes/about';
import woocommerceCheckout from './routes/checkout';
import wheelSearch from './routes/wheel-search';
import tyreSearch from './routes/wheel-search';
import tyreWheelPackages from './routes/packages';
import singleProduct from './routes/wheel-search';
import search from './routes/search';

/** Populate Router instance with DOM routes */
const routes = new Router({
  // All pages
  common,
  // Home page
  home,
  // About Us page, note the change from about-us to aboutUs.
  aboutUs,
  woocommerceCheckout,
  wheelSearch,
  tyreSearch,
  tyreWheelPackages,
  singleProduct,
  search,
});

Any help much appreciated!

Just to add to this, looking in my browser console, on the frontend my-account pages of woocommerce I’m noticing that main.js is not getting loaded at all! Why would that be the case on the woocommerce my-account pages? The main.css file is loading just fine and I can tell that the wp_enqueue_scripts hook is being hit by putting a breakpoint in???

Righto, I found it! By changing the enqueue to this in setup.php:

wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, false);

It worked - I just changed the final parameter from true to false, so it now loads in the head! No idea for the reason behind this - anyone??

This topic was automatically closed after 42 days. New replies are no longer allowed.