News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Coupon values incorrectly calculated

Started by Oliver Griffiths, April 10, 2008, 14:20:07 PM

Previous topic - Next topic

siesta

The above code doesn't seem to work for shipping... has someone tried it and shown it works?

I think the problem is because of the below part of the code around line 200 in the ps_coupon.php file. This seems to be written to set the coupon value to be equal to the total amount if the total value is less than the value of the coupon, which is why the shipping cannot be included. Is there a way around this so that shipping can be discounted by the coupon?

//$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
                 $coupon_value = round( ($d["total"] * $coupon_db->f("coupon_value") / 100), 2);
                 
                 if( $d["total"] < $coupon_value ) {
                     $coupon_value = (float)$d['total'];
                     $vmLogger->info( str_replace('{value}',$GLOBALS['CURRENCY_DISPLAY']->getFullValue( $coupon_value ),$VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')) );
                }

Logically it seems possible if the customer can enter the coupon code AFTER selecting their shipping method...

Mark Fabrizio

#16
Hi All-
I was having a similar problem here. I wanted the discount to be applied BEFORE the tax. I found that setting the configuration variable Subtract payment discount before tax/shipping? did not seem to do the trick. This appears to be because the store was setup to base Tax off the vendor location.
Anyway, I found a way to get this working. You basically need to ensure that the order_taxable takes into account the discount. In the latest version (1.1.2), I adjusted the administrator/components/com_virtuemart/classes/ps_checkout.php file (line 1483) - replaced:

$rate = $order_taxable * floatval( $db->f("tax_rate") );

with

if( !empty($_SESSION['coupon_discount']) && PAYMENT_DISCOUNT_BEFORE=="1"){
    $order_taxable -= $_SESSION['coupon_discount'];
}
$rate = $order_taxable * floatval( $db->f("tax_rate") );

Hope this helps someone else out.

Best Regards-
Mark Fabrizio Jr.
http://www.owlwatch.com

aravot

By "Subtract payment discount before tax/shipping?" we mean Product Discount and not coupon however it can be changed if someone is willing to provide a configuration option where user can select if coupon should be discount before or after tax.

louisangum

I was wondering if you had any luck finding the answer to your question regarding coupon code values deducted further along in the check out process?

I am having the same issue.  I have sold gift cards that are supposed to have values like $80.00, and if they want to just use $40 of it, it erases the value of the coupon and then to add insult to injury (to the customer), makes them pay for the shipping and on top of that adds sales tax to the shipping.

I may have to have my website rebuilt if there is no way to do this. I have lots of gift cards circulating and I am getting complaints from customers that feel gypped.

HELP!

Jeffrey Hughes

Here is a fix that worked for me http://forum.virtuemart.net/index.php?topic=56215.0

In the body of the first form posting is a link in the statement "Please visit my post here for the fix", this link will take you to the revised php code.

The post will recommend altering ps_checkout.php which is located in
/administrator/components/com_virtuemart/classes/ps_checkout.php

This is a major accomplishment and the word to this form needs to be spread throughout various VM Forms, please do so as you see people needing help on this issue.