[ad_1]
Plugin Contributor
Sark
(@sarkware)
I will look into it, meanwhite put the following snippet on your active theme’s functions.php
add_action('woocommerce_after_variations_table', 'trigger_change_event_snippet');
function trigger_change_event_snippet() { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
$("table.variations select:first-child").trigger("change");
});
</script>
<?php
}
@sarkware thanks for your quick reaction!
I have added this snippet, but there is no changes on the product page yet:
Plugin Contributor
Sark
(@sarkware)
Sorry, I made a mistake in the snippet, here is the updated one.
add_action('woocommerce_after_variations_table', 'trigger_change_event_snippet');
function trigger_change_event_snippet() { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("table.variations select:first-child").trigger("change");
});
</script>
<?php
}
@sarkware thank you, Sark! I reuploaded the snippet, but nothing changed. If I open that page with pre-selected variations – field group still isn’t loading.
Plugin Contributor
Sark
(@sarkware)
I think it triggering the change event way too early. we can add a time out like the below. It may solve the issue.
add_action('woocommerce_after_variations_table', 'trigger_change_event_snippet');
function trigger_change_event_snippet() { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
setTimeout(function() {
jQuery("table.variations select:first-child").trigger("change");
}, 800);
});
</script>
<?php
}
This one worked well! Even 400ms is OK!
Thank you a lot!
