Created
June 9, 2022 09:34
-
-
Save alewolf/12f2d9b7ccfc106e94e36e0799ed213b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* If you want to fire the ViewItem event on variable products when | |
* no variation has been selected yet, then use the following code in | |
* your functions.php file. | |
*/ | |
add_action('wp_footer', function () { | |
?> | |
<script> | |
new Promise((resolve) => { | |
(function waitForjQuery() { | |
if (window.jQuery) return resolve() | |
setTimeout(waitForjQuery, 100) | |
})() | |
}).then(() => { | |
jQuery(function () { | |
jQuery(".single_variation_wrap").on("hide_variation", function () { | |
jQuery(document).trigger("wpmViewItem") | |
}) | |
}) | |
}) | |
</script> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment