Okay
  Public Ticket #4311407
New Feature desire
Open

Comments

  •  3
    Brian started the conversation

    I could really use on the inventory screen the sales number for a product. Just like you show in stock amount, I'd like to see on the same screen for B2B and B2C how many have been sold of that product. 

    Thanks,

    Brian

  •  2,510
    WebWizards replied

    Hi Brian,

    Glad to assist,

    We may be able to do that with a code snippet.

    Could you please clarify where exactly you'd like to see this sales number displayed? Would this be on the frontend single product page? (e.g. alongside the price and add to cart button)


    Kind regards,
    Stefan

     

  •  3
  •  3
  •  2,510
    WebWizards replied

    Hi Brian,

    To display the number of sales there, you can add this PHP code snippet to your site:

    https://pastecode.io/s/xkitx2ja

    It should display that as follows:

    2414178764.png

     

    Kind regards,

    Stefan

  •  3
    Brian replied

    I sent a reply yesterday but it was not correct . I have B2B customers as well but I see that the sold is counting them.  We build pinball machines and they are pre-ordered so what I'm really trying to find out is how many are sold + how many have been invoiced.  I have about 15ish different status for orders.  Is there a way you can put another field on the inventory screen of how many of that product are in an "other" status other than completed, or paid awaiting production? In other words everything else that is not in a paid status?  In addition (probably too much) is there a way this info can show up on the order list page in their own columns?  Then you can look at a glance of products "sold" without having to go to each product page.  Thanks!  Great work so far!

    Attached files:  Screenshot 2025-08-27 at 9.48.47 AM.png

  •  2,510
    WebWizards replied

    Hi Brian,

    Thank you for clarifying,

    The problem with that is performance. It is difficult to do that query in a live way. We cannot just query all orders with completed status because after a certain point (e.g. thousands of orders) that might not load at all / crash the page whenever you try to edit a product.

    In the snippet I sent in my last message that uses a heavily cached number (via $total_sales = $product->get_total_sales(); ) that WooCommerce handles by default.

    Therefore unfortunately I think you need something more custom:
    - Either a system that runs whenever an order is updated and maintains a cached number by occasionally incrementing / decreasing the nr.
    - Or a custom inventory management system
    - Or perhaps an occasional SYNC (so that instead of pulling that info each time and risk crashing the page, you can do it on occasion, e.g. once per day).

    This is achievable but I'm afraid it goes beyond what I can provide here as part of support - I'd recommend working with a developer on a custom project. You can take a look at https://codeable.io for a quote. The project itself is not too complex in my view and also does not require specific knowledge of B2BKing (it is mostly Woo functionality), so I believe a WooCommerce developer should be able to do it.

    Kind regards,
    Stefan