2 Tax Modification

Completed modifications to the NOP Shopping Cart. Additions, modifications, and more.

Moderators: Koibito, Stefko, Randy, Rosey

Problem using your cart

Postby AlphaandOmega » Sun Jul 25, 2004 11:26 pm

Randy,

I have used your two tax system for my website. But there has been a problem. Even with the original nopcart.js from the website you posted the output doesnt work. The taxes work put the id and product name wont come up in the email. Tried another configuration etc. i am using an asp checkout but i think the problem lies within the the nopcart. I would really aprreciate some advise. The website is http://www.demoland.nl

Patrick
AlphaandOmega
 
Posts: 1
Joined: Sun Jul 25, 2004 11:18 pm

Postby Randy » Mon Aug 02, 2004 2:59 am

I took a peek at your site...everything in the checkout function looks OK to me.

Before you do anything else, edit checkout.htm line 106:

<FORM
onsubmit="if(CheckForm(this)){SetCookie ('NumberOrdered', 0, null, '/'); return true;} else { return false; }"

to read:

<FORM
onSubmit="return CheckForm(this)"

you may be passing an empty cart to checkout.asp.

Then, it that isn't the problem, read on...

To find out if the info is being passed along properly, add this in place of the blank line at 818:

alert(strOutput);

This will display an alert box with all the items ordered in it when you call up the CheckoutCart function...you should get the item's info in the order it is given in lines 809 to 814...

OutputItemId + strFooter should be the item's order number followed by the item count...1, 2, 3 etc.

If everything is there as it should be, go to the checkout.asp and make sure that page is expecting the same variable names with the info in them...I don't know what the ASP equivalent to an alert box is, but that would tell you if the info is being passed correctly.


Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Checkout Error

Postby WingNut » Thu Dec 09, 2004 8:06 am

Hi,

After implementing Randy's code, I got the following error on line 1194: 'ItemWeight' is undefined.

Did anyone run into this before? your assistance is appreciated.

Avi "WingNut" Reem
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

Postby Randy » Thu Dec 09, 2004 10:57 pm

At the beginning of nopcart.js where the tax rate is set, add the line

ItemWeight = 0;

By defining the variable at the start of nopcart.js you will not see that error again.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Shipping Issue

Postby WingNut » Fri Dec 10, 2004 2:01 pm

Hi,

That seemed to do the trick - thanks!

The next issue is the shipping. It seems to be fixed at 6.50 even though I set the shipping cost for the items through the form
Code: Select all
<input type=hidden name="SHIPPING" value="10.00">

I found the following through quick search through the nopcart.js :
Code: Select all
function ComputeShipping(Zone, NoQty, Wgt, TotVal, ship) {
Shipping = 6.50;
...


Can you give some examples on how to calculate shipping costs? I have various size items with various associated shipping costs.

:) Thanks again.
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

Postby Randy » Fri Dec 10, 2004 3:17 pm

If you are setting the SHIPPING for each item this is the way to do it:

<input type=hidden name="SHIPPING" value="10.00">

If you buy one it costs $10 to ship it, while 3 of the same thing would be $30.

In the example you give, the shipping cost was set for a flat rate of $6.50 in the code you quoted:

Code: Select all
 
function ComputeShipping(Zone, NoQty, Wgt, TotVal, ship) {
Shipping = 6.50;
... 


Rather remove the line, change it to read:

Shipping += 0;

or whatever you want to charge as a minimum flat rate to be added to the SHIPPING amounts.

There are a number of methods for computing shipping...some offer shipping as a percentage of the total cost of the products, some discount it as the total goes up, or some offer flat rates in steps based on the total.
Then there is by distance, weight, and of course by SHIPPING value set on each item.

About the only way I haven't seen is by the phase of the moon, or by the day of the month (As in COP's speeding ticket quotas). The best way is to determine how you ship your products, (Mail, UPS, FedEx etc) and work up a cost table that can be translated into a formula, and code that into nopcart.js. You can even compute shipping by different methods, and have the customer select (and pay for) their preference.

Don't forget to add GST on Shipping...you have to pay it!

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Shipping

Postby WingNut » Fri Dec 10, 2004 4:16 pm

Hi Randy,

Thanks for the fast reply. The full function looks like this :
Code: Select all
//-----------------------------------------------------------------------||
// FUNCTION: ComputeShipping                                             ||
// PARAMETERS: Zone, Total Quantity, Weight, Total Value, preset amount  ||
// RETURNS:  Shipping Cost                                               ||
// PURPOSE: Compute shipping cost total Qty and shipping zone            ||
//-----------------------------------------------------------------------||
 
function ComputeShipping(Zone, NoQty, Wgt, TotVal, ship) {
Shipping = 6.50;
// LocationValue = GetCookie("ZoneSelected");

    // ------------------- Calculate shipping by total order weight ------------||

    // ------------------- fWeight is in lbs or Kilograms ----------------------||
    // - between this weight and    this ,  shipping costs this ----------------||
if ( Wgt >  0.00 && Wgt <=  0.50 ){ Shipping +=  3.30 };
if ( Wgt >  0.50 && Wgt <=  1.00 ){ Shipping +=  4.40 };
if ( Wgt >  1.00 && Wgt <=  2.00 ){ Shipping +=  5.50 };
if ( Wgt >  2.00 && Wgt <=  5.00 ){ Shipping +=  6.60 };
if ( Wgt >  5.00 && Wgt <= 10.00 ){ Shipping +=  7.70 };
if ( Wgt > 10.00 && Wgt <= 15.00 ){ Shipping +=  8.80 };
if ( Wgt > 15.00 && Wgt <= 20.00 ){ Shipping += 10.00 };
if ( Wgt > 20.00 && Wgt <= 25.00 ){ Shipping += 11.10 };
if ( Wgt > 25.00 && Wgt <= 30.00 ){ Shipping += 12.20 };
if ( Wgt > 30.00 ){ Shipping  += 15.50; }


/*
if (LocationValue != Zone) {
SetCookie("ZoneSelected", Zone, null, "/");
location.href=location.href;
   }
   
var ItemQty = parseInt(NoQty);
if (LocationValue == 0 ){
  var ship =  (ItemQty * 5.00);
  return (ship);
}
if (LocationValue == 1 ){
  var ship =  (ItemQty * 7.00);
  return (ship);
}

if (LocationValue == 99 ) return 0.00;
*/
   return Shipping;
}


if I change it to
Code: Select all
Shipping += 0;
I get Error: Object expected

Ultimately what I'm trying to achieve is the ability to charge for shipping on a per item basis, where the shipping price varies from one province to another. I am from Ontario, so shipping to Ontario will be X. Shipping to other provinces would be X + some fixed amount. The fixed amount will vary by province
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

Postby Randy » Sat Dec 11, 2004 4:08 am

I might have missed something...try changing the Shipping = 6.50; to Shipping = 0.00;

forget the += stuff.

As for computing shipping, take a look at the UPS shipping by zone mod. This could be modified to make it work for provinces if there is either a math relationship between the provinces shipping costs, or if a provincial flat rate would be enough to cover the differences.

Canada Post offers an online calculator based on the shipper and destination postal codes. I don't know if there is one to download.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

Shipping = 0.00;

Postby WingNut » Sat Dec 11, 2004 2:44 pm

Shipping = 0.00; causes the shipping total to be 0. It ignores the <input type=hidden name="SHIPPING" value="10.00"> defined in the item forms.
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

any idea?

Postby WingNut » Tue Dec 21, 2004 8:41 pm

any ideas how I can get this going?
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

Postby Randy » Wed Dec 22, 2004 10:59 pm

I have isolated the problem and here is the fix:

In Nopcart.js

change line 857 to FShipping from fShip
so it reads:
fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );

delete line 913:
fShipping = ComputeShipping(LocationSelected, fItems, fWeight, fTotal, fShip);

and line 1172:

fShipping = ComputeShipping(LocationSelected, fItems, fWeight, fTotal, fShip);

That will fix it up!!

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

almost there

Postby WingNut » Wed Dec 22, 2004 11:31 pm

OK, that took care of the intermediate step of managing the shopping cart. To make the calculation easy, I made the product price $100, and the shipping $10. The cart showed correct totals until I hit the checkout button have a look at http://www.logicscape.com/pokerandgaming and tell me what you think...

Thanks.
WingNut
 
Posts: 6
Joined: Thu Dec 09, 2004 5:31 am
Location: Canada eh!

Postby Randy » Fri Dec 24, 2004 1:35 am

I must have missed a couple!

Remove the following from lines 1172 and 1225 (and anywhere else you see them)

fShipping = ComputeShipping(LocationSelected, fItems, fWeight, fTotal, fShip);

It will work then!!

Also your checkout page is too wide...iI have to do a horz. scroll--managecart is OK.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

GST/PST Questions

Postby Jeremy Haynes » Thu Dec 30, 2004 4:24 am

Randy,

First off, great script...it has really helped me out in a jam. The question I have is:

is there anyway to have the GST and PST Calculated when the "Ontario" Radio button is seleted...when the radio button for "others" is checked off to have the GST = 0?

thanks
Jay
Jeremy Haynes
 
Posts: 2
Joined: Thu Dec 30, 2004 4:14 am

Postby Randy » Thu Dec 30, 2004 1:56 pm

I have been playing with a 3rd radio button:

"Ontario" for GST + PST
"Other Canadians" for GST only
"Other Countries" no PST, no GST

You would then add the GST on shipping into the cost of shipping.

This is only necessary if you are using a Payment Processor, so an easier way to do it would be to show the Provincial Sales Tax as a separate row just like the GST, add both taxes together for the 3 radio buttons and the Payment Processor would get one tax figure.

This would probably work for the 2 Provinces that use the combined HST.
HST is easier to calculate--there is nothing tax exempt! :lol:

Let me know what you think.

Randy
Randy
Guru
 
Posts: 1511
Joined: Tue Apr 22, 2003 12:21 pm
Location: Thunder Bay, Ontario

PreviousNext

Return to Modifications

Who is online

Users browsing this forum: No registered users and 1 guest

cron