From: Anthony Talarico Date: Fri, 24 Jun 2016 15:52:36 +0000 (-0400) Subject: adding query string parameters for the enquire form X-Git-Tag: v1.0.0^2~145 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=72a963e237141235a79591b6947e05c0e0f8ba4c;p=WP-Themes%2Ffrancejourneys.git adding query string parameters for the enquire form --- 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 @@
- +