Page 9 of 9 FirstFirst ... 789
Results 81 to 89 of 89
  1. #81
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    OMG you ROCK

    Ajeh thank you!

  2. #82
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    OK, now to really push my luck.

    There is a line at http://www.myzensite.com/index.php?m...=shopping_cart
    Underneath the "Cart Contents' header, example:

    Total Items: 70 Weight: 2380g Amount: $623.70

    Q how do I get the same line to show up on checkout stage 1
    (Shipping Information) .

    http://www.myzensite.com/index.php?m...ckout_shipping

    Ideal location would be under the (3rd?) heading that by default simply says... Shipping: and above the following line that by default says... Please select the preferred shipping method to use on this order.

    So for the sake of elegance I would like this to appear as:

    Shipping:
    Total Items: 70 Weight: 2380g Amount: $623.70
    Please select the preferred shipping method to use on this order.

    (later I may edit the text line to indicate that the methods shown are specific to the weight of the cart contents and shipping zone).

    I would like to do this because it helps the customer to visualise the shipping cost as a fractional amount of the value of the things he or she wishes to buy rather than an islolated page containing a request for money for which he or she gets no tangible reward.

    Again I have tried for hours to copy and paste code from cart pages that generate this line, but either nothing new appears on screen for me or the code gets broken completely. I would be most grateful for a piece of code to achieve this. With many thanks in advance.

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

    Default Re: Tips on cloning Table Rate shipping module

    IF you do not use Tare Rates and Free Shipping where the Free Shipping Products have weight for other modules ...

    You could customize your checkout_shipping.php language file, using your templates and overrides and change it to read:
    Code:
    $totalsDisplay = 'Total Items: ' . $_SESSION['cart']->count_contents() . ' Weight: ' . $_SESSION['cart']->show_weight() . TEXT_PRODUCT_WEIGHT_UNIT . ' Amount: ' . $currencies->format($_SESSION['cart']->show_total());
    define('TEXT_CHOOSE_SHIPPING_METHOD', $totalsDisplay . ' <br />' . 'Please select the preferred shipping method to use on this order.');
    Otherwise it would require more work than this ...

    If you need taxes and such, you will need more work than this as well as the Total is just the SubTotal of the order ...
    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. #84
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    Ajeh, again fantastic - I don't need to deal with tax on my instance of Zen cart because this cart is used 100% for import business where any applicable tax is a matter between the customer and the port of entry/shipping co. - A long way of saying this is perfect!

  5. #85
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    I trust that this will be the last issue on any related topic:

    I have hit a strange and unexpected issue with $this->icon = ''


    I have looked at how the UPS module puts a UPS icon on the page.

    $this->icon = $template->get_template_dir('shipping_ups.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_ups.gif';

    So I have created and uploaded .gif icons to the same directory as shipping_ups.gif

    However when I paste the above code into table.pdf in place of $this->icon = '' then the cloned module breaks completely and so does the ups shipping module (coincidentally without editing that module at all) and sometimes others too. All the affected modules disappear completely from the shipping modules Admin page, and the checkout breaks also at the shipping method page. All is recovered simply by putting the code back to $this->icon = ''

    There is nothing wrong with my .gif icons - I can get any one of them to show up on the UPS shipping module at check out by editing shipping_ups.gif to shipping_otherlogo.gif. But try as I might I cannot get the Icons to appear on table.php or its clones - everything just breaks instead and I cannot see how or why.

    Please will you advise.

  6. #86
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    AH HA Found it!

    Contribution: How to add icons to Table Rate shipping method (or its clones). Probably applies to Zone Rate (or its clones) also.


    1. Add a shipping_logo.gif (name image what you like but probably should avoid CAPITALS) note a size of 50 x 25 pixels is nice IMHO. Upload your image to: includes/templates/template_default/images/icons/

    2 .Open includes/modules/shipping/table.php (or clone thereof)

    at or around line 50 locate:

    global $order, $db;

    and replace with:

    global $order, $db, $template, $current_page_base;

    3. In the same file

    at or around line 56 locate:

    $this->icon = '';

    and replace with:

    $this->icon = $template->get_template_dir('shipping_logo.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_logo.gif';

    where 'shipping_logo.gif' is the name of the .gif you uploaded at step 1.

    Notes: it appears that just copying the function at step 3 from the UPS or USPS shipping modules and replacing $this->icon = ''; calls upon template and current page base functions that are not included without first doing step 2.

  7. #87
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    Here is a complete page of working code with image icon function working and also a code to prevent it displaying above 1000 weight units (in my case grams, maybe yours is lb or KG) for royalmail.php (a clone of table.php from includes/modules/shipping).

    ____


    <?php
    /**
    * @package shippingMethod
    * @copyright Copyright 2003-2009 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 $Id: royalmail.php 14498 2009-10-01 20:16:16Z ajeh $
    */
    /**
    * Enter description here...
    *
    */
    class royalmail extends base {
    /**
    * Declare shipping module alias code
    *
    * @var string
    */
    var $code;
    /**
    * Shipping module display name
    *
    * @var string
    */
    var $title;
    /**
    * Shipping module display description
    *
    * @var string
    */
    var $description;
    /**
    * Shipping module icon filename/path
    *
    * @var string
    */
    var $icon;
    /**
    * Shipping module status
    *
    * @var boolean
    */
    var $enabled;
    /**
    * Enter description here...
    *
    * @return royalmail
    */
    function royalmail() {
    global $order, $db, $template, $current_page_base;

    $this->code = 'royalmail';
    $this->title = MODULE_SHIPPING_ROYALMAIL_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_ROYALMAIL_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_ROYALMAIL_SORT_ORDER;
    $this->icon = $template->get_template_dir('shipping_rm.gif', DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . 'shipping_rm.gif';
    $this->tax_class = MODULE_SHIPPING_ROYALMAIL_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_ROYALMAIL_TAX_BASIS;
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_ROYALMAIL_STATUS == 'True') ? true : false);
    }

    // bof: turn off if over 1000
    global $cart;
    if (!IS_ADMIN_FLAG && $_SESSION['cart']->show_weight() > 1000) {
    $this->enabled = false;
    }
    // eof: turn off if over 1000

    if ($this->enabled) {
    // check MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD is in
    $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD'");
    if ($check_query->EOF) {
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
    }
    }

    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ROYALMAIL_ZONE > 0) ) {
    $check_flag = false;
    $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ROYALMAIL_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;
    }
    }
    }
    /**
    * Enter description here...
    *
    * @param unknown_type $method
    * @return unknown
    */
    function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

    // shipping adjustment
    switch (MODULE_SHIPPING_ROYALMAIL_MODE) {
    case ('price'):
    $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
    break;
    case ('weight'):
    $order_total = $shipping_weight;
    break;
    case ('item'):
    $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
    break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    $royalmail_cost = preg_split("/[:,]/" , MODULE_SHIPPING_ROYALMAIL_COST);
    $size = sizeof($royalmail_cost);
    for ($i=0, $n=$size; $i<$n; $i+=2) {
    if (round($order_total,9) <= $royalmail_cost[$i]) {
    if (strstr($royalmail_cost[$i+1], '%')) {
    $shipping = ($royalmail_cost[$i+1]/100) * $order_total_amount;
    } else {
    $shipping = $royalmail_cost[$i+1];
    }
    break;
    }
    }

    if (MODULE_SHIPPING_ROYALMAIL_MODE == 'weight') {
    $shipping = $shipping * $shipping_num_boxes;
    // show boxes if weight
    switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
    case (0):
    $show_box_weight = '';
    break;
    case (1):
    $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
    break;
    case (2):
    $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
    break;
    default:
    $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
    break;
    }
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_ROYALMAIL_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_ROYALMAIL_TEXT_WAY,
    'cost' => $shipping + (MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_ROYALMAIL_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_ROYALMAIL_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);

    return $this->quotes;
    }
    /**
    * Enter description here...
    *
    * @return unknown
    */
    function check() {
    global $db;
    if (!isset($this->_check)) {
    $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ROYALMAIL_STATUS'");
    $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
    }
    /**
    * Enter description here...
    *
    */
    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 Table Method', 'MODULE_SHIPPING_ROYALMAIL_STATUS', 'True', 'Do you want to offer royalmail 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, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_ROYALMAIL_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can also use percentage amounts, such 25:8.50,35:5%,40:9.50,10000:7% to charge a percentage value of the Order Total', '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, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_ROYALMAIL_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', 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_ROYALMAIL_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, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', 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_ROYALMAIL_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_ROYALMAIL_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_ROYALMAIL_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_ROYALMAIL_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }
    /**
    * Enter description here...
    *
    */
    function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_ROYALMAIL\_%'");
    }

    /**
    * Enter description here...
    *
    * @return royalmail
    */
    function keys() {
    return array('MODULE_SHIPPING_ROYALMAIL_STATUS', 'MODULE_SHIPPING_ROYALMAIL_COST', 'MODULE_SHIPPING_ROYALMAIL_MODE', 'MODULE_SHIPPING_ROYALMAIL_HANDLING', 'MODULE_SHIPPING_ROYALMAIL_HANDLING_METHOD', 'MODULE_SHIPPING_ROYALMAIL_TAX_CLASS', 'MODULE_SHIPPING_ROYALMAIL_TAX_BASIS', 'MODULE_SHIPPING_ROYALMAIL_ZONE', 'MODULE_SHIPPING_ROYALMAIL_SORT_ORDER');
    }
    }
    ?>

  8. #88
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    here is the other part of this module from includes/languages/english/modules/shipping/

    -----

    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers |
    // | |
    // | http://www.zen-cart.com/index.php |
    // | |
    // | 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: |
    // | http://www.zen-cart.com/license/2_0.txt. |
    // | 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: table.php 1969 2005-09-13 06:57:21Z drbyte $
    //

    define('MODULE_SHIPPING_ROYALMAIL_TEXT_TITLE', 'Royal Mail 1st Class');
    define('MODULE_SHIPPING_ROYALMAIL_TEXT_DESCRIPTION', 'Royal Mail 1st Class Airmail - standard');
    define('MODULE_SHIPPING_ROYALMAIL_TEXT_WAY', 'Royal Mail 1st Class Airmail 4 - 6 days from factory release.');
    define('MODULE_SHIPPING_ROYALMAIL_TEXT_WEIGHT', 'Weight');
    define('MODULE_SHIPPING_ROYALMAIL_TEXT_AMOUNT', 'Amount');
    ?>

  9. #89
    Join Date
    Nov 2010
    Posts
    44
    Plugin Contributions
    0

    Default Re: Tips on cloning Table Rate shipping module

    for sake of completeness, here is the icon:

    Last edited by scientific_anomaly; 2 Dec 2010 at 10:45 AM.

 

 
Page 9 of 9 FirstFirst ... 789

Similar Threads

  1. Cloning the Flat Rate Shipping Module
    By jo_h1971 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 16 Oct 2009, 12:11 PM
  2. cloning table rate crushed
    By deadheat1 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 16 Jul 2008, 02:01 AM
  3. Clone a shipping module or define a new shipping attribute under table rate module?
    By meeven in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 4 Sep 2007, 04:56 PM
  4. Cloning Table Rate mode
    By sylsau in forum Addon Shipping Modules
    Replies: 5
    Last Post: 16 Dec 2006, 02:16 AM
  5. cloning the shipping module - table
    By drmad in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 20 Oct 2006, 08:11 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