Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Problem with Shipping module modification


Portman

Recommended Posts

Hi,

 

I'm trying to create a flat rate shipping module that only kicks in when a customer spends over $200

 

I Cant see why this does not work.... can someone please help me out;

// class constructor
    function flat() {
      global $order, $cart; // I added $cart as a global

      $this->code = 'flat';
      $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);

	 $flat_order_total = $cart->show_total(); // I Added this Bit *********
 
      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
	}

	if ($order_total < 200) {   // I added this if statement as well...
		  $this->enabled = false;
	  }	  
    }

Originally I changed the module while it was installed and it worked on the customer side - but caused problems in the admin.... I had to remove references to it in the configuration table as I could not get into the shipping module section of admin and had to physically remove it from the folders before I could get into the shipping modules section of admin.

 

Any help would be brilliant as I was going to use this as an opening special... and am just trying to sort this one problem out before i go live .... everything else is shmicko!!

Link to comment
Share on other sites

Hallo!

I dont understand your problem.

In admin module order total you can configure that you want free shipping with any amout you want, so why change code and make a new free shipping when It is allready included in the original OSC.

Link to comment
Share on other sites

Hi,

 

I'm trying to create a flat rate shipping module that only kicks in when a customer spends over $200

 

I Cant see why this does not work.... can someone please help me out;

        $flat_order_total = $cart->show_total(); // I Added this Bit *********
 
      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
	}

	if ($order_total < 200) {   // I added this if statement as well...
		  $this->enabled = false;
	  }	  
    }

Hi,

 

if you define a variable $flat_order_total you should use this variable and not an undefined $order_total :-

if ($flat_order_total < 200) {   // I added this if statement as well...
          $this->enabled = false;
      }

J.J.

Link to comment
Share on other sites

and you can add the check much earlier in the code, just after where you fetch the total, just before the if statement with the database query

 

saves time and resources

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

I use this in one my shipping modules to disable it if it goes above a certain amount (due to insurance limit):

if ($order->info['total'] > 2500)  {   				
    $this->enabled = false;	
}	

Just change it to suit and put it higher up as the above poster said

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...