WC_Product::set_tax_status
Set the tax status.
Method of the class: WC_Product{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Product = new WC_Product(); $WC_Product->set_tax_status( $status );
- $status(string) (required)
- Tax status.
Changelog
| Since 3.0.0 | Introduced. |
WC_Product::set_tax_status() WC Product::set tax status code WC 10.5.0
public function set_tax_status( $status ) {
$options = array(
ProductTaxStatus::TAXABLE,
ProductTaxStatus::SHIPPING,
ProductTaxStatus::NONE,
);
// Set default if empty.
if ( empty( $status ) ) {
$status = ProductTaxStatus::TAXABLE;
}
$status = strtolower( $status );
if ( ! in_array( $status, $options, true ) ) {
$this->error( 'product_invalid_tax_status', __( 'Invalid product tax status.', 'woocommerce' ) );
}
$this->set_prop( 'tax_status', $status );
}