Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Hi to All...

 

I was looking for this contribution, but can´t see some advice about if this one can work with UPS shipping module, I manage a oscommerce store for a local wine company, but they are using UPS shipping and not table shipping. Anybody, the creator/modificator of this contribution, could give some hand in this?

 

A lot of thx.

Link to comment
Share on other sites

I now have a problem with the paypal ipn not having the deducted amount passed onto paypal. It is in fact adding the discount to the total price.

 

It is showing the discount perfectly in the cart but when it goes to paypal it adds whatever discount there was back into the price that was computed in the cart.

Link to comment
Share on other sites

this is also not showing that a discount code has been used in the REPORTS section of admin. It is not keeping track of how many codes are used.

 

I believe there are instructions on setting DCC up to work with Paypal IPN.

 

As for the reports - I would double check that you have uploaded all the files in ASCII mode (not Binary).

~Tracy
 

Link to comment
Share on other sites

Hi, I've installed the coupon discount and it appears to be working correctly but something strange has happened...

Under "Configuration" I now have this link: BOX_CONFIGURATION_ADMINISTRATORS

 

When clicked on I get this 404 error:

The requested URL /catalog/admin/FILENAME_ADMINISTRATORS was not found on this server.

 

Anybody got any idea causing this? Thanks :)

Link to comment
Share on other sites

I believe there are instructions on setting DCC up to work with Paypal IPN.

 

As for the reports - I would double check that you have uploaded all the files in ASCII mode (not Binary).

 

 

Do you know where the instructions are for the DCC to work with paypal IPN?

 

What would the ASCII mode give me that the binary wouldnt? Thanks.

Link to comment
Share on other sites

Do you know where the instructions are for the DCC to work with paypal IPN?

 

What would the ASCII mode give me that the binary wouldnt? Thanks.

 

On the DCC Contribution Download page:

http://addons.oscommerce.com/info/4269 You should see Paypal IPN v2.2 available as a download.

 

ASCII is for scripted files - Binary is for graphics. When you upload PHP in Binary mode it can (and quite frequently does) corrupt the code. Just like uploading an image in ASCII mode can corrupt the image :thumbsup:

~Tracy
 

Link to comment
Share on other sites

I've installed this (v3.3.1) and it seems to be successful, but for some reason the page catalog/admin/coupons.php is totally blank, so I can't make it work. I wouldn't have been surprised if I'd messed up an edit somewhere, but as far as I can see, that page is generated by supplied files. Any suggestions about where I might have gone wrong?

 

I'm not sure if there is a problem with shipping charges (they are complicated in this store), because I can't get as far as testing.

Link to comment
Share on other sites

Hi, I've installed the coupon discount and it appears to be working correctly but something strange has happened...

Under "Configuration" I now have this link: BOX_CONFIGURATION_ADMINISTRATORS

 

When clicked on I get this 404 error:

The requested URL /catalog/admin/FILENAME_ADMINISTRATORS was not found on this server.

 

Anybody got any idea causing this? Thanks :)

 

 

I'm having the same problem. Did you figure out what was wrong?

 

nevermind, found the answer here...

 

http://www.oscommerce.com/forums/index.php?sho..._ADMINISTRATORS

Edited by rmuir3
Link to comment
Share on other sites

... for some reason the page catalog/admin/coupons.php is totally blank, so I can't make it work...

Does anyone have any suggestions? I've installed all the files from 3.3 and that didn't help, so I've reinstalled the 3.31 files on top again.

Link to comment
Share on other sites

Does anyone have any suggestions? I've installed all the files from 3.3 and that didn't help, so I've reinstalled the 3.31 files on top again.

 

Are you uploading in ASCII format? Binary can corrupt the PHP files.

 

If that isn't the issue - then I'd use a comparison program (like WinMerge) to compare your pages with the contributions pages - it may help you find if you missed an edit or mistyped something while editing :blush:

~Tracy
 

Link to comment
Share on other sites

I am having trouble with getting error messages to return on any of the initial discount_coupon class errors as well as the ones that are supposed to be URL encoded. I do not receive errors when customers enter an invalid code, or when they enter a code that has a minimum amount when they haven't reached the minimum amount. I have installed the STS template system as well as the Paypal direct payments module.

 

The module does work if you enter a valid code and it deducts items automatically, but any incorrect codes simply return you to the checkout_confirmation.php with no errors or code discount...

 

As far as I can tell everything initializes properly, but no errors are echoing out. I've even added this line to my checkout_payment.php like the "common problems" of the readme tell you to:

 

<?php
 if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr class="headerError">
   <td class="headerError"><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></td>
 </tr>
</table>
<?php
 }
?>

 

And I still have no error messages returning. I can also not see any output from turning on the debugging. Are there any quick fixes or patches I should be applying to my site? Here's the checkout_confirmation.php relevant code:

 

  require('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

// 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'));
   }
 }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
 if (!tep_session_is_registered('shipping')) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 }

 if (!tep_session_is_registered('payment')) tep_session_register('payment');
 if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];

 if (!tep_session_is_registered('comments')) tep_session_register('comments');
 if (tep_not_null($HTTP_POST_VARS['comments'])) {
   $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
 }

//---PayPal WPP Modification START ---//	
 if (tep_paypal_wpp_enabled()) {
   $ec_enabled = true;
 } else {
   $ec_enabled = false;
 }

 if ($ec_enabled) {
   $show_payment_page = false;

   $config_query = tep_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_PAYMENT_PAYPAL_DP_DISPLAY_PAYMENT_PAGE' LIMIT 1");
   if (tep_db_num_rows($config_query) > 0) {
     $config_result = tep_db_fetch_array($config_query);
     if ($config_result['configuration_value'] == 'Yes') {
       $show_payment_page = true;
     }
   }

   $ec_checkout = true;
   if (!tep_session_is_registered('paypal_ec_token') && !tep_session_is_registered('paypal_ec_payer_id') && !tep_session_is_registered('paypal_ec_payer_info')) { 
     $ec_checkout = false;
     $show_payment_page = true;
   }
 }
//---PayPal WPP Modification END ---//

//kgt - discount coupons
 if (!tep_session_is_registered('coupon')) tep_session_register('coupon');
 //this needs to be set before the order object is created, but we must process it after
 $coupon = tep_db_prepare_input($HTTP_POST_VARS['coupon']);
 //end kgt - discount coupons

// load the selected payment module
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment($payment);

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;

 $payment_modules->update_status();

 if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
 }

//kgt - discount coupons
 if( tep_not_null( $coupon ) && is_object( $order->coupon ) ) { //if they have entered something in the coupon field
$order->coupon->verify_code();
   if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG != 'true' ) {
	  if( !$order->coupon->is_errors() ) { //if we have passed all tests (no error message), make sure we still meet free shipping requirements, if any
		  if( $order->coupon->is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
	  } else {
		  if( tep_session_is_registered('coupon') ) tep_session_unregister('coupon'); //remove the coupon from the session
		  tep_redirect( tep_href_link( FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode( implode( ' ', $order->coupon->get_messages() ) ), 'SSL' ) ); //redirect to the payment page
	  }
   }
} else { //if the coupon field is empty, unregister the coupon from the session
	if( tep_session_is_registered('coupon') ) { //we had a coupon entered before, so we need to unregister it
     tep_session_unregister('coupon');
     //now check to see if we need to recalculate shipping:
     require_once( DIR_WS_CLASSES.'discount_coupon.php' );
     if( discount_coupon::is_recalc_shipping() ) tep_redirect( tep_href_link( FILENAME_CHECKOUT_SHIPPING, 'error_message=' . urlencode( ENTRY_DISCOUNT_COUPON_SHIPPING_CALC_ERROR ), 'SSL' ) ); //redirect to the shipping page to reselect the shipping method
   }
}
//end kgt - discount coupons
 if (is_array($payment_modules->modules)) {
   $payment_modules->pre_confirmation_check();
 }

// load the selected shipping module
 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping($shipping);

 require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

// Stock Check
 $any_out_of_stock = false;
 if (STOCK_CHECK == 'true') {
   for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
     if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
       $any_out_of_stock = true;
     }
   }
   // Out of Stock
   if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
     tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
   }
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_CONFIRMATION);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2);

 

I entered in echo statements in the verify() function to make sure that is initializing as well and it shows up fine. Has anyone else had similiar problems to this?

Assault

If you want to find it you'll have to google "Assault T-Shirts" because posting my damn url in my signature is against the forum rules.

T-Shirts with an edge

Powered by OSCommerce + about 20 different custom addons and some Wordpress

Link to comment
Share on other sites

Are you uploading in ASCII format? Binary can corrupt the PHP files.

 

If that isn't the issue - then I'd use a comparison program (like WinMerge) to compare your pages with the contributions pages - it may help you find if you missed an edit or mistyped something while editing :blush:

 

Thanks for the suggestions.

 

Definitely uploaded in binary.

 

I don't think I made any errors in the files I edited, but even if I had done, the page that is failing is one of the ones that are not altered at all.

 

As far as I can see, it and the pages it calls are ones that just need copying onto the server, as far as I can see.

 

If /admin/coupons.php does rely on any files that need to be edited before upload, please can someone tell me which?

Link to comment
Share on other sites

If /admin/coupons.php does rely on any files that need to be edited before upload, please can someone tell me which?

I've made some progress. By putting some data into the discount_coupons table I've managed to get some of the coupons.php page to work. So it looks as if there needs to be some data in there to start things off. But I need data for the other related tables.

 

I can't find any trace of an sql script to generate any "seed" coupons. Can someone let me have a sql export from their working system that I can import to get things started? I guess that I only need one row, and it can be an expired coupon.

 

Hope someone can help!

 

Iain

Link to comment
Share on other sites

The SQL should automatically be run - it is in the catalog/includes/modules/order_total/ot_discount_coupon.php file

 

In your Admin, when you click on "Modules -> Order Total" - is your Discount Coupons module installed with "enable discount coupon" set to true ?

 

 

I've made some progress. By putting some data into the discount_coupons table I've managed to get some of the coupons.php page to work. So it looks as if there needs to be some data in there to start things off. But I need data for the other related tables.

 

I can't find any trace of an sql script to generate any "seed" coupons. Can someone let me have a sql export from their working system that I can import to get things started? I guess that I only need one row, and it can be an expired coupon.

 

Hope someone can help!

 

Iain

~Tracy
 

Link to comment
Share on other sites

I am having trouble with getting error messages to return on any of the initial discount_coupon class errors as well as the ones that are supposed to be URL encoded. I do not receive errors when customers enter an invalid code, or when they enter a code that has a minimum amount when they haven't reached the minimum amount. I have installed the STS template system as well as the Paypal direct payments module.

 

The module does work if you enter a valid code and it deducts items automatically, but any incorrect codes simply return you to the checkout_confirmation.php with no errors or code discount...

 

As far as I can tell everything initializes properly, but no errors are echoing out. I've even added this line to my checkout_payment.php like the "common problems" of the readme tell you to:

 

 

I entered in echo statements in the verify() function to make sure that is initializing as well and it shows up fine. Has anyone else had similiar problems to this?

 

I'm running STS as well, and adding that bit of code to the checkout pages that I want errors to be able to appear on worked for me. If you want, PM me with your email addy (and a reminder of what files you need) and I can send you a copy of my checkout pages for you to compare to yours. Keep in mind that I have several other contrib's installed as well - so you won't need some of the code.

~Tracy
 

Link to comment
Share on other sites

I installed the necessary files and began changing the existing pages. When I reached

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

OPEN catalog/includes/classes/order.php

FIND on line 244:

$shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];

$this->info['subtotal'] += $shown_price;

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

Didn’t find “$shown_price = tep….” in the file. I did a search on the folder and couldn't find any line beginning that way.

Also didn't find

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

if (DISPLAY_PRICE_WITH_TAX == 'true')

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

on line 268

 

Can anyone advise?

Thank you.

Link to comment
Share on other sites

Tracy: Sent you my email

 

I have re-installed the contribution and turned on the debugging to see if there was any information for when I entered an invalid code. As it turns out no debugging information shows up in the source code, but if I enter a correct coupon code, the debug code shows up.

 

I am still not being re-redirected to the checkout_payment.php as I should when there is an invalid coupon code entered. I can enter just about anything and I am still redirected to the checkout_confirmation.php page.

 

Why aren't errors showing up? Why am I not redirected when an indirect coupon code is entered?

Assault

If you want to find it you'll have to google "Assault T-Shirts" because posting my damn url in my signature is against the forum rules.

T-Shirts with an edge

Powered by OSCommerce + about 20 different custom addons and some Wordpress

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