/**
  * returns an Array of OrderItem IDs
  * to which the coupon applies
  * @param DiscountCouponOption
  * @return Array
  */
 protected function applicableProductsArray($coupon)
 {
     if (self::$_applicable_products_array === null) {
         self::$_applicable_products_array = array();
         $finalArray = array();
         $order = $this->Order();
         if ($order) {
             $items = $order->Items();
             if ($items && $items->count()) {
                 //get a list of all the products in the cart
                 $arrayOfProductsInOrder = array();
                 foreach ($items as $item) {
                     $buyable = $item->Buyable();
                     if ($buyable instanceof ProductVaration) {
                         $buyable = $buyable->Product();
                     }
                     $arrayOfProductsInOrder[$item->ID] = $buyable->ID;
                 }
                 //if no products / product groups are specified then
                 //it applies
                 //get a list of all the products to which the coupon applies
                 $productsArray = $coupon->Products()->map("ID", "ID")->toArray();
                 if (count($productsArray)) {
                     $matches = array_intersect($productsArray, $arrayOfProductsInOrder);
                     foreach ($matches as $buyableID) {
                         foreach ($arrayOfProductsInOrder as $itemID => $innerBuyableID) {
                             if ($buyableID == $innerBuyableID) {
                                 $finalArray[$itemID] = $itemID;
                             }
                         }
                     }
                 } else {
                     foreach ($arrayOfProductsInOrder as $itemID => $buyableID) {
                         $finalArray[$itemID] = $itemID;
                     }
                 }
             }
         }
         self::$_applicable_products_array = $finalArray;
     }
     return self::$_applicable_products_array;
 }