[MarketPress eCommerce] Quantity discounts MarketPress

Hi again guys, hope you’re doing well!

On another project, I’m selling a high-value book and would like to offer discounts for quantity purchases. Browsing the forums I’ve created a workaround involving creating product variants for quantities, fixing the buying limit to one, then hiding the regular quantity field on the product page using CSS (works for the shortcode too). [Edit: just realised there was no need for the CSS, it’s now an option in MarketPress…doh! The quantity is still visible on the cart page, too…]

It works ok, but it’s not terribly elegant. For a start the price shows at 0 until you select a variant. It also would make the stock control wrong as variants are not designed for this.

Since it’s been a few years that people have been requesting this, any chance we could get this in MarketPress and avoid the complexity of WooCommerce? Pretty please with cherries on top? :smiley:

  • Ash
    • WordPress Hacker

    There is no easy solution I am afraid. I have a very dirty hack, not sure if it can fulfill your plan but you can take a look:

    add_action( 'wp_head', function(){
    if( mp_is_shop_page( 'cart' ) )
    $item_count = 5;
    $coupon = 'XXXX';
    .mp_cart_item_content-qty{display: none;}
    <script type="text/javascript">
    jQuery(function( $ ){
    var length = 0;

    $( '.mp_cart_item_content-qty' ).each(function(){
    length += parseInt( $(this).find( 'select' ).val() );

    if( length >= <?php echo $item_count; ?> )
    $( '.mp_coupon_form .mp_form_input' ).val( '<?php echo $coupon; ?>' );
    $( '.mp_coupon_form .mp_button-check' ).click();

    You can use this code in your child theme’s functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Have a nice day!



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.