Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 08-27-2013 22:19:13

mgoff1j
Member
Registered: 01-26-2010
Posts: 17

Custom Surcharge Method

Aloha,

I've created a new custom surcharge method.  I've selected and activated my new custom surcharge method.  The result and text are not appearing on the checkout form.  I've also tried to select an existing surcharge method with the same result... It's not showing on the checkout form as the Display Includes, Checkout Totals Display code says it should.  Is there another place I need to add code or a setting I missed?

Much Mahalos!
mgoff1j

Offline

 

#2 08-28-2013 07:24:48

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Custom Surcharge Method

It sounds like you might have an error in your surcharge script.  Can you post it?  Also, try running a default script and see if that works.


Nick Hendler

Offline

 

#3 08-28-2013 15:02:13

mgoff1j
Member
Registered: 01-26-2010
Posts: 17

Re: Custom Surcharge Method

As soon as my code didn't work, I did try the default script, Buy X Items - Y Percent Surcharge, and it didn't show up on the checkout form in the order totals section either.

Here's my custom script.

Code:

<?php 

// +--
// | All custom surcharge scripts work in the same way.  Global
// | variables named 'ecom.checkout_cartids' and 
// | 'ecom.checkout_cosess' contain cart information and 
// | checkout session information respectively.
// |
// | This script must set global variables named 
// | 'ecom.total_customsurcharge' and 'ecom.customsurcharge_text' which
// | contain the surcharge total and the surcharge text respectively.
// |
// | NOTE: Do not print anything within custom surcharge 
// | scripts.  They are designed only to return amounts and
// | text for custom surcharge methods.
// |
// | This script is a User Defined script that returns a shipping 
// | insurance amount based on the amount of the order.
// +--

$cartids = $this->globals('ecom.checkout_cartids');
$cosess  = $this->globals('ecom.checkout_cosess');

// +--
// | surcharge_amount   = The amount of the surcharge.
// | surcharge_subtotal = The subtotal needed to get the surcharge.
// | surcharge_textshow = The text to be displayed for the surcharge.
// +--

$surcharge_amount   = 0;
$surcharge_textshow = 'Shipping Insurance Estimate';

foreach ($cartids as $cartid => $item) {$subtotal = $subtotal + $item['subtotal'];}

if ($subtotal >= '0.01' && $subtotal <= '50') {
     $surcharge_amount = '1.95';
     
} elseif ($subtotal >= '51' && $subtotal <= '100') {
     $surcharge_amount = '2.45';
     
} elseif ($subtotal >= '101' && $subtotal <= '200') {
     $surcharge_amount = '3.05';
     
} elseif ($subtotal >= '201' && $subtotal <= '300') {
     $surcharge_amount = '5.10';
     
} elseif ($subtotal >= '301' && $subtotal <= '400') {
     $surcharge_amount = '6.25';
     
} elseif ($subtotal >= '401' && $subtotal <= '500') {
     $surcharge_amount = '7.40';
     
} elseif ($subtotal >= '501' && $subtotal <= '600') {
     $surcharge_amount = '8.55';
     
} elseif ($subtotal >= '601' && $subtotal <= '700') {
     $surcharge_amount = '9.70';
     
} elseif ($subtotal >= '701' && $subtotal <= '800') {
     $surcharge_amount = '10.85';
     
} elseif ($subtotal >= '801' && $subtotal <= '900') {
     $surcharge_amount = '12.00';
     
} elseif ($subtotal >= '901' && $subtotal <= '1000') {
     $surcharge_amount = '13.15';
     
} elseif ($subtotal >= '1001' && $subtotal <= '1100') {
     $surcharge_amount = '14.30';
     
} elseif ($subtotal >= '1101' && $subtotal <= '1200') {
     $surcharge_amount = '15.45';
     
} elseif ($subtotal >= '1201' && $subtotal <= '1300') {
     $surcharge_amount = '16.60';
     
} elseif ($subtotal >= '1301' && $subtotal <= '1400') {
     $surcharge_amount = '17.75';
     
} elseif ($subtotal >= '1401' && $subtotal <= '1500') {
     $surcharge_amount = '18.90';
     
} elseif ($subtotal >= '1501' && $subtotal <= '1600') {
     $surcharge_amount = '20.05';
     
} elseif ($subtotal >= '1601' && $subtotal <= '1700') {
     $surcharge_amount = '21.20';
     
} elseif ($subtotal >= '1701' && $subtotal <= '1800') {
     $surcharge_amount = '22.35';
     
} elseif ($subtotal >= '1801' && $subtotal <= '1900') {
     $surcharge_amount = '23.50';
     
} else ($subtotal >= '1901') {
     $surcharge_amount = '25.00';
     
} // End of if statement.

     $this->globals('ecom.total_customsurcharge',$surcharge_amount);
     $this->globals('ecom.customsurcharge_text',$surcharge_textshow);

?>

Last edited by mgoff1j (08-28-2013 15:04:49)

Offline

 

#4 08-29-2013 08:02:43

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Custom Surcharge Method

Under Store > Component > Settings > Checkout, do you have 'Custom Surcharge Method Status' set to true in addition to selecting a script from 'Custom Surcharge Method'?  Your script is written incorrectly:

Code:

} else ($subtotal >= '1901') {

Should be:

Code:

} else {

That will fix the error with your code.


Nick Hendler

Offline

 

#5 08-29-2013 12:44:09

mgoff1j
Member
Registered: 01-26-2010
Posts: 17

Re: Custom Surcharge Method

Yes, custom surcharge method status is set to true and fixing the last else did the trick.  My bad.  I've got to add the costs all the way up to $5000 in increments of 100, so there will be a lot more elseif's.

Thanks Nick!

Offline

 

Board footer