MarketPress – Inventory limit and variation on 1 product with different user rates


I signed up to use MarketPress. It’s my first time using it.

Could you please tell how to do the following:

1 product with 10 in stock

Sell for $100

Sell for $80 to student (don’t worry about verifying the student)

Pay deposit $50

Basically three prices to buy the same product (not really a variation in product but in price) and only 10 in stock. So each one added to the shopping cart would reduce the stock.

If I create them in product variations and set each one to 10 then 30 of them can be sold. Which is not what I want, there are only 10 of them. I can’t set them to a limit of something like 5,2, and 3 because I don’t know how many people will purchase with deposit or full.

If there is no way of doing this out of the box then I can give a go at recoding it myself. But do you have any suggestions on the best way? It needs to charge the lower price and reduce the stock count for the shopping cart.

Maybe using the discount code? Would that be the best way or is there another way? If you think the discount way would be the best way do you have any documentation or pointers on the discount code used in MarketPress?

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi Anthony!

    I think your best bet for the reduced student rate is to offer a coupon code, or a similar deal, rather than using a product variation. That would prevent the stocking issue you’re seeing, and make it simpler on the back end to manage. Here’s a tutorial video (it’s part of a great series on MarketPress, totally worth your time to check it out.) on setting up discounts and coupon codes:

    Ideally, you could do the same for the deposit, but then you’d have to follow up manually to get the remainder of the payment, as of right now, MarketPress isn’t set up to manage follow up payments.

    Using this method would ensure your stock was properly reflected, so you won’t over or undersell the service.

    Hope this helps!

  • anthony.g.fitzsimons
    • WPMU DEV Initiate

    I don’t want the user to have to type in a code though.

    Imagine a cinema selling tickets. You have 80 seats and prices for Adults, Children, Students, S-Citizens, Deposit (pay in full on arrival).

    That is 5 prices to take one seat/inventory. This pricing model would go across a lot of industries. If a MarketPress developer could point me in the right direction I would be happy to share my code with WPMUDEV.

  • anthony.g.fitzsimons
    • WPMU DEV Initiate

    Hi, thanks Michelle but I was hoping for more of a developer answer than an out of the box answer. Something to point me in the right direction for me to change the code.

    For example a MarketPress developer could suggest: You can find the coupon function in xyz.php file and if you create a coupon callback function on custom buy now button it should apply aromatically and remember to also change this in the price function on the checkout.

    Or they could suggest something I didn’t think of. Maybe a simpler solution would be to create another tick field in products (“Apply variations to one stock count). Then if a user adds 2 products/tickets to the shopping cart it deducts 2 from the other variations, so they will all have the same stock count.

    Perhaps a developer could inform me of where to look for me to make these changes? This is not a wish list for Marketpress I need to have this in place by next Friday. I can do the work but I’d appreciate developer support in the form of a paragraph or two that just points me in the right direction.

  • Tyler Postle
    • CGO

    Hey Anthony,

    Hope you’re doing well today and thanks for your thorough reply here :slight_smile:

    I believe you will find all the coupon functions inside the marketpress.php file. Just do a search and find and you will be able to roll through them and find the ones you need.

    I will also call in one of our developers so we can get their valuable feedback on this as well. Keep in mind the developers have many other responsibilities so response times can be a bit slower than normal. Especially during the weekend :slight_smile:

    Thanks again Anthony. In the meantime, you can browse through the marketpress.php file or ask us any other questions you may have!

    Have a great rest of your weekend.

    All the best,


  • anthony.g.fitzsimons
    • WPMU DEV Initiate

    Suggestion for Next Version of Market Press.

    If you guys plan on making another version maybe think of adding an additional “single inventory” field on the admin product page, and then cinema tickets and all sorts of complex product variations of prices and be created, even price add-ons all handled because of one field. The field could say “If these variations use a single inventory enter the maximum amount that can be sold”. The “add to cart” button would check this number before adding products to the cart.

  • Hoang Ngo
    • Code Slayer

    Hi @anthony.g.fitzsimons,

    I hope you are well today.

    Unfortunately this is a extremely complex feature and is beyond the scope of custom coding that we could provide.

    For archive this, I think we can do like this

    1.We will need a custom field for product’s inventory, so instead of getting the inventory from variant, we will get from product. We can use the metabox for archive this.

    2.Assume that you have the metabox working, and now you can add inventory for product, of course, you can using the variant inventory for limit of that variant, so to archive that, we will need to modify the code a little bit, file /marketpress/marketpress.php line 3541, you will see the code like this

    $this->create_order(false, $cart, $_SESSION['mp_shipping_info'], $payment_info, true);

    So upper that code, you can adding a condition for validate the cart inventory data.

    3.So now all the data is passed, after the order, you will need to reduce the inventory, so the hook mp_new_order is what you need now.

    function update_order_addition_meta($order_id){
    //process your logic code here.

    From an order, you can address the product detail by using the function get_order(), example

    global $mp;
    if($mp instance of MarketPress){
    $order = $mp->get_order($order_id);

    So you can getting the order info and update the inventory of the products.

    If you have any issues please don’t hesitate to let us know so we can assist

    Best regards,

    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.