Jump to content


Corporate Sponsors


Latest News: (loading..)

Passing Discount Amount to Paypal


  • You cannot reply to this topic
1 reply to this topic

#1 jerseyboy

  • Community Member
  • 7 posts
  • Real Name:John Ewin

Posted 09 February 2012, 21:32

I've added the following code to paypal_standard.php to pass the discount amount created by the Quantity Discount add_on.


if (MODULE_ORDER_TOTAL_INSTALLED) {

$discount_query = tep_db_query('select value from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int)$order_id . '" and class = "ot_quantity_discount" ');
$discount_var = tep_db_fetch_array($discount_query);
$parameters['discount_amount_cart'] = $discount_var['value'];

}

However, no discount line appears in paypal.
When I just force a value such as

if (MODULE_ORDER_TOTAL_INSTALLED) {

$parameters['discount_amount_cart'] = 5.40;

}

it works

The query returns a single row. Is there a problem with how the decimal value is being assigned?

Any help would be greatly appreciated. Thanks.

#2 jerseyboy

  • Community Member
  • 7 posts
  • Real Name:John Ewin

Posted 13 February 2012, 02:02

Is there a problem with the tax_cart field that is passed to Paypal? Does this have to be formatted a certain way?
I made the changes in bold to payment_standard.php. This is driving me crazy!!!!! Please help anyone.

function process_button() {
global $customer_id, $order, $sendto, $currency, $cart_PayPal_Standard_ID, $shipping,
$discount; // Discount Code
$customer_query1 = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = $customer_id order by orders_id desc");
$orders_query = tep_db_fetch_array($customer_query1);
$orders_id = $orders_query['orders_id'];

if (MODULE_ORDER_TOTAL_INSTALLED) {

$discount_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = $orders_id and class = 'ot_quantity_discount'");
if (tep_db_num_rows($discount_query) > 0) {
$discount_tot = tep_db_fetch_array($discount_query);
$final_discount = $discount_tot['value'];
}

$tax_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = $orders_id and class = 'ot_tax'");
if (tep_db_num_rows($tax_query) > 0) {
$discounted_tax = tep_db_fetch_array($tax_query);
$finaltax = $discounted_tax['value'];

}
}
$process_button_string = '';
$parameters = array('cmd' => '_cart',
'upload' => '1',
'business' => MODULE_PAYMENT_PAYPAL_STANDARD_ID,
'currency_code' => $currency,
'invoice' => substr($cart_PAYPAL_Standard_ID, strpos($cart_PAYPAL_Standard_ID, '-')+1),
'custom' => $customer_id,
'no_note' => '1',
'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false),
'return' => tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'),
'cancel_return' => tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'),
'bn' => 'osCommerce22_Default_ST',
'discount_amount_cart' => $final_discount,
'tax_cart' => $finaltax,

'paymentaction' => ((MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD == 'Sale') ? 'sale' : 'authorization'));

[