Jump to content
Strider

Credit Class/Gift Vouchers/Discount Coupons 5.10

Recommended Posts

Strider, is it possible for you please post the fix for the GV Tick Box on CHECKOUT_PAYMENT.PHP? I know I can change the Sort Order, but thats just a work-around.

 

By the way, great work. I can see that ALOT of work went into this mod, as well as supporting it. CC/GV has evolved quite a bit since the first versions. I commend your diligence.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

Greg: though I wouldn't mind this being the only thing I do, it isn't. If you are looking for the code to determin the restrictions it is in ot_coupon.php I don't plan any major changes til 2.2.3 comes out because of the differences in the code it will encompass and then it is actually a complete rewrite or at least that is what is planned.

 

Randy: I looked into it over the past week because I too wanted to change it and it isn't as simple as a . here or a quote there. I will look for a hack for you over the weekend and see what comes up. Right now I am just trying to make sure this new code actually plays like it should. If you find one before me give it a share please.


(my knowledge is so small you would think that an ant was a genius in comparison)

Share this post


Link to post
Share on other sites

Hi Strider,

 

I totally understand that you have other things to do and hope your updates for the mod will go smooth and easy.

 

I'll take a closer look at the ot_coupon.php file.

 

Good luck and Happy New Year to you and yours! :D


Running osC - 2.2MS2. P.S. Please don't ask for a link to my site, it is on a production server and not available for the general public, yet!

Share this post


Link to post
Share on other sites
I'm sorry for confusing everyone about the popup window.

 

Yes, Strider the popup I was speaking of is the same one that you speak of being shown in the shopping cart box, I have added the GV/Coupon code from the shopping cart box to the account.php page (picture), so maybe that is why there was so much confusion about my statement from my last post.

Could you post this? - should be added to the contrib.

 

Does anyone have the voucher balance updating? It does not update on orders or if a voucher is emailed to a friend... :(

 

There is no payment method showing in admin orders if a voucher is used...

 

Matti

Edited by Johnson

Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

Ok - I've been testing this somewhat today.

 

If I send myself a gift voucher through admin I am able to redeem that voucher and make purchases with it. This seem fine, however, if 'queue vouchers' is set to 'true' in admin, the amount does not update - therefore I am able to continue to make purchases with it endlessly....scary, particularly when payment method does not show in admin - the order is set to 'processing' during checkout_process, which one would assume means that payment has be received (awaiting payment is the pending notice).

 

So, I must set queue to 'false', then the amount updates, however, as the docs point out, a voucher may be purchased by a method that requires processing in itself, rather than it being immediately available for use.... :blink:

 

Oops, my checkbox in checkout payment just disappeared.... dang!

 

Who said something about three hours...? :unsure:

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

Hi

 

I'm Having some problems with the Coupon admin.

 

After coupons are rehemmed or expired the coupons do not become in active. I have to use MySql to change the status from Y to N

 

When selecting Inactive coupons from the drop down menu it displays the inactive coupons, but when I try to pull a page # from the pull down menu or click the >> link to go to the next page it takes me to the active coupons.

 

My last problem is when a person checks out the Gift Voucher code is no entered on the invoice, so we have to look all of them up manually.

 

Is anyone having similar problems, did I miss some code?

 

 

Any help is appreciated.

 

Joe


----------------------------

Long Island, New York

Share this post


Link to post
Share on other sites

I have also been playing around with this.

 

One thing I just found is this... When someone redeems a Coupon then DOES NOT complete Checkout, even if they empty the Cart Contents and Logout, the Coupon remains ACTIVE and REGISTERED. :unsure:

 

Here is what I did to fix this...

 

Open CATLOG/LOGOFF.PHP and locate the following code...

  tep_session_unregister('customer_id');
 tep_session_unregister('customer_default_address_id');
 tep_session_unregister('customer_first_name');
 tep_session_unregister('customer_country_id');
 tep_session_unregister('customer_zone_id');
 tep_session_unregister('comments');

Add this just BELOW...

  if (tep_session_is_registered('cc_id')) tep_session_unregister('cc_id');

 

Matti, I also see what you mean that there is no Payment Method listed in the Order Details. Thats my next thing to look at.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

Randy the gv is already fixed. I have just been waiting for more testing, or for someone to say something. On the coupons, I don't think if someone doesn't use a coupon that it should become inactive, and in actuality it requires being reentered from the user to be used if they logout without purchasing.

It does not get 'used' til the payment process is complete and it doesn't stay in the cart.

 

 

Applelinks it depends on how your coupons are setup.

If you have 500 uses for a coupon then should they become inactive at 498? or if you have an unlimited amount of coupons but can only be used once per person should they become inactive? .. I don't think the cart should determine if the number of clients you have has been reached. And yes if the admin sets a coupon inactive .. it stays inactive.


(my knowledge is so small you would think that an ant was a genius in comparison)

Share this post


Link to post
Share on other sites

Strider, just to elimate any confusion, here's what I mean...

 

When a customer is going through checkout and enters the redeem code for coupon, a "coupon session" is registered. Which means, when they reach checkout_confirmation, there is an active "coupon session".

 

Now, at this point, lets say the customer decides to NOT to complete checkout, dumps the cart contents, then logs out. The "coupon session" is still registered, and thus, the notice remains in the shopping cart infobox. Its my feeling that the coupon session should be tied to the cart and/or customer sessions.

 

If they dump the cart, but remain logged in, the "coupon session" remains active.

If they dump the cart and logout. the "coupon session" SHOULD BE unregistered (its NOT right now) and must be re-entered if it is to be used at another point in time.

 

The code that I offered in my earlier post accomplishes this functionality.

 

If the customer makes it all the way through checkout, the "coupon session" is unregistered from code called in checkout_process.php. What I am talking about has nothing to do with the expiration of a coupon.

 

Does this make sense? If I am wrong, please tell me so. I guess I see it as kind of a "loose end". I like to minimize my loose ends.

 

Is it possible for you to forward me the updated GV code? That would really be helpful.

 

By the way...

I also modified the gv_redeem page to include an input box. That way, the recipient can redeem by either clicking on the link in the email they receive, or they can visit the redeem page and enter their redeem code in the input box and submit.

 

If you would like me to forward this updated gv_redeem.php to you for inclusion in future releases, I would be happy to do so.

 

Let me know.

 

-R

Edited by ugottasalsa

"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

ugottasalsa: well the coupon id is tied to the instantiation of the class and the users session.

When the person logs out is not the session ended though the class is still there the coupon is discarded as with all the class variables that were registered.

(please try this out with http://www.oscworks.com/work/anew_ccgv/index.php with coupon code test_10_percent)

The coupon is discarded even if there are items in the cart when the person logs out. The coupon is not actually entered as used til checkout process and is then also discarded. It is also discarded during logout.

If you are looking at this in 5.10 then you might be correct in assuming this, I think. Hell I don't really remember, it has changed a few times since then. I changed the way the session variables were handled to be tep compliant instead of php compliant and I missed one or two I think in that release.

 

if you would like to forward your code for the dual purpose gv_redeem that will be fine.


(my knowledge is so small you would think that an ant was a genius in comparison)

Share this post


Link to post
Share on other sites

Yes... I am looking at this in v5.10.

 

I look forward to the updated code. Is there an ETA? Its a new year and I'm hell-bent on getting my demo store finally completed. This is one of the last pieces.

 

PM or email me your email address and I will forward you the new gv_redeem.php.

 

Thanks.


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

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


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites
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.

I just tested and it showed gift vouchers with all payment types - gift voucher/credit card, gift voucher/cheque money order even though the orders were not made using a gift voucher :(


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

Hmmmm.... <_<

 

Matti... do me a favor a check your ORDERS_TOTALS table to see if the ot_gv "VALUE" field is being populated with the GV amount. For me its not.

 

As far as the code goes, the logic is there and it works for me, although I have a highly modified Demo Store with 60+ contribs. The Version is MS2CVS from 11/8/2003. Maybe there is something different between my snapshot and yours.

 

Did you install it into ADMIN/ORDERS.PHP? I know... I know... But, I have to at least ask. :)

 

The code basically checks the ot_total "VALUE" field for 0.0000 based on the Order ID (oID)...

If its 0.0000, it supposed to use GV as the Payment Method, if its not, its supposed to use GV / Payment Method.

 

Make sure that your ORDERS_TOTALS are getting populated correctly.

 

Keep me posted. I'm very interested in your findings.

 

Thanks.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

... yeah I did to. Same result. plus a couple of other problems.


(my knowledge is so small you would think that an ant was a genius in comparison)

Share this post


Link to post
Share on other sites

Upon further testing, you guys were right... I have updated the code and tested it successfully. Please give it a try...

          <tr>
           <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
<?php
   $gv_query = tep_db_query("select class from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$oID . "'");
   while ($gv_value = tep_db_fetch_array($gv_query)) {
     if (in_array('ot_gv', $gv_value)) {
       $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>

 

Let me know if this works okay for you.

 

I am about to do the update that you just released. I'll let you know how it goes.

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

Everything is looking good!!! Great work Strider! So far, all of my testing has been positive!

 

My ORDER_TABLES is populating correctly, and the tick box is working just fine!

 

Now that the Gift Voucher amount VALUE field is now being populated correctly, I have modified the above code I posted earlier to include the actual Amount used for each of the Payment Methods...

 

i.e. Gift Voucher -- $25.00 / Credit Card -- $43.54

 

Once again... Open ADMIN/ORDERS.php and locate the following...

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

And replace it with this code...

          <tr>
           <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
<?php
   $gv_query = tep_db_query("select class, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$oID . "' and class = 'ot_gv'");
   $gv_value = tep_db_fetch_array($gv_query);
    
   if ($gv_value) {
     $gv_amount = $gv_value['value'];
     $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 -- ' . $currencies->format($gv_amount) . ' / ' . $order->info['payment_method'] . ' -- ' . $currencies->format($total_amount);
     } elseif ($total_amount == '0.0000') {
 $method = 'Gift Voucher -- ' . $currencies->format($gv_amount);
     }
?>
           <td class="main"><?php echo $method; ?></td>
<?php
   } else {
?>
           <td class="main"><?php echo $order->info['payment_method']; ?></td>
<?php
   }
?>
         </tr>

Let me know if this works for you. I have only tested it in ADMIN -> ORDERS -> EDIT. Try it there first. As I stated before, this code should work anywhere that the Payment Method is displayed.

 

Thanks again Strider!

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites

If anyone else has CC/GV v5.10 installed and would like to update their install, here are the updates...

-- catalog/checkout_process.php --

LOCATE this...
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment($payment);

REPLACE with this...
 require(DIR_WS_CLASSES . 'payment.php');
 if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS
 $payment_modules = new payment($payment);

LOCATE this...
 $order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM

ADD this above it...
 if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');

 
-- catalog/checkout_payment.php --

LOCATE this...
// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
   if ($cart->cartID != $cartID) {
     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
   }
 }
 
ADD this AFTER it...
// if we have been here before and are coming back get rid of the credit covers variable
 if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');  //ICW ADDED FOR CREDIT CLASS SYSTEM

 
-- catalog/includes/classes/order_totals.php --

LOCATE this function...    function collect_posts() {

 LOCATE this line...
             $post_var = 'c' . $GLOBALS[$class]->code;

 REPLACE with this line...
             $post_var = 'c_' . $GLOBALS[$class]->code;

           
 LOCATE this line...
             if (!tep_session_is_registered('post_var')) tep_session_register('post_var');
           
 REPLACE with this line...
             if (!tep_session_is_registered($post_var)) tep_session_register($post_var);

                       
LOCATE this function...    function pre_confirmation_check() {

 LOCATE this...
         if ($order->info['total'] - $total_deductions <= 0 ) {
           $credit_covers = true;
         }

 REPLACE it with this...
         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');	
   }
           
 
LOCATE this function...    function clear_posts() {

 LOCATE this line...
             $post_var = 'c_' . $GLOBALS[$class]->code;

 REPLACE with this line...
             $post_var = 'c' . $GLOBALS[$class]->code;

           
LOCATE this function...    function get_order_total_main($class, $order_total) {

 LOCATE this...
       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'];
           
 REPLACE it with this...
 //      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'];


-- catalog/includes/classes/payment.php --

LOCATE this function...    function pre_confirmation_check() {

ADD this ABOVE it...
//ICW CREDIT CLASS Gift Voucher System
// check credit covers was setup to test whether credit covers is set in other parts of the code
   function check_credit_covers() {
  global $credit_covers;

  return $credit_covers;
   }

   
-- catalog/includes/modules/order_totals/ot_gv.php --

Upload and Replace with new version of the file.

Strider, did I catch all of the changes? These are the only modifications that I found. If I missed something, I apoligize in advance. I tried to take detailed notes as I made the updates to my Demo Store.

 

Have a great day!

 

-R


"Courage is not the absence of fear, but the awareness of fear and the ability to get past it."

 

It's difficult to diagnose an issue when the patient says, "I have this pain right here Doc, what do you think it is?"

Share this post


Link to post
Share on other sites
Let me know if this works for you. I have only tested it in ADMIN -> ORDERS -> EDIT. Try it there first. As I stated before, this code should work anywhere that the Payment Method is displayed.

Makin progress - great stuff fellas!

 

Ok - so far, in admin->orders

the payment method does not show when vouchers are used.

 

in admin->orders->edit

Payment method does not show beside the heading - it does show below the order total - not sure if it should, but there it is.

 

Still testing.

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

I updated with the latest release, but now cannot redeem a voucher balance. Before the update I could redeem a voucher, but the balance in my account never decreased, now I have a balance, but cannot redeem.. Any ideas where to start to look...

Share this post


Link to post
Share on other sites

I can redeem ok - one little thing - in the browser address bar it shows as "error_message" such and such.... :P

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

such & such? I haven't heard that one.. what kind of error msg... for what function or page

where is my coffee


(my knowledge is so small you would think that an ant was a genius in comparison)

Share this post


Link to post
Share on other sites
I updated with the latest release, but now cannot redeem a voucher balance. Before the update I could redeem a voucher, but the balance in my account never decreased, now I have a balance, but cannot redeem.. Any ideas where to start to look...

In /catalog/includes/classes/order_total.php

 

Find the following:

 

function collect_posts() {

 

and look for the following line:

 

$post_var = 'c_' . $GLOBALS[$class]->code;

 

and change it to:

 

$post_var = 'c' . $GLOBALS[$class]->code;

 

This will take care of showing the redeemed Gift Voucher amount. However, it is still not deducting the redeemed amount from the GV total. I'm still working on that. Any help is appreciated.

Share this post


Link to post
Share on other sites

Hi Johnson,

 

Could you post this?

 

Here it is:

 

the mod

 

As for the errors your receiving, Sorry, I have no idea.

 

Good luck! :D


Running osC - 2.2MS2. P.S. Please don't ask for a link to my site, it is on a production server and not available for the general public, yet!

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

×