Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Credit Class/Gift Vouchers/Discount Coupons 5.10


Strider

Recommended Posts

I made a change to the CCVG v5.15 code in /includes/classes/order_total.php. It is a cosmetic change that separates Redeem and the Tick box for credit application. I am posting it in case someone likes the way it looks on the page and wants to do the same thing.

 

Here is what it looks like:

 

003.jpg

 

Here is the code change in /includes/classes/order_total.php at around line 91. This replaced the "function credit_selection()" section:

 

// BEGIN >>> Contribution CCVG v5.15 - Custom Modification to separate Redeem from Tick box.

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";

$header_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";

$header2_string = '<tr>' . "\n";

$header2_string .= ' <td><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n";

$header2_string .= ' <tr>' . "\n";

$header2_string .= ' <td class="main"><b>' . TABLE_HEADING_CREDIT2 . '</b></td>' . "\n";

$header2_string .= ' </tr>' . "\n";

$header2_string .= ' </table></td>' . "\n";

$header2_string .= ' </tr>' . "\n";

$header2_string .= '<tr>' . "\n";

$header2_string .= ' <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">' . "\n";

$header2_string .= ' <tr class="infoBoxContents"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">' ."\n";

$header2_string .= ' <tr><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n";

$header2_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 = '';

$credit_string = '';

$apply_credit_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 = ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' .

' <td class="main"><b>' . $GLOBALS[$class]->header . '</b></td>';

$output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';

$output_string .= ' </tr>' . "\n";

$output_string .= $selection_string;

if ($use_credit_string != '' ) {

$apply_credit_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>' . '</b></td>' . $use_credit_string;

$apply_credit_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';

$apply_credit_string .= ' </tr>' . "\n";

}

}

}

}

if ($output_string != '') {

$output_string = $header_string . $output_string . $close_string;

if ($apply_credit_string != '') {

$credit_string = $header2_string . $apply_credit_string . $close_string;

}

$output_string .= $credit_string;

}

}

return $output_string;

}

// END <<< Contribution CCVG v5.15 - Custom Modification to separate Redeem from Tick box.

 

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

 

Also in /catalog/includes/languages/english.php, add this line:

 

define('TABLE_HEADING_CREDIT2', 'Certificate/Coupon Application');

 

Hope this helps out in some way....

 

Joe

 

Joe

 

I think it would be a real value to add a case switch to that setup. If voucher value is > than 0, then display voucher value within table " Apply my $XXX.XX E-Gift Credit" > checkbox and I'm not sure but if no voucher is present, table is invisible completely to clean up the screen

 

Chris

Edited by kittmaster
Link to comment
Share on other sites

  • Replies 4.8k
  • Created
  • Last Reply

Top Posters In This Topic

Chris,

 

when i use the 123 coupon and click redeem, it takes me to the checkout_confirmation.php page with the coupon applied, although there is no message indicating it's applied. it only shows up as the Discount Coupons:123 -25.00 line item in the order totals. BUT, if i use the browser's back button to go back to the checkout_payment.php page and enter the coupon again, it then keeps me on the checkout_payment.php page and displays the notice that my coupon has been applied (The coupon code is valid and has been successfully applied for the amount of $25.00 on orders greater than $1.00 and has been discounted from the final total.).

Link to comment
Share on other sites

Chris,

 

when i use the 123 coupon and click redeem, it takes me to the checkout_confirmation.php page with the coupon applied, although there is no message indicating it's applied. it only shows up as the Discount Coupons:123 -25.00 line item in the order totals. BUT, if i use the browser's back button to go back to the checkout_payment.php page and enter the coupon again, it then keeps me on the checkout_payment.php page and displays the notice that my coupon has been applied (The coupon code is valid and has been successfully applied for the amount of $25.00 on orders greater than $1.00 and has been discounted from the final total.).

 

I'll look at that, I'll must have forgot the message redirector for that section since I've rewritten part of that section.

Link to comment
Share on other sites

Joe

 

I think it would be a real value to add a case switch to that setup. If voucher value is > than 0, then display voucher value within table " Apply my $XXX.XX E-Gift Credit" > checkbox and I'm not sure but if no voucher is present, table is invisible completely to clean up the screen

 

Chris

 

 

Chris, the code already will only display the Tick box section if you have a credit you want to apply. The Redeem section is always displayed. I like your idea of adding the amount and will work that. I do not think it will be too hard. Will post when this is done, probably tomorrow...the wife is getting on me for too much computer time :-" .

 

Thanks,

 

Joe

Link to comment
Share on other sites

I think I found another small bug in CCVG v5.15. If you send a voucher to someone via e-mail, if someone intercepts the e-mail and logs into the web site with any e-mail account, they get the voucher money and not the intended recipient. It seems there is no validation against the e-mail address recipient. Not too bad but something we probably should fix in the future.

 

Joe

Link to comment
Share on other sites

I am having the same exact problem.

 

 

 

You guys may want to wait until we can get this sorted out. Right now we are in the process of correcting these issues. The code in the last few pages are for the people who have PHP skills who can apply this information to their sites to get it working correctly. The only operative word here is to have some patience while we get the final fixes in place

 

Chris

Link to comment
Share on other sites

QUOTE(nerditup @ Dec 21 2005, 08:44 PM) *

 

Maybe someone can help w/ my problem. Installed the CCGV system. I created a coupon and when I test it out, the first time I enter the coupon, I get this message:

 

The coupon has been successfully applied for <BR>***HOWEVER:No reducion available, please see the coupon restrictions***

The second time i enter the same coupon, it works just fine. Any ideas?

 

 

yeah because the message redeem has been hacked so many times for both a non functioning module to double repeated error message with incorrect points, it keeps selecting the wrong messages for the right transaction.

 

I'm working on it as we speak, but most likely won't have a final update until late tonight or tomorrow

 

Chris

 

Chris, I have resolved the issue where entering the coupon code the first time produces an error but entering the coupon code the second time works as expected. I found the $cc_id variable was not set when calling the $ot_coupon->pre_confirmation_check subroutine causing the problem. To fix the problem:

 

In /catalog/includes/modules/order_total.php

 

Find this code around line 146:

 

if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');

$cc_id = $coupon_result['coupon_id'];

 

Remove it and relocate to around line 136 and just after:

 

global $order,$ot_coupon,$currency;

 

if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');

$cc_id = $coupon_result['coupon_id'];

 

Moving it up allows the $cc_id variable to get populated before calling the pre_confirmation_check subroutine.

 

Joe

Link to comment
Share on other sites

Chris, I have resolved the issue where entering the coupon code the first time produces an error but entering the coupon code the second time works as expected. I found the $cc_id variable was not set when calling the $ot_coupon->pre_confirmation_check subroutine causing the problem. To fix the problem:

 

In /catalog/includes/modules/order_total.php

 

Find this code around line 146:

 

if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');

$cc_id = $coupon_result['coupon_id'];

 

Remove it and relocate to around line 136 and just after:

 

global $order,$ot_coupon,$currency;

 

if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');

$cc_id = $coupon_result['coupon_id'];

 

Moving it up allows the $cc_id variable to get populated before calling the pre_confirmation_check subroutine.

 

Joe

 

Joe

 

Already set up that way as suggested, I'm still diggin around. Xmas is killing me......LOL......got to get them gifts.......I'll be on this for the next few hours or until fix is found..........god willing.....

 

Here is the code as it stands:

 

 

		global $order,$ot_coupon,$currency;

	$coupon_amount= tep_round($ot_coupon->pre_confirmation_check($order->info['subtotal']), $currencies->currencies[$currency]['decimal_places']); // $cc_id
/* you will need to uncomment this if your tax order total module is AFTER shipping eg you have all of your tax, including tax from shipping module, in your tax total.
	if ($coupon_result['coupon_type']=='S')  {
		//if not zero rated add vat to shipping
		$coupon_amount = tep_add_tax($coupon_amount, '17.5');
	}
*/
	$coupon_amount_out = $currencies->format($coupon_amount) . ' ';
	if ($coupon_result['coupon_minimum_order']>0) $coupon_amount_out .= 'on orders greater than ' . $currencies->format($coupon_result['coupon_minimum_order']) . ' and has been discounted from the final total.';

	if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');
	$cc_id = $coupon_result['coupon_id'];

	if ( strlen($cc_id)>0 && $coupon_amount==0 ) {
		$err_msg = ERROR_REDEEMED_AMOUNT . ERROR_REDEEMED_AMOUNT_ZERO;
		//<BR><STRONG>Please Note:</STRONG><BR>If the form fields are missing, just click on the payment option button below to view the form fields <I>again</I>;
	} else {
		$err_msg = ERROR_REDEEMED_AMOUNT . $coupon_amount_out;
		tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode($err_msg), 'SSL'));
	}


if ($HTTP_POST_VARS['submit_redeem_coupon_x']) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL'));
}

Link to comment
Share on other sites

here's another request.......

 

who has their voucher balance showing in the header?

 

can anyone please share the code... thanks

Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Link to comment
Share on other sites

it seems my coupon code is working now, but when i click continue from the checkout_payment to checkout_confirmation page, I get this error:

 

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /home/.informant/account/mydomain.com/includes/functions/database.php:13) in /home/.informant/account/mydomain.com/includes/functions/database.php on line 13

 

 

I haven't added/deleted anything such as includes or requires. i'm not sure how it's being declared twice. what files are used in that process that i should be looking in? i looked in checkout_payment and checkout_confirmation already with no luck.

Edited by nerditup
Link to comment
Share on other sites

You guys may want to wait until we can get this sorted out. Right now we are in the process of correcting these issues. The code in the last few pages are for the people who have PHP skills who can apply this information to their sites to get it working correctly. The only operative word here is to have some patience while we get the final fixes in place

 

Chris

 

 

Chris, et al,

 

You guys are awesome! I have been wanting to add this contribution to my site for some time now, but with so many different versions and various issues needing resolved, I have been very hesitant to even attempt to install it on my modded store (70+ contribs) especially after reading through this thread. I have gained a great deal of PHP skills by installing all these contribs, but my skills are still somewhat limited and I don't think I would be much help here.

 

I just wanted to say thank you for all your hard work as I patiently (albiet somewhat anxiously (w00t) ) await a stable (if that is possible in osCommerce) version. I realize it might be awhile, but totally understand.

 

Thanks again to everyone who is trying to make this great contribution even better! :thumbsup:

 

John

Link to comment
Share on other sites

i installed the latest version 5.15 on a brand new installation of OSc 2.2 ms2 and it doesn't work at all.

I've spent days installing, reinstalling, configuring, drinking, screaming, throwing stuff, reinstalling, twitching, reading, contemplating tall bridges, reinstalling, etc.

 

for the love of god can someone get a Full Package that works with a fresh install of OSC working in the contributions area.

 

-n

Link to comment
Share on other sites

I have a general question... I have applied shipping modules that calculate shipping based on the price of the shopping cart. When someone orders a gift certificate with other purchase, or by itself, shipping is calculated. Is there any way to fix this issue?

 

My site is www.irishimprt.com

 

Thanks and Happy Holidays,

 

Irish

Link to comment
Share on other sites

I have a general question... I have applied shipping modules that calculate shipping based on the price of the shopping cart. When someone orders a gift certificate with other purchase, or by itself, shipping is calculated. Is there any way to fix this issue?

 

My site is www.irishimprt.com

 

Thanks and Happy Holidays,

 

Irish

 

Irish,

 

I believe this is addressed by turning on Downloads on your site and then setting the product weight to zero for the certificates. I found these instructions in the install manual near the end. It works for me.

 

Joe

Link to comment
Share on other sites

hi there, i have a site that is supposed to be ready to go to the next phase this eve but I still cant get over this gift voucher install.

When i try to create an account i get this

 

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /home/www/jgsales/includes/functions/database.php:13) in /home/www/jgsales/includes/functions/database.php on line 13

 

thoughts?

Link to comment
Share on other sites

The error is telling you what is wrong, it is looking for "ERROR_REDEEMED_AMOUNT_ZERO" which is stored in the catalog/includes/language/add_ccgvdc_english.php FILE,

 

YOU must edit the file by adding this information by copying and pasting the following:

 

define('ERROR_REDEEMED_AMOUNT_ZERO', 'a valid coupon number. HOWEVER: No reduction will be applied, please see the coupon restrictions that was sent within your offer email***');

 

at the very bottom of that file just before the

 

?>

at the end of the file!!!

 

This will solve your problem of the wrong error message showing up

 

Hope this helps

 

Chris

 

 

ok, i tried what you said here, and then the other one, the ot_coupon.

I still get the error it wont go away, but in the shopping cart box, is shows the value for the coupon, it also is not deducting the coupon total from the purchase total.

Link to comment
Share on other sites

HEYYYYYYYYYYYYYYY!!! About 3 weeks ago I asked for help regarding coupons not deducting from order totals before passing to payment gateway and NOTHING - not a single reply...

 

I have tried adding some "upgrades" from 5.15 but if thats a fix... well - i have a feeling I cant say what i'd like to...

 

Does ANYONE have a WORKING version of this thing ANYWHERE??????

Link to comment
Share on other sites

HEYYYYYYYYYYYYYYY!!! About 3 weeks ago I asked for help regarding coupons not deducting from order totals before passing to payment gateway and NOTHING - not a single reply...

 

I have tried adding some "upgrades" from 5.15 but if thats a fix... well - i have a feeling I cant say what i'd like to...

 

Does ANYONE have a WORKING version of this thing ANYWHERE??????

 

 

Yes go and check the site link that I provided above or on the last page. With XMAS on the horizon, most will be busy with the holidays. Check back with us next week and most likely it will be updated then.

 

Chris

Link to comment
Share on other sites

Thanx?

 

With all due respect, what does your site link do for me again?

 

I need to get the order total to show the coupon discount before passing on to payment gateway... Is this a DB error, is it code?

 

We are all tired and ready for Xmas but some things need doing yes?

Link to comment
Share on other sites

Thanx?

 

With all due respect, what does your site link do for me again?

 

I need to get the order total to show the coupon discount before passing on to payment gateway... Is this a DB error, is it code?

 

We are all tired and ready for Xmas but some things need doing yes?

 

I believe you had asked if there was a working version anywhere and if someone can post a link for you. Ergo, the site link from Chris.

 

Oh by the way........HAPPY HOLIDAYS to everyone.

 

Oh, guess I should ask while i am here, I am about to do a fresh install of the CCGV and start from scratch, which shoud i get? i see there is a 5.15, should i be using this one?

Link to comment
Share on other sites

I believe you had asked if there was a working version anywhere and if someone can post a link for you. Ergo, the site link from Chris.

 

Oh by the way........HAPPY HOLIDAYS to everyone.

 

Oh, guess I should ask while i am here, I am about to do a fresh install of the CCGV and start from scratch, which shoud i get? i see there is a 5.15, should i be using this one?

 

I recently installed v5.15 and I have it functional on my dev site without errors. I did a full backup of the database and then all files first, printed out the 99 file names that are used in this contribution, and then I used a compare tool (ExamDiff) to compare the original files OSC files to the CCVG v5.15 files. As I compared and hand updated each file, I checked off the file on the list. I have found that this methodical way of implementing a contribution of this caliber is required. It took me a couple of days to implement, a couple of days of testing and changing some of the text in e-mails etc..

 

I found two major issues that had to be addressed:

 

1) There is one file that contains french database calls. I compared this few lines of code to the code in the same filename in the v5.13 contribution and replaced the french code with the english code.

 

2) I found one error in the v5.15 and a fix was already provided. See contribution: Fix for 'ERROR_REDEEMED_AMOUNT_ZERO' error for COUPONS 5.15. This is just one line of code that was forgotten that needed to be added in.

 

This is not an easy contribution to implement but it can be done and it is packed with features.

 

Hope this helps...

 

Joe

Link to comment
Share on other sites

Thanx?

 

With all due respect, what does your site link do for me again?

 

I need to get the order total to show the coupon discount before passing on to payment gateway... Is this a DB error, is it code?

 

We are all tired and ready for Xmas but some things need doing yes?

 

Maybe not you, but someone was asking if it works, the link demostrates that it does.

 

If you ran the proper sql's then the DB is not in error most likely a code update is the issue.

 

No, Xmas and family trump all things that need doing. This is non-negotiable for me.

 

Merry xmas all, I'll be back at it after the holiday

 

Chris

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.
Note: Your post will require moderator approval before it will be visible.

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...