WC_Discounts::get_discount()
Get discount by key with or without precision.
Method of the class: WC_Discounts{}
No Hooks.
Return
float
.
Usage
$WC_Discounts = new WC_Discounts(); $WC_Discounts->get_discount( $key, $in_cents );
- $key(string) (required)
- name of discount row to return.
- $in_cents(true|false)
- Should the totals be returned in cents, or without precision.
Default: false
Changelog
Since 3.2.0 | Introduced. |
WC_Discounts::get_discount() WC Discounts::get discount code WC 8.7.0
public function get_discount( $key, $in_cents = false ) { $item_discount_totals = $this->get_discounts_by_item( $in_cents ); return isset( $item_discount_totals[ $key ] ) ? $item_discount_totals[ $key ] : 0; }