Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php get woocommerce attribute from database

//This article helped me put everything together - https://www.webhat.in/article/woocommerce-tutorial/how-product-attribute-are-stored-in-database/

global $wpdb;
$posts = $wpdb->get_results("SELECT DISTINCT name FROM $wpdb->terms WHERE term_id in (SELECT DISTINCT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'pa_yourattributename' AND count > 0)");
print_r(array_values($posts));
 
PREVIOUS NEXT
Tagged: #php #woocommerce #attribute #database
ADD COMMENT
Topic
Name
1+3 =