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.
|