Jump to content
Strider

Credit Class/Gift Vouchers/Discount Coupons 5.10

Recommended Posts

Woah I jsut found something wierd, i hope someone can help. Here's what I did. I bought a gift certificate of 5 dollars. Now next time i did a test shop and clicked on redeem when making a purchase using paypal and then I reach the paypal website and it shows the totals but when i accidently clicked back, it went back to the website and my 5 dollars disappeared allthough i never bought anything. Anyone ever experience this?

bump! I did a fresh install with CCGV 5.10b and did all the updates and am still receiving this issue.

Share this post


Link to post
Share on other sites
Two other quick things...

 

Regarding what Matti had pointed out about no Payment Method being displayed while in Order -> Edit.

 

I have come up with a solution... at least for Admin -> Orders -> Edit. I'm sure that this code could easily be added to the other pages that require display of the Payment Method. I haven't gotten that far yet.

 

In ADMIN/ORDERS.PHP, locate the folowing code...

 ? ? ? ? ?<tr>
? ? ? ? ? ?<td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
? ? ? ? ? ?<td class="main"><?php echo $order->info['payment_method']; ?></td>
? ? ? ? ?</tr>

Replace it with this...

 ? ? ? ? ?<tr>
? ? ? ? ? ?<td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
<?php
? ?for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) { 
? ? ?if ($order->totals[$i]['title'] == 'Gift Vouchers:') {
? ? $gv = 'true';
? ? ?}
? ?}
? ?
? ?if ($gv = 'true') {
? $total_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$oID . "' and title = 'Total:'");
? $total_value = tep_db_fetch_array($total_query);
? $total_amount = $total_value['value'];
? 
? if ($total_amount > '0.0000') {
? ? $method = 'Gift Voucher / ' . $order->info['payment_method'];
? ? ?} elseif ($total_amount == '0.0000') {
?$method = 'Gift Voucher';
? ? ?}
?>
? ? ? ? ? ?<td class="main"><?php echo $method; ?></td>
<?php
? ?} else {
?>
? ? ? ? ? ?<td class="main"><?php echo $order->info['payment_method']; ?></td>
<?php
? ?}
?>
? ? ? ? ?</tr>

Here's the logic...

 

1. The first section does a check to see if "Gift Vouchers" is in the ORDER_TOTALS table for this Order. If it is, the $gv is set to true.

 

2. If $gv is true, the second section of code queries the ORDERS_TOTALS table for the actual Total of this Order, and returns its value.

 

3a. If the ot_total value is equal to 0.0000, then...

$method = "Gift Voucher'

 

3b. Otherwise, it is assumed that a combination of Gift Voucher and another form of Payment Method were used, and...

$method = "Gift Voucher / $order ->info['payment_method']

 

4. If the first section of code does not find "Gift Vouchers" in the ORDER_TOTALS tables for this Order, then use the standard Payment Method Output.

 

****************************

 

The second item I wanted to mention has to do with the ORDERS_TOTALS table.

 

Is it just me, or is the VALUE field for Gift Vouchers in the ORDERS_TOTAL table being set to 0.000? The TEXT field seems to be updated with the correct Gift Voucher data from the Order, but the VALUE field is not and subsequently set to 0.0000.

 

The ot_coupon VALUE field is populated correctly.

 

Could this have anything to do with the GV Sessions issue fixed wth the updated code?

 

If the value can be set to the correct amount, then the above code could be modified even further to include another query to get the VALUE of the Gift Voucher used, then display how much was paid by Gift Voucher and how much was paid with the other payment method.

 

i.e. Payment Method: Gift Voucher - $25.00 / Credit Card - $43.97

 

Let me know what you think.

 

-R

Just wondering how did you get this to work on account_history_info.php? I tried doing the same thing and I can't get it to display any payment methods now, I believe it's the sql because it works on all the other pages.

Share this post


Link to post
Share on other sites

Actually I got it fixed by changing the int(Oid) to

(int)$HTTP_GET_VARS['order_id'] and removing the title.

 

Thanks!

Share this post


Link to post
Share on other sites
Hi,

 

I just noticed when a user sends a gift certificate to an unsubscribed user account, and the person clicks on the link, it shows the amount total in the shopping cart, but soon after they become a member the amount disappears from the shopping cart, but is still redeamable through checkout. Is it possible to somehow link the gift certificate amount to the email address that received the item, and when the person creates an account, it'll show up in their shopping cart box?

 

Sorry if this sounds confusing.

 

Thanks again.

Does anyone know a fix for this, i tested this again on a fresh install and get the same issue as before and I believe other people have this issue as well.

 

Thanks again!

Share this post


Link to post
Share on other sites
Hi,

 

I just noticed when a user sends a gift certificate to an unsubscribed user account, and the person clicks on the link, it shows the amount total in the shopping cart, but soon after they become a member the amount disappears from the shopping cart, but is still redeamable through checkout. Is it possible to somehow link the gift certificate amount to the email address that received the item, and when the person creates an account, it'll show up in their shopping cart box?

 

Sorry if this sounds confusing.

 

Thanks again.

NM, this issue works above! =D

Share this post


Link to post
Share on other sites

Ok I finished reading all 126 pages again and got most of the bugs worked out, but for some reason my tax isn't rounding correctly and i'm loosing sales tax of 3 cents on discounts. That sounds little but if u times that by 1000 thats $30.00 lost.

 

For Example [Calculator]:

 

((59.98 + $30.00) - 5.00 CC) * 8.25% = 7.01 [CORRECT]

 

With coupon:

 

((59.95 + 30.00) - $5.00 CC) * 8.25% = 6.97 Tax [iNCORRECT]

-> Loss of 4 cents

 

While reading the entire 126 pages I have tried padding the tax to 6 places in admin->Config.

 

I have also tried the 2 rounding issues mentioned in my above post by Strider and someone else.

 

My Sort order is

 

Discount Coupons 9

Gift Vouchers 740

Low Order Fee

Shipping 15

Sub-Total 1

Tax 12

Total 900

 

I believe this is the most correct way for a customer to read it because in California you don't charge tax on shipping. Also if you put discount coupon after anything other than subtotal as a customer i would assume your giving me a discount on shipping and whatever is above the discount coupon. Also I put gift vouchers last before total so that gift vouchers can pay for all of the above.

 

I have also set:

 

Discount Coupon

 

Display Total

true

 

Sort Order

9

 

Include Shipping

false

 

Include Tax

false

 

Re-calculate Tax

Standard

 

Tax Class

--none--

 

 

Thanks everyone for the help, especially strider for helping everyone!

Edited by talon177

Share this post


Link to post
Share on other sites

ok for some reason the tax decimal place is only padding 3 decimals instead of 4, even if i set tax padding to 4 on admin->config i'm still getting 6.97 instead of 7.01.

Share this post


Link to post
Share on other sites
I just read as much as I can here and didnt find one thing that I just realized is a problem.

 

When you restrict a coupon to a product or category...but then decide on a minimum...It actually only seems to check the total of the valid products to reach the minimum of the coupon. This shouldn't be.

 

Lets say I have X item valid and its a $10 item but I want the coupon to have a $30 minimum to reach that deal...well it only sees the $10 total and wont allow the coupon to work even if I have $50 worth in my cart. If I wanted to make only the valid product or category a $10 minimum than I would set that.

 

I been looking at the code for a couple hours and cant seem to get it right.

 

 

   // OK thats fine for global coupons but what about restricted coupons 
   // where you can only redeem against certain products/categories.
   // and I though this was going to be easy !!!
  $coupon_query=tep_db_query("select coupon_code  from " . TABLE_COUPONS . " where coupon_id='".$cc_id."'");
  if (tep_db_num_rows($coupon_query) !=0) {
    $coupon_result=tep_db_fetch_array($coupon_query);
    $coupon_get=tep_db_query("select coupon_amount, coupon_minimum_order,restrict_to_products,restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code='".$coupon_result['coupon_code']."'");
    $get_result=tep_db_fetch_array($coupon_get);
    $in_cat = true;
    if ($get_result['restrict_to_categories']) {
      $cat_ids = split("[,]", $get_result['restrict_to_categories']);
      $in_cat=false;
      for ($i = 0; $i < count($cat_ids); $i++) {
        if (is_array($this->contents)) {
          reset($this->contents);
          while (list($products_id, ) = each($this->contents)) {
           $cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'");
            if (tep_db_num_rows($cat_query) !=0 ) {
              $in_cat = true;
              $total_price += $this->get_product_price($products_id);
            }
          }
        }      
      }          
    }
    $in_cart = true;
    if ($get_result['restrict_to_products']) {

      $pr_ids = split("[,]", $get_result['restrict_to_products']);

      $in_cart=false;
      $products_array = $cart->get_products();

      for ($i = 0; $i < sizeof($pr_ids); $i++) {
        for ($ii = 1; $ii<=sizeof($products_array); $ii++) {
          if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) {
            $in_cart=true;
            $total_price += $this->get_product_price($products_array[$ii-1]['id']);
          }
        } 
      }
      $order_total = $total_price;         
    }
  }
  return $order_total;
 }  

 

It is most likely here but I havent found out yet how to correct this.

 

Please Please Please help me out.

 

-----

Ok I think I have it.

 

 ? ? if ($get_result['restrict_to_products']) {

? ? ? $pr_ids = split("[,]", $get_result['restrict_to_products']);

? ? ? $in_cart=false;
? ? ? $products_array = $cart->get_products();

// ? ? ? for ($i = 0; $i < sizeof($pr_ids); $i++) {
// ? ? ? ? for ($ii = 1; $ii<=sizeof($products_array); $ii++) {
// ? ? ? ? ? if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) {
// ? ? ? ? ? ? $in_cart=true;
? ? ? ? ? ? ? $total_price += $order_total;
// ? ? ? ? ? }
// ? ? ? ? } 
// ? ? ? }
? ? ? $order_total = $total_price; ? ? ? ? 
? ? }
? }
? return $order_total;
?} ?

 

I commented out the lines that add up the products. Then I changed

 

 ? ? ? ? ? ? $total_price += $this->get_product_price($products_array[$ii-1]['id']);

 

to:

 

 ? ? ? ? ? ? ? $total_price += $order_total;

 

I guess that's about as clean as I can make it. It seems to work as I want and I tested against a few things and it seems ok.

Did anyone get this to work? I'm having the same issues for categories as well.

Share this post


Link to post
Share on other sites

I have just joined this forum.

 

I am stuck up with a problem

 

I am using oscommerce-2.2ms2 and have installed Linda's DownloadController v5.3 MS2.2 and Credit Class/Gift Voucher (ccgb-510b) and everything is working fine except for a small problem.

Suppose I have 50$ as gift voucher amount balance and I purchase a downloadable product of 20$. Now if I use my Gift Voucher amount.

to make the purchase then the download link doesnt appear at the end ... Instead the download message appears (downloads will not happen unless payments are confirmed ). Now in this case since the customer is using his gift voucher amount to pay for that product it should allow him to download instantly.

Note : If the customer has 10$ as gift voucher amount balance and if he is purchasing a downloadable product of 20$ and using his Gift Voucher for partial payment then the download link appears.

 

The conclusion is that if a purchased product is paid entirely with the Gift Voucher amount then the download link doesnt show up whereas if I make part of the payment through my Gift Voucher balance and remaining through other payment method then the download link shows up

 

I am sorry if this question has been asked previously.

Maybe someone else might have had a similar problem

 

Please help......

Any news on this as well.

Share this post


Link to post
Share on other sites

Did you read the instructions? If you turn the module on for gift vouchers it should normally say set queue to true

Edited by talon177

Share this post


Link to post
Share on other sites

I have an interesting error I hope you can help with.

Fatal error: Call to undefined function: count_contents_virtual() in /var/www/html/store/checkout_payment.php on line 76

 

Version 5.10

 

I have followed the instructions the best i could. and Now I have a sql error in the account create area of my store and This error above when I try to checkout.

 

Any help or suggestions would be appreciated. This store is already full of other contributions. its an upgrade i guess :o


Thanks in advance for your help!

Stephen

Share this post


Link to post
Share on other sites
I just read as much as I can here and didnt find one thing that I just realized is a problem.

 

When you restrict a coupon to a product or category...but then decide on a minimum...It actually only seems to check the total of the valid products to reach the minimum of the coupon. This shouldn't be.

 

Lets say I have X item valid and its a $10 item but I want the coupon to have a $30 minimum to reach that deal...well it only sees the $10 total and wont allow the coupon to work even if I have $50 worth in my cart.  If I wanted to make only the valid product or category a $10 minimum than I would set that.

 

I been looking at the code for a couple hours and cant seem to get it right.

 

 

 ? // OK thats fine for global coupons but what about restricted coupons 
? ?// where you can only redeem against certain products/categories.
? ?// and I though this was going to be easy !!!
? $coupon_query=tep_db_query("select coupon_code ?from " . TABLE_COUPONS . " where coupon_id='".$cc_id."'");
? if (tep_db_num_rows($coupon_query) !=0) {
? ? $coupon_result=tep_db_fetch_array($coupon_query);
? ? $coupon_get=tep_db_query("select coupon_amount, coupon_minimum_order,restrict_to_products,restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code='".$coupon_result['coupon_code']."'");
? ? $get_result=tep_db_fetch_array($coupon_get);
? ? $in_cat = true;
? ? if ($get_result['restrict_to_categories']) {
? ? ? $cat_ids = split("[,]", $get_result['restrict_to_categories']);
? ? ? $in_cat=false;
? ? ? for ($i = 0; $i < count($cat_ids); $i++) {
? ? ? ? if (is_array($this->contents)) {
? ? ? ? ? reset($this->contents);
? ? ? ? ? while (list($products_id, ) = each($this->contents)) {
? ? ? ? ? ?$cat_query = tep_db_query("select products_id from products_to_categories where products_id = '" . $products_id . "' and categories_id = '" . $cat_ids[$i] . "'");
? ? ? ? ? ? if (tep_db_num_rows($cat_query) !=0 ) {
? ? ? ? ? ? ? $in_cat = true;
? ? ? ? ? ? ? $total_price += $this->get_product_price($products_id);
? ? ? ? ? ? }
? ? ? ? ? }
? ? ? ? } ? ? ?
? ? ? } ? ? ? ? ?
? ? }
? ? $in_cart = true;
? ? if ($get_result['restrict_to_products']) {

? ? ? $pr_ids = split("[,]", $get_result['restrict_to_products']);

? ? ? $in_cart=false;
? ? ? $products_array = $cart->get_products();

? ? ? for ($i = 0; $i < sizeof($pr_ids); $i++) {
? ? ? ? for ($ii = 1; $ii<=sizeof($products_array); $ii++) {
? ? ? ? ? if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) {
? ? ? ? ? ? $in_cart=true;
? ? ? ? ? ? $total_price += $this->get_product_price($products_array[$ii-1]['id']);
? ? ? ? ? }
? ? ? ? } 
? ? ? }
? ? ? $order_total = $total_price; ? ? ? ? 
? ? }
? }
? return $order_total;
?} ?

 

It is most likely here but I havent found out yet how to correct this.

 

Please Please Please help me out.

 

-----

Ok I think I have it. 

 

 ? ? if ($get_result['restrict_to_products']) {

? ? ? $pr_ids = split("[,]", $get_result['restrict_to_products']);

? ? ? $in_cart=false;
? ? ? $products_array = $cart->get_products();

// ? ? ? for ($i = 0; $i < sizeof($pr_ids); $i++) {
// ? ? ? ? for ($ii = 1; $ii<=sizeof($products_array); $ii++) {
// ? ? ? ? ? if (tep_get_prid($products_array[$ii-1]['id']) == $pr_ids[$i]) {
// ? ? ? ? ? ? $in_cart=true;
? ? ? ? ? ? ? $total_price += $order_total;
// ? ? ? ? ? }
// ? ? ? ? } 
// ? ? ? }
? ? ? $order_total = $total_price; ? ? ? ? 
? ? }
? }
? return $order_total;
?} ?

 

I commented out the lines that add up the products.  Then I changed

 

 ? ? ? ? ? ? $total_price += $this->get_product_price($products_array[$ii-1]['id']);

 

to:

 

 ? ? ? ? ? ? ? $total_price += $order_total;

 

I guess that's about as clean as I can make it.  It seems to work as I want and I tested against a few things and it seems ok.

Did anyone get this to work? I'm having the same issues for categories as well.

Ok doing this actually works, but still have a few kinks to fix.

 

For example:

 

Rules: Coupon Restriction $30.00, Coupon = $5.00

 

 

Products in cart:

 

Gift Certificate 5.00

Matrix 29.99

 

Subtotal: 34.99

 

So at the moment it's calculating the coupon before and the subtotal making it 29.99. Instead of doing 34.99 - 5.00.

 

Also restriction_to_categories needs fixing.

Share this post


Link to post
Share on other sites
I have an interesting error I hope you can help with.
Fatal error: Call to undefined function: count_contents_virtual() in /var/www/html/store/checkout_payment.php on line 76

 

Version 5.10

 

I have followed the instructions the best i could. and Now I have a sql error in the account create area of my store and This error above when I try to checkout.

 

Any help or suggestions would be appreciated. This store is already full of other contributions. its an upgrade i guess :o

Ok sounds cool, u said your using 5.10, do you mean 5.10b? Also did you use beyond compare to compare files to make sure u loaded all the 5.10b?

 

Also what's on line 76

Edited by talon177

Share this post


Link to post
Share on other sites

Can someone please, please help me out here. I have posted this 3 times now without anyanswers.

 

I have successfully installed this contribution with just one file that is causing an issue and that is catalog/includes/classes/order_total.php on line 14.

 

Here is that file

 

 

  
<?php
/*
$Id: order_total.php,v 1.3.2.7 2003/05/14 22:52:58 wilt Exp $
orig : order_total.php,v 1.4 2003/02/11 00:04:53 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class order_total {
  var $modules;

// class constructor
  function order_total() {
    global $language;

    if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
      $this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);

      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        include(DIR_WS_LANGUAGES . $language . '/modules/order_total/' . $value);
        include(DIR_WS_MODULES . 'order_total/' . $value);

        $class = substr($value, 0, strrpos($value, '.'));
        $GLOBALS[$class] = new $class;
      }
    }
  }

  function process() {
    $order_total_array = array();
    if (is_array($this->modules)) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ($GLOBALS[$class]->enabled) {
          $GLOBALS[$class]->process();

          for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
            if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
              $order_total_array[] = array('code' => $GLOBALS[$class]->code,
                                           'title' => $GLOBALS[$class]->output[$i]['title'],
                                           'text' => $GLOBALS[$class]->output[$i]['text'],
                                           'value' => $GLOBALS[$class]->output[$i]['value'],
                                           'sort_order' => $GLOBALS[$class]->sort_order);
            }
          }
        }
      }
    }

    return $order_total_array;
  }

  function output() {
    $output_string = '';
    if (is_array($this->modules)) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ($GLOBALS[$class]->enabled) {
          $size = sizeof($GLOBALS[$class]->output);
          for ($i=0; $i<$size; $i++) {
            $output_string .= '              <tr>' . "\n" .
                              '                <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['title'] . '</td>' . "\n" .
                              '                <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['text'] . '</td>' . "\n" .
                              '              </tr>';
          }
        }
      }
    }

    return $output_string;
  }
// ICW ORDER TOTAL CREDIT CLASS/GV SYSTEM - START ADDITION
//
// This function is called in checkout payment after display of payment methods. It actually calls
// two credit class functions.
//
// use_credit_amount() is normally a checkbox used to decide whether the credit amount should be applied to reduce
// the order total. Whether this is a Gift Voucher, or discount coupon or reward points etc.
//
// The second function called is credit_selection(). This in the credit classes already made is usually a redeem box.
// for entering a Gift Voucher number. Note credit classes can decide whether this part is displayed depending on
// E.g. a setting in the admin section.
//
  function credit_selection() {
    $selection_string = '';
    $close_string = '';
    $credit_class_string = '';
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      $header_string = '<tr>' . "\n";
      $header_string .= '   <td><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
      $output1_string .= '      <tr>' . "\n";
      $header_string .= '        <td class="main"><b>' . TABLE_HEADING_CREDIT . '</b></td>' . "\n";
      $header_string .= '      </tr>' . "\n";
      $header_string .= '    </table></td>' . "\n";
      $header_string .= '  </tr>' . "\n";
      $header_string .= '<tr>' . "\n";
      $header_string .= '   <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">' . "\n";
      $header_string .= '     <tr class="infoBoxContents"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">' ."\n";
     $header_string .= '       <tr><td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n";
      $header_string .= '           <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";
      $close_string   = '                           </table></td>';
      $close_string  .= '<td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
      $close_string  .= '</tr></table></td></tr></table></td>';
      $close_string  .= '<tr><td width="100%">' .  tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
      reset($this->modules);
      $output_string = '';
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) {
          $use_credit_string = $GLOBALS[$class]->use_credit_amount();
          if ($selection_string =='') $selection_string = $GLOBALS[$class]->credit_selection();
          if ( ($use_credit_string !='' ) || ($selection_string != '') ) {
            $output_string .=  '<tr colspan="4"><td colspan="4" width="100%">' .  tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
            $output_string = ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" >' . "\n" .
                             '   <td width="10">' .  tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' .
                             '     <td class="main"><b>' . $GLOBALS[$class]->header . '</b></td>' . $use_credit_string;
            $output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';
            $output_string .= '  </tr>' . "\n";
            $output_string .= $selection_string;
          }

        }
      }
      if ($output_string != '') {
        $output_string = $header_string . $output_string;
        $output_string .= $close_string;
      }
    }
    return $output_string;
  }


//            if ($selection_string !='') {
//              $output_string .= '</td>' . "\n";
//              $output_string .= $selection_string;
//            }




// update_credit_account is called in checkout process on a per product basis. It's purpose
// is to decide whether each product in the cart should add something to a credit account.
// e.g. for the Gift Voucher it checks whether the product is a Gift voucher and then adds the amount
// to the Gift Voucher account.
// Another use would be to check if the product would give reward points and add these to the points/reward account.
//
  function update_credit_account($i) {
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
          $GLOBALS[$class]->update_credit_account($i);
        }
      }
    }
  }
// This function is called in checkout confirmation.
// It's main use is for credit classes that use the credit_selection() method. This is usually for
// entering redeem codes(Gift Vouchers/Discount Coupons). This function is used to validate these codes.
// If they are valid then the necessary actions are taken, if not valid we are returned to checkout payment
// with an error
//
  function collect_posts() {
    global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
          $post_var = 'c' . $GLOBALS[$class]->code;
          if ($HTTP_POST_VARS[$post_var]) {
      if (!tep_session_is_registered($post_var)) tep_session_register($post_var);
     $post_var = $HTTP_POST_VARS[$post_var];
    }
          $GLOBALS[$class]->collect_posts();
        }
      }
    }
  }
// pre_confirmation_check is called on checkout confirmation. It's function is to decide whether the
// credits available are greater than the order total. If they are then a variable (credit_covers) is set to
// true. This is used to bypass the payment method. In other words if the Gift Voucher is more than the order
// total, we don't want to go to paypal etc.
//
  function pre_confirmation_check() {
    global $payment, $order, $credit_covers;
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      $total_deductions  = 0;
      reset($this->modules);
      $order_total = $order->info['total'];
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        $order_total = $this->get_order_total_main($class,$order_total);
        if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
          $total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
          $order_total = $order_total - $GLOBALS[$class]->pre_confirmation_check($order_total);
        }
      }
      if ($order->info['total'] - $total_deductions <= 0 ) {
   if(!tep_session_is_registered('credit_covers')) tep_session_register('credit_covers');
        $credit_covers = true;
      }
  else{   // belts and suspenders to get rid of credit_covers variable if it gets set once and they put something else in the cart
   if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers'); 
  }
    }
  }
// this function is called in checkout process. it tests whether a decision was made at checkout payment to use
// the credit amount be applied aginst the order. If so some action is taken. E.g. for a Gift voucher the account
// is reduced the order total amount.
//
  function apply_credit() {
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
          $GLOBALS[$class]->apply_credit();
        }
      }
    }
  }
// Called in checkout process to clear session variables created by each credit class module.
//
  function clear_posts() {
    global $HTTP_POST_VARS,$HTTP_SESSION_VARS;
    if (MODULE_ORDER_TOTAL_INSTALLED) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ( ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) ) {
          $post_var = 'c' . $GLOBALS[$class]->code;
           if (tep_session_is_registered($post_var)) tep_session_unregister($post_var);
        }
      }
    }
  }
// Called at various times. This function calulates the total value of the order that the
// credit will be appled aginst. This varies depending on whether the credit class applies
// to shipping & tax
//
  function get_order_total_main($class, $order_total) {
    global $credit, $order;
//      if ($GLOBALS[$class]->include_tax == 'false') $order_total=$order_total-$order->info['tax'];
//      if ($GLOBALS[$class]->include_shipping == 'false') $order_total=$order_total-$order->info['shipping_cost'];
    return $order_total;
  }
// ICW ORDER TOTAL CREDIT CLASS/GV SYSTEM - END ADDITION
}
?>

 

 

 

This is what is on line 14 in my editor:

 

class order_total {

 

Basically when trying to purchase something as soon as I click to continue from payment information I just get a blank screen with the following at the top:

 

Fatal error: Cannot redeclare class order_total in /home/popcorn/public_html/catalog/includes/classes/order_total.php on line 14

 

Can anyone solve this problem for me?

 

Mark

Share this post


Link to post
Share on other sites

Hi,

 

after installing this great contribution everything worked out fine but I am now having some major problems with enableing the downloads.

 

If downloads are disabled, there is the correct calculation of subtotal, tax, gv- amount and total but right after enabeling the downloads all tax calculation got lost ... there iss just the products price without tax, gv-amount and the total left ... all excluding tax.

 

I've read about 60 pages within this thread (right form the release of v510b on) but I still got no idea in what is going wrong ! Any ideas or hints ? Thank you ...

 

Sebastian

 

(v510b on MS2 - but WITH B2B Suite)

Share this post


Link to post
Share on other sites

:blink: Hi guys...

 

Im wondering if you could please help. Just finished going through the 120+ pages here for an answer but no luck:(

 

Ok, my problem. I use a TOTALLY different checkout system, which means all I do is pass the variables in my basket to another page(different company) which processes the login, basket info etc.

 

So what I need, and this contrib kinda does it for me but to totally. If I add a product into my catalog with a negative price, it works as a gift voucher and subtracts that amount from the total in my basket - thats a nice feature which has been implemented in my site!! ie : This is what happens!!!!

 

Now, is there ANY way this could work with a % ammount????? Im desparate. I need a way that it would work out the percentage of the total value in the cart and discount it by that amount?? I would then need to pass it on as a product with a negative value to processing payment page(the non-oscommerce one)

 

Thanks guys for any suggestions/help!!! :ph34r:

Share this post


Link to post
Share on other sites

Here's an interesting challenge for all the experts on order totalling.

 

I have a home party business in addition to e-commerce. My home party reps use a coupon code to get their discount. They should not be charged tax, even if they would normally be charged tax as a regular customer in their state.

 

I need to detect the home party coupon code and then exclude tax from the order.

 

The home party coupon code is distinct (it starts with "hp") so I can detect it. Now I need to know in what file I should trip the checkout to exclude tax, and what the most efficient way to do that is. I use the Credit Class & Gift Voucher contribution.

 

Anyone know?

Share this post


Link to post
Share on other sites

Multiple coupon support

 

Our client needs for customers to be able to enter multiple coupons at checkout.

 

But despite talk of coupons (plural) throughout the module I can't seem to get more than one working per order..

 

For example, under checkout_payment.php's Credits Available header, it says Gift Vouchers/Discount Coupons" and again on the order confirmation.

 

So.. Does anyone here have experience with enabling or adding such a thing? I was thinking that worst-case scenario I would continue what I've been working on.. Which is to try adding multiple input boxes with distinct names and then cut and pasting insteances of processing code to handle them.. or something.

Share this post


Link to post
Share on other sites

Hi All,

After processing the order, which variable would indicate the total discount amount?

or How would I extract the total discount amount wether it was a Coupon or a Voucher?

 

I would like to have this information so it will be automatically inserted into my QuickBooks import file.

 

Thank you,

Ron Peled

Share this post


Link to post
Share on other sites

Talon Thanks so much for the response. I actually fixed the problem. Had to do with a couple of other contributions I am using.

Thanks though


Thanks in advance for your help!

Stephen

Share this post


Link to post
Share on other sites

For orders using a voucher when tax is calculated, I'm getting a total amount of 0.01 when is should be 0.00. I'm not recaculating tax or anything...anyone have any ideas why this is happening and what to do about it?

 

Thanks for your help!

Share this post


Link to post
Share on other sites

Hi

I would like to use the discount coupon and not the gift voucher. Are there anyways to separate the two. I would like to install the discount coupon only. Any help would be appreciated.

 

Thanks. :rolleyes:

Share this post


Link to post
Share on other sites

Has anyone gotten the restrict to categories or products to work with tax? If you look at the tax calculations it's adding the tax before discounting the coupons.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×