WordPress.org

Ready to get started?Download WordPress

Forums

MarketPress - WordPress eCommerce
[Plugin: WordPress eCommerce - MarketPress] Controlling total number of tickets across all variants (6 posts)

  1. billc108
    Member
    Posted 2 years ago #

    WordPress Ecommerce currently allows you to set the number of tickets available by ticket type/variant type.

    In our situation, we need to control the total number of tickets available for an event across all variants. For instance, a particular event allows 20 attendees total. Tickets can be sold as singles at one price, pairs at a lower per-ticket price, and in threes at a still lower per-ticket price. We don't particularly care if we sell 20 singles or 10 doubles, but the total sold needs to be a max of 20. As choices are made, the available number of tickets of the other types should adjust accordingly.

    Any pointers on how to get that to happen? Or if it can be added to the features request list?

    http://wordpress.org/extend/plugins/wordpress-ecommerce/

  2. DavidM
    Member
    Posted 2 years ago #

    Hi billc108,

    That would take some serious code tweaking to make happen with MarketPress at the moment. I'll pass that on to the developer for further consideration though.

    Thanks,
    David

  3. billc108
    Member
    Posted 2 years ago #

    I'm not afraid to do some serious code tweaking... or work with you guys to get it done.

    Please ask your developer to let me know how he'd like me to proceed. Contact me through sustainablesources.com/about/contact-us/

    Thanks.

  4. billc108
    Member
    Posted 2 years ago #

    Just touching base on this. I haven't heard from a developer yet on guidelines on how to modify this plugin such that we have the ability to set the total number of tickets sold for an event across all variants, instead of each variant having its own inventory number.

  5. masonjames
    Volunteer Moderator
    Posted 2 years ago #

    Hiya billc108,

    I can help provide the customizations for you - but you'll have to continually make them after each update until we add this feature to the core plugin (and we have no ETA for this).

    The good news is, there's only 3 changes we have to make.

    Open up wordpress-ecommerce/marketpress.php and scroll down to line 1846. This is the inventory checkbox. We're first gonna want to make sure this defaults to 'checked'. To do this just add the word 'checked' to the input field. Here's an example:
    <th scope="col" class="mp_inv_col"><label title="<?php _e('When checked inventory tracking will be enabled.', 'mp'); ?>"><input checked type="checkbox" id="mp_track_inventory" name="mp_track_inventory" value="1"<?php checked($meta["mp_track_inventory"], '1'); ?> /> <?php _e('Inventory', 'mp') ?></label></th>

    Now, we just need to input the number you want to use for default on all items (note that you can change them manually per-product, but this will set the default for a product and any variation)

    Look at lines 1864 and 1879. Change the value="0" to the number you'd like to use as default. For example:
    <td class="mp_inv_col"><input type="text" name="mp_inventory[]" value="200" /></td>

    Save the file and try adding a new product. It should do the trick for ya. It's a bit of a hack, but hopefully solves your need in this case.

    Thanks!

  6. billc108
    Member
    Posted 2 years ago #

    Thanks for that. I'm cool with making a few changes when upgrading. It's not uncommon that I have to hack a plugin to make it do exactly what's needed in a given situation, so I always mark which file and line needs it.

    What you've written above works fine to a point. In essence, it presets inventory to "on" and the stock value of each variant to whatever we plugged into lines 1864 and 1879. Unfortunately, it doesn't do what I'm after.

    Let's say I have 30 seats to sell on a bus. I'm offering 3 variations on tickets: cheap, medium, and all-bells-and-whistles. I can fill all thirty seats with any combination of the variations, but the total number of seats sold can't exceed 30 or somebody has to ride on the roof.

    If someone buys one cheap seat, your method shows 29 remaining cheap seats possible and no change to the stock available in 'medium' and 'b&w'. If I don't go in and manually change the stock numbers I could end up selling as many as 90 seats. I need a way to subtract the stock sold from EACH variant whenever ANY variant for a particular product is sold, not just the one from the one variant which was sold.

    I'm guessing what I need will have to occur somewhere in the vicinity of

    //send ajax leftover stock
            if ($no_ajax !== true) {
              $return = $stock[$variation]-$new_quantity . '||';
            }

    probably involving an iterative process through all the variations on that particular $product_id. Right?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic