Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Disable Shipping Method above a certain weight


Marc_J

Recommended Posts

I'm currently using 2 shipping modules - the Zone Rates that comes with osC (used for TNT Express rates) and the Zone Shiping Rates Update (UK Royal Mail) contrib for UK Postage rates wordlwide.

 

The postal rates are only good for orders up to 2Kgs, after that the TNT rates tend to be better. The customer gets to choose from both methods at the checkout.

 

I only priced the postage rates up to 2Kgs, for orders above that weight the postal option is still able to be selected, although it says "The shipping rate cannot be determined at this time" and the price is shown as 0.00.

 

My point is, if someone sees a shipping charge of 0.00 they'll invariably click it and proceed, especially if given another option which has a price (which they SHOULD be selecting).

 

Is there a way of disabling a shipping module above a certain weight, so that the postage method isn't offered above 2 Kgs?

 

I know I could put an extra entry at the end of postal rates like ...1.9:16.48,2:17.33,100:500.00 to make sure no-one selects it over 2 Kgs (who wants to pay ?500 shipping?) but that seems a "messy" way of doing things...

 

Also, I could combine the two into one module (postal rates <= 2Kgs, TNT rates > 2Kgs) but I want to give customers the option of express shipping at an extra charge, for lighter orders.

Link to comment
Share on other sites

I've made quite some changes in my shipping pages, so I'm not sure if this does it completely, let me know how it goes:

 

Go to the particular include/shipping/module/xxx.php and change the beginning of hte quote function for the selected xxx shipping method, by adding the if statement, and change 30 to your particular value, eg 2kg or 2000gr depending on your setup.

 

// class methods
   function quote($method = '') {
     global $order, $shipping_weight;

       if ($shipping_weight > 30) { 
      	 $this->quotes = array('module' => $this->title,
                             'error' => 'Max weight superceded');
      	 return $this->quotes; }

 

In includes/classes/shipping.php my cheapest function looks like this to avoid selecting a 0$ as default for eg a store pickup that is active:

(I think I only changed the inner if, but just in case here's the full function)

    function cheapest() {
     if (is_array($this->modules)) {
       $rates = array();

       reset($this->modules);
       while (list(, $value) = each($this->modules)) {
         $class = substr($value, 0, strrpos($value, '.'));
         if ($GLOBALS[$class]->enabled) {
           $quotes = $GLOBALS[$class]->quotes;
           for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
             if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])
             && ($quotes['methods'][$i]['cost'] > 0)
             ) {
               $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
                                'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
                                'cost' => $quotes['methods'][$i]['cost']);
             }
           }
         }
       }

       $cheapest = false;
       for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
         if (is_array($cheapest)) {
           if ($rates[$i]['cost'] < $cheapest['cost']) {
             $cheapest = $rates[$i];
           }
         } else {
           $cheapest = $rates[$i];
         }
       }

       return $cheapest;
     }
   }

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...