Created
September 21, 2020 22:06
-
-
Save trvswgnr/c2fe25c7e333f39c95e684b8802eab7f to your computer and use it in GitHub Desktop.
pass product data to javascript
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 | |
add_action( 'wp_head', function() { | |
global $product; | |
wp_localize_script('main-js-script-name', 'product', $product->get_data() ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment