Needs review
Project:
UC Gift Certificate
Version:
6.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
26 Sep 2012 at 08:03 UTC
Updated:
22 Feb 2013 at 09:55 UTC
Jump to comment: Most recent
Bug: if you choose a gift certificate from your codes and this one doesn't cover your checkout value, the system deduces 2 time the same certificate.
This is my patch:
diff --git a/uc_gift_certificate.module b/uc_gift_certificate.module
index f1f0cf3..5ebc0a2 100644
--- a/uc_gift_certificate.module
+++ b/uc_gift_certificate.module
@@ -1526,11 +1526,14 @@ function uc_gift_certificate_attach(&$order, $certificate) {
*/
function uc_gift_certificate_calculate_deduction(&$order, $line_items = FALSE) { // Get order line items.
$total_certificates = 0;
-
+ $deduct = 0;
// If we are adding a new certificate at checkout, handle that first.
if (is_object($order->uc_gift_certificate_added)) {
// $new_certificate = $order->uc_gift_certificate_added;
$total_certificates += $order->uc_gift_certificate_added->remaining_value;
+ if($order->uc_gift_certificate_added->uid == $order->uid ) {
+ $deduct = $order->uc_gift_certificate_added->remaining_value;
+ }
// $order->uc_gift_certificate_used[$new_certificate->certificate_id] = $new_certificate;
//uc_order_line_item_add($order->order_id, 'gift_certificate', t('Gift Certificates'), -abs(floatval($new_certificate['remaining_value'])), 10, $certificate_data);
}
@@ -1538,7 +1541,7 @@ function uc_gift_certificate_calculate_deduction(&$order, $line_items = FALSE) {
$total_deducted = 0;
// @todo: Refactor this into the $order->uc_gift_certificate_used array somehow, so it's one less function call
- $total_certificates += uc_gift_certificate_total($order->uid);
+ $total_certificates += (uc_gift_certificate_total($order->uid) - $deduct );
$order_total = uc_order_get_total($order); // Order total may not be correct, so we need to recalculate it.
| Comment | File | Size | Author |
|---|---|---|---|
| uc_certificate_6_2_diff.txt | 1.57 KB | Admdebian |
Comments
Comment #1
Eranga commentedSame issue here.. I tried to find the function you have mentioned but there is no function called uc_gift_certificate_calculate_deduction(&$order, $line_items = FALSE)... in uc_gift_certificate.module file. I am using UC gift certificate 6.x-1.4.
Comment #2
rajeevgolePlease replace the line in the patch
if($order->uc_gift_certificate_added->uid == $order->uid ) {
with
if($order->uc_gift_certificate_added->user_id == $order->uid ) {