Codice: Seleziona tutto
if (tep_db_num_rows($attributes_query)) {
while ($attributes = tep_db_fetch_array($attributes_query)) {
$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
//begin PayPal_Shopping_Cart_IPN
'option_id' => $attributes['products_options_id'],
'value_id' => $attributes['products_options_values_id'],
//end PayPal_Shopping_Cart_IPN
'value' => $attributes['products_options_values'],
'prefix' => $attributes['price_prefix'],
'price' => $attributes['options_values_price']);
$subindex++;
}
}
$this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';
$index++;
}
}
function cart() {
global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment;
$this->content_type = $cart->get_content_type();
$customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id");
$customer_address = tep_db_fetch_array($customer_address_query);
$shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'");
$shipping_address = tep_db_fetch_array($shipping_address_query);
//PIVACF start
$billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_piva, ab.entry_cf, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'");
//PIVACF end
$billing_address = tep_db_fetch_array($billing_address_query);
$tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'");
$tax_address = tep_db_fetch_array($tax_address_query);
$this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
'currency' => $currency,
'currency_value' => $currencies->currencies[$currency]['value'],
'payment_method' => $payment,
'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),
'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),
'shipping_method' => $shipping['title'],
'shipping_cost' => $shipping['cost'],
'subtotal' => 0,
'tax' => 0,
'tax_groups' => array(),
'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : ''));
if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {
$this->info['payment_method'] = $GLOBALS[$payment]->title;
if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) {
$this->info['order_status'] = $GLOBALS[$payment]->order_status;
}
}
$this->customer = array('firstname' => $customer_address['customers_firstname'],
'lastname' => $customer_address['customers_lastname'],
'company' => $customer_address['entry_company'],
//PIVACF start
'piva' => $billing_address['entry_piva'],
//PIVACF end
'street_address' => $customer_address['entry_street_address'],
'suburb' => $customer_address['entry_suburb'],
'city' => $customer_address['entry_city'],
'postcode' => $customer_address['entry_postcode'],
'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']),
'zone_id' => $customer_address['entry_zone_id'],
'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']),
'format_id' => $customer_address['address_format_id'],
'telephone' => $customer_address['customers_telephone'],
'email_address' => $customer_address['customers_email_address']);
$this->delivery = array('firstname' => $shipping_address['entry_firstname'],
'lastname' => $shipping_address['entry_lastname'],
'company' => $shipping_address['entry_company'],
//PIVACF start
'piva' => $billing_address['entry_piva'],
'cf' => $billing_address['entry_cf'],
//PIVACF end
'street_address' => $shipping_address['entry_street_address'],
'suburb' => $shipping_address['entry_suburb'],
'city' => $shipping_address['entry_city'],
'postcode' => $shipping_address['entry_postcode'],
'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),
'zone_id' => $shipping_address['entry_zone_id'],
'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),
'country_id' => $shipping_address['entry_country_id'],
'format_id' => $shipping_address['address_format_id']);
$this->billing = array('firstname' => $billing_address['entry_firstname'],
'lastname' => $billing_address['entry_lastname'],
'company' => $billing_address['entry_company'],
//PIVACF start
'piva' => $billing_address['entry_piva'],
'cf' => $billing_address['entry_cf'],
//PIVACF end
'street_address' => $billing_address['entry_street_address'],
'suburb' => $billing_address['entry_suburb'],
'city' => $billing_address['entry_city'],
'postcode' => $billing_address['entry_postcode'],
'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']),
'zone_id' => $billing_address['entry_zone_id'],
'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']),
'country_id' => $billing_address['entry_country_id'],
'format_id' => $billing_address['address_format_id']);
$index = 0;
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$this->products[$index] = array('qty' => $products[$i]['quantity'],
'name' => $products[$i]['name'],
'model' => $products[$i]['model'],
'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']),
'price' => $products[$i]['price'],
'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
'weight' => $products[$i]['weight'],
'id' => $products[$i]['id']);
if ($products[$i]['attributes']) {
$subindex = 0;
reset($products[$i]['attributes']);
while (list($option, $value) = each($products[$i]['attributes'])) {
$attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
$attributes = tep_db_fetch_array($attributes_query);
$this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'],
'value' => $attributes['products_options_values_name'],
'option_id' => $option,
'value_id' => $value,
'prefix' => $attributes['price_prefix'],
'price' => $attributes['options_values_price']);
$subindex++;
}
}
$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
$this->info['subtotal'] += $shown_price;
$products_tax = $this->products[$index]['tax'];
$products_tax_description = $this->products[$index]['tax_description'];
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
if (isset($this->info['tax_groups']["$products_tax_description"])) {
$this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
} else {
$this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
}
} else {
$this->info['tax'] += ($products_tax / 100) * $shown_price;
if (isset($this->info['tax_groups']["$products_tax_description"])) {
$this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price;
} else {
$this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price;
}
}
$index++;
}
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
} else {
$this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
}
}
}
?>
e
Codice: Seleziona tutto
<?php
/*
$Id: checkout_process.inc.php,v 1.2 2005/03/13 22:00:34 devosc Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
DevosC, Developing open source Code
http://www.devosc.com
Copyright (c) 2003 osCommerce
Copyright (c) 2004 DevosC.com
Released under the GNU General Public License
*/
global $payment_modules, $shipping_modules, $order, $currencies, $cart, $PayPal_osC, $customer_id,
$sendto, $billto, $shipping, $payment, $language, $currency, $languages_id, $order_total_modules, $order_totals;
require_once(DIR_WS_INCLUDES . 'modules/payment/paypal/database_tables.inc.php');
if ( !class_exists('order_total') ) {
include_once(DIR_WS_CLASSES . 'order_total.php');
}
if ( !is_object($order_total_modules) )
$order_total_modules = new order_total;
if ( !is_array($order_totals) )
$order_totals = $order_total_modules->process();
$sql_data_array = array('customers_id' => $customer_id,
'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
'customers_company' => $order->customer['company'],
'customers_street_address' => $order->customer['street_address'],
'customers_suburb' => $order->customer['suburb'],
'customers_city' => $order->customer['city'],
'customers_postcode' => $order->customer['postcode'],
'customers_state' => $order->customer['state'],
'customers_country' => $order->customer['country']['title'],
'customers_telephone' => $order->customer['telephone'],
'customers_email_address' => $order->customer['email_address'],
'customers_address_format_id' => $order->customer['format_id'],
'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
'delivery_company' => $order->delivery['company'],
'delivery_street_address' => $order->delivery['street_address'],
'delivery_suburb' => $order->delivery['suburb'],
'delivery_city' => $order->delivery['city'],
'delivery_postcode' => $order->delivery['postcode'],
'delivery_state' => $order->delivery['state'],
'delivery_country' => $order->delivery['country']['title'],
'delivery_address_format_id' => $order->delivery['format_id'],
'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
'billing_company' => $order->billing['company'],
'billing_street_address' => $order->billing['street_address'],
'billing_suburb' => $order->billing['suburb'],
'billing_city' => $order->billing['city'],
'billing_postcode' => $order->billing['postcode'],
'billing_state' => $order->billing['state'],
'billing_country' => $order->billing['country']['title'],
'billing_address_format_id' => $order->billing['format_id'],
'payment_method' => $this->codeTitle,
'cc_type' => $order->info['cc_type'],
'cc_owner' => $order->info['cc_owner'],
'cc_number' => $order->info['cc_number'],
'cc_expires' => $order->info['cc_expires'],
'orders_status' => MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID,
'last_modified' => 'now()',
'currency' => $order->info['currency'],
'currency_value' => $order->info['currency_value']);
$session_exists = false;
if(tep_session_is_registered('PayPal_osC')) {
$orders_session_query = tep_db_query("select osi.orders_id, o.payment_id from " . TABLE_ORDERS_SESSION_INFO . " osi left join " . TABLE_ORDERS . " o on osi.orders_id = o.orders_id where osi.txn_signature ='" . tep_db_input($PayPal_osC->txn_signature) . "'");
$orders_check = tep_db_fetch_array($orders_session_query);
//Now check to see whether order session info exists AND that this order
//does not currently have an IPN.
if ($orders_check['orders_id'] > 0 && $orders_check['payment_id'] == '0' ) {
$session_exists = true;
$this->orders_id = $orders_check['orders_id'];
}
}
if($session_exists) {
tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', "orders_id = '" . (int)$this->orders_id . "'");
} else {
$sql_data_array['date_purchased'] = 'now()';
tep_db_perform(TABLE_ORDERS, $sql_data_array);
$this->orders_id = tep_db_insert_id();
}
if($session_exists) {
tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$this->orders_id . "'");
}
for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$sql_data_array = array('orders_id' => (int)$this->orders_id,
'title' => $order_totals[$i]['title'],
'text' => $order_totals[$i]['text'],
'value' => $order_totals[$i]['value'],
'class' => $order_totals[$i]['code'],
'sort_order' => $order_totals[$i]['sort_order']);
tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
}
$sql_data_array = array('orders_status_id' => MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID,
'date_added' => 'now()',
'customer_notified' => 0,
'comments' => $order->info['comments']);
if($session_exists) {
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array, 'update', "orders_id = '" . (int)$this->orders_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$this->orders_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$this->orders_id . "'");
} else {
$sql_data_array['orders_id'] = $this->orders_id;
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
}
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
$sql_data_array = array('orders_id' => (int)$this->orders_id,
'products_id' => tep_get_prid($order->products[$i]['id']),
'products_model' => $order->products[$i]['model'],
'products_name' => $order->products[$i]['name'],
'products_price' => $order->products[$i]['price'],
'final_price' => $order->products[$i]['final_price'],
'products_tax' => $order->products[$i]['tax'],
'products_quantity' => $order->products[$i]['qty']);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = tep_db_insert_id();
if(is_callable(array($order_total_modules, 'update_credit_account'))) {
global $insert_id;
$insert_id = $this->orders_id;
$order_total_modules->update_credit_account($i);//ICW ADDED FOR CREDIT CLASS SYSTEM
}
//------insert customer choosen option to order--------
$attributes_exist = '0';
if (isset($order->products[$i]['attributes'])) {
$attributes_exist = '1';
for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
if (DOWNLOAD_ENABLED == 'true') {
$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
on pa.products_attributes_id=pad.products_attributes_id
where pa.products_id = '" . $order->products[$i]['id'] . "'
and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
and pa.options_id = popt.products_options_id
and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
and pa.options_values_id = poval.products_options_values_id
and popt.language_id = '" . $languages_id . "'
and poval.language_id = '" . $languages_id . "'";
$attributes = tep_db_query($attributes_query);
} else {
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
}
$attributes_values = tep_db_fetch_array($attributes);
$sql_data_array = array('orders_id' => (int)$this->orders_id,
'orders_products_id' => $order_products_id,
'products_options_id' => $order->products[$i]['attributes'][$j]['option_id'],
'products_options' => $attributes_values['products_options_name'],
'products_options_values_id' => $order->products[$i]['attributes'][$j]['value_id'],
'products_options_values' => $attributes_values['products_options_values_name'],
'options_values_price' => $attributes_values['options_values_price'],
'price_prefix' => $attributes_values['price_prefix']);
tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
}
}
}
// store the session info for notification update - gsb
$sql_data_array = array('sendto' => $sendto,
'billto' => $billto,
'firstname' => $order->billing['firstname'],
'lastname' => $order->billing['lastname'],
'payment' => $payment,
'payment_title' => $this->codeTitle,
'payment_amount' => $this->grossPaymentAmount($this->currency()),
'payment_currency' => $this->currency(),
'payment_currency_val' => $currencies->get_value($this->currency()),
'language' => $language,
'language_id' => $languages_id,
'currency' => $currency,
'currency_value' => $currencies->get_value($currency),
'content_type' => $order->content_type,
'txn_signature' => $this->setTransactionID());
global $affiliate_ref, $affiliate_clickthroughs_id, $affiliate_clientdate, $affiliate_clientbrowser, $affiliate_clientip;
if (tep_session_is_registered('affiliate_ref') && tep_not_null($affiliate_ref)) {
$sql_data_array['affiliate_id'] = $affiliate_ref;
$sql_data_array['affiliate_clickthroughs_id'] = $affiliate_clickthroughs_id;
$sql_data_array['affiliate_date'] = $affiliate_clientdate;
$sql_data_array['affiliate_browser'] = $affiliate_clientbrowser;
$sql_data_array['affiliate_ipaddress'] = $affiliate_clientip;
}
if($session_exists) {
tep_db_perform(TABLE_ORDERS_SESSION_INFO, $sql_data_array, 'update', "orders_id = '" . (int)$this->orders_id . "'");
$PayPal_osC->txn_signature = $this->digest;
} else {
$sql_data_array['orders_id'] = (int)$this->orders_id;
tep_db_perform(TABLE_ORDERS_SESSION_INFO, $sql_data_array);
$PayPal_osC = new PayPal_osC($this->orders_id,$this->digest);
tep_session_register('PayPal_osC');
}
if(is_callable(array($order_total_modules, 'apply_credit')))
$order_total_modules->apply_credit();
require(DIR_WS_INCLUDES . 'modules/payment/paypal/catalog/checkout_splash.inc.php');
?>
Credo di aver capito il problema.
Và inserita la voce che richiama billing_piva subito dopo:
Codice: Seleziona tutto
$sql_data_array = array('customers_id' => $customer_id,
Giusto?
Non ho ancora provato, ma se così fosse avrei la conferma che funziona solo al prossimo ordine registrato con paypal, quelli già registrati non verrebbero aggiornati o sbaglio?
Grazie