Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Any Way To Force USPS Express Shipping based on dollar amount?

Any Way To Force USPS Express Shipping based on dollar amount?

Locked

Views: 997

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
8 Nov 2010, 9:24 PM
#1
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Any Way To Force USPS Express Shipping based on dollar amount?

Is there anyway to force USPS Express shipping if the order amount is over a certain amount?

ex. $8 order

the regular shipping options:
1st Class Mail International (no tracking)
Express Mail International (tracking)

$1000 order

shipping options:
Express Mail International (tracking) only

using USPS Shipping API quotes (weight)

8 Nov 2010, 11:48 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Any Way To Force USPS Express Shipping based on dollar amount?

You can use something like this in the quote function:

          $cost = preg_replace('/[^0-9.]/', '',  $cost);

// bof: skip shipping method type based on amount
          $skip_method = false;
          $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices();
// echo 'Type: ' . $type . '<br>';          
          if ($order_total_amount > 8 && $type == 'First-Class Mail International Letter') {
            $skip_method = true;
          }
          if ($skip_method) { 
            // do not show
          } else {
          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
          }
// eof: skip shipping method type based on amount
        }

        $this->quotes['methods'] = $methods;

You can uncomment the echo line to see for sure what your type is on the shipping that you want to make disappear ... it has to be exactly the same ...

The code in red is the new code ...

9 Nov 2010, 2:46 PM
#3
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Any Way To Force USPS Express Shipping based on dollar amount?

Works Perfectly! :clap:

How would I add one more mail class to this skip method?

      if ($order_total_amount > 8 && $type == 'First-Class Mail International Letter') {

to something like

      if ($order_total_amount > 8 && $type == 'First-Class Mail International Letter', 'Priority Mail') {
9 Nov 2010, 3:36 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Any Way To Force USPS Express Shipping based on dollar amount?

Close but ... not quite ...

Try:

      if ($order_total_amount > 8 && ($type == 'First-Class Mail International Letter' || $type == 'Priority Mail')) {
9 Nov 2010, 6:15 PM
#5
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

Re: Any Way To Force USPS Express Shipping based on dollar amount?

Wooo Hooo!

Good Old pipe-y "||" pants!

Thanks Again! :cheers:

9 Nov 2010, 6:23 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Any Way To Force USPS Express Shipping based on dollar amount?

You are most welcome ... thanks for the update that you have this working now with the exclusions of USPS methods based on the type and amount of the order ... :smile: