Home › Forums › ACF PRO › Getting WC product SKU from relationship field › Reply To: Getting WC product SKU from relationship field
Figured it out 🙂
$product_id = $p->ID;
$product = wc_get_product( $product_id );
echo $product->get_sku();
Find the post/product ID inside the loop, look for the SKU.
I did notice however that it spits out all the data about the product, which doesn’t seem very optimised? Would there be any way to only get the SKU without getting the whole product data?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.