Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shipping by categories


AxMendoza

Recommended Posts

Hi everyone , i introduce myself, my name is Axxe, im from Mexico, and work at company that work on copper artisan, well we are introducing a online store, so im working on that.

 

Well i have one problem, i need one shipping module by categories i gonna try to explain me with an example

 

Categories:

 

Bathroom

Kitchen

Forniture

 

Bathroom shipping price is $1.00

Kitchen shipping price is $2.00

Forniture shipping price is $3.00

 

I need that module add the shipping cost Bathroom+Kitchen+Forniture Categories i mean : total shipping cost $6.00.

 

I have looking for entire forum and i have found some shipping module but no how that i need, so if some1 have any idea i gonna be grateful.

 

Hopefully i have explained. Greetings.

Link to comment
Share on other sites

Hi again!, i see that nobody answer my post, so i gonna try to be more explicit.

 

Im modifying Table And Zones By Categories basically i want to do next:

 

Categorie A = Shipping Cost $10

Categorie B = Shipping Cost $20

 

Shipping Total Cost = Categorie A + Categorie B

 

Now i can choose 1 or more item from Categorie A and module give shipping cost correctly ($10) and i can choose 1 or more item from Categorie B and give shipping cost correctly ($20), but if i want to choose one item from Categorie A and 1 item from Categorie B, i mean mixed the categories , the module give as result shipping cost for Categorie A OR Categorie B, i mean i didnt got the sum of the 2 categories shipping cost.

 

I hope have explain me correctly.

 

Anyway i put whole entire code here, i hope someone can help me, :(

 

table.php

 

<?php

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

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

     $this->code = 'table';
     $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;
     $this->icon = '';
     $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_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_TABLE_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 $order, $cart, $shipping_weight, $shipping_num_boxes;


	  $is_category = false;

		$cats_array = explode(',',MODULE_SHIPPING_TABLE_CATEGORIES);
		$cat_names = '';

		for($i=0, $x=sizeof($cats_array); $i<$x; $i++){
		     $cats_array[$i] = (int)$cats_array[$i];
          $cat_names .= tep_get_categories_name($cats_array[$i]).', ';
		}

		$cat_names = substr($cat_names, 0,-2);

		 $pID_list = $cart->get_product_id_list();

		 $pID_list = explode(',',$pID_list);
			for($i=0, $x=sizeof($pID_list); $i<$x; $i++){
			     $pID_list[$i] = (int)$pID_list[$i];
			}
			$pID_list = implode(',',$pID_list);


		      $products = $cart->get_products();
					for($i=0, $x=sizeof($products); $i<$x; $i++){
									$check_query = tep_db_query('select * from '.TABLE_PRODUCTS_TO_CATEGORIES.' where categories_id in ('.implode(',',$cats_array).') and products_id="'.(int)$products[$i]['id'].'"');
									if (tep_db_num_rows($check_query)) {
									  $is_category = true;
					} ELSE {
									  $is_category = false;
					}
				}


$is_category1 = false;

		$cats_array1 = explode(',',MODULE_SHIPPING_TABLE_CATEGORIES1);
		$cat_names1 = '';

		for($i=0, $x=sizeof($cats_array1); $i<$x; $i++){
		     $cats_array1[$i] = (int)$cats_array1[$i];
          $cat_names1 .= tep_get_categories_name($cats_array1[$i]).', ';
		}

		$cat_names1 = substr($cat_names1, 0,-2);

		 $pID_list1 = $cart->get_product_id_list();

		 $pID_list1 = explode(',',$pID_list);
			for($i=0, $x=sizeof($pID_list1); $i<$x; $i++){
			     $pID_list1[$i] = (int)$pID_list1[$i];
			}
			$pID_list1 = implode(',',$pID_list1);


		      $products1 = $cart->get_products();
					for($i=0, $x=sizeof($products); $i<$x; $i++){
									$check_query1 = tep_db_query('select * from '.TABLE_PRODUCTS_TO_CATEGORIES.' where categories_id in ('.implode(',',$cats_array1).') and products_id="'.(int)$products1[$i]['id'].'"');
									if (tep_db_num_rows($check_query1)) {
									  $is_category1 = true;

					} ELSE {
									  $is_category1 = false;

					}
				}

     if (MODULE_SHIPPING_TABLE_MODE == 'price') {
       $order_total = $cart->show_total();
        } else if (MODULE_SHIPPING_TABLE_MODE == 'count') {
       $order_total = $cart->count_contents();
     } else {
       $order_total = $shipping_weight;
     }

     $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
     $size = sizeof($table_cost);
     for ($i=0, $n=$size; $i<$n; $i+=2) {
       if ($order_total <= $table_cost[$i]) {
         $shipping = $table_cost[$i+1];
         break;
       }
     }

$table_cost1 = split("[:,]" , MODULE_SHIPPING_TABLE_COST1);
     $size1 = sizeof($table_cost1);
     for ($i=0, $n=$size1; $i<$n; $i+=2) {
       if ($order_total <= $table_cost1[$i]) {
         $shipping1 = $table_cost1[$i+1]; 

         break;
       }
     }

//Percentage Mod
  if ( strpos($shipping,"%") > 0 && MODULE_SHIPPING_TABLE_MODE == 'price') {
  	$shipping = $order_total * round(($shipping/100),2);
  }
//end Percentage Mod

$cost1= printf ($shipping+$shipping1);

     if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
       $shipping = $shipping * $shipping_num_boxes;
     }


if (($is_category))	{
         $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => $shipping)));
   } elseif (($is_category1)) {

        $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => $shipping1)));

   }  /*elseif (($is_category1) or ($is_category) ) {        

       $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => 1000)));

   } else {

      $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => 0)));
   }   */




   /*elseif (($is_category1))
{
     $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => $shipping1)));
} elseif (($is_category1) && ($is_category1)) {
   $this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => $shipping1+$shipping+100)));



}
   */

     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_TABLE_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, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', 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 ('Categories List', 'MODULE_SHIPPING_TABLE_CATEGORIES', '', 'For what categories do you want to offer this shipping method.', '667', '8', 'tep_cfg_show_multicategories', 'tep_cfg_select_multicategories(', 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 ('Categories List', 'MODULE_SHIPPING_TABLE_CATEGORIES1', '', 'For what categories do you want to offer this shipping method.', '667', '8', 'tep_cfg_show_multicategories', 'tep_cfg_select_multicategories(', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '1:8.50,2:5.50,3:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, If by price you may also use % IE: 70:3.50,99999:5%, charge 3.50 upto 70 total, then 5% over 70', '6', '0', now())");

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST1', '1:18.50,2:15.50,3:10.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, If by price you may also use % IE: 70:3.50,99999:5%, charge 3.50 upto 70 total, then 5% over 70', '6', '0', now())");


     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for this shipping method.', '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 ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '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_TABLE_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 ('Sort Order', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_CATEGORIES', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_MODE', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_SORT_ORDER','MODULE_SHIPPING_TABLE_CATEGORIES1','MODULE_SHIPPING_TABLE_COST1');
   }
 }
?>

 

thanks for help :)

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