Add a hook that allows modules to alter the discount codes or take action upon discount codes that are entered by the user. This will allow for things like automatically adding a discount code to an order based on custom conditions or automatically adding a product to an order based on a discount code.

Comments

jrust’s picture

Status: Active » Fixed

Added the hook. From the README:

/**
 * hook_uc_discounts_codes_alter() example
 *
 * Allows for the discount codes that a customer submits to be altered or for the order
 * to be altered based on the discount codes.
 *
 * @param $order Order object with uc_discounts_codes array set
 * @param $context Either 'js_calculate' or 'pane_submit'
 */
function mymodule_uc_discounts_codes_alter($order, $context) {
  // Do something if a certain code is entered
  foreach ($order->uc_discounts_codes as $code) {
    if (strtolower($code) == 'special_code') {
      // add another item to the cart, etc.
    }
  }
}

Status: Fixed » Closed (fixed)

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