chrisandy
(Chris Fickling)
February 10, 2023, 3:36pm
#1
Thought I’d try the blue theme to improve the checkout and it’s hanging when I click checkout.
Getting the following in browser console…
Uncaught ReferenceError: CommerceConfig is not defined
at updateMiniCart (main.js:319:25)
at HTMLDocument. (main.js:12:9)
Uncaught ReferenceError: CommerceConfig is not defined
at HTMLFormElement. (main.js:151:34)
…it’s probably something I’ve done wrong!
mhamstra
(Mark Hamstra)
February 10, 2023, 3:53pm
#2
Does your checkout cart resource use the checkout cart template provided by the theme, and have the ctblue.footer chunk there?
This code should be before the end of the body to transfer some variables to the JS:
<script>
window.CommerceConfig = {
cart_url: '[[~[[++commerce.cart_resource]]:htmlent]]',
checkout_url: '[[~[[++commerce.checkout_resource]]:htmlent]]',
i18n: {
shipping: '[[!%commerce.shipping:htmlent]]',
tax: '[[!%commerce.is_inclusive:htmlent]]'
}
}
</script>
<script src="[[++ctblue.assets_url]]js/main.js"></script>
1 Like
chrisandy
(Chris Fickling)
February 10, 2023, 4:05pm
#3
No - I didn’t know about that template. Do I have to use it or can I just insert that script?
mhamstra
(Mark Hamstra)
February 10, 2023, 4:18pm
#4
You can just use that script.
The header chunk also needs the CSS if you also don’t have that one:
<link rel="stylesheet" href="[[++ctblue.assets_url]]css/main.css">
chrisandy
(Chris Fickling)
February 10, 2023, 4:25pm
#5
Thank you. I added the css and js to my own header chunk and then just added that script below the snippet call on the cart page. Is that ok? Looking a little bit messy at the moment but I can tdy up.