How to add a coupon to order automatically?

bob-hinrichs - July 8, 2009 - 00:22
Project:Ubercart Discount Coupons
Version:6.x-1.1
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello, under a certain condition, I need to have a coupon added automatically to an order, at the checkout form, or preferably reflected in the cart if that is possible. Tried a few things but having no luck. Is there any documentation, or a quick and easy description of how this is done? thank you.

#1

bob-hinrichs - July 8, 2009 - 15:37

Would this be the best method?

function my_module_checkout_pane() {
  $panes[] = array(
    'id' => 'team_coupon',
    'callback' => 'my_module_pane_coupon',
    'title' => t(' Special Discount'),
    'desc' => t(''),
    'weight' => 5,
    'process' => TRUE,
  );
  return $panes;
}

function my_module_pane_coupon($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
if ($codeinfo = validate_session_code()){
$arg1->data['coupon'] = $codeinfo->code;
uc_checkout_pane_coupon('view', $arg1, $arg2);
}
break;
}
}

#2

longwave - July 10, 2009 - 18:43
Status:active» fixed

If you use 6.x-1.x-dev, the code has been refactored a little, which makes this easier:

<?php
$coupon
= uc_coupon_validate($code);
if (
$coupon->valid) {
 
_uc_coupon_apply_to_order($order_id, $coupon);
}
?>

#3

System Message - July 24, 2009 - 18:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.