close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Need help with calculation

Thread began 5/03/2010 6:13 pm by Roxana | Last modified 5/12/2010 1:28 pm by Eric Mittman | 1477 views | 12 replies |

Roxana

Need help with calculation

Hi, when testing the site, I just discovered, that one of the calculations is not done properly. For orders within Europe, I need eCart to add 19% to the subtotal and then get a EuroGrandTotal (not the GrandTotal, leaving out shipping).

I tried that by calculating the EuroTotal: [TotalPrice]*1.19.

Unfortunately this will only add the tax and the first line, and not the total of the column TotalPrice.

I tried a few variations, but I only ended up with blank pages.

Could you please let me know, how to write the calculation to get a EuroTotal? (this would be the subtotal plus tax).

Sign in to reply to this post

Eric Mittman

You will only be able to reference the total of the cart for a discount or charge rule, not in a calculation. This is because calculations are performed on a per item basis with values for an individual item, not the whole cart.

If you have a special charge, discount, shipping or tax rule you can make use of the cart's sub total by selecting 'subtotal of cart' from the select lists. If you are custom coding the rules you can specify the sub total of the cart like this:

php:
$eCart1->TotalColumn("TotalPrice")



The tax can be specified in the code like this:

php:
$eCart1->GetTax()



You would need to use the name of your cart in place of eCart1. If you have any further trouble with this post back with some more details about how your rules and calculations are currently setup and how you would like them to work in the end.

Sign in to reply to this post

Roxana

Hi Eric,

Thank you for your help.

The value I am looking for is the GrandTotal. For European customers this value should not include shipping cost. Therefore I tried calculating a EuropeanGrandTotal. But like I said, all I am getting is the wrong calculation or empty pages.

My calculation looks like this:
item 1: 4.00
item 2: 6.00
subtotal: 10.00
tax: 1.90 (that is 19 % of the subtotal)
total: 4.76 (my try to calculate the EuropenGrandTotal adds 19% only to the first item, instead of the subtotal. The total should be 11.90)

So, my question is, how do I generate a European GrandTotal (one, that does not include shipping cost).

I also tried adding a cart object $nameEuropean. For that cart object I did not specify shipping cost, and I changed all $name to $nameEuropean on the success page. I still end up with the same (above) calculation.

Sign in to reply to this post

Roxana

I would like to add, that our shop ships internationally. There is three different shipping/tax options. The cart, confirm and success page display the invoice only, the customer pays later.

1. Shipment to Germany: Total includes flat shipping fee and tax.
2. Shipment to rest of Europe: Total includes tax.
3. Shipment to all other countries: Total is just the net amount (to display that, I am just using the columns subtotal).

So, how would I display a GrandTotal, that does not include shipping.

Sign in to reply to this post

Roxana

I still haven't solved the problem, but I am getting closer (maybe).

I thought I could set the trigger for shipping to the existence of a session variable. So I added the code "$_SESSION['germanShipping'] = on;" to the german confirm page, and "$_SESSION['euroShipping'] = on;" to the european confirm page. GermanShipping is set to a flat rate, and euroShipping is set to 0.00.

When I enter a European shipping destination, I am redirected to the European confirm page. Shipping is 0.00 and it is not added to the grandTotal.

When I then enter Germany as shipping destination, I am redirected to the German confirm page. Shipping is 5.80 (flat rate), and it is added to the grandTotal.

So far it is working.

However, when I change my mind again, and set a European shipping destination, the 5.80 flat rate will not go away.

I have close to no knowledge of PHP. Would it be possible to end the germanShipping session on the European confirm page? I have tried, but I can't get it to stop. The only way to stop it is to confirm the order and thereby completely destroy the session. But I don't want to do that and have the customer reenter all data.

Could you please help me out, Eric?

Sign in to reply to this post

Eric Mittman

If the shipping charge rule is still present in the cart then the conditions for the charge rule must still be true. If the German shipping charge rule is based on "$_SESSION['germanShipping'] = on;" then on the European confirm page you should check to see if the value is set, and if it is unset it or change it's value so that it does not trigger the shipping charge rule. The code might look like this:

php:
if(isset($_SESSION['germanShipping']) && $_SESSION['germanShipping'] != ""){

  $_SESSION['germanShipping'] = "";
}



Since the session variables control the shipping charge, if you change the values or remove them then you should be able to trigger or clear a shipping charge.

Sign in to reply to this post

Roxana

Thank you for getting back, Eric.

This is exactly, what I am trying to do: unset the session germanShipping. But the code you provided does not unset the session. The shipping charge is still triggered.

Sign in to reply to this post

Roxana

I changed the code (by trial and error) to:

<?php if(isset($_SESSION['germanShipping']) && $_SESSION['germanShipping'] != ""){
$_SESSION['germanShipping'] = $_SESSION['euroShipping'];
}
?>

It works now. Since I am just guessing here, could you confirm that this code will not turn up any problems down the road?

Sign in to reply to this post

Eric Mittman

I'm not sure why it would work for you like this and not the way that I had it, if you can post back with a copy of your cart file that has these charges defined I would better be able to tell you about the effect of making this change. Unless you have some other rules that are based on the euro shipping then it should not have any other effect.

Sign in to reply to this post

Roxana

I couldn't explain it either. For me it was a lucky shot.

I am attaching confirm_europe, confirm_germany and two ecart object pages. I am not sure which one you need.

I had defined shippingGermany as 5.80 flatrate, and shippingEuro as 0.00 flatrate.

Attached Files
Archive.zip
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...