Free Shipping by Shopper Group

(1/3) > >>

grwright:
Allowing free shipping to a group of users seems to be a common question here. I'm surprised no one has posted a solution before now. It only took me about 30 minutes to figure it out.

Here is one way to allow free shipping to a group of users. This is for VM 1.1.

First, create a new shopper group called "Free Shipping". You could also use an existing group if you want. Add the users that you want to allow free shipping to this group.

Next, find the following line in ps_checkout.php:

Code:

                if( $vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping) {


Change it to something similar to this:

Code:

                $db = new ps_DB;
                $q = "SELECT shopper_group_name " .
                     "FROM #__{vm}_shopper_group g, #__{vm}_shopper_vendor_xref x " .
                     "WHERE x.user_id = '" . $_SESSION['auth']["user_id"] . "' " .
                     "AND g.shopper_group_id = x.shopper_group_id";
                $db->query($q);
                if( $db->f("shopper_group_name") == "Free Shipping") {
                        $PSHOP_SHIPPING_MODULES = Array( "free_shipping" );
                        include_once( CLASSPATH. "shipping/free_shipping.php" );
                        $this->_SHIPPING = new free_shipping();
                }
                elseif( $vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping) {


Note: If you used a group name different than "Free Shipping" then change the 8th line above to match.

I hope this helps.

Bob Bloom:
I was responding to a post, and I saw this thread. So I thought I'd add my 2cents!

A client asked me about this, so I snuck it into my Shipping Bypass add-on for VM 1.1.0 (http://www.southlasalle.com/forum/viewtopic.php?f=5&t=9). I strongly recommend that you upgrade to VM 1.1.2, which has an adaptation of my Shipping Bypass add-on built right in.

This is what I have in my ps_checkout.php file. I figured most people want my Shipping Bypass code, not my Shopper Group code, so my code is commented out. I have comments explaining how to enable the code. So, it does look kinda confusing.

Mine is not exactly an elegant solution. You have to know the shopper id number -- no easy drop down boxes in VM's config. And my code is ready to go for one shopper code only. So, if don't mind fishing for the id, and you need just one shopper group, then you are in luck!

My client needed free shipping for Shopper Group "8". I think that means I've "optimized the code" -- is that what it is?!!


Quote

/* ======================================================================================================================================
   START: DISPLAY VM's FREE SHIPPING MODULE IF THE USER BELONGS TO SHOPPER GROUP 8 (OR WHATEVER shopper_group_id YOU SPECIFIY -BOB BLOOM
   ====================================================================================================================================== */
$auth = $_SESSION['auth'];
      

/* *************************************************************************************************
   ** ALERT! YOU MUST FIND THE FOLLOWING IF CONDITION NEAR HERE AND DELETE IT (OR COMMENT IT OUT) **
   ** IF YOU ARE COPY-PASTING CODE. THE ORIGINAL IF CONDITION IS:                                 **
   ** if( $vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping ) { **
   *************************************************************************************************
      

   *************************************************************************************************
   ** NOW, WHAT I DID WAS TURN OFF THIS OPTIONAL FEATURE, BY KEEPING THE ORIGINAL IF CONDITION    **
   ** SO, IF YOU WANT TO ENABLE THIS FEATURE, YOU MUST COMMENT OUT THE FOLLOWING LINE             **
   *************************************************************************************************
   ** I TURNED IT OFF SO MY SHIPPING BYPASS AND PAYMENT BYPASS WORK SIMPLY BY OVERWRITING FILES   **
   *************************************************************************************************
   ** SO, IF YOU WANT TO ENABLE THIS SHOPPER GROUP FEATURE, YOU MUST COMMENT OUT THE NEXT LINE    **
   ************************************************************************************************* */
   if( $vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping ) {

/* *************************************************************************************************
   ** THEN, YOU HAVE TO UN-COMMENT THE NEXT LINE, AND THEN SPECIFY THE APPLICABLE SHOPPER GROUP # **
   ************************************************************************************************* */
   //if( ($vendor_freeshipping > 0 && $vars['order_subtotal_withtax'] >= $vendor_freeshipping) || ($auth['shopper_group_id'] == 8) ) {

/* ======================================================================================================================================
   END: DISPLAY VM's FREE SHIPPING MODULE IF THE USER BELONGS TO SHOPPER GROUP 8 (OR WHATEVER shopper_group_id YOU SPECIFIY -BOB BLOOM
   ====================================================================================================================================== */


-Bob

P.S. My "8" turned into a happy face. If PHP would just parse happy faces, my clients would be a whole lot happier! Dear Zend...

osmosisinc:
I wonder if I can use this for multiple groups? For example, I need not only group 8, but groups 3 and 6...?

osmosisinc:
After reading more carefully, I see not... :(

hmm, a quandry.

Reincha:
if anybody is still looking how to add multiple groups:

i took code from 1st post and repeated this part for each group right where first finishes:

if( $db->f("shopper_group_name") == "Free Shipping") {
$PSHOP_SHIPPING_MODULES = Array( "free_shipping" );
include_once( CLASSPATH. "shipping/free_shipping.php" );
$this->_SHIPPING = new free_shipping();
}

-------
now, maybe anybody knows if its possible to make a coupon for free shipping?

Navigation

[0] Message Index

[#] Next page