osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

3 Pages V   1 2 3 >  
Reply to this topicStart new topic
> CMCIC Cybermut P@iement 3.0, Récupération des variables de session
ThomasB
posté 30 Jun 2010, 10:38
Message #1


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 6
Inscrit : 30-June 10
Membre no 27751



Bonjour à tous,

Mon problème :
Le package d'origine "CMCIC Cybermut P@iement 3.0" ne semble pas permettre la récupération des variables placées dans la table SESSION de OSCOMMERCE, que ce soit celles liées à "$language", "$order", "order_total", etc.
Les mails de confirmation ne sont pas envoyé au client.

Ma démarche
J'ai installé le pack "CMCIC Cybermut P@iement 3.0" sur ma version de OSCOMMERCE (v2.2 RC1), rentré les variables qui m'ont été fournies par ma banque (CLE, TPE et autres). Pour information, après avoir parcouru les forums, j'utilise bien la version "cmcic_response_rc1.php" (et non "cmcic_response.php").

Résultats
Le dialogue avec la banque fonctionne correctement, ma transaction est enregistrée. Pour autant, toutes les informations liée à la commande coté OSCOMMERCE ne s'enregistrent absolument pas, dans aucune des tables !

Solution temporaire
J'ai donc été contraint de modifier le fichier "cmcic_response_rc1.php" en y ajoutant des variables pour récupérer les valeurs en session :
- $customer_id = $_SESSION['customer_id'];
- $cart = $_SESSION['cart'];
- $language = $_SESSION['language'];
- ...
Pour autant, je n'arrive pas a récupérer toutes les informations de cette façon.

Je trouve ce fonctionnement vraiment bancale, obliger de créer un patch sur une solution éprouvée.
De doute évidence je pas utiliser la bonne méthode.

Si quelqu'un a déjà rencontré ce problème ou bien pense avoir une solution, alors je serai ravis d'en discuter.
Merci d'avance à tous ceux qui on prit de leur temps pour lire ce post.

Thomas
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 11:20
Message #2


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Bonjour,

Le problème je l'ai rencontré aussi.
De la contribution, je n'ai garder que la phase aller.

Pour le retour j'ai reecrit un fichier sur la base de mon checkout process en y incluant mon application top modifier afin de pouvoir recuperer la session qui est en texte libre.
Le fichier doit etre enregistrer sous le nom xyz-cmici.php et declarer comme fichier de retour directement au support technique.


a inclure dans l'application_top que l'on met en debut de fichier
// ********************************************************************************
************************************
// recuperation de l'id de session contenu dans texte-libre
tep_session_id($CMCIC_bruteVars['texte-libre']);
// ********************************************************************************
************************************

Puis reprendre leur fichier retour que l'on met à la fin

nilegoff


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
ThomasB
posté 30 Jun 2010, 13:16
Message #3


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 6
Inscrit : 30-June 10
Membre no 27751



Merci pour ta réponse nilegoff.

Avant de modifier ma façon de procéder, je voudrais être certain d'un point important.
J'utilise déjà la récupération de l'ID session ( tep_session_id($CMCIC_bruteVars['texte-libre']); ) dans mon fichier "cmcic_response_rc1.php", que j'ai ensuite renommé pour qu'il soit appelé par la banque (lors du retour). Pour autant cela ne me permet pas de faire remonter automatiquement les variable de cession, c'est pourquoi je dois les inscrire à la main ( ex. $cart = $_SESSION['cart']; ).

Est-ce que le fait d'utiliser le fichier "application_top.php" d'origine résout ce problème ? Si oui, pourquoi ??
ou bien est-ce le fait de mettre la récupération de l'ID session en début de fichier ?

D'autre part, puisque tu as l'air d'avoir bien fait le tour de la question, comment cela se fait-il que l'on doive utiliser 2 modules pour remplir les fonctions de connexion bancaire et validation de commande ?

- "Liaison-SSL" pour la récupération du moyen de paiement et la connexion bancaire depuis OSCOMMERCE.
- "CyberMut P@iement" pour la validation de la transaction bancaire (provenant de la banque) et l'insertion des variables de commande dans les tables OSCOMMERCE.

Merci encore pour ta participation !
Thomas

Ce message a été modifié par ThomasB - 30 Jun 2010, 13:17.
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 13:23
Message #4


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Personnellement, je n'utilise pas de liaison SSL entre mon site et la banque (utilité?); la liaison ssl est utile seulement au moment de la communication des infos bancaires, c'est à dire directement sur le site du CIC ou du CM.

Pour recuperer les infos commandes, il suffit de rappeler toutes les infos juste apres l'application_top avec
Code
// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

  if (!tep_session_is_registered('sendto')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  }

  if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

  include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

// load selected payment module
// require(DIR_WS_CLASSES . 'payment.php');
//  $payment_modules = new payment($payment);

// load the selected shipping module
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping($shipping);

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

  require(DIR_WS_CLASSES . 'order_total.php');
  $order_total_modules = new order_total;

  $order_totals = $order_total_modules->process();


nilegoff

Ce message a été modifié par nilegoff - 30 Jun 2010, 13:24.


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
ThomasB
posté 30 Jun 2010, 13:51
Message #5


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 6
Inscrit : 30-June 10
Membre no 27751



Ok, je comprends effectivement qu'il n'est pas nécessaire d'utiliser le module "liaison SSL" pour me connecter à la banque. Le module utile reste donc "CMCIC Cybermut P@iement 3.0" qui permet de valider la transaction avec la banque puis de valider la commande et d'insérer les information dans les tables OSC.

Pour ce qui est de la récupération des informations, je me suis apparemment mal expliqué sur la gestion du fichier réponse (cmcic_response_rc1.php).
Tous les morceaux de code dont tu fais mention sont bien inclus dans le fichier que j'utilise. Tout y est, les "require", les contrôle de session, la récupération de l'ID session, les commandes d'insertion en base, etc.

Le problème est que les variables déclarées dans ce fichier et prévues pour être insérer dans les tables sont vides. La récupération de l'ID session ( tep_session_id($CMCIC_bruteVars['texte-libre']); ) ne permet pas d'en récupérer la valeur.

Exemple pour ORDER : $sql_data_array = array('customers_id' => $customer_id, 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'] ...

Exemple pour ORDER TOTAL : $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'] ...


$customer_id, $order->customer['firstname'], ..., $order_totals[$i]['title'] ... sont vides.

Il me faut déclarer ces variables à la main dans le code :
- $customer_id = $_SESSION['customer_id'];
- $cart = $_SESSION['cart'];
- $language = $_SESSION['language'];
- ...

Je ne sais pas comment faire pour quelles remontent directement, c'est vraiment étrange que le module en question ne prévoit pas cela automatiquement.

J'espère avoir été clair cette fois-ci, merci encore pour ton temps. Si jamais je peux te contacter directement pour éviter de t'en faire perdre plus, je serai ravis de le faire.

Thomas
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 14:28
Message #6


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Essaye mon fichier directement: (Partie I car je ne peux tout envoyer dans le meme message)
Code
/*
  $Id: $

  osCommerce, Open Source E-Commerce Solutions
  [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

  Copyright © 2007 osCommerce

  Released under the GNU General Public License
*/

// start the timer for the page parse time log
  define('PAGE_PARSE_START_TIME', microtime());

// set the level of error reporting
  error_reporting(E_ALL & ~E_NOTICE);
//  error_reporting(E_ALL | E_STRICT);
// check support for register_globals
  if (function_exists('ini_get') && (ini_get('register_globals') == false) && (PHP_VERSION < 4.3) ) {
    exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory. Please use PHP 4.3+ if register_globals cannot be enabled on the server.');
  }

// Set the local configuration parameters - mainly for developers
  if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
  require('includes/configure.php');

  if (strlen(DB_SERVER) < 1) {
    if (is_dir('install')) {
      header('Location: install/index.php');
    }
  }

// define the project version
  define('PROJECT_VERSION', 'osCommerce Online Merchant v2.2 RC1 W3C Valid FR');

// some code to solve compatibility issues
  require(DIR_WS_FUNCTIONS . 'compatibility.php');

// set the type of request (secure or not)
  $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
  if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
  
  
$request_method = $_SERVER["REQUEST_METHOD"];
$wRequestVars = "_" . $request_method;
$CMCIC_bruteVars = ${$wRequestVars};



  if ($request_type == 'NONSSL') {
    define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
  } else {
    define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
  }

// include the list of project filenames
  require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
  require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
  define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// include the database functions
  require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now
  tep_db_connect() or die('Connexion impossible à la Base de Données!');

// set the application parameters
  $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
  $config_flag_in = array('Oui', 'Non');
  $config_flag_out = array('true', 'false');
  while ($configuration = tep_db_fetch_array($configuration_query)) {
    $configuration['cfgValue'] = str_replace($config_flag_in, $config_flag_out, $configuration['cfgValue']);
    define($configuration['cfgKey'], $configuration['cfgValue']);
  }

// if gzip_compression is enabled, start to buffer the output
  if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
    if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
      if (PHP_VERSION >= '4.0.4') {
        ob_start('ob_gzhandler');
      } else {
        include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
        ob_start();
        ob_implicit_flush();
      }
    } else {
      ini_set('zlib.output_compression_level', GZIP_LEVEL);
    }
  }

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
  if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
    if (strlen(getenv('PATH_INFO')) > 1) {
      $GET_array = array();
      $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
      $vars = explode('/', substr(getenv('PATH_INFO'), 1));
      for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
        if (strpos($vars[$i], '[]')) {
          $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
        } else {
          $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
        }
        $i++;
      }

      if (sizeof($GET_array) > 0) {
        while (list($key, $value) = each($GET_array)) {
          $HTTP_GET_VARS[$key] = $value;
        }
      }
    }
  }

// define general functions used application-wide
  require(DIR_WS_FUNCTIONS . 'general.php');
  require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
  $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
  $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
  if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');

// include shopping cart class
  require(DIR_WS_CLASSES . 'shopping_cart.php');

// include navigation history class
  require(DIR_WS_CLASSES . 'navigation_history.php');

// check if sessions are supported, otherwise use the php3 compatible session class
  if (!function_exists('session_start')) {
    define('PHP_SESSION_NAME', 'osCsid');
    define('PHP_SESSION_PATH', $cookie_path);
    define('PHP_SESSION_DOMAIN', $cookie_domain);
    define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

    include(DIR_WS_CLASSES . 'sessions.php');
  }

// define how the session functions will be used
  require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
  tep_session_name('osCsid');
  tep_session_save_path(SESSION_WRITE_DIRECTORY);
// ********************************************************************************
************************************
// recuperation de l'id de session contenu dans texte-libre
tep_session_id(substr($CMCIC_bruteVars['texte-libre'],0,26));
// ********************************************************************************
************************************
// set the session cookie parameters
   if (function_exists('session_set_cookie_params')) {
    session_set_cookie_params(0, $cookie_path, $cookie_domain);
  } elseif (function_exists('ini_set')) {
    ini_set('session.cookie_lifetime', '0');
    ini_set('session.cookie_path', $cookie_path);
    ini_set('session.cookie_domain', $cookie_domain);
  }

// set the session ID if it exists
   if (isset($HTTP_POST_VARS[tep_session_name()])) {
     tep_session_id($HTTP_POST_VARS[tep_session_name()]);
   } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
     tep_session_id($HTTP_GET_VARS[tep_session_name()]);
   }

// start the session
  $session_started = false;
  if (SESSION_FORCE_COOKIE_USE == 'true') {
    tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

    if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
      tep_session_start();
      $session_started = true;
    }
  } elseif (SESSION_BLOCK_SPIDERS == 'true') {
    $user_agent = strtolower(getenv('HTTP_USER_AGENT'));
    $spider_flag = false;

    if (tep_not_null($user_agent)) {
      $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

      for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
        if (tep_not_null($spiders[$i])) {
          if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
            $spider_flag = true;
            break;
          }
        }
      }
    }

    if ($spider_flag == false) {
      tep_session_start();
      $session_started = true;
    }
  } else {
    tep_session_start();
    $session_started = true;
  }

  if ( ($session_started == true) && (PHP_VERSION >= 4.3) && function_exists('ini_get') && (ini_get('register_globals') == false) ) {
    extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS);
  }

// set SID once, even if empty
  $SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
  if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'true') && (ENABLE_SSL == true) && ($session_started == true) ) {
    $ssl_session_id = getenv('SSL_SESSION_ID');
    if (!tep_session_is_registered('SSL_SESSION_ID')) {
      $SESSION_SSL_ID = $ssl_session_id;
      tep_session_register('SESSION_SSL_ID');
    }

    if ($SESSION_SSL_ID != $ssl_session_id) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
    }
  }

// verify the browser user agent if the feature is enabled
  if (SESSION_CHECK_USER_AGENT == 'true') {
    $http_user_agent = getenv('HTTP_USER_AGENT');
    if (!tep_session_is_registered('SESSION_USER_AGENT')) {
      $SESSION_USER_AGENT = $http_user_agent;
      tep_session_register('SESSION_USER_AGENT');
    }

    if ($SESSION_USER_AGENT != $http_user_agent) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_LOGIN));
    }
  }

// verify the IP address if the feature is enabled
  if (SESSION_CHECK_IP_ADDRESS == 'true') {
    $ip_address = tep_get_ip_address();
    if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
      $SESSION_IP_ADDRESS = $ip_address;
      tep_session_register('SESSION_IP_ADDRESS');
    }

    if ($SESSION_IP_ADDRESS != $ip_address) {
      tep_session_destroy();
      tep_redirect(tep_href_link(FILENAME_LOGIN));
    }
  }

// create the shopping cart & fix the cart if necesary
  if (tep_session_is_registered('cart') && is_object($cart)) {
    if (PHP_VERSION < 4) {
      $broken_cart = $cart;
      $cart = new shoppingCart;
      $cart->unserialize($broken_cart);
    }
  } else {
    tep_session_register('cart');
    $cart = new shoppingCart;
  }

// include currencies class and create an instance
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

// include the mail classes
  require(DIR_WS_CLASSES . 'mime.php');
  require(DIR_WS_CLASSES . 'email.php');

// set the language
  if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
    if (!tep_session_is_registered('language')) {
      tep_session_register('language');
      tep_session_register('languages_id');
    }

    include(DIR_WS_CLASSES . 'language.php');
    $lng = new language();

    if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
      $lng->set_language($HTTP_GET_VARS['language']);
    } else {
      $lng->get_browser_language();
    }

    $language = $lng->language['directory'];
    $languages_id = $lng->language['id'];
  }

// include the language translations
  require(DIR_WS_LANGUAGES . $language . '.php');

// Ultimate SEO URLs v2.1
  if ((!defined(SEO_ENABLED)) || (SEO_ENABLED == 'true')) {
    include_once(DIR_WS_CLASSES . 'seo.class.php');
    if ( !is_object($seo_urls) ){
      $seo_urls = new SEO_URL($languages_id);
    }
  }

// currency
  if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
    if (!tep_session_is_registered('currency')) tep_session_register('currency');

    if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) {
      $currency = $HTTP_GET_VARS['currency'];
    } else {
      $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
    }
  }

// navigation history
  if (tep_session_is_registered('navigation')) {
    if (PHP_VERSION < 4) {
      $broken_navigation = $navigation;
      $navigation = new navigationHistory;
      $navigation->unserialize($broken_navigation);
    }
  } else {
    tep_session_register('navigation');
    $navigation = new navigationHistory;
  }
  $navigation->add_current_page();

// Shopping cart actions
  if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
    if ($session_started == false) {
      tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
    }

    if (DISPLAY_CART == 'true') {
      $goto =  FILENAME_SHOPPING_CART;
      $parameters = array('action', 'cPath', 'products_id', 'pid');
    } else {
      $goto = basename($PHP_SELF);
      if ($HTTP_GET_VARS['action'] == 'buy_now') {
        $parameters = array('action', 'pid', 'products_id');
      } else {
        $parameters = array('action', 'pid');
      }
    }
    switch ($HTTP_GET_VARS['action']) {
      // customer wants to update the product quantity in their shopping cart
      case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
                                if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
                                  $cart->remove($HTTP_POST_VARS['products_id'][$i]);
                                } else {
                                  if (PHP_VERSION < 4) {
                                    // if PHP3, make correction for lack of multidimensional array.
                                    reset($HTTP_POST_VARS);
                                    while (list($key, $value) = each($HTTP_POST_VARS)) {
                                      if (is_array($value)) {
                                        while (list($key2, $value2) = each($value)) {
                                          if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
                                            $id2[$var[1]][$var[2]] = $value2;
                                          }
                                        }
                                      }
                                    }
                                    $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
                                  } else {
                                    $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
                                  }
                                  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
      // customer adds a product from the products page
      case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
    // BOF: Product Listing in Columns
    // add to cart
      case 'buy_now_form' :   if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
    // customer adds multiple products from the products_listing page
      case 'add_multiple' :   while (list($key, $val) = each($HTTP_POST_VARS)) {
                                if (substr($key,0,11) == "Qty_ProdId_" || substr($key,0,11) == "Qty_NPrdId_") {
                                  $prodId = substr($key, 11);
                                  $qty = $val;
                                  if ($qty <= 0) continue;
                                  if (isset($HTTP_POST_VARS["id_$prodId"]) && is_array($HTTP_POST_VARS["id_$prodId"])) {
                                  // We have attributes
                                    $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$HTTP_POST_VARS["id_$prodId"]))+$qty, $HTTP_POST_VARS["id_$prodId"]);
                                  } else {
                                    // No attributes
                                    $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);
                                  }
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
    // BOF: Product Listing in Columns
      // performed by the 'buy now' button in product listings and review page
      case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                                if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                                } else {
                                  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
      case 'notify' :         if (tep_session_is_registered('customer_id')) {
                                if (isset($HTTP_GET_VARS['products_id'])) {
                                  $notify = $HTTP_GET_VARS['products_id'];
                                } elseif (isset($HTTP_GET_VARS['notify'])) {
                                  $notify = $HTTP_GET_VARS['notify'];
                                } elseif (isset($HTTP_POST_VARS['notify'])) {
                                  $notify = $HTTP_POST_VARS['notify'];
                                } else {
                                  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                                }
                                if (!is_array($notify)) $notify = array($notify);
                                for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
                                  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
                                  $check = tep_db_fetch_array($check_query);
                                  if ($check['count'] < 1) {
                                    tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
                                  }
                                }
                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                              } else {
                                $navigation->set_snapshot();
                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                              }
                              break;
      case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
                                $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                                $check = tep_db_fetch_array($check_query);
                                if ($check['count'] > 0) {
                                  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                                }
                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
                              } else {
                                $navigation->set_snapshot();
                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                              }
                              break;
      case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
                                if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
                                } else {
                                  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
                                }
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
    }
  }

// include the who's online functions
  require(DIR_WS_FUNCTIONS . 'whos_online.php');
  tep_update_whos_online();

// include the password crypto functions
  require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include validation functions (right now only email address)
  require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
  require(DIR_WS_CLASSES . 'split_page_results.php');

(Fin de la partie I)

Mais attention, il est basé sur mon application_top et devra peut etre modifié un peu vis a vis des utilisateurs ulterieurs.
Pa contre, modifier le nom du repertoire appelé 'REPERTOIRE_CMCIC' dans les requires

Bon courrage
(pour infos, comme je n'arrivais pas à faire fonctionner le fichier retour de la contribution, j'en ai ecrit un mois meme)
Nico

Ce message a été modifié par nilegoff - 30 Jun 2010, 14:35.


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 14:30
Message #7


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Partie II (la Suite du code)
Code
// infobox
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//Site thema configuration
  $configuration_query = tep_db_query("select  configuration_key as themaKey, configuration_value as themaValue from " . TABLE_CONFIGURATION . " where configuration_key = 'SITE_THEMA'");
  $configuration = tep_db_fetch_array($configuration_query);
  define($configuration['themaKey'], $configuration['themaValue']);
  if($configuration['themaKey']==""){
  define(THEMA_STYLE, "stylesheet.css");
  // infobox
  require(DIR_WS_CLASSES . 'boxes.php'); }
  else{
  // Thema_infobox
  require(DIR_WS_CLASSES . 'thema_boxes.php');
  define(THEMA_STYLE, DIR_WS_CLASSES . "thema/" . SITE_THEMA . "/stylesheet.css");
  }
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

// auto activate and expire banners
  require(DIR_WS_FUNCTIONS . 'banner.php');
  tep_activate_banners();
  tep_expire_banners();

// auto expire special products
  require(DIR_WS_FUNCTIONS . 'specials.php');
  tep_expire_specials();

// calculate category path
  if (isset($HTTP_GET_VARS['cPath'])) {
    $cPath = $HTTP_GET_VARS['cPath'];
  } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
    $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
  } else {
    $cPath = '';
  }

  if (tep_not_null($cPath)) {
    $cPath_array = tep_parse_category_path($cPath);
    $cPath = implode('_', $cPath_array);
    $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
  } else {
    $current_category_id = 0;
  }

// include the breadcrumb class and start the breadcrumb trail
  require(DIR_WS_CLASSES . 'breadcrumb.php');
  $breadcrumb = new breadcrumb;

  $breadcrumb->add(' ', HTTP_SERVER);
  //$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));





// initialize the message stack for output messages
  require(DIR_WS_CLASSES . 'message_stack.php');
  $messageStack = new messageStack;

// set which precautions should be checked
  define('WARN_INSTALL_EXISTENCE', 'true');
  define('WARN_CONFIG_WRITEABLE', 'true');
  define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
  define('WARN_SESSION_AUTO_START', 'true');
  define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
  
  require_once(DIR_WS_CLASSES . 'preventDuplicates.php');
    $preventDuplicates = new preventDuplicates();
?>

<?
/*****************************************************************************
*
* "Open source" kit for CM-CIC P@iement(TM).
* Process CMCIC Payment. Sample RFC2104 compliant with PHP4 skeleton.
*
* File "Phase2Retour.php":
*
* Author   : Euro-Information/e-Commerce (contact: centrecom@e-i.com)
* Version  : 1.04
* Date     : 01/01/2009
*
* Copyright: (c) 2009 Euro-Information. All rights reserved.
* License  : see attached document "Licence.txt".
*
*****************************************************************************/
          tep_session_unregister('ip_adresse');
        $ip = $ip_address;
        $client = gethostbyaddr($ip_address);
        $str = preg_split("/\./", $client);
        $i = count($str);
        $x = $i - 1;
        $n = $i - 2;
        $isp = $str[$n] . "." . $str[$x];
// include('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

  if (!tep_session_is_registered('sendto')) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  }

  if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
    if ($cart->cartID != $cartID) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
  }

  include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

// load selected payment module
// require(DIR_WS_CLASSES . 'payment.php');
//  $payment_modules = new payment($payment);

// load the selected shipping module
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping($shipping);

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

  require(DIR_WS_CLASSES . 'order_total.php');
  $order_total_modules = new order_total;

  $order_totals = $order_total_modules->process();


// TPE Settings
// Warning !! CMCIC_Config contains the key, you have to protect this file with all the mechanism available in your development environment.
// You may for instance put this file in another directory and/or change its name. If so, don't forget to adapt the include path below.

require_once("REPERTOIRE_CMCIC/CMCIC_Config.php");

// --- PHP implementation of RFC2104 hmac sha1 ---
require_once("REPERTOIRE_CMCIC/CMCIC_Tpe.inc.php");


// Begin Main : Retrieve Variables posted by CMCIC Payment Server
$CMCIC_bruteVars = getMethode();

// TPE init variables
$oTpe = new CMCIC_Tpe();
$oHmac = new CMCIC_Hmac($oTpe);

// Message Authentication
$cgi2_fields = sprintf(CMCIC_CGI2_FIELDS, $oTpe->sNumero,
                      $CMCIC_bruteVars["date"],
                          $CMCIC_bruteVars['montant'],
                          $CMCIC_bruteVars['reference'],
                          $CMCIC_bruteVars['texte-libre'],
                          $oTpe->sVersion,
                          $CMCIC_bruteVars['code-retour'],
                      $CMCIC_bruteVars['cvx'],
                      $CMCIC_bruteVars['vld'],
                      $CMCIC_bruteVars['brand'],
                      $CMCIC_bruteVars['status3ds'],
                      $CMCIC_bruteVars['numauto'],
                      $CMCIC_bruteVars['motifrefus'],
                      $CMCIC_bruteVars['originecb'],
                      $CMCIC_bruteVars['bincb'],
                      $CMCIC_bruteVars['hpancb'],
                      $CMCIC_bruteVars['ipclient'],
                      $CMCIC_bruteVars['originetr'],
                      $CMCIC_bruteVars['veres'],
                      $CMCIC_bruteVars['pares']
                    );


if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC']))
    {
    switch($CMCIC_bruteVars['code-retour']) {
        case "Annulation" :
                //________________________________________________________________________________
_____________________
                // on archive les données reçues de la banque dans la table cmcic_response
                tep_db_perform('cmcic_response', array(
                    'ref_number' => tep_db_input($CMCIC_bruteVars['reference']),
                    //'MAC' => $CMCIC_bruteVars['MAC'],
                    'TPE' => tep_db_input($CMCIC_bruteVars['TPE']),
                    'date' => tep_db_input($CMCIC_bruteVars['date']),
                    'montant' => tep_db_input($CMCIC_bruteVars['montant']),
                    'texte_libre' => tep_db_input($CMCIC_bruteVars['texte-libre']),
                    'motifrefus' => tep_db_input($CMCIC_bruteVars['motifrefus']),
                    'cvx' => tep_db_input($CMCIC_bruteVars['cvx']),
                    'vld' => tep_db_input($CMCIC_bruteVars['vld']),
                    'brand' => tep_db_input($CMCIC_bruteVars['brand']),
                    'status3ds' => tep_db_input($CMCIC_bruteVars['status3ds']),
                    'originecb' => tep_db_input($CMCIC_bruteVars['originecb']),
                    'bincb' => tep_db_input($CMCIC_bruteVars['bincb']),
                    'ipclient' => tep_db_input($CMCIC_bruteVars['ipclient']),
                    'originetr' => tep_db_input($CMCIC_bruteVars['originetr']),
                    'hpancb' => tep_db_input($CMCIC_bruteVars['hpancb']),
                    'code_retour' => tep_db_input($CMCIC_bruteVars['code-retour']),
                    'customers_name' => $order->customer['lastname'] . ' ' . $order->customer['firstname'],
                    'custumers_id' => $customer_id));
//________________________________________________________________________________
_________________________
                    break;

        case "payetest":
        
//  $payment_modules->before_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_fax' => $order->customer['fax'],
                          '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'],
                          'sms' => $order->info['sms'],
                'payment_method' => '*** Carte Bancaire Test ***',
                'transaction_id' => tep_db_input($CMCIC_bruteVars['numauto']),
                'complementary_info' => tep_db_input($CMCIC_bruteVars['status3ds']).'|'.tep_db_input($CMCIC_bruteVars['originecb']).'|'.tep_db_input($CMCIC_bruteVars['hpancb']).'|'.tep_db_input($CMCIC_bruteVars['ipclient']).'|'.tep_db_input($CMCIC_bruteVars['originetr']),
                'cc_type' => tep_db_input($CMCIC_bruteVars['brand']),
                'cc_owner' => tep_db_input($CMCIC_bruteVars['reference']),
                'cc_number' => substr(tep_db_input($CMCIC_bruteVars['bincb']),0,4).' #### #### ##'.substr(tep_db_input($CMCIC_bruteVars['bincb']),4,2),
                'cc_bin' => tep_db_input($CMCIC_bruteVars['bincb']),
                'cc_expires' => tep_db_input($CMCIC_bruteVars['vld']),
                'date_purchased' => 'now()',
                'orders_status' => '1',
                'ip' => $ip,
                'isp' => $isp,
                'currency' => $order->info['currency'],
                'customers_referer_url' => $referer_url,
                'shipping_module' => $shipping['id'],
                'currency_value' => $order->info['currency_value']);
  tep_db_perform(TABLE_ORDERS, $sql_data_array);
  $insert_id = tep_db_insert_id();
  for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
    $sql_data_array = array('orders_id' => $insert_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);
  }

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
  $sql_data_array = array('orders_id' => $insert_id,
                          'orders_status_id' => '1',
                          'date_added' => 'now()',
                          'customer_notified' => $customer_notification,
                          'comments' => $order->info['comments']);
  tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// initialized for the email confirmation
  $products_ordered = '';
  $subtotal = 0;
  $total_tax = 0;

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
    if (STOCK_LIMITED == 'true') {
      if (DOWNLOAD_ENABLED == 'true') {
        $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
                            FROM " . TABLE_PRODUCTS . " p
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                             ON p.products_id=pa.products_id
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                             ON pa.products_attributes_id=pad.products_attributes_id
                            WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
        $products_attributes = $order->products[$i]['attributes'];
        if (is_array($products_attributes)) {
          $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
        }
        $stock_query = tep_db_query($stock_query_raw);
      } else {
        $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
      }
      if (tep_db_num_rows($stock_query) > 0) {
        $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
        if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
          $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
        } else {
          $stock_left = $stock_values['products_quantity'];
        }

        tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        
        $desactive_query = mysql_query("SELECT conditionnement from products where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        while($row = mysql_fetch_array($desactive_query))
       {
        if ($row[conditionnement]==-100) {
        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // pour annuler disparition produit qd stock=0; $stock_left < 1 est devenu $stock_left < 0
          tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        }}
        else {
        if ( ($stock_left < 0) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // pour annuler disparition produit qd stock=0; $stock_left < 1 est devenu $stock_left < 0
          tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        }}}
      }
    }


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 14:34
Message #8


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Partie 3 et FIN
Code
// Update products_ordered (for bestsellers list)
    tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

    $sql_data_array = array('orders_id' => $insert_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();

//------insert customer choosen option to order--------
    $attributes_exist = '0';
    $products_ordered_attributes = '';
    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' => $insert_id,
                                'orders_products_id' => $order_products_id,
                                'products_options' => $attributes_values['products_options_name'],
                                '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);

        if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
          $sql_data_array = array('orders_id' => $insert_id,
                                  'orders_products_id' => $order_products_id,
                                  'orders_products_filename' => $attributes_values['products_attributes_filename'],
                                  'download_maxdays' => $attributes_values['products_attributes_maxdays'],
                                  'download_count' => $attributes_values['products_attributes_maxcount']);
          tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
        }
        $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
      }
    }
//------insert customer choosen option eof ----
    $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
    $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
    $total_cost += $total_products_price;

    $products_ordered .= "<tr><td><FONT color=#000000 size=2 face=Arial>".$order->products[$i]['qty'] . "</font></td><td><FONT color=#000000 size=2 face=Arial>x</font></td><td><FONT color=#000000 size=2 face=Arial>" . $order->products[$i]['name'] . "</font></td><td align='right'><FONT color=#000000 size=2 face=Arial>" . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "</font></td></tr>\n";
  }

// lets start with the email confirmation

$email_order  =   "<a href=\"http://www.ton-site.com\"><img src=\"http://www.ton-site.com/images/ton_logo.jpg\" alt=\"ton-site.com\" border=\"0\"></a><br><br><FONT color=#000000 size=2 face=Arial>Bonjour ".$order->customer['firstname'] . " " . $order->customer['lastname']."\n\n";
  $email_order .= "ton-site.com a bien enregistr&eacute; votre commande\n</FONT>";                
     $email_order .="<table border='1' width='600px' bordercolor='#000000' cellpadding='10'  cellspacing='0'><tr><td width='300px'><FONT color=#000000 size=2 face=Arial>Commande n°" . $insert_id . "</font></td><td width='300px' align='right'><FONT color=#000000 size=2 face=Arial>Date de Commande: ". strftime(DATE_FORMAT_SHORT) . "</font></td></tr>\n";
$email_order .="<tr><td colspan='2' align='center'><FONT color=#000000 size=2 face=Arial>Contact: <u>".$order->customer['email_address']."</u></font></td></tr>";
  
      $email_order .="<tr><td width='300px' valign='top'><FONT color=#000000 size=2 face=Arial>";
  if ($order->content_type != 'virtual') {
    $email_order .=  "<b><u>".EMAIL_TEXT_DELIVERY_ADDRESS . "</u>:</b><br>" .
                    tep_address_label($customer_id, $sendto, 0, '', "<br>") . "<br>";
  }
$email_order .="</font></td><td width='300px' valign='top'><FONT color=#000000 size=2 face=Arial>";
  $email_order .=  "<b></u>".EMAIL_TEXT_BILLING_ADDRESS . "</u>:</b><br>" .
                  tep_address_label($customer_id, $billto, 0, '', "<br>") . "<br>";
                  
$email_order .="</font></td></tr>\n";    

  
  $email_order .= "<tr><td colspan='2'><FONT color=#000000 size=2 face=Arial><b><u>Liste des produits command&eacute;s</u>:</b><br>" .
                  "<br><table width='100%' border='0'>".$products_ordered . "\n";
                  
  $email_order .="<tr><td colspan='3'>&nbsp;</td><td align='right'>__________</font></tr> ";
for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
    $email_order .= "<tr><td align='right' colspan='3'><FONT color=#000000 size=2 face=Arial>".strip_tags($order_totals[$i]['title']) . "</font></td><td align='right'><FONT color=#000000 size=2 face=Arial>" . strip_tags($order_totals[$i]['text']) . "</font></td></tr>";
  }
    $email_order .="</table></td></tr>\n";
    
  if ($order->info['comments']) {
    $email_order .= "<tr><td colspan='2'><FONT color=#000000 size=2 face=Arial><b><u>Commentaire</u>:</b><br> ".strip_tags(tep_db_output($order->info['comments']),'<br>') . "</font></td></tr>\n";
  }
  

   $email_order .="<tr><td colspan='2' align='left'><FONT color=#000000 size=2 face=Arial><b><u>".EMAIL_TEXT_PAYMENT_METHOD . "</u>:</b> Carte Bancaire<br><br>".$textepaiement."</font></td></tr></table>";              

  tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], 'Enregistrement de votre commande', $email_order, 'ton-site.com','service.clients@ton-site.com');

// send emails to other people
  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
   // tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  }

// load the after_process function from the payment modules
//  $payment_modules->after_process();

  $cart->reset(true);

// unregister session variables used during checkout
  tep_session_unregister('sendto');
  tep_session_unregister('billto');
  tep_session_unregister('shipping');
  tep_session_unregister('payment');
  tep_session_unregister('comments');
  tep_session_unregister('sms');
            break;

        case "paiement":
//  $payment_modules->before_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_fax' => $order->customer['fax'],
                          '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'],
                          'sms' => $order->info['sms'],
                'payment_method' => 'Carte Bancaire',
                'transaction_id' => tep_db_input($CMCIC_bruteVars['numauto']),
                'complementary_info' => tep_db_input($CMCIC_bruteVars['status3ds']).'|'.tep_db_input($CMCIC_bruteVars['originecb']).'|'.tep_db_input($CMCIC_bruteVars['hpancb']).'|'.tep_db_input($CMCIC_bruteVars['ipclient']).'|'.tep_db_input($CMCIC_bruteVars['originetr'].'|'.substr(tep_db_input($CMCIC_bruteVars['texte-libre']),29,8)),
                'cc_type' => tep_db_input($CMCIC_bruteVars['brand']),
                'cc_owner' => tep_db_input($CMCIC_bruteVars['reference']),
                'cc_number' => substr(tep_db_input($CMCIC_bruteVars['bincb']),0,4).' #### #### ##'.substr(tep_db_input($CMCIC_bruteVars['bincb']),4,2),
                'cc_bin' => tep_db_input($CMCIC_bruteVars['bincb']),
                'cc_expires' => tep_db_input($CMCIC_bruteVars['vld']),
                'date_purchased' => 'now()',
                'orders_status' => '1',
                'ip' => $ip,
                'isp' => $isp,
                'currency' => $order->info['currency'],
                'customers_referer_url' => $referer_url,
                'shipping_module' => $shipping['id'],
                'currency_value' => $order->info['currency_value']);
  tep_db_perform(TABLE_ORDERS, $sql_data_array);
  $insert_id = tep_db_insert_id();
  for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
    $sql_data_array = array('orders_id' => $insert_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);
  }

  $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
  $sql_data_array = array('orders_id' => $insert_id,
                          'orders_status_id' => '1',
                          'date_added' => 'now()',
                          'customer_notified' => $customer_notification,
                          'comments' => $order->info['comments']);
  tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// initialized for the email confirmation
  $products_ordered = '';
  $subtotal = 0;
  $total_tax = 0;

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
    if (STOCK_LIMITED == 'true') {
      if (DOWNLOAD_ENABLED == 'true') {
        $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
                            FROM " . TABLE_PRODUCTS . " p
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                             ON p.products_id=pa.products_id
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                             ON pa.products_attributes_id=pad.products_attributes_id
                            WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
        $products_attributes = $order->products[$i]['attributes'];
        if (is_array($products_attributes)) {
          $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
        }
        $stock_query = tep_db_query($stock_query_raw);
      } else {
        $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
      }
      if (tep_db_num_rows($stock_query) > 0) {
        $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
        if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
          $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
        } else {
          $stock_left = $stock_values['products_quantity'];
        }

        tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        
        $desactive_query = mysql_query("SELECT conditionnement from products where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        while($row = mysql_fetch_array($desactive_query))
       {
        if ($row[conditionnement]==-100) {
        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // pour annuler disparition produit qd stock=0; $stock_left < 1 est devenu $stock_left < 0
          tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        }}
        else {
        if ( ($stock_left < 0) && (STOCK_ALLOW_CHECKOUT == 'false') ) { // pour annuler disparition produit qd stock=0; $stock_left < 1 est devenu $stock_left < 0
          tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
        }}}
      }
    }

// Update products_ordered (for bestsellers list)
    tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

    $sql_data_array = array('orders_id' => $insert_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();

//------insert customer choosen option to order--------
    $attributes_exist = '0';
    $products_ordered_attributes = '';
    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' => $insert_id,
                                'orders_products_id' => $order_products_id,
                                'products_options' => $attributes_values['products_options_name'],
                                '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);

        if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
          $sql_data_array = array('orders_id' => $insert_id,
                                  'orders_products_id' => $order_products_id,
                                  'orders_products_filename' => $attributes_values['products_attributes_filename'],
                                  'download_maxdays' => $attributes_values['products_attributes_maxdays'],
                                  'download_count' => $attributes_values['products_attributes_maxcount']);
          tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
        }
        $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
      }
    }
//------insert customer choosen option eof ----
    $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
    $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
    $total_cost += $total_products_price;

    $products_ordered .= "<tr><td><FONT color=#000000 size=2 face=Arial>".$order->products[$i]['qty'] . "</font></td><td><FONT color=#000000 size=2 face=Arial>x</font></td><td><FONT color=#000000 size=2 face=Arial>" . $order->products[$i]['name'] . "</font></td><td align='right'><FONT color=#000000 size=2 face=Arial>" . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "</font></td></tr>\n";
  }

// lets start with the email confirmation

$email_order  =   "<a href=\"http://www.ton-site.com\"><img src=\"http://www.ton-site.com/images/ton_logo.jpg\" alt=\"ton-site.com\" border=\"0\"></a><br><br><FONT color=#000000 size=2 face=Arial>Bonjour ".$order->customer['firstname'] . " " . $order->customer['lastname']."\n\n";
  $email_order .= "ton-site.com a bien enregistr&eacute; votre commande\n</FONT>";                
     $email_order .="<table border='1' width='600px' bordercolor='#000000' cellpadding='10'  cellspacing='0'><tr><td width='300px'><FONT color=#000000 size=2 face=Arial>Commande n°" . $insert_id . "</font></td><td width='300px' align='right'><FONT color=#000000 size=2 face=Arial>Date de Commande: ". strftime(DATE_FORMAT_SHORT) . "</font></td></tr>\n";
$email_order .="<tr><td colspan='2' align='center'><FONT color=#000000 size=2 face=Arial>Contact: <u>".$order->customer['email_address']."</u></font></td></tr>";
  
      $email_order .="<tr><td width='300px' valign='top'><FONT color=#000000 size=2 face=Arial>";
  if ($order->content_type != 'virtual') {
    $email_order .=  "<b><u>".EMAIL_TEXT_DELIVERY_ADDRESS . "</u>:</b><br>" .
                    tep_address_label($customer_id, $sendto, 0, '', "<br>") . "<br>";
  }
$email_order .="</font></td><td width='300px' valign='top'><FONT color=#000000 size=2 face=Arial>";
  $email_order .=  "<b></u>".EMAIL_TEXT_BILLING_ADDRESS . "</u>:</b><br>" .
                  tep_address_label($customer_id, $billto, 0, '', "<br>") . "<br>";
                  
$email_order .="</font></td></tr>\n";    

  
  $email_order .= "<tr><td colspan='2'><FONT color=#000000 size=2 face=Arial><b><u>Liste des produits command&eacute;s</u>:</b><br>" .
                  "<br><table width='100%' border='0'>".$products_ordered . "\n";
                  
  $email_order .="<tr><td colspan='3'>&nbsp;</td><td align='right'>__________</font></tr> ";
for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
    $email_order .= "<tr><td align='right' colspan='3'><FONT color=#000000 size=2 face=Arial>".strip_tags($order_totals[$i]['title']) . "</font></td><td align='right'><FONT color=#000000 size=2 face=Arial>" . strip_tags($order_totals[$i]['text']) . "</font></td></tr>";
  }
    $email_order .="</table></td></tr>\n";
    
  if ($order->info['comments']) {
    $email_order .= "<tr><td colspan='2'><FONT color=#000000 size=2 face=Arial><b><u>Commentaire</u>:</b><br> ".strip_tags(tep_db_output($order->info['comments']),'<br>') . "</font></td></tr>\n";
  }
  
  $email_order .="<tr><td colspan='2' align='left'><FONT color=#000000 size=2 face=Arial><b><u>".EMAIL_TEXT_PAYMENT_METHOD . "</u>:</b> Carte Bancaire<br><br>".$textepaiement."</font></td></tr></table>";              

  tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], 'Enregistrement de votre commande', $email_order, 'ton-site.com','service.clients@ton-site.com');

// send emails to other people
  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
   // tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  }

// load the after_process function from the payment modules
//  $payment_modules->after_process();

  $cart->reset(true);

// unregister session variables used during checkout
  tep_session_unregister('sendto');
  tep_session_unregister('billto');
  tep_session_unregister('shipping');
  tep_session_unregister('payment');
  tep_session_unregister('comments');
  tep_session_unregister('sms');
            break;

            
    }

    $receipt = CMCIC_CGI2_MACOK;

}
else
{
    // your code if the HMAC doesn't match
    $receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
}

//-----------------------------------------------------------------------------
// Send receipt to CMCIC server
//-----------------------------------------------------------------------------
printf (CMCIC_CGI2_RECEIPT, $receipt);
// Copyright (c) 2009 Euro-Information ( mailto:centrecom@e-i.com )
// All rights reserved. ---
?>

Les 3 parties de codes font le meme fichier

Ce message a été modifié par nilegoff - 30 Jun 2010, 14:43.


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
ThomasB
posté 30 Jun 2010, 15:26
Message #9


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 6
Inscrit : 30-June 10
Membre no 27751



Merci Nico !

Je vais regarder ça de plus près. A première vue la différence qu'il y a dans le fichier d'origine et le tien, c'est ta façon de gérer la partie "session". J'ai pu noté une intervention répété du code "$PHP_SELF", chose que je n'ai pas dans mon fichier de base.

Te serait-il possible, sans trop prendre de ton temps, de me décrire spécifiquement ce que tu as du ajouter ou modifier pour faire remonter les variables inclus dans la session (table session) ?
Cela m'aidera à y voir plus clair. Pour le reste, j'arrive à peu près à gérer.

Encore merci, à charge de revanche (si tant est que cela soit possible smile.gif )
Thomas
Go to the top of the page
 
nilegoff
posté 30 Jun 2010, 16:14
Message #10


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



En realité, comme je l'ai deja dit, je fonctionne exactement comme le checkout process.
Une fois la session recupéré, j'appele la class order.php qui me redonne toute les variables de la commande en cours.

A ce moment là, il n'y a plus qu'a verifier que la reponse vient bien ce Cybermut

puis en fonction de la reponse, l'enregistre le teste, l'annulation ou le paiement (ou encore un des paiements fractionnés)

Le fichier est long, car je n'ai pas enlevé tout ce qui ne servait à rien dans l'application_top et peut etre epuré.

nilegoff

Ce message a été modifié par nilegoff - 1 Jul 2010, 18:38.


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
ThomasB
posté 5 Jul 2010, 07:57
Message #11


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 6
Inscrit : 30-June 10
Membre no 27751



Une nouvelle fois merci.
J'ai mis en place une partie des lignes de code que tu m'as communiqué, ça fonctionne parfaitement.

Thomas
Go to the top of the page
 
valerie22
posté 27 Oct 2010, 19:12
Message #12


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



bonjour
je rencontre le meme pb, j'ai installe order_check comme preconisé par Grindal mais c'est une solution paliative... je suis donc preneuse de ton explication et des 3 codes de ton fichier... simplement il composent quel fichier ? cmic-reponse ou chekout success ?
merci de ton aide*
val
Go to the top of the page
 
nilegoff
posté 27 Oct 2010, 22:50
Message #13


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Bonsoir,

Les 3 bouts de code composent le fichier cmcic-reponse.php (que je te conseille de renommer par principe (mais ne pas oublier de donner le nouveau nom au centre de gestion CIC ou CM)).
Ce fichier cmcic-response.php a exactement la meme fonction que checkout-process.php mais est dedié au retour du centre CB du CIC et CM. Il a été fabriqué à partir de mon checkout-process.php et peut necessité quelques adaptations pour une autre boutique

nilegoff


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
valerie22
posté 28 Oct 2010, 09:31
Message #14


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



Bonjour Nilegof
merci de ta reponse... ca va etre un peu au dela de mes connaissances techniques
j'ai introduit ton code mais en effet ca me fait des erreur... peux tu m'aiguiller pour demarrer a partir de mon checkout success?
merci d'avance
val
Go to the top of the page
 
nilegoff
posté 28 Oct 2010, 14:58
Message #15


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Peux tu nous dire quelles erreurs as tu?
Verifie bien que
Code
require_once("REPERTOIRE_CMCIC/CMCIC_Config.php");
indique bien le chemin de ton repertoire avec le fichier config

nilegoff


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
valerie22
posté 28 Oct 2010, 15:31
Message #16


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



oui j'ai bien le require
je vais proceder par elimination... voici la 1ere erreur renvoyee par cmic :
REPONSE DE VOTRE CGI DE CONFIRMATION :
<br />
<b>Warning</b>: reset() [<a href='function.reset?osCsid=10373b7618f7c11f9eec5cf53b26ce5d'>function.reset</a>]: Passed variable is not an array or object in <b>/serveur/www/boutique/includes/classes/navigation_history.php</b> on line <b>130</b><br /> <br />
<b>Warning</b>: Variable passed to each() is not an array or object in <b>/serveur/www/boutique/includes/classes/navigation_history.php</b> on line <b>131</b><br /> <br />
<b>Warning</b>: reset() [<a href='function.reset?osCsid=10373b7618f7c11f9eec5cf53b26ce5d'>function.reset</a>]: Passed variable is not an array or object in <b>/serveur/www/boutique/includes/classes/navigation_history.php</b> on line <b>130</b><br /> <br />
<b>Warning</b>: Variable passed to each() is not an array or object in <b>/serveur/www/boutique/includes/classes/navigation_history.php</b> on line <b>131</b><br />


voila....





Ce message a été modifié par valerie22 - 28 Oct 2010, 15:39.
Go to the top of the page
 
valerie22
posté 28 Oct 2010, 16:36
Message #17


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



apres quelques modifs je n'ai plus d'erreur et le retour du cgi est ok ce qui est deja bien, mais toujours pas de trace de la commande dans l'admin, ni d'envoi de mail de confirmation au client test.
en relisant ton precedent post je m'appercois que je n'ai pas de cmci_config... j'ai installé la contrib cmcic_contrib_3.0b
as tu une idee ?
merci en tout cas
valerie
Go to the top of the page
 
valerie22
posté 29 Oct 2010, 14:24
Message #18


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



Bonjour Nilegoff
je patauge si tu as 5 min pour m'aiguiller ce serait super sympa
merci d'avance
val
Go to the top of the page
 
nilegoff
posté 29 Oct 2010, 14:34
Message #19


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 193
Inscrit : 26-June 05
Lieu : Finistère Sud
Membre no 6327



Si tu as le retour CGI ok, c'est presque gagné.
Il ne reste plus qu'a enregistrer la commande

remplace pour faire un teste le contenue de l'action de paytest par echo '1321321321321321321321321321321321321'; et regarde si ce texte apparait.

Si apparait, remplace le par le contenu de ton checkout_process qui enregistre la commande

nilegoff


--------------------
MS2.2 - AdminMS2fr 2.3 - All Products - Categorie tab - Thema 2.7 - Browse by categorie - Colissimo - Define Main PAge 1.3.3 - Low stock - Fckeditor 2.0 - Header tag Controllers - LoginBox 5.4 in header - Mbtable - Must agree to terms 1.5.3 - Order Ip Recorder - Ordomaxdropdown 1.2.3 - Products listing Columns - Prof Invoice - Quick stock update - send order html mail 5.4 - Stock status in product listing - Ultimate SEO URL V2.1 - Visible contries 1.1c - Atos - CCGV - Fianet - Xsell 2.2 - et d'autres encore...
Go to the top of the page
 
chti_poupon
posté 29 Oct 2010, 14:36
Message #20


Ceinture noire OSC
Icône de groupe

Groupe : TechDev
Messages : 2757
Inscrit : 9-September 08
Lieu : Douai
Membre no 22915



Citation (chti_poupon @ 18 Sep 2010, 17:26) *
Citation (zattara @ 17 Apr 2009, 10:29) *
Bonjour tout le monde,

Depuis le 1er Avril 2009 le module CyberMut est obsolète, car le groupement CMCIC a changé son protocole de cryptage des données.
A la demande de plusieurs de mes clients j'ai créé une contribution CyberMut 3.0, compatible avec les clés SHA1 de nouvelle génération.

Vous trouverez cette contribution, qui supporte le Crédit Mutuel, le CiC et OBC à cette adresse : http://addons.oscommerce.com/info/6691. Il vous suffit d'uploader, de placer la clé XXXXXXX.key fournie dans le répertoire cmcic. Activez et renseignez trois champs dans l'admin, le tour est joué.

En vous souhaitant de bonnes ventes !

Voilà la version utilisée sur osCommerce actuellement.
En suivant scrupuleusement les indications, y compris celles données dans le code, et en prenant bien la version adaptée à l'osC utilisé, l'installation, les tests et les indications du très aimable service clientèle Cybermut tout se passe bien. Les ennuis rencontrés sont à la suite de cet épinglé et souvent dus à une lecture trop rapide des instructions.
Bonne installation !
Chti poupon


Bonjour !
Rien à ajouter sauf à insister sur le scrupuleusement.
Chti poupon
Go to the top of the page
 
valerie22
posté 29 Oct 2010, 16:30
Message #21


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



Merci Nilegoff
apres maintes et maintes tentatives et sur tes conseils, tout fonctionne !!!
quelle merveille !!!
merci encore de ton aide et bravo a ce forum pour debrouiller les pbs...
merci val

Ce message a été modifié par valerie22 - 29 Oct 2010, 16:31.
Go to the top of the page
 
valerie22
posté 3 Nov 2010, 16:27
Message #22


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



Bonjour
une chose étrange tout est ok desormais pour cmic cybermut, mais dans l'outil d'admin comme dans le compte des clients lorsqu'ils reglent par cb (uniquement) la commande apparait en double... c'est le meme numero de commande mais elles est visibles deux fois, idem dans l'historique des commandes et dans l'outil d'admin...
dans la bdd elle n'est pas doublee pourtant... quelqu'un peut il m'aider ?
merci d'avance
val
Go to the top of the page
 
chti_poupon
posté 3 Nov 2010, 20:13
Message #23


Ceinture noire OSC
Icône de groupe

Groupe : TechDev
Messages : 2757
Inscrit : 9-September 08
Lieu : Douai
Membre no 22915



smile.gif Bonsoir !
Vérifier dans catalog/cmcic_response.php qu'un break; n'a pas été accidentellement avant la partie exploitation: il faut avoir :
Code
  break;
  
  case "paiement":

sinon la partie test fait son travail sauvegarde, courriels... puis la partie exploitation recommence happy.gif
Réponse non transcendante, mais çà serait trop bête ! tongue.gif
Chti poupon
Go to the top of the page
 
valerie22
posté 4 Nov 2010, 10:29
Message #24


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 50
Inscrit : 3-March 09
Membre no 24689



bonjour
merci de ta reponse .. dans le fichier en question j'ai 3 break :
1 -
break;
case "payetest":
2-
// on enregistre la valeur de la derniere commande
$order_id = $insert_id;
tep_session_register('order_id');
tep_db_perform('cmcic_reference', array('order_id' => $order_id), 'update', "ref_number='". $CMCIC_bruteVars['reference']."'");
break;

case "paiement":
3-
// ________________________________________________________________________________
________________________________
// on enregistre la valeur de la derniere commande
$order_id = $insert_id;
tep_session_register('order_id');
tep_db_perform('cmcic_reference', array('order_id' => $order_id), 'update', "ref_number='". $CMCIC_bruteVars['reference']."'");
break;
}
$receipt = CMCIC_CGI2_MACOK;

est ce normal ?

merci

Go to the top of the page
 
chti_poupon
posté 5 Nov 2010, 22:56
Message #25


Ceinture noire OSC
Icône de groupe

Groupe : TechDev
Messages : 2757
Inscrit : 9-September 08
Lieu : Douai
Membre no 22915



smile.gif Bonjour !
Alors là n'est pas la cause de ce bégaiement.... wub.gif
Ton code ne se répète pas 2 fois entre case et break ??
Car la ( blush.gif ) contrib est fournie avec un morceau de checkout_process.php, à remplacer si le tien est différent. Si tu l'as ajouté, tu l'as ajouté biggrin.gif !
Une Belle Journée à toi !
Chti Poupon
PS cette partie vient aussi à l'identique après
case "paiement":

Ce message a été modifié par chti_poupon - 5 Nov 2010, 23:04.
Go to the top of the page
 

3 Pages V   1 2 3 >
Reply to this topicStart new topic
2 utilisateur(s) sur ce sujet (2 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 19th March 2024 - 10:40
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)