How To Change Sold_individually Product Property In WooCommerce
I need to update '_sold_individually' field of product in woocommerce.
I have using below field it isn't working
update_post_meta($product->get_id(), '_sold_individually', "yes");
Any alternate please help thanks!
As you are already using the
WC_Product instance object
$product, you can better try using
set_sold_individually() dedicated method this way:
$product->set_sold_individually( true ); $product->save();
It should better work and sync product cached data…
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?