Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Musilda/b77a94b43dfe508d6a30d0ecc20051bb to your computer and use it in GitHub Desktop.
Save Musilda/b77a94b43dfe508d6a30d0ecc20051bb to your computer and use it in GitHub Desktop.
<?php
$product_id = 111;
wp_remove_object_terms( $product_id, 'simple', 'product_type' );
wp_set_object_terms( $product_id, 'variable', 'product_type', true );
@baras
Copy link

baras commented Jan 4, 2021

Hi,
A product can't be of multiple types, isn't this enough?

<?php

$product_id = 111;
wp_set_object_terms( $product_id, 'variable', 'product_type' );

This should delete any existing product_type values and set only variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment