Exemplo n.º 1
0
 /**
  * Set or load the discounts applied to this order
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @param ShoppDiscounts $ShoppDiscounts The ShoppDiscounts object from the order to add to this purchase
  * @return array List of discounts applied
  **/
 public function discounts(ShoppDiscounts $ShoppDiscounts = null)
 {
     if (empty($this->id)) {
         return false;
     }
     if (isset($ShoppDiscounts)) {
         // Save the given discounts
         $discounts = array();
         foreach ($ShoppDiscounts as $Discount) {
             $discounts[$Discount->id()] = new ShoppPurchaseDiscount($Discount);
         }
         shopp_set_meta($this->id, 'purchase', 'discounts', $discounts);
         $this->discounts = $discounts;
         ShoppPromo::used(array_keys($discounts));
     }
     if (empty($this->discounts)) {
         $this->discounts = shopp_meta($this->id, 'purchase', 'discounts');
     }
     return $this->discounts;
 }