View Single Post
  #1 (permalink)  
Old August 1st, 2017, 12:55 AM
nsdinc nsdinc is offline
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2017
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote