Skip to content

Instantly share code, notes, and snippets.

@dizzyza
Created May 24, 2021 21:14
Show Gist options
  • Save dizzyza/2e17526d9d76eb9f3cea2635af52fe1b to your computer and use it in GitHub Desktop.
Save dizzyza/2e17526d9d76eb9f3cea2635af52fe1b to your computer and use it in GitHub Desktop.
Add Code From A Page To Hidden Fields In Gravity Form Embedded In Popup Maker
function custom_jc_woo_product_loop_Contact_for_bulk_pricing(){
global $post,$product;
$formsku = get_post_meta(get_the_id(), '_sku' , true);
$permalink = get_the_permalink();
//Request Quote Button,
echo "<a class='ab-item button pdfspec' href='' onclick=\"save_current_product('$formsku', '$permalink'); PUM.open(43068);return false;\">Request Quote</a>";
}
<script>
jQuery(function($){
// Populate SKU and embed_url hidden fields on popup opening.
$(document).on("pumBeforeOpen", "#pum-43068", function(){
try {
$("#input_3_5").val(window.current_product_url);
$("#input_3_8").val(window.current_product_sku);
} catch(e) {
$("#input_3_5").val("");
$("#input_3_8").val("");
}
});
});
// save current product's SKU and URL to be available on popup opening.
function save_current_product(sku, url)
{
window.current_product_sku = sku;
window.current_product_url = url;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment