If my category is the same in wocommerce category do the action

Hello guys i have code below the code is running if I assign id=1, etc. and repeat my codes, i want to happen is it will automatically post the code if the category name in my table and categoryname in woocommerce are the same.,

for example ihave
mytable

id categoryname imageurl
1 wedding https://wordpress.stackexchange.com/
2 birthday https://wordpress.stackexchange.com/

wordpresstable

id name
1 rings
2 wedding

wedding=wedding
what will happen is if mytable.categoryname=wordpresstable.name then the imageurl will display to wedding category only.can you read my code if this is correct?ThankYou.

add_action( ‘woocommerce_before_add_to_cart_button’, ‘size_guide_data’ );
function size_guide_data() {
global $wpdb;
$table_name = $wpdb->prefix . “sizeguide”;
$datas = $wpdb->get_results(“SELECT * from $table_name where id=1″);
foreach ($datas as $data) {
if ( has_term( $data->category, ‘product_cat’ ) && has_term( $data->prodtype, ‘product_type’ )) {
?>

imageurl; ?>” target=”_blank”>name; ?>/wp-knaven/images/sg-icon.png” width=”24″ height=”24″>

Read more here:: If my category is the same in wocommerce category do the action

Leave a Reply

Your email address will not be published. Required fields are marked *