discount_coupon Class Reference

List of all members.

Public Member Functions

Public Attributes


Detailed Description

Definition at line 16 of file discount_coupon.php.


Member Function Documentation

discount_coupon::apply_tax ( price,
tax,
round = false,
force = false 
)

Definition at line 415 of file discount_coupon.php.

Referenced by calculate_discount().

00415                                                                        {
00416 //       if( _cst_bool('DISPLAY_PRICE_WITH_TAX') || $force ) {
00417         if( $tax != 0 ) $price = tep_add_tax( $price, $tax );
00418 //       }
00419       if( $round ) {
00420         global $currencies;
00421         $price = tep_round( $price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] );
00422       }
00423       return $price;
00424     }

discount_coupon::calculate_discount ( product = array(),
current_product = 0 
)

Class order Boucle de produits.

Definition at line 313 of file discount_coupon.php.

00313                                                                             {
00314       if( !$this->is_allowed_product( tep_get_prid( $product['id'] ) ) ) { //check that the product isn't excluded
00315         $applied_discount = 0; //don't apply a discount
00316       } else {
00317         switch( $this->coupon['coupons_discount_type'] ) {
00318           case 'shipping':
00319             $applied_discount = 0;
00320           break;
00321           case 'fixed':
00322             //get the percentage of the total discount to apply to this item:
00323             $percentage_applied = $this->coupon['coupons_discount_amount'] / $this->cart_info['valid_products']['total'];
00324             //calculate the applied discount:
00325             $applied_discount = $product['final_price'] - $percentage_applied;
00326             //this section is to make sure that both the fixed discount and the tax are correct:
00327             if( $this->cart_info['valid_products']['line_items'] == ( $current_product + 1 ) ) {
00328               $difference = $this->coupon['coupons_discount_amount'] - ( array_sum( $this->applied_discount ) + $applied_discount );
00329               if( $difference != 0 ) {
00330                 $applied_discount += $difference;
00331               }
00332             }
00333           break;
00334           case 'percent':
00335             $applied_discount = round($product['final_price'] * $this->coupon['coupons_discount_amount'],2) * $product['qty'];
00336           break;
00337         }
00338 
00339       }
00340 
00341       //now determine how we need to handle tax:
00342       if( tep_cst_define('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TAX') != 'None' ) {
00343         $discount_tax = $this->apply_tax( $applied_discount, $product['tax'], false, true ) - $applied_discount;
00344         if( tep_cst_define('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG') == 'true' ) $this->message( 'INFO: Tax not applied to product '.$product['id'].': '.$discount_tax, 'debug' );
00345       } else $discount_tax = 0;
00346 
00347       //tally the discount tax amount for each tax group
00348       if( isset( $this->discount_tax[$product['tax_description']] ) ) $this->discount_tax[$product['tax_description']] += $discount_tax;
00349       else $this->discount_tax[$product['tax_description']] = $discount_tax;
00350 
00351       //tally the discount amount for each tax group
00352       if( isset( $this->applied_discount[$product['tax_description']] ) ) $this->applied_discount[$product['tax_description']] += $applied_discount;
00353       else $this->applied_discount[$product['tax_description']] = $applied_discount;
00354 
00355       $discount = array('applied_discount' => $applied_discount, 'discount_tax' => $discount_tax);
00356 
00357       return $discount;
00358     }

discount_coupon::calculate_shown_price ( discount,
product 
)

in class order.php calculate price in boucle products

Definition at line 364 of file discount_coupon.php.

00364                                                           {
00365       $actual_shown_price = null;
00366       if( !_cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL')) {
00367         //we don't want to display the subtotal with the discount applied, so apply the discount then set the applied_discount variable to zero so that it's not added into the order subtotal, but is still used to correctly calculate tax
00368           $actual_shown_price = ( /*$this->apply_tax(*/ $product['final_price']/*, $product['tax'] )*/ * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
00369           $applied_discount = 0;
00370           $shown_price = /*$this->apply_tax( */$product['final_price']/*, $product['tax'] )*/ * $product['qty']; //$product['final_price'] * $product['qty'];
00371       } else {
00372           $shown_price = ( /*$this->apply_tax(*/ $product['final_price']/*, $product['tax'] )*/ * $product['qty'] ) - ( $discount['applied_discount'] + $discount['discount_tax'] );
00373       }
00374       //if we need to display the subtotal without the discount applied, then add the shown price to the subtotal, then change shown price to the price with the applied discount in order to properly calculate taxes
00375       if( !isset( $actual_shown_price ) ) $actual_shown_price = $shown_price;
00376       $shown_price_array = array( 'shown_price' => $shown_price, 'actual_shown_price' => $actual_shown_price );
00377       return $shown_price_array;
00378     }

discount_coupon::check_coupons_max_use (  ) 

Maxi utilisation / client.

Definition at line 123 of file discount_coupon.php.

Referenced by verify_code().

00123                                      {
00124       global $customer_id;
00125       $check_use_query = tep_db_query($sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_ORDERS." AS o INNER JOIN ".TABLE_DISCOUNT_COUPONS_TO_ORDERS." dc2o ON dc2o.orders_id=o.orders_id AND o.customers_id = '".(int)$customer_id."' AND dc2o.coupons_id='".tep_db_input( $this->coupon['coupons_id'] )."'");
00126       $use = tep_db_fetch_array( $check_use_query );
00127       //show error message if coupons_max_use is equal to the number of times this customer has used the code
00128       if( $this->coupon['coupons_max_use'] <= $use['cnt'] ) {
00129         $this->message( sprintf( ENTRY_DISCOUNT_COUPON_USE_ERROR, $use['cnt'], $this->coupon['coupons_max_use'] ) ); //display the error message for number of times used
00130         return false;
00131       }
00132       return true;
00133     }

discount_coupon::check_coupons_min_order (  ) 

Definition at line 83 of file discount_coupon.php.

Referenced by finalize_discount().

00083                                        {
00084       if(!isset($this->coupon['coupons_min_order_type'])) return false;
00085       switch($this->coupon['coupons_min_order_type'] ) {
00086         //minimum number of products:
00087         case 'quantity':
00088           global $cart;
00089           $total = $this->cart_info['valid_products']['count'];
00090           if( $this->coupon['coupons_min_order'] > $total ) { //make sure there are enough products in the cart
00091             $this->message( sprintf( ENTRY_DISCOUNT_COUPON_MIN_QUANTITY_ERROR, $this->coupon['coupons_min_order'] ) );
00092             return false;
00093           }
00094           break;
00095         //minimum price:
00096         case 'price':
00097         default:
00098           global $order, $currencies;
00099          $total = $this->cart_info['valid_products']['total'];
00100           //if we display the subtotal without the discount applied, then just compare the subtotal to the minimum order
00101           if( !_cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL')  && $this->coupon['coupons_min_order'] > $total ) {
00102             $this->message( sprintf( ENTRY_DISCOUNT_COUPON_MIN_PRICE_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $order->info['currency'], $order->info['currency_value'] ) ).'.' );
00103             return false;
00104           //if we display the subtotal with the discount applied, then we need to compare the subtotal with the discount added back in to the minimum order
00105           } else if( _cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL')) {
00106             $subtotal = $total;
00107 //             foreach( $this->applied_discount as $discount ) {
00108 //               $subtotal += $discount;
00109 //             }
00110             if( $this->coupon['coupons_min_order'] > $subtotal ) {
00111               $this->message( sprintf( ENTRY_DISCOUNT_COUPON_MIN_PRICE_ERROR, $currencies->format( $this->coupon['coupons_min_order'], true, $this->info['currency'], $this->info['currency_value'] ) ).'.' );
00112               return false;
00113             }
00114           }
00115           break;
00116       }
00117       return true;
00118     }

discount_coupon::discount_coupon ( code,
delivery 
)

Definition at line 20 of file discount_coupon.php.

00020                                                  {
00021       global $order, $currencies, $page;
00022       $this->messages = array();
00023       $this->coupon = array();
00024       $this->applied_discount = array();
00025       $this->cart_info = array( 'valid_products' => array( 'count' => 0, 'line_items' => 0, 'total' => 0 ),
00026                                 'total_products' => array( 'count' => 0, 'line_items' => 0, 'total' => 0 ),
00027                                 'exclusions' => array() );
00028       $this->get_coupon( $code, $delivery );
00029 //       $this->message='';
00030     }

discount_coupon::finalize_discount ( info  ) 

In class order.php Applique discount total.

Definition at line 384 of file discount_coupon.php.

00384                                         {
00385       global  $currencies;
00386       //make sure we meet the order minimum
00387       if( !$this->check_coupons_min_order() ) {
00388         $this->applied_discount = array();
00389         //add on to the min_order error message since we have excluded items
00390         if( $this->is_exists_exclusions() ) $this->message( ENTRY_DISCOUNT_COUPON_EXCLUSION_ERROR );
00391       }
00392       if( !$this->is_errors() ) {
00393         //discount shipping if the coupon type is shipping
00394         if( $this->coupon['coupons_discount_type'] == 'shipping' ) {
00395           if($this->cart_info['valid_products']['count']>0){
00396             $this->applied_discount['shipping'] = $info['shipping_cost'] * $this->coupon['coupons_discount_amount'];
00397             $this->applied_discount['shipping'] = $this->applied_discount['shipping'];
00398             $info['total_ht'] -= $this->applied_discount['shipping'];
00399             $info['total'] -= $this->applied_discount['shipping'];
00400           }
00401         }
00402 
00403         if( !_cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_SUBTOTAL')) { //subtract the discount from the order total if it's not displayed in the subtotal
00404           foreach( $this->applied_discount as $discount ) {
00405             $info['total_ht'] -=$discount;
00406             $info['total'] -= $discount;
00407           }
00408         }
00409         if( !_cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_ALLOW_NEGATIVE') && $info['total'] < 0 ) $info['total'] = 0;
00410       }
00411       return $info;
00412     }

discount_coupon::format_display ( tax_group = ''  ) 

Definition at line 426 of file discount_coupon.php.

00426                                                {
00427       global $order, $currencies;
00428 
00429       //if using multiple languages, get the language format string from the proper language file, otherwise, use the module configuration field
00430         $display = ( _cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_USE_LANGUAGE_FILE') ? MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_FILE : MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_CONFIG );
00431 
00432       switch( $this->coupon['coupons_discount_type'] ) {
00433         case 'shipping':
00434           $discount_amount = ( $this->coupon['coupons_discount_amount'] * 100 ).'% '.MODULE_ORDER_TOTAL_DISCOUNT_COUPON_TEXT_SHIPPING_DISCOUNT;
00435           break;
00436         case 'percent':
00437           $discount_amount = ( $this->coupon['coupons_discount_amount'] * 100 ).'%';
00438           break;
00439         case 'fixed':
00440           $discount_amount = $currencies->format( $this->coupon['coupons_discount_amount'] );
00441           break;
00442       }
00443 
00444       $min_order = ( $this->coupon['coupons_min_order'] != 0 ? ( $this->coupon['coupons_min_order_type'] == 'price' ? $currencies->format( $this->coupon['coupons_min_order'] ) : (int)$this->coupon['coupons_min_order'] ) : '' );
00445 
00446       //replace the variables with their proper values:
00447       $display = str_replace( '[code]', $this->coupon['coupons_id'], $display );
00448       $display = str_replace( '[discount_amount]', $discount_amount, $display );
00449       $display = str_replace( '[coupon_desc]', $this->coupon['coupons_description'], $display );
00450       $display = str_replace( '[min_order]', $min_order, $display );
00451       $display = str_replace( '[number_available]', $this->coupon['coupons_number_available'], $display );
00452       $display = str_replace( '[tax_desc]', $tax_group, $display );
00453       return $display;
00454     }

discount_coupon::get_coupon ( code,
delivery 
)

Control de user en exlusion, ou row presente et user en inclusion

Definition at line 39 of file discount_coupon.php.

Referenced by discount_coupon().

00039                                                    {
00040       global $customer_id; //needed for customer_exclusions
00041       $check_code_query = tep_db_query( $sql = "SELECT dc.*
00042                                                 FROM " . TABLE_DISCOUNT_COUPONS . " dc
00043                                                 WHERE coupons_id = '".tep_db_input( $code )."'
00044                                                   AND ( coupons_date_start <= NOW() OR ( coupons_date_start IS NULL OR coupons_date_start = '1000-01-01 00:00:00') )
00045                                                   AND ( coupons_date_end >= NOW() OR ( coupons_date_end IS NULL OR coupons_date_end = '1000-01-01 00:00:00') )" );
00046       if( tep_db_num_rows( $check_code_query ) != 1 ) { //if no rows are returned, then they haven't entered a valid code
00047         $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
00048       } else {
00049 
00050         //customer_exclusions
00051             $check_user_query = tep_db_query( $sql = 'SELECT dc2u.customers_id, dc2u.in_out
00052                                                   FROM '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u
00053                                                   WHERE customers_id='.(int)$customer_id.'
00054                                                     AND coupons_id="'.tep_db_input( $code ).'"' );
00056         if( tep_db_num_rows( $check_user_query ) > 0 ) {
00057           $rctr_2 = tep_db_fetch_array( $check_user_query );
00058           if ($rctr_2['in_out']=='E') $this->message( ENTRY_DISCOUNT_COUPON_ERROR );
00059         }
00060         //shipping zone exclusions
00061         $check_user_query = tep_db_query($sql = 'SELECT dc2z.geo_zone_id
00062                                                   FROM '.TABLE_DISCOUNT_COUPONS_TO_ZONES.' dc2z
00063                                                   LEFT JOIN '.TABLE_ZONES_TO_GEO_ZONES.' z2g
00064                                                     USING( geo_zone_id )
00065                                                   WHERE ( z2g.zone_id='.(int)$delivery['zone_id'].' or z2g.zone_id = 0 or z2g.zone_id IS NULL )
00066                                                     AND ( z2g.zone_country_id='.(int)$delivery['country_id'].' or z2g.zone_country_id = 0 )
00067                                                     AND dc2z.coupons_id="'.tep_db_input( $code ).'"' );
00068 
00069           if (tep_db_num_rows( $check_user_query ) > 0 ) {
00070             $this->message( ENTRY_DISCOUNT_COUPON_ERROR ); //display the error message
00071           //use this to debug exclusions:
00072             //$this->message( 'Shipping Zones exclusion check failed' );
00073           }
00074           //end shipping zone exclusions
00075         $row = tep_db_fetch_array( $check_code_query ); //since there is one record, we have a valid code
00076         $this->coupon = $row;
00077 
00078 //         print_r($this->message);
00079 //         exit;
00080       }
00081     }

discount_coupon::get_messages ( error_level = 'error'  ) 

Definition at line 465 of file discount_coupon.php.

00465                                                     {
00466       if( $error_level == 'debug' ) return $this->messages;
00467       return $this->messages[$error_level];
00468     }

discount_coupon::is_allowed_product ( product_id  ) 

Prend en charge exclusion des products.

Definition at line 193 of file discount_coupon.php.

Referenced by calculate_discount(), and total_valid_products().

00193                                                {
00194       //category exclusion
00195       if( isset($this->cart_info['exclusions']['categories']) && !is_array( $this->cart_info['exclusions']['categories'] ) ) { //only create the array when we need to and only once
00196         //check to see if the product is in one of the limited categories
00197         $check_category_query = tep_db_query( $sql = 'SELECT categories_id
00198                                                        FROM '.TABLE_DISCOUNT_COUPONS_TO_CATEGORIES.'
00199                                                        WHERE coupons_id="'.tep_db_input( $this->coupon['coupons_id'] ).'"' );
00200         $this->cart_info['exclusions']['categories'] = array();
00201         if( tep_db_num_rows( $check_category_query ) > 0 ) {
00202           //for each category, get all the child categories
00203           while( $categories = tep_db_fetch_array( $check_category_query ) ) {
00204             $this->cart_info['exclusions']['categories'][] = $categories['categories_id'];
00205             tep_get_subcategories( $this->cart_info['exclusions']['categories'], $categories['categories_id'] );
00206           }
00207           //$this->excluded_categories are all categories and subcategories excluded from use with the coupon code
00208           $this->cart_info['exclusions']['categories'] = array_unique( $this->cart_info['exclusions']['categories'] );
00209         }
00210       }
00211       if( isset($this->cart_info['exclusions']['categories']) && count( $this->cart_info['exclusions']['categories'] ) > 0 ) {
00212         $c_path = tep_get_product_path( $product_id ); //get the product's cPath
00213         $this_products_catgeory_array = tep_parse_category_path( $c_path ); //convert the product's cPath into an array
00214         //if the product's cPath and the excluded categories array have elements in common, then the product is excluded
00215         $intersection = array_intersect( $this_products_catgeory_array, $this->cart_info['exclusions']['categories'] );
00216         if( is_array( $intersection ) && count( $intersection ) > 0 )  return false;
00217       }
00218       //end category exclusion
00219 
00220       //product exclusion
00221       if(isset($this->cart_info['exclusions']['products']) && !is_array( $this->cart_info['exclusions']['products'] ) ) { //only create the array when we need to and only once
00222         //check to see if the product is in one of the limited categories
00223         $check_product_query = tep_db_query( $sql = 'SELECT products_id FROM '.TABLE_DISCOUNT_COUPONS_TO_PRODUCTS.' WHERE coupons_id="'.tep_db_input( $this->coupon['coupons_id'] ).'"' );
00224         echo $sql;
00225         $this->cart_info['exclusions']['products'] = array();
00226         if( tep_db_num_rows( $check_product_query ) > 0 ) {
00227           while( $products = tep_db_fetch_array( $check_product_query ) ) {
00228             $this->cart_info['exclusions']['products'][] = $products['products_id'];
00229           }
00230         }
00231       }
00232       if(isset($this->cart_info['exclusions']['products']) && count( $this->cart_info['exclusions']['products'] ) > 0 ) {
00233         if( in_array( $product_id, $this->cart_info['exclusions']['products'] ) )  return false;
00234       }
00235       //end product exclusion
00236 
00237       //manufacturer exclusion
00238       if(isset($this->cart_info['exclusions']['manufacturers']) && !is_array( $this->cart_info['exclusions']['manufacturers'] ) ) { //only create the array when we need to and only once
00239         //check to see if the product is in one of the limited categories
00240         $check_manufacturer_query = tep_db_query( $sql = 'SELECT manufacturers_id
00241                                                            FROM '.TABLE_DISCOUNT_COUPONS_TO_MANUFACTURERS.'
00242                                                            WHERE coupons_id="'.tep_db_input( $this->coupon['coupons_id'] ).'"' );
00243         $this->cart_info['exclusions']['manufacturers'] = array();
00244         if( tep_db_num_rows( $check_manufacturer_query ) > 0 ) {
00245           while( $manufacturers = tep_db_fetch_array( $check_manufacturer_query ) ) {
00246             $this->cart_info['exclusions']['manufacturers'][] = $manufacturers['manufacturers_id'];
00247           }
00248         }
00249       }
00250       if(isset($this->cart_info['exclusions']['manufacturers']) && count( $this->cart_info['exclusions']['manufacturers'] ) > 0 ) {
00251         $check_manufacturer_query = tep_db_query( $sql = 'SELECT manufacturers_id
00252                                                            FROM '.TABLE_PRODUCTS.'
00253                                                            WHERE products_id="'.(int)$product_id.'"' );
00254         if( tep_db_num_rows( $check_manufacturer_query ) > 0 ) {
00255           $manufacturers = tep_db_fetch_array( $check_manufacturer_query );
00256           if( in_array( $manufacturers['manufacturers_id'], $this->cart_info['exclusions']['manufacturers'] ) ) {
00257             //use this to debug exclusions:
00258             if( _cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG')) $this->message( 'INFO: Product '.$product_id.' failed manufacturer exclusion check', 'debug' );
00259             return false;
00260           }
00261         }
00262       }
00263       //end manufacturer exclusion
00264 
00265       //specials exclusion
00266       if( _cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_EXCLUDE_SPECIALS')) {
00267         if( ( $special_price = tep_get_products_special_price( $product_id ) ) !== null ) {
00268           $this->cart_info['exclusions']['products'][] = $product_id;
00269           return false;
00270         }
00271       }
00272       //end specials exclusion
00273 
00274       return true;
00275     }

discount_coupon::is_errors (  ) 

Definition at line 456 of file discount_coupon.php.

Referenced by finalize_discount().

00456                          {
00457       if( isset($this->messages['error'] ) /*&& manufacturerscount( $this->messages['error'] ) > 0 */) return true;
00458       return false;
00459     }

discount_coupon::is_exists_exclusions (  ) 

Definition at line 277 of file discount_coupon.php.

Referenced by finalize_discount().

00277                                     {
00278       if( $this->cart_info['valid_products']['total'] != $this->cart_info['total_products']['total'] ) return true;
00279       if( $this->cart_info['valid_products']['count'] != $this->cart_info['total_products']['count'] ) return true;
00280       return false;
00281     }

discount_coupon::is_recalc_shipping (  ) 

Control validité coupon Nombre de coupon dispo.

Definition at line 150 of file discount_coupon.php.

00150                                   {
00151       global $order, $language;
00152 
00153       //calculate the order total:
00154       $order_total = $order->info['total'] - $order->info['shipping_cost'];
00155       if( !_cst_bool('DISPLAY_PRICE_WITH_TAX')) $order_total -= $order->info['tax'];
00156 
00157       //check if there is free shipping
00158       if( _cst_bool('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING')) {
00159         include( DIR_WS_LANGUAGES.$language.'/modules/order_total/ot_shipping.php' );
00160         //if free shipping is enabled, make sure the discount does not bring the order total below free shipping limit
00161         if( $order->info['shipping_method'] == FREE_SHIPPING_TITLE ) { //if free shipping is the selected shipping method
00162           if( $order_total < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER ) { //if the discount lowers the total below the free shipping limit
00163             return true;
00164           }
00165         }
00166       }
00167 
00168       //check if table rate shipping has changed
00169       if( _cst_bool('MODULE_SHIPPING_TABLE_STATUS') ) {
00170         include( DIR_WS_LANGUAGES.$language.'/modules/shipping/table.php' );
00171 
00172         if( substr($order->info['shipping_method'], 0, strlen(MODULE_SHIPPING_TABLE_TEXT_TITLE)) == MODULE_SHIPPING_TABLE_TEXT_TITLE && _cst_bool('MODULE_SHIPPING_TABLE_MODE') ) {
00173           $table_cost = preg_split( "/[:,]/", MODULE_SHIPPING_TABLE_COST );
00174           for( $i = 0; $i < count( $table_cost ); $i += 2 ) {
00175             if( $order_total <= $table_cost[$i] ) {
00176               $shipping = $table_cost[$i+1];
00177               break;
00178             }
00179           }
00180           if( $order->info['shipping_cost'] != $shipping ) { //if the discount lowers the total below the table rate
00181             return true;
00182           }
00183         }
00184       }
00185 
00186       return false;
00187     }

discount_coupon::message ( message,
error_level = 'error' 
)

Definition at line 461 of file discount_coupon.php.

Referenced by calculate_discount(), check_coupons_max_use(), check_coupons_min_order(), finalize_discount(), get_coupon(), and is_allowed_product().

00461                                                          {
00462       $this->messages[$error_level][] = $message;
00463     }

discount_coupon::total_valid_products ( products = array()  ) 

Class order, avant boucle produits this function is for tracking the product totals and count so that we can correctly calculate the discount.

Definition at line 287 of file discount_coupon.php.

00287                                                          {
00288       global $cart,$tax_address,$order;
00289       reset($products);
00290       for( $i = 0; $i < count( $products ); $i++ ) {
00291 //         if (_cst_bool('DISPLAY_PRICE_WITH_TAX')){
00292                         $product_tax = tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']);
00293                         $price = ( tep_add_tax($products[$i]['price'], $product_tax) + $cart->attributes_price( $products[$i]['id'] ) ) * $products[$i]['quantity'];
00294 /*
00295                 }else{
00296                         $price = ( $products[$i]['price'] + $cart->attributes_price( $products[$i]['id'] ) ) * $products[$i]['quantity'];
00297                 }*/
00298         $this->cart_info['total_products']['total'] += $price;
00299         $this->cart_info['total_products']['count'] += $products[$i]['quantity'];
00300         $this->cart_info['total_products']['line_items']++;
00301         if( $this->is_allowed_product( tep_get_prid( $products[$i]['id'] ) ) ) { //not an excluded product
00302           $this->cart_info['valid_products']['count'] += $products[$i]['quantity'];
00303           $this->cart_info['valid_products']['total'] += $price;
00304           $this->cart_info['valid_products']['line_items']++;
00305         }
00306       }
00307     }

discount_coupon::verify_code (  ) 

Definition at line 32 of file discount_coupon.php.

00032                            {
00033       //check the global number of discounts that may be used
00034       if( $this->coupon['coupons_number_available'] == 0 || $this->coupon['coupons_number_available'] <1 ) return false; //$this->check_num_available();
00035       //if coupons_max_use==0, then use is unlimited, otherwise, we need to verify the customer hasn't used this coupon more than coupons_max_use times
00036       if( $this->coupon['coupons_max_use'] != 0 ) $this->check_coupons_max_use();
00037     }


Member Data Documentation

discount_coupon::$applied_discount

Definition at line 18 of file discount_coupon.php.

Referenced by calculate_discount(), and calculate_shown_price().

discount_coupon::$cart_info

Definition at line 18 of file discount_coupon.php.

discount_coupon::$coupon

Definition at line 18 of file discount_coupon.php.

discount_coupon::$messages

Definition at line 18 of file discount_coupon.php.


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