Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Can someone please help me add this contribution to PayPal Express checkout? When someone clicks on the PayPal Express Checkout button it skips the checkout_payment.php and goes straight to the checkout_confirmation.php so they never see the discount coupon box. What do I need to do to get this working with PayPal Express Checkout?

Link to comment
Share on other sites

Hi,

 

Does anybody have changed the code for product exclusion (or other existing exclusions) so that it works the other way around, like product inclusion? I have thousands of products on my shop and the most common use I have for this contribution is to apply the discount to a couple of selected products. So instead of selecting the products that won't get the discount, I would rather like to be able to select the products that will get the discount.

 

Here is the code for product exclusion:

 

 

//product exclusion

if( !is_array( $this->cart_info['exclusions']['products'] ) ) { //only create the array when we need to and only once

//check to see if the product is in one of the limited categories

$check_product_query = tep_db_query( $sql = 'SELECT products_id

FROM '.TABLE_DISCOUNT_COUPONS_TO_PRODUCTS.'

WHERE coupons_id="'.tep_db_input( $this->coupon['coupons_id'] ).'"' );

$this->cart_info['exclusions']['products'] = array();

if( tep_db_num_rows( $check_product_query ) > 0 ) {

while( $products = tep_db_fetch_array( $check_product_query ) ) {

$this->cart_info['exclusions']['products'][] = $products['products_id'];

}

}

}

if( count( $this->cart_info['exclusions']['products'] ) > 0 ) {

if( in_array( $product_id, $this->cart_info['exclusions']['products'] ) ) {

//use this to debug exclusions:

if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DEBUG == 'true' ) $this->message( 'INFO: Product '.$product_id.' failed product exclusion check', 'debug' );

return false;

}

}

//end product exclusion

 

Thanks,

Andybird

Edited by Andybird
Link to comment
Share on other sites

Hi to all,

 

Before I install this contribution, I've install the Low Stock Report contribution and it did change my catalog/admin/includes/boxes/catalog.php in line 29. This is the low stock contribution

 

http://www.oscommerce.com/forums/index.php?showtopic=164523

 

This contribution required me to change the the above lines, follows is how i did

 

if ($selected_box == 'catalog') {
$contents[] = array('text'  => '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS . '</a><br>' .
							   '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS_ATTRIBUTES . '</a><br>' .
							   '<a href="' . tep_href_link(FILENAME_MANUFACTURERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_MANUFACTURERS . '</a><br>' .
							   '<a href="' . tep_href_link(FILENAME_REVIEWS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_REVIEWS . '</a><br>' .
							   '<a href="' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_SPECIALS . '</a><br>' .
							   '<a href="' . tep_href_link(FILENAME_STATS_LOW_STOCK, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_REPORTS_STOCK_LEVEL . '</a>'
	);
							   //kgt - discount coupons
							   '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'
							   '<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' );
							   /***************
							   '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>' );
							   ***************/
							   //end kgt - discount coupons

 }

 

and the result in my admin/modules was

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xxxxx/public_html/admin/includes/boxes/catalog.php on line 33

 

I hope you can help me to resolve how to arrange the coding above and make this contribution works for me.

 

Thanks in advance.

Link to comment
Share on other sites

Much too much discount given!

 

I've got this working OK, but am having a problem. We have a few products costing just a few pence, but most are a few hundred pounds.

 

Create a coupon that reduces the price by 50.00 and it works fine, except if the first item added to the basket costs up to 0.22. If a very cheap item goes in first, the coupon reduces the price to almost nil.

 

If I exclude the cheap item from the coupon, that sorts the problem. If I make the cheap item 0.23 or more, it works fine.

 

But how do I fix the problem properly?

Link to comment
Share on other sites

Hello,

 

I use this contribution for a long time with succes.

But after mine provider had upgraded to php5 is there something wrong.

 

When you put in a discount code it is not visible on the checkout_payment page.

The discount is also not applied.

When you press F5 it's there and applied as well.

 

I still haven't find the solution on the dutch and english forum, so is there anybody who's knows this problem?

 

regards,

Jan

 

Same problem here, worked fine on PHP 4 and mySQL 4 but now I've upgraded to PHP 5.2.5 and mySQL 5.0.45 the discount isn't showing on checkout_confirmation.php, if I continue with the order it works fine and the discount is applied, but it doesn't show during checkout which is of coarse going to put customers off as they'll think they're not getting the discount.

 

This is the last of a long long line of errors I have had to fix because of the php upgrade and register globals changes and I'd really love some help ;)

 

Nigel

Link to comment
Share on other sites

Yes - when creating the coupon you would enter the discount as 100 and choose Shipping Discount (rather than fixed amount or percent)

 

 

Is there any way with this contrib to specify that a coupon is to give free shipping, period. That is, no matter what the shipping charge is, the shipping will be free with the coupon?

~Tracy
 

Link to comment
Share on other sites

Yes - when creating the coupon you would enter the discount as 100 and choose Shipping Discount (rather than fixed amount or percent)

 

FANTASTIC! Thank you Tracy. I thought I was going to have to write yet more code for my client :-)

Link to comment
Share on other sites

Hey Everyone

 

I just installed 3.31 and I am getting the error "redeclare class ot_discount_coupon in .../ot_discount_coupon.php on line 13" I have notice a solution commenting out line 14 on the forum but I believe that was for an old installer.

 

I have had a look and if I change line 13 from

 

class ot_discount_coupon {

 

to

 

class ot_discount_coupon2 {

 

The page error goes away but I cannot find the coupon setting in my admin error.

 

regs,

Jacko

Link to comment
Share on other sites

what wappen??

I have all SQL tables...

 

1146 - Table 'planetaorganico.TABLE_DISCOUNT_COUPONS' doesn't exist

SELECT dc.* FROM TABLE_DISCOUNT_COUPONS dc WHERE coupons_id = 'TEST CODE' AND ( coupons_date_start <= CURDATE() OR coupons_date_start IS NULL ) AND ( coupons_date_end >= CURDATE() OR coupons_date_end IS NULL )

[TEP STOP]

 

thanks!

Link to comment
Share on other sites

Looks like it might be something in your configure files? It is putting planetaorganico in front of TABLE_DISCOUNT_COUPONS - any idea why it is doing that?

 

what wappen??

I have all SQL tables...

 

1146 - Table 'planetaorganico.TABLE_DISCOUNT_COUPONS' doesn't exist

SELECT dc.* FROM TABLE_DISCOUNT_COUPONS dc WHERE coupons_id = 'TEST CODE' AND ( coupons_date_start <= CURDATE() OR coupons_date_start IS NULL ) AND ( coupons_date_end >= CURDATE() OR coupons_date_end IS NULL )

[TEP STOP]

 

thanks!

~Tracy
 

Link to comment
Share on other sites

Hi,

 

Like others above I've got a problem when using Paypal Express Checkout - if you click on the paypal icon it skips the input field coupon completely because it goes straight to payment_confirmation.php.

And if you use the regular checkout button, you see the normal checkout_shipping.php, checkout_payment.php etc so you can enter the code - but then it whisks you off to paypal and when it comes back to checkout_confirmation.php it's forgotten the voucher code (and the shipping for that matter).

 

Anyone got any ideas? I haven't installed Paypal IPN or whatever it's called, just use the PayPal Express Checkout and PayPal Website Payments Pro (UK) Direct Payments modules that came in oscommerce 2.2 RC2.

I have added in an extra shipping module that might be getting screwed up with discounts and coupons, as I noticed I had to edit some of the same pages to install coupons today.

 

Any ideas very gratefully received!!

 

Lisa x

Link to comment
Share on other sites

got it all installed and when i tried to go into the admin area I get "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /homepages/18/d241181317/htdocs/storenew/admin/includes/boxes/catalog.php on line 31"

 

this is my line 31 "'<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' );"

 

any ideas?

Link to comment
Share on other sites

I've installed the contribution and it works fine. However, I just made a coupon that was for one specific category, I excluded (put on the right side) everything except the one category it was supposed to be for, but the coupon still works on other categories. Then I excluded all of the products that weren't in that category and it still works on everything. Any idea as to what's wrong?

Link to comment
Share on other sites

Sounds like something was missed when updating or uploading your files. I would use a file comparison program and double check your files against the contribution files and see if something is missing or misplaced.

 

I've installed the contribution and it works fine. However, I just made a coupon that was for one specific category, I excluded (put on the right side) everything except the one category it was supposed to be for, but the coupon still works on other categories. Then I excluded all of the products that weren't in that category and it still works on everything. Any idea as to what's wrong?

~Tracy
 

Link to comment
Share on other sites

hi, i just installed the contribution and everything seemed to work fine.

 

but now i discovered a little problem:

 

in the admin area i can't navigate... wherever i click the page refreshes to the default page index.php. maybe i changed something :S dunno.

 

can some1 help me out?

Link to comment
Share on other sites

got it all installed and when i tried to go into the admin area I get "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /homepages/18/d241181317/htdocs/storenew/admin/includes/boxes/catalog.php on line 31"

 

this is my line 31 "'<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' );"

 

any ideas?

 

Try this:

 

1) At admin/includes/boxes/catalog.php has to be

//kgt - discount coupons

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>'.

'<a href="' . tep_href_link(FILENAME_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_DISCOUNT_COUPONS . '</a>' );

/***************

'<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>' );

***************/

//end kgt - discount coupons

 

and

 

2) At admin/includes/boxes/reports.php has to be

 

//kgt - discount coupons report

'<a href="' . tep_href_link(FILENAME_STATS_CUSTOMERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_REPORTS_ORDERS_TOTAL . '</a><br>'.

'<a href="' . tep_href_link(FILENAME_STATS_DISCOUNT_COUPONS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_REPORTS_DISCOUNT_COUPONS . '</a>');

/*************

'<a href="' . tep_href_link(FILENAME_STATS_CUSTOMERS, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_REPORTS_ORDERS_TOTAL . '</a>'); *************/

//end kgt - discount coupons report

Link to comment
Share on other sites

hi, i just installed the contribution and everything seemed to work fine.

 

but now i discovered a little problem:

 

in the admin area i can't navigate... wherever i click the page refreshes to the default page index.php. maybe i changed something :S dunno.

 

can some1 help me out?

 

i fixed it myself :)

 

thanks though

Link to comment
Share on other sites

i fixed it myself :)

 

thanks though

 

Hi I am new here, may I knw how, where and which disount coupon code you have install and download the file into which directory? step by step guide would be really helpful. In need of help. Thank you.

Link to comment
Share on other sites

Hi I am new here, may I knw how, where and which disount coupon code you have install and download the file into which directory? step by step guide would be really helpful. In need of help. Thank you.

 

download the contribution at:

 

http://addons.oscommerce.com/info/4269

 

there is a guide included.

 

btw, there is no installer or something like that. you have to upload the files yourself.

Link to comment
Share on other sites

I've got this contribution installed and it appears to be working fine in OSC, but when I go to PayPal to process the sale none of the discount information gets carried over.

 

I'm not a PHP pro, but I can check the code... I just have no idea where to look. Can anyone help?

Link to comment
Share on other sites

I added this contribution and everything works beautifully. However, I just noticed that now I have two zeros under shopping cart (as if I now have two columns for items in shopping cart) and if I add an item only one column changes, the other zero doesn't change. so it looks like 10 items in the cart while I only added 1 item.

 

Shopping Cart:

0 0 items

 

Shopping Cart:

1 0 items

 

What did I do wrong?

Link to comment
Share on other sites

Go to catalog/includes/languages/english.php

 

Around line 97 you will see the following code:

 

define('BOX_SHOPPING_CART_EMPTY', '0 items');

 

Just simply remove the zero as below:

 

define('BOX_SHOPPING_CART_EMPTY', ' items');

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