boomerdigital / solidus_flexi_variants

BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

Product javascript not being inserted into product page #18

Open ums-uk opened 5 years ago

ums-uk commented 5 years ago

Hi,

I have a problem where the javascript used to calculate the price of the product has stopped working in production mode. It seems to run fine and then just stopped. Viewing the source code the javascript required to update the price when a dropdown is selected is not there. There are no errors in the production log or the browser console.

An example page can be seen here: https://www.yournewbed.co.uk/products/kozee-sleep-limited-edition-2-drawer-set?taxon_id=6

Any thoughts?

Thanks.

dhonig commented 5 years ago

@ums-uk The asset pipeline is configured differently for development/staging/production. It may be something about the way you have it configured is causing the scripts to not be loaded after the asset pipeline is compiled. I might try running locally as production to see if the problem persists. This would tell me it something about my projects packaging of assets. Perhaps @acreilly who has done more work maintaining this gem will have some more ideas for you.

ums-uk commented 5 years ago

I have done some more investigating and can see the problem is that the line <%= yield :flexi_variants_body_js %> doesn't return any information. I've run the production server with non-compiled JS to see if this helps but it still does not return any details. Running in production mode on my local computer also recreates the same problem - running in development mode and all works fine.

ums-uk commented 5 years ago

I've found a work around by dumping the contents of the file solidus_flexi_variants/app/views/spree/products/_pricing.html.erb into the bottom of the body of the application and surrounding it with a if @product.present? clause - not ideal but works for me. I expect I could actually put that content into a product view page...

dhonig commented 5 years ago

@ums-uk that sounds reasonable. It really does seem that something about your project isn't automatically including the JS in the asset pipeline for prod mode. It's not the worst thing in the world to include the JS in the partial that needs it. You would just want to be sure its slowing down the page rendering in any way and this code shouldn't do that as it fires after the page is loaded.