osCommerce 4 osCommerce 4 App Shop Support Services App Shop Us
• Checkout
• Get in touch

osCommerce

The e-commerce.

# Order total round problem

## Recommended Posts

I have some problems with order total .

Let's say the following :

Product A has a price of X in default currency

Product A in Euro has a displayed value of 0.11 E

Shipping method has a price of Y in default currency

Shipping method in Euro has 0.22 E

Order total should be 0.33 E but at me is 0.34 E and from this cause i can't finish order with paypal and other customers too .

With i observed :

If a calculate the exact price for product A in Euro the result is 0.114......

For shipping method is 0.224.....

Order total is 0.338 and the function tep_round rounds the total order value to 0.34 , and on paypal page it displays 0.33 . The total order from my site is different from total order from paypal page , and the payment can't pe finished

I don't know what should i do ? Does anyone has an idea ???

##### Share on other sites

A similar problem has been discussed a number of times before, particularly for the addition of a given % tax, but the same principle applies here for multiplying the original price by a non-integer number. Rounded for display, the new displayed number may be a bit higher or a bit lower than the actual value. Adding up all the original prices and then applying the multiplier gives the same result (to unlimited decimal places), but rounded to some fixed number of decimal places, it may differ from the sum of the rounded individual prices. But you've figured this part out by now...

Will PayPal let you send prices with more than two decimal places? If the original price (say, GBP) has two decimal places and the conversion to Euros has three, you would probably need 5 decimal places to preserve the exact number. If they don't, you would have to find a way to enter and list your prices directly in Euros (without multiplying on the run) for customers using Euros. I'm not experienced with using multiple currencies, but doesn't osC permit this (storing multiple prices for different currencies, rather than one price and various multipliers)? If not, that will indeed be a problem. If osC permits both ways, but you are using a base price + conversions because your prices (or exchange rates) change frequently, look into using the Easy Populate add-on to change product prices in bulk (using a spreadsheet and CSV file). On the other hand, if osC only permits one price with conversions, I can't believe that lots of people haven't run into this problem before. osC would have to be modified to carry the rounded price forward to the totals page, and I'm not sure that was ever done.

What osC version?

##### Share on other sites

I am using 2.3.1

I changed to default currency to EURO and i updated all product's prices , now the total amount is ok but i still can't make a payment . WTF is it having . For three days i tried all modules , none of them work .

I can make the payment only if i am choosing a free shipping method . If the cost of the shipping method is greater than 0 EURO i can't make the payment , it redirects me to shopping cart . I don't know what to do more ...

my site is ecig-vapo.com

##### Share on other sites

Is the shipping added a fixed amount, or a percentage? I'm getting a bit out of my comfort zone here, so maybe someone else can help!

##### Share on other sites

a fixed amount , if order < 50 E the shipping method has a cost if order is more than 50 E another cost ....

##### Share on other sites

Somewhere you must be multiplying by a non-integer number. How about tax rates?

##### Share on other sites

Can't be much help. There is a line

\$params['AMT'] = \$paypal_express->format_raw(\$params['ITEMAMT'] + \$params['TAXAMT'] + \$params['SHIPPINGAMT'], '', 1);

in

ext/modules/payment/paypal/express.php

which we could replace with the four lines

\$params['ITEMAMT'] = \$paypal_express->format_raw(\$params['ITEMAMT'], '', 1);

\$params['TAXAMT'] = \$paypal_express->format_raw(\$params['TAXAMT'], '', 1);

\$params['SHIPPINGAMT'] = \$paypal_express->format_raw(\$params['SHIPPINGAMT'], '', 1);

\$params['AMT'] = \$params['ITEMAMT'] + \$params['TAXAMT'] + \$params['SHIPPINGAMT'];

to format the 3 amounts separately.

Not tested.

##### Share on other sites

Tried and not working , it keep redirecting me to shopping cart , without any error message . How could i find the problem why my payment is not succesfull??Here is my ext/modules/payment/paypal/express.php file

```<?php
/*
\$Id\$[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  Copyright (c) 2009 osCommerce[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  Released under the GNU General Public License
*/[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  chdir('../../../../');
require('includes/application_top.php');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  require(DIR_WS_LANGUAGES . 'english/modules/payment/paypal_express.php');
require(DIR_WS_LANGUAGES . \$language . '/' . FILENAME_CREATE_ACCOUNT);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// initialize variables if the customer is not logged in
if (!tep_session_is_registered('customer_id')) {
\$customer_id = 0;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  require('includes/modules/payment/paypal_express.php');
\$paypal_express = new paypal_express();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  if (!\$paypal_express->check() || !\$paypal_express->enabled) {
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  if (!tep_session_is_registered('sendto')) {
tep_session_register('sendto');
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  if (!tep_session_is_registered('billto')) {
tep_session_register('billto');
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
if (!tep_session_is_registered('cartID')) tep_session_register('cartID');
\$cartID = \$cart->cartID;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  switch (\$HTTP_GET_VARS['osC_Action']) {
case 'cancel':
tep_session_unregister('ppe_token');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL'));[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  break;
case 'callbackSet':
if (MODULE_PAYMENT_PAYPAL_EXPRESS_INSTANT_UPDATE == 'True') {
\$counter = 0;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    while (true) {
if (isset(\$HTTP_POST_VARS['L_NUMBER' . \$counter])) {
\$cart->add_cart(\$HTTP_POST_VARS['L_NUMBER' . \$counter], \$HTTP_POST_VARS['L_QTY' . \$counter]);
} else {
break;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$counter++;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// exit if there is nothing in the shopping cart
if (\$cart->count_contents() < 1) {
exit;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$sendto = array('firstname' => '',
'lastname' => '',
'company' => '',
'suburb' => '',
'postcode' => \$HTTP_POST_VARS['SHIPTOZIP'],
'city' => \$HTTP_POST_VARS['SHIPTOCITY'],
'zone_id' => '',
'zone_name' => \$HTTP_POST_VARS['SHIPTOSTATE'],
'country_id' => '',
'country_name' => \$HTTP_POST_VARS['SHIPTOCOUNTRY'],
'country_iso_code_2' => '',
'country_iso_code_3' => '',
[color=#282828][font=helvetica, arial, sans-serif]	    \$country_query = tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . tep_db_input(\$sendto['country_name']) . "' limit 1");
if (tep_db_num_rows(\$country_query)) {
\$country = tep_db_fetch_array(\$country_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$sendto['country_id'] = \$country['countries_id'];
\$sendto['country_name'] = \$country['countries_name'];
\$sendto['country_iso_code_2'] = \$country['countries_iso_code_2'];
\$sendto['country_iso_code_3'] = \$country['countries_iso_code_3'];
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$sendto['country_id'] > 0) {
\$zone_query = tep_db_query("select * from " . TABLE_ZONES . " where zone_country_id = '" . (int)\$sendto['country_id'] . "' and (zone_name = '" . tep_db_input(\$sendto['zone_name']) . "' or zone_code = '" . tep_db_input(\$sendto['zone_name']) . "') limit 1");
if (tep_db_num_rows(\$zone_query)) {
\$zone = tep_db_fetch_array(\$zone_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    \$sendto['zone_id'] = \$zone['zone_id'];
\$sendto['zone_name'] = \$zone['zone_name'];
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$billto = \$sendto;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$quotes_array = array();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    include(DIR_WS_CLASSES . 'order.php');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$cart->get_content_type() != 'virtual') {
\$order = new order;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$total_weight = \$cart->show_weight();
\$total_count = \$cart->count_contents();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// load all enabled shipping modules
include(DIR_WS_CLASSES . 'shipping.php');
\$shipping_modules = new shipping;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$free_shipping = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
\$pass = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if (\$order->delivery['country_id'] == STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  case 'international':
if (\$order->delivery['country_id'] != STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  case 'both':
\$pass = true;
break;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    if ( (\$pass == true) && (\$order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
\$free_shipping = true;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  include(DIR_WS_LANGUAGES . \$language . '/modules/order_total/ot_shipping.php');
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if ( (tep_count_shipping_modules() > 0) || (\$free_shipping == true) ) {
if (\$free_shipping == true) {
\$quotes_array[] = array('id' => 'free_free',
'name' => FREE_SHIPPING_TITLE,
'label' => FREE_SHIPPING_TITLE,
'cost' => '0',
'tax' => '0');
} else {
// get all available shipping quotes
\$quotes = \$shipping_modules->quote();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  foreach (\$quotes as \$quote) {
if (!isset(\$quote['error'])) {
foreach (\$quote['methods'] as \$rate) {
\$quotes_array[] = array('id' => \$quote['id'] . '_' . \$rate['id'],
'name' => \$quote['module'],
'label' => \$rate['title'],
'cost' => \$rate['cost'],
'tax' => isset(\$quote['tax']) ? \$quote['tax'] : '0');
}
}
}
}
}
} else {
\$quotes_array[] = array('id' => 'null',
'name' => 'No Shipping',
'label' => 'No Shipping',
'cost' => '0',
'tax' => '0');
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$params = array('METHOD' => 'CallbackResponse',
'OFFERINSURANCEOPTION' => 'false');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$counter = 0;
\$cheapest_rate = null;
\$cheapest_counter = \$counter;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    foreach (\$quotes_array as \$quote) {
\$shipping_rate = \$paypal_express->format_raw(\$quote['cost'] + tep_calculate_tax(\$quote['cost'], \$quote['tax']));[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$params['L_SHIPPINGOPTIONNAME' . \$counter] = \$quote['name'] . ' (' . \$quote['label'] . ')';
\$params['L_SHIPINGPOPTIONLABEL' . \$counter] = \$quote['name'] . ' (' . \$quote['label'] . ')';
\$params['L_SHIPPINGOPTIONAMOUNT' . \$counter] = \$paypal_express->format_raw(\$quote['cost']);
\$params['L_SHIPPINGOPTIONISDEFAULT' . \$counter] = 'false';
\$params['L_TAXAMT' . \$counter] = \$paypal_express->format_raw(\$order->info['tax'] + tep_calculate_tax(\$quote['cost'], \$quote['tax']));[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (is_null(\$cheapest_rate) || (\$shipping_rate < \$cheapest_rate)) {
\$cheapest_rate = \$shipping_rate;
\$cheapest_counter = \$counter;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$counter++;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$params['L_SHIPPINGOPTIONISDEFAULT' . \$cheapest_counter] = 'true';[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$post_string = '';[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    foreach (\$params as \$key => \$value) {
\$post_string .= \$key . '=' . urlencode(utf8_encode(trim(\$value))) . '&';
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$post_string = substr(\$post_string, 0, -1);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    echo \$post_string;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  exit;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  break;
case 'retrieve':
// if there is nothing in the customers cart, redirect them to the shopping cart page
if (\$cart->count_contents() < 1) {
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$response_array = \$paypal_express->getExpressCheckoutDetails(\$HTTP_GET_VARS['token']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if ((\$response_array['ACK'] == 'Success') || (\$response_array['ACK'] == 'SuccessWithWarning')) {
[color=#282828][font=helvetica, arial, sans-serif]// check if e-mail address exists in database and login or create customer account
if (!tep_session_is_registered('customer_id')) {
[color=#282828][font=helvetica, arial, sans-serif]		  \$email_address = tep_db_prepare_input(\$response_array['EMAIL']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$check_query = tep_db_query("select * from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input(\$email_address) . "' limit 1");
if (tep_db_num_rows(\$check_query)) {
\$check = tep_db_fetch_array(\$check_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    \$customer_id = \$check['customers_id'];
\$customers_firstname = \$check['customers_firstname'];
} else {
\$customers_firstname = tep_db_prepare_input(\$response_array['FIRSTNAME']);
\$customers_lastname = tep_db_prepare_input(\$response_array['LASTNAME']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    \$sql_data_array = array('customers_firstname' => \$customers_firstname,
'customers_lastname' => \$customers_lastname,
'customers_telephone' => '',
'customers_fax' => '',
[color=#282828][font=helvetica, arial, sans-serif]		    if (isset(\$response_array['PHONENUM']) && tep_not_null(\$response_array['PHONENUM'])) {
\$customers_telephone = tep_db_prepare_input(\$response_array['PHONENUM']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  \$sql_data_array['customers_telephone'] = \$customers_telephone;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    tep_db_perform(TABLE_CUSTOMERS, \$sql_data_array);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    \$customer_id = tep_db_insert_id();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int)\$customer_id . "', '0', now())");[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// build the message content
\$name = \$customers_firstname . ' ' . \$customers_lastname;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (SESSION_RECREATE == 'True') {
tep_session_recreate();
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$customer_first_name = \$customers_firstname;
tep_session_register('customer_id');
tep_session_register('customer_first_name');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// reset session token
\$sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// check if paypal shipping address exists in the address book
\$ship_firstname = tep_db_prepare_input(substr(\$response_array['SHIPTONAME'], 0, strpos(\$response_array['SHIPTONAME'], ' ')));
\$ship_lastname = tep_db_prepare_input(substr(\$response_array['SHIPTONAME'], strpos(\$response_array['SHIPTONAME'], ' ')+1));
\$ship_city = tep_db_prepare_input(\$response_array['SHIPTOCITY']);
\$ship_zone = tep_db_prepare_input(\$response_array['SHIPTOSTATE']);
\$ship_zone_id = 0;
\$ship_postcode = tep_db_prepare_input(\$response_array['SHIPTOZIP']);
\$ship_country = tep_db_prepare_input(\$response_array['SHIPTOCOUNTRYCODE']);
\$ship_country_id = 0;
[color=#282828][font=helvetica, arial, sans-serif]	    \$country_query = tep_db_query("select countries_id, address_format_id from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . tep_db_input(\$ship_country) . "' limit 1");
if (tep_db_num_rows(\$country_query)) {
\$country = tep_db_fetch_array(\$country_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$ship_country_id = \$country['countries_id'];
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$ship_country_id > 0) {
\$zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)\$ship_country_id . "' and (zone_name = '" . tep_db_input(\$ship_zone) . "' or zone_code = '" . tep_db_input(\$ship_zone) . "') limit 1");
if (tep_db_num_rows(\$zone_query)) {
\$zone = tep_db_fetch_array(\$zone_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    \$ship_zone_id = \$zone['zone_id'];
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$check_query = tep_db_query("select address_book_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)\$customer_id . "' and entry_firstname = '" . tep_db_input(\$ship_firstname) . "' and entry_lastname = '" . tep_db_input(\$ship_lastname) . "' and entry_street_address = '" . tep_db_input(\$ship_address) . "' and entry_postcode = '" . tep_db_input(\$ship_postcode) . "' and entry_city = '" . tep_db_input(\$ship_city) . "' and (entry_state = '" . tep_db_input(\$ship_zone) . "' or entry_zone_id = '" . (int)\$ship_zone_id . "') and entry_country_id = '" . (int)\$ship_country_id . "' limit 1");
if (tep_db_num_rows(\$check_query)) {
\$check = tep_db_fetch_array(\$check_query);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$sendto = \$check['address_book_id'];
} else {
\$sql_data_array = array('customers_id' => \$customer_id,
'entry_firstname' => \$ship_firstname,
'entry_lastname' => \$ship_lastname,
'entry_postcode' => \$ship_postcode,
'entry_city' => \$ship_city,
'entry_country_id' => \$ship_country_id);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (ACCOUNT_STATE == 'true') {
if (\$ship_zone_id > 0) {
\$sql_data_array['entry_zone_id'] = \$ship_zone_id;
\$sql_data_array['entry_state'] = '';
} else {
\$sql_data_array['entry_zone_id'] = '0';
\$sql_data_array['entry_state'] = \$ship_zone;
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$address_id = tep_db_insert_id();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$sendto = \$address_id;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (\$customer_default_address_id < 1) {
tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)\$address_id . "' where customers_id = '" . (int)\$customer_id . "'");
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$force_login == true) {
\$customer_country_id = \$ship_country_id;
\$customer_zone_id = \$ship_zone_id;
tep_session_register('customer_country_id');
tep_session_register('customer_zone_id');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$billto = \$sendto;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    include(DIR_WS_CLASSES . 'order.php');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$cart->get_content_type() != 'virtual') {
\$order = new order;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$total_weight = \$cart->show_weight();
\$total_count = \$cart->count_contents();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// load all enabled shipping modules
include(DIR_WS_CLASSES . 'shipping.php');
\$shipping_modules = new shipping;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$free_shipping = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
\$pass = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if (\$order->delivery['country_id'] == STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  case 'international':
if (\$order->delivery['country_id'] != STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  case 'both':
\$pass = true;
break;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    if ( (\$pass == true) && (\$order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
\$free_shipping = true;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  include(DIR_WS_LANGUAGES . \$language . '/modules/order_total/ot_shipping.php');
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
\$shipping = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if ( (tep_count_shipping_modules() > 0) || (\$free_shipping == true) ) {
if (\$free_shipping == true) {
\$shipping = 'free_free';
} else {
// get all available shipping quotes
\$quotes = \$shipping_modules->quote();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  \$shipping_set = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// if available, set the selected shipping rate from PayPals order review page
if (isset(\$response_array['SHIPPINGOPTIONNAME']) && isset(\$response_array['SHIPPINGOPTIONAMOUNT'])) {
foreach (\$quotes as \$quote) {
if (!isset(\$quote['error'])) {
foreach (\$quote['methods'] as \$rate) {
if (\$response_array['SHIPPINGOPTIONNAME'] == \$quote['module'] . ' (' . \$rate['title'] . ')') {
if (\$response_array['SHIPPINGOPTIONAMOUNT'] == \$paypal_express->format_raw(\$rate['cost'] + tep_calculate_tax(\$rate['cost'], \$quote['tax']))) {
\$shipping = \$quote['id'] . '_' . \$rate['id'];
\$shipping_set = true;
break 2;
}
}
}
}
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  if (\$shipping_set == false) {
// select cheapest shipping method
\$shipping = \$shipping_modules->cheapest();
\$shipping = \$shipping['id'];
} else {
if ( (isset(\$quote[0]['methods'][0]['title'])) && (isset(\$quote[0]['methods'][0][/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]['cost'])) ) {
\$shipping = array('id' => \$shipping,
'title' => ((\$free_shipping == true) ?  \$quote[0]['methods'][0][/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]['title'] : \$quote[0]['module'] . ' (' . \$quote[0]['methods'][0]['title'] . ')'),
'cost' => \$quote[0]['methods'][0]['cost']);
}
}
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if (strpos(\$shipping, '_')) {
list(\$module, \$method) = explode('_', \$shipping);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    if ( is_object(\$\$module) || (\$shipping == 'free_free') ) {
if (\$shipping == 'free_free') {
\$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
\$quote[0]['methods'][0]['cost'] = '0';
} else {
\$quote = \$shipping_modules->quote(\$method, \$module);
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			  if (isset(\$quote['error'])) {
tep_session_unregister('shipping');[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]			    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    } else {
if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
\$shipping = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  \$sendto = false;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (!tep_session_is_registered('payment')) tep_session_register('payment');
\$payment = \$paypal_express->code;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (!tep_session_is_registered('ppe_token')) tep_session_register('ppe_token');
\$ppe_token = \$response_array['TOKEN'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (!tep_session_is_registered('ppe_payerid')) tep_session_register('ppe_payerid');
\$ppe_payerid = \$response_array['PAYERID'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (!tep_session_is_registered('ppe_payerstatus')) tep_session_register('ppe_payerstatus');
\$ppe_payerstatus = \$response_array['PAYERSTATUS'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
} else {
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]    default:
// if there is nothing in the customers cart, redirect them to the shopping cart page
if (\$cart->count_contents() < 1) {
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if (MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_SERVER == 'Live') {
\$paypal_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout';
} else {
\$paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout';
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  include(DIR_WS_CLASSES . 'order.php');
\$order = new order;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$params = array('CURRENCYCODE' => \$order->info['currency']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// A billing address is required for digital orders so we use the shipping address PayPal provides
//	  if (\$order->content_type == 'virtual') {
//	    \$params['NOSHIPPING'] = '1';
//	  }[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$line_item_no = 0;
\$items_total = 0;
\$tax_total = 0;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  foreach (\$order->products as \$product) {
\$params['L_NAME' . \$line_item_no] = \$product['name'];
\$params['L_AMT' . \$line_item_no] = \$paypal_express->format_raw(\$product['final_price']);
\$params['L_NUMBER' . \$line_item_no] = \$product['id'];
\$params['L_QTY' . \$line_item_no] = \$product['qty'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$product_tax = tep_calculate_tax(\$product['final_price'], \$product['tax']);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$params['L_TAXAMT' . \$line_item_no] = \$paypal_express->format_raw(\$product_tax);
\$tax_total += \$paypal_express->format_raw(\$product_tax) * \$product['qty'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$items_total += \$paypal_express->format_raw(\$product['final_price']) * \$product['qty'];[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$line_item_no++;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$params['ITEMAMT'] = \$items_total;
\$params['TAXAMT'] = \$tax_total;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if (tep_not_null(\$order->delivery['firstname'])) {
\$params['SHIPTONAME'] = \$order->delivery['firstname'] . ' ' . \$order->delivery['lastname'];
\$params['SHIPTOCITY'] = \$order->delivery['city'];
\$params['SHIPTOSTATE'] = tep_get_zone_code(\$order->delivery['country']['id'], \$order->delivery['zone_id'], \$order->delivery['state']);
\$params['SHIPTOCOUNTRYCODE'] = \$order->delivery['country']['iso_code_2'];
\$params['SHIPTOZIP'] = \$order->delivery['postcode'];
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$quotes_array = array();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if (\$cart->get_content_type() != 'virtual') {
\$total_weight = \$cart->show_weight();
\$total_count = \$cart->count_contents();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// load all enabled shipping modules
include(DIR_WS_CLASSES . 'shipping.php');
\$shipping_modules = new shipping;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$free_shipping = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
\$pass = false;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if (\$order->delivery['country_id'] == STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    case 'international':
if (\$order->delivery['country_id'] != STORE_COUNTRY) {
\$pass = true;
}
break;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    case 'both':
\$pass = true;
break;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		  if ( (\$pass == true) && (\$order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
\$free_shipping = true;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    include(DIR_WS_LANGUAGES . \$language . '/modules/order_total/ot_shipping.php');
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if ( (tep_count_shipping_modules() > 0) || (\$free_shipping == true) ) {
if (\$free_shipping == true) {
\$quotes_array[] = array('id' => 'free_free',
'name' => FREE_SHIPPING_TITLE,
'label' => FREE_SHIPPING_TITLE,
'cost' => '0.00',
'tax' => '0');
} else {
// get all available shipping quotes
\$quotes = \$shipping_modules->quote();[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]		    foreach (\$quotes as \$quote) {
if (!isset(\$quote['error'])) {
foreach (\$quote['methods'] as \$rate) {
\$quotes_array[] = array('id' => \$quote['id'] . '_' . \$rate['id'],
'name' => \$quote['module'],
'label' => \$rate['title'],
'cost' => \$rate['cost'],
'tax' => \$quote['tax']);
}
}
}
}
}
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$counter = 0;
\$cheapest_rate = null;
\$expensive_rate = 0;
\$cheapest_counter = \$counter;
\$default_shipping = null;[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  foreach (\$quotes_array as \$quote) {
\$shipping_rate = \$paypal_express->format_raw(\$quote['cost'] + tep_calculate_tax(\$quote['cost'], \$quote['tax']));[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$params['L_SHIPPINGOPTIONNAME' . \$counter] = \$quote['name'] . ' (' . \$quote['label'] . ')';
\$params['L_SHIPINGPOPTIONLABEL' . \$counter] = \$quote['name'] . ' (' . \$quote['label'] . ')';
\$params['L_SHIPPINGOPTIONAMOUNT' . \$counter] = \$shipping_rate;
\$params['L_SHIPPINGOPTIONISDEFAULT' . \$counter] = 'false';[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (is_null(\$cheapest_rate) || (\$shipping_rate < \$cheapest_rate)) {
\$cheapest_rate = \$shipping_rate;
\$cheapest_counter = \$counter;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (\$shipping_rate > \$expensive_rate) {
\$expensive_rate = \$shipping_rate;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    if (tep_not_null(\$shipping) && (\$shipping['id'] == \$quote['id'])) {
\$default_shipping = \$counter;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$counter++;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if (!is_null(\$default_shipping)) {
\$cheapest_rate = \$params['L_SHIPPINGOPTIONAMOUNT' . \$default_shipping];
\$cheapest_counter = \$default_shipping;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if (!is_null(\$cheapest_rate)) {
if ( (MODULE_PAYMENT_PAYPAL_EXPRESS_INSTANT_UPDATE == 'True') && ((MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_SERVER != 'Live') || ((MODULE_PAYMENT_PAYPAL_EXPRESS_TRANSACTION_SERVER == 'Live') && (ENABLE_SSL == true))) ) { // Live server requires SSL to be enabled
\$params['CALLBACK'] = tep_href_link('ext/modules/payment/paypal/express.php', 'osC_Action=callbackSet', 'SSL', false, false);
\$params['CALLBACKTIMEOUT'] = '5';
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	    \$params['INSURANCEOPTIONSOFFERED'] = 'false';
\$params['L_SHIPPINGOPTIONISDEFAULT' . \$cheapest_counter] = 'true';
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]// don't recalculate currency values as they have already been calculated
\$params['SHIPPINGAMT'] = \$paypal_express->format_raw(\$cheapest_rate, '', 1);
\$params['AMT'] = \$paypal_express->format_raw(\$params['ITEMAMT'] + \$params['TAXAMT'] + \$params['SHIPPINGAMT'], '', 1);
\$params['MAXAMT'] = \$paypal_express->format_raw(\$params['AMT'] + \$expensive_rate + 100, '', 1); // safely pad higher for dynamic shipping rates (eg, USPS express)[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  \$response_array = \$paypal_express->setExpressCheckout(\$params);[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  if ((\$response_array['ACK'] == 'Success') || (\$response_array['ACK'] == 'SuccessWithWarning')) {
tep_redirect(\$paypal_url . '&token=' . \$response_array['TOKEN'] . '&useraction=commit');
} else {
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]	  break;
}[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL'));[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
```
##### Share on other sites

after i am redirected to shopping cart if i try to confirm again the order with paypal , i am getting this error after i am clicking on "Confirm Order "

"Fatal error: Cannot redeclare class shipping in /var/www/vhosts/ecig-vapo.com/httpdocs/includes/classes/shipping.php on line 13"