checkout_process Class Reference

Inherits AbstractAcaModule.

List of all members.

Public Member Functions

Static Public Member Functions

  • static generat_uniq_id ($pre_order_id='')
  • static check_string_return ($string)
    Control de la chaine transmise et retoruné par service de paiement.
  • static generat_string ($id_pre_commande='')
    generation chaine unique transmise au service de paiement
  • static purgeHolding ($held_order='')
    Purge l'ordre in holding, basé sur valeur en session ou en arguement.

Public Attributes

Private Member Functions

Static Private Member Functions

  • static test_pre_order_id ($pre_order_id)
    appelé par preventDuplicate Test présence pre_order_id dans table holding_order ET n'existe pas dans order (holding_origin_id)

Static Private Attributes

  • static $tables
    array tableau de table
  • static $mode
    bool Mode (orders=true | holding_order=false)

Detailed Description

Definition at line 26 of file checkout_process.php.


Constructor & Destructor Documentation

checkout_process::__construct ( order_id = '',
table = '' 
)

Charge les module aca specifique au porduits.

Parameters:
$order_id int|null
$table string|null

Definition at line 49 of file checkout_process.php.

00049                                                {
00050     global $language, $page;
00051     $this-> name='checkout_process';
00052     $this->modules=array();
00053     $this->list_mod=array();
00054 
00055     /*
00056       Selection Holding /orders
00057     */
00058     self::$mode=(tep_not_null($table)?false:true);
00059 
00060     $table=((!self::$mode)? '_'.strtoupper($table) : '');
00061 
00062     self::$tables=array( 'ORDERS'=>constant('TABLE'.$table.'_ORDERS'),
00063                           'TOTAL'=>constant('TABLE'.$table.'_ORDERS_TOTAL'),
00064                           'PRODUCTS'=>constant('TABLE'.$table.'_ORDERS_PRODUCTS'),
00065                           'ATTRIBUTES'=>constant('TABLE'.$table.'_ORDERS_PRODUCTS_ATTRIBUTES'),
00066                           'DOWNLOAD'=>constant('TABLE'.$table.'_ORDERS_PRODUCTS_DOWNLOAD'),
00067                           'HISTORY'=>constant('TABLE'.$table.'_ORDERS_STATUS_HISTORY'),
00068                         );
00069 
00070         /*
00071          * Load module type process
00072          */
00073      foreach(parent::initialise_type('MODULE_CHECKOUT_PROCESS_INSTALLED','checkout_process') as $class){
00074       $cl[$class]=new $class ();
00075       $list_mod[$class] = $cl[$class]->sort_order;
00076       asort($list_mod);
00077       foreach($list_mod as $class=>$s){
00078         $GLOBALS[$class] =$this->modules[$class] =$cl[$class];
00079       }
00080       unset($cl);unset($list_mod);
00081      }
00082 
00083     /*if(tep_not_null($order_id))*/ $this->the_order_id=(int)$order_id;
00084   }


Member Function Documentation

checkout_process::after_process (  ) 

Chargement apres le process et apres appel des after_process des pay_mod.

Definition at line 159 of file checkout_process.php.

00159                                  {
00160     global  $page;
00161       foreach ($this->modules as $key=>$module) {
00162         if (($module->enabled)  and (method_exists($module, 'after_process'))) {
00163           $funct='after_process';
00164           return $this->modules[$key]->$funct();
00165         }
00166       }
00167   }

checkout_process::before_process (  ) 

Chargement avant process et avant before_process payment.

Definition at line 99 of file checkout_process.php.

00099                                   {
00100     global  $page;
00101       foreach ($this->modules as $key=>$module) {
00102         if (($module->enabled)  and (method_exists($module, 'before_process'))) {
00103           $funct='before_process';
00104           return $this->modules[$key]->$funct();
00105         }
00106       }
00107   }

static checkout_process::check_string_return ( string  )  [static]

Control de la chaine transmise et retoruné par service de paiement.

LA chaine est composé de diverse info, contenu dans la pre_commande

Returns:
$string false | pre_order_id

Definition at line 227 of file checkout_process.php.

00227                                                      {
00228     $res=explode('|',$string);
00229     $DB=Database::getInstance();
00230     $query=$DB->query($sql="Select customers_id, date_purchased from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . (int)$res[0] . "' ");
00231     $item=$query->fetchAssoc();
00232     if($item['customers_id'] != (int)$res[1] ) return false;
00233     if($item['date_purchased'] !=$res[2]) return false;
00234 
00235     $query=$DB->query("Select value, class from ".TABLE_HOLDING_ORDERS_TOTAL." Where orders_id='".(int)$res[0]."' and class='ot_total' ");
00236     $item=$query->fetchAssoc();
00237 
00238     if($item['value'] !=$res[3]) return false;
00239 
00240     return $res[0];
00241   }

checkout_process::email_confirm_order ( order_id  ) 

Envoi email de confirmation de commande.

Parameters:
$order_id 

admin notif

Definition at line 523 of file checkout_process.php.

Referenced by process_confirm().

00523                                                 {
00524     global $payment,$shipping,$language, $currencies ;
00525 
00526     $order=new order($order_id);
00527 
00528 
00529     if (isset($$payment) && is_object($$payment)) {
00530       $payment_class = $$payment;
00531       $payment_= $payment_class->title;
00532       $email_footer = (isset($payment_class->email_footer)) ? $payment_class->email_footer . "\n\n" : '';
00533     }
00534     else {
00535       $payment_=$order->info['payment_method'];
00536       $email_footer='';
00537     }
00538     if (is_array($shipping)) {
00539       $shipping_= $shipping['title'];
00540     } else {
00541       $shipping_=$order->info['shipping_method'];
00542     }
00543 
00544     $myarray = array(
00545                     'from'=>STORE_OWNER,
00546                     'subject'=>'',
00547                     '_oID'=>$this->get_the_order_formated(),
00548                     'date_purchased'=>tep_strftime(DATE_FORMAT_LONG),
00549                     '_comments'=>((isset($order->info['comments']) )?tep_db_output($order->info['comments']) : ''),
00550                     'sendToFormatted'=> tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br />'),
00551                     'billToFormatted'=>tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br />'),
00552                     'payment_'=>$payment_,
00553                     'shipping_'=>$shipping_,
00554                     'order_totals'=>$order->totals,
00555                     'order_products'=>$order->products,
00556                     'email_footer'=>$email_footer,
00557     //                   '_ostatus'=>$orders_status_array[$status],
00558                     '_oLinks'=>tep_href_link(FILENAME_ACCOUNT, 'action=history_info&amp;order_id=' . $order_id, 'SSL'),
00559                     'email_use_html'=>_cst_bool('EMAIL_USE_HTML'),
00560                     'message'=>'',
00561                     );
00562 
00563 
00564     $message_final=tep_post_prepare_email('checkout_process.tpl',$language,$myarray);
00565 
00566     tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $message_final, STORE_OWNER, EMAIL_FROM);
00567 
00569     notification::notifInMess('checkout_process','copy '.EMAIL_TEXT_SUBJECT,$message_final,'customers_id='.$order->info['customers_id']);
00570 
00571   }

static checkout_process::generat_string ( id_pre_commande = ''  )  [static]

generation chaine unique transmise au service de paiement

Returns:
id_pre_commande|customers_id|date_purchased|value ot_total

table orders_total

Definition at line 247 of file checkout_process.php.

00247                                                             {
00248     global $customer_id;
00249     $DB=Database::getInstance();
00250 
00251     $pre_order_id=(!tep_not_null($id_pre_commande))? $_SESSION['pre_order_id']:$id_pre_commande;
00252 
00253     $generat=$pre_order_id.'|'.$customer_id.'|';
00254 
00255     $res=$DB->query("Select date_purchased from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . (int)$pre_order_id . "' ");
00256     $item=$res->fetchAssoc();
00257     $generat .=$item['date_purchased'].'|';
00258 
00260     $res=$DB->query("Select value, class from ".TABLE_HOLDING_ORDERS_TOTAL." Where orders_id='".(int)$pre_order_id."' and class='ot_total' ");
00261     $item=$res->fetchAssoc();
00262     $generat .=$item['value'];
00263 
00264     return $generat;
00265   }

static checkout_process::generat_uniq_id ( pre_order_id = ''  )  [static]

Definition at line 217 of file checkout_process.php.

00217                                                           {
00218     $pre_order_id=(!tep_not_null($pre_order_id))? $_SESSION['pre_order_id']:$pre_order_id;
00219     return date('Y-m-d').'-'.$pre_order_id;
00220   }

checkout_process::get_the_order_formated (  ) 

Renvoi numero commande formated.

Definition at line 173 of file checkout_process.php.

Referenced by email_confirm_order().

00173                                           {
00174     return (isset($this->the_order_formated) && !empty($this->the_order_formated)) ? $this->the_order_formated : $this->the_order_id;
00175   }

checkout_process::in_process_finish (  ) 

Chargement dans le fin du process.

Definition at line 144 of file checkout_process.php.

Referenced by process_exe().

00144                                      {
00145     global  $page;
00146       foreach ($this->modules as $key=>$module) {
00147         if (($module->enabled)  and (method_exists($module, 'in_process_finish'))) {
00148           $funct='in_process_finish';
00149           return $this->modules[$key]->$funct();
00150         }
00151       }
00152   }

checkout_process::in_process_order (  ) 

Chargement dans le process, dans le detail order avant boucle produits.

Definition at line 114 of file checkout_process.php.

Referenced by process_exe().

00114                                     {
00115     global  $page, $order;
00116       foreach ($this->modules as $key=>$module) {
00117         if (($module->enabled)  and (method_exists($module, 'in_process_order'))) {
00118           $funct='in_process_order';
00119           return $this->modules[$key]->$funct();
00120         }
00121       }
00122   }

checkout_process::in_process_products (  ) 

Chargement dans le process, dans boucle produits.

Definition at line 129 of file checkout_process.php.

Referenced by process_exe().

00129                                        {
00130     global  $page;
00131       foreach ($this->modules as $key=>$module) {
00132         if (($module->enabled)  and (method_exists($module, 'in_process_products'))) {
00133           $funct='in_process_products';
00134           return $this->modules[$key]->$funct();
00135         }
00136       }
00137   }

checkout_process::insert_order ( customer_id,
order,
update = '' 
) [private]

Enregsitrement de la table order.

Parameters:
$customer_id int l'id
$order object
$update string si string update
Returns:
order_id

Definition at line 581 of file checkout_process.php.

Referenced by process_exe().

00581                                                                  {
00582     $date_purchased=date("Y-m-d H:i:s");
00583     $format_prefix='';
00584     $sql_data_array = array('customers_id' => $customer_id,
00585                             'orders_prefix' => $format_prefix,
00586                             'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
00587                             'customers_company' => (string)$order->customer['company'],
00588                             'customers_street_address' => (string)$order->customer['street_address'],
00589                             'customers_suburb' => $order->customer['suburb'],
00590                             'customers_city' => (string)$order->customer['city'],
00591                             'customers_postcode' => $order->customer['postcode'],
00592                             'customers_state' => (string)$order->customer['state'],
00593                             'customers_country' => $order->customer['country']['title'],
00594                             'customers_telephone' => $order->customer['telephone'],
00595                             'customers_email_address' => $order->customer['email_address'],
00596                             'customers_address_format_id' => $order->customer['format_id'],
00597                             'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
00598                             'delivery_company' => $order->delivery['company'],
00599                             'delivery_street_address' => (string)$order->delivery['street_address'],
00600                             'delivery_suburb' => $order->delivery['suburb'],
00601                             'delivery_city' => (string)$order->delivery['city'],
00602                             'delivery_postcode' => $order->delivery['postcode'],
00603                             'delivery_state' => $order->delivery['state'],
00604                             'delivery_country' => $order->delivery['country']['title'],
00605                             'delivery_address_format_id' => $order->delivery['format_id'],
00606                             'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
00607                             'billing_company' => $order->billing['company'],
00608                             'billing_street_address' => (string)$order->billing['street_address'],
00609                             'billing_suburb' => $order->billing['suburb'],
00610                             'billing_city' => (string)$order->billing['city'],
00611                             'billing_postcode' => $order->billing['postcode'],
00612                             'billing_state' => $order->billing['state'],
00613                             'billing_country' => $order->billing['country']['title'],
00614                             'billing_address_format_id' => $order->billing['format_id'],
00615                             'payment_method' => $order->info['payment_method'],
00616                             'cc_type' => $order->info['cc_type'],
00617                             'cc_owner' => $order->info['cc_owner'],
00618                             'cc_number' => substr_replace($order->info['cc_number'],"XXXXXXXX",4,8),
00619                             'cc_expires' => $order->info['cc_expires'],
00620                             'date_purchased' => $date_purchased,
00621                             'orders_status' => (int)$order->info['order_status'],
00622                             'currency' => (string)$order->info['currency'],
00623                             'currency_value' => $order->info['currency_value'],
00624                             'ip_address' => tep_get_ip_address(),
00625                             'total_weight'=>$order->info['total_weight']);
00626 
00627     if(empty($update)) tep_db_perform(self::$tables['ORDERS'], $sql_data_array);
00628     else tep_db_perform(self::$tables['ORDERS'], $sql_data_array, 'update', $update);
00629 
00630     $cs_s=tep_db_query("select orders_id from " . self::$tables['ORDERS'] . "  where customers_id='".$customer_id."' and date_purchased='".$date_purchased."'");
00631     $cs=tep_db_fetch_array($cs_s);
00632     $_SESSION['the_order_id'] =$this->the_order_id=$insert_id=$cs['orders_id'];
00633 
00634 
00635     /* Ajout prefix de numero de commande */
00636     if(defined('ORDERS_NUMBER_PREFIX') && ORDERS_NUMBER_PREFIX !='' ){
00637       preg_match('#([a-zA-Z]*)(.{0,1})([0-9])#',ltrim(ORDERS_NUMBER_PREFIX),$reg);
00638       $the_order_final=date($reg[1]).$reg[2].str_pad('',(int)($reg[3]-strlen($insert_id)),"0" ,STR_PAD_LEFT);
00639       $sql_data_array = array( 'orders_prefix' =>$the_order_final  );
00640       tep_db_perform(self::$tables['ORDERS'], $sql_data_array, 'update', " orders_id='".$insert_id."' ");
00641       $the_order_final .=$insert_id;
00642      $this->the_order_formated=$_SESSION['the_order_formated']=$the_order_final;
00643     }
00644 
00645 
00646 
00647     return  $this->the_order_id;
00648   }

checkout_process::insert_order_product ( i,
products_stock_attributes,
order 
) [private]

In boucle product.

Parameters:
$i int index de boucle
$products_stock_attributes string
$order object
Returns:
$order_products_id

Definition at line 705 of file checkout_process.php.

Referenced by process_exe().

00705                                                                               {
00706     $sql_data_array = array('orders_id' => $this->the_order_id,
00707                           'products_id' => tep_get_prid($order->products[$i]['id']),
00708                           'products_model' => tep_db_input($order->products[$i]['model']),
00709                           'products_name' => tep_db_input($order->products[$i]['name']),
00710                           'products_price' => tep_db_input($order->products[$i]['price']),
00711                           'final_price' => tep_db_input($order->products[$i]['final_price']),
00712                           'products_tax' => tep_db_input($order->products[$i]['tax']),
00713                           'products_quantity' => (int)$order->products[$i]['qty'],
00714                           'products_stock_attributes' => tep_db_input($products_stock_attributes) );
00715     tep_db_perform(self::$tables['PRODUCTS'], $sql_data_array);
00716 
00717     $cs_s=tep_db_query("select orders_products_id from " . self::$tables['PRODUCTS'] . "  where orders_id='".(int)$this->the_order_id."' and products_id='".tep_get_prid($order->products[$i]['id'])."' and final_price='".tep_db_input($order->products[$i]['final_price'])."' order by  orders_products_id DESC LIMIT 1 ");
00718     $cs=tep_db_fetch_array($cs_s);
00719     $order_products_id=$cs['orders_products_id'];
00720     return $order_products_id;
00721   }

checkout_process::insert_order_product_attribut ( order_products_id,
attributes_values 
) [private]

Insert db product attribute.

Parameters:
int $order_products_id
aray $attributes_values
Returns:
no

Definition at line 730 of file checkout_process.php.

Referenced by process_exe().

00730                                                                                        {
00731     $sql_data_array = array('orders_id' => (int)$this->the_order_id,
00732                             'orders_products_id' => (int)$order_products_id,
00733                             'products_options' => tep_db_input($attributes_values['products_options_name']),
00734                             'products_options_values' => tep_db_input($attributes_values['products_options_values_name']),
00735                             'options_values_price' => tep_db_input($attributes_values['options_values_price']),
00736                             'price_prefix' => tep_db_input($attributes_values['price_prefix']));
00737     tep_db_perform(self::$tables['ATTRIBUTES'], $sql_data_array);
00738 
00739     if ((_cst_bool('DOWNLOAD_ENABLED')) && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
00740       $sql_data_array = array('orders_id' => (int)$this->the_order_id,
00741                               'orders_products_id' => (int)$order_products_id,
00742                               'orders_products_filename' => tep_db_input($attributes_values['products_attributes_filename']),
00743                               'download_maxdays' => tep_db_input($attributes_values['products_attributes_maxdays']),
00744                               'download_count' => tep_db_input($attributes_values['products_attributes_maxcount']));
00745       tep_db_perform(self::$tables['DOWNLOAD'], $sql_data_array);
00746     }
00747   }

checkout_process::insert_order_total ( order_totals  )  [private]

Order total.

Parameters:
$order_totals array resultat de $order_total->process()
Returns:
no

Definition at line 657 of file checkout_process.php.

Referenced by process_exe().

00657                                                     {
00658     for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
00659       $sql_data_array = array('orders_id' =>  $this->the_order_id,
00660                               'title' => tep_db_input($order_totals[$i]['title']),
00661                               'text' => tep_db_input($order_totals[$i]['text']),
00662                               'value' => tep_db_input($order_totals[$i]['value']),
00663                               'class' => tep_db_input($order_totals[$i]['code']),
00664                               'sort_order' => (int)$order_totals[$i]['sort_order']);
00665       tep_db_perform(self::$tables['TOTAL'], $sql_data_array);
00666     }
00667   }

checkout_process::insert_status_history ( order  ) 

status history

Parameters:
$object object/array
Returns:
$customer_notification bool

Definition at line 685 of file checkout_process.php.

Referenced by process_exe().

00685                                                {
00686     $customer_notification = (_cst_bool('SEND_EMAILS')) ? '1' : '0';
00687     $sql_data_array = array('orders_id' =>   (int)$this->the_order_id ,
00688                             'orders_status_id' =>  (is_object($order)?  (int)$order->info['order_status']:  (int)$order['orders_status_id']),
00689                             'date_added' => 'now()',
00690                             'customer_notified' => (is_object($order)?  (int)$customer_notification :  (int)$order['customer_notified']) ,
00691                             'comments' => (is_object($order)? tep_db_input($order->info['comments']): tep_db_input($order['comments']) ) );
00692     tep_db_perform(self::$tables['HISTORY'], $sql_data_array);
00693 
00694     return $customer_notification;
00695   }

checkout_process::load_db_attribut_product ( i,
j,
order 
) [private]

Load db attribute products.

Parameters:
$i int index boucle produit
$j int index boucle attribute produits
$order object object order
Returns:
$attributes_values

Definition at line 758 of file checkout_process.php.

Referenced by process_exe().

00758                                                          {
00759     global $languages_id;
00760     if (_cst_bool('DOWNLOAD_ENABLED')) {
00761       $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
00762                             from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
00763                             left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
00764                             on pa.products_attributes_id=pad.products_attributes_id
00765                             where pa.products_id = '" . (int)$order->products[$i]['id'] . "'
00766                             and pa.options_id = '" . (int)$order->products[$i]['attributes'][$j]['option_id'] . "'
00767                             and pa.options_id = popt.products_options_id
00768                             and pa.options_values_id = '" . (int)$order->products[$i]['attributes'][$j]['value_id'] . "'
00769                             and pa.options_values_id = poval.products_options_values_id
00770                             and popt.language_id = '" . (int)$languages_id . "'
00771                             and poval.language_id = '" .(int) $languages_id . "'";
00772       $attributes = tep_db_query($attributes_query);
00773     } else {
00774       $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 = '" .(int) $order->products[$i]['id'] . "' and pa.options_id = '" . (int)$order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" .(int) $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" .(int) $languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
00775     }
00776     $attributes_values = tep_db_fetch_array($attributes);
00777 
00778     /* Specifique option type texte / file champ personnalisé par le client */
00779     $attributes_values['products_options_values_name'] = $order->products[$i]['attributes'][$j]['value'];
00780     return $attributes_values;
00781   }

checkout_process::order_destock_product ( i,
order 
) [private]

Destock de produits.

Author:
oscim <mail oscim@oscss.org> <www http://www.oscim.fr>
Parameters:
$order int valeur de boucle
$order object
Returns:
$products_stock_attributes

Gestion stock et attribut If not downloadable and attributes present, adjust attribute stock

stock produit sans attribut et non downloadable

descative les produit qu ne sont plus en stock, si l'achat hors stock nest pas autorise

Definition at line 792 of file checkout_process.php.

Referenced by process_exe().

00792                                                    {
00793 
00794     $products_stock_attributes=null;
00795 
00796     if (_cst_bool('STOCK_LIMITED')) {
00797 
00798       $products_attributes =(isset($order->products[$i]['attributes'])) ?  $order->products[$i]['attributes'] : array();
00799       if (_cst_bool('DOWNLOAD_ENABLED') ) {
00800         $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
00801                             FROM " . TABLE_PRODUCTS . " p
00802                             LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
00803                               ON p.products_id=pa.products_id
00804                             LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
00805                               ON pa.products_attributes_id=pad.products_attributes_id
00806                             WHERE p.products_id = '" .tep_db_input( tep_get_prid($order->products[$i]['id']) ). "'";
00807         // Will work with only one option for downloadable products
00808         // otherwise, we have to build the query dynamically with a loop
00809         if (is_array($products_attributes) && isset($products_attributes[0]))
00810           $stock_query_raw .= " AND pa.options_id = '" . (int)$products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . (int)$products_attributes[0]['value_id'] . "'";
00811         $stock_query = tep_db_query($stock_query_raw);
00812       }
00813       else {
00814         $stock_query = tep_db_query("select products_quantity, track_stock from " . TABLE_PRODUCTS . " where products_id = '" .tep_db_input( tep_get_prid($order->products[$i]['id']) ). "'");
00815       }
00816 
00817       if (tep_db_num_rows($stock_query) > 0) {
00818           $stock_values = tep_db_fetch_array($stock_query);
00819           $actual_stock_bought = $order->products[$i]['qty'];
00820           $download_selected = false;
00821 
00822           if ((!_cst_bool('DOWNLOAD_ENABLED')) && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
00823             $download_selected = true;
00824             $products_stock_attributes='$$DOWNLOAD$$';
00825           }
00826 
00829           if (!$download_selected  && is_array($products_attributes) && count($products_attributes)>0) {
00830             $all_nonstocked = true;
00831             $products_stock_attributes_array = array();
00832             foreach ($products_attributes as $attribute) {
00833               $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
00834               if ($attribute['track_stock'] == 1)  $all_nonstocked = false;
00835             }
00836             if ($all_nonstocked) {
00837               $actual_stock_bought = $order->products[$i]['qty'];
00838 
00839             asort($products_stock_attributes_array, SORT_NUMERIC);
00840             $products_stock_attributes = implode(",", $products_stock_attributes_array);
00841 
00842             } else {
00843               asort($products_stock_attributes_array, SORT_NUMERIC);
00844               $products_stock_attributes = implode(",", $products_stock_attributes_array);
00845               $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '".tep_db_input($products_stock_attributes)."' AND products_id = '" .tep_db_input( tep_get_prid($order->products[$i]['id']) ). "'");
00846 
00847               if (tep_db_num_rows($attributes_stock_query) > 0) {
00848                 $attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
00849                 $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
00850 
00851                 tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" .tep_db_input( $attributes_stock_left) . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_db_input(tep_get_prid($order->products[$i]['id'])) . "'");
00852 
00853                 $actual_stock_bought = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty'];
00854               } else {
00855                 $attributes_stock_left = 0 - $order->products[$i]['qty'];
00856 
00857                 tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_db_input(tep_get_prid($order->products[$i]['id'])) . "', '" .tep_db_input($products_stock_attributes) . "', '" . tep_db_input($attributes_stock_left ). "')");
00858 
00859                 $actual_stock_bought = 0;
00860               }
00861             }
00862           }
00863 
00865           elseif (!$download_selected && $stock_values['track_stock']>0) {
00866             $stock_left = $stock_values['products_quantity'] - $actual_stock_bought;
00867 
00868             tep_db_query($sql="update " . TABLE_PRODUCTS . " set products_quantity = '" .tep_db_input( $stock_left ). "' where products_id = '" . tep_db_input( tep_get_prid($order->products[$i]['id']) ). "'");
00869 
00871             if ( ($stock_left < 1) && (!_cst_bool('STOCK_ALLOW_CHECKOUT')) && @$stock_values['track_stock'] ==1 )
00872               tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" .tep_db_input( tep_get_prid($order->products[$i]['id']) ). "'");
00873 
00874           }
00875 
00876       }
00877     }
00878     return $products_stock_attributes;
00879   }

checkout_process::preventDuplicate ( array  ) 

Bacule pre commande vers commande Si a pre-commande existe (ds la session),elle est transformé en commande Si pas de pre-commande en session, creation de la commande.

Parameters:
$array array

Definition at line 190 of file checkout_process.php.

00190                                           {
00191     if (tep_session_is_registered('pre_order_id') && !isset($array['pre_order_id']) ) return $this->process_confirm($_SESSION['pre_order_id']);
00192     elseif(self::test_pre_order_id($array['pre_order_id'])) return $this->process_confirm($array['pre_order_id']);
00193     else {
00194       return $this->process_exe($array['order_totals'],$array['order']);
00195     }
00196   }

checkout_process::process_confirm ( pre_order_id  ) 

Ordananceur process holding vs order.

Parameters:
$pre_order_id int id pre commande

table order

table orders_total

product / products_attributes / products_download

table orders_status_history

purge

emptying cart

RETURN

Definition at line 398 of file checkout_process.php.

Referenced by preventDuplicate().

00398                                                 {
00399     $corresp=$corresp_attrib=array();
00400 
00401     $DB=Database::getInstance();
00402 
00404     $order_query = $DB->query("select orders_prefix, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified, ip_address from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . (int)$pre_order_id . "'");
00405     $order = $order_query->fetchAssoc();
00406 
00407     $sql_data_array = array('holding_origin_id'=>(int)$pre_order_id,
00408                             'orders_prefix' => tep_db_input($order['orders_prefix']),
00409                             'currency' => tep_db_input($order['currency']),
00410                             'customers_id' => (int)$order['customers_id'],
00411                             'currency_value' => tep_db_input($order['currency_value']),
00412                             'payment_method' => tep_db_input($order['payment_method']),
00413                             'cc_type' => tep_db_input($order['cc_type']),
00414                             'cc_owner' => tep_db_input($order['cc_owner']),
00415                             'cc_number' => tep_db_input($order['cc_number']),
00416                             'cc_expires' => tep_db_input($order['cc_expires']),
00417                             'date_purchased' => date('Y-m-d H:i:s'),
00418                             'orders_status' => tep_db_input($order['orders_status']),
00419                             'ip_address' => tep_db_input($order['ip_address']),
00420                             'last_modified' => tep_db_input($order['last_modified']),
00421                             'customers_name' => tep_db_input($order['customers_name']),
00422                             'customers_company' => tep_db_input($order['customers_company']),
00423                             'customers_street_address' => tep_db_input($order['customers_street_address']),
00424                             'customers_suburb' => tep_db_input($order['customers_suburb']),
00425                             'customers_city' => tep_db_input($order['customers_city']),
00426                             'customers_postcode' => tep_db_input($order['customers_postcode']),
00427                             'customers_state' => tep_db_input($order['customers_state']),
00428                             'customers_country' => tep_db_input($order['customers_country']),
00429                             'customers_address_format_id' => tep_db_input($order['customers_address_format_id']),
00430                             'customers_telephone' => tep_db_input($order['customers_telephone']),
00431                             'customers_email_address' => tep_db_input($order['customers_email_address']),
00432                             'delivery_name' => tep_db_input($order['delivery_name']),
00433                             'delivery_company' => tep_db_input($order['delivery_company']),
00434                             'delivery_street_address' => tep_db_input($order['delivery_street_address']),
00435                             'delivery_suburb' => tep_db_input($order['delivery_suburb']),
00436                             'delivery_city' => tep_db_input($order['delivery_city']),
00437                             'delivery_postcode' => tep_db_input($order['delivery_postcode']),
00438                             'delivery_state' => tep_db_input($order['delivery_state']),
00439                             'delivery_country' => tep_db_input($order['delivery_country']),
00440                             'delivery_address_format_id' => (int)$order['delivery_address_format_id'],
00441                             'billing_name' => tep_db_input($order['billing_name']),
00442                             'billing_company' => tep_db_input($order['billing_company']),
00443                             'billing_street_address' => tep_db_input($order['billing_street_address']),
00444                             'billing_suburb' => tep_db_input($order['billing_suburb']),
00445                             'billing_city' => tep_db_input($order['billing_city']),
00446                             'billing_postcode' => tep_db_input($order['billing_postcode']),
00447                             'billing_state' => tep_db_input($order['billing_state']),
00448                             'billing_country' => tep_db_input($order['billing_country']),
00449                             'billing_address_format_id' => (int)$order['billing_address_format_id']);
00450 
00451     $query=tep_db_perform(TABLE_ORDERS, $sql_data_array);
00452 
00453     $this->the_order_id=$order_id=$query->__get('insertId');
00454 
00456     $res=$DB->query("Select title, text, value, class, sort_order from ".TABLE_HOLDING_ORDERS_TOTAL." Where orders_id='".(int)$pre_order_id."' ");
00457 
00458     while ($item = $res->fetchAssoc())
00459       $DB->query("Insert into ".TABLE_ORDERS_TOTAL." (orders_id,title,text,value,class,sort_order) values ('".(int)$order_id."','".tep_db_input($item['title'])."','".tep_db_input($item['text'])."','".tep_db_input($item['value'])."','".tep_db_input($item['class'])."','".tep_db_input($item['sort_order'])."') ");
00460 
00461 
00463     $orders_products_query = tep_db_query("select orders_products_id, products_id,products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_HOLDING_ORDERS_PRODUCTS . " where orders_id = '" . (int)$pre_order_id . "'");
00464     while ($orders_products = tep_db_fetch_array($orders_products_query)) {
00465 
00466       $sql_data_array2 = array('orders_id' => (int)$order_id,
00467                               'products_id' => (int)$orders_products['products_id'],
00468                               'products_quantity' => tep_db_input($orders_products['products_quantity']),
00469                               'products_name' => tep_db_input($orders_products['products_name']),
00470                               'products_model' => tep_db_input($orders_products['products_model']),
00471                               'products_tax' => tep_db_input($orders_products['products_tax']),
00472                               'products_price' => tep_db_input($orders_products['products_price']),
00473                               'final_price' => tep_db_input($orders_products['final_price']));
00474 
00475       $res2=tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array2);
00476       $order_products_id = tep_db_insert_id($res2);
00477 
00478 
00479       $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_HOLDING_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$pre_order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
00480       if (tep_db_num_rows($attributes_query)) {
00481         while ($attributes = tep_db_fetch_array($attributes_query)) {
00482           $sql_data_array1 = array('orders_id' => (int)$order_id,
00483                                   'orders_products_id' => (int)$order_products_id,
00484                                   'products_options' => tep_db_input($attributes['products_options']),
00485                                   'products_options_values' => tep_db_input($attributes['products_options_values']),
00486                                   'price_prefix' => tep_db_input($attributes['price_prefix']),
00487                                   'options_values_price' => tep_db_input($attributes['options_values_price']) );
00488 
00489           tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array1);
00490         }
00491       }
00492     }
00493 
00494 
00496     $res=$DB->query("Select * from ".TABLE_HOLDING_ORDERS_STATUS_HISTORY." Where orders_id='".(int)$pre_order_id."' ");
00497 
00498     while ($item = $res->fetchAssoc())
00499       $DB->query("Insert into ".TABLE_ORDERS_STATUS_HISTORY." ( orders_id , orders_status_id , date_added , customer_notified , comments) values ('".$order_id."','".$item['orders_status_id']."','".$item['date_added']."','".$item['customer_notified']."','".$item['comments']."') ");
00500 
00501 
00502 
00504     self::purgeHolding($pre_order_id);
00505 
00507     tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$order['customers_id'] . "'");
00508     tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$order['customers_id'] . "'");
00509 
00510 
00511     $this->email_confirm_order($order_id);
00513     return array (  'the_order_id'=>$order_id,
00514                     'customer_notification'=>(_cst_bool('SEND_EMAILS')) ? '1' : '0',
00515                   );
00516   }

checkout_process::process_exe ( order_totals,
order = '' 
)

Ordananceur process.

Parameters:
$order_totals 
$order object orders|null

Process class

unqieuemnt held_horder

Process class

Process class

Before process module ACA

Process class Gestion du stock

Process class meilleur vente

Process class Enregsitrement des produits

Process class recup des attribut de produits

Process class enregistrement des attribut de produits

Before process module ACA

Before process module ACA

Fin pre commande

Definition at line 273 of file checkout_process.php.

Referenced by preventDuplicate().

00273                                                       {
00274     global $customer_id, $currencies;
00275 
00276     $ip = tep_get_ip_address();
00277     $total_weight='';
00278     $total_cost='';
00279     $products_tax='';
00280     $products_ordered='';
00281 
00282     $order = (!is_object($order)? new order('', ((!self::$mode)? 'holding' : '') ) : $order );
00283 
00287       $the_order_id=$insert_id=$this->insert_order($customer_id, $order);
00288 
00290       if(!self::$mode) {
00291         self::purgeHolding();
00292 //      self::preventDuplicateholding($the_order_id);
00293       }
00297       $this->insert_order_total($order_totals);
00298 
00302       $customer_notification =$this->insert_status_history($order);
00303 
00304 
00308       $this->in_process_order();
00309 
00310     // initialized for the email confirmation
00311       $subtotal = 0;
00312       $total_tax = 0;
00313 
00314       for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
00315 
00320         $products_stock_attributes=(self::$mode) ? $this->order_destock_product($i,$order) : '';
00321 
00326         if(self::$mode)$this->update_product_bestseller( $order->products[$i]['id'],  $order->products[$i]['qty']);
00327 
00332         $order_products_id =$this->insert_order_product($i,$products_stock_attributes,$order);
00333 
00334 
00335         //------insert customer choosen option to order--------
00336         $attributes_exist = '0';
00337         $products_ordered_attributes = '';
00338         if (isset($order->products[$i]['attributes'])) {
00339           $attributes_exist = '1';
00340           for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
00345             $attributes_values=$this->load_db_attribut_product($i, $j, $order);
00346 
00351             $this->insert_order_product_attribut($order_products_id,$attributes_values);
00352 
00353 
00354             $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
00355           }
00356         }
00357 
00358 
00362         $this->in_process_products();
00363 
00364     //------insert customer choosen option eof ----
00365         $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
00366         $total_products_price=$currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) ;
00367         $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
00368         $total_cost += $total_products_price;
00369 
00370 //      $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
00371       }
00372 
00373 
00377       $this->in_process_finish();
00378 
00384     return array (  'the_order_id'=>$the_order_id,
00385                     'customer_notification'=>$customer_notification,
00386                     'total_weight'=>$total_weight,
00387                     'total_tax'=>$total_tax,
00388                     'total_cost'=>$total_cost,
00389                   );
00390   }

checkout_process::purgeHolding ( held_order = ''  )  [static]

Purge l'ordre in holding, basé sur valeur en session ou en arguement.

Parameters:
$held_order int

Definition at line 887 of file checkout_process.php.

Referenced by process_confirm(), and process_exe().

00887                                                      {
00888     $held_order=(!tep_not_null($held_order))? (int)@$_SESSION['pre_order_id']:(int)$held_order;
00889     if($held_order==0) return false;
00890     tep_db_query("delete from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . (int)$held_order . "'");
00891     tep_db_query("delete from " . TABLE_HOLDING_ORDERS_PRODUCTS . " where orders_id = '" . (int)$held_order . "'");
00892     tep_db_query("delete from " . TABLE_HOLDING_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$held_order . "'");
00893     tep_db_query("delete from " . TABLE_HOLDING_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$held_order . "'");
00894     tep_db_query("delete from " . TABLE_HOLDING_ORDERS_TOTAL . " where orders_id = '" . (int)$held_order . "'");
00895 
00896     if (tep_session_is_registered('pre_order_id')) tep_session_unregister('pre_order_id');
00897   }

checkout_process::ret_modules ( class = ''  ) 

retourne la liste des modules actifs ou l'object de l'un d'eux

Reimplemented from AbstractAcaModule.

Definition at line 90 of file checkout_process.php.

00090                                         {
00091     if(!empty($class) && isset($this->modules[$class]))  return $this->modules[$class];
00092     return $this->modules;
00093   }

checkout_process::test_pre_order_id ( pre_order_id  )  [static, private]

appelé par preventDuplicate Test présence pre_order_id dans table holding_order ET n'existe pas dans order (holding_origin_id)

Parameters:
$pre_order_id int

Definition at line 204 of file checkout_process.php.

00204                                                           {
00205     $DB=Database::getInstance();
00206 
00207     $res=$DB->query("Select orders_id from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . (int)$pre_order_id . "' ");
00208     if($res->__get('numRows') ==0) return false;
00209 
00210     $res=$DB->query("Select orders_id from " . TABLE_ORDERS . " where holding_origin_id = '" . (int)$pre_order_id . "' ");
00211     if($res->__get('numRows') ==1) return false;
00212 
00213     return true;
00214   }

checkout_process::update_product_bestseller ( pid,
qty 
) [private]

Update meilleur vente.

Parameters:
$pid int
$qty int

Definition at line 906 of file checkout_process.php.

Referenced by process_exe().

00906                                                         {
00907     tep_db_query($sql="update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $qty) . " where products_id = '" .tep_db_input( tep_get_prid($pid)) . "'");
00908   }

checkout_process::update_status_order ( order_status_id  ) 

Mise a jour du status.

Parameters:
$order_status_id 

Definition at line 674 of file checkout_process.php.

00674                                                        {
00675     tep_db_query("update " . self::$tables['ORDERS'] . " set orders_status = '" . (int)$order_status_id . "', last_modified = now() where orders_id = '" .  (int)$this->the_order_id . "'");
00676   }


Member Data Documentation

checkout_process::$mode [static, private]

bool Mode (orders=true | holding_order=false)

Definition at line 41 of file checkout_process.php.

checkout_process::$tables [static, private]

array tableau de table

Definition at line 37 of file checkout_process.php.

checkout_process::$the_order_formated

string Formated order_id

Definition at line 32 of file checkout_process.php.


The documentation for this class was generated from the following file: