Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 5 votes

[Contribution] Discount Coupon Codes


3204 replies to this topic

#3141 chemist4

  • Community Member
  • 77 posts
  • Real Name:Tim
  • Gender:Male
  • Location:Missouri

Posted 09 August 2011, 19:48

View Posttdejesus, on 28 July 2011, 23:16, said:

Hey! Thanks for the quick reply. You know, I had played with this feature and I am enrolled with Paypal Standard payments via my PayPal account, but, I notice that when the billing moves from my website to my PayPal standard page, the itemized products are removed and replaced with only the total cost of my (test) cart and the name of my website, instead of the name of any product.

Using PayPal standard, is there a charge for API credentials? I can't seem to figure how this is supposed to be configured from PayPal to my Website. (Public Certificates, etc.) I have spent the last few days trying to resolve this, even dangerously editing code in sensitive module files, all to no success. (I do know to backup! :) )

I'm a complete novice at this. I am far better a PHP "manipulator", but, cannot seem to pull raw code from my rear to make anything useful happen.

Thanks again for your reply. Any further thoughts are greatly appreciated...
I'm no expert on any of this either, but I did happen to talk to PayPal about their modules. You don't need to do anything special for it to work. The API credentials are only needed for some of the other modules. Just the email address you use with the PayPal account is required for Express and Standard, the rest is "filled in" by PayPal when the order is sent to them for processing. The modules that require the APIs don't send the checkout to PayPal, they are handled by PayPal through your site, hence the need for special authentication. I don't think there is a charge for using the API modules, but you do have to contact PayPal to get the codes.

The reason no items are listed individually is that osC hands off the payment to PayPal by sending only the required information, i.e. total, tax, shipping, etc. It is handled securely through PayPal. With PayPal Standard you should see the checkout confirmation page with all of the items listed, which gives the customer a chance to make changes.

There is a thread about setting up PayPal Standard somewhere if you have questions about that. But basically, you just put in the email address linked to your PayPal account and it works. If you want to use the Sandbox to test, you have to open an account just for that in addition to your regular PayPal account.

All of this is just my understanding after a conversation with PayPal about getting APIs before deciding to use Standard.

#3142 chemist4

  • Community Member
  • 77 posts
  • Real Name:Tim
  • Gender:Male
  • Location:Missouri

Posted 09 August 2011, 19:59

View Postssnb, on 08 August 2011, 06:21, said:

Hi All

Can anyone help me to improve the following code I have added to checkout_confirmation?

It bypasses the checkout payment page if the order total is $0.00

The problem is - it only works with a redirect to checkout_success, which is at least something, but missing out checkout_process also means missing out on the order process (i.e. sending emails, updating the DB etc) - so not very helpful really!

if ($order->info['total'] <= 0) {
   $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');


} else {
	
if (isset($$payment->form_action_url)) {
    $form_action_url = $$payment->form_action_url;
  } else {
  
  

    $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
  }
  
  }


I just want to skip the payment modules if the total is $0.00 but not having much luck.

Any one have this functionality working?

Thanks for suggestions...
Have you looked at this contribution?

#3143 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 10 August 2011, 00:53

View Postchemist4, on 09 August 2011, 19:59, said:

Have you looked at this contribution?


Hi Chemist, thanks for your reply.

The contributions suggested is designed to bypass checkout / payment if the value of the item is zero.
unfortunately, it doesn't work with KGT discount coupons when they are 100% discount, because the discount coupon is processed AFTER the free module is looking at cart total.

I've been playing around with it for a while to see if I could modify it to get checkout_process.php to recognise a zero cart total and thereby ignore the payment modules (or choose the free one) but not having much luck.

In the contribution instructions, it says to bypass the payment page add some code to catalog/checkout_payment.php but that's the same page witht he discount coupons on - so the cart total has not yet been updated to zero...

When user has entered their discount coupon code and the hits confirm button, it takes them to the catalog/checkout_confirmation.php page and I am assuming it is here that the payment module check must be made, or on the the following page catalog/checkout_process.php

So I am playing around with this but so far, no luck.

I was hoping that someone had already worked out a way to make a 100% discount (i.e. zero total) skip the payment checking and directly proceed to checkout_success.php (via checkout_process)

#3144 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 10 August 2011, 06:48

Updated:

I've made significant progress!

1) Moved discount coupon code on the checkout_shipping.php page as it makes more sense there (after choose shipping method and before notes)
2) Added free of charge payment method - as trying to bypass the payment page seems impossible

It works fine now EXCEPT:
I can't seem to display JUST the free of charge payment method when the order total is zero -
I've tried using the old trick of disabling payment methods if the order total is zero, but this seems to either end up in a browser loop error or tell me to select a payment method!

I've discovered that in the DB all the payment modules are listed as sort order 0 - I don't know if this is a bug or an error specific to me, but it seems when you disable 1 payment method, they all go !

Will keep trucking on and see how I get on.

If anyone wants the code info on what to do to achieve what I have doen, let me know.

#3145 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 10 August 2011, 09:25

Right well, after a few more beers, I've managed to sort it...

I just added in checkout_payment.php - in the upper part of the code, right after the payment classes are declared, a default payment.

// load all enabled payment modules
  if ($order->info['total'] <= 0) {
 	$payment = 'freeofcharge';
	if (!tep_session_is_registered('payment')) tep_session_register('payment');
	tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
	}


Took me all day to figure this out, but now I'm happy :-)

Let me know if you want the instructions...

#3146 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 10 August 2011, 11:46

One final thing to work on - how to display a success message once the coupon has been added.... that would be sweet!

If anyone already has a method, please share, otherwise I'll look into it.

#3147 chemist4

  • Community Member
  • 77 posts
  • Real Name:Tim
  • Gender:Male
  • Location:Missouri

Posted 10 August 2011, 16:16

View Postssnb, on 10 August 2011, 11:46, said:

One final thing to work on - how to display a success message once the coupon has been added.... that would be sweet!

If anyone already has a method, please share, otherwise I'll look into it.
If you get this working well enough you should submit it as a contribution.

Is the 'freeofcharge' a payment module you made? I have paid virtually no attention to the payment modules since I use PayPal, but I would think a change to payment_process could redirect to the success page after the 0 total checkout. Essentially you are processing an order that happens to have a total of $0, so if you can make it work the same as any other payment module it should send emails as it would otherwise. Of course, it would have to load the 0 total module only when the total is 0, and not show as an option on the payment page if the total is not 0. Or at least have a provision to handle the inevitable customer choosing that option to avoid paying.

I can't see myself ever using this on my current store, but it could be useful for others.

#3148 goring_gap

  • Community Member
  • 112 posts
  • Real Name:Simon
  • Location:UK

Posted 15 August 2011, 07:43

There seems to be a session issue when using this with version 2.2

Coupons are not showing first time. If you refresh checkout_confirmation.php then the discount shows.

This is because the coupon code in classes->orders.php does not see the session the first time (I don't know why).

My solution was to pre-register the session on the checkout_payment.php page.

You only need this if you have the issue above!

in checkout_payment.php find:


<?php
/* kgt - discount coupons */
	if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true' ) {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><b><?php echo TABLE_HEADING_COUPON; ?></b></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo ENTRY_DISCOUNT_COUPON.' '.tep_draw_input_field('coupon', '', 'size="32"'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
	}
/* end kgt - discount coupons */
?>

change to:


<?php
/* kgt - discount coupons */
	if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true' ) {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><b><?php echo TABLE_HEADING_COUPON; ?></b></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main"><?php echo ENTRY_DISCOUNT_COUPON.' '.tep_draw_input_field('coupon', '', 'size="32"'); ?></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
	if (!tep_session_is_registered('coupon')) tep_session_register('coupon'); //fix - session not registering
	}
/* end kgt - discount coupons */
?>


Regards,
Simon

#3149 dkfranc

  • Community Member
  • 1 posts
  • Real Name:Francis

Posted 19 August 2011, 07:28

Hi can any one help me with this problem??

I have added discount coupon module in oscommerce 2.3.1.
and its working well..

BUT when i choose cash on delivery method for payment and confirm order i get this..


1054 - Unknown column 'delivery_date' in 'field list'

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, delivery_date, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, date_purchased, orders_status, currency, currency_value) values ('1', 'fff', '', 'ffffffff', '', 'ffffffff', '1111111', 'ffffffff', 'India', '123456788', 'ff@ymail.com', '1', 'fff', '', 'ffffffff', '', 'ffffffff', '1111111', 'ffffffff', 'India', '1', '', 'francis babu', '', 'ffffffff', '', 'ffffffff', '1111111', 'ffffffff', 'India', '1', 'Cash on Delivery', '', '', '', '', now(), '1', 'USD', '1.00000000')

[TEP STOP]

#3150 Kebyr

  • Community Member
  • 1 posts
  • Real Name:Kebyr

Posted 24 August 2011, 16:47

Hello.

First, thanks for this contribution, is wonderful...

I have used it in the past, now I need it for the version 2.3, but the total amount, after applied the coupon, is $0

Anyone can help me?

Thanks.

#3151 amal2004

  • Community Member
  • 24 posts
  • Real Name:Amal Weerathunge

Posted 31 August 2011, 10:54

HII ALL

Im looking to add large number of discount codes such a 5000. Should be able to use only once per order.
I managed to fill up discount_coupons table using CSV using LOAD DATA function. As i need to apply these codes only for 1 product i have to exclude all other products from list.

Once you excluded product from list "discount_coupons_to_products" table automatically fills with excluded product IDs along with Discount Coupon Code. My problem is how its possible to do this for large number coupon codes such a 5000. I have around 530 Products on my website. I have to exclude 529 products for each discount code of 5000. If anyone has idea how to do this please help me to fix my problem.

Thank you

#3152 amal2004

  • Community Member
  • 24 posts
  • Real Name:Amal Weerathunge

Posted 02 September 2011, 12:29

View Postkgt, on 07 June 2006, 15:27, said:

This is the support thread for the Order Total contribution Discount Coupon Codes found here:

http://www.oscommerc...tributions,4269



Hii KGT

First i want to thank you for your grate contribution Discount coupon code module. I already installed that. But im having problem passing discounted total to paypal

Im using osCommerce 2.2-MS2 with osCommerce_PayPal_IPN_v2.3.3 and KGT Discount coupon code module dc_autoinstaller_2.14_2_1

And i did some changes found on forum.
But still my discount amount does not transfer to paypal.Posted Image It shows total amount without applying Discount percentage.
When i try with bank transfer payment method it shows correct amount. If i used paypal payment method after first using
bank transfer payment method, then paypal also shows correct discounted total amount.
But if i try paypal as a payment method at the first place, it doesn't show discounted total.

I tried installing different paypal IPNs and discount module versions. But still my problem same.

If you have any idea how to fix this error please help me. i really appreciate any level of help.
Thank you so much in advance.

-----------------------------------------------------
i did following changes.
-----------------------------------------------------


1) I selected aggregate instead of individual On transaction type.



2)

FIND around line 195:

//+1.4
$sql_data_array = array('orders_id' => $insert_id,
'orders_status_id' => $order->info['order_status'],
'date_added' => 'now()',
'customer_notified' => '0',
'comments' => $order->info['comments']);
tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
//-1.4



ADD this code after:

//kgt - discount coupons
if( tep_session_is_registered( 'coupon' ) && is_object( $order->coupon ) ) {
$sql_data_array = array( 'coupons_id' => $order->coupon->coupon['coupons_id'],
'orders_id' => $insert_id );
tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );
}
//end kgt - discount coupons



FIND around line 493:

// unregister session variables used during checkout
tep_session_unregister('sendto');
tep_session_unregister('billto');
tep_session_unregister('shipping');
tep_session_unregister('payment');
tep_session_unregister('comments');



ADD this code after:

//kgt - discount coupons
tep_session_unregister('coupon');
//end kgt - discount coupons


3)

FOLLOWING CODE:


if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
$parameters['amount'] = number_format(($subtotal + $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
} else {
// default
$parameters['amount'] = number_format($subtotal * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
$parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}


Updated to THIS :


if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
if (isset($order_total['ot_gv']) || isset($order_total['ot_coupon'])) {
//the discount will apply to the order total
$parameters['amount'] = number_format((($subtotal + $order->info['tax'] + $shipping) * $currencies->get_value($my_currency)) - $order_total['ot_gv'] - $order_total['ot_coupon'], $currencies->get_decimal_places($my_currency));
}else{
$parameters['amount'] = number_format(($subtotal + $order->info['tax'] + $shipping) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}

} else {
// default
$parameters['amount'] = number_format(($subtotal + $shipping) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
$parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
}

#3153 karthi

  • Community Member
  • 6 posts
  • Real Name:karthi

Posted 03 September 2011, 07:40

IS there any way to integrate with paypal express

#3154 psseuro

  • Community Member
  • 3 posts
  • Real Name:John

Posted 04 September 2011, 11:02

I have just installed this add-on to my web site - www.925silverexpress.com. But when I log onto my admin page and click on Catalog > Discount Coupons, it does not display the Discount Coupons configuration page. Rather, I receive the infamous HTTP 500 error message - "The website cannot dispplay the page". I have other contributions that are working. I can also access every other configuration options on the admin page. i have enabled Discount Coupons from Module > Order Total > Discount Coupon. Set the sort order to 2. As I am not great with PHP, it is difficult to know what to look for in the coupons.php file.

I am using OSC 2.3.1

Any help will be greatly appreciated.

Many Thanks

Edited by psseuro, 04 September 2011, 11:04.


#3155 psseuro

  • Community Member
  • 3 posts
  • Real Name:John

Posted 04 September 2011, 14:50

View Postpsseuro, on 04 September 2011, 11:02, said:

I have just installed this add-on to my web site - www.925silverexpress.com. But when I log onto my admin page and click on Catalog > Discount Coupons, it does not display the Discount Coupons configuration page. Rather, I receive the infamous HTTP 500 error message - "The website cannot dispplay the page". I have other contributions that are working. I can also access every other configuration options on the admin page. i have enabled Discount Coupons from Module > Order Total > Discount Coupon. Set the sort order to 2. As I am not great with PHP, it is difficult to know what to look for in the coupons.php file.

I am using OSC 2.3.1

Any help will be greatly appreciated.

Many Thanks

i have sorted the issue. I went through /admin/coupon.php again and discovered these two reference lines at the very top:
require('includes/application_top.php');
require( DIR_WS_FUNCTIONS.'coupons.php' );


Upon checking my /admin/includes/functions/ directory, somehow Ifailed to copy the 'coupons.php' file to that directory.Copying the 'coupons,php' to the /admin/functions/ directory, I can now open the Discount Coupons page and create a coupon.

#3156 lee_murphy

  • Community Member
  • 1 posts
  • Real Name:Lee Murphy

Posted 05 September 2011, 13:28

Hi,

I'm having a problem with the installation. In the Admin side I didn't have a problem, the module is installed, and I can Add/Edit new codes, but on the catalogue I can't see anywhere to enter the coupon code, it's not displaying at all, and I don't really know how to troubleshoot. I've double checked all the code changes have been made to all files and can't see anything missing and don't get an error anywhere, can you give me some ideas on where to look for problems!

Many thanks!

#3157 peterkbm

  • Community Member
  • 10 posts
  • Real Name:peter

Posted 15 September 2011, 12:46

At oscommerce 2.2MS2 control panel, when click at Catalog > Discount coupons, facing this issue:

Access Denied  
 
No Right Permission Access
Please contact your Web Administrator to request
more access or if you found any problem.
 

Try to makes /includes & /admin folder all files permission to 777, still can't solve it.

Any suggestion?

Many thanks in advance!

#3158 Tom172

  • Community Member
  • 55 posts
  • Real Name:Thomas
  • Gender:Male

Posted 19 September 2011, 18:08

Hi.

I have installed version 3.34 of this contribution together with the last two fixes on a 2.2rca shop and everything just works fine as far I can see. My only question is:

Has anybody achieved to link coupons to the order # a coupon has been used with? Is there any sollution if I would like to see for which order numbers a specific coupon code has been used with? Or even better: Is there a way to link the coupon to the products that it was used to purchase?

Any hint will be greatly appreciated.
tom

Edited by Tom172, 19 September 2011, 18:10.


#3159 peterkbm

  • Community Member
  • 10 posts
  • Real Name:peter

Posted 03 October 2011, 07:29

i solve my own question.


Access Denied

No Right Permission Access
Please contact your Web Administrator to request
more access
or if you found any problem.


at admin, adminstrator, exclude file ( store/admin/admin_files.php ) , store the nessesary file under module folder.

#3160 dmk4112

  • Community Member
  • 2 posts
  • Real Name:David
  • Gender:Male

Posted 03 October 2011, 10:58

Hi everybody,

I am very new to all this and I am trying to install discount codes 3.4. I added the new files and manually added the code for existing ones. The website seems fine but in the admin panel when I click on the Discount Coupon under catalog I get the following error

[an error occurred while processing this directive]

I have no idea where to go from here. I have restored my files,tried it over and over and keep getting same error. I am running v2.2 rc2

Any help is greatly appreciated,

Dave