Skip to content

Instantly share code, notes, and snippets.

@mtruitt
Created April 25, 2019 18:07
Show Gist options
  • Select an option

  • Save mtruitt/19fc83b841294060b13ae72e3e66a577 to your computer and use it in GitHub Desktop.

Select an option

Save mtruitt/19fc83b841294060b13ae72e3e66a577 to your computer and use it in GitHub Desktop.
Example of how to update postmeta on a new product.
<?php
function add_this_to_new_products( $product_get_id ) {
$productType = WC_Product_Factory::get_product_type( $product_get_id);
if( $productType == 'registrations') {
update_post_meta( $product_get_id, '_tax_status', 'none' );
}
}
add_action( 'woocommerce_update_product', 'add_this_to_new_products', 10, 1 );
@mtruitt
Copy link
Author

mtruitt commented Apr 25, 2019

This example is changing tax status to none on product type of registrations.

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