Page 5 of 5 FirstFirst ... 345
Results 41 to 48 of 48
  1. #41
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    here's an update to the freightquote.com module
    here is the original file
    Code:
    <?php
    /*
      Freightquote.com Shipping Module for Zen Cart
    
      Copyright (c) 2010 Freightquote.com
      
      Developed by Dynamo Effects - sales [at] dynamoeffects.com
    
      Released under the GNU General Public License v2
    */
      class freightquote {
        var $code, $title, $description, $sort_order, $icon, 
            $tax_class, $enabled, $request, $response;
        
        function freightquote() {
          global $order, $db;
    
          $this->code = 'freightquote';
          $this->title = MODULE_SHIPPING_FREIGHTQUOTE_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_FREIGHTQUOTE_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_FREIGHTQUOTE_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_FREIGHTQUOTE_TAX_CLASS;
          
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = (MODULE_SHIPPING_FREIGHTQUOTE_STATUS == 'True' ? true : false);
          }
          
          if (($this->enabled == true) && ((int)MODULE_SHIPPING_FREIGHTQUOTE_ZONE > 0)) {
            $check_flag = false;
            
            $check_query = $db->Execute(
              "SELECT zone_id " .
              "FROM " . TABLE_ZONES_TO_GEO_ZONES . " " .
              "WHERE geo_zone_id = '" . MODULE_SHIPPING_FREIGHTQUOTE_ZONE . "' " .
              "  AND zone_country_id = '" . $order->delivery['country']['id'] . "' " .
              "ORDER BY zone_id"
            );
            
            while (!$check_query->EOF) {
              if ($check_query->fields['zone_id'] < 1) {
                $check_flag = true;
                break;
              } elseif ($check_query->fields['zone_id'] == $order->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check_query->MoveNext();
            }
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    
        function quote($method = '') {
          global $db, $order, $currencies, $shipping;
          
          //Array used to store data that will be fed into XML template
          $shipping_info = array();
          
          //This array will be turned into the XML that is sent to Freightquote.com
          $request_xml = array(
            'GetRatingEngineQuote' => array(
              'request' => array(
                'CustomerId' => $_SESSION['customer_id'],
                'QuoteType' => 'B2B',
                'ServiceType' => MODULE_SHIPPING_FREIGHTQUOTE_SERVICE_TYPE,
                'QuoteShipment' => array(
                  'ShipmentLabel' => MODULE_SHIPPING_FREIGHTQUOTE_TEXT_SHIPMENT_LABEL,
                  'IsBlind' => (MODULE_SHIPPING_FREIGHTQUOTE_BLIND == 'True' ? 'true' : 'false'),
                  'ShipmentLocations' => array(
                    'Location' => array()
                  ),
                  'ShipmentProducts' => array(
                    'Product' => array()
                  )
                )
              ),
              'user' => array(
                'Name' => MODULE_SHIPPING_FREIGHTQUOTE_USERNAME,
                'Password' => MODULE_SHIPPING_FREIGHTQUOTE_PASSWORD
              )
            )
          );
          
          //ZIP Code and country code of the destination address
          $dest_zip = $order->delivery['postcode'];
          $dest_country = $order->delivery['country']['iso_code_2'];
          
          //Format the ZIP codes for the US and Canada
          if ($dest_country == 'US') {
            $dest_zip = preg_replace('/[^0-9]/', '', $dest_zip);
            $dest_zip = substr($dest_zip, 0, 5);
          } elseif ($dest_country == 'CA') {
            $dest_zip = preg_replace('/[^0-9A-Z]/', '', strtoupper($dest_zip));
            $dest_zip = substr($dest_zip, 0, 6);
          }
          
          $ship_country = zen_get_countries(MODULE_SHIPPING_FREIGHTQUOTE_SHIP_COUNTRY, true);
          
          $ship_country = $ship_country['countries_iso_code_2'];
          
          //Retrieve all products in the cart
          $products = $_SESSION['cart']->get_products();
    
          //Determine the type of location selected by the customer	  -- YW BEGIN
          //$delivery_location = 1;	  
    	  if (!isset($delivery_location)) {
    		switch (MODULE_SHIPPING_FREIGHTQUOTE_DELIVERY_LOCATION) {
    			case 'Residence': 
    				$delivery_location = 0;
    				break;
    			case 'Commercial (with loading dock)': 
    				$delivery_location = 2;
    				break;
    			case 'Construction Site': 
    				$delivery_location = 3;
    				break;
    			case 'Commercial (no loading dock)':
    			default:
    				$delivery_location = 1;
    				break;
    		}
    	  }	  
          
          if (isset($_REQUEST['freightquote_delivery_location'])) {
            $delivery_location = (int)$_REQUEST['freightquote_delivery_location'];
          }
          
          $delivery_info = array();
          
          switch ($delivery_location) {
            case '0':
              $delivery_info['residence'] = 'true';
              $delivery_info['construction_site'] = 'false';
              $delivery_info['loading_dock'] = 'false';
              break;
            case '2':
              $delivery_info['residence'] = 'false';
              $delivery_info['construction_site'] = 'false';
              $delivery_info['loading_dock'] = 'true';
              break;
            case '3':
              $delivery_info['residence'] = 'false';
              $delivery_info['construction_site'] = 'true';
              $delivery_info['loading_dock'] = 'false';
              break;
            case '1':
            default:
              $delivery_info['residence'] = 'false';
              $delivery_info['construction_site'] = 'false';
              $delivery_info['loading_dock'] = 'false';
              break;
          }
    
          $request_xml['GetRatingEngineQuote']['request']['QuoteShipment']['ShipmentLocations']['Location'] = array(
            array(
              'LocationName' => STORE_NAME,
              'LocationType' => 'Origin',
              'HasLoadingDock' => strtolower(MODULE_SHIPPING_FREIGHTQUOTE_LOADING_DOCK),
              'IsConstructionSite' => strtolower(MODULE_SHIPPING_FREIGHTQUOTE_CONSTRUCTION_SITE),
              'IsResidential' => strtolower(MODULE_SHIPPING_FREIGHTQUOTE_RESIDENCE),
              'LocationAddress' => array(
                'PostalCode' => MODULE_SHIPPING_FREIGHTQUOTE_SHIP_ZIP,
                'CountryCode' => $ship_country
              )
            ),
            array(
              'LocationName' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
              'LocationType' => 'Destination',
              'HasLoadingDock' => $delivery_info['loading_dock'],
              'IsConstructionSite' => $delivery_info['construction_site'],
              'IsResidential' => $delivery_info['residence'],
              'LocationAddress' => array(
                'PostalCode' => $dest_zip,
                'CountryCode' => $dest_country
              )
            )
          );
          
          $product_list = array();
          
          $counter = 1;
          
          $excluded_items = 0;
          
          foreach ($products as $product) {
            $data = $db->Execute(
              "SELECT products_freightquote_enable, products_freightquote_length, products_freightquote_width, " .
              "       products_freightquote_height, products_freightquote_class, products_freightquote_nmfc, " .
              "       products_freightquote_hzmt, products_freightquote_content_type, " .
              "       products_freightquote_package_type, products_freightquote_commodity_type " .
              "FROM " . TABLE_PRODUCTS . " " .
              "WHERE products_id = " . (int)$product['id'] . " " .
              "LIMIT 1"
            );
            
            if ($data->fields['products_freightquote_enable'] == '1') {
              $product_list[] = array(
                'Class' => (zen_not_null($data->fields['products_freightquote_class']) ? $data->fields['products_freightquote_class'] : '50'),
                'ProductDescription' => $product['name'],
                'Weight' => ceil($product['quantity'] * (int)$product['weight']),
                'Length' => ceil($data->fields['products_freightquote_length']),
                'Width' => ceil($data->fields['products_freightquote_width']),
                'Height' => ceil($data->fields['products_freightquote_height']),
                'PackageType' => (zen_not_null($data->fields['products_freightquote_package_type']) ? $data->fields['products_freightquote_package_type'] : 'Boxes'),
                'DeclaredValue' => round($product['price']),
                'CommodityType' => (zen_not_null($data->fields['products_freightquote_commodity_type']) ? $data->fields['products_freightquote_commodity_type'] : 'GeneralMerchandise'),
                'ContentType' => (zen_not_null($data->fields['products_freightquote_content_type']) ? $data->fields['products_freightquote_content_type'] : 'NewCommercialGoods'),
                'IsHazardousMaterial' => $data->fields['products_freightquote_hzmt'],
                'NMFC' => $data->fields['products_freightquote_nmfc'],
                'PieceCount' => $product['quantity'],
                'ItemNumber' => $counter
              );
              
              $counter++;
            } else {
              $excluded_items++;
            }
          }
          
          $total_products = count($product_list);
          
          if (count($total_products) < 1) {
            if (MODULE_SHIPPING_FREIGHTQUOTE_DEBUG == 'True') {
              return array(
                'module' => $this->title,
                'error' => "DEBUG: The products in your cart are not configured to be used with Freightquote.com"
              );
            }
            
            return false;
          }
          
          /* Maximum 6 products allowed per query, so repeat the query multiple times if necessary */
          $freightquote_queries = array();
          $query_string = '';
          
          /*
           * Only 6 items allowed per query
           */
          for ($x = 0; $x < $total_products; $x+=6) {
            $product_request = array();
            
            for ($n = 1; $n <= 6; $n++) {
              $ret = ($n + $x) - 1;
              if (isset($product_list[$ret])) {
                $product_request[] = $product_list[$ret];
              }
            }
            
            $request_xml['GetRatingEngineQuote']['request']['QuoteShipment']['ShipmentProducts']['Product'] = $product_request;
            
            $request_result = $this->query_rates($request_xml);
            
            if (isset($request_result['error'])) {
              return array(
                'module' => $this->title,
                'error' => $request_result['error']
              );
            }
    
            $freightquote_queries[] = $request_result['GetRatingEngineQuoteResponse'][0]['GetRatingEngineQuoteResult'][0];
          }
    
          $total_shipping_price = array(
            'rate' => 0, 
            'shipment_id' => ''
          );
          
          $errors = array();
    
          foreach ($freightquote_queries as $quote) {
            if (is_array($quote['QuoteCarrierOptions'])) {
              if ($total_shipping_price['shipment_id'] != '') $total_shipping_price['shipment_id'] .= ' & ';
              $total_shipping_price['shipment_id'] .= $quote['QuoteId'];
              
              $total_shipping_price['rate'] += preg_replace('/[^0-9\.]/', '', $quote['QuoteCarrierOptions'][0]['CarrierOption'][0]['QuoteAmount']);
            } elseif (count($quote['ValidationErrors']) > 0) {
              foreach ($quote['ValidationErrors'][0]['B2BError'] as $error_msg) {
                $errors[] = $error_msg['ErrorMessage'];
              }
            }
          }
          
          /* If the shipping price is 0 and no errors were returned, don't display this shipping option */
          if ($total_shipping_price['rate'] <= 0 && count($errors) < 1) {
            if (MODULE_SHIPPING_FREIGHTQUOTE_DEBUG == 'True') {
              return array(
                'module' => $this->title,
                'error' => "DEBUG: No shipping rates or errors were returned from Freightquote.com, so no shipping option is being returned."
              );
            }
            
            return false;
          }
          
          //Add price modifier
          if (MODULE_SHIPPING_FREIGHTQUOTE_PRICE_MODIFIER > 0) {
            $total_shipping_price['rate'] = $total_shipping_price['rate'] * MODULE_SHIPPING_FREIGHTQUOTE_PRICE_MODIFIER;
          }
          
          //Add handling charges
          $total_shipping_price['rate'] += MODULE_SHIPPING_FREIGHTQUOTE_HANDLING * $total_products;
    
          $shipping_form = '';
          if ($_POST['action'] != 'process') {
            $shipping_form  = '<table border="0" cellspacing="0" cellpadding="2">';
            $shipping_form .= '<tr><td class="main" width="120">Delivery Location:</td><td class="main">';
            $shipping_form .= '<select name="freightquote_delivery_location" onchange="window.location.href=\'' . zen_href_link(FILENAME_CHECKOUT_SHIPPING, 'freightquote_delivery_location=') . '\'+this.value">';
            $shipping_form .= '<option value="0"' . ($delivery_location == '0' ? ' SELECTED' : '') . '>Residence</option>';
            $shipping_form .= '<option value="1"' . (!isset($delivery_location) || $delivery_location == '1' ? ' SELECTED' : '') . '>Commercial (no loading dock)</option>';
            $shipping_form .= '<option value="2"' . ($delivery_location == '2' ? ' SELECTED' : '') . '>Commercial (with loading dock)</option>';
            $shipping_form .= '<option value="3"' . ($delivery_location == '3' ? ' SELECTED' : '') . '>Construction Site</option>';
            $shipping_form .= '</select></td></tr>';
            $shipping_form .= '</table>';
          } else {
            $shipping_form  = '<br>Delivery Location: ';
            switch ($delivery_location) {
              case '0':
                $shipping_form .= 'Residence';
                break;
              case '2':
                $shipping_form .= 'Commercial (with loading dock)';
                break;
              case '3':
                $shipping_form .= 'Construction Site';
                break;
    Last edited by jimmie; 17 Nov 2014 at 02:12 AM.

  2. #42
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    Code:
    case '1':
              default:
                $shipping_form .= 'Commercial (no loading dock)';
                break;
            }
          }
    
          if (count($errors) < 1) {
            $shipping_options = array();
            
            $shipping_options[] = array('id' => 'CHEAPEST',
                                        'title' => MODULE_SHIPPING_FREIGHTQUOTE_TEXT_WAY . $total_shipping_price['shipment_id'] . ($excluded_items > 0 ? MODULE_SHIPPING_FREIGHTQUOTE_TEXT_EXCLUDED . $excluded_items : '') . $shipping_form,
                                        'cost' => $total_shipping_price['rate'],
                                        'tfrc_quote_id' => $total_shipping_price['shipment_id']);
    
            $this->quotes = array('id' => $this->code,
                                  'module' => MODULE_SHIPPING_FREIGHTQUOTE_TEXT_TITLE,
                                  'methods' => $shipping_options);            
      
            if (isset($_REQUEST['freightquote_delivery_location'])) {
              $_SESSION['shipping'] = array(
                'id' => $this->code . '_CHEAPEST',
                'title' => $this->quotes['methods'][0]['title'],
                'cost' => $this->quotes['methods'][0]['title'],
                'module' => $this->code
              );
            }
            
            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);
          } else {
            $error_message = '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>';
            
            $this->quotes = array('module' => $this->title . $shipping_form,
                                  'error' => $error_message);
          }
          return $this->quotes;
        }
            
        function query_rates($request_xml) {
          //Make sure cURL exists
          if (!function_exists('curl_init')) {
            return array('error' => MODULE_SHIPPING_FREIGHTQUOTE_TEXT_ERROR_CURL);
          }
          
          //URL to send requests to
          $service_url = 'https://b2b.Freightquote.com/WebService/QuoteService.asmx';
          
          //XML template file used for request
          $query_xml = $xml = $this->array_to_xml($request_xml);
        
          //Make sure the XML file exists
    
          $this->request = $query_xml;
          
          //Initialize curl
          $ch = curl_init();
          
          $headers = array(
            'Content-Type: text/xml; charset=utf-8',
            'Content-Length: ' . strlen($this->request),
            'SOAPAction: "http://tempuri.org/GetRatingEngineQuote"'
          );
    
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_HEADER, 0); 
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_TIMEOUT, 180);
          curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
          curl_setopt($ch, CURLOPT_POST, 1);
          curl_setopt($ch, CURLOPT_URL, $service_url);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request); 
          
          $this->response = curl_exec($ch);
    
          if (curl_errno($ch) == 0) {
            curl_close($ch);
            //Simple check to make sure that this is a valid XML response
    
            if (strpos(strtolower($this->response), 'soap:envelope') === false) {
              return array('error' => MODULE_SHIPPING_FREIGHTQUOTE_TEXT_ERROR_DESCRIPTION);
            }
    
            if ($this->response) {
              //Convert the XML into an easy-to-use associative array
              $this->response = $this->parse_xml($this->response);       
            }
            
            return $this->response;
          } else {
            //Collect the error returned
            $curl_errors = curl_error($ch) . ' (Error No. ' . curl_errno($ch) . ')';
    
            curl_close($ch);
            
            return array('error' => $curl_errors);
          }
        }
    
        function array_to_xml($array, $wrapper = true) {
          $xml = '';
          
          $first_key = false;
          
          if ($wrapper) {
            $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n" .
                     '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n" .
                     'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' . "\n" .
                   '<soap:Body>' . "\n";
                   
            $first_key = true;
          }
    
          foreach ($array as $key => $value) {
            $position = 0;
            
            if (is_array($value)) {
              $is_value_assoc = $this->is_assoc($value);
              $xml .= "<$key" . ($first_key ? ' xmlns="http://tempuri.org/"' : '') . ">\n";
              $first_key = false;
              
              foreach ($value as $key2 => $value2) {
                if (is_array($value2)) {
                  if ($is_value_assoc) {
                    $xml .= "<$key2>\n" . $this->array_to_xml($value2, false) . "</$key2>\n";
                  } elseif (is_array($value2)) {
                    $xml .= $this->array_to_xml($value2, false);
                    $position++;
                    
                    if ($position < count($value) && count($value) > 1) $xml .= "</$key>\n<$key>\n";
                  }
                } else {
                  $xml .= "<$key2>" . $this->xml_safe($value2) . "</$key2>\n";
                }
              }
              $xml .= "</$key>\n";
            } else {
            
              $xml .= "<$key>" . $this->xml_safe($value) . "</$key>\n";
            }
          }
          
          if ($wrapper) {
            $xml .= '</soap:Body>' . "\n" .
                  '</soap:Envelope>';
          }
          
          return $xml;
        }
        
        function is_assoc($array) {
          return (is_array($array) && 0 !== count(array_diff_key($array, array_keys(array_keys($array)))));
        }
    
        function parse_xml($text) {
          $reg_exp = '/<(\w+)[^>]*>(.*?)<\/\\1>/s';
          preg_match_all($reg_exp, $text, $match);
          foreach ($match[1] as $key=>$val) {
            if ( preg_match($reg_exp, $match[2][$key]) ) {
                $array[$val][] = $this->parse_xml($match[2][$key]);
            } else {
                $array[$val] = $match[2][$key];
            }
          }
          return $array;
        }
        
        function xml_safe($str) {
          //The 5 evil characters in XML
          $str = str_replace('<', '&lt;', $str);
          $str = str_replace('>', '&gt;', $str);
          $str = str_replace('&', '&amp;', $str);
          $str = str_replace("'", '&apos;', $str);
          $str = str_replace('"', '&quot;', $str);
    
          return $str;
        }
      
        function check() {
          global $db;
          
          if (!isset($this->_check)) {
            $check_query = $db->Execute(
              "SELECT configuration_value " .
              "FROM " . TABLE_CONFIGURATION . " " .
              "WHERE configuration_key = 'MODULE_SHIPPING_FREIGHTQUOTE_STATUS' " . 
              "LIMIT 1"
            );
            
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }
        
        function next_business_day() {
          $next_date = date("U")+86400;
    
          $workday = date("w", $next_date);
          
          if ($workday > 0 && $workday < 6) {
            return date(DATE_ATOM, $next_date);
          } else {
            while ($workday < 1 || $workday > 5) {
              $next_date += 86400;
              $workday = date("w", $next_date);
              if ($workday > 0 && $workday < 6) {
                return date(DATE_ATOM, $next_date);
              }
            }
          }
        }
    
        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 Freightquote.com Shipping Module', 'MODULE_SHIPPING_FREIGHTQUOTE_STATUS', 'True', 'Do you want to offer Freightquote.com shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', 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 ('Enable Freightquote.com Debug Mode', 'MODULE_SHIPPING_FREIGHTQUOTE_DEBUG', 'False', 'Enable debug mode?  This will dump the data string to the user\'s screen when an error occurs.  Should not be turned on unless there are problems.', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Username', 'MODULE_SHIPPING_FREIGHTQUOTE_USERNAME', '[email protected]', 'Enter your Freightquote.com Username', '6', '1', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Password', 'MODULE_SHIPPING_FREIGHTQUOTE_PASSWORD', 'XML', 'Enter your Freightquote.com Password', '6', '1', 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 ('Service Type', 'MODULE_SHIPPING_FREIGHTQUOTE_SERVICE_TYPE', 'LTL', 'What service type do you want to use?', '6', '0', 'zen_cfg_select_option(array(\'LTL\', \'Truckload\', \'Europe\', \'Groupage\', \'Haulage\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Origin: Zip Code', 'MODULE_SHIPPING_FREIGHTQUOTE_SHIP_ZIP', '', 'What zip code will you be shipping from?', '6', '1', 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 Origin: Country', 'MODULE_SHIPPING_FREIGHTQUOTE_SHIP_COUNTRY', '223', 'What country will you be shipping from?', '6', '1', 'zen_get_country_name', 'zen_cfg_pull_down_country_list(', 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 ('Shipping Origin: Loading Dock', 'MODULE_SHIPPING_FREIGHTQUOTE_LOADING_DOCK', 'True', 'Does the shipping location have a loading dock?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', 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 ('Shipping Origin: Residence', 'MODULE_SHIPPING_FREIGHTQUOTE_RESIDENCE', 'True', 'Is the shipping location a residence?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', 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 ('Shipping Origin: Construction Site', 'MODULE_SHIPPING_FREIGHTQUOTE_CONSTRUCTION_SITE', 'True', 'Is the shipping location a construction site?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', 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 ('Blind Ship', 'MODULE_SHIPPING_FREIGHTQUOTE_BLIND', 'True', 'Blind shipments are used to keep the originating location and receiving destination unaware of each other.', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Price Modifier', 'MODULE_SHIPPING_FREIGHTQUOTE_PRICE_MODIFIER', '1', 'This number will be multiplied by the total shipping rate.  If you\'d like to increase or decrease the price returned, modify this field.  e.g. For a 10% price increase, enter 1.1', '6', '1', 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_FREIGHTQUOTE_HANDLING', '0', 'Handling fee for this shipping method (peritem).', '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_FREIGHTQUOTE_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, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FREIGHTQUOTE_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 of display.', 'MODULE_SHIPPING_FREIGHTQUOTE_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', 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 ('Default delivery location', 'MODULE_SHIPPING_FREIGHTQUOTE_DELIVERY_LOCATION', 'Commercial (no loading dock)', 'Default delivery location type', '6', '0', 'zen_cfg_select_option(array(\'Residence\', \'Commercial (no loading dock)\', \'Commercial (with loading dock)\', \'Construction Site\'), ', now())");
    
          
          $col_query = $db->Execute("SHOW COLUMNS FROM " . TABLE_PRODUCTS);
          
          $found = array(
            'products_freightquote_enable' => array('type' => "CHAR( 1 ) DEFAULT '0' NOT NULL"),
            'products_freightquote_class' => array('type' => "VARCHAR( 6 ) DEFAULT '50' NOT NULL"),
            'products_freightquote_length' => array('type' => "INT DEFAULT '0' NOT NULL"),
            'products_freightquote_width' => array('type' => "INT DEFAULT '0' NOT NULL"),
            'products_freightquote_height' => array('type' => "INT DEFAULT '0' NOT NULL"),
            'products_freightquote_nmfc' => array('type' => "VARCHAR(32) NULL"),
            'products_freightquote_hzmt' => array('type' => "VARCHAR(5) DEFAULT 'false' NOT NULL"),
            'products_freightquote_package_type' => array('type' => "VARCHAR(32) DEFAULT 'Boxes' NOT NULL"),
            'products_freightquote_commodity_type' => array('type' => "VARCHAR(32) DEFAULT 'GeneralMerchandise' NOT NULL"),
            'products_freightquote_content_type' => array('type' => "VARCHAR(32) DEFAULT 'NewCommercialGoods' NOT NULL")
          );
          
          while (!$col_query->EOF) {
            $columns[] = $col_query->fields['Field'];
            $col_query->MoveNext();
          }
    
          foreach ($found as $col => $info) {
            if (!in_array($col, $columns)) {
              $db->Execute("ALTER TABLE " . TABLE_PRODUCTS . " ADD `" . $col . "` " . $info['type']);
            }
          }
        }
    
        function remove() {
          global $db;
          
          $db->Execute("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key IN ('" . implode("', '", $this->keys()) . "')");
        }
    
        function keys() {
          return array(
            'MODULE_SHIPPING_FREIGHTQUOTE_STATUS',
            'MODULE_SHIPPING_FREIGHTQUOTE_DEBUG',
            'MODULE_SHIPPING_FREIGHTQUOTE_USERNAME',
            'MODULE_SHIPPING_FREIGHTQUOTE_PASSWORD',
            'MODULE_SHIPPING_FREIGHTQUOTE_SERVICE_TYPE',
            'MODULE_SHIPPING_FREIGHTQUOTE_SHIP_ZIP',
            'MODULE_SHIPPING_FREIGHTQUOTE_SHIP_COUNTRY',
            'MODULE_SHIPPING_FREIGHTQUOTE_LOADING_DOCK',
            'MODULE_SHIPPING_FREIGHTQUOTE_RESIDENCE',
            'MODULE_SHIPPING_FREIGHTQUOTE_CONSTRUCTION_SITE',
            'MODULE_SHIPPING_FREIGHTQUOTE_BLIND',
            'MODULE_SHIPPING_FREIGHTQUOTE_PRICE_MODIFIER',
            'MODULE_SHIPPING_FREIGHTQUOTE_HANDLING',
            'MODULE_SHIPPING_FREIGHTQUOTE_TAX_CLASS',
            'MODULE_SHIPPING_FREIGHTQUOTE_ZONE',
            'MODULE_SHIPPING_FREIGHTQUOTE_SORT_ORDER',
            'MODULE_SHIPPING_FREIGHTQUOTE_DELIVERY_LOCATION'
          );
        }
      }
    ?>
    I changed
    Code:
    'Weight' => ceil($product['quantity'] * (int)$product['weight']),
    to
    Code:
    'Weight' => ceil($_SESSION['cart']->weight),
    also changed this
    Code:
    'PieceCount' => $product['quantity'],
    to this
    Code:
    'PieceCount' => ceil($product['quantity'])
    added this
    Code:
    if (!IS_ADMIN_FLAG) {      
          global $cart;      
          if ($_SESSION['cart']->weight < 150 ) {        
          $this->enabled = false;       
         }     }
    under
    Code:
    if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = (MODULE_SHIPPING_FREIGHTQUOTE_STATUS == 'True' ? true : false);
          }
    Now need to get rates working without logging in
    and the option for customer to choose location
    Last edited by jimmie; 17 Nov 2014 at 02:12 AM.

  3. #43
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    Changed this
    Code:
    'CustomerId' => $_SESSION['customer_id'],
    to
    Code:
    'CustomerId' => '0'
    Now can see when not logged in

  4. #44
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    changed this
    Code:
    $shipping_form .= '<select name="freightquote_delivery_location" onchange="window.location.href=\'' . zen_href_link(FILENAME_CHECKOUT_SHIPPING, 'freightquote_delivery_location=') . '\'+this.value">';
    to
    Code:
    $shipping_form .= '<select name="freightquote_delivery_location" onchange="window.location.href=\'' . zen_href_link(FILENAME_SHOPPING_CART, 'freightquote_delivery_location=') . '\'+this.value">';
    but showing this in address bar
    http://floorz-n-more.com/index.php?m...ery_location=1
    wound like it to refresh on same page if on shopping cart and they select commercial it will refresh on shopping cart, if in checkout and they select commercial it will refresh checkout

  5. #45
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    min max is set to 40.20, product info pages show 40.2(wont allow checkout as 40.2) how can i tell zencart not to strip the zero) stock quantity decimals set to 2)

  6. #46
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: quantity deicimals

    Quote Originally Posted by jimmie View Post
    min max is set to 40.20, product info pages show 40.2(wont allow checkout as 40.2) how can i tell zencart not to strip the zero) stock quantity decimals set to 2)
    Not sure if the above identifies this setting set this way or is asking where the setting is, but I would expect to support quantities that include at least.0.2 that the stock be allowed to exist or be modified in quantities of at least 0.1 or have 1 decimal place. This is controlled in configuration->stock->product Quantity Decimals. If this is set to 2, then quantities will work using 2 decimal places (0.01)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #47
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    if a quantity has 40.20 the page only shows 40.2, suppose to be 40.20 - 2 decimals
    http://1stchoiceflooringservice.com/...oducts_id=7403
    Last edited by jimmie; 20 Oct 2019 at 01:09 PM.

  8. #48
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: quantity deicimals

    Quote Originally Posted by mc12345678 View Post
    Not sure if the above identifies this setting set this way or is asking where the setting is, but I would expect to support quantities that include at least.0.2 that the stock be allowed to exist or be modified in quantities of at least 0.1 or have 1 decimal place. This is controlled in configuration->stock->product Quantity Decimals. If this is set to 2, then quantities will work using 2 decimal places (0.01)
    yes but not .10

 

 
Page 5 of 5 FirstFirst ... 345

Similar Threads

  1. Need to Offer Quantity Discount Depending on Total Cart Quantity
    By ikernbecauseicare in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 3 Feb 2011, 01:26 AM
  2. Position quantity update button under quantity box
    By JC.M in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 16 Feb 2010, 02:43 PM
  3. Price by attributes - quantity discount and minimum quantity required
    By josefine in forum Setting Up Categories, Products, Attributes
    Replies: 14
    Last Post: 24 Sep 2009, 07:28 PM
  4. quantity discount for checked attributes NOT product quantity
    By adod in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 6 Mar 2009, 06:39 PM
  5. Quantity Total in Shopping Cart Sidebox with Quantity Discount Contribution
    By maineiac13 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 14 Oct 2008, 08:40 PM

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