Get custom product attribute value inside product_attributes in WooCommerce
-
I need to confirm in a loop if the “visitor mail” (a custom product attribute) is what I get on the query string url loading.
My actual code is:
<?php if ( has_term( 'photos', 'product_cat' ) ) { if (isset($_GET['visitormail']) && count($_GET) == 1){ ?> <p class="photos-notify aligncenter">Visiting photos available for <strong><?php echo $_GET['visitormail']; ?></strong> [ <a href="/photos/">Change e-mail</a> ]</p> <?php woocommerce_product_loop_start(); $args = array( //'meta_compare' => 'LIKE', 'post_type' => 'product', 'meta_query' => array( array( 'key' => '_product_attributes', 'value' => 'visitormail', 'compare' => 'LIKE' ) ) ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); { the_post(); /** * Hook: woocommerce_shop_loop. */ do_action( 'woocommerce_shop_loop' ); wc_get_template_part( 'content', 'product' ); } endwhile; } woocommerce_product_loop_end(); ?> <?php }
In this way, I can “filter” those who only have “visitor mail” filled… but not the specific e-mail on the query string ($_GET[‘visitormail’]). I’ve already tried to insert “visitormail” as “key” but it doesn’t work!
Looks like I need to reach the 2nd “layer” of the product_attributes but I din’t found this.
The page I need help with: [log in to see the link]
- The topic ‘Get custom product attribute value inside product_attributes in WooCommerce’ is closed to new replies.