WordPress.org

Forums

WooCommerce - excelling eCommerce
Having Trouble Creating Attributes and Linking Attributes to Product (3 posts)

  1. timothyky
    Member
    Posted 2 years ago #

    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?

    http://wordpress.org/extend/plugins/woocommerce/

  2. timothyky
    Member
    Posted 2 years ago #

    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?

  3. timothyky
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.