Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Discount Coupon Codes


kgt

Recommended Posts

Thanks for the quick response.. but thats the bit I'm stuck on... add the data... whats the data / variable called that I need to pass? or am I just horribly confused?

 

 

The API will tell you what the variable is called. You'll need two variables: the variable name your payment provider expects, and the DCC variable that holds the value you want. Once you find out whether your payment provider can take a discount line (if they can), then I will help you with getting the value that needs to be passed.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

The API will tell you what the variable is called. You'll need two variables: the variable name your payment provider expects, and the DCC variable that holds the value you want. Once you find out whether your payment provider can take a discount line (if they can), then I will help you with getting the value that needs to be passed.

 

Ok, I'm confused. With securehosting (http://www.oscommerce.com/community/contributions,569/category,1/search,securehosting)

 

you have the securehosting.php payment module. This file from what I understand takes the osc data (example below) and passes it to their secure payment page - (os_template.html)

 

tep_draw_hidden_field('shippingcharge', number_format($order->info['shipping_cost'], 2)) .

tep_draw_hidden_field('transactiontax', number_format($order->info['tax'], 2)) .

 

I have access to change both files... so I see no reason I can't display the discount amount.

 

If I were to add the following line, I can sucessfully get the actual cupon code to pass to the payment page.

 

tep_draw_hidden_field('discount', $order->info['coupon']) .

 

but thats as far as I can get at the moment... how do I get the amount?

 

Many thanks & sorry for Hijacking the thread

Link to comment
Share on other sites

Ok, I'm confused. With securehosting (http://www.oscommerce.com/community/contributions,569/category,1/search,securehosting)

 

you have the securehosting.php payment module. This file from what I understand takes the osc data (example below) and passes it to their secure payment page - (os_template.html)

 

tep_draw_hidden_field('shippingcharge', number_format($order->info['shipping_cost'], 2)) .

tep_draw_hidden_field('transactiontax', number_format($order->info['tax'], 2)) .

 

I have access to change both files... so I see no reason I can't display the discount amount.

 

If I were to add the following line, I can sucessfully get the actual cupon code to pass to the payment page.

 

tep_draw_hidden_field('discount', $order->info['coupon']) .

 

but thats as far as I can get at the moment... how do I get the amount?

 

Many thanks & sorry for Hijacking the thread

 

That is exactly how you would add the field once you know the name expected by the securehosting API. The fields 'shippingcharge', 'transactiontax', etc are fields you would find in the securehosting API. Your payment gateway will not just take any field willy-nilly. They must be expecting certain fields, and those fields must have certain names. Their API is the document that tells you which fields they accept and what they call them.

 

So before you even look in osCommerce code, you must find out from securehosting whether or not they can accept a discount line, and if they do, what it needs to be called. You can normally find out this information by requesting an API document from them. Their tech support people will know what this means.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

ok, so if they won't accept any field willy-nilly how come I can get the discount code to display already using -

 

tep_draw_hidden_field('discount', $order->info['coupon']) .

 

All I'm trying to do is get the discount code displayed on the screen where credit card details are entered. I dont need it to be processed at all.

 

Many thanks

Edited by knott
Link to comment
Share on other sites

ok, so if they won't accept any field willy-nilly how come I can get the discount code to display already using -

 

tep_draw_hidden_field('discount', $order->info['coupon']) .

 

All I'm trying to do is get the discount code displayed on the screen where credit card details are entered. I dont need it to be processed at all.

 

Many thanks

 

They may accept a discount, and they may call it 'discount'. Otherwise, I can't really know what you mean by 'display'. Display where? If you don't want it processed, then please describe exactly what you're looking for. I'm not sure where you're trying to put this.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Dear All,

 

Thanks for this amazing contribution. I installed carefully within 45 minutes by reading all steps twice without any fatal error.

 

But,

 

When i enter invalid codes or used codes, I don't receive any error message on the site except URL. I read the previous messages where this may be due to installed template on default oscommerce. There are some other messages also which didn't replied.

 

the error_message is

******/checkout_payment.php?error_message=The+coupon+code+you+have+entered+is+not+valid.

******/checkout_payment.php?error_message=Our+records+show+that+you+have+used+this+coupon+1+time%28s%29.++You+may+not+use+this+code+more+than+1+time%28s%29.

 

kgt replied one of the messages,

 

"...as due to templates, the default warning messages were disabled..."

 

but I am still receiving some warning messages like below with my templated osc ms2.2,

8b5.jpg

091.jpg

SO, IS IT POSSIBLE TO RECEIVE THIS KIND OF WARNING MESSAGES WITH THIS CONTRIBUTION ?

(I actually don't know which kind of warning message is appearing since I see only in the url.)

 

Thanks a lot...

 

I am still brainstorming about the problem above ? Are there anyone face the same problem ?

What should I do, I can't receive the error messages except the URL ?

 

Any help is highly appreciated.

Link to comment
Share on other sites

I am still brainstorming about the problem above ? Are there anyone face the same problem ?

What should I do, I can't receive the error messages except the URL ?

 

Any help is highly appreciated.

 

I already responded to this post:

 

http://www.oscommerce.com/forums/index.php?sho...019&st=860#

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Sorry for the confusion.

 

If you have time the best way would be to look at my store

http://www.abacus-ise.co.uk/shop

 

When you order, the final screen where you enter creditcard details is on the securehosting server. This screen does not display the discount amount so it looks a little odd (the previous screen in osc does).

eg 10% discount

item 1 £50

item 2 £50

 

sub £90 (although correct, looks odd?)

 

 

so all I would like to do is put the discount amount in just above the sub.

currently i have it working so it shows the discount code as I cant work out how to get the amount there.

Thats it. secure hosting dont need to process this... it just needs to be displayed so it makes the maths look correct.

Link to comment
Share on other sites

Sorry for the confusion.

 

If you have time the best way would be to look at my store

http://www.abacus-ise.co.uk/shop

 

When you order, the final screen where you enter creditcard details is on the securehosting server. This screen does not display the discount amount so it looks a little odd (the previous screen in osc does).

eg 10% discount

item 1 £50

item 2 £50

 

sub £90 (although correct, looks odd?)

so all I would like to do is put the discount amount in just above the sub.

currently i have it working so it shows the discount code as I cant work out how to get the amount there.

Thats it. secure hosting dont need to process this... it just needs to be displayed so it makes the maths look correct.

 

 

Despite the fact that it looks like you should be able to just display this value, I can tell you for certain that it is not. Securehost MUST accept a order total line like this in their API. If they do not, you cannot display it as such.

 

Most osCommerce users run into this issue when using Paypal. Paypal has two settings for this display page: aggregate and itemized. Itemized is similar to the display screen you have: it lists the items, the tax and shipping, and the total. Paypal does not have the ability to list a discount line, so their itemized screen looks exactly like yours when a discount is used. The aggregate function will accept and display the order total only.

 

In all probability, your payment provider cannot accept a discount line. As unbelievable as it may seem, the screen displayed is actually using strict guidelines as to which fields can be accepted, what they mean, and the expected values. This is made to work with osCommerce, but you are very limited in the amount to which this screen can be customized. This is where adding a new field/line "willy-nilly" comes in. If they do not already have the ability to accept a discount line on this screen, you CANNOT add one in.

 

If you contact their technical support and ask for an API, that document will tell you for sure whether a discount line is possible or not.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi

 

Thanks for the reply.

I've called securehosting and they confirm they dont use an application program interface & I can pass any information I like to the payment screen.

 

All I need to know is the name (variable?) of the information I want to pass.

 

many thanks

Graeme

 

did you get a chan

Link to comment
Share on other sites

Hi

 

Thanks for the reply.

I've called securehosting and they confirm they dont use an application program interface & I can pass any information I like to the payment screen.

 

All I need to know is the name (variable?) of the information I want to pass.

 

many thanks

Graeme

 

did you get a chan

 

 

If you can pass any information you like, then I can't tell you why it's not working. It has to do with their system.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Because I dont know the variable? name that contains the discount amount.

 

Like I said, I have found the name for the cupon, but not the amount of discount.

 

 

It would be something like this (Taken directly from ot_discount_coupon.php):

 

global $order, $currencies;
  if( is_object( $order->coupon ) ) {

	  //if the order total lines for multiple tax groups should be displayed as one, add them all together
	  if( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_LINES == 'false' ) $discount_lines = array( array_sum( $order->coupon->applied_discount ) );
			else $discount_lines = $order->coupon->applied_discount;

		foreach( $discount_lines as $tax_group => $discount ) {
		  if( $discount > 0 ) {
			$display_type = ( MODULE_ORDER_TOTAL_DISCOUNT_COUPON_DISPLAY_TYPE == 'true' ? '-' : '' );
			$this->output[] = array('title' => $order->coupon->format_display( $tax_group ) . ':',
									'text' => $display_type.$currencies->format( $discount, true, $order->info['currency'], $order->info['currency_value'] ),
									'value' => $display_type.$discount);
		  }
		}
	  }

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

You must add this code either to your header file or directly to checkout_payment.php:

 

<?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
 }

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

 

What I find strange is that this code is already in my catalog/include/header.php file but the error messages do not show up.

 

So I added this code to my /catalog/checkout_payment file and now the error messages work. Has anyone else seen this?

 

I'm using the Simple Template System v4.3 - is this having an effect on how the header.php file is included maybe?

 

Bill

Link to comment
Share on other sites

What I find strange is that this code is already in my catalog/include/header.php file but the error messages do not show up.

 

So I added this code to my /catalog/checkout_payment file and now the error messages work. Has anyone else seen this?

 

I'm using the Simple Template System v4.3 - is this having an effect on how the header.php file is included maybe?

 

Bill

 

When you use a template, the header file is usually ignored. That is one of the reasons templates are so confusing to people. The original files are there, but they are not used to generate the actual content you see. Your true header is generated elsewhere. (Don't ask me where - it depends on your template!)

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

When you use a template, the header file is usually ignored. That is one of the reasons templates are so confusing to people. The original files are there, but they are not used to generate the actual content you see. Your true header is generated elsewhere. (Don't ask me where - it depends on your template!)

 

Interesting.

 

I'll have a little hunt around on the Simple Template System support thread and see if I can find out what's happening.

 

Thanks for the insight.

 

Bill

Link to comment
Share on other sites

ok this may get my head bitten off, but any chance you could give a rough idea of when the new version will be ready. Just an idea of whether its going to be in the next few days or longer is all I need..

 

We're planning on using this contribution (looks really great BTW), and just working out whether its worth waiting for the new one or going ahead and upgrading later.

 

I realise you probably hate being hassled about this, but if could just say whether you expected to release it this week, that would be great..

 

Thanks!

Link to comment
Share on other sites

ok this may get my head bitten off, but any chance you could give a rough idea of when the new version will be ready. Just an idea of whether its going to be in the next few days or longer is all I need..

 

We're planning on using this contribution (looks really great BTW), and just working out whether its worth waiting for the new one or going ahead and upgrading later.

 

I realise you probably hate being hassled about this, but if could just say whether you expected to release it this week, that would be great..

 

Thanks!

 

 

I had hoped to release it two weeks ago. I am slammed with work right now (have been since December). There are some issues with it that are taking a lot of time to work out because I don't have much time to devote to it.

 

The answer is, I don't know, and I will not know until the day I post it.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Hi,

 

I seem to be getting some sort of rounding error on tax when using coupon codes, anyone able to point me in the right direction ?

 

An example of the problem is

 

Sub-Total: £2,068.90

Flat Rate (Best Way): £4.95

Discount Coupons:01745e: -£311.08

EU VAT rate at 17.5%: £308.87

Total: £1,762.77

 

If my calculator is working, 17.5% of £1,762.77 is £308.48

 

I'm using the default sort order in the order totals module and tax recalcultion required.

 

Regards

John

Link to comment
Share on other sites

Hi,

 

I seem to be getting some sort of rounding error on tax when using coupon codes, anyone able to point me in the right direction ?

 

An example of the problem is

 

Sub-Total: £2,068.90

Flat Rate (Best Way): £4.95

Discount Coupons:01745e: -£311.08

EU VAT rate at 17.5%: £308.87

Total: £1,762.77

 

If my calculator is working, 17.5% of £1,762.77 is £308.48

 

I'm using the default sort order in the order totals module and tax recalcultion required.

 

Regards

John

 

Not sure if this is the issue, since I haven't installed the contribution yet, but the common_problems.txt file (in the root of the contribution folder) includes this:

 

Problem:

The Discount Applied order total line shows an incorrect discount amount for

the order subtotal. (Only happens on some orders and amount is off by no more

than a few cents.)

 

Solution:

There isn't really one. The discount is applied before tax, and OSC allows

for multiple tax groups in each order. This means the discount percentage

must be applied to each line item in the order, taking into account the tax

rate for that item. Rounding can then cause the Discount Applied line to be a

few cents off of the actual discount percentage for the Sub-Total line.

 

The discount is not actually taken from the order Sub-Total, even though it

may appear as though it is. If you have configured your store to display

prices with taxes or you have configured your Discount Coupon Codes module to

display the order Sub-total without the discount applied, then your likelihood

of running into this situation is slightly higher.

Edited by ytswy
Link to comment
Share on other sites

Hi,

 

I seem to be getting some sort of rounding error on tax when using coupon codes, anyone able to point me in the right direction ?

 

An example of the problem is

 

Sub-Total: £2,068.90

Flat Rate (Best Way): £4.95

Discount Coupons:01745e: -£311.08

EU VAT rate at 17.5%: £308.87

Total: £1,762.77

 

If my calculator is working, 17.5% of £1,762.77 is £308.48

 

I'm using the default sort order in the order totals module and tax recalcultion required.

 

Regards

John

 

Comment out line 116 of includes/classes/discount_coupon.php and see if that helps. If not, you need to include your product prices above. The discount is taken off of individual products, so showing the subtotal is not enough.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I have install Discount Coupon Codes following your Install instructions and all appears to be fine.

 

When I Installed the Discount Coupon Order Total Module I started asking myself a few questions, I've spent a few hours in this forum but I can't find the answers, I'm probably missing something obvious but I'm not expert with osCommerce or phpMyAdmin.

 

Question 1: When I added the length for randomly generated coupon codes I wondered how does it know what is a correct discount code and what is a false code? Is there somewhere I'm supposed to set this?

 

Question 2: When I set the display format for the order total line I told it I wanted it to calculate a percentage of the order. Where does it get that percentage information from? I want it to deduct 10% of the order cost.

 

If anyone can help answers these questions it would be appreciated.

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