Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hey.

 

I'm trying to code a new shipping module - Norwegian letter (to europe).

 

I need a little help. This module must only be activated if another country than your store country is selected by the customer.

I mananged to insert a code for this, but you can only select one country at once.

 

Can someone help me please:=) ?

 

Heres the code:

 

<?php
/*
 $Id: brevposteuropa.php,v 1.0 2006/02/02 00:00:00 Bjørn Olav Bøe Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2002 osCommerce

 Released under the GNU General Public License
*/

 class brevposteuropa {
   var $code, $title, $description, $icon, $enabled;

// class constructor
   function brevposteuropa() {
     global $order;

     $this->code = 'brevposteuropa';
     $this->title = MODULE_SHIPPING_BREVPOSTEUROPA_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_BREVPOSTEUROPA_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_BREVPOSTEUROPA_SORT_ORDER;
     $this->icon = DIR_WS_ICONS . 'posten.png';
     $this->tax_class = MODULE_SHIPPING_BREVPOSTEUROPA_TAX_CLASS;
     $this->enabled = MODULE_SHIPPING_BREVPOSTEUROPA_STATUS;



   if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_BREVPOSTEUROPA_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_BREVPOSTEUROPA_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;
       }
     }
   }



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

                       $vekt = $shipping_weight;

		$query = "select * from brevpost_satser_europa where $vekt<=vekt";
		$result = tep_db_query($query);
		$row = tep_db_fetch_array($result);
		$totalpris=$row["sone"];


     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_BREVPOSTEUROPA_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => MODULE_SHIPPING_BREVPOSTEUROPA_TEXT_WAY,




                                                    'cost' => MODULE_SHIPPING_BREVPOSTEUROPA_CODCOST + $totalpris)));

     if ($this->tax_class > 0) {
       $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }

     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);











return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_BREVPOSTEUROPA_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tilby Brevpost sending til Europa', 'MODULE_SHIPPING_BREVPOSTEUROPA_STATUS', '1', 'Vil du tilby Brevpost sending?', '6', '0', now())");
		if (!tep_db_fetch_array(tep_db_query ("select configuration_key from " . TABLE_CONFIGURATION . " where configuration_key='STORE_ORIGIN_ZIP'")))
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Postnummer', 'STORE_ORIGIN_ZIP', '', 'Fyll inn postnummer til butikken som skal brukes i beregning av frakt.', '7', '2', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Legg til gebyr', 'MODULE_SHIPPING_BREVPOSTEUROPA_CODCOST', '0', 'Gebyr for Brevpost, fylles inn eks. mva.', '6', '0', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Skatteklasse', 'MODULE_SHIPPING_BREVPOSTEUROPA_TAX_CLASS', '0', 'Bruk følgende skatteklasse på Brevpost.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_BREVPOSTEUROPA_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Rekkefølge', 'MODULE_SHIPPING_BREVPOSTEUROPA_SORT_ORDER', '0', 'Rekkefølge for visning på side for fraktvalg.', '6', '0', now())");
   }

   function remove() {
     $keys = '';
     $keys_array = $this->keys();
     $keys_size = sizeof($keys_array);
     for ($i=0; $i<$keys_size; $i++) {
       $keys .= "'" . $keys_array[$i] . "',";
     }
     $keys = substr($keys, 0, -1);

     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key ='MODULE_SHIPPING_BREVPOSTEUROPA_STATUS'");
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key ='MODULE_SHIPPING_BREVPOSTEUROPA_CODCOST'");
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key ='MODULE_SHIPPING_BREVPOSTEUROPA_TAX_CLASS'");
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key ='MODULE_SHIPPING_BREVPOSTEUROPA_SORT_ORDER'");
   }

   function keys() {
     return array('MODULE_SHIPPING_BREVPOSTEUROPA_STATUS', 'STORE_ORIGIN_ZIP', 'MODULE_SHIPPING_BREVPOSTEUROPA_CODCOST', 'MODULE_SHIPPING_BREVPOSTEUROPA_TAX_CLASS','MODULE_SHIPPING_BREVPOSTEUROPA_ZONE', 'MODULE_SHIPPING_BREVPOSTEUROPA_SORT_ORDER');
   }
 }
?>

Posted
if ($order->delivery['country']['id'] == X) $this->enabled = false;

 

Where X is the ID of the country that the delivery address is in. It's should be as simple as that.

 

thank you so much.

but where to put it?

And should I remove some of the old zone code?

Posted
"Where X is the ID of the country that the delivery address is in"

 

Should have said;

 

"Where X is the ID of Norway"

 

Thank you. It works!

 

if ($order->delivery['country']['id'] == 240) $this->enabled = false;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...