woocommerce/includes/class-wc-discount.php

83 lines
1.5 KiB
PHP
Raw Normal View History

2017-07-20 19:50:09 +00:00
<?php
2017-07-21 13:22:40 +00:00
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
2017-07-20 19:50:09 +00:00
/**
2017-07-28 12:02:39 +00:00
* A discount.
2017-07-20 19:50:09 +00:00
*
2017-07-28 12:02:39 +00:00
* Represents a fixed, percent or coupon based discount calculated by WC_Discounts class.
2017-07-20 19:50:09 +00:00
*
* @author Automattic
* @package WooCommerce/Classes
* @version 3.2.0
* @since 3.2.0
*/
class WC_Discount {
2017-07-20 19:50:09 +00:00
/**
* Data array, with defaults.
*
* @var array
*/
protected $data = array(
'amount' => 0, // Discount amount.
2017-07-28 15:17:57 +00:00
'discount_type' => 'fixed', // Fixed, percent, or coupon.
'discount_total' => 0,
2017-07-20 19:50:09 +00:00
);
2017-07-21 13:22:40 +00:00
/**
* Get discount amount.
*
* @return int
2017-07-21 13:22:40 +00:00
*/
public function get_amount() {
return $this->data['amount'];
2017-07-20 19:50:09 +00:00
}
/**
* Discount amount - either fixed or percentage.
*
* @param string $raw_amount Amount discount gives.
2017-07-20 19:50:09 +00:00
*/
2017-07-21 13:22:40 +00:00
public function set_amount( $raw_amount ) {
$this->data['amount'] = wc_format_decimal( $raw_amount );
2017-07-20 19:50:09 +00:00
}
/**
2017-07-21 13:22:40 +00:00
* Get discount type.
*
* @return string
2017-07-20 19:50:09 +00:00
*/
public function get_discount_type() {
return $this->data['discount_type'];
2017-07-21 13:22:40 +00:00
}
2017-07-20 19:50:09 +00:00
2017-07-21 13:22:40 +00:00
/**
* Set discount type.
*
* @param string $discount_type Type of discount.
2017-07-21 13:22:40 +00:00
*/
public function set_discount_type( $discount_type ) {
$this->data['discount_type'] = $discount_type;
2017-07-20 19:50:09 +00:00
}
/**
* Get discount total.
*
* @return int
*/
public function get_discount_total() {
return $this->data['discount_total'];
}
2017-07-20 19:50:09 +00:00
/**
* Discount total.
2017-07-20 19:50:09 +00:00
*
* @param string $total Total discount applied.
2017-07-20 19:50:09 +00:00
*/
public function set_discount_total( $total ) {
$this->data['discount_total'] = wc_format_decimal( $total );
}
2017-07-20 19:50:09 +00:00
}