Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shipping Surcharge contribution


knifeman

Recommended Posts

I still don't understand. This adds an extra amount for shipping. What do you mean when you say to apply it to shipping?

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 87
  • Created
  • Last Reply

I cant seem to get this module to work for Paypal Pro Direct Credit Card or Express Checkout. It works perfectly for my money order, but I'm not sure how to enter the type of payments it applies to for the other 2 modules.

 

Any help is greatly appreciated.

Link to comment
Share on other sites

It isn't applied to any payment modules. It adds an extra amount for shipping if the country being ordered from is not listed in its settings.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

What I'm speaking of is at the bottom right. It doesnt seem to work without something filled in the payment type window:

 

shippingsurcharge.jpg

 

I currently have "moneyorder" in that box. It then works perfectly. But I'd like to get the 2 paypal pro modules to work as well. The credit card and express checkout modules from paypal pro will still show the normal shipping rate, not the shipping rate+surcharge.

Link to comment
Share on other sites

Oh, I see what you mean. The Payment Type is a comma separated list of payment modules the surcharge will be applied to. The names of the modules come from the modules themselves. You will need to open each module you want to use (includes/moudles/payment), and look near the top where it says class XXX, where XXX is the name of the module. Copy and paste that name into this box.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Oh, I see what you mean. The Payment Type is a comma separated list of payment modules the surcharge will be applied to. The names of the modules come from the modules themselves. You will need to open each module you want to use (includes/moudles/payment), and look near the top where it says class XXX, where XXX is the name of the module. Copy and paste that name into this box.

 

Jack

Hi Jack,

 

I want to add a surcharge to payments made by credit card, but not debit cards, i have the seperate payment modules worked out, but not how to surcharge, can i use your module for this?

 

I see this module is based on the payment surcharge module, but i could not find this in the payment or shipping contributions, would that be the correct module to use?

 

Thanks

HRH SII

Link to comment
Share on other sites

I don't think this is the module you want, although it may work. If you put the class name of the credit module in the payment type box and then leave the Countries empty, it should charge the surcharge for every charge using that paymetn type. Still, the payment surcharge would probably be the way to go. You might want to search all of the contribuiton sections. It may be in some other category.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 6 months later...

Is there a way that the Shipping Surcharge contribution could be made to apply just to shipping charges and not the order total?

 

What I'm imagining is:

 

Surcharge is 20%, so

 

Item = $100

Shipping = $20

Surcharge = $4 (20% of $20)

 

Instead of the current:

 

Item =$100

Shipping = $20

Surcharge = $24 (20% of $120)

 

What do you think?

 

Thanks!

Link to comment
Share on other sites

This would also avoid additional charges for zero weight items (downloads).

 

Is there a way that the Shipping Surcharge contribution could be made to apply just to shipping charges and not the order total?

 

What I'm imagining is:

 

Surcharge is 20%, so

 

Item = $100

Shipping = $20

Surcharge = $4 (20% of $20)

 

Instead of the current:

 

Item =$100

Shipping = $20

Surcharge = $24 (20% of $120)

 

What do you think?

 

Thanks!

Link to comment
Share on other sites

  • 1 month later...

That is an excellent contribution! Thank you Jack.

I hope Jack can also give some advices in my special case:

When I ship chemical products, usually there will be surcharges for hazard material shipping and handling fee. So instead of based on country or payment methods, charging surchage fee will be based on hazard flag (if there are hazard material in the shopping cart, the flag will be set).

Link to comment
Share on other sites

  • 1 month later...

Tim

 

Just found your mod which looks great. Unfortunately I cannot get it to work and was hoping you could advise. Here are my settings:

 

Display Total

true

 

Sort Order

3

 

Surcharge Percentage

0

 

Surcharge Flat Charge

1.20

 

Minimum Amount

.01

 

Payment Type

Credit Card - Protx Form

 

Country

United Kingdom

 

We sell CD's and DVD's and wish to implement a surcharge when any of our products are sold outside the United Kingdom.

 

Can you suggest why this isn't working?

 

My thanks to you

 

Steve

Link to comment
Share on other sites

ok, cracked it!

 

Noticed a post Jack had made:

 

Oh, I see what you mean. The Payment Type is a comma separated list of payment modules the surcharge will be applied to. The names of the modules come from the modules themselves. You will need to open each module you want to use (includes/moudles/payment), and look near the top where it says class XXX, where XXX is the name of the module. Copy and paste that name into this box.

 

So I opened the protx_form.php file found the class name (protx_form), inserted that into payment type (as this is the only payment type we have) and it works.

 

Great mod, thank guys.

 

Quand tout est d'autre dit et est fait, il n'y aura rien d'autre de dire ou faire et seul nous pouvons faire si petit mais ensemble nous pouvons faire si beaucoup de

Link to comment
Share on other sites

  • 7 months later...

I have this contribution installed and is running great except this MINOR but HUGE detail. The checkout totally completes with the surcharge added as expected in the OS Commerce(database) but Paypal never charges the surcharge! I am using paypal_wpp and have that listed and as the only payment type in the admin section of SHIPPING SURCHARGE. All other entries in the admin section are not left blank (I left them 0 (zero percentage).

 

As a test I also changed the name from from paypal_wpp to paypal_wpp.php with no luck, other then it did not add the surcharge to the database with that name?

 

Does my paypal_wpp file need to adjusted to accept this line item?

 

Thanks

Mike

http://thoughtout.biz

Link to comment
Share on other sites

I would like to make more than one of these...

 

(i.e.)

Canada shipping surcharge 5%

Mexico shipping surcharge 10%

Europe shipping surcharge 25% etc.

 

Can the module and lang file be simply copied and a few attributes changed within each?? Or is there a much more simple method that I'm overlooking.

 

Thanks!!

 

-Speed

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Copied both files (module and language) and changed file names and attributes within to duplicate this for more than 1 country

 

Now however it shows (and calculates all my 4 countries) as this:

country_surcharge.jpg

(percentages are just for test so nobody get all too excited :)

 

Here is an example of the module for Ireland:

<?php

 class ot_shipireland {
var $title, $output;

function ot_shipireland() {
  $this->code = 'ot_shipireland';
  $this->title = MODULE_SHIPPING_TITLE_IRELAND;
  $this->description = MODULE_SHIPPING_DESCRIPTION_IRELAND;
  $this->enabled = MODULE_SHIPPING_STATUS_IRELAND;
  $this->sort_order = MODULE_SHIPPING_SORT_ORDER_IRELAND;
  $this->percentage = MODULE_SHIPPING_PERCENTAGE_IRELAND;
  $this->flatcharge = MODULE_SHIPPING_FLATCHARGE_IRELAND;
  $this->shipcountry = MODULE_SHIPPING_COUNTRY_IRELAND; 
  $this->minimum = MODULE_SHIPPING_MINIMUM_IRELAND;
  $this->output = array();
}

function process() {
 global $order, $currencies;

  $od_amount = $this->calculate_fee($this->get_order_total());
  if ($od_amount>0) {
  $this->addition = $od_amount;
  $this->output[] = array('title' => $this->title . ':',
						  'text' => '<font color=green>' . $currencies->format($od_amount) . '</font>',
						  'value' => $od_amount);
$order->info['total'] = $order->info['total'] + $od_amount;
}
}

 function calculate_fee($amount) {
global $order, $customer_id, $payment;

	  $countries = split("[,]" , MODULE_SHIPPING_COUNTRY_IRELAND);
  for ($i = 0; $i < count($countries); $i++) {
		 if (tep_get_country_name($order->delivery['country_id']) == $countries[$i]) 
	   return 0;
  }

$od_amount=0;
$od_pc = $this->percentage; //this is percentage
$do = false;
if ($amount > $this->minimum) {
$table = split("[,]" , MODULE_SHIPPING_TYPE_IRELAND);
for ($i = 0; $i < count($table); $i++) {
	  if ($payment == $table[$i]) $do = true;
	}
if ($do) {
	   if (MODULE_SHIPPING_FLATCHARGE_IRELAND) {
		$od_amount = $this->flatcharge;
		 }  
		 else {
  $od_amount = round($amount*10)/10*$od_pc/100 + .35; //percentage plus base fee
  $od_amount = $od_amount + $tod_amount;
		}
}
}
return $od_amount;
 }

 function get_order_total() {
global  $order, $cart;
$order_total = $order->info['total'];
// Check if gift voucher is in cart and adjust total
$products = $cart->get_products();
for ($i=0; $i<sizeof($products); $i++) {
  $t_prid = tep_get_prid($products[$i]['id']);
  $gv_query = tep_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
  $gv_result = tep_db_fetch_array($gv_query);
  if (ereg('^GIFT', addslashes($gv_result['products_model']))) {
	$qty = $cart->get_quantity($t_prid);
	$products_tax = tep_get_tax_rate($gv_result['products_tax_class_id']);
	if ($this->include_tax =='false') {
	   $gv_amount = $gv_result['products_price'] * $qty;
	} else {
	  $gv_amount = ($gv_result['products_price'] + tep_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
	}
	$order_total=$order_total - $gv_amount;
  }
}
if ($this->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
if ($this->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
return $order_total;
 }

function check() {
  if (!isset($this->check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_STATUS_IRELAND'");
	$this->check = tep_db_num_rows($check_query);
  }

  return $this->check;
}

function keys() {
 return array('MODULE_SHIPPING_STATUS_IRELAND', 'MODULE_SHIPPING_SORT_ORDER_IRELAND','MODULE_SHIPPING_PERCENTAGE_IRELAND','MODULE_SHIPPING_FLATCHARGE_IRELAND','MODULE_SHIPPING_MINIMUM_IRELAND', 'MODULE_SHIPPING_TYPE_IRELAND', 'MODULE_SHIPPING_COUNTRY_IRELAND');
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Total', 'MODULE_SHIPPING_STATUS_IRELAND', 'true', 'Do you want to enable the Order Payment Fee?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_SORT_ORDER_IRELAND', '4', 'Sort order of display.', '6', '2', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Surcharge Percentage', 'MODULE_SHIPPING_PERCENTAGE_IRELAND', '35', 'Amount of Surcharge(percentage).', '6', '7', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Surcharge Flat Charge', 'MODULE_SHIPPING_FLATCHARGE_IRELAND', '0', 'Amount of Surcharge(Flat Charge).', '6', '7', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Amount', 'MODULE_SHIPPING_MINIMUM_IRELAND', '0', 'Minimum order before fee', '6', '2', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Country', 'MODULE_SHIPPING_COUNTRY_IRELAND', 'USA, Other', 'Do not apply Surcharge to', '6', '7', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payment Type', 'MODULE_SHIPPING_TYPE_IRELAND', 'cc,paypal,moneyorder', 'Payment Type to pay surcharge', '6', '2', now())");
}

function remove() {
  $keys = '';
  $keys_array = $this->keys();
  for ($i=0; $i<sizeof($keys_array); $i++) {
	$keys .= "'" . $keys_array[$i] . "',";
  }
  $keys = substr($keys, 0, -1);

  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
}
 }
?>

 

So what needs to be changed so this module can be used for multiple countries??????

 

THANK YOU!

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Copied both files (module and language) and changed file names and attributes within to duplicate this for more than 1 country

 

Now however it shows (and calculates all my 4 countries) as this:

country_surcharge.jpg

(percentages are just for test so nobody get all too excited :)

 

Here is an example of the module for Ireland:

<?php

 function calculate_fee($amount) {
global $order, $customer_id, $payment;

	  $countries = split("[,]" , MODULE_SHIPPING_COUNTRY_IRELAND);
  for ($i = 0; $i < count($countries); $i++) {
		 if (tep_get_country_name($order->delivery['country_id']) == $countries[$i]) 
	   return 0;
  }


So what [b]needs to be changed [/b]so this module can be used for multiple countries??????

THANK YOU!
[/quote]This code[code]	  $countries = split("[,]" , MODULE_SHIPPING_COUNTRY_IRELAND);
  for ($i = 0; $i < count($countries); $i++) {
	 if (tep_get_country_name($order->delivery['country_id']) == $countries[$i]) 
	   return 0;
  }

says to read in the Countries list and ignore all that it finds. So if you wanted this module to only work for Ireland, you would have to enter in all the other Countries in that field. So the above code needs to be changed so that if Ireland is found, it passes. Actually, if you are going to do this, then you don't need the seperate modules. You would just list all Countries you want to charge and change the code to allow them to pass. You would also need to had a check to change the percentage based on the Country since you want those to be different.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thank you Jack.

 

Glad to talk with you again too, I've been real busy with our brick & mortar store and projects for my 2 sites :)

Hope all is well with you and your family!

 

 

1st) What I would like to have is multiple surcharges depending on the country. Lets' say, England 10%, Ireland 12%, Spain 14%, Mexico 7% etc.

I think this contrib would be over the edge to be able to have multiple countries and rates either by manually editing or even further thru the ACP (major cool!)

 

 

2nd) One more thing (sorry to be a pain), I look up to you as an awesome phper (you know way more than me!). Can you take a look at a simple contrib i made and see if there are some tips for it? sLOppY worDs CleaNeR (aka) Sloppy Words Cleaner

 

THANK YOU, looking forward to your advancement on this Shipping Surcharge contrib and critiquing mine :)

KJ (top_speed)

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Thank you Jack.

 

Glad to talk with you again too, I've been real busy with our brick & mortar store and projects for my 2 sites :)

Hope all is well with you and your family!

1st) What I would like to have is multiple surcharges depending on the country. Lets' say, England 10%, Ireland 12%, Spain 14%, Mexico 7% etc.

I think this contrib would be over the edge to be able to have multiple countries and rates either by manually editing or even further thru the ACP (major cool!)

2nd) One more thing (sorry to be a pain), I look up to you as an awesome phper (you know way more than me!). Can you take a look at a simple contrib i made and see if there are some tips for it? sLOppY worDs CleaNeR (aka) Sloppy Words Cleaner

 

THANK YOU, looking forward to your advancement on this Shipping Surcharge contrib and critiquing mine :)

KJ (top_speed)

The code to figure teh countries is already in the module, although it checks the list of countries for those to exclude instead so that would have to be changed to include instead. The percentage field is also already there. It just needs to be changed to allow for multiple inputs. Here is some untested code that should get you started. Change this
 	  $countries = split("[,]" , MODULE_SHIPPING_COUNTRY);
  for ($i = 0; $i < count($countries); $i++) {
		 if (tep_get_country_name($order->delivery['country_id']) == $countries[$i]) 
	   return 0;
  }	
$od_amount=0;
$od_pc = $this->percentage; //this is percentage

to this

	  $percent = '';
	  $countries = split("[,]" , MODULE_SHIPPING_COUNTRY);
  for ($i = 0; $i < count($countries); $i++) {
		 if (tep_get_country_name($order->delivery['country_id']) == $countries[$i])
		 {
		$percentage = explode("," , MODULE_SHIPPING_PERCENTAGE);
		$percent = $percentage[$i];
		break;
	 }
  }
  if (! tep_not_null($percent))
	return 0;

$od_amount=0;
$od_pc = $percent; //this is percentage

 

As for the sloppy words contribution, I don't have time to install it but it looks like a very good idea. I've had that problem myself so I think it would be useful.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

I'm not very good with this stuff, but I'm having a problem installing this shipping surcharge contribution.

When I installed the two files, I didn't see a 'Order Total' folder. I only had a 'Shipping' folder, so I placed the files as follows

 

catalog/includes/lang/english/modules/shipping/ot_shipsurcharge

catalog/includes/modules/shipping/ot_shipsurcharge

 

I then went into my admin panel/modules/Order Total, and did not see any 'Shipping Surcharge'.

 

I also went into the admin/modules/shipping and did not see it there either.

Can someone please help me out?

Thanks

Link to comment
Share on other sites

I currently have "moneyorder" in that box. It then works perfectly. But I'd like to get the 2 paypal pro modules to work as well. The credit card and express checkout modules from paypal pro will still show the normal shipping rate, not the shipping rate+surcharge.

 

I think I may be having this same problem. I'm using Linkpoint API. Do I need to type in Linkpoint API into the 'Payment Type' box?

I figured out my install problem, now I can't get the surcharge to show when I'm doing a test order.

 

I don't use money orders, so should I remove that from the 'payment type' box?

Thanks

Link to comment
Share on other sites

I think I may be having this same problem. I'm using Linkpoint API. Do I need to type in Linkpoint API into the 'Payment Type' box?

I figured out my install problem, now I can't get the surcharge to show when I'm doing a test order.

 

I don't use money orders, so should I remove that from the 'payment type' box?

Thanks

Please see my previous post regarding payment types.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Please see my previous post regarding payment types.

 

Jack

 

I did read that post, but I wan't that clear on what the 'payment type' field was actually used for. I know it sounds kind of obvious, but i just wasn't sure. Anyhow, my only form of payment is credit card. No paypal or money order or anything like that. I use the Linkpoint API payment module. I tried typing 'linkpoint API credit card' in the 'payment type' field, and I still couldn't get this to work.

 

Am I typing the correct words in the 'payment type' field?

Link to comment
Share on other sites

I did read that post, but I wan't that clear on what the 'payment type' field was actually used for. I know it sounds kind of obvious, but i just wasn't sure. Anyhow, my only form of payment is credit card. No paypal or money order or anything like that. I use the Linkpoint API payment module. I tried typing 'linkpoint API credit card' in the 'payment type' field, and I still couldn't get this to work.

 

Am I typing the correct words in the 'payment type' field?

As the previous post states, you need to get the name from the class definiton in the module.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...