Found the solution to make a product attribute, a variation.
Lets say we have:
wp_set_object_terms( $post_id, 'XL', 'pa_size' );
Above is a custom attribute (a size attribute). In order to make it a variation you need to do this:
$thedata = Array('pa_size'=>Array(
'name'=>'pa_size',
'value'=>'',
'is_visible' => '1',
'is_variation' => '1',
'is_taxonomy' => '1'
));
update_post_meta( $post_id,'_product_attributes',$thedata);
Related Posts:
- How can I allow commas in tag names?
- wp.media update options and force render on uploader
- How can I modify what is being output in wp_head, whether by a theme or WordPress in general?
- Where should I use get_option in a plugin
- WordPress Plugin Development from Scratch. How? [closed]
- How to access options of Redux framework in front end
- Using tabs for wordpress plugin
- How can I save repeatable fields with one value inside an array?
- Automatic updates not working/plugins not installing
- append stylesheet via shortcode
- Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
- Remove action from woocommerce barcode plugin [closed]
- How to call bind function in wordpress actions or hooks
- clean wp_options table unused rows
- Disable Other Plugins on my Custom Post Type?
- Passing RichText attributes to function onChange
- Getting media library popup in custom plugin admin page
- How to write one comment and publish on every post using database or plugin?
- ‘wp_login’ action hook not working with wp-login.php file
- Can WordPress Plugin Directory Cache Delay the Upload of Images?
- Hook (or other way) to find out when another plugin is activated / installed
- Issue using wp-load.php in WordPress Plugin Development
- How to change custom post type pemalink Hierarcy
- Get post values of form created by widget in sidebar
- Calendar Solution: Handling upcoming Dates with Posts?
- Disable woocommerce cookies and delete cart data automatically
- Why required field not working in Country dropdown in WooCommerce –
- WordPress: cleaning media library
- How to identify the names of deleted plugins?
- How to Display Taxonomy Custom Meta Box Data in Archive Page?
- Cannot display settings field
- WordPress 4.2.1 pre_get_comments doesn’t work after update
- WordPress plugin updates / set file as immutable to prevent certain files from changing?
- AJAX search as you type? [duplicate]
- plugin links not working [closed]
- Class variables not correct on page
- How to display price including tax with formatting?
- How can i create a newsletter for my wp blog? [closed]
- Why am I unable to load scripts in head in plugin?
- How to create a page with links to other pages that include image and excerpt?
- Create WordPress posts from JSON array using plugin in admin
- Add SideBar/Widgets Just Below the Post
- Add filter on html tags,attributes on specific function in wordpress
- output html on post or page from custom plugin [closed]
- To perform the requested action, WordPress needs to access your web > server
- Add “Featured Image” box in my plugin post page
- Profile / benchmark wordpress on apache?
- WordPress Object Oriented plugin development [closed]
- CMB2 – array_search or in_array from repeat_group and comma separated values
- Change Header (Logo) Based on Login
- Image Galleries for website migrated from .com to .org
- Call Ajax URL in Plugin
- Am I allowed to enqueue scripts like this to control what pages they are on?
- Shortcode and variable
- Using Microsift Word/Outlook for content publishing to WordPress
- How can I add user profile fields to my mailpress mailout
- How can I create a page as a draft from my plugin?
- Engadget Like most commented plugins
- exec-PHP shows output at bottom of page
- How do I send the contents of a form to deliver to the already existing custom field in the wordpress theme
- How to get custom minimum price in Woocommerce
- Elementor Combined all Sections into 1 Text Editor
- Adding plugin editing capability for Author
- How to hide featured images of all posts falling under the same category in wordpress?
- Getting current user data with MySQL statement
- Multisite – Cloning CPT pages + content (including ACF Flexible Content) from site to site
- Potential issue that plugin could have when it will be installed on several sites
- Cannot view Custom Post Type no matter what I try
- WordPress products authentication
- myStickymenu hide on scroll up to certain Y values
- How to use information from the database in the front-end?
- Mailpoet Sign up on Custom registration form won’t work
- How can I write code in a plugin for my child theme that will allow me to use remove_action() based on if the current page is the home page?
- Get value from an input field and pass into update_meta_data as $meta_value
- How to delete posts older than one year with post meta, post attachments and files?
- custom template only for content
- I keep getting fake users registrations
- Trouble implementing python on WordPress
- Allow non-admin users to access plug-in
- WordPress audio player add class randomly using Audio Album plugin
- “Tree view” for wp_dropdown_categories() markup
- How to display single arbitrary facebook post with a shortcode?
- Best way for overwriting plugin css with custom one
- How to use a Must-Use plugin to hide a regular one and to hide itself?
- WordPress plugin not eching popular posts
- My first plugin doesn’t save the data in options
- Check if MemberPress exists before add_action call
- Response from Php File to Ajax is not getting sent
- What is wrong with this dbDelta syntax?
- How to show more than 10 order on woo commerce order view [closed]
- Call a function with href
- Current location plugin [closed]
- BuddyPress group filter
- How can I convert a complete bootstrap template into a WordPress template? [closed]
- WP Donation Form with custom payment API
- Manually update notification of plugins needing updating
- The Best Multilanguage Plugin supporting the FSE [closed]
- What is the easiest way to create a custom field archive?
- How to make a page setting translatable in theme?
- Can you open a media frame to sellect an attachment to associate with another attachment you are editing on an existing media frame?