[MarketPress eCommerce] Addition to shipping table in Marketpress

I\'d like to be able to charge shipping based on number of products rather than just total $ for cart - is there an option for that in Marketpress? or something else I could use on WPMU DEV?

  • Dimitris

    Hello there Glenn,

    hope you're doing good today! :slight_smile:

    There isn't any way to accomplish this in MarketPress I'm afraid, or by using any other plugin.
    This thread is already in our Features&Feedback section of our forums, so if more members upvote it, our developers will consider adding it as a new feature.

    Meanwhile, I've already contacted MarketPress developers to provide some insights on this, in case this is something that could be easily be done with few modifications.

    Me or another colleague of mine will keep you posted here, as soon as we've got some valuable feedback.

    Warm regards,
    Dimitris

  • Dimitris

    Hello Glenn,

    I just had some feedback from our SLS team. It seems that this is possible by setting the Table Rate option and use the mp_calculate_shipping_table_rate filter in a MU plugin, for example in wp-content/mu-plugins/mp-shipping.php(create both /mu-plugins/ folder and .php file in your server, and insert the exact snippet in there)

    <?php
    add_filter( 'mp_calculate_shipping_table_rate', function( $price, $total, $cart ){
    
      $cart_items_shipping = array(
          //number of products => shipping price
          '2' => 2.8,
          '5' => 6,
          '8' => 7,
          '10' => 8,
          '15' => 10
      );
    
      $cart_items_count = $cart->item_count( false, false );
    
      foreach( $cart_items_shipping as $items => $s_price ){
          if( $items >= $cart_items_count ){
              return $s_price;
          }
      }
    
      return $price;
    
    }, 20, 3 );

    Warm regards,
    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.