Alpha /e and Coupon Contribution

Posts: 203
Joined: 09/06/2007

@Ryan,

I just vae updated to 7e and it causes me 2 issues with coupons contribution!!!

first it told me that there is now undefined function call for uc_cart_new_pane, then i removed the new and it worked but now i get Fatal error: Call to undefined function uc_cart_checkout_next_button() in modules/uc_coupon/uc_coupon.module on line 473

have you changed function names in core? It seems that the next button for coupon no longer cen be set up in order to enter a 2nd coupon?

Posts: 4379
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Yep, the order status and checkout pane APIs have been changed. It's up to the maintainer of that module to fix it, but he may just be busy with other projects. I'm pretty sure I've posted fixes for that module elsewhere in the forums.

Posts: 79
Joined: 08/09/2007
Bug Finder

Where can we find the latest version of the coupon module? I didn't see it in the contributions. We might be able to update it.

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 85
Joined: 09/08/2007
Bug Finder
Posts: 203
Joined: 09/06/2007

is that already for version 7e??? check the release dates, doubt it...

Posts: 29
Joined: 08/23/2007

Oh hi, I'm here for the update. Eye-wink

Posts: 1
Joined: 10/15/2007

Are there any time scales on an update to coupon module, for 7e?

Really looking to get my new site up and running but it is core to the running and also to the marketing.

cheers

James

Posts: 203
Joined: 09/06/2007

i emailed the author, and hope he got now time by now ...

Posts: 6
Joined: 10/11/2007

I'm no developer, but after looking at the new (alpha 7e) uc_cart_checkout_pane.inc, I made changes to the coupon module's uc_checkout_pane_coupon function that appear to work from my limited testing:

Here's what I changed the uc_checkout_pane_coupon function to:

<?php
function uc_checkout_pane_coupon($op, $arg1, $arg2) {
  switch (
$op) {
    case
'view':
     
$description = t('Enter your coupon here.');
     
$contents['coupon'] = uc_textfield(t('Coupon Code'), $arg1->couponCode, FALSE, FALSE, 14);             
    
      return array(
'description' => $description, 'contents' => $contents);

    case
'process':
     
$arg1->coupon = check_plain($arg2['coupon']);
      return
true;
  }
}
?>

Posts: 203
Joined: 09/06/2007

Appears to work Cool did you get at first also 2 error messages one about the next button function and then also about another which I stripped of or added "_new" in the function' name?

Right now, you enter a coupon (just one?) and then you go from checkout to the next order screen and there then it is told if the coupon is ok or not, else please go back ...

anybody with the same results?

Posts: 203
Joined: 09/06/2007

right now it seems not even valird coupons are accepted?

 

$arg1->coupon = check_plain($arg2['coupon']);
      return true;
 

it looks like as if $arg1->coupon is empty????? Anybody! Puzzled

Posts: 203
Joined: 09/06/2007

Subtotal: €193,00
Coupon Discount: 'coupon 111': -€44,00
Total: €149,00

Smiling

works ...

PS: anybody trouble with the used coupon not deactivated and that you can re-use it in a subsequent order??

Posts: 6
Joined: 10/11/2007

I got the 2 errors messages, yes, but after rewriting the above, they were fixed.

And yes, the coupon discount is applied after the user enters a code and clicks 'Review order' -- in the table, it shows the discount coupon used and its discount.

Posts: 24
Joined: 08/29/2007

The fix above got the coupons themselves working, but the report isn't showing any coupon usage. Anyone know how to fix the coupon usage report?

Posts: 203
Joined: 09/06/2007

do you get any error msg or a merely blank screen?

Posts: 24
Joined: 08/29/2007

No errors... just a blank report with no data.

Posts: 203
Joined: 09/06/2007

Hmmm, but the rest of the coupon system works fine? you can active and use coupons? have you logged in and back out again, clear some cache. Maybe that helps...

RYAN? Cool

Posts: 4379
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Sorry, I don't really have time to debug this. Sticking out tongue I know Blake has been busy, but maybe for the proper amount of cash he'd get it done. You can always come together on a bounty for him.

Posts: 203
Joined: 09/06/2007

it works, but not for him ...

Posts: 29
Joined: 08/23/2007

We need a nice and stable coupon module.

Buy one get one free needs to be implemented as well.

How much for the bounty?

Posts: 24
Joined: 08/29/2007

I'll be happy to pitch in for the bounty, for a functional coupon report.

Posts: 203
Joined: 09/06/2007

<?php
/**
* Output Coupon Reports
*/
function uc_coupon_reports($start = null, $end = null) {
 
drupal_add_css(drupal_get_path('module', 'uc_coupon') .'/reports.css', 'uc_coupon');
 
$output .= drupal_get_form('uc_coupon_reports_form', $start, $end);
 
// gather all the coupon data from the time period specified

 
if (isset($start) && isset($end)) {
   
$query = db_query("SELECT co.cid, co.oid, co.value, co.code, o.order_total, o.created FROM {uc_coupons_orders} AS co LEFT JOIN {uc_orders} AS o ON (co.oid = o.order_id) WHERE o.order_status > 0 AND o.created > %d AND o.created < %d ORDER BY co.cid, o.created ASC",$start, $end);

   
$row_header = array('Order #', 'Date Purchased', 'Order Value', 'Coupon Value');
   
$last_cid = 0;
   
    while (
$row = db_fetch_object($query)) {
     
// Display the table of coupons if this is the next set of coupons
     
if ($row->cid != $last_cid AND $last_cid != 0) {
   
$td[] = array('', '<b>Uses: '. $num_uses .'</b>', '<b>$'. number_format($coupon_sale_amount,2) .'</b>', '<b>$'. number_format($coupon_amount,2) .'</b>');
       
$data .= theme('table', $row_header, $td, array('width' => '100%'));
       
$td = array();
       
$num_uses = 0;
       
$coupon_amount = 0;
       
$coupon_sale_amount = 0;
      }
     
// if this is the first coupon of the set display the header first
     
if ($row->cid != $last_cid || $last_cid = 0) {
       
$data .= '<div class="totals"> Coupon Code: '.l($row->code,'admin/store/customers/coupon/'. $row->cid . '/edit') .'</div>';
      }
     
$td[] = array(l('#'. $row->oid, 'admin/store/orders/'. $row->oid), date('m/d/Y', $row->created), '$'. number_format($row->order_total, 2), '$'. number_format($row->value,2));
     
$num_uses++;
     
$coupon_amount += $row->value;
     
$coupon_sale_amount += $row->order_total;
     
$last_cid = $row->cid;
     
$orders_total += $row->order_total;
     
$coupons_total += $row->value;
    }
   
$td[] = array('', '<b>Uses: '. $num_uses .'</b>', '<b>$'. number_format($coupon_sale_amount,2) .'</b>', '<b>$'. number_format($coupon_amount,2) .'</b>');
   
$data .= theme('table', $row_header, $td, array('width' => '100%'));

   
$output .= '<h2>Coupon Usage report</h2>'
   
$output .= $data;
   
$output .= '<br><table width="100%"><tr><td></td><td><b>Coupons Used: '. db_num_rows($query) .'</td><td>Orders Value: $'. $orders_total .'</td><td>Coupons Value: $'. $coupons_total .'</tr></tr></table>';
   
  }
  return
$output;   
}
?>

Full Texts  cuid cid oid value user role code
Edit Delete 1 18 27 85.00 0 0 code1
Edit Delete 2 56 75 44.00 0 0 code2
Edit    Delete 3 61 76 29.70 0 0 code3
Edit Delete 4 63 82 49.00 0 0 code4
Edit Delete 5 63 83 49.00 0 0 code5
Edit Delete 6 64 85 49.00 0 0 code6
Edit Delete 7 64 88 49.00 0 0 code7
Edit Delete 8 63 90 49.00 0 0 code8
Edit Delete 9 63 91 49.00 0 0 code9

this is my table of coupons used in orders and i also get a blnak page!! Evil Ok, we should get this done though without having to pay cash Eye-wink

#1 start it with fixed dates
#2 alter the sql to basically just show them all to see where the error is, meaning a simple sql code to just show something from the one table

#3 then check if it still counts correct ...

Post your results here!

Guest (not verified)

So we don't have a working coupon module for 7e yet? :\

Posts: 20
Joined: 08/08/2007

It works with the fix mentioned earlier in this post (the first batch of code you see on the thread). We just don't have a functional report... I've emailed Blake about this and have yet to hear from him. No biggie, tho, because our customers are happy to get their discounts Smiling

Posts: 203
Joined: 09/06/2007

i would say the code is not that hard to fix.. i may look into it the next days or so ... too bad there are not more willing to help many with this!!! Sad

Posts: 2
Joined: 11/05/2007

Has anyone managed to get the coupon module working with latest Ubercart builds, or is this functionality going to be added to the Ubercart core any time soon?

I'd fix it myself, but I'm still very much a PHP newb..

Guest (not verified)

My coupon module has never stopped working, I'm on the latest dev build, (bazar update last night) and have the coupon modede installed from drupal site. I just did a test order, and all went though fine. I have my cart set with one long page, no next buttons, so this may be why mine is working fine.

Posts: 20
Joined: 08/08/2007

osilux, my code looks exactly the same as yours. We still don't know why the reports stopped working...

Guest (not verified)

mizru
"It works with the fix mentioned earlier in this post (the first batch of code you see on the thread). We just don't have a functional report... I've emailed Blake about this and have yet to hear from him. No biggie, tho, because our customers are happy to get their discounts"

You mean this?

http://www.ubercart.org/comment/5127/Re-Alpha-e-and-Coupon-Contribution

I tried this but maybe I didn't change something properly, where exactly would I add/change this?

Guest (not verified)

anybody?

Posts: 49
Joined: 08/17/2007
Getting busy with the Ubercode.Spreading the word - Ubercart for president.

you change it in the uc_coupon module. Start with the module located at: http://drupal.org/project/uc_coupon

Then do the modification by searching for the function "uc_checkout_pane_coupon".

I have also attached my modificed uc_coupon module.

Note that I too cannot get the reports working but I am also looking into it...The coupon is working on Ubercart v0.8 w/Drupal 5.3 for me.

-Aaron

AttachmentSize
uc_coupon.zip13.46 KB
Posts: 49
Joined: 08/17/2007
Getting busy with the Ubercode.Spreading the word - Ubercart for president.

I was able to get the coupon reports functioning again by changing sql query near line 594 in the uc_coupon module to:

$query = db_query("SELECT co.cid, co.oid, co.value, co.code, o.order_total, o.created FROM uc_coupons_orders AS co LEFT JOIN uc_orders AS o ON (co.oid = o.order_id) WHERE o.order_status >= 0 AND o.created > %d AND o.created < %d ORDER BY co.cid, o.created ASC",$start, $end);

I have also attached the modified uc_coupon module package.

Everyone - please let me know if this gets functioning for you as well as it appears to be working fine for me with ubercart v0.8

cheers - Aaron

AttachmentSize
uc_coupon_module.zip13.47 KB
Posts: 20
Joined: 08/08/2007

aswalla - Much much much thanks!!

Posts: 19
Joined: 11/09/2007

WOW IT WORKS!!

THANKS

...........................................
-------------------------------------------
USAindie.com -- film & music production
-------------------------------------------

--

------------------------------------------------------------------------------
Using the cart in USAindie.com -- film & music production
------------------------------------------------------------------------------

Posts: 1140
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

I like the module, but is there anyway we can make the "allowed users" an option to activate? Waiting for 18,000 users to load every time I want to add a coupon kinda stinks. Doesn't take a HUGE amount of time, but I think it's something that could be made more concise.

Perhaps a role-based option as well? Otherwise it looks great, will be testing this shortly.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 1140
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Hmm .. is there a reason why I can't make a coupon for 1.99? Our products usually cost x.99 and I like the idea of being able to "Use this coupon for a free track!" and not just a discount (as nice as that is).

Also, does the number of redemptions count per user? It looks like it does, but since I can't get a freebie yet (without hacking) I haven't been able to test. Will try modifying it to my needs and report back.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 104
Joined: 09/07/2007
Uber Donor

If you want all users to be able to use a coupon, would you just not select any users in the list? Does it default to all users?

Posts: 104
Joined: 09/07/2007
Uber Donor

Anyone?

Posts: 60
Joined: 09/04/2007

As far as I know, if you don't select any user, then the coupon is valid for anyone.
I tested it using alpha 7c and now 8. It's still the same regarding your question.

Posts: 1140
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Excellent, thanks for the info.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 20
Joined: 08/08/2007

torgosPizza: To make a coupon just for an amount, just select "Price" under "Discount Value Type" and in the "Value" field, type 1.99.

Now apparently in the coupon reports, it's reporting IN CHECKOUT orders as well as COMPLETED orders. Any ways to get rid of those IN CHECKOUT orders on the report? I'm running 7e.

Posts: 1140
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Price IS selected. When I enter, say, 2.99 for the dollar amount, and hit submit, the coupon comes back as 2.00. For some reason it is truncating or rounding. Haven't looked into it much. If I go in and edit the value in the database directly, it sticks, and of course the amount is deducted correctly. But it looks like some code in the "add coupon to the database" function is not working properly.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 8
Joined: 11/24/2007

Hiyah, I love Ubercart so far and have it on a new Dupal site: www.kristinit.com (our store area is hidden though)

The only hitch is that it doesn't apply coupons in the Review Order page after entering the correct coupon code in the Checkout page. I applied the code fixes in this thread to work with v.08, but it still doesn't take. Did I need to do something with Workflowng?

I'm using Drupal 5.3, Ubercart alpha8... I DID have e/Commerce installed for a couple of hours and didn't do a thorough database cleanse, in case that may interfere, but I don't think so.

Any help would be greatly appreciated...

Gary

Posts: 8
Joined: 11/24/2007

oslinux, did you get valid coupons to be accepted? It's not for me, I've applied the code fixes in this thread, but still no go. Thanks in advance for any tips...

Posts: 104
Joined: 09/07/2007
Uber Donor

torgosPizza, did you ever figure out how the redemptions field works?

Posts: 1140
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Redemptions? I think that field works fine. It's the setting of the coupon value in the admin that doesn't like the .99 cent value, for some reason. (Haven't tried with other values, yet).

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 104
Joined: 09/07/2007
Uber Donor

Sorry, I should have clarified: did you determine whether the field refers to total redemptions or to redemptions per user?