Alpha /e and Coupon Contribution

46 replies [Last post]
Joined: 09/06/2007
Juice: 431

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

Joined: 08/07/2007
Juice: 15046

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.

Joined: 08/09/2007
Juice: 229

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

Joined: 09/08/2007
Juice: 205
Joined: 09/06/2007
Juice: 431

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

Joined: 08/23/2007
Juice: 77

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

Joined: 10/15/2007
Juice: 2

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

Joined: 09/06/2007
Juice: 431

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

Joined: 10/11/2007
Juice: 4

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;
  }
}
?>
Joined: 09/06/2007
Juice: 431

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?

Joined: 09/06/2007
Juice: 431

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

Joined: 09/06/2007
Juice: 431

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

Joined: 11/24/2007
Juice: 8

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

Joined: 10/11/2007
Juice: 4

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.

Joined: 08/29/2007
Juice: 55

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?

Joined: 09/06/2007
Juice: 431

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

Joined: 08/29/2007
Juice: 55

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

Joined: 09/06/2007
Juice: 431

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

Joined: 08/07/2007
Juice: 15046

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.

Joined: 09/06/2007
Juice: 431

it works, but not for him ...

Joined: 08/23/2007
Juice: 77

We need a nice and stable coupon module.

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

How much for the bounty?

Joined: 08/29/2007
Juice: 55

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

Joined: 09/06/2007
Juice: 431
<?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)
Guest's picture

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

Joined: 08/08/2007
Juice: 48

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

Joined: 09/06/2007
Juice: 431

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

Joined: 08/08/2007
Juice: 48

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

Guest (not verified)
Guest's picture

anybody?

Joined: 08/17/2007
Juice: 100

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.zip 13.46 KB
Joined: 08/17/2007
Juice: 100

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.zip 13.47 KB
Joined: 08/08/2007
Juice: 48

aswalla - Much much much thanks!!

Joined: 11/09/2007
Juice: 61

WOW IT WORKS!!

THANKS

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

------------------------------------------------------------------------------
Using the cart in WebARtSale.com -- a new site not yet in production
---------------------------------------------------------------------------

Joined: 08/14/2007
Juice: 3867

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.

Help directly fund development: Donate via PayPal!

Joined: 08/14/2007
Juice: 3867

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.

Help directly fund development: Donate via PayPal!

Guest (not verified)
Guest's picture

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?

realityloop (not verified)
Guest's picture

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)
Guest's picture

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.

Joined: 09/07/2007
Juice: 213

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?

Joined: 09/07/2007
Juice: 213

Anyone?

Joined: 09/04/2007
Juice: 110

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.

Joined: 08/14/2007
Juice: 3867

Excellent, thanks for the info.

Help directly fund development: Donate via PayPal!

Joined: 08/08/2007
Juice: 48

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.

Joined: 08/14/2007
Juice: 3867

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.

Help directly fund development: Donate via PayPal!

Joined: 11/24/2007
Juice: 8

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

Joined: 09/07/2007
Juice: 213

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

Joined: 08/14/2007
Juice: 3867

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

Help directly fund development: Donate via PayPal!

Joined: 09/07/2007
Juice: 213

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