Esempio n. 1
0
 /**
  * Assigns to this Bf_Coupon a Bf_ProductRatePlan and Bf_Product.
  * @param union[string ($id | $name) | Bf_ProductRatePlan $ratePlan] The product discounted by the coupon. <string>: ID or name of the Bf_ProductRatePlan. <Bf_ProductRatePlan>: The Bf_ProductRatePlan.
  * @param union[string ($id | $name) | Bf_Product $entity | NULL] (Default: NULL) The product discounted by the coupon. <string>: ID or name of the Bf_Product. <Bf_Product>: The Bf_Product. <NULL>: Fetch first result for Bf_ProductRatePlan (if identifying rate plan by name, please ensure this rate plan's name is unique), and use its Bf_Product.
  * @return Bf_Coupon The modified coupon model.
  */
 public function setRatePlan($ratePlan, $product = NULL)
 {
     if (is_null($product)) {
         // get rate plan
         $ratePlanEntity = Bf_ProductRatePlan::fetchIfNecessary($ratePlan);
         $product = $ratePlanEntity->productID;
     }
     $productIdentifier = Bf_Product::getIdentifier($product);
     $ratePlanIdentifier = Bf_ProductRatePlan::getIdentifier($ratePlan);
     $this->product = $productIdentifier;
     $this->productRatePlan = $ratePlanIdentifier;
     return $this;
 }