Is there a manner so as to add customized information to the cart utilizing javascript? The info is from URL question params. I’ve tried utilizing woocommerce_add_cart_item_data
and setting query-vars and so forth, however my information just isn’t populated on the time I click on the add to cart button. I’m pondering perhaps the $( doc.physique ).set off( 'adding_to_cart', [ $thisbutton, data ] );
occasion however I’m not positive easy methods to go about including the url params as additional information. Right here is my code up to now.
$(doc.physique).on('adding_to_cart', operate( button, information ) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
//the url params that i need to add as customized cart information
var colour = urlParams.get('colour'),
hexcode = urlParams.get('hex'),
extracost = urlParams.get('value')
})