Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Apr 2013
    Location
    Boston, Massachusetts, United States
    Posts
    10
    Plugin Contributions
    0

    Default Flat Rate Shipping Clone with added code won't progress to the payment page

    I only use domestic USPS Flat Rate boxes. Using the USPS module I just get a bunch of shipping options that don't really relate to how many flat rate boxes will actually be used. What I really need is dimensional weight shipping.

    So I did some research and found the formula that UPS and FedEx are using ((LxWxH)/166).

    First I did a real life test pack of a products into flat rate boxes. I measured each product and got it's LxWxH. Because I use packing peanuts, I added 1 inch to the dimensions. I then figured the dimensional weight of each product using the above formula and then entered that as the weight for the product in Zencart. Then I did the actual test pack so that I would know how many boxes I would need and what the price would be. Doing this validated my algorithm.

    I then took copies of the 2 flat.php files used for Flat Rate Shipping in Zencart (1 is in include/languages and 1 is in include/modules). I inserted some code using the algorithm I'd developed based on the above tests and research. I also renamed the variables and the files in the manner described on an older thread on subject.

    I uploaded the files and installed them to my test cart as uspost_flat.php. The shipping page came up and had the right price based on the real life test packs of products. I choose that shipping method via the radio button (even though it was the only shipping method). Then I tried to go to the Payment Step and it didn't go. It just came back to the Shipping Step.

    So I then downloaded the 2 flat.php files that come with the standard installation. I made copies (so I could go back) and inserted the logic into the flat.php module file. I uploaded and overwrote the original ones.

    I made sure both shipping methods - my new one (USPOST_Flat) and Flat - were installed and active. No issues there.

    I tried placing an order again. Both shipping methods came up with the same price for shipping. If I chose the Flat method, the order progressed to the Payment Step. If I chose the USPOST Flat method, it just came back to the Shipping Step.

    And before anyone asks, I called it USPOST_Flat because USPS checks for the string USPS when it checks to see if it is installed correctly.

    Any ideas?

    Module:
    PHP Code:
    <?php
    /**
     * @package shippingMethod
     * @copyright Copyright 2003-2009 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license [url]http://www.zen-cart.com/license/2_0.txt[/url] GNU Public License V2.0
     */
    // $Id: uspost_flat.php 14498 2009-10-01 20:16:16Z ajeh $
    //

      
    class uspost_flat {
        var 
    $code$title$description$icon$enabled;

    // class constructor
        
    function uspost_flat() {
          global 
    $order$db;

          
    $this->code 'uspost_flat';
          
    $this->title MODULE_SHIPPING_USPOST_FLAT_TEXT_TITLE;
          
    $this->description MODULE_SHIPPING_USPOST_FLAT_TEXT_DESCRIPTION;
          
    $this->sort_order MODULE_SHIPPING_USPOST_FLAT_SORT_ORDER;
          
    $this->icon '';
          
    $this->tax_class MODULE_SHIPPING_USPOST_FLAT_TAX_CLASS;
          
    $this->tax_basis MODULE_SHIPPING_USPOST_FLAT_TAX_BASIS;

          
    // disable only when entire cart is free shipping
          
    if (zen_get_shipping_enabled($this->code)) {
            
    $this->enabled = ((MODULE_SHIPPING_USPOST_FLAT_STATUS == 'True') ? true false);
          }

          if ( (
    $this->enabled == true) && ((int)MODULE_SHIPPING_USPOST_FLAT_ZONE 0) ) {
            
    $check_flag false;
            
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_SHIPPING_USPOST_FLAT_ZONE "' and zone_country_id = '" $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;
            }
          }
        }

    // class methods
        
    function quote($method '') {
          global 
    $order;

          
    $sfrbdw .453819;
          
    $mfrbdw 3.097891;
          
    $lfrbdw 4.771084;
          
    $scwleft $_SESSION['cart']->weight;
          
    $mcwleft $_SESSION['cart']->weight;
          
    $lcwleft $_SESSION['cart']->weight;
          
    $snumbox 0;
          
    $mnumbox 0;
          
    $lnumbox 0;
          
    $lcost 17.9;
          
    $mcost 12.65;
          
    $scost 5.95;
          
    $final_cost 0;
          
          if (
    $lcwleft >= $lfrbdw) {
                
    $lnumbox floor($lcwleft/$lfrbdw);
                
    $mcwleft $lcwleft - ($lfrbdw*$lnumbox);
                
    $scwleft $mcwleft;
          }
          if (
    $mcwleft >= $mfrbdw) {
                
    $mnumbox floor($mcwleft/$mfrbdw);
                
    $scwleft $mcwleft - ($mfrbdw*$mnumbox);
          }

          if (
    $scwleft $sfrbdw) {
                
    $mnumbox $mnumbox 1;
          }
          if (
    $scwleft <= $sfrbdw) {     
                
    $snumbox 1;
          }

          
    $final_cost = ($snumbox $scost) + ($mnumbox $mcost) + ($lnumbox $lcost);
          
          
    $this->quotes = array('id' => $this->code,
                                
    'module' => MODULE_SHIPPING_USPOST_FLAT_TEXT_TITLE,
                                
    'methods' => array(array('id' => $this->code,
                                                         
    'title' => MODULE_SHIPPING_USPOST_FLAT_TEXT_WAY,
                                                         
    'cost' => $final_cost)));
          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);

          return 
    $this->quotes;
        }

        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->_check)) {
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_SHIPPING_USPOST_FLAT_STATUS'");
            
    $this->_check $check_query->RecordCount();
          }
          return 
    $this->_check;
        }

        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 USPOST Flat Shipping', 'MODULE_SHIPPING_USPOST_FLAT_STATUS', 'True', 'Do you want to offer uspost_flat rate 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, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_USPOST_FLAT_COST', '5.00', 'The shipping cost for all orders using 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_USPOST_FLAT_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_USPOST_FLAT_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_USPOST_FLAT_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_USPOST_FLAT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
        }

        function 
    remove() {
          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key like 'MODULE\_SHIPPING\_USPOST_FLAT\_%'");
        }

        function 
    keys() {
          return array(
    'MODULE_SHIPPING_USPOST_FLAT_STATUS''MODULE_SHIPPING_USPOST_FLAT_COST''MODULE_SHIPPING_USPOST_FLAT_TAX_CLASS''MODULE_SHIPPING_USPOST_FLAT_TAX_BASIS''MODULE_SHIPPING_USPOST_FLAT_ZONE''MODULE_SHIPPING_USPOST_FLAT_SORT_ORDER');
        }
      }
    ?>
    Language:
    PHP Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers                           |
    // |                                                                      |   
    // | [url]http://www.zen-cart.com/index.php[/url]                                    |   
    // |                                                                      |   
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | [url]http://www.zen-cart.com/license/2_0.txt[/url].                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: uspost_flat.php 1969 2005-09-13 06:57:21Z drbyte $
    //

    define('MODULE_SHIPPING_USPOST_FLAT_TEXT_TITLE''USPOST Flat Rate');
    define('MODULE_SHIPPING_USPOST_FLAT_TEXT_DESCRIPTION''USPOST Flat Rate');
    define('MODULE_SHIPPING_USPOST_FLAT_TEXT_WAY''Best Way');
    ?>
    Last edited by mrudden; 15 Jan 2015 at 05:21 PM.

 

 

Similar Threads

  1. v150 Clone Flat Rate Shipping with Zone
    By nfallat in forum Built-in Shipping and Payment Modules
    Replies: 21
    Last Post: 29 Jul 2012, 11:42 PM
  2. v150 Flat Rate Shipping Clone
    By laurelsstitchery in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 22 Feb 2012, 02:02 AM
  3. free shipping for specific zip code, flat rate otherwise
    By newdre in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 11 Jan 2012, 11:39 AM
  4. Flat Rate Shipping with Zones
    By BotRot in forum General Questions
    Replies: 4
    Last Post: 8 Oct 2010, 04:28 AM
  5. Flat rate shipping per item with shipping & handling
    By FlameAngel in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 8 Jan 2008, 05:43 PM

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