Hi Nicolas,
I did have the '#hikashop_product_option_7' in my original code but it still did not work.
I finally got it to trigger and update the custom field using the following code:
document.getElementById('hikashop_product_option_7').onchange = function() {
const service = this.value;
const qty = document.getElementById('hikashop_product_quantity_field_1').value;
document.getElementById('fsw_quantity').value = qty;
if(service == '0') {
console.log('None');
}
if(service == '1') {
console.log('Bronze');
}
if(service == '2') {
console.log('Silver');
}
if(service == '3') {
console.log('Gold');
}
}
I see what you mean by the ids. They are dynamically created for each product page. To avoid this I created another custom drop down field so the id will be consistent on all product pages making it easier to target.
How do I get the price with options?
I tried:
document.getElementById('hikashop_product_price_with_options_main').value;
This does not work. It returns undefined.
How would I use the calculations plugin to add the new price to the product?
Am I calculating the price in JS and sending that to my custom field ?
What is the syntax used in the price calculations plugin?
There is no instructions on its usage.