• I’m having trouble creating attributes for products. For example I have products that have different color. So the main attribute is Color and the Variables would be Red, Orange and Purple.

    I have tried the following but I am unable to set it.

    wp_set_object_terms( 165, 'Color', 'pa_colour' );
    wp_set_object_terms( 165, Array("Red", "Orange", "Purple"), 'pa_colour' );

    How do I create the attributes first and link them to the product?

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter timothyky

    (@timothyky)

    I’ve been able to do some research and able to create the attribute.

    $wpdb->insert(
    	$wpdb->prefix . 'woocommerce_attribute_taxonomies',
    	array(
    		'attribute_label'   => $data['attributelabel'],
    		'attribute_name'    => $data['attributename'],
    		'attribute_type'    => $data['attributetype'],
    		'attribute_orderby' => $data['attributeorder'],
    	)
    );

    However, when I tried the following code:

    wp_set_object_terms (165, 'variable', 'product_type');
    wp_set_object_terms( 165, Array("ta", "tb"), 'pa_testing' );

    I check the backend I see the product is linked to the attribute however the textbox for the values are missing. I am not able to even enter the variation page for the product.

    Anyone have any idea?

    Thread Starter timothyky

    (@timothyky)

    Is the inserting method I am using for the attribute incorrect causing me not being able to see the product attribute variables in the backend?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having Trouble Creating Attributes and Linking Attributes to Product’ is closed to new replies.