From 72a963e237141235a79591b6947e05c0e0f8ba4c Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 24 Jun 2016 11:52:36 -0400 Subject: [PATCH] adding query string parameters for the enquire form --- functions.php | 37 +++++++++++++++++++++++++++++++------ sidebar.php | 2 +- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/functions.php b/functions.php index f4a8ed9..80ea695 100644 --- a/functions.php +++ b/functions.php @@ -112,16 +112,41 @@ function woo_photos_content() { 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 ); diff --git a/sidebar.php b/sidebar.php index ab80484..a1fcdc8 100644 --- a/sidebar.php +++ b/sidebar.php @@ -9,7 +9,7 @@
- +