I have a popup with the following layout
Plan | Subscription | Region .
dropdown dropdown dropdown
There is a quantity and “Add to Cart” button and a label next to it for showing the amount. I am trying to load the default value when the popup opens (inside this method $(“.show_ct_popup”).click(function(){} ). But the amount not shown. But when I manually change the Region the price shows up. The following method I used to do the same. But I get an error “Uncaught TypeError: Cannot set properties of undefined (setting ‘selected’)” because the amount section for price variation is not loading properly. Is there anything else I have to do in script!?
if($(this).hasClass(‘std_mnth_bt’)){
setTimeout(function() {
$(‘#subscription’).val(’30 Day Trial’).trigger(“change”);
$(“#plan”).val(‘Standard’).trigger(“change”);
$.fn.changeRegion(2, id_number, middle);
}, 2500);
}
$.fn.changeRegion = function(regionOption, id_number, priceText) {
$(‘#region’).find(‘option’)[regionOption].selected=true;
$(‘#region’).trigger(‘change’);
$(‘form.variations_form’).find(‘input[name=variation_id]’ ).val(id_number ).trigger(‘change’); $(‘form.variations_form’).find(‘.woocommerce-variation-price span.woocommerce-Price-amount bdi’).contents().get(1).nodeValue = priceText;
};
Firoz