Exemplo n.º 1
0
 /**
  * Return the price for the product + the price difference applied by selected product options.
  * If the product is a subscription this price includes both the one time fee and the first 
  * subscription payment if the subscription start date is today.
  * 
  * @param boolean $includeFirstSubscription
  * @return float Price of product
  */
 public function getProductPrice()
 {
     if ($this->_productId < 1) {
         return false;
     }
     $product = new Cart66Product($this->_productId);
     if ($this->isPayPalSubscription()) {
         $price = $product->getCheckoutPrice();
     } elseif ($this->isSpreedlySubscription()) {
         $price = $product->getCheckoutPrice();
     } elseif ($product->is_user_price == 1 || $product->gravity_form_pricing) {
         $session_var_name = "userPrice_{$this->_productId}";
         if ($product->gravity_form_pricing) {
             $session_var_name .= '_' . $this->getFirstFormEntryId();
         }
         //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Looking for product price in session variable: " . $session_var_name . "\n" .
         //  print_r(Cart66Session::dump(), true));
         if (Cart66Session::get($session_var_name)) {
             // using a user-defined price
             $userPrice = Cart66Session::get($session_var_name);
             if ($product->min_price > 0 && $userPrice < $product->min_price) {
                 $userPrice = $product->min_price;
             }
             if ($product->max_price > 0 && $userPrice > $product->max_price) {
                 $userPrice = $product->max_price;
             }
             $price = $userPrice;
         } else {
             $price = $product->price;
         }
     } else {
         $price = $product->getCheckoutPrice() + $this->_priceDifference;
     }
     return $price;
 }