Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Shipping specials? Please help

Shipping specials? Please help

Locked

Views: 1,651

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
24 Nov 2008, 3:47 AM
#1
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Shipping specials? Please help

Hey everyone,

Is there any way to charge $4.99 for shipping on the first item and then $1.00 for each additional product added to the cart?

And then finally an option for priority mail at $2.49 added to the final cost?

Any help is appreciated! :smile:

24 Nov 2008, 3:58 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

Use the Item Rate item shipping module with 1.00 per item and a handling charge of 3.99 ...

Then clone the Item Rate item to something like:
item.php itempriority.php

where item becomes itempriority and ITEM becomes ITEMPRIORITY

Copy the two files:
/includes/modules/shipping/item.php
/includes/languages/english/modules/shipping/item.php

/includes/modules/shipping/itempriority.php
/includes/languages/english/modules/shipping/itempriority.php

And add another 2.49 to the Handling charge ...

Now they can pick which ever one they want ...

25 Nov 2008, 4:58 AM
#3
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

Ajeh:

Use the Item Rate item shipping module with 1.00 per item and a handling charge of 3.99 ...

Then clone the Item Rate item to something like:
item.php itempriority.php

where item becomes itempriority and ITEM becomes ITEMPRIORITY

Copy the two files:
/includes/modules/shipping/item.php
/includes/languages/english/modules/shipping/item.php

/includes/modules/shipping/itempriority.php
/includes/languages/english/modules/shipping/itempriority.php

And add another 2.49 to the Handling charge ...

Now they can pick which ever one they want ...

Thanks for the reply!

So you are saying I should copy item.php and rename it itempriority.php?

Do I need to edit the code in the copied file or just leave it the same?

Thanks!

25 Nov 2008, 5:31 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

Fazle:

Thanks for the reply!

So you are saying I should copy item.php and rename it itempriority.php?

Do I need to edit the code in the copied file or just leave it the same?

Thanks!

In the code you will see item and ITEM ... where item is you will change it to** itempriority and where ITEM is you will change it to ITEMPRIORITY** ...

26 Nov 2008, 6:46 AM
#5
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

Thanks again for the quick reply!

I'm getting an error on my admin shipping module page after I uploaded the new itempriority.php file.

Here is the error I am getting:
Fatal error: Cannot redeclare class item in /home/.champ/farboenterprises/stickersftw.com/includes/modules/shipping/itempriority.php on line 11

Here is my itempriority.php file:

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2006 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: itempriority.php 5501 2007-01-01 15:42:54Z ajeh $
 */


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

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

      $this->code = 'itempriority';
      $this->title = MODULE_SHIPPING_ITEMPRIORITY_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_ITEMPRIORITY_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_ITEMPRIORITY_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_ITEMPRIORITY_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_ITEMPRIORITY_TAX_BASIS;

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

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEMPRIORITY_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . 

MODULE_SHIPPING_ITEMPRIORITY_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, $total_count;

      // adjusted count for free shipping
      $itempriority_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ITEMPRIORITY_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_ITEMPRIORITY_TEXT_WAY,
                                                     'cost' => (MODULE_SHIPPING_ITEMPRIORITY_COST * 

$itempriority_total_count) + MODULE_SHIPPING_ITEMPRIORITY_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;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where 

configuration_key = 'MODULE_SHIPPING_ITEMPRIORITY_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 Item Shipping', 'MODULE_SHIPPING_ITEMPRIORITY_STATUS', 'True', 'Do you want to offer per item 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_ITEMPRIORITY_COST', '2.50', 'The shipping cost will be multiplied by the number of items in 

an order that uses 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, date_added) values ('Handling 

Fee', 'MODULE_SHIPPING_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this

->keys()) . "')");
    }

    function keys() {
      return array('MODULE_SHIPPING_ITEMPRIORITY_STATUS', 'MODULE_SHIPPING_ITEMPRIORITY_COST', 

'MODULE_SHIPPING_ITEMPRIORITY_HANDLING', 'MODULE_SHIPPING_ITEMPRIORITY_TAX_CLASS', 

'MODULE_SHIPPING_ITEMPRIORITY_TAX_BASIS', 'MODULE_SHIPPING_ITEMPRIORITY_ZONE', 

'MODULE_SHIPPING_ITEMPRIORITY_SORT_ORDER');
    }
  }
?>

Any ideas what I'm doing wrong?

26 Nov 2008, 4:00 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

Looks like you got a little carried away on the replacements ...

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2006 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: itempriority.php 5501 2007-01-01 15:42:54Z ajeh $
 */


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

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

      $this->code = 'itempriority';
      $this->title = MODULE_SHIPPING_ITEMPRIORITY_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_ITEMPRIORITY_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_ITEMPRIORITY_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_ITEMPRIORITY_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_ITEMPRIORITY_TAX_BASIS;

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

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEMPRIORITY_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEMPRIORITY_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, $total_count;

      // adjusted count for free shipping
      $item_total_count = $total_count - $_SESSION['cart']->free_shipping_items();
      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_ITEMPRIORITY_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => MODULE_SHIPPING_ITEMPRIORITY_TEXT_WAY,
                                                     'cost' => (MODULE_SHIPPING_ITEMPRIORITY_COST * $item_total_count) + MODULE_SHIPPING_ITEMPRIORITY_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;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEMPRIORITY_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 Item Shipping', 'MODULE_SHIPPING_ITEMPRIORITY_STATUS', 'True', 'Do you want to offer per item 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_ITEMPRIORITY_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses 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, date_added) values ('Handling Fee', 'MODULE_SHIPPING_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_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_ITEMPRIORITY_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }

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

    function keys() {
      return array('MODULE_SHIPPING_ITEMPRIORITY_STATUS', 'MODULE_SHIPPING_ITEMPRIORITY_COST', 'MODULE_SHIPPING_ITEMPRIORITY_HANDLING', 'MODULE_SHIPPING_ITEMPRIORITY_TAX_CLASS', 'MODULE_SHIPPING_ITEMPRIORITY_TAX_BASIS', 'MODULE_SHIPPING_ITEMPRIORITY_ZONE', 'MODULE_SHIPPING_ITEMPRIORITY_SORT_ORDER');
    }
  }
?>

Also make sure you do not have any backup copies or additional copies on the server as that is a self loading directory ...

26 Nov 2008, 10:01 PM
#7
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

Ugh. Thanks for all the help.

I managed to screw it up somehow.

I deleted the item.php file and then reuploaded it and now I'm getting and error and the shipping page during checkout shows up blank.

In the shipping modules admin area this error is displayed:
Fatal error: Cannot redeclare class item in /home/.champ/farboenterprises/5dollarpostershop.com/includes/modules/shipping/item.php on line 11

All I did was delete and reupload item.php.

I'm so confused by this.

27 Nov 2008, 5:06 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

Load the original item.php files:
/includes/modules/shipping/item.php
/includes/languages/english/modules/shipping/item.php

Next, copy these two files:
/includes/modules/shipping/item.php
/includes/languages/english/modules/shipping/item.php

to these twofiles:
/includes/modules/shipping/itempriority.php
/includes/languages/english/modules/shipping/itempriority.php

Then, delete the contents of:
/includes/modules/shipping/itempriority.php

and paste into it the code I posted above for the itempriority.php file ...

Finally, edit the file:
/includes/languages/english/modules/shipping/itempriority.php

and change all item to read itempriority and ITEM to read ITEMPRIORITY ...

Copy the files to the server ...

Install the Item Priority itempriority and see if it now works better ...

4 Dec 2008, 7:15 AM
#9
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

I did everything you said to do. The itempriority.php is no longer a problem.

However, I accidentally deleted the original item.php. I re uploaded the file and now in my admin area, when I click on shipping modules I get this error: Fatal error: Cannot redeclare class item in /home/.champ//.com/includes/modules/shipping/item.php on line 11

Most of my shipping modules I had before I deleted the item.php files have dissapeared and now I am only left with 3. "Flat Rate" "Free Shipping Options" and "Free Shipping"

All the other have dissapeared and I am getting that error.

Also, during checkout, now when you get to shipping page, a blank white page is displayed.

What happened?

4 Dec 2008, 8:35 AM
#10
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

There is a screenshot of what I am seeing.

4 Dec 2008, 12:15 PM
#11
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

If anyone knows what the problem is, please help!

This is urgent. Thanks!

4 Dec 2008, 3:01 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

Go to the Tools ... Developers Tool Kit ...

and in the bottom input box type in:
class item

then select Catalog from the dropdown and click search ...

How many files contain that?

If more than one, what are the files that show up?

Make sure none are in the languages directory ... if there is one, then you loaded the code file to the language directory instead of the language file and just need to reload the right file to the server ...

4 Dec 2008, 4:38 PM
#13
fazle avatar

fazle

New Zenner

Join Date:
Nov 2008
Posts:
8
Plugin Contributions:
0

Re: Shipping specials? Please help

Ajeh:

Go to the Tools ... Developers Tool Kit ...

and in the bottom input box type in:
class item

then select Catalog from the dropdown and click search ...

How many files contain that?

If more than one, what are the files that show up?

Make sure none are in the languages directory ... if there is one, then you loaded the code file to the language directory instead of the language file and just need to reload the right file to the server ...

Thanks for the reply. This is what I got when I did the search:

**Searching 774 files ... for: class item

/home/.champ/includes/languages/english/modules/shipping/item.php

Line #10 : class item {

/home/.champ/includes/languages/english/modules/shipping/itempriority.php

Line #10 : class itempriority {

/home/.champ/includes/modules/itempriority.php

Line #10 : class itempriority {

/home/.champ/includes/modules/shipping/item.php

Line #10 : class item {

/home/.champ/includes/modules/shipping/itempriority.php

Line #10 : class itempriority {

Match Lines found: 5**

I don't understand what you mean by the language file instead of the language directory.

I have item.php and itempriority.php in both /includes/modules/shipping/ and also includes/languages/english/modules/shipping/

4 Dec 2008, 5:38 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

You goobered your copy of the files to the server ... :eek:

The language files contain all of the define statements ...

The code files contain all of the php code to run the shipping module(s) ...

Language files belong in:
/includes/languages/english/modules/shipping

Code files belong in:
/includes/modules/shipping

Reload your language files and this will fix the problems you are having ...

4 Dec 2008, 5:40 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shipping specials? Please help

NOTE: one other error:
home/.champ/includes/modules/itempriority.php

Line #10 : class itempriority {

This tells me you have the file:
itempriority.php

in the directory:
/includes/modules

and it does not belong there ...

You can delete that from the server ...