Created
August 27, 2018 09:28
-
-
Save Faisalawanisee/815c751b7d07c93adcfd472f28e27256 to your computer and use it in GitHub Desktop.
Engraving Source Code for Michael - Just Replace "FORMID" with your form ID number and all is good to go.
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_filter('gform_pre_render_FORMID', 'populate_posts_FORMID'); | |
| function populate_posts_FORMID($form) { | |
| ?> | |
| <script> | |
| var flag = true; | |
| var checkExist = setInterval(function () { | |
| if (jQuery('form#gform_FORMID').hasClass('cart')) { | |
| jQuery('.engraving_loader').remove(); | |
| clearInterval(checkExist); | |
| } else if (flag) { | |
| flag = false; | |
| } | |
| }, 100); | |
| </script> | |
| <?php | |
| global $product; | |
| foreach ($form['fields'] as &$field) { | |
| if ($field->type != 'select') { | |
| continue; | |
| } | |
| $array = (array) $product; | |
| $prefix = chr(0) . '*' . chr(0); | |
| $sku = $array[$prefix . 'data']['sku']; | |
| if (!empty($sku)) { | |
| $choices = array(); | |
| $choices[] = array('text' => $sku, 'value' => $sku); | |
| $field->choices = $choices; | |
| } | |
| } | |
| return $form; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment