I am getting burned out, still can't figure this out. I have been trying to use the coupon module for a special free item discount. But when giving somebody a code for a free item, it makes sense to also provide free shipping (these will mostly be for friends and family as gifts).
Now, I know that you can use the Flat Rate Shipping module for that. I already have. The problem is, this is a situation where I would only want the free shipping to be an option based on the fact that the order is free. When I set a conditional action to check the order total, it checks the Subtotal. This seems to be a part of Ubercart's functionality. So rather than screwing with that I opted to write some custom php that will check the order total (subtotal) and subtract the value of the coupon (and will return TRUE when the result is below a certain amount)
I still can't seem to find what will bring in the value of the coupon. Working with ubercart ver 6.x-2.2, and UC Coupon ver 6.x-1.3
This is what I have as far as code
$total = 0;
$coupon_result = //Whatever the value is supposed to be//;
foreach ($order->products as $product) {
$price = $product->qty * $product->price;
$total = $total + $price;
}
$total_result = $total - $coupon_result;
if ($total_result >= 0 && $total_result < 14) {
return TRUE;
}
If I enter a specific value as $coupon_result, then I am able to manipulate a TRUE, and the Free Shipping option activates. This has never really been my thing, but it's killing me that I can't figure this out. Any help with this would be greatly appreciated
***Also, this would probably be appreciated by anyone who was waiting for a response to http://drupal.org/node/276498. Free shipping seems to be in a number of dead and abandoned threads both here and on the ubercart forums
Comments
Comment #1
bbshopplf commented+1
Comment #2
longwaveIf you have an order object:
$coupon will be FALSE if the coupon was not found, or a coupon object.
$coupon->valuewill then contain the coupon value - but this could be a percentage or an amount, so you should check$coupon->typeas well.Comment #4
bartezz commentedHi longwave,
Sorry to open this one again. I use uc edi to export the orders of a shop I'm maintaining and I wanted to add the coupon details per order. uc_coupon_find() is great for this, but this works only for active coupons. So if I export and order after the coupon has expired the coupon details can't be fetched. Does that seem right to you?
Is this by design and is there another function to collect the coupon details without having to query the db myself?
Cheers