Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 50
  1. #21
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Shipping per Categories

    You would have to control how much is being charged in this section:
    Code:
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
          $chk_total_charge += ($chk_total_charge_constant * ${$chk_cat_group});
          $chk_total_count += ${$chk_cat_group};
    The price is set in:
    $chk_total_charge_constant

    you would want to change that from the amount you set per sheet of 2.50 to the lower amount of 0.40 when the count:
    $chk_total_count

    is at the number of sheets where you want to charge less ...

    Keep in mind that the count:
    $chk_total_count

    is set after the charge is calculated ... so when the first item is calculated the count is 0 ...

    Plus, you have to decide if all of the item counts when > 1 get changed to 0.40 or if you want different charges for the groups as it could get complicated to figure out the:
    $chk_total_charge_constant
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  2. #22
    Join Date
    Apr 2009
    Location
    Portland, OR
    Posts
    106
    Plugin Contributions
    0

    Default Re: Shipping per Categories

    so I have to write a "IF" statement?

    Quote Originally Posted by Ajeh View Post
    You would have to control how much is being charged in this section:
    Code:
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
          $chk_total_charge += ($chk_total_charge_constant * ${$chk_cat_group});
          $chk_total_count += ${$chk_cat_group};
    The price is set in:
    $chk_total_charge_constant

    you would want to change that from the amount you set per sheet of 2.50 to the lower amount of 0.40 when the count:
    $chk_total_count

    is at the number of sheets where you want to charge less ...

    Keep in mind that the count:
    $chk_total_count

    is set after the charge is calculated ... so when the first item is calculated the count is 0 ...

    Plus, you have to decide if all of the item counts when > 1 get changed to 0.40 or if you want different charges for the groups as it could get complicated to figure out the:
    $chk_total_charge_constant

  3. #23
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Shipping per Categories

    Yes, you will need an IF in this section of the code ...

    I would start by rearrange that section of code as:
    Code:
          $chk_total_count += ${$chk_cat_group};
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
          $chk_total_charge += ($chk_total_charge_constant * ${$chk_cat_group});
    so you can better tell if you are on sheet 1 or sheet 2, sheet 3 etc.

    Then, you have to decide when/what to use the cost setting for:
    $chk_total_charge_constant

    the issue is how much to charge based on the count but you are dropping the rate based on count from 2.50 to 0.40 ...

    The difficulty is, this is using multiple rates based on the Category ... it wasn't written to suddenly decide to charge different rates for different quantities for different categories ...

    You have some categories for 2.50 and some categories for 0.46 ... then, you suddenly want on the categories for 2.50 to only charge the 2.50 if it is 1 sheet but then charge a different price of 0.40 if there are more than 1 sheet ...

    But, this is not the same logic for all of the category groups, meaning that on the categories for the 2.50 you want 2.50 for sheet 1 and 0.40 for sheet 2+ but on the categories for 0.46 you want 0.46 for sheet 1 and 0.46 for sheet 2+ ...

    I am not sure just how hard it will be to do that with the multiple categories settings ...

    The main idea is to get the:
    $chk_total_charge_constant

    set to the right amount to charge for the sheet for the right category group at the right time ...

    You will really need to work with that section to get the IF right on how much to charge ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #24
    Join Date
    Apr 2009
    Location
    Portland, OR
    Posts
    106
    Plugin Contributions
    0

    Default Re: Shipping per Categories

    This is over my head, I dont think I can do any of what you suggested above
    is there a shipping module will work for my situation? or do I need to pay someone to do this for me?

    I am hoping to get this shipping module done, so I can upgrade to the new version of Zen Cart.

    thank you so much for your help!

  5. #25
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Shipping per Categories

    You could try this to charge sheet 1 2.50 and 0.40 sheet 2+ in category group 1 and charge sheet 1 0.46 and 0.40 sheet 2+ in category group 2
    Code:
          $chk_total_count += ${$chk_cat_group};
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
    //      $chk_total_charge += ($chk_total_charge_constant * ${$chk_cat_group});
          $chk_total_charge += (${$chk_cat_group} > 0 ? (1 * $chk_total_charge_constant) + ( (${$chk_cat_group} - 1) * .40) : 0);
    It should work but you will need to test it ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #26
    Join Date
    Apr 2009
    Location
    Portland, OR
    Posts
    106
    Plugin Contributions
    0

    Default Re: Shipping per Categories

    it works for US and Rest of World shipping, Yay!!!!

    however Canada shipping is not, it seems it charge the same shipping fees as US shipping.
    I am not sure where I did wrong on itemcatcan.php, can you take a look?

    Thank you!!!

    Code:
    <?php
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version itemcatcan.php 1969 2104-01-03 06:57:21Z ajeh $
     */
    
    class itemcatcan extends base {
      /**
       * $code determines the internal 'code' name used to designate "this" shipping module
       *
       * @var string
       */
      var $code;
      /**
       * $title is the displayed name for this shipping method on the storefront
       *
       * @var string
       */
      var $title;
      /**
       * $description is a soft name for this shipping method, rarely used
       *
       * @var string
       */
      var $description;
      /**
       * module's icon, if any.  Must be manually uploaded to the server's images folder, and an appropriate call to zen_image() added to the constructor.
       *
       * @var string
       */
      var $icon;
      /**
       * $enabled determines whether this module shows or not during checkout.
       * Can be updated with custom code in the module's update_status() method.
       * Can be overridden with observers via notifier points NOTIFY_SHIPPING_CHECK_ENABLED_FOR_ZONE and NOTIFY_SHIPPING_CHECK_ENABLED
       * @var boolean
       */
      var $enabled;
      /**
       * additional category groups itemcatcan rate
       */
      var $num_cat_group;
      /**
       * constructor
       *
       * @return itemcatcan
       */
      function __construct() {
        $this->code = 'itemcatcan';
        $this->title = MODULE_SHIPPING_ITEMCATCAN_TEXT_TITLE;
        $this->description = MODULE_SHIPPING_ITEMCATCAN_TEXT_DESCRIPTION;
        $this->sort_order = MODULE_SHIPPING_ITEMCATCAN_SORT_ORDER;
        $this->icon = ''; // add image filename here; must be uploaded to the /images/ subdirectory
        $this->tax_class = MODULE_SHIPPING_ITEMCATCAN_TAX_CLASS;
        $this->tax_basis = MODULE_SHIPPING_ITEMCATCAN_TAX_BASIS;
        $this->enabled = (MODULE_SHIPPING_ITEMCATCAN_STATUS == 'True') ? true : false;
        $this->update_status();
        $this->notify('MODULE_SHIPPING_' . strtoupper($this->code) . '_INSTANTIATED');
    
        /*
        ** CUSTOMIZE SETTING FOR THE NUMBER OF CATEGORY GROUPS NEEDED **
        If Itemcat Rates module is currently installed ...
          1. Change number below for the number of Category Groups for this->num_cat_group
          2. Upload changed itemcatcan.php
          3. Go to Modules ... Shipping ...
          4. Go to Modules ... Shipping ... a second time to clear any error messages
          5. Click on Itemcat Rates and Edit and Configure new Category groups
    
        If Itemcat Rates module is not currently installed
          1. Change number below for the number of Category Groups for this->num_cat_group
          2. Upload changed itemcatcan.php
          3. Go to Modules ... Shipping ...
          4. Click on Itemcat Rates and Click Install
          5. Edit and Configure new Item category groups
    
        */
        $this->num_cat_group = 3;
    
        if (IS_ADMIN_FLAG === true) {
          // build in admin only additional category groups if missing in the configuration table due to customization of default $this->num_cat_group = 2
          global $db;
          for ($i = 1; $i <= $this->num_cat_group; $i++) {
            $check = $db->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEMCATCAN_GROUP_" . $i . "'");
            if ($this->enabled && $check->EOF) {
              $default_categories_group = '';
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Itemcat group"  . $i . " categories', 'MODULE_SHIPPING_ITEMCATCAN_GROUP_" . $i ."', '" . $default_categories_group . "', 'What categories belong to this category group<br />Separate categories by commas, Example: 53,67 or 10, 12', '6', '0', 'zen_cfg_textarea(', now())");
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost Itemcat group"  . $i . "', 'MODULE_SHIPPING_ITEMCATCAN_COST" . $i ."', '" . '2.50' . "', 'The shipping cost will be multiplied by the number of items in an order that uses this Category Group.', '6', '0', now())");
            }
          }
        } // build in admin only
    
      }
    
      /**
       * Coders can add custom logic here in the update_status() method to allow for manipulating the $this->enabled status
       */
      function update_status() {
        global $order, $db;
        if (IS_ADMIN_FLAG == TRUE) return;
    
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code) == FALSE) $this->enabled = FALSE;
    
        /** CUSTOM ENABLE/DISABLE LOGIC CAN BE ADDED IN THE AREA SPECIFIED BELOW **/
        if ($this->enabled) {
          global $template, $current_page_base;
          // CUSTOMIZED CONDITIONS GO HERE
          // Optionally add additional code here to disable the module by changing $this->enabled to false based on whatever custom rules you require.
          // -----
    
    
          // -----
          // eof: optional additional code
        }
    //echo 'ITEM function ' . __FUNCTION__ . ' $this->enabled: ' . ($this->enabled ? ' ON' : ' OFF') . ' $shipping_weight: ' . $shipping_weight . '<br>';
      }
    
      /**
       * Sets $this->enabled based on zone restrictions applied to this module
       * @return boolean
       */
      function check_enabled_for_zone()
      {
        global $order, $db;
        if ($this->enabled == true && (int)MODULE_SHIPPING_ITEMCATCAN_ZONE > 0) {
          $check_flag = false;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . "
                                 where geo_zone_id = '" . MODULE_SHIPPING_ITEMCATCAN_ZONE . "'
                                 and zone_country_id = '" . (int)$order->delivery['country']['id'] . "'
                                 order by zone_id");
          while (!$check->EOF) {
            if ($check->fields['zone_id'] < 1) {
              $check_flag = true;
              break;
            } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
              $check_flag = true;
              break;
            }
            $check->MoveNext();
          }
    
          if ($check_flag == false) {
            $this->enabled = false;
          }
        }
        return $this->enabled;
      }
    
      /**
       * Returns the value of $this->enabled variable
       * @return boolean
       */
      function check_enabled()
      {
        return $this->enabled;
      }
    
      /**
       * Obtain quote from shipping system/calculations
       *
       * @param string $method
       * @return array
       */
      function quote($method = '') {
        global $order, $total_count;
    
        $chk_products_id_list_defined = '';
        $chk_total_count = 0;
        $chk_free_shipping_total_count = 0;
        $chk_products_in_cart = $_SESSION['cart']->get_product_id_list();
    //echo '$chk_products_in_cart: ' . $chk_products_in_cart . '<br><br>';
    
        for ($i=1; $i<=$this->num_cat_group; $i++) {
          $chk_cat_group = '$chk_cat_group_' . $i;
          ${$chk_cat_group} = 0;
    
          $cat_group = '$cat_group_' . $i;
          $cat_group_constant = constant('MODULE_SHIPPING_ITEMCATCAN_GROUP_' . $i);
          ${$cat_group} = preg_split("/[,]/" , $cat_group_constant);
    
          $size = sizeof(${$cat_group});
          if ($cat_group_constant == '') break; // do not continue if empty
          for ($j=0, $n=$size; $j<$n; $j+=1) {
            if (${$cat_group}[$j] != '') {
              ${$chk_cat_group} += $_SESSION['cart']->in_cart_check('master_categories_id', trim(${$cat_group}[$j]));
            }
    
    //echo 'Looking at trim(${$cat_group}[$j]): ' . trim(${$cat_group}[$j]) . '<br>';
            // check free shipping products
            global $categories_products_id_list;
            $categories_products_id_list = '';
            $chk_products_id_list = array();
            $chk_cat_group_products = trim(${$cat_group}[$j]);
    
            $chk_products_id_list = zen_get_categories_products_list($chk_cat_group_products);
    //echo '<pre>'; echo var_dump($chk_products_id_list); echo '</pre>';
    //echo 'itemcatcan $chk_products_id_list';print_r($chk_products_id_list);
            if (is_array($chk_products_id_list) && sizeof($chk_products_id_list) > 0) {
              // build products list
              $list_of_products = '';
              foreach($chk_products_id_list as $key => $value) {
                $list_of_products .= $key . ', ';
              }
              // if any $list_of_products are in cart check if free shipping
              $chk_products = trim(trim($list_of_products), ',');
    //echo '$chk_products: ' . $chk_products . '<br>in cart $chk_products_in_cart: '. $chk_products_in_cart . '<br>';
              $chk_donotchargeshipping = '';
              $chk_donotchargeshipping_cnt = 0;
              $arr1 = explode(", ", $chk_products_in_cart);
              $arr2 = explode(", ", $chk_products);
    //  echo '<pre>'; echo var_dump($chk_products); echo '</pre>';
              $chk_donotchargeshipping = array_intersect($arr1, $arr2);
    //echo '<br>itemcatcan $chk_donotchargeshipping<br> '; print_r($chk_donotchargeshipping); echo '<br>';
              foreach($chk_donotchargeshipping as $key2 => $value) {
                $chk_products_id_list_defined .= $value . ', ';
                $chk_donotchargeshipping_cnt = itemcatcan_free_shipping($value);
                if ($chk_donotchargeshipping_cnt) {
                  $chk_free_shipping_total_count += 1;
                  echo '<br>Do not charge $key2 $value: ' . $value . ' $chk_donotchargeshipping_cnt: ' . $chk_donotchargeshipping_cnt . '<br>';
                }
                          ${$chk_cat_group} += -$chk_donotchargeshipping_cnt;
              }
    //echo 'Cat: ' . trim(${$cat_group}[$j]) . ' ${$chk_cat_group}: ' . ${$chk_cat_group} . '<br>';
            }
          }
    
    	  $chk_total_count += ${$chk_cat_group};
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
    //      $chk_total_charge += ($chk_total_charge_constant * ${$chk_cat_group});
          $chk_total_charge += (${$chk_cat_group} > 0 ? (1 * $chk_total_charge_constant) + ( (${$chk_cat_group} - 1) * .75) : 0);
    	  
        }
    //echo '$chk_total_count: ' . $chk_total_count . ' $chk_total_charge found: ' . $chk_total_charge . '<br>';
    //echo '$chk_products_in_cart: ' . $chk_products_in_cart . '<br>vs $chk_products_id_list_defined: ' . $chk_products_id_list_defined . '<br>';
    // check products undefined for Free shipping
        //$chk_products_id_list
        // if any $list_of_products are in cart check if free shipping
        $chk_products_id_list_defined = trim(trim($chk_products_id_list_defined), ',');
    //echo '$chk_products: ' . $chk_products . '<br>in cart $chk_products_in_cart: '. $chk_products_in_cart . '<br>';
        $chk_donotchargeshipping_undefined = '';
        $chk_undefined_free_shipping = 0;
        $chk_free_shipping_total_count_undefined = 0;
        $arr1 = explode(", ", $chk_products_in_cart);
        $arr2 = explode(", ", $chk_products_id_list_defined);
        $chk_donotchargeshipping_undefined = array_diff($arr1, $arr2);
        foreach($chk_donotchargeshipping_undefined as $key2 => $value) {
    //      $chk_products_id_list .= $value . ',';
          $chk_donotchargeshipping_undefined_cnt = itemcatcan_free_shipping($value);
          if ($chk_donotchargeshipping_undefined_cnt) {
            echo 'itemcatcan Do not charge UNDEFINED $key2: ' . $value . '<br>';
            $chk_free_shipping_total_count_undefined += 1;
          }
          $chk_undefined_free_shipping += $chk_donotchargeshipping_undefined_cnt;
        }
    //echo '$chk_undefined_free_shipping: ' . $chk_undefined_free_shipping . '<br>';
    // calculate any undefined categories and add to $chk_total_charge
        $undefined_products = $_SESSION['cart']->count_contents() - ($chk_total_count + ($chk_free_shipping_total_count + $chk_undefined_free_shipping));
        $undefined_products_charge = (MODULE_SHIPPING_ITEMCATCAN_COST_UNDEFINED * ($undefined_products - $chk_undefined_free_shipping));
    //echo '$undefined_products: ' . $undefined_products . ' $undefined_products_charge: ' . $undefined_products_charge . '<br>';
    
        $chk_total_charge += $undefined_products_charge;
    //echo 'TOTAL CHARGE $chk_total_charge: ' . $chk_total_charge . '<br>';
    
        // adjusted count for free shipping
        $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
    
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_ITEMCATCAN_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_ITEMCATCAN_TEXT_WAY,
                                                       'cost' => ($chk_total_charge) + MODULE_SHIPPING_ITEMCATCAN_HANDLING)));
    
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }
    
        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
        $this->notify('MODULE_SHIPPING_' . strtoupper($this->code) . '_QUOTES_PREPARED');
        return $this->quotes;
      }
    
      /**
       * Check to see whether module is installed
       *
       * @return boolean
       */
      function check() {
        global $db;
        if (!isset($this->_check)) {
          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEMCATCAN_STATUS'");
          $this->_check = $check_query->RecordCount();
        }
        return $this->_check;
      }
    
      /**
       * Install the shipping module and its configuration settings
       */
      function install() {
        global $db;
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Itemcat Shipping', 'MODULE_SHIPPING_ITEMCATCAN_STATUS', 'True', 'Do you want to offer per itemcatcan rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    
          for ($i = 1; $i <= $this->num_cat_group; $i++) {
            $check = $db->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEMCATCAN_GROUP_" . $i . "'");
            if ($this->enabled && $check->EOF) {
              $default_categories_group = '';
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Itemcat group"  . $i . " categories', 'MODULE_SHIPPING_ITEMCATCAN_GROUP_" . $i ."', '" . $default_categories_group . "', 'What categories belong to this category group<br />Separate categories by commas, Example: 53,67', '6', '0', 'zen_cfg_textarea(', now())");
              $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost Itemcat group"  . $i . "', 'MODULE_SHIPPING_ITEMCATCAN_COST" . $i ."', '" . '2.50' . "', 'The shipping cost will be multiplied by the number of items in an order that uses this Category Group.', '6', '0', now())");
            }
          }
    
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost for Itemcat category groups undefined', 'MODULE_SHIPPING_ITEMCATCAN_COST_UNDEFINED', '', 'The shipping cost will be multiplied by the number of items in an order that are not in a defined category group.', '6', '0', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_ITEMCATCAN_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
          $db->Execute("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_ITEMCATCAN_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_ITEMCATCAN_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
          $db->Execute("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_ITEMCATCAN_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_ITEMCATCAN_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      }
    
      /**
       * Remove the module and all its settings
       */
      function remove() {
        global $db;
        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_ITEMCATCAN\_%'");
      }
    
      /**
       * Internal list of configuration keys used for configuration of the module
       *
       * @return array
       */
      function keys() {
        $keys = array('MODULE_SHIPPING_ITEMCATCAN_STATUS', 'MODULE_SHIPPING_ITEMCATCAN_HANDLING', 'MODULE_SHIPPING_ITEMCATCAN_TAX_CLASS', 'MODULE_SHIPPING_ITEMCATCAN_TAX_BASIS', 'MODULE_SHIPPING_ITEMCATCAN_ZONE', 'MODULE_SHIPPING_ITEMCATCAN_SORT_ORDER');
    
        for ($i=1; $i<=$this->num_cat_group; $i++) {
          $keys[] = 'MODULE_SHIPPING_ITEMCATCAN_GROUP_' . $i;
          $keys[] = 'MODULE_SHIPPING_ITEMCATCAN_COST' . $i;
        }
    
        $keys[] = 'MODULE_SHIPPING_ITEMCATCAN_COST_UNDEFINED';
    
        return $keys;
      }
    }
    
    function itemcatcan_free_shipping($product_id) {
      global $db;
      if ($product_id == '' || $product_id == 0 || !$product_id) {
    //    echo 'Blank $product_id<br>';
        return 0;
      }
      if (!zen_has_product_attributes_downloads_status($product_id)) {
    //echo 'itemcatcan_free_shipping 1 - A Download: ' . $product_id . ' - ' . zen_has_product_attributes_downloads_status($product_id) . '<br><br>';
        return 1;
      }
      $sql = "SELECT product_is_always_free_shipping, products_virtual, products_model, products_weight from " . TABLE_PRODUCTS . " WHERE products_id = '" . (int)$product_id . "'";
      $chk_free_shipping = $db->Execute($sql);
      if (($chk_free_shipping->fields['product_is_always_free_shipping'] == 1) or ($chk_free_shipping->fields['products_virtual'] == 1) or (preg_match('/^GIFT/', addslashes($chk_free_shipping->fields['products_model'])))) {
    //echo 'itemcatcan_free_shipping 1 - B Virtual: ' . $product_id . '<br><br>';
        return 1;
      }
      if ($chk_free_shipping->fields['products_weight'] == 0 && ORDER_WEIGHT_ZERO_STATUS == 1) {
    //echo 'itemcatcan_free_shipping 1 - C Weight: ' . $product_id . '<br><br>';
        return 1;
      }
      return 0;
    }

  7. #27
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Shipping per Categories

    I believe this line:
    Code:
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCAT_COST' . $i);
    should be:
    Code:
          $chk_total_charge_constant = constant('MODULE_SHIPPING_ITEMCATCAN_COST' . $i);
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #28
    Join Date
    Apr 2009
    Location
    Portland, OR
    Posts
    106
    Plugin Contributions
    0

    Default Re: Shipping per Categories

    YAY!!! It all works...!!!!
    I bought everyone round of coffees!!!

    Thank you so much!!!!

  9. #29
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Shipping per Categories

    Glad that all is now working for you!

    Thanks especially for the coffees and donuts! It really helps the Zen Cart Team to continue to help you ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #30
    Join Date
    Nov 2007
    Posts
    342
    Plugin Contributions
    0

    Default Re: Shipping per Categories

    Ajeh Oba San -

    (giddy with excitement). Will this mod you wrote work in the case when:

    1. I have 3 clones of the Zone Rates working just fine
    2. Setting a Per Unit (or other shipping module) to a specific category
    3. When a use adds two different products from different categories, the shipping adds fine in the cart?

    thanks a bunch!
    gabstero

 

 
Page 3 of 5 FirstFirst 12345 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 20 Mar 2013, 02:12 PM
  2. v151 International Per Item Shipping and Domestic Per Order Shipping
    By function in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 15 Mar 2013, 03:44 PM
  3. v139h Per unit/per category/per location shipping rates
    By jsavoie in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 4 Nov 2012, 06:19 PM
  4. HOW TO? - Multiple Shipping options per product per order etc....
    By shags38 in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 15 Sep 2011, 03:44 AM
  5. shipping items per weight per zone with extras
    By secondnature in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 10 Mar 2011, 07:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR