Open Basket drawer when clicking custom element
-
Desired Behaviour
Trigger the basket drawer to open from the right hand side on WP 2024 theme when a user clicks some custom text on the header and not just the ‘basket icon’.
Attempted Solution
I wrote this JS as from what I saw in the DOM i could see that this is what was changing, so I thought that add this CSS when the user clicks my custom element would make the drawer open
document.querySelector('.sigurd-123').addEventListener('click', function() {
document.body.classList.add('drawer-open');
document.querySelector('.wp-site-blocks').setAttribute('aria-hidden', 'true');
});Outcome right now..
However this does not work. The code is defs triggering and I put a console.log in there and it was working but no success.
I cannot go into the Woocommerce JS and see exactly what is happening because it is all minified and so it is impossible to read this code.
I would prefer not to put the website here, however it is just normal WooCommerce site that used the WP 2024 theme and so when you click the basket icon (which displays the number of basket items) the drawer opens from the right and you can see all the items in the basket or it will say that the basket is empty.
Thanks
- You must be logged in to reply to this topic.