Hot answers tagged

1

There are some errors as get_post_meta() first argument need to be a defined product ID here (and in your code post_ID is not even dynamic variable and will not give anything)… Try the following: <?php function check_gtin(){ if ( $gtin = get_post_meta(get_the_id(), 'gtin', true) ){ echo "gtin13:". $gtin; } else { ...


1

The $havemeta variable isn't defined inside your shopping_location_text() function, so it isn't available for use there. For a quick fix (or for testing/toying) you can move your code inside the function, like this: add_action( 'woocommerce_before_main_content', 'shopping_location_text', 10 ); function shopping_location_text() { global $current_user; ...


1

$boat_safety_terms_cleaned_sorted = sort( $boat_safety_terms_cleaned ); error_log( print_r( $boat_safety_terms_cleaned_sorted, TRUE ) ); PHP's sort accepts an array reference and sorts in-place, and returns success or failure - hence the 1 you're getting. You want: sort( $boat_safety_terms_cleaned ); error_log( print_r( $boat_safety_terms_cleaned, TRUE ) );...


Only top voted, non community-wiki answers of a minimum length are eligible