PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, May 9, 2022

[FIXED] How to change sold_individually product property in WooCommerce

 May 09, 2022     metadata, php, product, woocommerce, wordpress     No comments   

Issue

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!


Solution

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…



Answered By - LoicTheAztec
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing