예제 #1
0
function xmlrpc_GetCustomer($xmlrpcmsg)
{
    ob_start('ob_file_callback');
    /*x*/
    if ($xmlrpcmsg->getNumParams() == 3) {
        /*x*/
        $rtn = new xmlrpcresp(php_xmlrpc_encode(GetCustomer($xmlrpcmsg->getParam(0)->scalarval(), $xmlrpcmsg->getParam(1)->scalarval(), $xmlrpcmsg->getParam(2)->scalarval())));
        /*x*/
    } else {
        /*e*/
        $rtn = new xmlrpcresp(php_xmlrpc_encode(GetCustomer($xmlrpcmsg->getParam(0)->scalarval(), '', '')));
        /*x*/
    }
    ob_end_flush();
    return $rtn;
}
예제 #2
0
파일: orders.php 프로젝트: hungnv0789/vhtm
/**
 *	Send an email notification to a customer when the status of their order changes.
 *
 * @param int The ID of the order to email the invoice for.
 * @return boolean True if successful.
 */
function EmailOnStatusChange($orderId, $status)
{
	// Load the order
	$order = GetOrder($orderId);
	if (!$order) {
		return false;
	}

	// Load the customer we'll be contacting
	if ($order['ordcustid'] > 0) {
		$customer = GetCustomer($order['ordcustid']);
		$GLOBALS['ViewOrderStatusLink'] = '<a href="'.$GLOBALS['ShopPathSSL'].'/orderstatus.php">'.GetLang('ViewOrderStatus').'</a>';
	} else {
		$customer['custconemail'] = $order['ordbillemail'];
		$customer['custconfirstname'] = $order['ordbillfirstname'];
		$GLOBALS['ViewOrderStatusLink'] = '';
	}

	if (empty($customer['custconemail'])) {
		return;
	}

	// All prices in the emailed invoices will be shown in the default currency of the store
	$defaultCurrency = GetDefaultCurrency();

	$statusName = GetOrderStatusById($status);
	$GLOBALS['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname']));
	$GLOBALS['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName);
	$GLOBALS['OrderTotal'] = FormatPrice($order['total_inc_tax'], false, true, false, $defaultCurrency, true);
	$GLOBALS['DatePlaced'] = CDate($order['orddate']);

	if ($order['orderpaymentmethod'] === 'giftcertificate') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate');
	}
	else if ($order['orderpaymentmethod'] === 'storecredit') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit');
	}
	else {
		$GLOBALS['PaymentMethod'] = $order['orderpaymentmethod'];
	}

	$query = "
		SELECT COUNT(*)
		FROM [|PREFIX|]order_products
		WHERE ordprodtype='digital'
		AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
	";

	$numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);

	$emailTemplate = FetchEmailTemplateParser();

	$GLOBALS['SNIPPETS']['CartItems'] = "";

	if (OrderIsComplete($status) && $numDigitalProducts > 0) {
		$query = "
			SELECT *
			FROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)
			WHERE ordprodtype='digital'
			AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$GLOBALS['ProductOptions'] = '';
			$GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
			$GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);

			$GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
			$DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']);
			$GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'].'/account.php?action=download_item&amp;data='.$DownloadItemEncrypted;

			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem");
		}
	}

	$GLOBALS['SNIPPETS']['OrderTrackingLink'] = "";

	$shipments = $GLOBALS['ISC_CLASS_DB']->Query("
		SELECT shipmentid, shipdate, shiptrackno, shipping_module, shipmethod, shipcomments
		FROM [|PREFIX|]shipments
		WHERE shiporderid = " . (int)$orderId . "
		ORDER BY shipdate, shipmentid
	");

	$GLOBALS['TrackingLinkList'] = '';

	while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($shipments)) {
		if (!$shipment['shiptrackno']) {
			continue;
		}

		GetModuleById('shipping', /** @var ISC_SHIPPING */$module, $shipment['shipping_module']);

		if ($module) {
			$link = $module->GetTrackingLink($shipment['shiptrackno']);
			if ($link) {
				$link = '<a href="' . isc_html_escape($link) . '" target="_blank">' . $shipment['shiptrackno'] . '</a>';
			} else {
				$link = $shipment['shiptrackno'];
			}
		} else {
			$link = $shipment['shiptrackno'];
		}

		if($shipment['shipmethod']) {
			$link .= ' (' . $shipment['shipmethod'] . ')';
		}

		if ($link) {
			$GLOBALS['TrackingLinkList'] .= '<li>' . $link . '</li>';
		}
	}

	if (empty($GLOBALS['TrackingLinkList'])) {
		$GLOBALS['TrackingLinkList'] = GetLang('NoTrackingNumbersYet');
	} else {
		$GLOBALS['TrackingLinkList'] = '<ul>' . $GLOBALS['TrackingLinkList'] . '</ul>';
	}

	// Set up tracking numbers for orders. Whilst we don't have tracking numbers
	// on orders any longer, this code is being kept for legacy reasons where
	// orders may already have a tracking number saved. To be removed in a future
	// version.
	if (!empty($order['ordtrackingno'])) {
		$GLOBALS['HideTrackingText'] = "";
		$GLOBALS['OrderTrackingNo'] = isc_html_escape($order['ordtrackingno']);

		// Let's instantiate an object for the shipper
		$shipper_object = false;
		if ($order['ordershipmodule'] != "" && GetModuleById('shipping', $shipper_object, $order['ordershipmodule'])) {
			// Does it have a link to track the order?
			if ($shipper_object->GetTrackingLink() != "") {
				// Show the tracking link
				$GLOBALS['TrackURL'] = $shipper_object->GetTrackingLink($order['ordtrackingno']);
				$GLOBALS['SNIPPETS']['OrderTrackingLink'] = $emailTemplate->GetSnippet("OrderTrackingLink");
			}
		}
	}

	if (empty($GLOBALS['SNIPPETS']['CartItems'])) {
		$emailTemplate->SetTemplate("order_status_email");
	} else {
		$emailTemplate->SetTemplate("order_status_downloads_email");
	}
	$message = $emailTemplate->ParseTemplate(true);

	// Create a new email API object to send the email
	$store_name = GetConfig('StoreName');
	$subject = GetLang('OrderStatusChangedSubject');

	require_once(ISC_BASE_PATH . "/lib/email.php");
	$obj_email = GetEmailClass();
	$obj_email->Set('CharSet', GetConfig('CharacterSet'));
	$obj_email->From(GetConfig('OrderEmail'), $store_name);
	$obj_email->Set('Subject', $subject);
	$obj_email->AddBody("html", $message);
	$obj_email->AddRecipient($customer['custconemail'], '', "h");
	$email_result = $obj_email->Send();

	if ($email_result['success']) {
		return true;
	}
	else {
		return false;
	}
}
예제 #3
0
	private function IssueReturnCredit()
	{
		if(!GetConfig('ReturnCredits')) {
			$this->ManageReturns(GetLang('Unauthorized'), MSG_ERROR);
		}

		// Fetch the return
		$query = "
			SELECT r.*, o.ordcurrencyid, o.ordcurrencyexchangerate
			FROM [|PREFIX|]returns r
			LEFT JOIN [|PREFIX|]orders o ON (r.retorderid=o.orderid)
			WHERE r.returnid='".(int)$_REQUEST['returnId']."'
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		$return = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

		if(!$return['returnid']) {
			$this->ManageReturns(GetLang('InvalidReturn'), MSG_ERROR);
			return;
		}

		// Grab the order if it still exists to provide a refund on the tax as well
		$order = GetOrder($return['retorderid'], null, null, true);
		if (!$order) {
			return false;
		}

		// Does the current user have permission to view this return?
		if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
			FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewReturns');
		}

		if($return['retreceivedcredit']) {
			$this->ManageReturns(GetLang('InvalidReturn'), MSG_ERROR);
			return;
		}

		// If the review status is not already "Refunded", then we need to also process the refund.
		if($return['retstatus'] != 5) {
			if(!$this->UpdateReturnStatus($return, 5, true)) {
				$this->ManageReturns(GetLang('FailedToUpdateReturn'), MSG_ERROR);
				return;
			}
		}

		$GLOBALS['ISC_CLASS_DB']->Query("START TRANSACTION");

		$additionalCredit = $return['retprodcost']*$return['retprodqty'];

		// Issue credit to the customer
		$customer = GetCustomer($return['retcustomerid']);
		$updatedCustomer = array(
			"custstorecredit" => $customer['custstorecredit'] + $additionalCredit
		);
		$GLOBALS['ISC_CLASS_DB']->UpdateQuery("customers", $updatedCustomer, "customerid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['retcustomerid'])."'");

		// Log the credit in to the database
		$creditLog = array(
			"customerid" => $return['retcustomerid'],
			"creditamount" => $additionalCredit,
			"credittype" => "return",
			"creditdate" => time(),
			"creditrefid" => $return['returnid'],
			"credituserid" => $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUserId(),
			"creditreason" => $return['retreason']
		);
		$GLOBALS['ISC_CLASS_DB']->InsertQuery("customer_credits", $creditLog);

		// Update the return to mark it as credit received
		$updatedReturn = array(
			"retreceivedcredit" => 1
		);
		$GLOBALS['ISC_CLASS_DB']->UpdateQuery("returns", $updatedReturn, "returnid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['returnid'])."'");

		// Fetch the customers name
		$query = sprintf("SELECT CONCAT(custconfirstname, ' ', custconlastname) FROM [|PREFIX|]customers WHERE customerid='%d'", $return['retcustomerid']);
		$custName = $GLOBALS['ISC_CLASS_DB']->FetchOne($GLOBALS['ISC_CLASS_DB']->Query($query));

		if($GLOBALS['ISC_CLASS_DB']->GetErrorMsg() == "") {
			$GLOBALS['ISC_CLASS_DB']->Query("COMMIT");
			$GLOBALS['ISC_LANG']['ReturnCreditIssued'] = sprintf(GetLang('ReturnCreditIssued'), $custName, FormatPrice($additionalCredit));
			$this->ManageReturns(GetLang('ReturnCreditIssued'), MSG_SUCCESS);
		}
		else {
			$GLOBALS['ISC_LANG']['FailedIssueReturnCredit'] = sprintf(GetLang('FailedIssueReturnCredit'), $custName, FormatPrice($additionalCredit));
			$this->ManageReturns(GetLang('FailedIssueReturnCredit'), MSG_ERROR);
		}
	}
예제 #4
0
function xmlrpc_GetCustomer($xmlrpcmsg)
{
    return new xmlrpcresp(php_xmlrpc_encode(GetCustomer($xmlrpcmsg->getParam(0)->scalarval(), $xmlrpcmsg->getParam(1)->scalarval(), $xmlrpcmsg->getParam(2)->scalarval())));
}
예제 #5
0
/**
 *	Send an email notification to a customer when the status of their order changes.
 *
 * @param int The ID of the order to email the invoice for.
 * @return boolean True if successful.
 */
function EmailOnStatusChange($orderId, $status)
{
    // Load the order
    $order = GetOrder($orderId);
    // Load the customer we'll be contacting
    if ($order['ordcustid'] > 0) {
        $customer = GetCustomer($order['ordcustid']);
        $GLOBALS['ViewOrderStatusLink'] = '<a href="' . $GLOBALS['ShopPathSSL'] . '/orderstatus.php">' . GetLang('ViewOrderStatus') . '</a>';
    } else {
        $customer['custconemail'] = $order['ordbillemail'];
        $customer['custconfirstname'] = $order['ordbillfirstname'];
        $GLOBALS['ViewOrderStatusLink'] = '';
    }
    if (empty($customer['custconemail'])) {
        return;
    }
    // All prices in the emailed invoices will be shown in the default currency of the store
    $defaultCurrency = GetDefaultCurrency();
    $statusName = GetOrderStatusById($status);
    $GLOBALS['ISC_LANG']['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname']));
    $GLOBALS['ISC_LANG']['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName);
    $GLOBALS['OrderTotal'] = FormatPrice($order['ordtotalamount'], false, true, false, $defaultCurrency, true);
    $GLOBALS['DatePlaced'] = CDate($order['orddate']);
    if ($order['orderpaymentmethod'] === 'giftcertificate') {
        $GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate');
    } else {
        if ($order['orderpaymentmethod'] === 'storecredit') {
            $GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit');
        } else {
            $GLOBALS['PaymentMethod'] = $order['orderpaymentmethod'];
        }
    }
    $query = "\n\t\tSELECT COUNT(*)\n\t\tFROM [|PREFIX|]order_products\n\t\tWHERE ordprodtype='digital'\n\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t";
    $numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
    $emailTemplate = FetchEmailTemplateParser();
    $GLOBALS['SNIPPETS']['CartItems'] = "";
    if (OrderIsComplete($status) && $numDigitalProducts > 0) {
        $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)\n\t\t\tWHERE ordprodtype='digital'\n\t\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t\t";
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
        while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
            $GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);
            $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
            $DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']);
            $GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'] . '/account.php?action=download_item&amp;data=' . $DownloadItemEncrypted;
            $GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem");
        }
    }
    if (empty($GLOBALS['SNIPPETS']['CartItems'])) {
        $emailTemplate->SetTemplate("order_status_email");
    } else {
        $emailTemplate->SetTemplate("order_status_downloads_email");
    }
    $message = $emailTemplate->ParseTemplate(true);
    // Create a new email API object to send the email
    $store_name = GetConfig('StoreName');
    $subject = GetLang('OrderStatusChangedSubject');
    require_once ISC_BASE_PATH . "/lib/email.php";
    $obj_email = GetEmailClass();
    $obj_email->Set('CharSet', GetConfig('CharacterSet'));
    $obj_email->From(GetConfig('OrderEmail'), $store_name);
    $obj_email->Set('Subject', $subject);
    $obj_email->AddBody("html", $message);
    $obj_email->AddRecipient($customer['custconemail'], '', "h");
    $email_result = $obj_email->Send();
    if ($email_result['success']) {
        return true;
    } else {
        return false;
    }
}
예제 #6
0
	private function getOrderData($orderRow, $addressIndex)
	{
		// Get the customer data
		if ($orderRow['ordcustid'] == 0){
			$customerData = array(
				'CustomerID' 	=> -1,
				'Phone' 		=> $orderRow['ordbillphone'],
				'Email'			=> $orderRow['ordbillemail']
			);
		}
		else {
			$customer = GetCustomer($orderRow['ordcustid']);
			$customerData = array(
				'CustomerID'	=> $orderRow['ordcustid'],
				'Phone'			=> $customer['custconphone'],
				'Email'			=> $customer['custconemail']
			);
		}

		$orderId = $orderRow['orderid'];

		if ($orderRow['shipping_address_count'] > 1) {
			$orderId .= '-' . $addressIndex;
		}

		$data = array(
			'OrderNumber' 		=> $orderId,
			'OrderDate' 		=> gmdate('Y-m-d H:i:s', $orderRow['orddate']),
			'LastModified' 		=> gmdate('Y-m-d H:i:s', $orderRow['ordlastmodified']),
			'LastModifiedLocal'	=> isc_date('Y-m-d H:i:s', $orderRow['ordlastmodified']),
			'ShippingMethod'	=> $orderRow['method'],
			'StatusCode'		=> $orderRow['ordstatus'],

			'CustomerComment'	=> $orderRow['ordcustmessage'],
			'Customer'			=> $customerData,

			'ShipAddress'		=> array(
									'Name'		=> $orderRow['first_name'] . ' ' . $orderRow['last_name'],
									'Company'	=> $orderRow['company'],
									'Street1'	=> $orderRow['address_1'],
									'Street2'	=> $orderRow['address_2'],
									'Street3'	=> '',
									'City'		=> $orderRow['city'],
									'PostalCode'=> $orderRow['zip'],
									'State'		=> $orderRow['state'],
									'Country'	=> $orderRow['country_iso2']
								),

			'BillAddress'		=> array(
									'Name'		=> $orderRow['ordbillfirstname'] . ' ' . $orderRow['ordbilllastname'],
									'Company'	=> $orderRow['ordbillcompany'],
									'Street1'	=> $orderRow['ordbillstreet1'],
									'Street2'	=> $orderRow['ordbillstreet2'],
									'Street3'	=> '',
									'City'		=> $orderRow['ordbillsuburb'],
									'PostalCode'=> $orderRow['ordbillzip'],
									'State'		=> $orderRow['ordbillstate'],
									'Country'	=> $orderRow['ordbillcountrycode']
								),

			'Payment'			=> array(
									'Method' => $orderRow['orderpaymentmethod'],
								),
		);


		$incTaxPrices = false;
		if (GetConfig('taxDefaultTaxDisplayOrders') != TAX_PRICES_DISPLAY_EXCLUSIVE) {
			$incTaxPrices = true;
		}

		// get the products for the order
		$items = array();
		$totalWrapCost = 0;

		$query = '
			SELECT
				op.*,
				pi.*
			FROM
				[|PREFIX|]order_products op
				LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageprodid = op.ordprodid AND pi.imageisthumb = 1)
			WHERE
				op.order_address_id = ' . $orderRow['address_id'];

		$res = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($productRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) {
			$item = array(
				'ItemID'	=> $productRow['orderprodid'],
				'ProductID'	=> $productRow['ordprodid'],
				'Code'		=> $productRow['ordprodsku'],
				'Name'		=> $productRow['ordprodname'],
				'Quantity'	=> $productRow['ordprodqty'],
				'Weight'	=> ConvertWeight($productRow['ordprodweight'], 'lbs'),
			);

			if ($incTaxPrices) {
				$item['UnitPrice'] = $productRow['price_inc_tax'];
				$totalWrapCost += $productRow['wrapping_cost_inc_tax'] * $productRow['ordprodqty'];
			}
			else {
				$item['UnitPrice'] = $productRow['price_ex_tax'];
				$totalWrapCost += $productRow['wrapping_cost_ex_tax'] * $productRow['ordprodqty'];
			}

			try {
				$image = new ISC_PRODUCT_IMAGE();
				$image->populateFromDatabaseRow($productRow);
				$item['Image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true);
			}
			catch (Exception $ex) {
			}

			$items['Item'][] = $item;
		}

		$data['Items'] = $items;

		// get the totals
		$totals = array();
		$totalID = 1;

		// gift wrapping cost
		if ($totalWrapCost > 0) {
			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> GetLang('ShipWorksGiftWrapping'),
				'Text'		=> FormatPrice($totalWrapCost),
				'Value'		=> $totalWrapCost,
				'Class'		=> 'Adjust'
			);

			$totals['Total'][] = $total;
		}

		// shipping cost
		if ($orderRow['shipping_cost_ex_tax'] > 0) {
			if ($incTaxPrices) {
				$shippingCost = $orderRow['shipping_cost_inc_tax'];
			}
			else {
				$shippingCost = $orderRow['shipping_cost_ex_tax'];
			}

			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> GetLang('ShipWorksShipping'),
				'Text'		=> FormatPrice($shippingCost),
				'Value'		=> $shippingCost,
				'Class'		=> 'Shipping'
			);

			$totals['Total'][] = $total;
		}

		// handling cost
		if ($orderRow['handling_cost_ex_tax'] > 0) {
			if ($incTaxPrices) {
				$handlingCost = $orderRow['handling_cost_inc_tax'];
			}
			else {
				$handlingCost = $orderRow['handling_cost_ex_tax'];
			}

			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> GetLang('ShipWorksHandling'),
				'Text'		=> FormatPrice($handlingCost),
				'Value'		=> $handlingCost,
				'Class'		=> 'Shipping'
			);

			$totals['Total'][] = $total;
		}

		// tax (not included in total)
		if ($orderRow['total_tax'] > 0 && !$incTaxPrices) {
			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> 'Tax',
				'Text'		=> FormatPrice($orderRow['total_tax']),
				'Value'		=> $orderRow['total_tax'],
				'Class'		=> 'Tax'
			);

			$totals['Total'][] = $total;
		}

		// total
		if ($incTaxPrices) {
			$orderTotal = $orderRow['total_inc_tax'];
		}
		else {
			$orderTotal = $orderRow['total_ex_tax'];
		}

		$total = array(
			'TotalID' 	=> $totalID++,
			'Name'		=> GetLang('ShipWorksTotal'),
			'Text'		=> FormatPrice($orderTotal),
			'Value'		=> $orderTotal,
			'Class'		=> 'ot_total'
		);

		$totals['Total'][] = $total;

		// gift certificates
		if ($orderRow['ordgiftcertificateamount'] > 0) {
			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> GetLang('ShipWorksGiftCertificates'),
				'Text'		=> FormatPrice($orderRow['ordgiftcertificateamount']),
				'Value'		=> $orderRow['ordgiftcertificateamount'] * -1,
				'Class'		=> 'Adjust'
			);

			$totals['Total'][] = $total;
		}

		// other discount amount
		if ($orderRow['orddiscountamount'] > 0) {
			$total = array(
				'TotalID' 	=> $totalID++,
				'Name'		=> GetLang('ShipWorksDiscounts'),
				'Text'		=> FormatPrice($orderRow['orddiscountamount']),
				'Value'		=> $orderRow['orddiscountamount'] * -1,
				'Class'		=> 'Adjust'
			);

			$totals['Total'][] = $total;
		}

		$data['Totals'] = $totals;

		return $data;
	}