add_filter( 'gform_field_value_product_name', 'gform_add_product_name_field' );
function gform_add_product_name_field( $value ) {
-// global $product;
-// return $product->get_title();
+
+ global $product, $post, $woocommerce;
+
+ if ( ! empty($_GET) && isset($_GET)){
+ $title = $_GET['title'];
+ } else {
+ $id = $post->ID;
+ $product_meta = new WC_Product($id);
+ $title = $product_meta->get_title();
+ }
+
+ if ($title){
+ return $title;
+ } else {
+ return __( '(not set)', 'woocommerce' );
+ }
}
add_filter( 'gform_field_value_product_sku', 'gform_add_product_sku_field' );
function gform_add_product_sku_field( $value ) {
-// global $product;
-// return ( $sku = $product->get_sku() ) ? $sku : __( '(not set)', 'woocommerce' );
-}
-
+ global $product, $post, $woocommerce;
+
+ if ( ! empty($_GET) && isset($_GET)){
+ $sku = $_GET['sku'];
+ } else {
+ $id = $post->ID;
+ $product_meta = new WC_Product($id);
+ $sku = $product_meta->get_sku();
+ }
+ if ($sku){
+ return $sku;
+ } else {
+ return __( '(not set)', 'woocommerce' );
+ }
+}
/*---Move Product Title*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
<?php get_template_part('parts/shop-sidebar');?>
</div>
<div id="enquire_button_container">
- <a href="<?php echo get_permalink(163); ?>"><button id="enquire_button"> Enquire about this tour </button></a>
+ <a href="<?php echo get_permalink(2); ?>?sku=<?php echo $sku; ?>&title=<?php echo $title; ?>"><button id="enquire_button"> Enquire about this tour </button></a>
</div>
<?php