p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional WordPress (http://p2p.wrox.com/forumdisplay.php?f=567)
-   -   get current term id for attribute_pa_color (http://p2p.wrox.com/showthread.php?t=99593)

nsdinc August 1st, 2017 12:55 AM

get current term id for attribute_pa_color
Hi, I’m trying to convert the selected color on my product pages dropdown box to a PHP variable to use in a custom price table.
I’ve tried using $wpdb but can’t figure out how to get the current term id for attribute_pa_color. It works if I manually put the colors term id in. the same happens when I try to use new WP Query () and SQL code.
I can convert to PHP when I use JQuery with a hidden form. This changes the price table to the correct selected color but the image then defaults back to the original default value so the price table and colored image don’t match.
I’ve tried XMLHttpRequest() but of course it sends the variable back as HTML. I tried processing the entire table in the XMLHttpRequest() PHP file. This will send the correct color back but will not process the same php code that I use in my other files. I’ve tried calling the header, footer and other files into this file to get the php to work but it even rejects these requests.
I’ve used many varieties of get_the_terms($product->id, 'pa_color') but I get all the colors for that product not the selected one. Again, I’m new at coding and WordPress and would appreciate any help with this.

All times are GMT -4. The time now is 11:45 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.