1

I have multiple sites using the same ubercart module. One of the sites has a new discount that I need to add. If you buy 25 or more you get a 25% discount, if you buy 100 or more you get a 35% discount for example. I don't want to add a new module to ubercart as I don't want to mess with everything that's already working. Plus it's just this one discount on one specific item.

In going through the ubercart documentation, it looks like there are several hooks that may be useful. hook_add_to_cart, hook_line_item_alter and hook_order which are defined here. Am I travelling down the right path or is there another better way or already laid out example that would make piling through this a bit simpler?

1

After digging through various hooks and trying different things, this is what ended up working for me, which was actually pretty simple in the end.:

function hook_cart_item($op, &$item) {
    if ($op == 'load') {
        if ($item->nid == xxx && $item->model == 'xxxxxxxxxx') {
            if ($item->qty >= 100) {
                $item->price = round($item->price * .65,2);
            } else if ($item->qty >= 25) {
                $item->price = round($item->price * .75,2);
            }
        }    
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.