Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Credit Class/Gift voucher/Discount Coupon v5


Ian

Recommended Posts

  • Replies 499
  • Created
  • Last Reply

Top Posters In This Topic

I also intend to revert back to having separate boxes for GV and discount coupon redeems. The current code that shows only one box is a pretty poor kludge and I can't abide the code that does that. It also may affect future credit class modules, so it has to go.

 

I think that is a really good idea for another reason that may not have been thought of. What if a user has a GV and a DC to use on the same order? That is currently not possible. Having separate boxes for each resolves this dilemma!

 

Take some Valerian Root and get a good 6 hours sleep and you will be amazed at how much better your mind and body works. ;)

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Just a quick observation after installing 5.0.3:

 

In adminincludesadd_ccgvdc_application_top.php look for:

 

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "'");

 

it should be:

 

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");

 

(there is one bracket missing)

 

Cheers and thanx Ian for this outstanding contribution!

 

- D. Michael

Link to comment
Share on other sites

Ian,

 

DO you have two versions of the 5.0.3 going around

 

 

Just a quick observation after installing 5.0.3:  

 

In adminincludesadd_ccgvdc_application_top.php look for:  

 

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "'");  

 

it should be:  

 

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");  

 

(there is one bracket missing)  

 

I just downloaded the version here http://www.oscommerce.com/community/contributions,282

 

and the code in that file reads diffrent :

 

  function tep_gv_account_update($customer_id, $gv_id) {

   $customer_gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'");

   $coupon_gv_query = tep_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . $gv_id . "'");

   $coupon_gv = tep_db_fetch_array($coupon_gv_query);

   if (tep_db_num_rows($customer_gv_query) > 0) {

     $customer_gv = tep_db_fetch_array($customer_gv_query);

     $new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount'];

     $gv_query = tep_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_gv_amount . "'");

   } else {

     $gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "'");

   }

 }

 

And if so which is the most recent?

 

Thank for the wonderful work. It's a piece of art :lol:

Link to comment
Share on other sites

You are right

 

DO you have two versions of the 5.0.3 going around

 

There must be two versions, the one I remember had no bugs at all in it :lol:

 

If you look at the last line of the code you posted

 

      $gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "'");

 

it should be

 

      $gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");

Trust me, I'm an Accountant.

Link to comment
Share on other sites

Melinda

 

It's there, but you need to get in the right frame of mind.

 

Drink 5 bottles of grolsch lager and then while downloading you must chant continually.

 

If peter piper picked a peck of pickled peppers, where's the peck of pickled peppers peter piper picked.

 

If you make a mistake with the chant you will be damned to the version with bugs :twisted:

Trust me, I'm an Accountant.

Link to comment
Share on other sites

I guess thats what I get for looking to close LOL

 

I was looking for 2 lines because thats the way it wraped in the first message.....

 

I just need to step back and put on some sunscreen and aloe to protect form the radiation off the monitor.

 

Cheers,

Link to comment
Share on other sites

hello, great mod Ian, i'm having one problem tho, everything seems to be working except paying from my GV account.

 

i just bought ?30 of vouchers, they are showing in the account but when i want to purchase something with them i cant see any box to tick. what page should it be on? i hope someone can help bcos my php is zero :oops:

 

thx

Kinky.

Link to comment
Share on other sites

Ian, I have a suggestion regarding the GV FAQ page.

 

As everyone likes things different ways, I wanted to put it here in the forum to get everyone else's opinion.

 

Could you make the page have the FAQ topics at the top, then a horizontal rule, and then the contents of the FAQ? When a user clicks on a topic, they are moved to the appropriate bookmarked answer within the same page?

 

I personally hate pages that make me click for every answer instead of being able to scroll through the list of answers. Such is the reason for my request.

 

Let me know if the above does not make sense or if you would like any additional information.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Hi Ian all the rest,

I am trying to get the GV contribution to work with the Paypal IPN (0.971) contribution and could use some ideas from you. My idea is to add the same GV code that you have added to checkout_process.php and checkout_confirmation.php to the Paypal IPN contribution.

 

As you pointed out before, the PayPal IPN contribution use it's own process and confirmation code, which is checkout_paypalipn.php and paypal_notify.php.

 

The things here is that paypal_notify.php is "redirected" from PayPal itself. This means that session vars may be old/deleted etc and you can not trust it's there anymore. My idea then is to update the file checkout_paypalipn.php with the same GV code. The file checkout_paypalipn.php contains code which save an order (with all products and attributes etc) to the database, unregister session vars and redirecting to PayPal. If you update the file checkout_paypalipn.php with:

 

<?php

/*

 $Id: checkout_paypalipn.php,v 0.971 2003-20-02 10:56:31 pablo_pasqualino Exp pablo_pasqualino $

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



...

$order_total_modules->update->credit_account($i);

...

$order_total_modules->apply_credit();

...

if ($credit_covers) $payment='';

$payment_modules = new payment($payment);

$payment_modules->update_status();



$order_total_modules = new order_total;

$order_total_modules->collect_posts();

$order_total_modules->pre_confirmation_check();



if ( (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$payment)) && (!$credit_covers) ) {

 tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));

}



if (is_array($payment_modules->modules)) {

 $payment_modules->pre_confirmation_check();

}

... 

//unregister session vars

$order_total_modules->clear_posts();

...

tep_redirect("https://www.paypal.com/cgi.....")

 

There is one issue (at least) with this and that is if a customer aborts the confirmation at PayPal then the GV and/or DC will be gone since the coupon/GV is marked as redeemed. I guess that if you inform about this then it's ok.

 

Any thoughts about this? All input on this is appreciated.

 

/Fred

Link to comment
Share on other sites

look in

 

catalog/includes/add_application_top.php or catalog/includes/add_ccgvdc_application_top.php if you have v5.03.

Trust me, I'm an Accountant.

Link to comment
Share on other sites

ok i can disable it, what would i need to do to give 10% instead of ?10?

 

 

// Set the coupon ID that will be sent by email to a new signup, if no id is set then no email :)

define('NEW_SIGNUP_DISCOUNT_COUPON', '3');

 

how do i find a coupon id? does this mean i could make a new coupon in admin and assign that to emails?

 

thx

Kinky.

Link to comment
Share on other sites

I respect your patience Ian, however, I am concerned to see so many people ask for answers in a demanding manner! I hope you recieve good amounts of Paypal donations... You deserve it! :oops: :shock: :roll:

Link to comment
Share on other sites

Hello Ian,

 

I installed the v.503 and it works (untill now) without any promlems. With the new install file it is much easier. Thank you!!!

 

I have one question about some files. Do I still need the file gv_redeem.php, since when I click on it, it does not appear even though it is under catalog/gv_redeem.php. And what for is the file coupon_restrict?

 

Thank you in advance

 

Devon

Link to comment
Share on other sites

I noticed something: I sent a gift voucher as a test. I redeemed the voucher from the email link, but I didn't log into my account & I closed the browser window. The funds from the coupon are gone.

 

Is this fixed in the newest 5.03 version? (I am currently running 5.02)

Link to comment
Share on other sites

Ian:

 

What happens if the voucher makes the total payment worth $0?

 

If I have Credit Card or paypal setup it still goes to the page.

 

For now I've put in the cash option, but is there a way to add a comment or maybe your script can detect a total price of $0 and put a message to choose the cash option?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...