VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: neo314 on December 21, 2012, 07:03:51 AM

Title: Total discount value
Post by: neo314 on December 21, 2012, 07:03:51 AM
In the invoice template, I would like to hide the discount column if there are no discounts on the order. Is $this->order_discount the total discount applied to the order and if not, is there a single value that I could test against for whether or not any discount has been applied to the order (coupon, quantity, etc.)?
Title: Re: Total discount value
Post by: bytelord on December 22, 2012, 00:32:15 AM
Hi,

You could create a template override for the the components\com_virtuemart\views\invoice\tmpl\invoice_items.php and just comment out the code you are don't need to displayed on invoices.

Regards
Title: Re: Total discount value
Post by: neo314 on December 22, 2012, 02:11:19 AM
Quote from: bytelord on December 22, 2012, 00:32:15 AM
Hi,

You could create a template override for the the components\com_virtuemart\views\invoice\tmpl\invoice_items.php and just comment out the code you are don't need to displayed on invoices.

Regards

Hi bytelord,

I'm already there. What I am trying to do in my override is test for whether any discounts exist. I assume that the discount column would show any quantity discounts, coupon discounts, shopper group discounts, etc. Correct?

If that is the case, instead of having to code a test for all the potential discount values before the output, I'm looking to see if a value already exists in the object that sums all the discounts to be applied. If there is a single value that is the sum of all the potential discounts, than I can simply test against that and hide the discount column if that value is zero.

Is order_discount a sum of all the discounts in the cart, or is there some other value that is the sum of all the discounts in the cart?

Thanks.
Title: Re: Total discount value
Post by: bytelord on December 22, 2012, 13:15:43 PM
Hello,

You have options in there, like per item

$item->product_subtotal_discount
$this->orderDetails['details']['BT']->order_discountAmount
$this->orderDetails['details']['BT']->coupon_discount
$this->orderDetails['details']['BT']->order_billDiscountAmount

use some if's over there to designed it as you wish
Title: Re: Total discount value
Post by: neo314 on December 22, 2012, 19:47:30 PM
Quote from: bytelord on December 22, 2012, 13:15:43 PM
Hello,

You have options in there, like per item

$item->product_subtotal_discount
$this->orderDetails['details']['BT']->order_discountAmount
$this->orderDetails['details']['BT']->coupon_discount
$this->orderDetails['details']['BT']->order_billDiscountAmount

use some if's over there to designed it as you wish

Do any of these values contain the sum of all discounts applied to the order? I know $this->order_discount is used and I do not see that in your list.
Title: Re: Total discount value
Post by: bytelord on December 22, 2012, 20:09:56 PM
$this->orderDetails['details']['BT']->order_billDiscountAmount)
Title: Re: Total discount value
Post by: neo314 on December 22, 2012, 20:18:04 PM
Quote from: bytelord on December 22, 2012, 20:09:56 PM
$this->orderDetails['details']['BT']->order_billDiscountAmount)

Perfect. Thanks.