Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:54:57+00:00 2026-06-18T08:54:57+00:00

I have a custom post type (product) that have a meta field that hold’s

  • 0

I have a custom post type (product) that have a meta field that
hold’s inventory quantity.

Once an order is made im updating the quantity

`$qty=get_post_meta($post->ID,’stock’,true);

$qty–;

Update_post_meta($post->ID,’stock’,$qty);`

The thing is im afraid that multiple and simultanious calls for this update
Might cause the data to be incorrect If a call will be made while another call is in process…

Is there a way to lock that piece of code and make sure it wont be fired
Simultaniously or am i exadurating in my concerns ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:54:58+00:00Added an answer on June 18, 2026 at 8:54 am

    Well generally there shouldnt be a concern, my issue is why are you getting the quantity and then using it to subtract it and update it again, when everything can be done in one step. I am assuming those 2 methods are making some call to a database. In MYsql you can do something like

    UPDATE yourtable SET quantity = quantity-1 WHERE id = ....
    

    That way the deduction happens in your database and you are saving one query…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template that displays the titles of a custom post type. I
I observed that if I have a custom post type called article, the links
I have to show all the posts from custom type post on my product
I have a custom post type (that I'm using on a template page), the
I have created a wordpress custom post type. I am using custom field template
I have two custom post type: product and faq. The product post type has
I have successfully pulled a custom post type through into a drop-down that is
I have a custom post type FAQ and custom taxonomy Category. I want to
I have created a custom post type named People. I have created a page
i have created a custom post type named Books & i have a widget

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.