I want to add a drop down selection (choose a sales representative section), at the cart page. I have already added the front-end as a custom liquid in to the theme.
the question is, where do I add the javascript code in the backend so that when a customer checkout the info in the selection is saved?(part of the order info).
I have tried to add javascript code in cart-drawer.liquid(added inside of addeventlistener). but it didnt work, that the script didnt seem to get executed(tried console log )
1 Like
Hi @robbie123
Seems like you have a Shopify 2.0 FREE themes. Try adding this to the cart.js or global.js under the Asset folder.
Please don’t forget to Like and Mark Solution to the post that helped you. Thanks!
1 Like
Hi:
this is a Dawn theme(free) Version 12.0.0
in the cart.js file, there are two class, CartItems and CartRemoveButton. did you mean add the event listener under the class CartItems?(under its constructor() )
the CartItems class looks like:
class CartItems extends HTMLElement {
constructor() {
super();
this.lineItemStatusElement =
document.getElementById('shopping-cart-line-item-status') || document.getElementById('CartDrawer-LineItemStatus');
const debouncedOnChange = debounce((event) => {
this.onChange(event);
}, ON_CHANGE_DEBOUNCE_TIMER);
this.addEventListener('change', debouncedOnChange.bind(this));
}
cartUpdateUnsubscriber = undefined;
//class functions ....
Hi Robbie123,
did you get any solution for this?
thanks!
nop, I can’t find any doc related to this